重新调整编辑

This commit is contained in:
jing's 2023-12-24 15:09:59 +08:00
parent 8557c82d0a
commit 580655a0a8
7 changed files with 220 additions and 166 deletions

View File

@ -190,11 +190,12 @@ public class EbomApi extends BaseApi {
@PostMapping("revertDesign")
@ApiOperation("退回到设计")
public ResultVO<Boolean> revertDesign(@RequestBody BomNewEBomRevertDTO dto) {
public ResultVO<Boolean> revertDesign(@RequestBody BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException {
if (CollectionUtil.isEmpty(dto.getRowIdList())) {
return ResultVO.error(STATE.ParamErr, "请选择要退回的数据");
}
dto.setRevertUserName(SessionUtil.getUserName());
dto.setUserCode(SessionUtil.getUserCode());
bomNewEbomParentService.revertDesign(dto);
return ResultVO.success(true);
@ -203,14 +204,15 @@ public class EbomApi extends BaseApi {
@PostMapping("reviewDesign")
@ApiOperation("设计复核")
public ResultVO<Boolean> reviewDesign(@RequestBody BomNewEBomRevertDTO dto) {
public ResultVO<Boolean> reviewDesign(@RequestBody BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException {
if (CollectionUtil.isEmpty(dto.getRowIdList())) {
return ResultVO.error(STATE.ParamErr, "请选择要复核的数据");
}
dto.setRevertUserName(SessionUtil.getUserName());
return bomNewEbomParentService.designReview(dto);
dto.setUserCode(SessionUtil.getUserCode());
bomNewEbomParentService.designReview(dto);
return ResultVO.success(true);
}
@ -252,8 +254,8 @@ public class EbomApi extends BaseApi {
@GetMapping("delete")
@ApiOperation("删除物料")
public ResultVO<Boolean> deleteMaterial(@RequestParam("bomRowId") Long bomRowId ) throws ExecutionException, InterruptedException{
bomNewEbomParentService.deleteMaterial(bomRowId);
public ResultVO<Boolean> deleteBom(@RequestParam("bomRowId") Long bomRowId ) throws ExecutionException, InterruptedException{
bomNewEbomParentService.deleteBom(bomRowId);
bomNewEbomParentService.computeLevelNumAndRootState();
return ResultVO.success(true);
}
@ -273,7 +275,7 @@ public class EbomApi extends BaseApi {
@PostMapping("submit")
@ApiOperation("提交")
public ResultVO<Boolean> submit(@RequestBody BomNewEBomParentEditDTO dto) {
public ResultVO<Boolean> submit(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
return ResultVO.success(bomNewEbomParentService.submit(dto));
}

View File

@ -39,4 +39,20 @@ public enum EBomExceptionStatusEnum implements ValueEnum<Integer> {
private final Integer value;
private final String description;
public static EBomExceptionStatusEnum findEnumByCode(Integer code) {
for (EBomExceptionStatusEnum statusEnum : EBomExceptionStatusEnum.values()) {
if (statusEnum.getValue().equals(code)) {
return statusEnum;
}
}
throw new IllegalArgumentException("code is invalid");
}
public static String code2description(Integer code) {
return findEnumByCode(code).getDescription();
}
}

View File

@ -32,7 +32,9 @@ public enum ProjectTypeInputTypeEnum implements ValueEnum<Integer> {
@AllArgsConstructor
public enum ProjectTypeEnum implements ValueEnum<String> {
TYPE_Q("Q", "Q"),
TYPE_F("F", "F");
TYPE_F("F", "F"),
TYPE_Z("Z", "Z"),
TYPE_L("L", "L");
private final String value;
private final String description;

View File

@ -15,9 +15,12 @@ public class BomNewEBomRevertDTO {
//退回人
@ApiModelProperty("忽略不是必填")
private String revertUserName;
@ApiModelProperty("忽略不是必填")
private String userCode;
@ApiModelProperty("行id列表")
@ApiModelProperty("必填,行id列表")
private List<Long> rowIdList;
}

View File

@ -279,8 +279,16 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
public List<BomNewEbomParentVO> buildBomTree(Long rowId) throws Exception {
return getBomTree(rowId);
public List<BomNewEbomParentVO> buildBomTreeContainSelf(Long rowId) throws ExecutionException, InterruptedException {
List<BomNewEbomParentVO> list= getBomTree(rowId);
BomNewEbomParentVO parentVO=Convert.convert(BomNewEbomParentVO.class,this.getById(rowId));
if(parentVO!=null) {
parentVO.setBomRowId(rowId);
parentVO.setParentRowId(0L);
list.add(parentVO);
}
return list;
}
@ -559,7 +567,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
@Transactional(rollbackFor = Exception.class)
public void createBomImport(BomNewEbomImportDTO dto, InputStream inputStream) throws IOException {
List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class);
@ -573,7 +580,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
bomNewEBomParentEditDTO.setParent(dto.getParent());
bomNewEBomParentEditDTO.setDatas(datas);
eBomEdit.temporary(bomNewEBomParentEditDTO);
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities);
}
if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
}
}
@ -645,51 +658,75 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
* 退回设计
*/
// @Transactional(rollbackFor = Exception.class)
public void revertDesign(BomNewEBomRevertDTO dto) {
public void revertDesign(BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException {
List<Long> rowIds = dto.getRowIdList();
List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.getBaseMapper().selectBatchIds(rowIds);
// List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.getBaseMapper().selectBatchIds(rowIds);
List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, rowIds).eq(BomNewEbomParentEntity::getRootIs, 1).list();
if (CollUtil.isEmpty(bomNewEbomParentEntityList)) {
throw new NflgBusinessException(STATE.BusinessError, "下级BOM无法进行退回");
// throw new NflgBusinessException(STATE.BusinessError, "下级BOM无法进行退回");
VUtils.isTure(true).throwMessage("下级BOM无法进行退回");
}
if (rowIds.size() != bomNewEbomParentEntityList.size()) {
throw new NflgBusinessException(STATE.BusinessError, "选择数据中包含有下级BOM无法进行退回");
// throw new NflgBusinessException(STATE.BusinessError, "选择数据中包含有下级BOM无法进行退回");
VUtils.isTure(true).throwMessage("选择数据中包含有下级BOM无法进行退回");
}
List<BomNewEbomParentEntity> waitList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.WAIT_CHECK.getValue())).collect(Collectors.toList());
List<BomNewEbomParentEntity> revertList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.RETURNED.getValue())).collect(Collectors.toList());
List<BomNewEbomParentEntity> pbomList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(waitList)) {
List<String> materialNoList = waitList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
List<Long> revertList=new ArrayList<>();
for (Long bomRowId:
rowIds) {
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为待复核,无法退回设计", StrUtil.join(",", materialNoList)));
}
if (CollUtil.isNotEmpty(revertList)) {
List<String> materialNoList = revertList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
List<BomNewEbomParentVO> bomTreeList= buildBomTreeContainSelf(bomRowId);
//
//
//
// List<BomNewEbomParentEntity> waitList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.WAIT_CHECK.getValue())).collect(Collectors.toList());
// List<BomNewEbomParentEntity> revertList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.RETURNED.getValue())).collect(Collectors.toList());
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已退回,不需要退回设计", StrUtil.join(",", materialNoList)));
}
if (pbomList.size() > 0) {
List<String> materialNoList = pbomList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
List<BomNewEbomParentVO> pbomList = bomTreeList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())).collect(Collectors.toList());
// if (CollUtil.isNotEmpty(waitList)) {
// List<String> materialNoList = waitList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
//
// throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为待复核,无法退回设计", StrUtil.join(",", materialNoList)));
// }
// if (CollUtil.isNotEmpty(revertList)) {
// List<String> materialNoList = revertList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
//
// throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已退回,不需要退回设计", StrUtil.join(",", materialNoList)));
// }
if (pbomList.size() > 0) {
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)));
}
//忽略叶子节点
revertList.addAll(bomTreeList.stream()
.filter(u->u.getBomRowId()>0)
.map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()));
}
//重新创建保存list 避免污染
List<BomNewEbomParentEntity> updateList = new ArrayList<>();
bomNewEbomParentEntityList.forEach(item -> {
for (Long rowId : revertList) {
BomNewEbomParentEntity entity = new BomNewEbomParentEntity();
entity.setRowId(item.getRowId());
entity.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
entity.setRowId(rowId);
entity.setEditStatus(EBomStatusEnum.RETURNED.getValue());
entity.setRevertTime(LocalDateTime.now());
entity.setRevertUserName(dto.getRevertUserName());
updateList.add(entity);
});
}
if (!this.updateBatchById(updateList)) {
throw new NflgBusinessException(STATE.Error, "退回设计失败");
@ -707,144 +744,63 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
* 6. 是否存在已冻结/永久禁用的物料
*/
// @Transactional(rollbackFor = Exception.class)
public ResultVO<Boolean> designReview(BomNewEBomRevertDTO dto) {
public Boolean designReview(BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException {
List<Long> rowIds = dto.getRowIdList();
List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.getBaseMapper().selectBatchIds(rowIds);
List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, rowIds).eq(BomNewEbomParentEntity::getRootIs, 1).list();
if (CollUtil.isEmpty(bomNewEbomParentEntityList)) {
return ResultVO.error("下级BOM无法进行复核");
// return ResultVO.error("下级BOM无法进行复核");
VUtils.isTure(true).throwMessage("下级BOM无法进行复核");
}
if (rowIds.size() != bomNewEbomParentEntityList.size()) {
return ResultVO.error("选择数据中包含有下级BOM无法进行复核");
}
for (BomNewEbomParentEntity item :
bomNewEbomParentEntityList) {
if (item.getStatus().equals(EBomStatusEnum.CHECKED.getValue())) {
return ResultVO.error(StrUtil.format("{} 已复核过,不需重复复核", item.getMaterialNo()));
}
if (item.getNum().equals(EBomExceptionStatusEnum.INIT.getValue())) {
return ResultVO.error("请调整数据后进行复核");
}
if (item.getNum().equals(EbomEditStatusEnum.HANDLER_CREATED.getValue())) {
return ResultVO.error("请先提交确认后进行复核");
}
if (StrUtil.isEmpty(item.getMaterialNo()) || (item.getNum() == null || item.getNum().floatValue() == 0)) {
return ResultVO.error(EBomExceptionStatusEnum.EXCEPT_NO_4.getDescription());
}
MaterialMainEntity entity = materialMainService.lambdaQuery().eq(MaterialMainEntity::getMaterialNo, item.getMaterialNo()).one();
if (entity == null) {
return ResultVO.error("物料编码[" + item.getMaterialNo() + "]物料不存在");
}
if (Objects.equals(entity.getMaterialState(), MaterialGetEnum.MaterialStateEnum.STATE_NO_4)
|| Objects.equals(entity.getMaterialState(), MaterialGetEnum.MaterialStateEnum.STATE_NO_5)) {
return ResultVO.error("物料编码[" + item.getMaterialNo() + "]冻结/完全弃用异常");
}
VUtils.isTure(true).throwMessage("数据中包含有下级BOM无法进行复核");
// return ResultVO.error("数据中包含有下级BOM无法进行复核");
}
List<Integer> checkStatus=CollectionUtil.toList(new Integer[]{
EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_4.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_6.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_7.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_8.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_9.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_10.getValue()
});
List<Long> updateReviewIdList = new ArrayList<>();
//子bom检查
for (BomNewEbomParentEntity item :
bomNewEbomParentEntityList) {
List<BomNewEbomParentVO> childBomList;
try {
childBomList = buildBomTree(item.getRowId());
} catch (Exception e) {
return ResultVO.error("获取Bom数据失败");
}
if (CollUtil.isNotEmpty(childBomList)) {
for (BomNewEbomParentVO childBomItem :
childBomList) {
if (childBomItem.getNum().equals(EBomExceptionStatusEnum.INIT.getValue())) {
return ResultVO.error("请调整数据后进行复核");
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_2.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_3.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_3.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_4.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_6.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_6.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_7.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_7.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_8.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_9.getDescription()));
}
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue())) {
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_10.getDescription()));
}
}
}
updateReviewIdList.addAll(childBomList.stream().map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()));
for (Long bomRowId:
rowIds) {
CheckEBomException checkEBomException=new CheckEBomException(bomRowId);
//错误状态包含在checkStatus内有异常抛出
checkEBomException.checkContainExcept(checkStatus);
//筛选bomRowId()>0 说明有bom更新只到parent这层无bom不需要更新
//设计人员只可以复核自己的物料如果存在引用其他用户创建的物料时不可以改变被引用物料的审核状态
updateReviewIdList.addAll( checkEBomException.getAllBomDetail().stream()
.filter(u->u.getBomRowId()>0
&& u.getCreatedBy().equals(dto.getUserCode()))
.map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()));
}
//改变复核状态
List<BomNewEbomParentEntity> updateReviewList = new ArrayList<>();
for (Long id : updateReviewIdList) {
BomNewEbomParentEntity entity = new BomNewEbomParentEntity();
entity.setRowId(id);
entity.setAuditTime(LocalDateTime.now());
entity.setAuditUserName(dto.getRevertUserName());
entity.setStatus(EBomStatusEnum.CHECKED.getValue());
updateReviewList.add(entity);
}
if (!this.updateBatchById(updateReviewList)) {
throw new NflgBusinessException(STATE.Error, "复核失败");
}
return ResultVO.success(true);
return true;
}
@ -878,6 +834,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class,parent);
parentVO.setBomRowId(parentVO.getRowId());
parentVO.setParentRowId(0l);
// List<BomNewEbomParentVO> parentList = new ArrayList<>();
// parentList.add(parentVO);
// materialMainService.intiMaterialInfo(parentList);
@ -926,12 +883,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
public Boolean deleteMaterial(Long bomRowId) throws ExecutionException, InterruptedException {
public Boolean deleteBom(Long bomRowId) throws ExecutionException, InterruptedException {
BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectById(bomRowId);
VUtils.isTure(Objects.isNull(parentEntity)).throwMessage("该节点不存在,请检查参数是否正确");
VUtils.isTure(!parentEntity.getCreatedBy().equals(SessionUtil.getUserCode())).throwMessage("该节点不属于你,你无权删除");
@ -956,6 +914,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
}
return true;
}
@ -992,18 +952,46 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
/**
* 提交物料
*
* 1.
*/
public Boolean submit(BomNewEBomParentEditDTO dto) {
public Boolean submit(BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
eBomEdit.temporary(dto);
List<Integer> checkStatus=CollectionUtil.toList(new Integer[]{
EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_4.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_6.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_7.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_8.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_9.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_10.getValue()
});
List<BomNewEbomParentVO> allBom =Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
},eBomEdit.childEntities);
if(CollectionUtil.isNotEmpty(eBomEdit.parentEntities)){
allBom.add(Convert.convert(BomNewEbomParentVO.class,eBomEdit.parentEntities.get(0)));
}
CheckEBomException checkEBomException = new CheckEBomException(allBom);
checkEBomException.checkContainExcept(checkStatus);
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities);
}
if (CollUtil.isNotEmpty(eBomEdit.childEntities)) {
if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
}
if (dto.getParent() != null) {
if (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|| dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())) {

View File

@ -1,18 +1,25 @@
package com.nflg.product.bomnew.service.domain.EBom;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.google.common.collect.ImmutableList;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum;
import com.nflg.product.bomnew.constant.MaterialGetEnum;
import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
import com.nflg.product.bomnew.service.BomNewEbomParentService;
import com.nflg.product.bomnew.service.MaterialMainService;
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 nflg.product.common.constant.STATE;
import java.math.BigDecimal;
import java.util.ArrayList;
@ -31,12 +38,14 @@ public class CheckEBomException {
List<BomNewEbomParentVO> allBomDetail ;
public CheckEBomException(Long bomRowId) throws ExecutionException, InterruptedException {
allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId);
BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId);
BomNewEbomParentVO convert = Convert.convert(BomNewEbomParentVO.class, parent);
convert.setBomRowId(convert.getRowId());
convert.setParentRowId(0L);
allBomDetail.add(convert);
// allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId);
// BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId);
// BomNewEbomParentVO convert = Convert.convert(BomNewEbomParentVO.class, parent);
// convert.setBomRowId(convert.getRowId());
// convert.setParentRowId(0L);
// allBomDetail.add(convert);
allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).buildBomTreeContainSelf(bomRowId);
}
/**
@ -58,9 +67,14 @@ public class CheckEBomException {
if(Objects.isNull(vo.getExceptionStatus())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
}
if (StrUtil.isNotBlank(vo.getMaterialNo()) && (MaterialGetEnum.MaterialStateEnum.STATE_NO_4.equalsValue(vo.getMaterialState()) || MaterialGetEnum.MaterialStateEnum.STATE_NO_5.equalsValue(vo.getMaterialState()))) {
if (StrUtil.isNotBlank(vo.getMaterialNo())
&& (MaterialGetEnum.MaterialStateEnum.STATE_NO_4.equalsValue(vo.getMaterialState())
|| MaterialGetEnum.MaterialStateEnum.STATE_NO_5.equalsValue(vo.getMaterialState()))) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue());
} else if (StrUtil.isBlank(vo.getMaterialNo()) || Objects.isNull(vo.getNum()) || (Objects.nonNull(vo.getNum()) && BigDecimal.ZERO.compareTo(vo.getNum()) >= 0)) {
} else if (StrUtil.isBlank(vo.getMaterialNo())
|| Objects.isNull(vo.getNum())
|| (Objects.nonNull(vo.getNum())
&& BigDecimal.ZERO.compareTo(vo.getNum()) >= 0)) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue());
} else if (StrUtil.isNotBlank(vo.getMaterialNo()) && Objects.isNull(vo.getMaterialState())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue());
@ -106,15 +120,15 @@ public class CheckEBomException {
}
}
if ("Q".equals(parent.getProjectType())) {
List<BomNewEbomParentVO> qList = child.stream().filter(u -> "Q".equals(u.getProjectType())).collect(Collectors.toList());
if (ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.equals(parent.getProjectType())) {
List<BomNewEbomParentVO> qList = child.stream().filter(u -> ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.equals(u.getProjectType())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(qList)) {
parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue());
qList.forEach(u -> u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue()));
}
}
if ("F".equals(parent.getProjectType())) {
List<BomNewEbomParentVO> qList = child.stream().filter(u -> "F".equals(u.getProjectType())).collect(Collectors.toList());
if (ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.equals(parent.getProjectType())) {
List<BomNewEbomParentVO> qList = child.stream().filter(u -> ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.equals(u.getProjectType())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(qList)) {
parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue());
qList.forEach(u -> u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue()));
@ -138,4 +152,32 @@ public class CheckEBomException {
}
}
public void checkContainExcept(List<Integer> codeList) throws NflgBusinessException {
if(CollUtil.isEmpty(codeList))return;
for (BomNewEbomParentVO item:
allBomDetail) {
//并集 寻找相同
List<Integer> list=CollectionUtil.intersection(codeList, ImmutableList.of(item.getExceptionStatus())).stream().collect(Collectors.toList());;
if(CollUtil.isNotEmpty(list)){
throw new NflgBusinessException(STATE.BusinessError, EBomExceptionStatusEnum.code2description(list.get(0)));
}
}
}
}

View File

@ -45,8 +45,6 @@ public class EBomEdit {
BomNewEbomParentEntity createParentBomInfo(BomNewEbomParentVO vo) {
BomNewEbomParentEntity parent = new BomNewEbomParentEntity();
BeanUtil.copyProperties(parent, vo);
@ -73,6 +71,7 @@ public class EBomEdit {
parent.setBomExist(1);
parent.setLastVersionIs(1);
parent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
if(StrUtil.isEmpty(parent.getProjectType())){
parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
}
@ -96,7 +95,6 @@ public class EBomEdit {
List<String> materialNos = dto.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
//检查物料编码是否在主数据中存在
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos);
List<String> effectiveMaterialNos = materialBaseInfo.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
@ -143,7 +141,10 @@ public class EBomEdit {
child.setCreatedTime(LocalDateTime.now());
child.setCreatedBy(SessionUtil.getUserCode());
child.setSourceRowId(0l);
}
parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
parent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician()?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue());
}
parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));