处理异常
This commit is contained in:
parent
a042d1fdbf
commit
638627b761
|
|
@ -33,7 +33,8 @@ public enum EBomExceptionStatusEnum implements ValueEnum<Integer> {
|
|||
EXCEPT_NO_10(10, "项目赋值异常(当父级物料的项目类型为F时,子级中不能存在项目类型为F的物料)"),
|
||||
EXCEPT_NO_11(11, "未填写变更原因和技术通知单"),
|
||||
EXCEPT_NO_12(12, "数量需要用户确认"),
|
||||
EXCEPT_NO_13(13, "项目类型需要用户确认") ;
|
||||
EXCEPT_NO_13(13, "项目类型需要用户确认") ,
|
||||
EXCEPT_NO_14(14,"黄色警告");
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.nflg.product.bomnew.mapper.master;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.ChildMaxExceptionStateVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -21,4 +22,6 @@ public interface BomNewEbomChildMapper extends BaseMapper<BomNewEbomChildEntity>
|
|||
* 全量更新-EBOM物料use
|
||||
*/
|
||||
void updateEBomMaterialUse();
|
||||
|
||||
List<ChildMaxExceptionStateVO> getChildMaxExceptionState(@Param("bomRowIds") List<Long> bomRowIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package com.nflg.product.bomnew.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 子节点最大状态
|
||||
*/
|
||||
@Data
|
||||
public class ChildMaxExceptionStateVO {
|
||||
|
||||
private Long parentRowId;
|
||||
@ApiModelProperty("最大异常状态")
|
||||
private Integer maxExceptionState;
|
||||
}
|
||||
|
|
@ -131,6 +131,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
materialMainService.intiMaterialInfo(result.getRecords(), "material", "materialTexture", "projectType");
|
||||
returnResult = result;
|
||||
}
|
||||
//动态判断异常
|
||||
CheckEBomExceptoinDynamic.check(returnResult.getRecords());
|
||||
return returnResult;
|
||||
}
|
||||
|
||||
|
|
@ -163,7 +165,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
* @param materialNo
|
||||
* @return
|
||||
*/
|
||||
private List<String> getParentMaterialByMaterialNo(String materialNo, Boolean selfIs) {
|
||||
public List<String> getParentMaterialByMaterialNo(String materialNo, Boolean selfIs) {
|
||||
BomNewEbomMaterialUseEntity materialBom = bomNewEbomMaterialUseService.lambdaQuery().eq(BomNewEbomMaterialUseEntity::getMaterialNo, materialNo).one();
|
||||
List<String> result = new ArrayList<>();
|
||||
if (Objects.nonNull(materialBom) && StrUtil.isNotBlank(materialBom.getParentMaterialNo())) {
|
||||
|
|
@ -190,6 +192,38 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量获取物料所有父节点
|
||||
*
|
||||
* @param materialNos
|
||||
* @return
|
||||
*/
|
||||
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);
|
||||
while (CollUtil.isNotEmpty(relSkuNo)) {
|
||||
result.addAll(relSkuNo);
|
||||
List<BomNewEbomMaterialUseEntity> relSkuList = bomNewEbomMaterialUseService.lambdaQuery().in(BomNewEbomMaterialUseEntity::getMaterialNo, relSkuNo).list();
|
||||
relSkuNo.clear();
|
||||
relSkuNo = getParentMaterialByUse(relSkuList);
|
||||
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Set<String> getSelfMaterialNo(Set<String> relSkuNo) {
|
||||
Set<String> selfParentMaterialNo = this.getBaseMapper().getSelfParentMaterialNo(SessionUtil.getUserCode(), relSkuNo);
|
||||
return selfParentMaterialNo;
|
||||
|
|
@ -285,8 +319,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
}
|
||||
}
|
||||
//初始化错误
|
||||
checkBomException(parentChild);
|
||||
//动态判断异常
|
||||
CheckEBomExceptoinDynamic.check(parentChild);
|
||||
return parentChild;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,10 +110,10 @@ public class CheckEBomException {
|
|||
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue());
|
||||
} else if (StrUtil.isNotBlank(vo.getMaterialNo()) && Objects.isNull(vo.getMaterialState())) {
|
||||
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue());
|
||||
} else if (StrUtil.isBlank(vo.getProjectType())) {
|
||||
} else if (StrUtil.isBlank(vo.getProjectType()) && Objects.nonNull(vo.getRootIs()) && !vo.getRootIs().equals(1)) {
|
||||
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
|
||||
}
|
||||
else if (StrUtil.isNotBlank(vo.getNoticeNums()) && EBomExceptionStatusEnum.EXCEPT_NO_11.equals(vo.getExceptionStatus())){
|
||||
else if (StrUtil.isNotBlank(vo.getNoticeNums()) && EBomExceptionStatusEnum.EXCEPT_NO_11.equalsValue(vo.getExceptionStatus())){
|
||||
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
|
||||
}
|
||||
|
||||
|
|
@ -169,7 +169,24 @@ public class CheckEBomException {
|
|||
}
|
||||
}
|
||||
}
|
||||
checkCircularDependency(checkEBomExceptionDTOS);
|
||||
// checkCircularDependency(checkEBomExceptionDTOS);
|
||||
//bom异常-黄色警号
|
||||
initExceptionYellowWarn(allBomDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 黄色警号异常
|
||||
* @param list
|
||||
*/
|
||||
public void initExceptionYellowWarn( List<BomNewEbomParentVO> list ){
|
||||
List<BomNewEbomParentVO> exceptionList = allBomDetail.stream().filter(u -> u.getExceptionStatus() > 1).collect(Collectors.toList());
|
||||
List<String> exceptionMaterialNos = exceptionList.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
||||
List<String> allErrorParent = SpringUtil.getBean(BomNewEbomParentService.class).getBatchParentMaterialByMaterialNo(exceptionMaterialNos);
|
||||
List<BomNewEbomParentVO> warnList = allBomDetail.stream().filter(u -> allErrorParent.contains(u.getMaterialNo()) && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList());
|
||||
warnList.forEach(k->{
|
||||
k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
package com.nflg.product.bomnew.service.domain.EBom;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.MaterialGetEnum;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewEbomChildMapper;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.ChildMaxExceptionStateVO;
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 动态检查BOM 异常状态
|
||||
*/
|
||||
public class CheckEBomExceptoinDynamic {
|
||||
|
||||
public static void check(List<BomNewEbomParentVO> list){
|
||||
|
||||
|
||||
for (BomNewEbomParentVO vo : list) {
|
||||
//物料状态-解除异常
|
||||
if (StrUtil.isNotBlank(vo.getMaterialNo())
|
||||
&& MaterialGetEnum.MaterialStateEnum.OK.equalsValue(vo.getMaterialState())
|
||||
&& EBomExceptionStatusEnum.EXCEPT_NO_2.equalsValue(vo.getExceptionStatus())) {
|
||||
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
|
||||
}
|
||||
//警告状态(子节点有异常则父节点黄色警告),子级无异常则解除警告
|
||||
List<BomNewEbomParentVO> parentList = list.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
|
||||
List<Long> bomRowIds = parentList.stream().map(u -> u.getBomRowId()).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(bomRowIds)) {
|
||||
List<ChildMaxExceptionStateVO> childMaxExceptionState = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildMaxExceptionState(bomRowIds);
|
||||
List<Long> okParent = childMaxExceptionState.stream().filter(u -> u.getMaxExceptionState().equals(1)).map(u -> u.getParentRowId()).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(okParent)){
|
||||
List<BomNewEbomParentVO> collect = list.stream().filter(u -> okParent.contains(u.getBomRowId()) && EBomExceptionStatusEnum.EXCEPT_NO_14.equalsValue(u.getExceptionStatus())).collect(Collectors.toList());
|
||||
collect.forEach(k->{
|
||||
k.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -59,4 +59,13 @@
|
|||
join t_bom_new_ebom_child b on a.row_id=b.parent_row_id and a.last_version_is=1
|
||||
group by b.material_no ;
|
||||
</update>
|
||||
|
||||
<select id="getChildMaxExceptionState" resultType="com.nflg.product.bomnew.pojo.vo.ChildMaxExceptionStateVO">
|
||||
select max(exception_status) maxExceptionState, parent_row_id from t_bom_new_ebom_child
|
||||
where parent_row_id in
|
||||
<foreach collection="bomRowIds" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
group by parent_row_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue