From 12f6e1c22782d19e434a2f3fa6dbe4a578ee1239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Wed, 13 Mar 2024 13:46:56 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/BomNewEbomParentService.java | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index 2d11d0ff..e0ae536e 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -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 parents = this.getBaseMapper().selectBatchIds(paramDto.getBomRowIds()); - List noVirPackage = parents.stream().filter(u -> u.getMaterialNo().startsWith("31") && u.getVirtrualPackageEnum() <= 0).map(u -> u.getMaterialNo()).collect(Collectors.toList()); + List 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 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); From 9b1d387bec0baf3940b2072b48cc825701d535ae Mon Sep 17 00:00:00 2001 From: jing's Date: Wed, 13 Mar 2024 14:52:18 +0800 Subject: [PATCH 2/3] mbom sap --- .../service/BomNewMbomParentService.java | 61 ++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomParentService.java index 2c119351..92e6a623 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomParentService.java @@ -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 list=queryDetail(0l,parentVO.getRowId()); - list.add(0,parentVO); + + //查找超级物料 + List superList=list.stream().filter(item-> ObjectUtil.equal(item.getSuperMaterialStatus(), EBomSuperMaterialStatusEnum.SUPER_MATERIAL_1.getValue())).collect(Collectors.toList()); + + if(CollUtil.isNotEmpty(superList)) { + List 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 rowIds=new ArrayList<>(); + List tmpId=new ArrayList<>(); + List nextTmpId=new ArrayList<>(); + Map> 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 Date: Wed, 13 Mar 2024 16:44:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=B7=A5=E8=89=BA=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=9C=8B=E5=88=B0=E8=87=AA=E5=B7=B1=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E7=9A=84=E5=BE=85=E5=A4=8D=E6=A0=B8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=88=E6=9E=81=E7=AB=AF=E6=83=85=E5=86=B5=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E4=BA=BA=E5=91=98=E8=BA=AB=E4=BB=BD=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E4=BA=86=E6=95=B0=E6=8D=AE=EF=BC=8C=E8=80=8C=E5=90=8E?= =?UTF-8?q?=E5=8F=88=E8=A2=AB=E8=B5=8B=E4=BA=88=E4=BA=86=E5=B7=A5=E8=89=BA?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E8=BA=AB=E4=BB=BD=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/master/BomNewEbomParentMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml index 8c3537aa..730b7d42 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml @@ -86,7 +86,7 @@ order by created_time desc - 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))) order by created_time desc