1、异常检查问题处理

This commit is contained in:
大米 2024-04-17 18:21:02 +08:00
parent e9875cac3c
commit 92c7d63a04
5 changed files with 137 additions and 2 deletions

View File

@ -78,4 +78,7 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
Set<String> getMaterialParent(@Param("materialNos") Collection<String> materialNos ,@Param("createdBy") String createdBy);
void resetAllBomExist();
List<BomNewEbomParentEntity> getEBomParentByMaterialNos(@Param("job") Integer job, @Param("createdBy")String createdBy, @Param("materialNos") List<String> materialNos);
}

View File

@ -533,7 +533,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
*/
public List<BomNewEbomParentVO> getBomTree(Long rowId, Boolean generateLevelNumberFlag) throws ExecutionException, InterruptedException {
List<BomNewEbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
EBomDetailTask detailTask = new EBomDetailTask(bomDetail);
// EBomDetailTask detailTask = new EBomDetailTask(bomDetail);
EBomCheckErrorDetailTask detailTask=new EBomCheckErrorDetailTask(bomDetail);
ForkJoinTask<List<BomNewEbomParentVO>> submit = bomDetailPool.submit(detailTask);
List<BomNewEbomParentVO> result = submit.join();

View File

@ -61,7 +61,7 @@ public class CheckEBomException {
allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId, true);
//只检查待复核和自己的
allBomDetail=allBomDetail.stream().filter(u-> SessionUtil.getUserCode().equals(u.getCreatedBy()) && u.getStatus().equals(1) ).collect(Collectors.toList());
//allBomDetail=allBomDetail.stream().filter(u-> SessionUtil.getUserCode().equals(u.getCreatedBy()) && u.getStatus().equals(1) ).collect(Collectors.toList());
BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId);
if (Objects.isNull(parent)){
return;

View File

@ -0,0 +1,114 @@
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.base.core.conmon.util.SessionUtil;
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.UserRoleService;
import com.nflg.product.bomnew.util.ListCommonUtil;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.RecursiveTask;
import java.util.stream.Collectors;
/**
* @author 大米(异常检查专用)
* @descreption
* @date 2023/7/8 9:18
*/
public class EBomCheckErrorDetailTask extends RecursiveTask<List<BomNewEbomParentVO>> {
private List<BomNewEbomParentVO> bomDetail;
@Getter
@Setter
public static int levelNum=1;
List<BomNewEbomParentVO> result = new ArrayList<>();
public EBomCheckErrorDetailTask(List<BomNewEbomParentVO> inBomDetail) {
bomDetail = inBomDetail;
}
/**
* 处理BOM明细中未选择Bom版本的明细使用最新版
*/
public void handlerChildBomVersionDetail() {
List<String> materialNos = bomDetail.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo()) ).map(BomNewEbomParentVO::getMaterialNo).collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) {
// List<BomNewEbomParentEntity> childBomlist = SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos).eq(BomNewEbomParentEntity::getLastVersionIs, 1).list();
Integer userJob = SpringUtil.getBean(UserRoleService.class).getUserJob();
List<BomNewEbomParentEntity> childBomlist=SpringUtil.getBean(BomNewEbomParentService.class).getBaseMapper().getEBomParentByMaterialNos(userJob, SessionUtil.getUserCode(),materialNos);
Map<String, BomNewEbomParentEntity> stringBomNewOriginalParentEntityMap = ListCommonUtil.listToMap(childBomlist, BomNewEbomParentEntity::getMaterialNo);
for (BomNewEbomParentVO detailVO : bomDetail) {
if (stringBomNewOriginalParentEntityMap.containsKey(detailVO.getMaterialNo())) {
BomNewEbomParentEntity ebomParentEntity = stringBomNewOriginalParentEntityMap.get(detailVO.getMaterialNo());
detailVO.setChildBomRowId(ebomParentEntity.getRowId());
detailVO.setBomRowId(ebomParentEntity.getRowId());
detailVO.setSourceRowId(ebomParentEntity.getSourceRowId());
detailVO.setCurrentVersion(ebomParentEntity.getCurrentVersion());
detailVO.setDeviseUserCode(ebomParentEntity.getDeviseUserCode());
detailVO.setDeptName(ebomParentEntity.getDeptName());
detailVO.setDeviseName(ebomParentEntity.getDeviseName());
detailVO.setBomExist(ebomParentEntity.getBomExist());
detailVO.setStatus(ebomParentEntity.getStatus());
}
}
}
}
/**
* 递归调用零部件BOM
*
* @return
*/
@Override
protected List<BomNewEbomParentVO> compute() {
handlerChildBomVersionDetail();
// 最新 BOM 版本
result.addAll(bomDetail);
if (CollUtil.isNotEmpty(bomDetail)) {
levelNumAdd();
List<Long> childBowIds = bomDetail.stream().filter(u-> u.getChildBomRowId()!=null && u.getChildBomRowId() > 0).map(u->u.getChildBomRowId()).collect(Collectors.toList());
if(CollUtil.isNotEmpty(childBowIds)) {
List<BomNewEbomParentVO> bom = SpringUtil.getBean(BomNewEbomParentService.class).getBaseMapper().getParentChildBatch(childBowIds);
EBomCheckErrorDetailTask task = new EBomCheckErrorDetailTask(bom);
task.fork();
bomDetail.addAll(task.join());
return bomDetail;
}
}
return result;
}
public synchronized void levelNumAdd(){
levelNum++;
}
}

View File

@ -361,4 +361,20 @@
SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_ebom_child WHERE parent_row_id = p.row_id), 1, 0))
WHERE p.status &lt; 4;
</select>
<select id="getEBomParentByMaterialNos" resultType="com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity">
<if test="job==0">
select * from t_bom_new_ebom_parent where created_by=#{createdBy} and last_version_is=1 and status in (1 ,3) and material_no in
<foreach collection="materialNos" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="job==1">
select * from t_bom_new_ebom_parent where (created_by=#{createdBy} or status=2) and last_version_is=1
and material_no in
<foreach collection="materialNos" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
</mapper>