diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java index 3e929fb1..7a53fc12 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java @@ -47,7 +47,7 @@ import java.util.concurrent.ExecutionException; @Api(tags = "原始BOM") @RestController @RequestMapping("bom/new/bomOriginal") -public class OriginalBomApi extends BaseApi { +public class OriginalBomApi extends BaseApi { @Resource BomNewOriginalParentService originalParentService; @@ -78,15 +78,16 @@ public class OriginalBomApi extends BaseApi { public ResultVO>> getChildTree(@RequestParam("rowId") Long rowId) throws ExecutionException, InterruptedException { return ResultVO.success(originalParentService.getChildTree(rowId)); } + @PostMapping("saveBom") @ApiOperation("编辑时-暂存") public ResultVO saveBom(@Valid @RequestBody OriginalSaveBomDTO bom) { - return ResultVO.success(originalParentService.saveBom(bom,false)); + return ResultVO.success(originalParentService.saveBom(bom, false)); } @PostMapping("saveSubmit") @ApiOperation("编辑时-提交") - public ResultVO saveSubmit(@Valid @RequestBody OriginalSaveBomDTO bom) { + public ResultVO saveSubmit(@Valid @RequestBody OriginalSaveBomDTO bom) { return ResultVO.success(originalParentService.saveSubmit(bom)); } @@ -120,6 +121,7 @@ public class OriginalBomApi extends BaseApi { /** * 原始BOM转EBom + * * @return */ @PostMapping("convertToEBom") @@ -128,7 +130,7 @@ public class OriginalBomApi extends BaseApi { public ResultVO convertToEBom(@RequestBody List bomRowIds) throws ExecutionException, InterruptedException { VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要转换的BOM"); - VUtils.isTure(bomRowIds.size()>20).throwMessage("你选择的BOM数据大于20"); + VUtils.isTure(bomRowIds.size() > 20).throwMessage("你选择的BOM数据大于20"); originalParentService.convertToEBom(bomRowIds); //更新物料使用 bomNewEbomChildMapper.updateEBomMaterialUse(); @@ -152,7 +154,7 @@ public class OriginalBomApi extends BaseApi { @ApiOperation("导入") @PostMapping("importBom") @Transactional(rollbackFor = Exception.class) - public ResultVO importBom(@RequestParam(value = "file")MultipartFile file) throws IOException { + public ResultVO importBom(@RequestParam(value = "file") MultipartFile file) throws IOException { if (file != null && !file.getOriginalFilename().endsWith("xls") && !file.getOriginalFilename().endsWith("xlsx")) { return ResultVO.error("请上传Excel文件"); } @@ -160,12 +162,7 @@ public class OriginalBomApi extends BaseApi { //计算层级 originalParentService.computeLevelNumAndRootState(); -// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { -// @Override -// public void afterCommit() { -// originalParentService.computeLevelNumAndRootState(); -// } -// }); + return ResultVO.success(true); } @@ -174,18 +171,18 @@ public class OriginalBomApi extends BaseApi { @ApiOperation("新增物料") @GetMapping("testaddMaterial") @Transactional(rollbackFor = Exception.class) - public ResultVO testaddMaterial(@RequestParam(value = "drawingNo" ,required = false)String drawingNo, - @RequestParam(value = "materialName" ,required = false)String materialName, - @RequestParam("materialCategoryCode")String materialCategoryCode) throws IOException { + public ResultVO testaddMaterial(@RequestParam(value = "drawingNo", required = false) String drawingNo, + @RequestParam(value = "materialName", required = false) String materialName, + @RequestParam("materialCategoryCode") String materialCategoryCode) throws IOException { - materialService.addMaterial(drawingNo, materialName,materialCategoryCode); + materialService.addMaterial(drawingNo, materialName, materialCategoryCode); return ResultVO.success("true"); } @ApiOperation("获取sessionKey") @GetMapping("getSessionKey") - public ResultVO getSessionKey() { + public ResultVO getSessionKey() { return ResultVO.success(SessionUtil.getSessionKey()); @@ -196,19 +193,16 @@ public class OriginalBomApi extends BaseApi { @PostMapping("testImportBom") @Transactional(rollbackFor = Exception.class) public ResultVO testImportBom() throws IOException { - InputStream inputStream=new FileInputStream("C:\\Users\\01956\\Desktop\\西卡印尼烘干线总站BOM.xlsx"); + InputStream inputStream = new FileInputStream("C:\\Users\\01956\\Desktop\\西卡印尼烘干线总站BOM.xlsx"); originalParentService.importBomTest(inputStream); - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { - @Override - public void afterCommit() { - originalParentService.computeLevelNumAndRootState(); - } - }); + + // originalParentService.computeLevelNumAndRootState(); + + originalParentService.computeLevelNumAndRootState(); + return ResultVO.success(true); } - - } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewOriginalParentMapper.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewOriginalParentMapper.java index 73d0b69c..8d0f215b 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewOriginalParentMapper.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewOriginalParentMapper.java @@ -33,5 +33,8 @@ public interface BomNewOriginalParentMapper extends BaseMapper saveEnts = bom.getBomList().stream().filter(u -> u.getDelIs().equals(0)).collect(Collectors.toList()); List childEntities = Convert.toList(BomNewOriginalChildEntity.class, saveEnts); // originalChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id",bom.getParentRowId())); childEntities.forEach(u -> { u.setParentRowId(bom.getParentRowId()); - if(submitIs){ + if (submitIs) { u.setEditStatus(OriginalEditStatusEnum.HANDLER_FINISHED.getValue()); } }); if (CollUtil.isNotEmpty(childEntities)) { //删除行 - List delRowIds = bom.getBomList().stream().filter(u->u.getRowId()>0).map(u-> u.getRowId()).collect(Collectors.toList()); - originalChildService.getBaseMapper().delOriginalChildNotInRowIds(delRowIds,bom.getParentRowId()); + List delRowIds = bom.getBomList().stream().filter(u -> u.getRowId() > 0).map(u -> u.getRowId()).collect(Collectors.toList()); + originalChildService.getBaseMapper().delOriginalChildNotInRowIds(delRowIds, bom.getParentRowId()); originalChildService.saveOrUpdateBatch(childEntities); } return true; @@ -128,7 +129,7 @@ public class BomNewOriginalParentService extends ServiceImpl bomDetail = this.getBaseMapper().getParentChild(bom.getRowId()); OriginalBomDetailTask detailTask = new OriginalBomDetailTask(bomDetail); detailTask.setLevelNum(1); @@ -284,16 +285,18 @@ public class BomNewOriginalParentService extends ServiceImpl { - try { - this.getBaseMapper().updateRootState(); - this.compucteLevelNum(); - } catch (Exception e) { - log.info("计算层级出错:"+e.getMessage()); - } -// }); + try { + this.getBaseMapper().updateRootState_1(); + this.getBaseMapper().updateRootState_2(); + this.getBaseMapper().updateRootState_3(); + this.compucteLevelNum(); + + + } catch (Exception e) { + + log.info("计算层级出错:" + e.getMessage()); + } } @@ -310,8 +313,8 @@ public class BomNewOriginalParentService extends ServiceImpl bomTree = getBomTree(bomRowId); //需删除的BOM List delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0 && OriginalStatusEnum.UN_CONVERT.equalsValue(u.getStatus())).collect(Collectors.toList()); - List delParentRowId=new ArrayList<>(); - for ( BomOriginalListVO bom: delBom) { + List delParentRowId = new ArrayList<>(); + for (BomOriginalListVO bom : delBom) { delParentRowId.add(bom.getBomRowId()); } delParentRowId.add(bomRowId); @@ -333,7 +336,7 @@ public class BomNewOriginalParentService extends ServiceImpl bomNewOriginalParentEntities = this.getBaseMapper().selectBatchIds(bomRowIds); List convertedBom = bomNewOriginalParentEntities.stream().filter(u -> OriginalStatusEnum.OVER_CONVERT.equalsValue(u.getStatus())).collect(Collectors.toList()); - // VUtils.isTure(CollUtil.isNotEmpty(convertedBom)).throwMessage("所选BOM中存在已转换的BOM"); + // VUtils.isTure(CollUtil.isNotEmpty(convertedBom)).throwMessage("所选BOM中存在已转换的BOM"); //开始转换 for (BomNewOriginalParentEntity parent : bomNewOriginalParentEntities) { @@ -385,17 +388,16 @@ public class BomNewOriginalParentService extends ServiceImpl()); String uuid = IdUtil.simpleUUID(); EecExcelUtil.handlerExcel(file.getInputStream(), BomNewOriginalExcelDTO.class, BomNewOriginalParentService::handlerExcelRow); List excelContext = excelContextTL.get(); - List noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u->u.getRowNum()).collect(Collectors.toList()); - VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",",noLevelNo )+"层次为空"); - List noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u->u.getRowNum()).collect(Collectors.toList()); - VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",",noDrawingNo )+"图号为空"); + List noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u -> u.getRowNum()).collect(Collectors.toList()); + VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",", noLevelNo) + "层次为空"); + List noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u -> u.getRowNum()).collect(Collectors.toList()); + VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",", noDrawingNo) + "图号为空"); // List noNum = excelContext.stream().filter(u -> Objects.isNull(u.getQty())).map(u->u.getRowNum()).collect(Collectors.toList()); // VUtils.isTure(CollUtil.isNotEmpty(noNum)).throwMessage( StrUtil.join(",",noNum )+"数量为空"); @@ -410,7 +412,7 @@ public class BomNewOriginalParentService extends ServiceImpl chileds = excelContext.stream().filter(u -> u.getParentKey().equals(data.getLevelNo() + "-" + data.getRowNum())).collect(Collectors.toList()); if (CollUtil.isNotEmpty(chileds)) { - int i=1; + int i = 1; for (BomNewOriginalExcelDTO ch : chileds) { ch.setOrderNo(i); i++; @@ -430,8 +432,8 @@ public class BomNewOriginalParentService extends ServiceImpl excelContext = excelContextTL.get(); - List noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u->u.getRowNum()).collect(Collectors.toList()); - VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",",noLevelNo )+"层次为空"); - List noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u->u.getRowNum()).collect(Collectors.toList()); - VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",",noDrawingNo )+"图号为空"); - List noNum = excelContext.stream().filter(u -> Objects.isNull(u.getQty())).map(u->u.getRowNum()).collect(Collectors.toList()); - VUtils.isTure(CollUtil.isNotEmpty(noNum)).throwMessage( StrUtil.join(",",noNum )+"数量为空"); + List noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u -> u.getRowNum()).collect(Collectors.toList()); + VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",", noLevelNo) + "层次为空"); + List noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u -> u.getRowNum()).collect(Collectors.toList()); + VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",", noDrawingNo) + "图号为空"); + List noNum = excelContext.stream().filter(u -> Objects.isNull(u.getQty())).map(u -> u.getRowNum()).collect(Collectors.toList()); + VUtils.isTure(CollUtil.isNotEmpty(noNum)).throwMessage(StrUtil.join(",", noNum) + "数量为空"); for (BomNewOriginalExcelDTO data : excelContext) { List parentData = excelContext.stream().filter(u -> u.getLevelNo().equals(data.getLevelNo() - 1) && u.getRowNum() < data.getRowNum()) @@ -464,7 +466,7 @@ public class BomNewOriginalParentService extends ServiceImpl chileds = excelContext.stream().filter(u -> u.getParentKey().equals(data.getLevelNo() + "-" + data.getRowNum())).collect(Collectors.toList()); if (CollUtil.isNotEmpty(chileds)) { - int i=1; + int i = 1; for (BomNewOriginalExcelDTO ch : chileds) { ch.setOrderNo(i); i++; diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml index 15f0d36b..30934a7f 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml @@ -124,23 +124,27 @@ ; - + - update t_bom_new_original_parent set root_is=0,user_root_is=0 where last_version_is=1; + update t_bom_new_original_parent set root_is=0,user_root_is=0 where last_version_is=1 + + + update t_bom_new_original_parent a join ( select a.row_id from t_bom_new_original_parent a left join t_bom_new_original_child b on a.drawing_no=b.drawing_no - where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.root_is=1; - + where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.root_is=1 + + update t_bom_new_original_parent a join ( select a.row_id from t_bom_new_original_parent a left join t_bom_new_original_child b on a.drawing_no=b.drawing_no and a.created_by=b.created_by - where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.user_root_is=1; - + where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.user_root_is=1 +