This commit is contained in:
jing's 2024-01-06 12:02:15 +08:00
parent 9f20578fef
commit b29fdd0baf
6 changed files with 167 additions and 157 deletions

View File

@ -3,6 +3,7 @@ package com.nflg.product.bomnew.pojo.vo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
/** /**
@ -60,7 +61,7 @@ public class BaseMaterialVO {
@ApiModelProperty("单位") @ApiModelProperty("单位")
private String materialUnit; private String materialUnit;
@ApiModelProperty("单重")
private BigDecimal materialWeight;
} }

View File

@ -215,9 +215,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
return result; return result;
} }
private Set<String> getParentMaterialByUse(List<BomNewEbomMaterialUseEntity> list){ private Set<String> getParentMaterialByUse(List<BomNewEbomMaterialUseEntity> list) {
Set<String> result=new HashSet<>(); Set<String> result = new HashSet<>();
for ( BomNewEbomMaterialUseEntity materialUse: list) { for (BomNewEbomMaterialUseEntity materialUse : list) {
Set<String> relSkuNo = Sets.newHashSet(StrUtil.split(materialUse.getParentMaterialNo(), ",")); Set<String> relSkuNo = Sets.newHashSet(StrUtil.split(materialUse.getParentMaterialNo(), ","));
result.addAll(relSkuNo); result.addAll(relSkuNo);
} }
@ -291,8 +291,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
child.setSourceRowId(parentEntity.getSourceRowId()); child.setSourceRowId(parentEntity.getSourceRowId());
child.setBomExist(parentEntity.getBomExist()); child.setBomExist(parentEntity.getBomExist());
child.setShouldBomExist(parentEntity.getShouldBomExist()); child.setShouldBomExist(parentEntity.getShouldBomExist());
child.setVirtualPackageIs(parentEntity.getVirtualPackageIs()) ; child.setVirtualPackageIs(parentEntity.getVirtualPackageIs());
if (parentEntity.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())) { if (parentEntity.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())) {
@ -307,7 +306,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
child.setDeptName(parent.getDeptName()); child.setDeptName(parent.getDeptName());
child.setStatus(parent.getStatus()); child.setStatus(parent.getStatus());
child.setEditStatus(parent.getEditStatus()); child.setEditStatus(parent.getEditStatus());
child.setVirtualPackageIs(parent.getVirtualPackageIs()) ; child.setVirtualPackageIs(parent.getVirtualPackageIs());
if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) { if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION); child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
child.setStatus(parent.getStatus()); child.setStatus(parent.getStatus());
@ -420,7 +419,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
// initBomException(list,new String[]{}); // initBomException(list,new String[]{});
} }
public void initBomException(List<BomNewEbomParentVO> list, String ... ignorePropertyList) { public void initBomException(List<BomNewEbomParentVO> list, String... ignorePropertyList) {
CheckEBomException checkEBomException = new CheckEBomException(list); CheckEBomException checkEBomException = new CheckEBomException(list);
checkEBomException.initException(ignorePropertyList); checkEBomException.initException(ignorePropertyList);
@ -429,9 +428,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
public void checkBomException(List<BomNewEbomParentVO> list, List<Integer> unCheckList) {
public void checkBomException(List<BomNewEbomParentVO> list) {
CheckEBomException checkEBomException = new CheckEBomException(list); CheckEBomException checkEBomException = new CheckEBomException(list);
checkEBomException.setUnCheckExcept(unCheckList);
checkEBomException.checkException(); checkEBomException.checkException();
//保存异常 //保存异常
@ -452,10 +451,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
saveException(checkEBomException); saveException(checkEBomException);
} }
private void saveException(CheckEBomException checkEBomException){ private void saveException(CheckEBomException checkEBomException) {
List<BomNewEbomParentVO> allBomDetail = checkEBomException.getAllBomDetail(); List<BomNewEbomParentVO> allBomDetail = checkEBomException.getAllBomDetail();
//父级 //父级
List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()); List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> u.getBomRowId() != null && u.getBomRowId() > 0).collect(Collectors.toList());
if (CollUtil.isNotEmpty(parents)) { if (CollUtil.isNotEmpty(parents)) {
List<BomNewEbomParentEntity> pentList = new ArrayList<>(); List<BomNewEbomParentEntity> pentList = new ArrayList<>();
parents.forEach(k -> { parents.forEach(k -> {
@ -469,7 +468,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
} }
//子级 //子级
List<BomNewEbomParentVO> child = allBomDetail.stream().filter(u -> u.getRowId() > 0).collect(Collectors.toList()); List<BomNewEbomParentVO> child = allBomDetail.stream().filter(u -> u.getRowId() != null && u.getRowId() > 0).collect(Collectors.toList());
if (CollUtil.isNotEmpty(parents)) { if (CollUtil.isNotEmpty(parents)) {
List<BomNewEbomChildEntity> childList = new ArrayList<>(); List<BomNewEbomChildEntity> childList = new ArrayList<>();
child.forEach(k -> { child.forEach(k -> {
@ -509,6 +508,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
/** /**
* 检查 并保存异常信息 * 检查 并保存异常信息
*/ */
@ -524,9 +524,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
/** /**
* 生成虚拟包 * 生成虚拟包
* *
@ -643,14 +640,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
public void editExportBom(List<BomNewEbomParentVO> list, HttpServletResponse response) throws IOException { public void editExportBom(List<BomNewEbomParentVO> list, HttpServletResponse response) throws IOException {
final ListSheet<EbomExcelEditVO> listSheet = new ListSheet<EbomExcelEditVO>() { final ListSheet<EbomExcelEditVO> listSheet = new ListSheet<EbomExcelEditVO>() {
Long n = 0L; Long n = 0L;
Long pages = 1L; Long pages = 1L;
@Override @Override
protected List<EbomExcelEditVO> more() { protected List<EbomExcelEditVO> more() {
@ -662,15 +656,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
public void exportBom(List<Long> bomRowIds, HttpServletResponse response) throws IOException { public void exportBom(List<Long> bomRowIds, HttpServletResponse response) throws IOException {
final ListSheet<EbomExcelVO> listSheet = new ListSheet<EbomExcelVO>() { final ListSheet<EbomExcelVO> listSheet = new ListSheet<EbomExcelVO>() {
Long n = 0L; Long n = 0L;
Long pages = 1L; Long pages = 1L;
@Override @Override
protected List<EbomExcelVO> more() { protected List<EbomExcelVO> more() {
List<BomNewEbomParentVO> child = getChildBatch(bomRowIds); List<BomNewEbomParentVO> child = getChildBatch(bomRowIds);
@ -681,9 +672,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
/** /**
* 计算BOM树高度 * 计算BOM树高度
* *
@ -732,25 +720,25 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class); List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class);
if(CollectionUtil.isEmpty(result)){ if (CollectionUtil.isEmpty(result)) {
throw new NflgBusinessException(STATE.Error,"上传数据为空"); throw new NflgBusinessException(STATE.Error, "上传数据为空");
} }
List<String> materialNos = result.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); List<String> materialNos = result.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
CheckEBomException.checkMaterialNoInMain1(materialNos); CheckEBomException.checkMaterialNoInMain1(materialNos);
EBomImportExcelCheck eBomImportExcelCheck=new EBomImportExcelCheck(); EBomImportExcelCheck eBomImportExcelCheck = new EBomImportExcelCheck();
eBomImportExcelCheck.validData(result); eBomImportExcelCheck.validData(result);
List<BomNewEbomParentVO> datas = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() { List<BomNewEbomParentVO> datas = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
}, result); }, result);
BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectById(dto.getRowId()); BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectById(dto.getRowId());
BomNewEbomParentVO parentVO=Convert.convert(BomNewEbomParentVO.class,parentEntity); BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parentEntity);
parentVO.setBomRowId(parentVO.getRowId()); parentVO.setBomRowId(parentVO.getRowId());
parentVO.setParentRowId(0l); parentVO.setParentRowId(0l);
materialMainService.intiMaterialInfo(datas, "projectType","materialWeight", materialMainService.intiMaterialInfo(datas, "projectType", "materialWeight",
"material_texture"); "material_texture");
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_EXCE.getValue()); EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_EXCE.getValue());
BomNewEBomParentEditDTO bomNewEBomParentEditDTO = new BomNewEBomParentEditDTO(); BomNewEBomParentEditDTO bomNewEBomParentEditDTO = new BomNewEBomParentEditDTO();
@ -759,28 +747,26 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
eBomEdit.temporary(bomNewEBomParentEditDTO); eBomEdit.temporary(bomNewEBomParentEditDTO);
int orderNo = 1;
if (dto.isDel()) {
int orderNo=1; if ((parentVO.getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
if(dto.isDel()){
if ( (parentVO.getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|| parentVO.getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))) { || parentVO.getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))) {
deleteBom(dto.getRowId()); deleteBom(dto.getRowId());
} }
}else { } else {
QueryWrapper<BomNewEbomChildEntity > queryWrapper=new QueryWrapper<>(); QueryWrapper<BomNewEbomChildEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId,dto.getRowId()).last("limit 1"); queryWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId, dto.getRowId()).last("limit 1");
queryWrapper.lambda().orderByDesc(BomNewEbomChildEntity::getOrderNumber); queryWrapper.lambda().orderByDesc(BomNewEbomChildEntity::getOrderNumber);
BomNewEbomChildEntity entity= ebomChildService.getOne(queryWrapper); BomNewEbomChildEntity entity = ebomChildService.getOne(queryWrapper);
if(entity!=null && StrUtil.isNotEmpty(entity.getOrderNumber())){ if (entity != null && StrUtil.isNotEmpty(entity.getOrderNumber())) {
orderNo= Integer.parseInt(entity.getOrderNumber()) ; orderNo = Integer.parseInt(entity.getOrderNumber());
orderNo++; orderNo++;
} }
} }
for(BomNewEbomChildEntity childEntities:eBomEdit.childEntities){ for (BomNewEbomChildEntity childEntities : eBomEdit.childEntities) {
childEntities.setOrderNumber(OrderNoUtil.orderNo2Str(orderNo)); childEntities.setOrderNumber(OrderNoUtil.orderNo2Str(orderNo));
orderNo++; orderNo++;
} }
@ -912,7 +898,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
// //
// throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已退回,不需要退回设计", StrUtil.join(",", materialNoList))); // throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已退回,不需要退回设计", StrUtil.join(",", materialNoList)));
// } // }
if (CollectionUtil.isNotEmpty(pbomList) ) { if (CollectionUtil.isNotEmpty(pbomList)) {
List<String> materialNoList = pbomList.stream().map(BomNewEbomParentVO::getMaterialNo).collect(Collectors.toList()); List<String> materialNoList = pbomList.stream().map(BomNewEbomParentVO::getMaterialNo).collect(Collectors.toList());
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已发布PBOM无法退回设计", StrUtil.join(",", materialNoList))); throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已发布PBOM无法退回设计", StrUtil.join(",", materialNoList)));
@ -926,8 +912,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
if (CollectionUtil.isNotEmpty(revertList)) {
if(CollectionUtil.isNotEmpty(revertList)) {
UpdateWrapper<BomNewEbomParentEntity> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<BomNewEbomParentEntity> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda() updateWrapper.lambda()
.set(BomNewEbomParentEntity::getRevertTime, LocalDateTime.now()) .set(BomNewEbomParentEntity::getRevertTime, LocalDateTime.now())
@ -936,12 +921,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
.set(BomNewEbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_CREATED.getValue()) .set(BomNewEbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_CREATED.getValue())
.in(BomNewEbomParentEntity::getRowId, revertList); .in(BomNewEbomParentEntity::getRowId, revertList);
UpdateWrapper<BomNewEbomChildEntity > childWrapper = new UpdateWrapper<>(); UpdateWrapper<BomNewEbomChildEntity> childWrapper = new UpdateWrapper<>();
childWrapper.lambda() childWrapper.lambda()
.set(BomNewEbomChildEntity::getModifyTime, LocalDateTime.now()) .set(BomNewEbomChildEntity::getModifyTime, LocalDateTime.now())
.set(BomNewEbomChildEntity::getEditStatus, EbomEditStatusEnum.HANDLER_CREATED.getValue()) .set(BomNewEbomChildEntity::getEditStatus, EbomEditStatusEnum.HANDLER_CREATED.getValue())
.in(BomNewEbomChildEntity ::getParentRowId, revertList); .in(BomNewEbomChildEntity::getParentRowId, revertList);
if (!this.update(updateWrapper)) { if (!this.update(updateWrapper)) {
throw new NflgBusinessException(STATE.Error, "退回设计失败"); throw new NflgBusinessException(STATE.Error, "退回设计失败");
@ -1008,7 +993,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<Long> updateReviewIdList = new ArrayList<>(); List<Long> updateReviewIdList = new ArrayList<>();
for (Long bomRowId : for (Long bomRowId :
rowIds) { rowIds) {
List<BomNewEbomParentVO > childList=getBomTree(bomRowId); List<BomNewEbomParentVO> childList = getBomTree(bomRowId);
CheckEBomException checkEBomException = new CheckEBomException(childList); CheckEBomException checkEBomException = new CheckEBomException(childList);
// System.out.println(JSON.toJSONString(checkEBomException.getAllBomDetail())); // System.out.println(JSON.toJSONString(checkEBomException.getAllBomDetail()));
checkEBomException.initException(); checkEBomException.initException();
@ -1025,23 +1010,23 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
//改变复核状态 //改变复核状态
if(CollectionUtil.isNotEmpty(updateReviewIdList)){ if (CollectionUtil.isNotEmpty(updateReviewIdList)) {
UpdateWrapper<BomNewEbomParentEntity> updateWrapper=new UpdateWrapper<>(); UpdateWrapper<BomNewEbomParentEntity> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda() updateWrapper.lambda()
.set(BomNewEbomParentEntity::getAuditTime,LocalDateTime.now()) .set(BomNewEbomParentEntity::getAuditTime, LocalDateTime.now())
.set(BomNewEbomParentEntity::getAuditUserName,SessionUtil.getUserName()) .set(BomNewEbomParentEntity::getAuditUserName, SessionUtil.getUserName())
.set(BomNewEbomParentEntity::getStatus,EBomStatusEnum.CHECKED.getValue()) .set(BomNewEbomParentEntity::getStatus, EBomStatusEnum.CHECKED.getValue())
.set(BomNewEbomParentEntity::getEditStatus,EbomEditStatusEnum.HANDLER_FINISHED.getValue()) .set(BomNewEbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_FINISHED.getValue())
.in(BomNewEbomParentEntity::getRowId,updateReviewIdList); .in(BomNewEbomParentEntity::getRowId, updateReviewIdList);
UpdateWrapper<BomNewEbomChildEntity > childWrapper = new UpdateWrapper<>(); UpdateWrapper<BomNewEbomChildEntity> childWrapper = new UpdateWrapper<>();
childWrapper.lambda() childWrapper.lambda()
.set(BomNewEbomChildEntity::getModifyTime, LocalDateTime.now()) .set(BomNewEbomChildEntity::getModifyTime, LocalDateTime.now())
.set(BomNewEbomChildEntity::getEditStatus, EbomEditStatusEnum.HANDLER_FINISHED.getValue()) .set(BomNewEbomChildEntity::getEditStatus, EbomEditStatusEnum.HANDLER_FINISHED.getValue())
.in(BomNewEbomChildEntity ::getParentRowId, updateReviewIdList); .in(BomNewEbomChildEntity::getParentRowId, updateReviewIdList);
if (! this.update(updateWrapper)) { if (!this.update(updateWrapper)) {
throw new NflgBusinessException(STATE.Error, "复核失败"); throw new NflgBusinessException(STATE.Error, "复核失败");
} }
ebomChildService.update(childWrapper); ebomChildService.update(childWrapper);
@ -1101,7 +1086,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
return true; return true;
} }
public BomNewEbomEditDetailVO editDetail(Long bomRowId,String projectType) { public BomNewEbomEditDetailVO editDetail(Long bomRowId, String projectType) {
BomNewEbomEditDetailVO vo = new BomNewEbomEditDetailVO(); BomNewEbomEditDetailVO vo = new BomNewEbomEditDetailVO();
BomNewEbomParentEntity parent = this.getBaseMapper().selectById(bomRowId); BomNewEbomParentEntity parent = this.getBaseMapper().selectById(bomRowId);
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parent); BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parent);
@ -1226,8 +1211,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
eBomEdit.temporary(dto); eBomEdit.temporary(dto);
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) { if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities); this.saveOrUpdateBatch(eBomEdit.parentEntities);
} }
@ -1242,9 +1225,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
deleteBomChild(dto.getDelDatas()); deleteBomChild(dto.getDelDatas());
} }
} }
List<BomNewEbomParentVO> childList=dto.getDatas(); List<BomNewEbomParentVO> childList = dto.getDatas();
if( dto.getParent().getRootIs()==null || dto.getParent().getRootIs()==0) { if (dto.getParent().getRootIs() == null || dto.getParent().getRootIs() == 0) {
childList.add(dto.getParent()); childList.add(dto.getParent());
} }
checkAndSaveEBomException(childList); checkAndSaveEBomException(childList);
@ -1281,16 +1264,16 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
} }
if(CollectionUtil.isNotEmpty(eBomEdit.childEntities)){ if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
List<BomNewEbomParentVO> allBom = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() { List<BomNewEbomParentVO> allBom = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
}, eBomEdit.childEntities); }, eBomEdit.childEntities);
BomNewEbomParentVO parent = Convert.convert( BomNewEbomParentVO .class BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class
, eBomEdit.parentEntities.get(0)); , eBomEdit.parentEntities.get(0));
if(dto.getParent().getRootIs()==null || dto.getParent().getRootIs()==0) { if (dto.getParent().getRootIs() == null || dto.getParent().getRootIs() == 0) {
allBom.add(parent); allBom.add(parent);
} }
@ -1309,12 +1292,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
// checkAndSaveEBomException(dto.getParent().getBomRowId()); // checkAndSaveEBomException(dto.getParent().getBomRowId());
List<BomNewEbomParentVO> childList= dto.getDatas(); List<BomNewEbomParentVO> childList = dto.getDatas();
if(dto.getParent().getRootIs()==null || dto.getParent().getRootIs()==0) { if (dto.getParent().getRootIs() == null || dto.getParent().getRootIs() == 0) {
childList.add(dto.getParent()); childList.add(dto.getParent());
} }
@ -1377,12 +1359,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentVO> checkBom = new ArrayList<>(); List<BomNewEbomParentVO> checkBom = new ArrayList<>();
List<BomNewEbomParentVO> tmp1=dto.getDatas().stream().filter(item->Objects.nonNull(item.getRowId()) && item.getRowId()>0).collect(Collectors.toList()); List<BomNewEbomParentVO> tmp1 = dto.getDatas().stream().filter(item -> Objects.nonNull(item.getRowId()) && item.getRowId() > 0).collect(Collectors.toList());
List<BomNewEbomParentVO> tmp2=dto.getDatas().stream().filter(item->Objects.isNull(item.getRowId()) || item.getRowId()==0).collect(Collectors.toList()); List<BomNewEbomParentVO> tmp2 = dto.getDatas().stream().filter(item -> Objects.isNull(item.getRowId()) || item.getRowId() == 0).collect(Collectors.toList());
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(tmp2);
String[] ignore= new String[]{ SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(tmp2, "");
String[] ignore = new String[]{
"projectType", "projectType",
"procureType", "procureType",
"materialUnit", "materialUnit",
@ -1390,32 +1373,39 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
"materialTexture", "materialTexture",
"materialGetType" "materialGetType"
}; };
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(tmp1,ignore); SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(tmp1, ignore);
checkBom.addAll(tmp1); checkBom.addAll(tmp1);
checkBom.addAll(tmp2); checkBom.addAll(tmp2);
if(dto.getParent().getRootIs()==null ||dto.getParent().getRootIs()==0 ) { // if(dto.getParent().getRootIs()==null ||dto.getParent().getRootIs()==0 ) {
// checkBom.add(dto.getParent());
// }
checkBom.add(dto.getParent()); checkBom.add(dto.getParent());
}
// CheckEBomException checkEBomException = new CheckEBomException(checkBom); // CheckEBomException checkEBomException = new CheckEBomException(checkBom);
// checkEBomException.checkException(); // checkEBomException.checkException();
// this.initBomException(checkBom); // this.initBomException(checkBom);
checkBomException(checkBom);
if(CollectionUtil.isNotEmpty(dto.getDatas())){ checkBomException(checkBom, Arrays.asList(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue()));
for (BomNewEbomParentVO vo: if (CollectionUtil.isNotEmpty(dto.getDatas())) {
for (BomNewEbomParentVO vo :
dto.getDatas()) { dto.getDatas()) {
if(Objects.isNull(vo.getRowId()) ||vo.getRowId()==0 ){ if (Objects.isNull(vo.getRowId()) || vo.getRowId() == 0) {
vo.setDeviseUserCode(SessionUtil.getUserCode()); vo.setDeviseUserCode(SessionUtil.getUserCode());
vo.setDeviseName(SessionUtil.getRealName()); vo.setDeviseName(SessionUtil.getRealName());
vo.setCreatedBy(SessionUtil.getUserCode()); vo.setCreatedBy(SessionUtil.getUserCode());
if (vo.getUnitWeight() == null ||BigDecimal.ZERO.compareTo(vo.getUnitWeight()) >= 0) {
vo.setUnitWeight(vo.getMaterialWeight());
}
vo.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum()));
} }
} }
} }
return dto.getDatas(); return dto.getDatas();
} }
} }

View File

@ -128,7 +128,7 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
* *
* @param list * @param list
* @param * @param
* @param setFun * @param
* @param <T> * @param <T>
*/ */
public <T> void initMaterialForDrawdingNo public <T> void initMaterialForDrawdingNo

