BOM删除优化
This commit is contained in:
parent
a32372b5ce
commit
04480c3b04
|
|
@ -615,8 +615,9 @@ public class EbomApi extends BaseApi {
|
|||
@GetMapping("bomDelete")
|
||||
@ApiOperation("BOM删除")
|
||||
@LogRecord(success = "Ebom-BOM删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}", type = "Ebom-BOM删除")
|
||||
public ResultVO<Boolean> bomDelete(@RequestParam("bomRowId") Long bomRowId) {
|
||||
return ResultVO.success(bomNewEbomParentService.bomDelete(bomRowId));
|
||||
public ResultVO<Boolean> bomDelete(@RequestParam("bomRowId") Long bomRowId,
|
||||
@RequestParam("childBomRowId") Long childBomRowId) {
|
||||
return ResultVO.success(bomNewEbomParentService.bomDelete(bomRowId,childBomRowId));
|
||||
}
|
||||
|
||||
@GetMapping("changeBomDelete")
|
||||
|
|
|
|||
|
|
@ -365,8 +365,9 @@ public class PBomApi extends BaseApi {
|
|||
@GetMapping("bomDelete")
|
||||
@ApiOperation("BOM删除")
|
||||
@LogRecord(success = "PBom删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}",type = "BOM删除")
|
||||
public ResultVO<Boolean> bomDelete(@RequestParam("bomRowId") Long bomRowId) {
|
||||
bomNewPbomParentService.bomDelete(bomRowId);
|
||||
public ResultVO<Boolean> bomDelete(@RequestParam("bomRowId") Long bomRowId,
|
||||
@RequestParam("childBomRowId") Long childBomRowId) {
|
||||
bomNewPbomParentService.bomDelete(bomRowId,childBomRowId);
|
||||
return ResultVO.success(true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1488,10 +1488,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
/**
|
||||
* BOM删除 by 10002327 241015
|
||||
*
|
||||
* @param bomRowId
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean bomDelete(Long bomRowId){
|
||||
public Boolean bomDelete(Long bomRowId,Long childBomRowId){
|
||||
BomNewEbomParentEntity parent = this.getById(bomRowId);
|
||||
VUtils.isTure(parent == null).throwMessage(StrUtil.join(",", bomRowId, "不存在~"));
|
||||
//检查是否存在发布前的版本,有则不能发起 BOM删除
|
||||
|
|
@ -1499,8 +1500,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list();
|
||||
Set<String> existMaterialNos = existEnt.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(existMaterialNos)).throwMessage(StrUtil.join(",", existMaterialNos, "存在发布前版本。"));
|
||||
//如果bom 有且只有一条 [BOM已删除] 标记行时,提示已删除,无须重复删除
|
||||
List<BomNewEbomChildEntity> ebomChildEntityList = ebomChildService.list(Wrappers.<BomNewEbomChildEntity>lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId,bomRowId));
|
||||
List<BomNewEbomChildEntity> kChildEntityList = ebomChildEntityList.stream().filter(c -> Objects.equals("K",c.getProjectType())).collect(Collectors.toList());
|
||||
VUtils.isTure(ebomChildEntityList.size() == 1 && kChildEntityList.size() == 1).throwMessage(StrUtil.join(",", bomRowId, "BOM已删除,无须重复删除~"));
|
||||
|
||||
List<BomNewEbomParentEntity> parentResult = new ArrayList<>();
|
||||
//1、生成一个新版本号的空BOM
|
||||
//1、生成一个新版本号的空BOM,直接变更为正式版
|
||||
LogRecordContext.putVariable("bom", parent);
|
||||
BomNewEbomParentEntity newParent = new BomNewEbomParentEntity();
|
||||
BeanUtil.copyProperties(parent, newParent);
|
||||
|
|
@ -1508,8 +1514,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
newParent.setLastVersionIs(1);
|
||||
newParent.setCurrentVersion(VersionUtil.getNextVersion(parent.getCurrentVersion()));
|
||||
newParent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
|
||||
newParent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue());
|
||||
newParent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
newParent.setStatus(EBomStatusEnum.PUBLISHED.getValue());
|
||||
newParent.setEditStatus(EbomEditStatusEnum.HANDLER_FINISHED.getValue());
|
||||
newParent.setDeptRowId(SessionUtil.getDepartRowId());
|
||||
newParent.setDeptName(SessionUtil.getDepartName());
|
||||
newParent.setDeviseName(SessionUtil.getRealName());
|
||||
|
|
@ -1535,12 +1541,24 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
parent.setLastVersionIs(0);
|
||||
parentResult.add(newParent);
|
||||
parentResult.add(parent);
|
||||
//将新增的newParent,替换到旧bom的子表上
|
||||
List<BomNewEbomChildEntity> childEntityList = Lists.newArrayList();
|
||||
BomNewEbomChildEntity oldBomChild = ebomChildService.getById(childBomRowId);
|
||||
BomNewEbomChildEntity newBomChild = new BomNewEbomChildEntity();
|
||||
BeanUtil.copyProperties(oldBomChild, newBomChild);
|
||||
newBomChild.setRowId(IdWorker.getId());
|
||||
newBomChild.setIdentityNo(newBomChild.getParentRowId() + "_" + newBomChild.getRowId());
|
||||
newBomChild.setBomVersionRowId(newParent.getRowId());
|
||||
newBomChild.setSource(EBomSourceEnum.FROM_DELETE.getValue());
|
||||
childEntityList.add(newBomChild);
|
||||
|
||||
//2、子表增加一行项目类别为K,标识删除
|
||||
BomNewEbomChildEntity newChild = new BomNewEbomChildEntity();
|
||||
newChild.setRowId(IdWorker.getId());
|
||||
newChild.setParentRowId(newParent.getRowId());
|
||||
newChild.setIdentityNo(newParent.getRowId() + "_" + newChild.getRowId());
|
||||
newChild.setOrderNumber("001");
|
||||
newChild.setMaterialDesc("[BOM已删除]");
|
||||
newChild.setProjectType(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_K.getValue());
|
||||
newChild.setProjectTypeInputType(0);
|
||||
newChild.setCreatedBy(SessionUtil.getUserCode());
|
||||
|
|
@ -1551,6 +1569,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
newChild.setExceptionStatus(1);
|
||||
newChild.setSource(EBomSourceEnum.FROM_DELETE.getValue());
|
||||
|
||||
childEntityList.add(newChild);
|
||||
//3、调用SAP接口删除BOM
|
||||
SapReqParams sapReqParams = new SapReqParams();
|
||||
sapReqParams.setFunName("ZRFC_PP_005");
|
||||
|
|
@ -1575,7 +1594,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
throw new NflgBusinessException(STATE.RouteServiceError, sapResult.getMsg());
|
||||
}
|
||||
this.saveOrUpdateBatch(parentResult);
|
||||
ebomChildService.save(newChild);
|
||||
ebomChildService.saveBatch(childEntityList);
|
||||
ebomChildService.removeById(childBomRowId);
|
||||
|
||||
//将历史已发布版-转移到正式历史表
|
||||
List<Long> addRowIds = com.google.common.collect.Lists.newArrayList(newParent.getRowId());
|
||||
List<Long> delRowIds = com.google.common.collect.Lists.newArrayList(bomRowId);
|
||||
eBomToFormal(addRowIds, delRowIds);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1444,7 +1444,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
* @param bomRowId
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void bomDelete(Long bomRowId){
|
||||
public void bomDelete(Long bomRowId,Long childBomRowId){
|
||||
BomNewPbomParentEntity parent = this.getById(bomRowId);
|
||||
VUtils.isTure(Objects.isNull(parent)).throwMessage("该BOM版本不存在");
|
||||
VUtils.isTure(parent.getStatus() < PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM,才能删除");
|
||||
|
|
@ -1458,17 +1458,22 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
.eq(BomNewPbomParentEntity::getFacCode, parent.getFacCode())
|
||||
.lt(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()).list();
|
||||
VUtils.isTure(CollUtil.isNotEmpty(waitPublishList)).throwMessage(parent.getMaterialNo() + "存在待发布的版本,无法删除");
|
||||
//如果bom 有且只有一条 [BOM已删除] 标记行时,提示已删除,无须重复删除
|
||||
List<BomNewPbomChildEntity> childEntityList = pbomChildService.list(Wrappers.<BomNewPbomChildEntity>lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId,bomRowId));
|
||||
List<BomNewPbomChildEntity> kEntityList = childEntityList.stream().filter(c -> Objects.equals("K",c.getProjectType())).collect(Collectors.toList());
|
||||
VUtils.isTure(childEntityList.size() == 1 && kEntityList.size() == 1).throwMessage("BOM已删除,无须重复删除~");
|
||||
|
||||
BomNewPbomParentVO rootVo = Convert.convert(BomNewPbomParentVO.class, parent);
|
||||
rootVo.setBomRowId(rootVo.getRowId());
|
||||
//1、parent增加一行大版本号记录
|
||||
//1、parent增加一行大版本号记录 直接变更为正式版
|
||||
BomNewPbomParentEntity pbomParent = new BomNewPbomParentEntity();
|
||||
List<BomNewPbomParentEntity> parentList = Lists.newArrayList();
|
||||
BeanUtil.copyProperties(rootVo, pbomParent);
|
||||
pbomParent.setRowId(IdWorker.getId());
|
||||
pbomParent.setCreatedTime(LocalDateTime.now());
|
||||
pbomParent.setCreatedBy(SessionUtil.getUserCode());
|
||||
pbomParent.setStatus(PBomStatusEnum.WAIT_PUBLISH.getValue());
|
||||
pbomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
pbomParent.setStatus(PBomStatusEnum.FACTORY_CONFIRM.getValue());
|
||||
pbomParent.setEditStatus(PBomEditStatusEnum.HANDLER_FINISHED.getValue());
|
||||
//获取大版本号
|
||||
pbomParent.setCurrentVersion(VersionUtil.getNextVersion(rootVo.getCurrentVersion()));
|
||||
pbomParent.setDeptRowId(SessionUtil.getDepartRowId());
|
||||
|
|
@ -1495,6 +1500,17 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
parentList.add(pbomParent);
|
||||
parentList.add(parent);
|
||||
|
||||
|
||||
List<BomNewPbomChildEntity> newChildEntityList = Lists.newArrayList();
|
||||
BomNewPbomChildEntity oldBomChild = pbomChildService.getById(childBomRowId);
|
||||
BomNewPbomChildEntity newBomChild = new BomNewPbomChildEntity();
|
||||
BeanUtil.copyProperties(oldBomChild, newBomChild);
|
||||
newBomChild.setRowId(IdWorker.getId());
|
||||
newBomChild.setBomVersionRowId(pbomParent.getRowId());
|
||||
newBomChild.setSource(PbomSourceEnum.FROM_DELETE.getValue());
|
||||
newChildEntityList.add(newBomChild);
|
||||
|
||||
|
||||
//2、子表新增一行项目类别为K的标识行
|
||||
BomNewPbomChildEntity child = new BomNewPbomChildEntity();
|
||||
child.setRowId(IdWorker.getId());
|
||||
|
|
@ -1502,6 +1518,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
child.setFacCode(pbomParent.getFacCode());
|
||||
child.setProjectType(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_K.getValue());
|
||||
child.setOrderNumber("001");
|
||||
child.setMaterialDesc("[BOM已删除]");
|
||||
child.setNum(new BigDecimal(1));
|
||||
child.setIdentityNo(pbomParent.getRowId() + "_" + child.getRowId());
|
||||
child.setCreatedTime(LocalDateTime.now());
|
||||
|
|
@ -1509,6 +1526,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
child.setModifyTime(null);
|
||||
child.setSource(PbomSourceEnum.FROM_DELETE.getValue());
|
||||
child.setRemark("");
|
||||
newChildEntityList.add(child);
|
||||
|
||||
//调用SAP接口 删除pbom
|
||||
SapReqParams sapReqParams = new SapReqParams();
|
||||
|
|
@ -1536,7 +1554,13 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
throw new NflgBusinessException(STATE.RouteServiceError, sapResult.getMsg());
|
||||
}
|
||||
this.saveOrUpdateBatch(parentList);
|
||||
pbomChildService.save(child);
|
||||
pbomChildService.saveBatch(newChildEntityList);
|
||||
pbomChildService.removeById(childBomRowId);
|
||||
|
||||
List<Long> exceptRowIds = Lists.newArrayList(pbomParent.getRowId());
|
||||
List<String> parentMaterialNos =Lists.newArrayList(pbomParent.getMaterialNo());
|
||||
//历史版本转移到formal正式工作表
|
||||
pBomToFormal(exceptRowIds, parentMaterialNos, parent.getFacCode());
|
||||
}
|
||||
|
||||
private void resetBomExist(Long rowId) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue