diff --git a/src/main/java/com/spring/modules/part/controller/PartInformationController.java b/src/main/java/com/spring/modules/part/controller/PartInformationController.java index 65b28bb6..b679de4d 100644 --- a/src/main/java/com/spring/modules/part/controller/PartInformationController.java +++ b/src/main/java/com/spring/modules/part/controller/PartInformationController.java @@ -749,8 +749,8 @@ public class PartInformationController { */ @PostMapping("/readPartFromFile") public R readPartFromFile(@RequestParam("file") MultipartFile file, @ModelAttribute GetParamInData data, @RequestParam("searchType") String searchType, - @RequestParam("partNos") String partNos, @RequestParam("limit") int limit, @RequestParam("page") int page){ - PageUtils list = partInformationService.readPartFromFile(file, data, searchType, partNos, limit, page); + @RequestParam("partNos") String partNos){ + PageUtils list = partInformationService.readPartFromFile(file, data, searchType, partNos); return R.ok().put("rows", list); } diff --git a/src/main/java/com/spring/modules/part/service/PartInformationService.java b/src/main/java/com/spring/modules/part/service/PartInformationService.java index c7e90bf7..d5479e7e 100644 --- a/src/main/java/com/spring/modules/part/service/PartInformationService.java +++ b/src/main/java/com/spring/modules/part/service/PartInformationService.java @@ -170,5 +170,5 @@ public interface PartInformationService { void deleteProjectPart(PlmProjectPartData data); - PageUtils readPartFromFile(MultipartFile file, GetParamInData data, String searchType, String partNos, int limit, int page); + PageUtils readPartFromFile(MultipartFile file, GetParamInData data, String searchType, String partNos); } diff --git a/src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java b/src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java index ebd5863c..aaf91816 100644 --- a/src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java +++ b/src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java @@ -23,6 +23,7 @@ import com.spring.modules.Tooling.mapper.ProjectToolingApplyMapper; import com.spring.modules.Tooling.service.ProjectToolingApplyService; import com.spring.modules.app.entity.UserEntity; import com.spring.modules.app.service.UserService; +import com.spring.modules.base.dao.BaseMapper; import com.spring.modules.base.data.*; import com.spring.modules.base.entity.Bu; import com.spring.modules.base.service.TransNoControlService; @@ -192,6 +193,9 @@ public class PartInformationServiceImpl extends ServiceImpl exceptionList = new ArrayList<>(); + List emptyPartNoRows = new ArrayList<>(); + List repeatPartNoRows = new ArrayList<>(); + List wrongBuNoRows = new ArrayList<>(); + List wrongIfsPartNos = new ArrayList<>(); List partList = new ArrayList<>(); + BuData buData = new BuData(); + buData.setSite(data.getOrderRef1()); + buData.setActive("Y"); + List buList = baseMapper1.getBUList(buData); + Map buMap = new HashMap(); + buList.forEach(bu -> { + buMap.put(bu.getBuNo(),bu.getBuDesc()); + }); + HashMap ifsPartNoMap = new HashMap<>(); try (InputStream is = file.getInputStream(); XSSFWorkbook workbook = new XSSFWorkbook(is)) { XSSFSheet sheet = workbook.getSheetAt(0); + limit = sheet.getLastRowNum(); Set partNoSet = new HashSet<>(); Set partNoSet1 = new HashSet<>(); @@ -4409,20 +4431,32 @@ public class PartInformationServiceImpl extends ServiceImpl list = new Page(page, limit); List list1 = new ArrayList<>(); for (PlmProjectPartData part : partList) { List list2 = getProjectPartList1(part).getList(); - if (list2.isEmpty()) continue; + if (list2.isEmpty()) { + wrongIfsPartNos.add(part.getFinalPartNo()); + continue; + } Object item = list2.get(0); PartInformationVo vo = (PartInformationVo)item; - vo.setCustomerPartNo(part.getCustomerPartNo()); vo.setBuNo(part.getBuNo()); - list1.add(vo) ; + vo.setBuDesc(buMap.get(part.getBuNo())); + vo.setCustomerPartNo(part.getCustomerPartNo()); + list1.add(vo); + } + if (flag){ + IPage list = new Page(page, limit); + list.setRecords(list1); + return new PageUtils(list); + }else { + IPage list = new Page(page, 4 *limit); + if (emptyPartNoRows.size()>0){ + String emptyPartNoRowsStr = "第" + emptyPartNoRows.stream().map(Object::toString).collect(Collectors.joining(",")) + "行料号为空!"; + exceptionList.add(emptyPartNoRowsStr); + } + if (repeatPartNoRows.size()>0){ + String repeatPartNoRowsStr = "第" + repeatPartNoRows.stream().map(Object::toString).collect(Collectors.joining(",")) + "行出现重复料号!"; + exceptionList.add(repeatPartNoRowsStr); + } + if (wrongBuNoRows.size()>0){ + String wrongBuNoRowsStr = "第" + wrongBuNoRows.stream().map(Object::toString).collect(Collectors.joining(",")) + "行数据的BU在系统中不存在!"; + exceptionList.add(wrongBuNoRowsStr); + } + if (wrongIfsPartNos.size()>0){ + String wrongIfsPartNosStr = "系统中不存在以下ifs物料编码:" + wrongIfsPartNos.stream().map(Object::toString).collect(Collectors.joining(",")) + "!"; + exceptionList.add(wrongIfsPartNosStr); + } + list.setRecords(exceptionList); + return new PageUtils(list); } - list.setRecords(list1); - return new PageUtils(list); } // 检查行是否为空的方法