主物料类别

This commit is contained in:
jing's 2023-12-24 19:42:43 +08:00
parent 9535d8d1df
commit 0f795e71fd
4 changed files with 120 additions and 102 deletions

View File

@ -274,7 +274,7 @@ public class EbomApi extends BaseApi {
@ApiOperation("删除物料") @ApiOperation("删除物料")
public ResultVO<Boolean> deleteBom(@RequestParam("bomRowId") Long bomRowId ) throws ExecutionException, InterruptedException{ public ResultVO<Boolean> deleteBom(@RequestParam("bomRowId") Long bomRowId ) throws ExecutionException, InterruptedException{
bomNewEbomParentService.deleteBom(bomRowId); bomNewEbomParentService.deleteBom(bomRowId);
bomNewEbomParentService.computeLevelNumAndRootState();
return ResultVO.success(true); return ResultVO.success(true);
} }

View File

@ -55,4 +55,9 @@ public class BaseMaterialVO {
@ApiModelProperty("物料大类别") @ApiModelProperty("物料大类别")
private String relCategoryCode; private String relCategoryCode;
@ApiModelProperty("物料分类编码名称")
private String categoryName;
} }

View File

@ -203,6 +203,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
/** /**
* 获取变更影响 * 获取变更影响
*
* @param query * @param query
* @return * @return
*/ */
@ -213,8 +214,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
/** /**
* 获取子级 * 获取子级
* *
@ -233,16 +232,23 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
for (BomNewEbomParentVO child : parentChild) { for (BomNewEbomParentVO child : parentChild) {
if (bomListMap.containsKey(child.getMaterialNo())) { if (bomListMap.containsKey(child.getMaterialNo())) {
BomNewEbomParentEntity parentEntity = bomListMap.get(child.getMaterialNo()); BomNewEbomParentEntity parentEntity = bomListMap.get(child.getMaterialNo());
child.setCurrentVersion(parentEntity.getCurrentVersion()); child.setCurrentVersion(parentEntity.getCurrentVersion());
child.setStatus(parentEntity.getStatus()); child.setStatus(parentEntity.getStatus());
child.setDeviseName(parentEntity.getDeviseName()); child.setDeviseName(parentEntity.getDeviseName());
child.setDeviseUserCode(parentEntity.getDeviseUserCode()); child.setDeviseUserCode(parentEntity.getDeviseUserCode());
//child.setCreatedBy(parentEntity.getCreatedBy());
child.setCreatedTime(parentEntity.getCreatedTime()); child.setCreatedTime(parentEntity.getCreatedTime());
child.setBomRowId(parentEntity.getRowId()); child.setBomRowId(parentEntity.getRowId());
child.setLevelNum(parentEntity.getLevelNum()); child.setLevelNum(parentEntity.getLevelNum());
child.setDeptName(parentEntity.getDeptName()); child.setDeptName(parentEntity.getDeptName());
child.setSource(parentEntity.getSource()); child.setSource(parentEntity.getSource());
child.setBomExist(parentEntity.getBomExist());
child.setShouldBomExist(parentEntity.getShouldBomExist());
if (parentEntity.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())) { if (parentEntity.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())) {
child.setStatus(OriginalStatusEnum.BORROWED_PARTS.getValue()); child.setStatus(OriginalStatusEnum.BORROWED_PARTS.getValue());
} }
@ -297,14 +303,14 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
public List<BomNewEbomParentVO> buildBomTreeContainSelf(Long rowId) throws ExecutionException, InterruptedException { public List<BomNewEbomParentVO> buildBomTreeContainSelf(Long rowId) throws ExecutionException, InterruptedException {
List<BomNewEbomParentVO> list= getBomTree(rowId); List<BomNewEbomParentVO> list = getBomTree(rowId);
BomNewEbomParentVO parentVO=Convert.convert(BomNewEbomParentVO.class,this.getById(rowId)); BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, this.getById(rowId));
if(parentVO!=null) { if (parentVO != null) {
parentVO.setBomRowId(rowId); parentVO.setBomRowId(rowId);
parentVO.setParentRowId(0L); parentVO.setParentRowId(0L);
list.add(parentVO); list.add(parentVO);
} }
return list; return list;
} }
@ -466,7 +472,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
parent.setChildBomRowId(parent.getRowId()); parent.setChildBomRowId(parent.getRowId());
parent.setParentRowId(0L); parent.setParentRowId(0L);
bomTree.add(parent); bomTree.add(parent);
EBomToPBom eBomToPBom = new EBomToPBom(parent, bomTree, paramDto.getFacCodes(),0L); EBomToPBom eBomToPBom = new EBomToPBom(parent, bomTree, paramDto.getFacCodes(), 0L);
eBomToPBom.convert(); eBomToPBom.convert();
if (CollUtil.isNotEmpty(eBomToPBom.getPBomParentResult())) { if (CollUtil.isNotEmpty(eBomToPBom.getPBomParentResult())) {
@ -476,14 +482,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (CollUtil.isNotEmpty(eBomToPBom.getPBomChildResult())) { if (CollUtil.isNotEmpty(eBomToPBom.getPBomChildResult())) {
pBomChildService.saveOrUpdateBatch(eBomToPBom.getPBomChildResult()); pBomChildService.saveOrUpdateBatch(eBomToPBom.getPBomChildResult());
} }
if(CollUtil.isNotEmpty(eBomToPBom.getVirtualPackageCompositionResult())){ if (CollUtil.isNotEmpty(eBomToPBom.getVirtualPackageCompositionResult())) {
virtualPackageCompositionService.saveOrUpdateBatch(eBomToPBom.getVirtualPackageCompositionResult()); virtualPackageCompositionService.saveOrUpdateBatch(eBomToPBom.getVirtualPackageCompositionResult());
} }
if(CollUtil.isNotEmpty(eBomToPBom.getUpgradeChangeResult())){ if (CollUtil.isNotEmpty(eBomToPBom.getUpgradeChangeResult())) {
upgradeChangeService.saveOrUpdateBatch(eBomToPBom.getUpgradeChangeResult()); upgradeChangeService.saveOrUpdateBatch(eBomToPBom.getUpgradeChangeResult());
}; }
if(CollUtil.isNotEmpty(eBomToPBom.getHasConvertEBomRowIds())){ ;
this.getBaseMapper().updateStateBatchByRowIds(EBomStatusEnum.PUBLISHED.getValue(),eBomToPBom.getHasConvertEBomRowIds()); if (CollUtil.isNotEmpty(eBomToPBom.getHasConvertEBomRowIds())) {
this.getBaseMapper().updateStateBatchByRowIds(EBomStatusEnum.PUBLISHED.getValue(), eBomToPBom.getHasConvertEBomRowIds());
} }
@ -581,6 +588,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
// CompletableFuture.runAsync(() -> { // CompletableFuture.runAsync(() -> {
try { try {
this.getBaseMapper().updateRootState(); this.getBaseMapper().updateRootState();
ebomChildService.getBaseMapper().updateEBomMaterialUse();
this.compucteLevelNum(); this.compucteLevelNum();
} catch (Exception e) { } catch (Exception e) {
@ -600,7 +608,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
materialMainService.intiMaterialInfo(datas, BomNewEbomParentVO::getMaterialNo); materialMainService.intiMaterialInfo(datas, BomNewEbomParentVO::getMaterialNo);
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_EXCE.getValue()); EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_EXCE.getValue());
BomNewEBomParentEditDTO bomNewEBomParentEditDTO=new BomNewEBomParentEditDTO(); BomNewEBomParentEditDTO bomNewEBomParentEditDTO = new BomNewEBomParentEditDTO();
bomNewEBomParentEditDTO.setParent(dto.getParent()); bomNewEBomParentEditDTO.setParent(dto.getParent());
bomNewEBomParentEditDTO.setDatas(datas); bomNewEBomParentEditDTO.setDatas(datas);
eBomEdit.temporary(bomNewEBomParentEditDTO); eBomEdit.temporary(bomNewEBomParentEditDTO);
@ -686,30 +694,30 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<Long> rowIds = dto.getRowIdList(); List<Long> rowIds = dto.getRowIdList();
// List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.getBaseMapper().selectBatchIds(rowIds); // List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.getBaseMapper().selectBatchIds(rowIds);
List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, rowIds).eq(BomNewEbomParentEntity::getRootIs, 1).list(); List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, rowIds).eq(BomNewEbomParentEntity::getRootIs, 1).list();
if (CollUtil.isEmpty(bomNewEbomParentEntityList)) { if (CollUtil.isEmpty(bomNewEbomParentEntityList)) {
// throw new NflgBusinessException(STATE.BusinessError, "下级BOM无法进行退回"); // throw new NflgBusinessException(STATE.BusinessError, "下级BOM无法进行退回");
VUtils.isTure(true).throwMessage("下级BOM无法进行退回"); VUtils.isTure(true).throwMessage("下级BOM无法进行退回");
} }
if (rowIds.size() != bomNewEbomParentEntityList.size()) { if (rowIds.size() != bomNewEbomParentEntityList.size()) {
// throw new NflgBusinessException(STATE.BusinessError, "选择数据中包含有下级BOM无法进行退回"); // throw new NflgBusinessException(STATE.BusinessError, "选择数据中包含有下级BOM无法进行退回");
VUtils.isTure(true).throwMessage("选择数据中包含有下级BOM无法进行退回"); VUtils.isTure(true).throwMessage("选择数据中包含有下级BOM无法进行退回");
} }
List<Long> revertList=new ArrayList<>(); List<Long> revertList = new ArrayList<>();
for (Long bomRowId: for (Long bomRowId :
rowIds) { rowIds) {
List<BomNewEbomParentVO> bomTreeList= buildBomTreeContainSelf(bomRowId); List<BomNewEbomParentVO> bomTreeList = buildBomTreeContainSelf(bomRowId);
// //
// //
// //
@ -734,9 +742,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
//忽略叶子节点 //忽略叶子节点
revertList.addAll(bomTreeList.stream() revertList.addAll(bomTreeList.stream()
.filter(u->u.getBomRowId()>0) .filter(u -> u.getBomRowId() > 0)
.map(BomNewEbomParentVO::getRowId).collect(Collectors.toList())); .map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()));
} }
@ -776,16 +784,16 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (CollUtil.isEmpty(bomNewEbomParentEntityList)) { if (CollUtil.isEmpty(bomNewEbomParentEntityList)) {
// return ResultVO.error("下级BOM无法进行复核"); // return ResultVO.error("下级BOM无法进行复核");
VUtils.isTure(true).throwMessage("下级BOM无法进行复核"); VUtils.isTure(true).throwMessage("下级BOM无法进行复核");
} }
if (rowIds.size() != bomNewEbomParentEntityList.size()) { if (rowIds.size() != bomNewEbomParentEntityList.size()) {
VUtils.isTure(true).throwMessage("数据中包含有下级BOM无法进行复核"); VUtils.isTure(true).throwMessage("数据中包含有下级BOM无法进行复核");
// return ResultVO.error("数据中包含有下级BOM无法进行复核"); // return ResultVO.error("数据中包含有下级BOM无法进行复核");
} }
List<Integer> checkStatus=CollectionUtil.toList(new Integer[]{ List<Integer> checkStatus = CollectionUtil.toList(new Integer[]{
EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(), EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(), EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_4.getValue(), EBomExceptionStatusEnum.EXCEPT_NO_4.getValue(),
@ -797,16 +805,16 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}); });
List<Long> updateReviewIdList = new ArrayList<>(); List<Long> updateReviewIdList = new ArrayList<>();
for (Long bomRowId: for (Long bomRowId :
rowIds) { rowIds) {
CheckEBomException checkEBomException=new CheckEBomException(bomRowId); CheckEBomException checkEBomException = new CheckEBomException(bomRowId);
//错误状态包含在checkStatus内有异常抛出 //错误状态包含在checkStatus内有异常抛出
checkEBomException.checkContainExcept(checkStatus); checkEBomException.checkContainExcept(checkStatus);
//筛选bomRowId()>0 说明有bom更新只到parent这层无bom不需要更新 //筛选bomRowId()>0 说明有bom更新只到parent这层无bom不需要更新
//设计人员只可以复核自己的物料如果存在引用其他用户创建的物料时不可以改变被引用物料的审核状态 //设计人员只可以复核自己的物料如果存在引用其他用户创建的物料时不可以改变被引用物料的审核状态
updateReviewIdList.addAll( checkEBomException.getAllBomDetail().stream() updateReviewIdList.addAll(checkEBomException.getAllBomDetail().stream()
.filter(u->u.getBomRowId()>0 .filter(u -> u.getBomRowId() > 0
&& u.getCreatedBy().equals(dto.getUserCode())) && u.getCreatedBy().equals(dto.getUserCode()))
.map(BomNewEbomParentVO::getRowId).collect(Collectors.toList())); .map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()));
} }
@ -824,20 +832,21 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (!this.updateBatchById(updateReviewList)) { if (!this.updateBatchById(updateReviewList)) {
throw new NflgBusinessException(STATE.Error, "复核失败"); throw new NflgBusinessException(STATE.Error, "复核失败");
} }
return true; return true;
} }
/** /**
* 更新项目类型 * 更新项目类型
*
* @return * @return
*/ */
public Boolean updateProjectType(BomNewEbomProjectTypeDTO dto ){ public Boolean updateProjectType(BomNewEbomProjectTypeDTO dto) {
List<BomNewEbomChildEntity> childEntity=new ArrayList<>(); List<BomNewEbomChildEntity> childEntity = new ArrayList<>();
dto.getRowIdList().forEach(rowid->{ dto.getRowIdList().forEach(rowid -> {
BomNewEbomChildEntity entity=new BomNewEbomChildEntity(); BomNewEbomChildEntity entity = new BomNewEbomChildEntity();
entity.setRowId(rowid); entity.setRowId(rowid);
entity.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue()); entity.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
entity.setProjectType(dto.getProjectType()); entity.setProjectType(dto.getProjectType());
@ -850,15 +859,14 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
public BomNewEbomEditDetailVO editDetail(Long bomRowId) { public BomNewEbomEditDetailVO editDetail(Long bomRowId) {
BomNewEbomEditDetailVO vo = new BomNewEbomEditDetailVO(); BomNewEbomEditDetailVO vo = new BomNewEbomEditDetailVO();
BomNewEbomParentEntity parent = this.getById(bomRowId);
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parent);
parentVO.setBomRowId(parentVO.getRowId());
parentVO.setParentRowId(0l);
materialMainService.intiMaterialInfo(ImmutableList.of(parentVO));
BomNewEbomParentEntity parent= this.getById(bomRowId);
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class,parent);
parentVO.setBomRowId(parentVO.getRowId());
parentVO.setParentRowId(0l);
// List<BomNewEbomParentVO> parentList = new ArrayList<>(); // List<BomNewEbomParentVO> parentList = new ArrayList<>();
// parentList.add(parentVO); // parentList.add(parentVO);
// materialMainService.intiMaterialInfo(parentList); // materialMainService.intiMaterialInfo(parentList);
@ -898,7 +906,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
BomNewEbomParentVO baseMaterialVO = new BomNewEbomParentVO(); BomNewEbomParentVO baseMaterialVO = new BomNewEbomParentVO();
BeanUtil.copyProperties(materialMainEntity, baseMaterialVO); BeanUtil.copyProperties(materialMainEntity, baseMaterialVO);
baseMaterialVO.setExceptionStatus(materialMainEntity.getMaterialState()); baseMaterialVO.setExceptionStatus(materialMainEntity.getMaterialState());
return baseMaterialVO; return baseMaterialVO;
} }
@ -907,21 +914,22 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
/** /**
* 1. 描述此删除功能是整个BOM结构的删除 * 1. 描述此删除功能是整个BOM结构的删除
* 2. 规则 * 2. 规则
* 1. 物料没有被设计复核 * 1. 物料没有被设计复核
* 2. 选中的物料必须为第一层不存在父级编码 * 2. 选中的物料必须为第一层不存在父级编码
* 3. 删除逻辑 * 3. 删除逻辑
* 1. 如果数据不是从原始BOM导入的情况下包含用户新增和通过变更添加的直接删除即可 * 1. 如果数据不是从原始BOM导入的情况下包含用户新增和通过变更添加的直接删除即可
* 2. 如果数据是在原始Bom中导入的需要删除EBom的数据并且还要将原始Bom的数据状态改为待处理如果数据已经在Ebom中进行了处理原始Bom不需要处理用户下次将数据导入过来的时候需要再一次修改 * 2. 如果数据是在原始Bom中导入的需要删除EBom的数据并且还要将原始Bom的数据状态改为待处理如果数据已经在Ebom中进行了处理原始Bom不需要处理用户下次将数据导入过来的时候需要再一次修改
* 3. 如果是借用件的节点不能删除 * 3. 如果是借用件的节点不能删除
* 4. 如果存在其它用户创建的节点不可以删除 * 4. 如果存在其它用户创建的节点不可以删除
* 5. 如果是工艺岗位角色的时候只能删除自己在EBOM中创建的数据 * 5. 如果是工艺岗位角色的时候只能删除自己在EBOM中创建的数据
*
* @return * @return
* @throws ExecutionException * @throws ExecutionException
* @throws InterruptedException * @throws InterruptedException
*/ */
@Transactional(rollbackFor = Exception.class)
public Boolean deleteBom(Long bomRowId) throws ExecutionException, InterruptedException { public Boolean deleteBom(Long bomRowId) throws ExecutionException, InterruptedException {
BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectById(bomRowId); BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectById(bomRowId);
@ -937,24 +945,21 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentVO> delBom = null; List<BomNewEbomParentVO> delBom = null;
//设计 工艺删录入 excel导入 //设计 工艺删录入 excel导入
delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0 delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0
&& (u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) && (u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|| EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()))) || EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus())))
.collect(Collectors.toList()); .collect(Collectors.toList());
//借用件不能删除原始bom转换只能自己
List<BomNewEbomParentVO> obomList = null;
//借用件不能删除原始bom转换只能自己
List<BomNewEbomParentVO> obomList=null;
if (userRoleService.designer()) { if (userRoleService.designer()) {
obomList=bomTree.stream().filter(u -> u.getBomRowId() > 0 obomList = bomTree.stream().filter(u -> u.getBomRowId() > 0
&& (u.getSource().equals(EBomSourceEnum.FROM_BOM.getValue()) && (u.getSource().equals(EBomSourceEnum.FROM_BOM.getValue())
&&u.getCreatedBy().equals(SessionUtil.getUserCode()) && u.getCreatedBy().equals(SessionUtil.getUserCode())
)) ))
.collect(Collectors.toList()); .collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(obomList)){ if (CollectionUtil.isNotEmpty(obomList)) {
delBom.addAll(obomList); delBom.addAll(obomList);
} }
} }
@ -969,16 +974,20 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (CollUtil.isNotEmpty(delParentRowId)) { if (CollUtil.isNotEmpty(delParentRowId)) {
this.getBaseMapper().delBatch(delParentRowId); this.getBaseMapper().delBatch(delParentRowId);
} }
computeLevelNumAndRootState();
} }
//恢复原始bom状态 //恢复原始bom状态
if(CollectionUtil.isNotEmpty(obomList)){ if (CollectionUtil.isNotEmpty(obomList)) {
List<Long> rowIds=obomList.stream().map(BomNewEbomParentVO::getSourceRowId).collect(Collectors.toList()); List<Long> rowIds = obomList.stream().map(BomNewEbomParentVO::getSourceRowId).collect(Collectors.toList());
SpringUtil.getBean(BomNewOriginalParentService.class).revertBom(rowIds); SpringUtil.getBean(BomNewOriginalParentService.class).revertBom(rowIds);
} }
return true; return true;
} }
@ -994,25 +1003,25 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue()); EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
eBomEdit.temporary(dto); eBomEdit.temporary(dto);
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) { if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities); this.saveOrUpdateBatch(eBomEdit.parentEntities);
} }
if (CollUtil.isNotEmpty(eBomEdit.childEntities)) { if (CollUtil.isNotEmpty(eBomEdit.childEntities)) {
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities); ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
ebomChildService.getBaseMapper().updateEBomMaterialUse();
} }
if (dto.getParent() != null) { if (dto.getParent() != null) {
if (dto.getParent() != null) { if (dto.getParent() != null) {
deleteBomChild(dto.getDelDatas()); deleteBomChild(dto.getDelDatas());
} }
} }
ebomChildService.getBaseMapper().updateEBomMaterialUse();
return true; return true;
} }
/** /**
* 提交物料 * 提交物料
* * <p>
* 1. * 1.
*/ */
public Boolean submit(BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException { public Boolean submit(BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
@ -1020,7 +1029,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue()); EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
eBomEdit.temporary(dto); eBomEdit.temporary(dto);
List<Integer> checkStatus=CollectionUtil.toList(new Integer[]{ List<Integer> checkStatus = CollectionUtil.toList(new Integer[]{
EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(), EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(), EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_4.getValue(), EBomExceptionStatusEnum.EXCEPT_NO_4.getValue(),
@ -1032,67 +1041,71 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}); });
List<BomNewEbomParentVO> allBom =Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() { List<BomNewEbomParentVO> allBom = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
},eBomEdit.childEntities); }, eBomEdit.childEntities);
if(CollectionUtil.isNotEmpty(eBomEdit.parentEntities)){ if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
allBom.add(Convert.convert(BomNewEbomParentVO.class,eBomEdit.parentEntities.get(0))); allBom.add(Convert.convert(BomNewEbomParentVO.class, eBomEdit.parentEntities.get(0)));
} }
CheckEBomException checkEBomException = new CheckEBomException(allBom); CheckEBomException checkEBomException = new CheckEBomException(allBom);
checkEBomException.checkContainExcept(checkStatus); checkEBomException.checkContainExcept(checkStatus);
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) { if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities); this.saveOrUpdateBatch(eBomEdit.parentEntities);
} }
if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) { if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities); ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
} }
if (dto.getParent() != null) { if (dto.getParent() != null) {
deleteBomChild(dto.getDelDatas()); deleteBomChild(dto.getDelDatas());
} }
ebomChildService.getBaseMapper().updateEBomMaterialUse();
return true; return true;
} }
/** /**
* 1. 编辑页面的删除只是删除BOM的关联关系 * 1. 编辑页面的删除只是删除BOM的关联关系
* 2. 删除规则 * 2. 删除规则
* 1. 从原始Bom导入的数据数据没有异常的情况下用户不可以删除 * 1. 从原始Bom导入的数据数据没有异常的情况下用户不可以删除
* 2. 用户可以直接删除用户单击暂存或是提交时才会保存至数据库 * 2. 用户可以直接删除用户单击暂存或是提交时才会保存至数据库
*/ */
private void deleteBomChild(List<BomNewEbomParentVO> delList){ private void deleteBomChild(List<BomNewEbomParentVO> delList) {
List<BomNewEbomParentVO> delTagList=new ArrayList<>(); List<BomNewEbomParentVO> delTagList = new ArrayList<>();
//原始bom不正常 //原始bom不正常
List<BomNewEbomParentVO> s1List= delList.stream().filter(u->Objects.equals(EBomSourceEnum.FROM_BOM.getValue(),u.getSource()) List<BomNewEbomParentVO> s1List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
&&!Objects.equals(u.getExceptionStatus(),EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList()); && !Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(s1List)){ if (CollectionUtil.isNotEmpty(s1List)) {
delTagList.addAll(s1List); delTagList.addAll(s1List);
} }
//手动创建 //手动创建
List<BomNewEbomParentVO> s2List= delList.stream().filter(u->Objects.equals(EBomSourceEnum.FROM_EXCE.getValue(),u.getSource() ) List<BomNewEbomParentVO> s2List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_EXCE.getValue(), u.getSource())
|| Objects.equals(EBomSourceEnum.FROM_MDM.getValue(),u.getSource())).collect(Collectors.toList()); || Objects.equals(EBomSourceEnum.FROM_MDM.getValue(), u.getSource())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(s2List)){ if (CollectionUtil.isNotEmpty(s2List)) {
delTagList.addAll(s2List); delTagList.addAll(s2List);
} }
if(CollectionUtil.isNotEmpty(delTagList)){ if (CollectionUtil.isNotEmpty(delTagList)) {
List<Long> rowIdList = delTagList.stream().filter(u -> u.getRowId()!=null || u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); List<Long> rowIdList = delTagList.stream().filter(u -> u.getRowId() != null || u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
ebomChildService.removeByIds(rowIdList); if (CollectionUtil.isNotEmpty(rowIdList)) {
ebomChildService.removeByIds(rowIdList);
}
} }
} }
} }

View File

@ -71,7 +71,7 @@
<select id="getMaterialBaseInfo" resultType="com.nflg.product.bomnew.pojo.vo.BaseMaterialVO"> <select id="getMaterialBaseInfo" resultType="com.nflg.product.bomnew.pojo.vo.BaseMaterialVO">
select a.row_id as materialRowId, material_no, material_name, material_desc, procure_type, project_type, material_state,drawing_no,a.material_category_code ,material_get_type,drawing_no select a.row_id as materialRowId, material_no, material_name, material_desc, procure_type, project_type, material_state,drawing_no,a.material_category_code ,material_get_type,drawing_no
,material_texture as material ,material_texture , b.rel_category_code ,material_texture as material ,material_texture , b.rel_category_code,b.category_name
from t_material_main a join t_material_category b on a.material_category_code=b.category_code from t_material_main a join t_material_category b on a.material_category_code=b.category_code
where material_no in where material_no in
<foreach collection="materialNos" item="item" open="(" close=")" separator=","> <foreach collection="materialNos" item="item" open="(" close=")" separator=",">