暂存/提交验证调整

This commit is contained in:
jing's 2024-03-20 09:37:32 +08:00
parent d055077b3f
commit 83aaed97f6
2 changed files with 47 additions and 33 deletions

View File

@ -377,6 +377,7 @@ public class EbomApi extends BaseApi {
@ApiOperation("提交")
@LogRecord(success = "Ebom-提交,物料编码:{{#dto.parent.materialNo}}-版本:{{#dto.parent.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#dto.parent.rowId}}",type = "Ebom-提交")
public ResultVO<Boolean> submit(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
return ResultVO.success(bomNewEbomParentService.submit(dto));
}

View File

@ -114,18 +114,18 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
}
if (StrUtil.isNotBlank(materialNo)) {
List<BomNewEbomParentEntity> materialBoms = this.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo,materialNo).eq(BomNewEbomParentEntity::getLastVersionIs, 1)
.ne(BomNewEbomParentEntity::getStatus,EBomStatusEnum.PUBLISHED.getValue()).list();
if(query.getDataType().equals(0) && CollUtil.isEmpty(materialBoms) ){
List<BomNewEbomParentEntity> materialBoms = this.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, materialNo).eq(BomNewEbomParentEntity::getLastVersionIs, 1)
.ne(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list();
if (query.getDataType().equals(0) && CollUtil.isEmpty(materialBoms)) {
return returnResult;
}
List<String> materialNos=new ArrayList<>();
List<String> materialNos = new ArrayList<>();
List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician()).stream().collect(Collectors.toList());
materialNos.add(materialNo);
materialNos.addAll(parentMaterialByMaterialNo);
if (CollUtil.isNotEmpty(materialNos)) {
List<BomNewEbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(materialNos, query.getDataType());
List<BomNewEbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(materialNos, materialNo,query.getDataType());
List<BomNewEbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(materialNos, materialNo, query.getDataType());
List<BomNewEbomParentVO> data = new ArrayList<>();
data.addAll(parents);
data.addAll(childs);
@ -687,10 +687,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
for (Long bomRowId : paramDto.getBomRowIds()) {
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, this.getById(bomRowId));
VUtils.isTure(Objects.isNull(parent)).throwMessage("Bom版本不存在"+bomRowId.toString());
VUtils.isTure(Objects.isNull(parent)).throwMessage("Bom版本不存在" + bomRowId.toString());
LogRecordContext.putVariable("bom", parent);
List<BomNewEbomParentVO> bomTree = getBomTree(bomRowId);
VUtils.isTure(CollUtil.isEmpty(bomTree)).throwMessage("该BOM不存在下级无需转换"+ bomRowId.toString());
VUtils.isTure(CollUtil.isEmpty(bomTree)).throwMessage("该BOM不存在下级无需转换" + bomRowId.toString());
parent.setBomRowId(parent.getRowId());
parent.setChildBomRowId(parent.getRowId());
parent.setParentRowId(0L);
@ -757,13 +757,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
}
private void upRootMark(BomNewEbomParentVO parent){
private void upRootMark(BomNewEbomParentVO parent) {
Integer rootIs = this.getBaseMapper().checkIsRoot(parent.getMaterialNo());
Integer userRootIs=this.getBaseMapper().checkIsUserRoot(parent.getMaterialNo(),parent.getCreatedBy());
BomNewEbomParentEntity ebomParent=new BomNewEbomParentEntity();
Integer userRootIs = this.getBaseMapper().checkIsUserRoot(parent.getMaterialNo(), parent.getCreatedBy());
BomNewEbomParentEntity ebomParent = new BomNewEbomParentEntity();
ebomParent.setRowId(parent.getRowId());
ebomParent.setRootIs(rootIs>0?0:1);
ebomParent.setUserRootIs(userRootIs>0?0:1);
ebomParent.setRootIs(rootIs > 0 ? 0 : 1);
ebomParent.setUserRootIs(userRootIs > 0 ? 0 : 1);
this.updateById(ebomParent);
@ -921,8 +921,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}, result);
BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectById(dto.getRowId());
if(parentEntity==null){
throw new NflgBusinessException(STATE.Error, StrUtil.format("bom {} 数据未查询到",dto.getRowId()));
if (parentEntity == null) {
throw new NflgBusinessException(STATE.Error, StrUtil.format("bom {} 数据未查询到", dto.getRowId()));
}
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parentEntity);
@ -978,8 +978,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
if ( eBomEdit.getParentEntity()!=null) {
this.saveOrUpdate( eBomEdit.getParentEntity());
if (eBomEdit.getParentEntity() != null) {
this.saveOrUpdate(eBomEdit.getParentEntity());
}
if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
@ -1294,11 +1294,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
return true;
}
public BomNewEbomEditDetailVO editDetail( Long rowId,Long bomRowId, String projectType) {
public BomNewEbomEditDetailVO editDetail(Long rowId, Long bomRowId, String projectType) {
BomNewEbomEditDetailVO vo = new BomNewEbomEditDetailVO();
BomNewEbomParentVO parentVO;
if(bomRowId==null || bomRowId.longValue()==0) {
if (bomRowId == null || bomRowId.longValue() == 0) {
BomNewEbomChildEntity child = SpringUtil.getBean(BomNewEbomChildService.class).getBaseMapper().selectById(rowId);
@ -1309,12 +1309,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|| (parentVO.getMaterialCategoryCode().startsWith("20") && (MaterialGetEnum.outsource.equalsValue(parentVO.getMaterialGetType()) || MaterialGetEnum.purchase.equalsValue(parentVO.getMaterialGetType())))
|| parentVO.getMaterialCategoryCode().equals("7013")) {
;
}else{
} else {
VUtils.isTure(true).throwMessage("编辑条件需满足1.存在下级物料或是缺BOM 2.物料的分类20且流程类型为外协和采购部分\n" +
" 3.分类70中的7013时的物料 ");
}
vo.setDatas(new ArrayList<>());
}else{
} else {
BomNewEbomParentEntity parent = this.getBaseMapper().selectById(bomRowId);
parentVO = Convert.convert(BomNewEbomParentVO.class, parent);
@ -1520,6 +1520,17 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
@Transactional(rollbackFor = Exception.class)
public BomNewEbomParentVO temporary(BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
if (CollectionUtil.isNotEmpty(dto.getDelDatas())) {
deleteBomChild(dto.getDelDatas());
}
//暂存数据为空后面不处理
if (CollUtil.isEmpty(dto.getDatas())) {
return dto.getParent();
}
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
dto.setOpType(EbomEditStatusEnum.HANDLER_CREATED.getValue());
eBomEdit.handleBom(dto);
@ -1531,7 +1542,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
}
if (eBomEdit.getParentEntity()!=null) {
if (eBomEdit.getParentEntity() != null) {
this.saveOrUpdate(eBomEdit.getParentEntity());
}
@ -1547,7 +1558,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
ebomChildService.getBaseMapper().updateEBomMaterialUse();
// ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
BomNewEbomParentVO retParentVO= Convert.convert(BomNewEbomParentVO.class,eBomEdit.getParentEntity());
BomNewEbomParentVO retParentVO = Convert.convert(BomNewEbomParentVO.class, eBomEdit.getParentEntity());
retParentVO.setBomRowId(retParentVO.getRowId());
return retParentVO;
@ -1561,6 +1572,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
@Transactional(rollbackFor = Exception.class)
public Boolean submit(BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
if (CollectionUtil.isNotEmpty(dto.getDelDatas())) {
deleteBomChild(dto.getDelDatas());
}
//无提交数据后面不处理
if (CollUtil.isEmpty(dto.getDatas())) {
return true;
}
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
dto.setOpType(EbomEditStatusEnum.HANDLER_FINISHED.getValue());
eBomEdit.handleBom(dto);
@ -1576,14 +1596,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
EBomExceptionStatusEnum.EXCEPT_NO_10.getValue()
});
if (dto.getParent() != null) {
if (CollectionUtil.isNotEmpty(dto.getDelDatas())) {
deleteBomChild(dto.getDelDatas());
}
}
if ( eBomEdit.getParentEntity()!=null) {
if (eBomEdit.getParentEntity() != null) {
this.saveOrUpdate(eBomEdit.getParentEntity());
}
@ -1598,7 +1612,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
@ -1635,10 +1648,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentVO> delTagList = new ArrayList<>();
List<BomNewEbomParentVO> okList = 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(CollUtil.isNotEmpty(okList)){
throw new NflgBusinessException(STATE.Error,"从原始Bom导入的数据数据没有异常的情况下不可以删除");
if (CollUtil.isNotEmpty(okList)) {
throw new NflgBusinessException(STATE.Error, "从原始Bom导入的数据数据没有异常的情况下不可以删除");
}