EBOM生成虚拟包

This commit is contained in:
大米 2024-02-28 16:33:01 +08:00
parent 9efab16980
commit 4999312fbc
4 changed files with 34 additions and 20 deletions

View File

@ -104,8 +104,11 @@ public class PBomApi extends BaseApi {
@PostMapping("editSubmit") @PostMapping("editSubmit")
@ApiOperation("编辑-提交") @ApiOperation("编辑-提交")
public ResultVO<Boolean> editSubmit(@Valid @RequestBody EditPBomParamDTO param){ public ResultVO<Boolean> editSubmit(@Valid @RequestBody EditPBomParamDTO param){
//检查物料编码是否存在
bomNewPbomParentService.checkMaterialNo(param.getChildList());
//检查物料是否被冻结 //检查物料是否被冻结
materialMainService.checkMaterialFreeze(param.getChildList()); materialMainService.checkMaterialFreeze(param.getChildList());
bomNewPbomParentService.editSave(param, PBomEditStatusEnum.HANDLER_FINISHED); bomNewPbomParentService.editSave(param, PBomEditStatusEnum.HANDLER_FINISHED);
return ResultVO.success(true); return ResultVO.success(true);
} }

View File

@ -127,7 +127,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
data.addAll(childs); data.addAll(childs);
for (BomNewPbomParentVO vi : childs) { for (BomNewPbomParentVO vi : childs) {
if (StrUtil.isBlank(vi.getCurrentVersion()) && MaterialshouldBomExistUtil.checkShouldBomExist(vi)) { if (StrUtil.isBlank(vi.getCurrentVersion()) && MaterialshouldBomExistUtil.checkShouldBomExist(vi)) {
vi.setCurrentVersion(OriginalConstant.NO_BOM_VERSION); vi.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
} }
} }
@ -271,7 +271,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
child.setVirtualPackageIs(parentEntity.getVirtualPackageIs()); child.setVirtualPackageIs(parentEntity.getVirtualPackageIs());
child.setTechnologyUserCode(parentEntity.getTechnologyUserCode()); child.setTechnologyUserCode(parentEntity.getTechnologyUserCode());
child.setTechnologyUserName(parentEntity.getTechnologyUserName()); child.setTechnologyUserName(parentEntity.getTechnologyUserName());
if ( parent.getStatus()< PBomStatusEnum.PUBLISH.getValue() && parentEntity.getStatus().equals(PBomStatusEnum.PUBLISH.getValue())) { if (parent.getStatus() < PBomStatusEnum.PUBLISH.getValue() && parentEntity.getStatus().equals(PBomStatusEnum.PUBLISH.getValue())) {
child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue()); child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue());
} }
@ -311,6 +311,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
public void editSave(EditPBomParamDTO paramDTO, PBomEditStatusEnum editStatus) { public void editSave(EditPBomParamDTO paramDTO, PBomEditStatusEnum editStatus) {
BomNewPbomParentEntity parent = this.getById(paramDTO.getBomRowId()); BomNewPbomParentEntity parent = this.getById(paramDTO.getBomRowId());
VUtils.isTure(Objects.isNull(parent)).throwMessage("参数错误该BOM不存在"); VUtils.isTure(Objects.isNull(parent)).throwMessage("参数错误该BOM不存在");
List<BomNewPbomChildEntity> childList = Convert.toList(BomNewPbomChildEntity.class, paramDTO.getChildList()); List<BomNewPbomChildEntity> childList = Convert.toList(BomNewPbomChildEntity.class, paramDTO.getChildList());
childList.forEach(u -> { childList.forEach(u -> {
u.setParentRowId(paramDTO.getBomRowId()); u.setParentRowId(paramDTO.getBomRowId());
@ -322,8 +323,22 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
} }
/**
* 1物料编码不能为空
* 2物料编码需在主数据中存在
*/
public void checkMaterialNo(List<BomNewPbomParentVO> data) {
List<BomNewPbomParentVO> noMaterialNoList = data.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noMaterialNoList)).throwMessage("存在物料编码为空的数据");
List<String> materialNos = data.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo())).map(u -> u.getMaterialNo()).collect(Collectors.toList());
List<BaseMaterialVO> mainMaterialList = materialMainService.getMaterialBaseInfo(materialNos);
Set<String> mainMaterialNoSet = mainMaterialList.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
Set<String> difference = Sets.difference(Sets.newHashSet(materialNos), mainMaterialNoSet);
VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference)+"物料编码在主数据中不存在");
}
/** /**
@ -387,8 +402,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
public void editExportV2(PBomEditExportParamDTO param, HttpServletResponse response) throws IOException { public void editExportV2(PBomEditExportParamDTO param, HttpServletResponse response) throws IOException {
EecExcelUtil.setResponseExcelHeader(response, "bom明细列表"); EecExcelUtil.setResponseExcelHeader(response, "bom明细列表");
List<BomNewPbomParentVO> child = this.getChild(param.getBomRowId()); List<BomNewPbomParentVO> child = this.getChild(param.getBomRowId());
if(CollUtil.isNotEmpty(param.getRowIds())){ if (CollUtil.isNotEmpty(param.getRowIds())) {
child=child.stream().filter(u->param.getRowIds().contains(u.getRowId())).collect(Collectors.toList()); child = child.stream().filter(u -> param.getRowIds().contains(u.getRowId())).collect(Collectors.toList());
} }
List<BomNewPbomEditExcelVO> result = Convert.toList(BomNewPbomEditExcelVO.class, child); List<BomNewPbomEditExcelVO> result = Convert.toList(BomNewPbomEditExcelVO.class, child);
@ -408,7 +423,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
VUtils.isTure(Objects.isNull(packageParam.getTechnologyPackageTypeRowId())).throwMessage("请选择工艺包类型"); VUtils.isTure(Objects.isNull(packageParam.getTechnologyPackageTypeRowId())).throwMessage("请选择工艺包类型");
BomNewTechnologyPackageTypeEntity technologyPackageTypeEntity = technologyPackageTypeService.getById(packageParam.getTechnologyPackageTypeRowId()); BomNewTechnologyPackageTypeEntity technologyPackageTypeEntity = technologyPackageTypeService.getById(packageParam.getTechnologyPackageTypeRowId());
//单条物料 //单条物料
String drawingNo = packageParam.getDrawingNo(); String drawingNo = packageParam.getDrawingNo();
String materialName = packageParam.getMaterialName(); String materialName = packageParam.getMaterialName();
String materialDesc = packageParam.getMaterialDesc(); String materialDesc = packageParam.getMaterialDesc();
BomNewPbomParentVO result = null; BomNewPbomParentVO result = null;
@ -433,8 +448,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
// materialName = StrUtil.join("", result.getMaterialName(), technologyPackageTypeEntity.getRemark()); // materialName = StrUtil.join("", result.getMaterialName(), technologyPackageTypeEntity.getRemark());
// materialDesc = StrUtil.join(" ", materialName, drawingNo); // materialDesc = StrUtil.join(" ", materialName, drawingNo);
AddVirtrualMaterialDTO toM =new AddVirtrualMaterialDTO(); AddVirtrualMaterialDTO toM = new AddVirtrualMaterialDTO();
String key=String.valueOf(IdWorker.getId()) ; String key = String.valueOf(IdWorker.getId());
toM.setKey(key); toM.setKey(key);
toM.setMaterialName(materialName); toM.setMaterialName(materialName);
toM.setDrawingNo(drawingNo); toM.setDrawingNo(drawingNo);
@ -443,7 +458,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
toM.setProjectType(packageParam.getProjectType()); toM.setProjectType(packageParam.getProjectType());
Map<String, AddVirtrualMaterialDTO> mMap = materialService.batchAddMaterial(ImmutableList.of(toM)); Map<String, AddVirtrualMaterialDTO> mMap = materialService.batchAddMaterial(ImmutableList.of(toM));
// String materialNo = materialService.addMaterial(drawingNo, materialName, materialDesc, "201201"); // String materialNo = materialService.addMaterial(drawingNo, materialName, materialDesc, "201201");
String materialNo=mMap.get(key).getMaterialNo(); String materialNo = mMap.get(key).getMaterialNo();
BaseMaterialVO resultD = materialMainService.getMaterialBaseInfo(ImmutableList.of(materialNo)).get(0); BaseMaterialVO resultD = materialMainService.getMaterialBaseInfo(ImmutableList.of(materialNo)).get(0);
//插入工艺包 //插入工艺包
packageParam.setTechnologyPackageMaterialNo(materialNo); packageParam.setTechnologyPackageMaterialNo(materialNo);
@ -727,7 +742,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
BigDecimal bNodeLevel = NumberUtil.add(parentVO.getLevelNumber(), (NumberUtil.div(new BigDecimal(1), new BigDecimal(zero)))); BigDecimal bNodeLevel = NumberUtil.add(parentVO.getLevelNumber(), (NumberUtil.div(new BigDecimal(1), new BigDecimal(zero))));
List<BomNewPbomParentVO> subNodes = child.stream().filter(u -> u.getLevelNumber().compareTo(parentVO.getLevelNumber()) > 0 && u.getLevelNumber().compareTo(bNodeLevel) < 0).collect(Collectors.toList()); List<BomNewPbomParentVO> subNodes = child.stream().filter(u -> u.getLevelNumber().compareTo(parentVO.getLevelNumber()) > 0 && u.getLevelNumber().compareTo(bNodeLevel) < 0).collect(Collectors.toList());
for (BomNewPbomParentVO node : subNodes) { for (BomNewPbomParentVO node : subNodes) {
if(StrUtil.isBlank(node.getProductionFactoryCode())) { if (StrUtil.isBlank(node.getProductionFactoryCode())) {
node.setProductionFactoryCode(facCode); node.setProductionFactoryCode(facCode);
node.setProductionFactoryCodeInputType(ProductionFactoryCodeInputTypeEnum.RULE_MATCH.getValue()); node.setProductionFactoryCodeInputType(ProductionFactoryCodeInputTypeEnum.RULE_MATCH.getValue());
} }
@ -738,7 +753,6 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
/** /**
* 修改生产工厂 * 修改生产工厂
* 重新发布 * 重新发布
*
*/ */
public void reConvertToMBom(Long bomRowId, List<Long> sourceRowId) throws ExecutionException, InterruptedException { public void reConvertToMBom(Long bomRowId, List<Long> sourceRowId) throws ExecutionException, InterruptedException {
@ -853,14 +867,14 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
// saySyncDEMO(); // saySyncDEMO();
// importSap(parent,allBom); // importSap(parent,allBom);
//记录-BOM版本RowId //记录-BOM版本RowId
List<BomNewPbomChildEntity> pBomChildren=new ArrayList<>(); List<BomNewPbomChildEntity> pBomChildren = new ArrayList<>();
allBom.forEach(k->{ allBom.forEach(k -> {
BomNewPbomChildEntity entChild=new BomNewPbomChildEntity(); BomNewPbomChildEntity entChild = new BomNewPbomChildEntity();
entChild.setRowId(k.getRowId()); entChild.setRowId(k.getRowId());
entChild.setBomVersionRowId(k.getBomRowId()); entChild.setBomVersionRowId(k.getBomRowId());
pBomChildren.add(entChild); pBomChildren.add(entChild);
}); });
if(CollUtil.isNotEmpty(pBomChildren)){ if (CollUtil.isNotEmpty(pBomChildren)) {
pbomChildService.updateBatchById(pBomChildren); pbomChildService.updateBatchById(pBomChildren);
} }
@ -873,10 +887,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
} }
private void importSap(BomNewPbomParentEntity parent, List<BomNewPbomParentVO> children) { private void importSap(BomNewPbomParentEntity parent, List<BomNewPbomParentVO> children) {
Sap sap=new Sap(parent,children); Sap sap = new Sap(parent, children);
ImportSapParamDTO importParm = sap.buildSyncSapParam(); ImportSapParamDTO importParm = sap.buildSyncSapParam();
if (CollUtil.isNotEmpty(importParm.getT1())) { if (CollUtil.isNotEmpty(importParm.getT1())) {
ResultVO<Boolean> booleanResultVO = sapOpUtilService.importToSap(importParm); ResultVO<Boolean> booleanResultVO = sapOpUtilService.importToSap(importParm);
@ -886,8 +899,6 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
} }
/** /**
* 获取CRM 订单号 * 获取CRM 订单号
* *

View File

@ -31,7 +31,7 @@ public class MaterialshouldBomExistUtil {
if(StrUtil.isNotBlank(material.getMaterialCategoryCode()) && if(StrUtil.isNotBlank(material.getMaterialCategoryCode()) &&
(material.getMaterialCategoryCode().startsWith("30") || material.getMaterialCategoryCode().equals(OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE) || (material.getMaterialCategoryCode().startsWith("30") || material.getMaterialCategoryCode().equals(OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE) ||
( material.getMaterialCategoryCode().startsWith("20") && material.getMaterialGetType().equals(MaterialGetEnum.developing.getValue())))){ ( material.getMaterialCategoryCode().startsWith("20") && MaterialGetEnum.developing.equalsValue(material.getMaterialGetType()) ))){
return true; return true;
} }

View File

@ -20,7 +20,7 @@ public class SessionUtil {
* @return * @return
*/ */
public static Long getRowId() { public static Long getRowId() {
return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getRowId).orElse(null); return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getRowId).orElse(1585164668335439881L);
} }
/** /**