feat(pbom): 修复获取节点异常状态问题

This commit is contained in:
曹鹏飞 2024-10-04 20:59:13 +08:00
parent 99f49ac434
commit 1985ad0f5b
2 changed files with 49 additions and 23 deletions

View File

@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
/**
@ -32,5 +33,6 @@ public class PBomExceptionQuery implements Serializable {
* facCode 工厂编号
*/
@ApiModelProperty(value = "工厂编号")
@NotEmpty(message = "工厂编号不能为空")
protected String facCode;
}

View File

@ -2011,22 +2011,32 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
public List<BomExceptionVO> getBomException(@Valid @NotEmpty List<BomExceptionQuery> query) {
List<BomExceptionVO> datas = new ArrayList<>();
List<BaseMaterialVO> materialVOS = materialMainService.getMaterialBaseInfo(query.stream().map(BomExceptionQuery::getMaterialNo).collect(Collectors.toList()));
boolean isException = false;
for (int index = query.size() - 1; index >= 0; index--) {
BomExceptionQuery bom = query.get(index);
for (BomExceptionQuery bom : query) {
BomExceptionVO vo = new BomExceptionVO();
vo.setBomRowId(bom.getBomRowId());
vo.setRowId(bom.getRowId());
vo.setMaterialNo(bom.getMaterialNo());
if (isException) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
BaseMaterialVO mv = materialVOS.stream().filter(f -> StrUtil.equals(f.getMaterialNo(), bom.getMaterialNo())).findFirst().orElse(null);
if (Objects.isNull(mv)) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue());
} else if (!Objects.equals(mv.getMaterialState(), MateiralStateEnum.ACTIVE.getValue())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue());
} else {
BaseMaterialVO mv = materialVOS.stream().filter(f -> StrUtil.equals(f.getMaterialNo(), bom.getMaterialNo())).findFirst().orElse(null);
if (Objects.isNull(mv) || !Objects.equals(mv.getMaterialState(), MateiralStateEnum.ACTIVE.getValue())) {
isException = true;
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue());
} else {
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
List<String> materialNos = pbomChildService.lambdaQuery()
.select(BomNewPbomChildEntity::getMaterialNo)
.eq(BomNewPbomChildEntity::getParentRowId, bom.getBomRowId())
.list()
.stream()
.map(BomNewPbomChildEntity::getMaterialNo)
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) {
List<BaseMaterialVO> vos = materialMainService.initMaterialForAnyNo(materialNos);
if (CollUtil.isNotEmpty(vos)) {
if (vos.stream().anyMatch(f -> !Objects.equals(f.getMaterialState(), MaterialGetEnum.MaterialStateEnum.OK.getValue()))) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
}
}
}
}
datas.add(vo);
@ -2039,25 +2049,39 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
List<String> materialNosOrDrawingNos = Collections.singletonList(StrUtil.isNotBlank(query.getMaterialNo()) ? query.getMaterialNo() : query.getDrawingNo());
List<BaseMaterialVO> materialVOS = materialMainService.initMaterialForAnyNo(materialNosOrDrawingNos);
BomExceptionVO vo = new BomExceptionVO();
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
BaseMaterialVO mVO = materialVOS.stream().findFirst().orElse(null);
if (Objects.nonNull(mVO)) {
vo.setMaterialNo(mVO.getMaterialNo());
if (!Objects.equals(mVO.getMaterialState(), MaterialGetEnum.MaterialStateEnum.OK.getValue())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue());
} else {
materialNosOrDrawingNos = pbomChildService.lambdaQuery()
.select(BomNewPbomChildEntity::getMaterialNo)
.eq(StrUtil.isNotBlank(query.getMaterialNo()), BomNewPbomChildEntity::getMaterialNo, query.getMaterialNo())
.eq(StrUtil.isNotBlank(query.getDrawingNo()), BomNewPbomChildEntity::getDrawingNo, query.getDrawingNo())
.eq(BomNewPbomChildEntity::getFacCode, query.getFacCode())
BomNewPbomParentEntity p = this.lambdaQuery()
.select(BomNewPbomParentEntity::getRowId)
.eq(StrUtil.isNotBlank(query.getMaterialNo()), BomNewPbomParentEntity::getMaterialNo, query.getMaterialNo())
.eq(StrUtil.isNotBlank(query.getDrawingNo()), BomNewPbomParentEntity::getDrawingNo, query.getDrawingNo())
.lt(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
.eq(BomNewPbomParentEntity::getFacCode, query.getFacCode())
.list()
.stream().map(BomNewPbomChildEntity::getMaterialNo)
.collect(Collectors.toList());
materialVOS = materialMainService.initMaterialForAnyNo(materialNosOrDrawingNos);
if (materialVOS.stream().anyMatch(f -> !Objects.equals(f.getMaterialState(), MaterialGetEnum.MaterialStateEnum.OK.getValue()))) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue());
} else {
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
.stream()
.findFirst()
.orElse(null);
if (Objects.nonNull(p)) {
materialNosOrDrawingNos = pbomChildService.lambdaQuery()
.select(BomNewPbomChildEntity::getMaterialNo)
.eq(BomNewPbomChildEntity::getParentRowId, p.getRowId())
.list()
.stream()
.map(BomNewPbomChildEntity::getMaterialNo)
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNosOrDrawingNos)) {
materialVOS = materialMainService.initMaterialForAnyNo(materialNosOrDrawingNos);
if (CollUtil.isNotEmpty(materialVOS)) {
if (materialVOS.stream().anyMatch(f -> !Objects.equals(f.getMaterialState(), MaterialGetEnum.MaterialStateEnum.OK.getValue()))) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
}
}
}
}
}
}