diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index b70ca385..2b8a76d8 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -515,4 +515,15 @@ public class EbomApi extends BaseApi { public ResultVO merge(@Valid @RequestBody @NotEmpty List rowIds) { return ResultVO.success(bomNewEbomParentService.merge(rowIds)); } + + /** + * 检查下级是否存在Q项 + * @param bomRowIds bomRowIds + * @return 检查结果 + */ + @PostMapping("checkQ") + @ApiOperation("检查下级是否存在Q项") + public ResultVO> checkQ(@Valid @RequestBody @NotEmpty List bomRowIds) { + return ResultVO.success(bomNewEbomParentService.checkQ(bomRowIds)); + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java index a41917d0..82e7a7fd 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java @@ -130,8 +130,9 @@ public class PBomApi extends BaseApi { @GetMapping("getChild") @ApiOperation("获取子级") - public ResultVO> getChild(@RequestParam("bomRowId") Long bomRowId){ - return ResultVO.success(bomNewPbomParentService.getChild(bomRowId)); + public ResultVO> getChild(@RequestParam("bomRowId") Long bomRowId + , @Valid @RequestParam("type") @NotNull Integer type) { + return ResultVO.success(bomNewPbomParentService.getChild(bomRowId, type)); } @PostMapping("editStaging") diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/CheckBomQVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/CheckBomQVO.java new file mode 100644 index 00000000..f77c3c16 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/CheckBomQVO.java @@ -0,0 +1,30 @@ +package com.nflg.product.bomnew.pojo.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * @author 曹鹏飞 + * @date 2024/6/28 15:03:25 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "com-nflg-product-bomnew-pojo-original-vo-CheckBomQVO") +public class CheckBomQVO implements Serializable { + + /** + * bom行id + */ + @ApiModelProperty(value = "bom行id") + private Long bomRowId; + + /** + * 下级是否存在Q项 + */ + @ApiModelProperty(value = "下级是否存在Q项") + private Boolean exists; +} 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 548da5b0..87e246cc 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 @@ -346,7 +346,7 @@ public class BomNewEbomParentService extends ServiceImpl materialNos = parentChild.stream().map(BaseMaterialVO::getMaterialNo).filter(StrUtil::isNotBlank).collect(Collectors.toList()); if (CollUtil.isNotEmpty(materialNos)) { List list = this.lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos) - .eq(!EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()), BomNewEbomParentEntity::getLastVersionIs, 1) + // .eq(!EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()), BomNewEbomParentEntity::getLastVersionIs, 1) .eq(EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()), BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list(); // if (EBomStatusEnum.CHECKED.equalsValue(parent.getStatus())) { // list = list.stream().filter(u -> EBomStatusEnum.CHECKED.equalsValue(u.getStatus())).collect(Collectors.toList()); @@ -943,7 +943,7 @@ public class BomNewEbomParentService extends ServiceImpl bomRowIds = bomTree.stream().filter(u ->!EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()) && u.getBomRowId() > 0).map(u -> u.getBomRowId()).collect(Collectors.toList()); if (CollUtil.isNotEmpty(eBomToPBom.getAddEBomNew())) { - this.getBaseMapper().updateStateBatchByRowIds(EBomStatusEnum.PUBLISHED.getValue(), eBomToPBom.getAddEBomNew()); + this.getBaseMapper().updateStateBatchByRowIds(EBomStatusEnum.PUBLISHED.getValue(), SessionUtil.getRealName(), eBomToPBom.getAddEBomNew()); //将历史已发布版-转移到正式历史表 eBomToFormal(eBomToPBom.getAddEBomNew(), eBomToPBom.getDelOldEBom() ); } @@ -1700,6 +1700,7 @@ public class BomNewEbomParentService extends ServiceImpl getReverseBoms(Long parentRowId) { return baseMapper.getReverseBoms(parentRowId); } + + public List checkQ(List bomRowIds) { + List children = ebomChildService.lambdaQuery() + .in(BomNewEbomChildEntity::getParentRowId, bomRowIds) + .list(); + return bomRowIds.stream().map(bomRowId -> { + CheckBomQVO vo = new CheckBomQVO(); + vo.setBomRowId(bomRowId); + vo.setExists(children.stream().anyMatch(c -> c.getParentRowId().equals(bomRowId) + && StrUtil.equals(c.getProjectType(), ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue()))); + return vo; + }).collect(Collectors.toList()); + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomUpgradeChangeService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomUpgradeChangeService.java index ceb3ce4f..d0fc32e6 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomUpgradeChangeService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomUpgradeChangeService.java @@ -63,6 +63,8 @@ public class BomNewEbomUpgradeChangeService extends ServiceImpl(result)).writeTo(response.getOutputStream()); } - public List getChild(Long rowId) { + public List getChild(Long rowId, Integer type) { VUtils.isTure(rowId == 0).throwMessage("参数不正确"); - return getChild(this.getById(rowId)); + return getChild(this.getById(rowId), type); } - public List getChild(BomNewPbomParentEntity parent) { + + public List getChild(BomNewPbomParentEntity parent, Integer type) { //List parentChild = this.getBaseMapper().getParentChild(rowId); //BomNewPbomParentEntity parent = this.getById(rowId); List parentChild = this.getBaseMapper().getParentChild(parent.getRowId()); @@ -316,7 +317,8 @@ public class BomNewPbomParentService extends ServiceImpl= PBomStatusEnum.PUBLISH.getValue()) { child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue()); } } else { //无BOM-版本时 确定版本号 @@ -334,6 +336,9 @@ public class BomNewPbomParentService extends ServiceImpl= EBomStatusEnum.PUBLISHED.getValue()) { + child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue()); + } } child.setSapOrderNum(BomUtil.generateSapOrderNum(child.getProjectType(), child.getMaterialCategoryCode() , child.getFacCode(), child.getMaterialNo(), child.getBomExist())); @@ -370,7 +375,7 @@ public class BomNewPbomParentService extends ServiceImpl child = this.getChild(parent); + List child = this.getChild(parent, 0); List result = Convert.toList(BomNewPbomEditExcelVO.class, child); new Workbook().addSheet(new ListSheet<>(result)).writeTo(response.getOutputStream()); @@ -483,7 +488,7 @@ public class BomNewPbomParentService extends ServiceImpl child = this.getChild(parent); + List child = this.getChild(parent, 0); if (CollUtil.isNotEmpty(param.getRowIds())) { child = child.stream().filter(u -> param.getRowIds().contains(u.getRowId())).collect(Collectors.toList()); } @@ -531,13 +536,14 @@ public class BomNewPbomParentService extends ServiceImpl mMap = materialService.batchAddMaterial(ImmutableList.of(toM)); // String materialNo = materialService.addMaterial(drawingNo, materialName, materialDesc, "201201"); String materialNo = mMap.get(key).getMaterialNo(); BaseMaterialVO resultD = materialMainService.getMaterialBaseInfo(ImmutableList.of(materialNo)).get(0); //插入工艺包 packageParam.setTechnologyPackageMaterialNo(materialNo); - insertTechnologyPackage(packageParam, result); + insertTechnologyPackage(packageParam); return resultD; } @@ -552,18 +558,25 @@ public class BomNewPbomParentService extends ServiceImpl materialVOS = materialMainService.getMaterialBaseInfo(ImmutableList.of(technologyPackageParam.getTechnologyPackageMaterialNo())); + VUtils.isTure(CollUtil.isEmpty(materialVOS)).throwMessage("未找到物料信息"); + insertTechnologyPackage(technologyPackageParam, materialVOS.get(0)); } @Transactional(rollbackFor = Exception.class) - public void insertTechnologyPackage(TechnologyPackageParam technologyPackageParam, BomNewPbomParentVO vo) { + public void insertTechnologyPackage(TechnologyPackageParam technologyPackageParam, BaseMaterialVO vo) { VUtils.isTure(StrUtil.isBlank(technologyPackageParam.getTechnologyPackageMaterialNo())).throwMessage("工艺包物料编码不能为空"); VUtils.isTure(CollUtil.isEmpty(technologyPackageParam.getRowIds())).throwMessage("请选择要插入工艺包的物料"); if (technologyPackageParam.getRowIds().size() == 1 && Objects.isNull(technologyPackageParam.getLevelBelong())) { throw new NflgBusinessException(STATE.BusinessError, "单条物料时,请选择上下级"); } VUtils.isTure(StrUtil.isBlank(vo.getMaterialCategoryCode())).throwMessage("物料分类代码不能为空"); + VUtils.isTure(!StrUtil.equals(vo.getMaterialCategoryCode(), MaterialMainConstant.CATEGORYCODE_TECHNOLOGYPACKAGE)) + .throwMessage("该物料不是工艺包"); if (vo.getMaterialCategoryCode().startsWith("10")) { //工艺包只能添加到上级 VUtils.isTure(!Objects.equals(technologyPackageParam.getLevelBelong(), 0)).throwMessage("10分类开头的物料,工艺包只能添加到上级"); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/TechnologyPackageParamBuilder.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/TechnologyPackageParamBuilder.java index dff03eaa..e63255af 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/TechnologyPackageParamBuilder.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/TechnologyPackageParamBuilder.java @@ -1,6 +1,7 @@ package com.nflg.product.bomnew.service.domain.PBom; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import com.baomidou.mybatisplus.core.toolkit.IdWorker; @@ -71,8 +72,20 @@ public class TechnologyPackageParamBuilder { } else { //虚拟包作为下级 BomNewPbomParentEntity childParent = buildParentByChild(children.get(0)); - buildPbomChildForTechnologyPackage(childParent); + BomNewPbomChildEntity gc = buildPbomChildForTechnologyPackage(childParent); this.packageParent.add(childParent); + //将选中物料的下级移动到工艺包下去 + List cpcs = SpringUtil.getBean(BomNewPbomChildService.class).lambdaQuery() + .eq(BomNewPbomChildEntity::getParentRowId, childParent.getRowId()) + .list(); + if (CollUtil.isNotEmpty(cpcs)) { + BomNewPbomParentEntity gp = buildParentForTechnologyPackage(gc); + cpcs.forEach(it -> { + it.setParentRowId(gp.getRowId()); + it.setModifyTime(LocalDateTime.now()); + }); + this.packageChildren.addAll(cpcs); + } } @@ -87,6 +100,8 @@ public class TechnologyPackageParamBuilder { .eq(BomNewPbomParentEntity::getLastVersionIs, 1) .one(); if(Objects.nonNull(oldBom)){ + VUtils.isTure(oldBom.getStatus() >= PBomStatusEnum.PUBLISH.getValue()) + .throwMessage("不能添加工艺包到借用件下级"); return oldBom; } BomNewPbomParentEntity newBom=new BomNewPbomParentEntity(); @@ -156,7 +171,48 @@ public class TechnologyPackageParamBuilder { } - private void buildPbomChildForTechnologyPackage(BomNewPbomParentEntity parent){ + private BomNewPbomParentEntity buildParentForTechnologyPackage(BomNewPbomChildEntity child) { + BomNewPbomParentEntity oldBom = SpringUtil.getBean(BomNewPbomParentService.class) + .lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, child.getMaterialNo()) + .eq(BomNewPbomParentEntity::getFacCode, parent.getFacCode()) + .orderByDesc(BomNewPbomParentEntity::getCurrentVersion) + .last(" limit 1") + .one(); + VUtils.isTure(Objects.nonNull(oldBom) && oldBom.getStatus() < PBomStatusEnum.PUBLISH.getValue()) + .throwMessage("该工艺包存在未发布的BOM版本"); + + BomNewPbomParentEntity newBom = new BomNewPbomParentEntity(); + newBom.setRowId(IdWorker.getId()); + newBom.setDrawingNo(child.getDrawingNo()); + newBom.setFacCode(parent.getFacCode()); + newBom.setMaterialNo(child.getMaterialNo()); + newBom.setMaterialName(child.getMaterialName()); + newBom.setMaterialDesc(child.getMaterialDesc()); + newBom.setMaterialTexture(child.getMaterialTexture()); + newBom.setMaterialUnit(child.getMaterialUnit()); + newBom.setNum(new BigDecimal(1)); + newBom.setProjectType(child.getProjectType()); + newBom.setBomExist(1); + newBom.setLastVersionIs(1); + newBom.setCurrentVersion(Objects.isNull(oldBom) ? VersionUtil.getNextVersion("") : VersionUtil.getNextVersion(oldBom.getCurrentVersion())); + newBom.setDeviseUserCode(SessionUtil.getUserCode()); + newBom.setDeviseName(SessionUtil.getRealName()); + newBom.setDeptName(SessionUtil.getDepartName()); + newBom.setDeptRowId(SessionUtil.getDepartRowId()); + newBom.setCreatedBy(SessionUtil.getUserCode()); + newBom.setCreatedTime(LocalDateTime.now()); + newBom.setTechnologyUserCode(SessionUtil.getUserCode()); + newBom.setTechnologyUserName(SessionUtil.getUserName()); + newBom.setSourceRowId(0L); + if (Objects.nonNull(oldBom)) { + oldBom.setLastVersionIs(0); + SpringUtil.getBean(BomNewPbomParentService.class).updateById(oldBom); + } + this.packageParent.add(newBom); + return newBom; + } + + private BomNewPbomChildEntity buildPbomChildForTechnologyPackage(BomNewPbomParentEntity parent) { BomNewPbomChildEntity child = new BomNewPbomChildEntity(); List parentChildren =SpringUtil.getBean(BomNewPbomChildService.class).lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId, parent.getRowId()).list(); child.setRowId(IdWorker.getId()); @@ -177,5 +233,6 @@ public class TechnologyPackageParamBuilder { child.setModifyTime(LocalDateTime.now()); child.setSourceRowId(0L); this.packageChildren.add(child); + return child; } }