View File

@ -22,6 +22,7 @@ import com.nflg.product.bomnew.util.ListCommonUtil;
import com.nflg.product.bomnew.util.TreeUtils; import com.nflg.product.bomnew.util.TreeUtils;
import com.nflg.product.bomnew.util.VUtils; import com.nflg.product.bomnew.util.VUtils;
import lombok.Getter; import lombok.Getter;
import lombok.Setter;
import nflg.product.common.constant.STATE; import nflg.product.common.constant.STATE;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -36,8 +37,8 @@ public class CheckEBomException {
@Getter @Getter
List<BomNewEbomParentVO> allBomDetail ; List<BomNewEbomParentVO> allBomDetail ;
@Setter
List<Integer> unCheckExcept;
public static void checkMaterialNoInMain1(List<String> materialNos){ public static void checkMaterialNoInMain1(List<String> materialNos){
@ -98,6 +99,13 @@ public class CheckEBomException {
public void checkException(){ public void checkException(){
for (BomNewEbomParentVO vo : allBomDetail) { for (BomNewEbomParentVO vo : allBomDetail) {
// if(Objects.isNull(vo.getExceptionStatus())) { // if(Objects.isNull(vo.getExceptionStatus())) {
//忽略不检查的如14
if(CollectionUtil.isNotEmpty(unCheckExcept)
&& vo.getExceptionStatus()!=null
&&unCheckExcept.contains(vo.getExceptionStatus())){
continue;
}
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
// } // }
if (StrUtil.isNotBlank(vo.getMaterialNo()) if (StrUtil.isNotBlank(vo.getMaterialNo())

View File

@ -39,8 +39,8 @@ public class EBomEdit {
Integer source; Integer source;
public EBomEdit(Integer source){ public EBomEdit(Integer source) {
this.source=source; this.source = source;
} }
BomNewEbomParentEntity createParentBomInfo(BomNewEbomParentVO vo) { BomNewEbomParentEntity createParentBomInfo(BomNewEbomParentVO vo) {
@ -76,14 +76,32 @@ public class EBomEdit {
// parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue()); // parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
// } // }
parent.setStatus(SpringUtil.getBean(UserRoleService.class).technician()? EBomStatusEnum.CHECKED.getValue():EBomStatusEnum.WAIT_CHECK.getValue()); parent.setStatus(SpringUtil.getBean(UserRoleService.class).technician() ? EBomStatusEnum.CHECKED.getValue() : EBomStatusEnum.WAIT_CHECK.getValue());
parent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician()?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue()); parent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
return parent; return parent;
} }
private void checkExcept(BomNewEbomParentVO parent, BomNewEbomChildEntity child) {
if (StrUtil.isBlank(child.getMaterialNo()) || Objects.isNull(child.getNum())
|| BigDecimal.ZERO.compareTo(child.getNum()) >= 0) {
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue());
} else if (StrUtil.isEmpty(child.getProjectType())) {
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
} else if (StrUtil.isNotBlank(parent.getProjectType())
&& StrUtil.containsAny(parent.getProjectType(), ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(), ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue())) {
if (StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(), child.getProjectType())) {
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue());
}
if (StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue(), child.getProjectType())) {
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue());
}
}
}
public void temporary(BomNewEBomParentEditDTO dto) { public void temporary(BomNewEBomParentEditDTO dto) {
@ -91,12 +109,12 @@ public class EBomEdit {
parentEntities = new ArrayList<>(); parentEntities = new ArrayList<>();
childEntities = new ArrayList<>(); childEntities = new ArrayList<>();
List<String> roleList= SpringUtil.getBean(UserRoleService.class).getUserPost(); List<String> roleList = SpringUtil.getBean(UserRoleService.class).getUserPost();
//添加数据 //添加数据
if (dto.getParent() == null) { if (dto.getParent() == null) {
for (BomNewEbomParentVO vo : dto.getDatas()) { for (BomNewEbomParentVO vo : dto.getDatas()) {
parentEntities.add(createParentBomInfo (vo)); parentEntities.add(createParentBomInfo(vo));
} }
} else { } else {
@ -109,7 +127,7 @@ public class EBomEdit {
parent = createParentBomInfo(dto.getParent()); parent = createParentBomInfo(dto.getParent());
parent.setEditStatus(dto.getOpType()); parent.setEditStatus(dto.getOpType());
parentEntities.add(parent); parentEntities.add(parent);
}else { } else {
parent = Convert.convert(BomNewEbomParentEntity.class, dto.getParent()); parent = Convert.convert(BomNewEbomParentEntity.class, dto.getParent());
parent.setEditStatus(dto.getOpType()); parent.setEditStatus(dto.getOpType());
@ -117,7 +135,7 @@ public class EBomEdit {
} }
childEntities=Convert.convert(new TypeReference<List<BomNewEbomChildEntity>>() { childEntities = Convert.convert(new TypeReference<List<BomNewEbomChildEntity>>() {
}, dto.getDatas()); }, dto.getDatas());
for (BomNewEbomChildEntity child : for (BomNewEbomChildEntity child :
@ -126,7 +144,7 @@ public class EBomEdit {
child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum())); child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
//新增数据 //新增数据
if(child.getRowId()==null || child.getRowId().longValue()==0){ if (child.getRowId() == null || child.getRowId().longValue() == 0) {
child.setRowId(IdWorker.getId()); child.setRowId(IdWorker.getId());
child.setIdentityNo(StrUtil.join("_", parent.getRowId(), child.getRowId())); child.setIdentityNo(StrUtil.join("_", parent.getRowId(), child.getRowId()));
@ -137,29 +155,34 @@ public class EBomEdit {
child.setSourceRowId(0l); child.setSourceRowId(0l);
child.setParentRowId(parent.getRowId()); child.setParentRowId(parent.getRowId());
child.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); child.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); // parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
//工艺人员 //工艺人员
if(roleList.contains(EBomConstant.TECHNICIAN)){ // 设计岗位设计岗位的用户只可以编辑未被设计复核过且是自己创建的物料如果设计岗位在编辑过程中新增的物料做为未被设计复核
parent.setStatus(EBomStatusEnum.CHECKED.getValue()); // 工艺岗位工艺岗位的用户可以编辑被设计复核过的物料如果工艺岗位在编辑过程中新增的物料状态为被设计复核
} // if(roleList.contains(EBomConstant.TECHNICIAN)){
// parent.setStatus(EBomStatusEnum.CHECKED.getValue());
// }
checkExcept(dto.getParent(), child);
} }
child.setEditStatus(dto.getOpType()); child.setEditStatus(dto.getOpType());
if (StrUtil.isNotBlank(child.getProjectType())) {
child.setProjectType(child.getProjectType().toUpperCase());
}
// parent.setCreatedJob(roleList.contains(EBomConstant.TECHNICIAN)?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue()); // parent.setCreatedJob(roleList.contains(EBomConstant.TECHNICIAN)?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue());
// parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum())); // parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
} }
} }
} }
public void submit(BomNewEBomParentEditDTO dto) { public void submit(BomNewEBomParentEditDTO dto) {
@ -170,16 +193,16 @@ public class EBomEdit {
Set<String> difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos)); Set<String> difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos));
VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料档案中不存在"); VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料档案中不存在");
// Map<String, BaseMaterialVO> materialVOMap = ListCommonUtil.listToMap(materialBaseInfo, BaseMaterialVO::getMaterialNo);
parentEntities = new ArrayList<>(); parentEntities = new ArrayList<>();
childEntities = new ArrayList<>(); childEntities = new ArrayList<>();
List<String> roleList= SpringUtil.getBean(UserRoleService.class).getUserPost(); List<String> roleList = SpringUtil.getBean(UserRoleService.class).getUserPost();
//添加数据 //添加数据
if (dto.getParent() == null) { if (dto.getParent() == null) {
CheckEBomException eBomException=new CheckEBomException( dto.getDatas() ); CheckEBomException eBomException = new CheckEBomException(dto.getDatas());
eBomException.checkException(); eBomException.checkException();
for (BomNewEbomParentVO vo : dto.getDatas()) { for (BomNewEbomParentVO vo : dto.getDatas()) {
parentEntities.add(createParentBomInfo (vo)); parentEntities.add(createParentBomInfo(vo));
} }
} else { } else {
@ -192,16 +215,16 @@ public class EBomEdit {
parent.setEditStatus(dto.getOpType()); parent.setEditStatus(dto.getOpType());
//工艺人员 //工艺人员
if(roleList.contains(EBomConstant.TECHNICIAN)){ if (roleList.contains(EBomConstant.TECHNICIAN)) {
parent.setStatus(EBomStatusEnum.CHECKED.getValue()); parent.setStatus(EBomStatusEnum.CHECKED.getValue());
} }
parentEntities.add(parent); parentEntities.add(parent);
}else { } else {
parent = Convert.convert(BomNewEbomParentEntity.class, dto.getParent()); parent = Convert.convert(BomNewEbomParentEntity.class, dto.getParent());
parent.setEditStatus(dto.getOpType()); parent.setEditStatus(dto.getOpType());
//工艺人员 //工艺人员
if(roleList.contains(EBomConstant.TECHNICIAN)){ if (roleList.contains(EBomConstant.TECHNICIAN)) {
parent.setStatus(EBomStatusEnum.CHECKED.getValue()); parent.setStatus(EBomStatusEnum.CHECKED.getValue());
} }
@ -209,7 +232,7 @@ public class EBomEdit {
} }
childEntities=Convert.convert(new TypeReference<List<BomNewEbomChildEntity>>() { childEntities = Convert.convert(new TypeReference<List<BomNewEbomChildEntity>>() {
}, dto.getDatas()); }, dto.getDatas());
for (BomNewEbomChildEntity child : for (BomNewEbomChildEntity child :
@ -217,10 +240,10 @@ public class EBomEdit {
//child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue()); //child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum())); // child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
child.setEditStatus(dto.getOpType()); child.setEditStatus(dto.getOpType());
//新增数据 //新增数据
if(child.getRowId()==null || child.getRowId().longValue()==0){ if (child.getRowId() == null || child.getRowId().longValue() == 0) {
child.setRowId(IdWorker.getId()); child.setRowId(IdWorker.getId());
child.setIdentityNo(StrUtil.join("-", parent.getRowId(), parent.getRowId())); child.setIdentityNo(StrUtil.join("-", parent.getRowId(), parent.getRowId()));
@ -232,6 +255,7 @@ public class EBomEdit {
child.setParentRowId(parent.getRowId()); child.setParentRowId(parent.getRowId());
child.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); child.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
// parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); // parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
checkExcept(dto.getParent(), child);
} }
@ -239,21 +263,8 @@ public class EBomEdit {
child.setEditStatus(dto.getOpType()); child.setEditStatus(dto.getOpType());
// parent.setCreatedJob(roleList.contains(EBomConstant.TECHNICIAN)?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue()); // parent.setCreatedJob(roleList.contains(EBomConstant.TECHNICIAN)?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue());
// parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum())); parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
// if(StrUtil.isEmpty(child.getProjectType())){
// child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
// }
//
// if(StrUtil.isNotEmpty(dto.getParent().getProjectType()) && StrUtil.containsAny(dto.getParent().getProjectType(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue())){
// if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),child.getProjectType())){
// child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue());
// }
//
// if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue(),child.getProjectType())){
// child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue());
// }
// }
// VUtils.isTure(parent.getProjectType().equals(child.getProjectType())).throwMessage("父、子级项目类型不能相同"); // VUtils.isTure(parent.getProjectType().equals(child.getProjectType())).throwMessage("父、子级项目类型不能相同");

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,b.category_name,material_unit ,material_texture as material ,material_texture ,material_weight,b.rel_category_code,b.category_name,material_unit
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=",">