Merge remote-tracking branch 'origin/feature/DM/nflg-bom' into feature/DM/nflg-bom

This commit is contained in:
大米 2024-03-13 17:28:11 +08:00
commit d6a2b2e5d3
3 changed files with 68 additions and 17 deletions

View File

@ -4,25 +4,18 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.mzt.logapi.context.LogRecordContext;
import com.nflg.product.base.core.conmon.util.SessionUtil;
@ -30,18 +23,18 @@ import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.*;
import com.nflg.product.bomnew.mapper.master.BomNewEbomParentMapper;
import com.nflg.product.bomnew.pojo.dto.*;
import com.nflg.product.bomnew.pojo.entity.*;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomMaterialUseEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity;
import com.nflg.product.bomnew.pojo.query.BomNewEbomMaterialQuery;
import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.service.domain.EBom.*;
import com.nflg.product.bomnew.service.domain.OriginalBom.OriginalBomDetailTask;
import com.nflg.product.bomnew.util.*;
import lombok.extern.slf4j.Slf4j;
import nflg.product.common.constant.STATE;
import nflg.product.common.vo.ResultVO;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -58,7 +51,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
@ -683,15 +675,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
public void convertToPBom(EBomToPBomParamDTO paramDto) throws ExecutionException, InterruptedException {
//31 须有虚拟包
List<BomNewEbomParentEntity> parents = this.getBaseMapper().selectBatchIds(paramDto.getBomRowIds());
List<String> noVirPackage = parents.stream().filter(u -> u.getMaterialNo().startsWith("31") && u.getVirtrualPackageEnum() <= 0).map(u -> u.getMaterialNo()).collect(Collectors.toList());
List<String> noVirPackage = parents.stream().filter(u -> u.getMaterialNo().startsWith("31") && u.getVirtrualPackageEnum() <= 0).map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noVirPackage)).throwMessage("31码须有虚拟包");
for (Long bomRowId : paramDto.getBomRowIds()) {
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, this.getById(bomRowId));
VUtils.isTure(Objects.isNull(parent)).throwMessage("Bom版本不存在");
VUtils.isTure(Objects.isNull(parent)).throwMessage("Bom版本不存在"+bomRowId.toString());
LogRecordContext.putVariable("bom", parent);
List<BomNewEbomParentVO> bomTree = getBomTree(bomRowId);
VUtils.isTure(CollUtil.isEmpty(bomTree)).throwMessage("该BOM不存在下降,无需转换");
VUtils.isTure(CollUtil.isEmpty(bomTree)).throwMessage("该BOM不存在下级,无需转换:"+ bomRowId.toString());
parent.setBomRowId(parent.getRowId());
parent.setChildBomRowId(parent.getRowId());
parent.setParentRowId(0L);

View File

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
@ -13,6 +14,7 @@ import com.google.common.collect.ImmutableList;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.bomnew.constant.BomConstant;
import com.nflg.product.bomnew.constant.EBomConstant;
import com.nflg.product.bomnew.constant.EBomSuperMaterialStatusEnum;
import com.nflg.product.bomnew.constant.MBomConstantEnum;
import com.nflg.product.bomnew.mapper.master.BomNewMbomParentMapper;
import com.nflg.product.bomnew.pojo.dto.BomNewMBomChildDTO;
@ -197,8 +199,64 @@ public class BomNewMbomParentService extends ServiceImpl<BomNewMbomParentMapper,
parentVO.setBomExist(1);
List<BomNewMbomMiddleVO> list=queryDetail(0l,parentVO.getRowId());
list.add(0,parentVO);
//查找超级物料
List<BomNewMbomMiddleVO> superList=list.stream().filter(item-> ObjectUtil.equal(item.getSuperMaterialStatus(), EBomSuperMaterialStatusEnum.SUPER_MATERIAL_1.getValue())).collect(Collectors.toList());
if(CollUtil.isNotEmpty(superList)) {
List<BomNewMbomMiddleVO> delList=new ArrayList<>();
//超级物料提层
for (BomNewMbomMiddleVO item :
superList) {
BomNewMbomMiddleVO parent=list.stream().filter(u->ObjectUtil.equal(item.getParentRowId(),u.getRowId())).collect(Collectors.toList()).get(0);
//超级物料上一级是根忽略
if(parent.getParentRowId().longValue()==0){
continue;
}
Long grandparentRowId=parent.getParentRowId();
//提层
item.setParentRowId(grandparentRowId);
delList.add(parent);
}
//删除提层被替换的
if(CollUtil.isNotEmpty(delList)){
List<Long> rowIds=new ArrayList<>();
List<Long> tmpId=new ArrayList<>();
List<Long> nextTmpId=new ArrayList<>();
Map<Long, List<BomNewMbomMiddleVO>> mapList = list.stream().collect(Collectors.groupingBy(BomNewMbomMiddleVO::getParentRowId));
delList.forEach(
item->{
tmpId.clear();
tmpId.add(item.getRowId());
while (!tmpId.isEmpty()){
nextTmpId.clear();
for(Long id:tmpId){
if(CollUtil.isNotEmpty(mapList.get(id))) {
nextTmpId.addAll(mapList.get(id).stream().map(BomNewMbomMiddleVO::getRowId).collect(Collectors.toList()));
}
}
rowIds.addAll(tmpId);
tmpId.clear();
tmpId.addAll(nextTmpId);
}
}
);
for (Long id:
rowIds) {
list.removeIf(u->ObjectUtil.equal(u.getRowId(),id));
}
}
}
ImportSapParamDTO result=new ImportSapParamDTO();
result.setT1(new ArrayList<>());
result.setZID(RandomUtil.randomNumbers(5));
@ -251,6 +309,7 @@ public class BomNewMbomParentService extends ServiceImpl<BomNewMbomParentMapper,
}
return resultVO;
// return null;
}

View File

@ -86,7 +86,7 @@
order by created_time desc
</if>
<if test="job==1">
select * ,row_id as bomRowId from t_bom_new_ebom_parent where ( (user_root_is= 1 and created_by=#{createdBy} ) or root_is=1) and status=2
select * ,row_id as bomRowId from t_bom_new_ebom_parent where ((((user_root_is=1 and created_by=#{createdBy}) or root_is=1) and status=2) or (created_by=#{createdBy} and user_root_is=1 and (status=1 or status=3)))
<include refid="whr"/>
order by created_time desc
</if>