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 e8b5b688..458a3ab2 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 @@ -157,16 +157,16 @@ public class OriginalBomApi extends BaseApi { @LogRecord(success = "删除BOM-图号:{{#bom.drawingNo}} 版本:{{#bom.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#bomRowIds.toString()}}" ,type = "原始BOM转Ebom") @Transactional(rollbackFor = Exception.class) - public ResultVO convertToEBom(@RequestBody List bomRowIds) throws ExecutionException, InterruptedException { + public ResultVO> convertToEBom(@RequestBody List bomRowIds) throws ExecutionException, InterruptedException { VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要转换的BOM"); VUtils.isTure(bomRowIds.size() > 20).throwMessage("你选择的BOM数据大于20"); - originalParentService.convertToEBom(bomRowIds); + List result = originalParentService.convertToEBom(bomRowIds); //更新物料使用 bomNewEbomChildMapper.updateEBomMaterialUse(); //更新-原始BOM跟节点 - CompletableFuture.runAsync(()->{ + CompletableFuture.runAsync(() -> { originalParentService.getBaseMapper().updateRootState_2(OriginalStatusEnum.OVER_CONVERT.getValue()); originalParentService.getBaseMapper().updateRootState_3(OriginalStatusEnum.OVER_CONVERT.getValue()); }); @@ -174,9 +174,7 @@ public class OriginalBomApi extends BaseApi { //跟新EBom 根节点 ebomParentService.getBaseMapper().updateRootState(); - - return ResultVO.success(true); - + return ResultVO.success(result); } @GetMapping("getOriginalBomExcelTemplate") diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index d1a6dd8b..52d7e5d4 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -10,6 +10,7 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.IdWorker; @@ -23,10 +24,7 @@ import com.nflg.product.base.core.exception.NflgBusinessException; import com.nflg.product.bomnew.constant.*; import com.nflg.product.bomnew.mapper.master.BomNewEbomParentMapper; import com.nflg.product.bomnew.pojo.dto.*; -import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity; -import com.nflg.product.bomnew.pojo.entity.BomNewEbomMaterialUseEntity; -import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; -import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity; +import com.nflg.product.bomnew.pojo.entity.*; import com.nflg.product.bomnew.pojo.query.BomNewEbomMaterialQuery; import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery; import com.nflg.product.bomnew.pojo.vo.*; @@ -256,7 +254,21 @@ public class BomNewEbomParentService extends ServiceImpl formalWorksheet(BomNewEbomParentQuery query) { Page result = this.getBaseMapper().formalWorksheet(new Page<>(query.getPage(), query.getPageSize()), query); - materialMainService.intiMaterialInfo(result.getRecords()); + if (CollUtil.isNotEmpty(result.getRecords())) { + materialMainService.intiMaterialInfo(result.getRecords()); + } else { + //查bom是否存在 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (StrUtil.isNotBlank(query.getDrawingNo())) { + wrapper.eq(BomNewEbomChildEntity::getDrawingNo, query.getDrawingNo()); + } else if (StrUtil.isNotBlank(query.getMaterialNo())) { + wrapper.eq(BomNewEbomChildEntity::getMaterialNo, query.getMaterialNo()); + } + if (wrapper.nonEmptyOfWhere() && ebomChildService.getBaseMapper().selectCount(wrapper) > 0) { + VUtils.isTure(true).throwMessage("不存在此BOM物料"); + } + } + return result; } @@ -1141,6 +1153,8 @@ public class BomNewEbomParentService extends ServiceImpl bomRowIds) throws ExecutionException, InterruptedException { + public List convertToEBom(List bomRowIds) throws ExecutionException, InterruptedException { List 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"); //检查:有子级的物料编码不能为空 + List importOriginalBomVOList = new ArrayList<>(); //开始转换 for (BomNewOriginalParentEntity parent : bomNewOriginalParentEntities) { if (!Objects.equals(parent.getCreatedBy(), SessionUtil.getUserCode())){ + importOriginalBomVOList.add(new ImportOriginalBomVO(parent.getDrawingNo(),"非本人创建")); log.warn(SessionUtil.getRealName()+"("+SessionUtil.getUserCode()+")转换原始bom("+parent.getRowId().toString()+")到ebom的操作被阻止"); continue; } LogRecordContext.putVariable("bom",parent); Long ebomRowId = IdWorker.getId(); - convertToEBomDo(parent, ebomRowId); + + try { + convertToEBomDo(parent, ebomRowId); + } catch (Exception e) { + importOriginalBomVOList.add(new ImportOriginalBomVO(parent.getDrawingNo(), "操作失败:" + e.getMessage())); + throw e; + } //更新并保存异常信息 ebomParentService.checkAndSaveEBomException(ebomRowId); - } - return true; - + return importOriginalBomVOList; } /**