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 lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
@ -60,7 +61,7 @@ public class BaseMaterialVO {
@ApiModelProperty("单位")
private String materialUnit;
@ApiModelProperty("单重")
private BigDecimal materialWeight;
}

View File

@ -199,8 +199,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
* @param materialNos
* @return
*/
public List<String> getBatchParentMaterialByMaterialNo(List<String> materialNos) {
List<BomNewEbomMaterialUseEntity> materialBom = bomNewEbomMaterialUseService.lambdaQuery().in(BomNewEbomMaterialUseEntity::getMaterialNo, materialNos).list();
public List<String> getBatchParentMaterialByMaterialNo(List<String> materialNos) {
List<BomNewEbomMaterialUseEntity> materialBom = bomNewEbomMaterialUseService.lambdaQuery().in(BomNewEbomMaterialUseEntity::getMaterialNo, materialNos).list();
List<String> result = new ArrayList<>();
if (CollUtil.isNotEmpty(materialBom)) {
Set<String> relSkuNo = getParentMaterialByUse(materialBom);
@ -215,9 +215,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
return result;
}
private Set<String> getParentMaterialByUse(List<BomNewEbomMaterialUseEntity> list){
Set<String> result=new HashSet<>();
for ( BomNewEbomMaterialUseEntity materialUse: list) {
private Set<String> getParentMaterialByUse(List<BomNewEbomMaterialUseEntity> list) {
Set<String> result = new HashSet<>();
for (BomNewEbomMaterialUseEntity materialUse : list) {
Set<String> relSkuNo = Sets.newHashSet(StrUtil.split(materialUse.getParentMaterialNo(), ","));
result.addAll(relSkuNo);
}
@ -287,12 +287,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
child.setBomRowId(parentEntity.getRowId());
child.setLevelNum(parentEntity.getLevelNum());
child.setDeptName(parentEntity.getDeptName());
// child.setSource(parentEntity.getSource());
// child.setSource(parentEntity.getSource());
child.setSourceRowId(parentEntity.getSourceRowId());
child.setBomExist(parentEntity.getBomExist());
child.setShouldBomExist(parentEntity.getShouldBomExist());
child.setVirtualPackageIs(parentEntity.getVirtualPackageIs()) ;
child.setVirtualPackageIs(parentEntity.getVirtualPackageIs());
if (parentEntity.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())) {
@ -307,7 +306,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
child.setDeptName(parent.getDeptName());
child.setStatus(parent.getStatus());
child.setEditStatus(parent.getEditStatus());
child.setVirtualPackageIs(parent.getVirtualPackageIs()) ;
child.setVirtualPackageIs(parent.getVirtualPackageIs());
if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
child.setStatus(parent.getStatus());
@ -417,10 +416,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
//保存异常
saveException(checkEBomException);
// 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.initException(ignorePropertyList);
@ -429,9 +428,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
public void checkBomException(List<BomNewEbomParentVO> list) {
public void checkBomException(List<BomNewEbomParentVO> list, List<Integer> unCheckList) {
CheckEBomException checkEBomException = new CheckEBomException(list);
checkEBomException.setUnCheckExcept(unCheckList);
checkEBomException.checkException();
//保存异常
@ -452,10 +451,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
saveException(checkEBomException);
}
private void saveException(CheckEBomException checkEBomException){
private void saveException(CheckEBomException checkEBomException) {
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)) {
List<BomNewEbomParentEntity> pentList = new ArrayList<>();
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)) {
List<BomNewEbomChildEntity> childList = new ArrayList<>();
child.forEach(k -> {
@ -509,10 +508,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
/**
* 检查 并保存异常信息
*/
public void batchCheckAndSaveEBomException(List<Long> bomRowIds) throws ExecutionException, InterruptedException {
public void batchCheckAndSaveEBomException(List<Long> bomRowIds) throws ExecutionException, InterruptedException {
for (Long bomRowId : bomRowIds) {
CheckEBomException checkEBomException = new CheckEBomException(bomRowId);
checkEBomException.initException();
@ -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 {
final ListSheet<EbomExcelEditVO> listSheet = new ListSheet<EbomExcelEditVO>() {
Long n = 0L;
Long pages = 1L;
@Override
protected List<EbomExcelEditVO> more() {
@ -662,18 +656,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
public void exportBom(List<Long> bomRowIds, HttpServletResponse response) throws IOException {
final ListSheet<EbomExcelVO> listSheet = new ListSheet<EbomExcelVO>() {
Long n = 0L;
Long pages = 1L;
@Override
protected List<EbomExcelVO> more() {
List<BomNewEbomParentVO> child = getChildBatch(bomRowIds);
List<BomNewEbomParentVO> child = getChildBatch(bomRowIds);
return n++ < pages ? Convert.toList(EbomExcelVO.class, child) : null;
}
};
@ -681,9 +672,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
/**
* 计算BOM树高度
*
@ -732,25 +720,25 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class);
if(CollectionUtil.isEmpty(result)){
throw new NflgBusinessException(STATE.Error,"上传数据为空");
if (CollectionUtil.isEmpty(result)) {
throw new NflgBusinessException(STATE.Error, "上传数据为空");
}
List<String> materialNos = result.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
CheckEBomException.checkMaterialNoInMain1(materialNos);
EBomImportExcelCheck eBomImportExcelCheck=new EBomImportExcelCheck();
EBomImportExcelCheck eBomImportExcelCheck = new EBomImportExcelCheck();
eBomImportExcelCheck.validData(result);
List<BomNewEbomParentVO> datas = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
}, result);
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.setParentRowId(0l);
materialMainService.intiMaterialInfo(datas, "projectType","materialWeight",
materialMainService.intiMaterialInfo(datas, "projectType", "materialWeight",
"material_texture");
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_EXCE.getValue());
BomNewEBomParentEditDTO bomNewEBomParentEditDTO = new BomNewEBomParentEditDTO();
@ -759,28 +747,26 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
eBomEdit.temporary(bomNewEBomParentEditDTO);
int orderNo=1;
if(dto.isDel()){
if ( (parentVO.getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
int orderNo = 1;
if (dto.isDel()) {
if ((parentVO.getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|| parentVO.getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))) {
deleteBom(dto.getRowId());
}
}else {
QueryWrapper<BomNewEbomChildEntity > queryWrapper=new QueryWrapper<>();
queryWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId,dto.getRowId()).last("limit 1");
} else {
QueryWrapper<BomNewEbomChildEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId, dto.getRowId()).last("limit 1");
queryWrapper.lambda().orderByDesc(BomNewEbomChildEntity::getOrderNumber);
BomNewEbomChildEntity entity= ebomChildService.getOne(queryWrapper);
if(entity!=null && StrUtil.isNotEmpty(entity.getOrderNumber())){
orderNo= Integer.parseInt(entity.getOrderNumber()) ;
BomNewEbomChildEntity entity = ebomChildService.getOne(queryWrapper);
if (entity != null && StrUtil.isNotEmpty(entity.getOrderNumber())) {
orderNo = Integer.parseInt(entity.getOrderNumber());
orderNo++;
}
}
for(BomNewEbomChildEntity childEntities:eBomEdit.childEntities){
for (BomNewEbomChildEntity childEntities : eBomEdit.childEntities) {
childEntities.setOrderNumber(OrderNoUtil.orderNo2Str(orderNo));
orderNo++;
}
@ -912,7 +898,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
//
// 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());
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.lambda()
.set(BomNewEbomParentEntity::getRevertTime, LocalDateTime.now())
@ -936,12 +921,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
.set(BomNewEbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_CREATED.getValue())
.in(BomNewEbomParentEntity::getRowId, revertList);
UpdateWrapper<BomNewEbomChildEntity > childWrapper = new UpdateWrapper<>();
UpdateWrapper<BomNewEbomChildEntity> childWrapper = new UpdateWrapper<>();
childWrapper.lambda()
.set(BomNewEbomChildEntity::getModifyTime, LocalDateTime.now())
.set(BomNewEbomChildEntity::getEditStatus, EbomEditStatusEnum.HANDLER_CREATED.getValue())
.in(BomNewEbomChildEntity ::getParentRowId, revertList);
.in(BomNewEbomChildEntity::getParentRowId, revertList);
if (!this.update(updateWrapper)) {
throw new NflgBusinessException(STATE.Error, "退回设计失败");
@ -1008,9 +993,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<Long> updateReviewIdList = new ArrayList<>();
for (Long bomRowId :
rowIds) {
List<BomNewEbomParentVO > childList=getBomTree(bomRowId);
List<BomNewEbomParentVO> childList = getBomTree(bomRowId);
CheckEBomException checkEBomException = new CheckEBomException(childList);
// System.out.println(JSON.toJSONString(checkEBomException.getAllBomDetail()));
// System.out.println(JSON.toJSONString(checkEBomException.getAllBomDetail()));
checkEBomException.initException();
//错误状态包含在checkStatus内有异常抛出
checkEBomException.checkContainExcept(checkStatus);
@ -1025,23 +1010,23 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
//改变复核状态
if(CollectionUtil.isNotEmpty(updateReviewIdList)){
UpdateWrapper<BomNewEbomParentEntity> updateWrapper=new UpdateWrapper<>();
if (CollectionUtil.isNotEmpty(updateReviewIdList)) {
UpdateWrapper<BomNewEbomParentEntity> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda()
.set(BomNewEbomParentEntity::getAuditTime,LocalDateTime.now())
.set(BomNewEbomParentEntity::getAuditUserName,SessionUtil.getUserName())
.set(BomNewEbomParentEntity::getStatus,EBomStatusEnum.CHECKED.getValue())
.set(BomNewEbomParentEntity::getEditStatus,EbomEditStatusEnum.HANDLER_FINISHED.getValue())
.in(BomNewEbomParentEntity::getRowId,updateReviewIdList);
.set(BomNewEbomParentEntity::getAuditTime, LocalDateTime.now())
.set(BomNewEbomParentEntity::getAuditUserName, SessionUtil.getUserName())
.set(BomNewEbomParentEntity::getStatus, EBomStatusEnum.CHECKED.getValue())
.set(BomNewEbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_FINISHED.getValue())
.in(BomNewEbomParentEntity::getRowId, updateReviewIdList);
UpdateWrapper<BomNewEbomChildEntity > childWrapper = new UpdateWrapper<>();
UpdateWrapper<BomNewEbomChildEntity> childWrapper = new UpdateWrapper<>();
childWrapper.lambda()
.set(BomNewEbomChildEntity::getModifyTime, LocalDateTime.now())
.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, "复核失败");
}
ebomChildService.update(childWrapper);
@ -1101,7 +1086,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
return true;
}
public BomNewEbomEditDetailVO editDetail(Long bomRowId,String projectType) {
public BomNewEbomEditDetailVO editDetail(Long bomRowId, String projectType) {
BomNewEbomEditDetailVO vo = new BomNewEbomEditDetailVO();
BomNewEbomParentEntity parent = this.getBaseMapper().selectById(bomRowId);
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parent);
@ -1205,8 +1190,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
if (CollectionUtil.isNotEmpty(eBomDel.getDelEBom())) {
ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
// computeLevelNumAndRootState();
ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
// computeLevelNumAndRootState();
}
return true;
@ -1226,8 +1211,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
eBomEdit.temporary(dto);
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities);
}
@ -1242,9 +1225,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
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());
}
checkAndSaveEBomException(childList);
@ -1281,21 +1264,21 @@ 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>>() {
}, eBomEdit.childEntities);
List<BomNewEbomParentVO> allBom = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
}, eBomEdit.childEntities);
BomNewEbomParentVO parent = Convert.convert( BomNewEbomParentVO .class
, eBomEdit.parentEntities.get(0));
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class
, 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);
}
CheckEBomException checkEBomException = new CheckEBomException(allBom);
checkEBomException.checkContainExcept(checkStatus);
CheckEBomException checkEBomException = new CheckEBomException(allBom);
checkEBomException.checkContainExcept(checkStatus);
}
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
@ -1309,18 +1292,17 @@ 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());
}
checkAndSaveEBomException(childList);
// ebomChildService.getBaseMapper().updateEBomMaterialUse();
// ebomChildService.getBaseMapper().updateEBomMaterialUse();
ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
return true;
@ -1377,12 +1359,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
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> tmp2=dto.getDatas().stream().filter(item->Objects.isNull(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());
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(tmp2);
String[] ignore= new String[]{
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(tmp2, "");
String[] ignore = new String[]{
"projectType",
"procureType",
"materialUnit",
@ -1390,32 +1373,39 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
"materialTexture",
"materialGetType"
};
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(tmp1,ignore);
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(tmp1, ignore);
checkBom.addAll(tmp1);
checkBom.addAll(tmp2);
if(dto.getParent().getRootIs()==null ||dto.getParent().getRootIs()==0 ) {
checkBom.add(dto.getParent());
}
// if(dto.getParent().getRootIs()==null ||dto.getParent().getRootIs()==0 ) {
// checkBom.add(dto.getParent());
// }
checkBom.add(dto.getParent());
// CheckEBomException checkEBomException = new CheckEBomException(checkBom);
// checkEBomException.checkException();
// this.initBomException(checkBom);
checkBomException(checkBom);
if(CollectionUtil.isNotEmpty(dto.getDatas())){
for (BomNewEbomParentVO vo:
dto.getDatas()) {
if(Objects.isNull(vo.getRowId()) ||vo.getRowId()==0 ){
// this.initBomException(checkBom);
checkBomException(checkBom, Arrays.asList(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue()));
if (CollectionUtil.isNotEmpty(dto.getDatas())) {
for (BomNewEbomParentVO vo :
dto.getDatas()) {
if (Objects.isNull(vo.getRowId()) || vo.getRowId() == 0) {
vo.setDeviseUserCode(SessionUtil.getUserCode());
vo.setDeviseName(SessionUtil.getRealName());
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();
}
}
}

View File

@ -128,7 +128,7 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
*
* @param list
* @param
* @param setFun
* @param
* @param <T>
*/
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.VUtils;
import lombok.Getter;
import lombok.Setter;
import nflg.product.common.constant.STATE;
import java.math.BigDecimal;
@ -36,8 +37,8 @@ public class CheckEBomException {
@Getter
List<BomNewEbomParentVO> allBomDetail ;
@Setter
List<Integer> unCheckExcept;
public static void checkMaterialNoInMain1(List<String> materialNos){
@ -98,6 +99,13 @@ public class CheckEBomException {
public void checkException(){
for (BomNewEbomParentVO vo : allBomDetail) {
// if(Objects.isNull(vo.getExceptionStatus())) {
//忽略不检查的如14
if(CollectionUtil.isNotEmpty(unCheckExcept)
&& vo.getExceptionStatus()!=null
&&unCheckExcept.contains(vo.getExceptionStatus())){
continue;
}
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
// }
if (StrUtil.isNotBlank(vo.getMaterialNo())

View File

@ -39,8 +39,8 @@ public class EBomEdit {
Integer source;
public EBomEdit(Integer source){
this.source=source;
public EBomEdit(Integer source) {
this.source = source;
}
BomNewEbomParentEntity createParentBomInfo(BomNewEbomParentVO vo) {
@ -57,7 +57,7 @@ public class EBomEdit {
// parent.setMaterialName(material.getMaterialName());
// parent.setMaterialDesc(material.getMaterialDesc());
// parent.setMaterialTexture(material.getMaterial());
// parent.setNum(vo.getNum() == null ? new BigDecimal(1) : vo.getNum());
// parent.setNum(vo.getNum() == null ? new BigDecimal(1) : vo.getNum());
parent.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum()));
parent.setDeviseUserCode(SessionUtil.getUserCode());
@ -76,14 +76,32 @@ public class EBomEdit {
// parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.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.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());
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) {
@ -91,12 +109,12 @@ public class EBomEdit {
parentEntities = 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) {
for (BomNewEbomParentVO vo : dto.getDatas()) {
parentEntities.add(createParentBomInfo (vo));
parentEntities.add(createParentBomInfo(vo));
}
} else {
@ -109,7 +127,7 @@ public class EBomEdit {
parent = createParentBomInfo(dto.getParent());
parent.setEditStatus(dto.getOpType());
parentEntities.add(parent);
}else {
} else {
parent = Convert.convert(BomNewEbomParentEntity.class, dto.getParent());
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());
for (BomNewEbomChildEntity child :
@ -126,7 +144,7 @@ public class EBomEdit {
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.setIdentityNo(StrUtil.join("_", parent.getRowId(), child.getRowId()));
@ -137,29 +155,34 @@ public class EBomEdit {
child.setSourceRowId(0l);
child.setParentRowId(parent.getRowId());
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());
// parent.setCreatedJob(roleList.contains(EBomConstant.TECHNICIAN)?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue());
// parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
if (StrUtil.isNotBlank(child.getProjectType())) {
child.setProjectType(child.getProjectType().toUpperCase());
}
// 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()));
}
}
}
public void submit(BomNewEBomParentEditDTO dto) {
@ -170,16 +193,16 @@ public class EBomEdit {
Set<String> difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos));
VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料档案中不存在");
// Map<String, BaseMaterialVO> materialVOMap = ListCommonUtil.listToMap(materialBaseInfo, BaseMaterialVO::getMaterialNo);
parentEntities = 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) {
CheckEBomException eBomException=new CheckEBomException( dto.getDatas() );
CheckEBomException eBomException = new CheckEBomException(dto.getDatas());
eBomException.checkException();
for (BomNewEbomParentVO vo : dto.getDatas()) {
parentEntities.add(createParentBomInfo (vo));
parentEntities.add(createParentBomInfo(vo));
}
} else {
@ -188,20 +211,20 @@ public class EBomEdit {
//缺bom
if (dto.getParent().getBomRowId() == null || dto.getParent().getBomRowId().longValue() == 0) {
dto.getParent().setBomRowId(dto.getParent().getRowId());
parent = createParentBomInfo(dto.getParent());
parent = createParentBomInfo(dto.getParent());
parent.setEditStatus(dto.getOpType());
//工艺人员
if(roleList.contains(EBomConstant.TECHNICIAN)){
if (roleList.contains(EBomConstant.TECHNICIAN)) {
parent.setStatus(EBomStatusEnum.CHECKED.getValue());
}
parentEntities.add(parent);
}else {
} else {
parent = Convert.convert(BomNewEbomParentEntity.class, dto.getParent());
parent.setEditStatus(dto.getOpType());
//工艺人员
if(roleList.contains(EBomConstant.TECHNICIAN)){
if (roleList.contains(EBomConstant.TECHNICIAN)) {
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());
for (BomNewEbomChildEntity child :
@ -217,10 +240,10 @@ public class EBomEdit {
//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());
//新增数据
if(child.getRowId()==null || child.getRowId().longValue()==0){
if (child.getRowId() == null || child.getRowId().longValue() == 0) {
child.setRowId(IdWorker.getId());
child.setIdentityNo(StrUtil.join("-", parent.getRowId(), parent.getRowId()));
@ -231,36 +254,24 @@ public class EBomEdit {
child.setSourceRowId(0l);
child.setParentRowId(parent.getRowId());
child.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
// parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
// parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
checkExcept(dto.getParent(), child);
}
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 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
where material_no in
<foreach collection="materialNos" item="item" open="(" close=")" separator=",">