【批量替代】版本号问题

This commit is contained in:
10001392 2024-11-14 10:13:51 +08:00
parent 60a807daec
commit fcc3947d3c
4 changed files with 24 additions and 13 deletions

View File

@ -14,7 +14,8 @@ public enum EBomSourceEnum implements ValueEnum<Integer> {
FROM_MDM(3, "MDM创建"),
FROM_SAP(4, "从SAP导入"),
FROM_CHANGE(5, "变更"),
FROM_DELETE(6, "BOM删除");
FROM_DELETE(6, "BOM删除"),
FROM_BATCH(7, "批量变更");
private final Integer value;
private final String description;

View File

@ -16,7 +16,8 @@ public enum PbomSourceEnum implements ValueEnum<Integer> {
FROM_SAP(3, "从SAP导入"),
FROM_COPY(4, "复制"),
FROM_CHANGE(5, "变更"),
FROM_DELETE(6, "BOM删除");
FROM_DELETE(6, "BOM删除"),
FROM_BATCH(7, "批量变更");
private final Integer value;
private final String description;

View File

@ -186,7 +186,7 @@ public class BatchBomService {
baseBomVO.setNewMaterialNo(batchBomQuery.getNewMaterialNo());
baseBomVO.setNewNum(newReplaceTimes.divide(replaceTimes, decimalScale, RoundingMode.HALF_UP).multiply(baseBomVO.getNum()));
baseBomVO.setNewUnit(batchBomQuery.getNewMaterialUnit());
baseBomVO.setNewVersion(VersionUtil.getNextVersion(baseBomVO.getParentVersion()));
baseBomVO.setNewVersion(VersionUtil.getPBomUpgradNextVersion(baseBomVO.getParentVersion()));
resultList.add(baseBomVO);
}
}
@ -338,6 +338,7 @@ public class BatchBomService {
// 新版本创建时间要更新创建人要不要更新待定根据权限管理考虑
newParent.setCreatedTime(now);
newParent.setModifyTime(now);
newParent.setSource(EBomSourceEnum.FROM_BATCH.getValue());
newParent.setSapState(SapStatusEnum.UNPUB_SAP.getValue());
newParent.setSapTime(null);
newParent.setDeptRowId(SessionUtil.getDepartRowId());
@ -358,6 +359,7 @@ public class BatchBomService {
newChild.setCreatedTime(now);
newChild.setModifyTime(now);
newChild.setCreatedBy(SessionUtil.getUserCode());
newChild.setSource(EBomSourceEnum.FROM_BATCH.getValue());
newChildList.add(newChild);
});
BomNewEbomChildEntity newReplaceChild = new BomNewEbomChildEntity();
@ -379,6 +381,7 @@ public class BatchBomService {
newReplaceChild.setModifyTime(now);
newReplaceChild.setCreatedBy(SessionUtil.getUserCode());
newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo());
newReplaceChild.setSource(EBomSourceEnum.FROM_BATCH.getValue());
newChildList.add(newReplaceChild);
bomNewEbomParentService.save(newParent);
bomNewEbomChildService.saveBatch(newChildList);
@ -395,7 +398,7 @@ public class BatchBomService {
// 转移后删除
bomNewEbomParentService.delEBomHistory(delRowIds);
}
// TODO 如果有草稿中数据草稿版本+1
// TODO 如果有草稿中数据草稿版本+1
for (BaseBomVO baseBomVO: baseBomVOList) {
BomNewEbomParentEntity draftParent = bomNewEbomParentService.lambdaQuery()
.eq(BomNewEbomParentEntity::getMaterialNo, baseBomVO.getParentMaterialNo())
@ -433,6 +436,7 @@ public class BatchBomService {
newReplaceChild.setModifyTime(now);
newReplaceChild.setCreatedBy(SessionUtil.getUserCode());
newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo());
newReplaceChild.setSource(EBomSourceEnum.FROM_BATCH.getValue());
}
bomNewEbomChildService.updateBatchById(replaceChildren);
}
@ -471,7 +475,7 @@ public class BatchBomService {
BomNewPbomChildEntity replaceChild = collect.get(0);
// 其他子级
List<BomNewPbomChildEntity> otherChildren = pbomChildEntities.stream().filter(item -> !item.getRowId().equals(baseBomVO.getChildRowId())).collect(Collectors.toList());
// 构建新版的父级规则版本号+1如果该BOM还有编辑中的草稿版本则草稿版本号也+1
// 构建新版的父级规则小小版本号+1如果该BOM还有编辑中的草稿版本则草稿小小版本号也+1
BomNewPbomParentEntity newParent = new BomNewPbomParentEntity();
BeanUtil.copyProperties(pbomParentEntity, newParent);
newParent.setRowId(IdWorker.getId());
@ -479,6 +483,7 @@ public class BatchBomService {
// 新版本创建时间要更新创建人要不要更新待定根据权限管理考虑
newParent.setCreatedTime(now);
newParent.setModifyTime(now);
newParent.setSource(PbomSourceEnum.FROM_BATCH.getValue());
newParent.setSapState(SapStatusEnum.UNPUB_SAP.getValue());
newParent.setSapTime(null);
newParent.setDeptRowId(SessionUtil.getDepartRowId());
@ -499,6 +504,7 @@ public class BatchBomService {
newChild.setCreatedTime(now);
newChild.setModifyTime(now);
newChild.setCreatedBy(SessionUtil.getUserCode());
newChild.setSource(PbomSourceEnum.FROM_BATCH.getValue());
newChildList.add(newChild);
});
BomNewPbomChildEntity newReplaceChild = new BomNewPbomChildEntity();
@ -520,6 +526,7 @@ public class BatchBomService {
newReplaceChild.setModifyTime(now);
newReplaceChild.setCreatedBy(SessionUtil.getUserCode());
newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo());
newReplaceChild.setSource(PbomSourceEnum.FROM_BATCH.getValue());
newChildList.add(newReplaceChild);
bomNewPbomParentService.save(newParent);
bomNewPbomChildService.saveBatch(newChildList);
@ -536,7 +543,7 @@ public class BatchBomService {
// 转移后删除
bomNewPbomParentService.delPBom(delRowIds);
}
// TODO 如果有草稿中数据草稿版本+1
// TODO 如果有草稿中数据草稿小小版本+1
for (BaseBomVO baseBomVO: baseBomVOList) {
BomNewPbomParentEntity draftParent = bomNewPbomParentService.lambdaQuery()
.eq(BomNewPbomParentEntity::getMaterialNo, baseBomVO.getParentMaterialNo())
@ -544,13 +551,8 @@ public class BatchBomService {
.lt(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
.one();
if (ObjectUtil.isNotEmpty(draftParent)) {
// 草稿版本 A01 -> A02A01.1 -> A02.1
String[] currentVersionArr = draftParent.getCurrentVersion().split("\\.");
String newVersion = VersionUtil.getNextVersion(currentVersionArr[0]);
if (currentVersionArr.length > 1) {
newVersion += "." + currentVersionArr[1];
}
draftParent.setCurrentVersion(newVersion);
// 草稿数据小小版本+1因为草稿的小小版本号已经被批量替代这个版本占用
draftParent.setCurrentVersion(VersionUtil.getPBomUpgradNextVersion(draftParent.getCurrentVersion()));
draftParent.setModifyTime(LocalDateTime.now());
bomNewPbomParentService.updateById(draftParent);
// 子级有原物料号也要替代成新物料号
@ -575,6 +577,7 @@ public class BatchBomService {
newReplaceChild.setModifyTime(now);
newReplaceChild.setCreatedBy(SessionUtil.getUserCode());
newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo());
newReplaceChild.setSource(PbomSourceEnum.FROM_BATCH.getValue());
}
bomNewPbomChildService.updateBatchById(replaceChildren);
}

View File

@ -54,6 +54,12 @@ public class SapErrorMsgUtil {
errMsg.msg = materialNo + "物料状态可能为冻结,实际为:" + materialNoStateMap.get(materialNo);
}
});
// SAP报错信息这个提示语'Z0'转义为状态为冻结
liErrMsg.forEach(errMsg -> {
if (ObjectUtil.isNotEmpty(errMsg.msg) && errMsg.msg.contains("'Z0'")) {
errMsg.msg = errMsg.msg.replaceAll("'Z0'", "状态为冻结");
}
});
}
}