Merge branch 'feature/DM/nflg-bom-transition'
This commit is contained in:
commit
f243456805
|
|
@ -2140,10 +2140,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
// return dto.getParent();
|
||||
// }
|
||||
|
||||
//检查是否在主数据里
|
||||
if (CollUtil.isNotEmpty(dto.getDatas())) {
|
||||
CheckEBomException.checkMaterialNoInMain(dto.getDatas());
|
||||
}
|
||||
|
||||
|
||||
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
|
||||
dto.setOpType(EbomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
|
|
@ -2163,12 +2160,14 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
//ebomChildService.getBaseMapper().updateEBomMaterialUse();
|
||||
}
|
||||
|
||||
superMaterialStatus(dto.getDatas());
|
||||
if(CollUtil.isNotEmpty(dto.getDatas())) {
|
||||
superMaterialStatus(dto.getDatas());
|
||||
}
|
||||
|
||||
|
||||
// checkAndSaveEBomException(childList);
|
||||
//不要异步
|
||||
ebomChildService.updateEBomMaterialUse(eBomEdit.childEntities.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toSet()));
|
||||
// ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
|
||||
|
||||
|
||||
if (eBomEdit.isRootForWaitReview()) {
|
||||
updateRootForWaitReview();
|
||||
|
|
@ -2197,10 +2196,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
|
||||
|
||||
//检查是否在主数据里
|
||||
if (CollUtil.isNotEmpty(dto.getDatas())) {
|
||||
CheckEBomException.checkMaterialNoInMain(dto.getDatas());
|
||||
}
|
||||
|
||||
//构建操作数据
|
||||
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
|
||||
dto.setOpType(EbomEditStatusEnum.HANDLER_FINISHED.getValue());
|
||||
|
|
@ -2242,7 +2238,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
|
||||
|
||||
}
|
||||
superMaterialStatus(dto.getDatas());
|
||||
if (CollectionUtil.isNotEmpty(dto.getDatas())) {
|
||||
superMaterialStatus(dto.getDatas());
|
||||
}
|
||||
|
||||
// checkAndSaveEBomException(dto.getParent().getBomRowId());
|
||||
if (eBomEdit.isRootForWaitReview()) {
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ public class EBomEdit {
|
|||
@Getter
|
||||
private BomNewEbomParentEntity parentEntity;
|
||||
@Getter
|
||||
private boolean isRootForWaitReview=false;
|
||||
private boolean isRootForWaitReview = false;
|
||||
@Getter
|
||||
private boolean isNewBom=false;
|
||||
private boolean isNewBom = false;
|
||||
|
||||
public List<BomNewEbomChildEntity> childEntities;
|
||||
|
||||
|
|
@ -84,22 +84,22 @@ public class EBomEdit {
|
|||
parent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
|
||||
|
||||
boolean isTechnician= SpringUtil.getBean(UserRoleService.class).technician();
|
||||
parent.setStatus(isTechnician? EBomStatusEnum.CHECKED.getValue() : EBomStatusEnum.WAIT_CHECK.getValue());
|
||||
parent.setCreatedJob(isTechnician? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
|
||||
boolean isTechnician = SpringUtil.getBean(UserRoleService.class).technician();
|
||||
parent.setStatus(isTechnician ? EBomStatusEnum.CHECKED.getValue() : EBomStatusEnum.WAIT_CHECK.getValue());
|
||||
parent.setCreatedJob(isTechnician ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
|
||||
|
||||
//工艺人不用更新
|
||||
if(isTechnician){
|
||||
isRootForWaitReview=false;
|
||||
}else{
|
||||
isRootForWaitReview=true;
|
||||
if (isTechnician) {
|
||||
isRootForWaitReview = false;
|
||||
} else {
|
||||
isRootForWaitReview = true;
|
||||
}
|
||||
|
||||
isNewBom=true;
|
||||
isNewBom = true;
|
||||
parent.setCreatedTime(LocalDateTime.now());
|
||||
parent.setModifyTime(LocalDateTime.now());
|
||||
|
||||
parent.setExpireEndTime( LocalDateTime.parse("9999-12-31 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") ));
|
||||
parent.setExpireEndTime(LocalDateTime.parse("9999-12-31 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
parent.setRootIs(0);
|
||||
parent.setUserRootIs(0);
|
||||
parent.setMaterialOriginalUnit(parent.getMaterialUnit());
|
||||
|
|
@ -113,24 +113,22 @@ public class EBomEdit {
|
|||
|
||||
/**
|
||||
* 如果有定版后才能新建bom
|
||||
*
|
||||
* @param materialNo
|
||||
*/
|
||||
void checkHadBom(String materialNo){
|
||||
void checkHadBom(String materialNo) {
|
||||
QueryWrapper<BomNewEbomParentEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(BomNewEbomParentEntity::getMaterialNo, materialNo)
|
||||
|
||||
.ne(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue());
|
||||
.ne(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue());
|
||||
List<BomNewEbomParentEntity> existBomlist = SpringUtil.getBean(BomNewEbomParentService.class).list(queryWrapper);
|
||||
VUtils.isTure(CollUtil.isNotEmpty(existBomlist)).throwMessage(materialNo+"该物料已存在BOM");
|
||||
VUtils.isTure(CollUtil.isNotEmpty(existBomlist)).throwMessage(materialNo + "该物料已存在BOM");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void createRootBom(BomNewEBomParentEditDTO createDTO) {
|
||||
|
||||
checkHadBom(createDTO.getParent().getMaterialNo());
|
||||
checkHadBom(createDTO.getParent().getMaterialNo());
|
||||
|
||||
parentEntity = createParentBomInfo(createDTO.getParent());
|
||||
parentEntity.setEditStatus(createDTO.getOpType());
|
||||
|
|
@ -155,7 +153,7 @@ public class EBomEdit {
|
|||
|
||||
}
|
||||
|
||||
public static void checkVirtualPackage(BomNewEbomChildEntity child){
|
||||
public static void checkVirtualPackage(BomNewEbomChildEntity child) {
|
||||
if (StrUtil.equals(child.getProjectType(), BomConstant.PROJECT_TYPE_TEMPORARY)) {
|
||||
child.setVirtualPartType(VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue());
|
||||
} else {
|
||||
|
|
@ -190,7 +188,7 @@ public class EBomEdit {
|
|||
// child.setVirtualPartIs(1);
|
||||
// }
|
||||
|
||||
EBomEdit.checkVirtualPackage(child);
|
||||
EBomEdit.checkVirtualPackage(child);
|
||||
|
||||
//新增数据
|
||||
if (child.getRowId() == null || child.getRowId() == 0) {
|
||||
|
|
@ -200,7 +198,7 @@ public class EBomEdit {
|
|||
child.setCreatedBy(SessionUtil.getUserCode());
|
||||
child.setSourceRowId("");
|
||||
child.setParentRowId(parentEntity.getRowId());
|
||||
if(StrUtil.isEmpty(child.getOrderNumber())){
|
||||
if (StrUtil.isEmpty(child.getOrderNumber())) {
|
||||
child.setOrderNumber("001");
|
||||
}
|
||||
if (dto.getOpType() == EbomEditStatusEnum.HANDLER_FINISHED.getValue()) {
|
||||
|
|
@ -262,20 +260,22 @@ public class EBomEdit {
|
|||
throw new NflgBusinessException(STATE.Error, "parent 数据不能为空");
|
||||
}
|
||||
|
||||
// if (CollUtil.isEmpty(dto.getDatas())) {
|
||||
// throw new NflgBusinessException(STATE.Error, "datas 数据不能为空");
|
||||
// }
|
||||
|
||||
List<String> materialNos = dto.getDatas().stream()
|
||||
.filter(f -> !StrUtil.equals(f.getProjectType(), BomConstant.PROJECT_TYPE_TEMPORARY, true))
|
||||
.map(BaseMaterialVO::getMaterialNo)
|
||||
.collect(Collectors.toList());
|
||||
if(materialNos.contains(dto.getParent().getMaterialNo())){
|
||||
VUtils.isTure(true).throwMessage(StrUtil.format("上下级存在相同物料{}",dto.getParent().getMaterialNo()));
|
||||
if (materialNos.contains(dto.getParent().getMaterialNo())) {
|
||||
VUtils.isTure(true).throwMessage(StrUtil.format("上下级存在相同物料{}", dto.getParent().getMaterialNo()));
|
||||
}
|
||||
//检查物料编码是否在主数据中存在
|
||||
//暂存不需检查,提交时检查
|
||||
if(ObjectUtil.equal(EbomEditStatusEnum.HANDLER_FINISHED.getValue(),dto.getOpType())) {
|
||||
if (ObjectUtil.equal(EbomEditStatusEnum.HANDLER_FINISHED.getValue(), dto.getOpType())) {
|
||||
List<String> checkMaterialInNull = materialNos.stream().filter(item -> StrUtil.isEmpty(item)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(checkMaterialInNull)) {
|
||||
VUtils.isTure(true).throwMessage("提交数据包含空物料编码");
|
||||
}
|
||||
|
||||
materialNos.add(dto.getParent().getMaterialNo());
|
||||
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos);
|
||||
List<String> effectiveMaterialNos = materialBaseInfo.stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toList());
|
||||
|
|
@ -284,43 +284,44 @@ public class EBomEdit {
|
|||
}
|
||||
|
||||
//检查数据是否可修改
|
||||
List<BomNewEbomParentVO> notNullRowIdList= dto.getDatas().stream().filter(u->u.getRowId()!=null && u.getRowId()>0).collect(Collectors.toList());
|
||||
Map<Long,BomNewEbomParentVO> mapList= ListCommonUtil.listToMap(notNullRowIdList,BomNewEbomParentVO::getRowId);
|
||||
List<BomNewEbomParentVO> notNullRowIdList = dto.getDatas().stream().filter(u -> u.getRowId() != null && u.getRowId() > 0).collect(Collectors.toList());
|
||||
Map<Long, BomNewEbomParentVO> mapList = ListCommonUtil.listToMap(notNullRowIdList, BomNewEbomParentVO::getRowId);
|
||||
|
||||
|
||||
QueryWrapper<BomNewEbomChildEntity> queryChildWrapper=new QueryWrapper<>();
|
||||
List<Long> rowIds=notNullRowIdList.stream().filter(u->ObjectUtil.isNotNull(u.getRowId()) && u.getRowId()>0 ).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
|
||||
if(CollUtil.isEmpty(rowIds)){
|
||||
return;
|
||||
}
|
||||
queryChildWrapper.lambda().in(BomNewEbomChildEntity::getRowId,rowIds);
|
||||
List<BomNewEbomChildEntity> childList=SpringUtil.getBean(BomNewEbomChildService.class).list(queryChildWrapper);
|
||||
QueryWrapper<BomNewEbomChildEntity> queryChildWrapper = new QueryWrapper<>();
|
||||
List<Long> rowIds = notNullRowIdList.stream().filter(u -> ObjectUtil.isNotNull(u.getRowId()) && u.getRowId() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(rowIds)) {
|
||||
return;
|
||||
}
|
||||
queryChildWrapper.lambda().in(BomNewEbomChildEntity::getRowId, rowIds);
|
||||
List<BomNewEbomChildEntity> childList = SpringUtil.getBean(BomNewEbomChildService.class).list(queryChildWrapper);
|
||||
|
||||
// 数据不存在异常的情况下,数据是不能被修改
|
||||
List<BomNewEbomChildEntity> check1List = childList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
|
||||
&& Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
|
||||
|
||||
for (BomNewEbomChildEntity childEntity:
|
||||
check1List ) {
|
||||
if(mapList.get(childEntity.getRowId()) ==null){
|
||||
continue;
|
||||
if (CollUtil.isEmpty(check1List)) {
|
||||
return;
|
||||
}
|
||||
//忽略物料编码空的
|
||||
if(ObjectUtil.isNull(childEntity.getMaterialNo())){
|
||||
for (BomNewEbomChildEntity childEntity :
|
||||
check1List) {
|
||||
if (mapList.get(childEntity.getRowId()) == null) {
|
||||
continue;
|
||||
}
|
||||
//忽略物料编码空的
|
||||
if (ObjectUtil.isNull(childEntity.getMaterialNo())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//检查物料id是否被修改,根据情况还可加入其他条件
|
||||
if(!mapList.get(childEntity.getRowId()).getMaterialNo().equals(childEntity.getMaterialNo())){
|
||||
throw new NflgBusinessException(STATE.Error,StrUtil.format("从原始Bom导入的数据,数据没有异常的情况下,{} 不可以修改 ", childEntity.getMaterialNo()));
|
||||
}
|
||||
//检查物料id是否被修改,根据情况还可加入其他条件
|
||||
if (!mapList.get(childEntity.getRowId()).getMaterialNo().equals(childEntity.getMaterialNo())) {
|
||||
throw new NflgBusinessException(STATE.Error, StrUtil.format("从原始Bom导入的数据,数据没有异常的情况下,{} 不可以修改 ", childEntity.getMaterialNo()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void handleBom(BomNewEBomParentEditDTO dto) {
|
||||
checkDataRule(dto);
|
||||
//添加根节点数据
|
||||
|
|
@ -334,17 +335,17 @@ public class EBomEdit {
|
|||
//缺bom
|
||||
if (dto.getParent().getBomRowId() == null || dto.getParent().getBomRowId().longValue() == 0) {
|
||||
|
||||
checkHadBom(dto.getParent().getMaterialNo());
|
||||
checkHadBom(dto.getParent().getMaterialNo());
|
||||
|
||||
parentEntity = createParentBomInfo(dto.getParent());
|
||||
// dto.getParent().setBomRowId(dto.getParent().getRowId());
|
||||
// dto.getParent().setBomRowId(dto.getParent().getRowId());
|
||||
|
||||
dto.getDatas().forEach(k -> {
|
||||
k.setParentRowId(parentEntity.getRowId());
|
||||
});
|
||||
// parentEntity.setEditStatus(dto.getOpType());
|
||||
// parentEntity.setEditStatus(dto.getOpType());
|
||||
|
||||
}else{
|
||||
} else {
|
||||
parentEntity = Convert.convert(BomNewEbomParentEntity.class, dto.getParent());
|
||||
parentEntity.setModifyTime(LocalDateTime.now());
|
||||
}
|
||||
|
|
@ -363,31 +364,31 @@ public class EBomEdit {
|
|||
}
|
||||
|
||||
|
||||
public void nextVersion(){
|
||||
public void nextVersion() {
|
||||
|
||||
if(!isNewBom){
|
||||
if (!isNewBom) {
|
||||
return;
|
||||
}
|
||||
//缺bom,新建的bom 版本增加
|
||||
//同一物料且存在一个 lastVersionIs=1
|
||||
if(ObjectUtil.isNotNull(getParentEntity().getLastVersionIs())
|
||||
&& ObjectUtil.equal(getParentEntity().getLastVersionIs(),1)) {
|
||||
QueryWrapper<BomNewEbomParentEntity> queryWrapper=new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(getParentEntity().getLastVersionIs())
|
||||
&& ObjectUtil.equal(getParentEntity().getLastVersionIs(), 1)) {
|
||||
QueryWrapper<BomNewEbomParentEntity> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
queryWrapper.lambda()
|
||||
queryWrapper.lambda()
|
||||
.eq(BomNewEbomParentEntity::getMaterialNo, getParentEntity().getMaterialNo())
|
||||
.eq(BomNewEbomParentEntity::getLastVersionIs,1)
|
||||
// .eq(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
||||
.eq(BomNewEbomParentEntity::getLastVersionIs, 1)
|
||||
// .eq(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
||||
.orderByDesc(BomNewEbomParentEntity::getCurrentVersion);
|
||||
List<BomNewEbomParentEntity> oldParent=SpringUtil.getBean(BomNewEbomParentService.class).list(queryWrapper);
|
||||
List<BomNewEbomParentEntity> oldParent = SpringUtil.getBean(BomNewEbomParentService.class).list(queryWrapper);
|
||||
|
||||
if(CollUtil.isNotEmpty(oldParent)){
|
||||
if (CollUtil.isNotEmpty(oldParent)) {
|
||||
// oldParent.setLastVersionIs(0);
|
||||
BomNewEbomParentEntity lastParent=oldParent.get(0);
|
||||
for (BomNewEbomParentEntity u:
|
||||
BomNewEbomParentEntity lastParent = oldParent.get(0);
|
||||
for (BomNewEbomParentEntity u :
|
||||
oldParent) {
|
||||
u.setLastVersionIs(0);
|
||||
lastParent=u;
|
||||
lastParent = u;
|
||||
}
|
||||
getParentEntity().setCurrentVersion(VersionUtil.getNextVersion(lastParent.getCurrentVersion()));
|
||||
SpringUtil.getBean(BomNewEbomParentService.class).updateBatchById(oldParent);
|
||||
|
|
|
|||
Loading…
Reference in New Issue