From b0afd5f4aa964790c192f5ead0403a7d943e31bf Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Tue, 1 Mar 2022 11:59:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8F=82=E6=95=B0=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xkrs/controller/FileController.java | 4 ++-- .../xkrs/controller/PictureController.java | 5 +---- .../com/xkrs/controller/SpecController.java | 19 ++++++++----------- src/main/java/com/xkrs/dao/DataDictDao.java | 6 +++--- .../service/impl/DataSourceServiceImpl.java | 4 ++-- .../xkrs/service/impl/SpecServiceImpl.java | 5 +++-- .../java/com/xkrs/util/ExcelUploadUtil.java | 2 -- 7 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/xkrs/controller/FileController.java b/src/main/java/com/xkrs/controller/FileController.java index 88eda8f..d47dfec 100644 --- a/src/main/java/com/xkrs/controller/FileController.java +++ b/src/main/java/com/xkrs/controller/FileController.java @@ -43,7 +43,7 @@ public class FileController { * @throws IOException */ @PostMapping("/insertFileExcel") - public String insertFileExcel(FileQo fileQo, @RequestParam("fileExcel") MultipartFile fileExcel) throws IOException { + public String insertFileExcel(@RequestBody FileQo fileQo, @RequestParam("fileExcel") MultipartFile fileExcel) throws IOException { return fileService.insertFileExcel(fileQo, fileExcel); } @@ -57,7 +57,7 @@ public class FileController { */ @PostMapping("/updateFileUploadPath") @Transactional(rollbackOn = Exception.class) - public String updateFileUploadPath(FileUpdateQo fileUpdateQo, @RequestParam("fileExcel") MultipartFile fileExcel) throws IOException { + public String updateFileUploadPath(@RequestBody FileUpdateQo fileUpdateQo, @RequestParam("fileExcel") MultipartFile fileExcel) throws IOException { Locale locale = LocaleContextHolder.getLocale(); String file = ExcelUploadUtil.memoryFile(fileExcel); fileDao.updateFileUploadPath(fileUpdateQo.getLotNo(), fileUpdateQo.getMachineNo(), fileUpdateQo.getMaterialNo(), fileUpdateQo.getModelNo(), fileUpdateQo.getPartNo(), file); diff --git a/src/main/java/com/xkrs/controller/PictureController.java b/src/main/java/com/xkrs/controller/PictureController.java index 030287a..2683a7e 100644 --- a/src/main/java/com/xkrs/controller/PictureController.java +++ b/src/main/java/com/xkrs/controller/PictureController.java @@ -6,10 +6,7 @@ import com.xkrs.model.entity.PictureEntity; import com.xkrs.model.qo.PictureQo; import com.xkrs.service.PictureService; import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; diff --git a/src/main/java/com/xkrs/controller/SpecController.java b/src/main/java/com/xkrs/controller/SpecController.java index 8a1b718..937d40a 100644 --- a/src/main/java/com/xkrs/controller/SpecController.java +++ b/src/main/java/com/xkrs/controller/SpecController.java @@ -6,12 +6,11 @@ import com.xkrs.model.entity.SpecEntity; import com.xkrs.model.qo.SpecQo; import com.xkrs.service.SpecService; import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.Locale; +import java.util.Optional; import static com.xkrs.encapsulation.OutputEncapsulation.outputEncapsulationObject; @@ -34,22 +33,20 @@ public class SpecController { * @param specQo */ @PostMapping("/insertSpec") - public String insertSpec(SpecQo specQo) { + public String insertSpec(@RequestBody SpecQo specQo) { return specService.insertSpec(specQo); } /** * 查询规格信息 */ - @PostMapping("/selectSpec") - public String selectSpec(@RequestBody SpecQo specQo) { + @GetMapping("/selectSpec") + public String selectSpec(@RequestParam("partNo") String partNo, @RequestParam("inspectionItemCode") String inspectionItemCode) { Locale locale = LocaleContextHolder.getLocale(); - String partNo = specQo.getPartNo(); - String inspectionItemCode = specQo.getInspectionItemCode(); - SpecEntity specEntity = specDao.findByPartNoAndInspectionItemCode(partNo, inspectionItemCode).get(); - if (specEntity == null) { + Optional byPartNoAndInspectionItemCode = specDao.findByPartNoAndInspectionItemCode(partNo, inspectionItemCode); + if (byPartNoAndInspectionItemCode.isEmpty()) { return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该零件的规格信息!", locale); } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, specEntity, locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byPartNoAndInspectionItemCode.get(), locale); } } diff --git a/src/main/java/com/xkrs/dao/DataDictDao.java b/src/main/java/com/xkrs/dao/DataDictDao.java index 3979fab..f59496a 100644 --- a/src/main/java/com/xkrs/dao/DataDictDao.java +++ b/src/main/java/com/xkrs/dao/DataDictDao.java @@ -34,9 +34,9 @@ public interface DataDictDao extends JpaRepository, JpaSpecificat /** * 根据id修改字典的信息 * @param id - * @param chineseName + * @param inspectionItemName */ @Modifying(clearAutomatically=true) - @Query(value = "update data_dict set dict_chinese_name = ?2 where id = ?1",nativeQuery = true) - void updateDict(Integer id, String chineseName); + @Query(value = "UPDATE qc_inspection_item_dict SET inspection_item_name = ?2 where id = ?1",nativeQuery = true) + void updateDict(Integer id, String inspectionItemName); } diff --git a/src/main/java/com/xkrs/service/impl/DataSourceServiceImpl.java b/src/main/java/com/xkrs/service/impl/DataSourceServiceImpl.java index f482d86..9507998 100644 --- a/src/main/java/com/xkrs/service/impl/DataSourceServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/DataSourceServiceImpl.java @@ -39,8 +39,8 @@ public class DataSourceServiceImpl implements DataSourceService { public String insertDataSource(DataSourceQo dataSourceQo) { Locale locale = LocaleContextHolder.getLocale(); Optional byInspectionItemCode = dataDictDao.findByInspectionItemCode(dataSourceQo.getInspectionItemCode()); - if (byInspectionItemCode.isPresent()) { - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "已存在该字典类型!", locale); + if (byInspectionItemCode.isEmpty()) { + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "不存在该字典类型!", locale); } DataSource dataSource = new DataSource(); dataSource.setLotNo(dataSourceQo.getLotNo()); diff --git a/src/main/java/com/xkrs/service/impl/SpecServiceImpl.java b/src/main/java/com/xkrs/service/impl/SpecServiceImpl.java index 66fbb4b..f6e12a7 100644 --- a/src/main/java/com/xkrs/service/impl/SpecServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/SpecServiceImpl.java @@ -10,6 +10,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Locale; +import java.util.Optional; import static com.xkrs.encapsulation.OutputEncapsulation.outputEncapsulationObject; @@ -22,8 +23,8 @@ public class SpecServiceImpl implements SpecService { @Override public String insertSpec(SpecQo specQo) { Locale locale = LocaleContextHolder.getLocale(); - SpecEntity specEntity = specDao.findByPartNoAndInspectionItemCode(specQo.getPartNo(), specQo.getInspectionItemCode()).get(); - if (specEntity != null) { + Optional inspectionItemCode = specDao.findByPartNoAndInspectionItemCode(specQo.getPartNo(), specQo.getInspectionItemCode()); + if (inspectionItemCode.isPresent()) { return outputEncapsulationObject(PromptMessageEnum.DATA_EXIT, "已存在该测量规格!", locale); } SpecEntity specEntity1 = new SpecEntity(); diff --git a/src/main/java/com/xkrs/util/ExcelUploadUtil.java b/src/main/java/com/xkrs/util/ExcelUploadUtil.java index c498ddf..4e863f6 100644 --- a/src/main/java/com/xkrs/util/ExcelUploadUtil.java +++ b/src/main/java/com/xkrs/util/ExcelUploadUtil.java @@ -52,8 +52,6 @@ public class ExcelUploadUtil { String uploadsImage = uploadPath + newName; //实现上传 fileExcel.transferTo(new File(path)); - - return path; } return null;