diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEBomImportExcelDTO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEBomImportExcelDTO.java index 44aef4da..e685a25a 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEBomImportExcelDTO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEBomImportExcelDTO.java @@ -3,6 +3,7 @@ package com.nflg.product.bomnew.pojo.dto; import com.baomidou.mybatisplus.annotation.TableField; import com.nflg.product.base.core.conmon.util.SessionUtil; +import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.ttzero.excel.annotation.ExcelColumn; @@ -71,4 +72,26 @@ public class BomNewEBomImportExcelDTO { @ApiModelProperty("物料状态") private Integer materialStatus; + + + @ApiModelProperty("0-非虚拟包 1-发货包 2-制作包 4-直发包 8-发货前装配包") + private Integer virtualPartType; + + public Integer getVirtualPartType() { + if( drawingNo.contains(VirtualPackageTypeEnum.DELIVERY_PACKAGE.getConMaterialName())){ + return VirtualPackageTypeEnum.DELIVERY_PACKAGE.getValue(); + } + else if( drawingNo.contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName())){ + return VirtualPackageTypeEnum.MAKING_PACKAGE.getValue(); + } + else if( drawingNo.contains(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getConMaterialName())){ + return VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue(); + } + else if( drawingNo.contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getConMaterialName())){ + return VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue(); + } + else { + return 0; + } + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseMaterialVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseMaterialVO.java index 1db64c1a..14b467ba 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseMaterialVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseMaterialVO.java @@ -43,7 +43,7 @@ public class BaseMaterialVO { private Integer materialState; @ApiModelProperty("图号") - private String drawingNo; + protected String drawingNo; /** * 材料 diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomOriginalListVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomOriginalListVO.java index 016a0a57..3cf35b02 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomOriginalListVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomOriginalListVO.java @@ -2,6 +2,7 @@ package com.nflg.product.bomnew.pojo.vo; import com.baomidou.mybatisplus.annotation.TableField; +import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -181,6 +182,27 @@ public class BomOriginalListVO extends BaseMaterialVO { @ApiModelProperty("转换后Ebom行ID") private Long eBomRowId=0L; + @ApiModelProperty("0-非虚拟包 1-发货包 2-制作包 4-直发包 8-发货前装配包") + private Integer virtualPartType; + + public Integer getVirtualPartType() { + if( drawingNo.contains(VirtualPackageTypeEnum.DELIVERY_PACKAGE.getConMaterialName())){ + return VirtualPackageTypeEnum.DELIVERY_PACKAGE.getValue(); + } + else if( drawingNo.contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName())){ + return VirtualPackageTypeEnum.MAKING_PACKAGE.getValue(); + } + else if( drawingNo.contains(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getConMaterialName())){ + return VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue(); + } + else if( drawingNo.contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getConMaterialName())){ + return VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue(); + } + else { + return 0; + } + } + private List childNodes = Collections.emptyList(); 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 ed8980b2..23f6cacb 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 @@ -18,6 +18,7 @@ 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; @@ -280,7 +281,7 @@ public class BomNewEbomParentService extends ServiceImpl materialNos = parentChild.stream().filter(u->StrUtil.isNotBlank(u.getMaterialNo())).map(u -> u.getMaterialNo()).collect(Collectors.toList()); + List materialNos = parentChild.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo())).map(u -> u.getMaterialNo()).collect(Collectors.toList()); if (CollUtil.isNotEmpty(materialNos)) { List list = this.lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos) .eq(BomNewEbomParentEntity::getLastVersionIs, 1) @@ -309,11 +310,11 @@ public class BomNewEbomParentService extends ServiceImplparentEntity.getStatus()) { + if (parentEntity.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue()) && EBomStatusEnum.PUBLISHED.getValue() > parentEntity.getStatus()) { child.setStatus(EBomStatusEnum.BORROWED_PARTS.getValue()); } //非本人则为借用件 - if (!parentEntity.getCreatedBy().equals(child.getCreatedBy()) && EBomStatusEnum.PUBLISHED.getValue()>parentEntity.getStatus()) { + if (!parentEntity.getCreatedBy().equals(child.getCreatedBy()) && EBomStatusEnum.PUBLISHED.getValue() > parentEntity.getStatus()) { child.setStatus(EBomStatusEnum.REFERENCE.getValue()); } @@ -441,7 +442,7 @@ public class BomNewEbomParentService extends ServiceImpl list = getChild(root.getRowId()); + List deliveryList = list.stream().filter(u -> VirtualPackageTypeEnum.DELIVERY_PACKAGE.equalsValue(u.getVirtualPartType())).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(deliveryList)) { + Integer virtualPartTypeEnum = VirtualPackageTypeEnum.DELIVERY_PACKAGE.getValue() | VirtualPackageTypeEnum.MAKING_PACKAGE.getValue() | VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue(); + List preList = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, deliveryList.get(0).getBomRowId()) + .eq(BomNewEbomChildEntity::getVirtualPartType, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()).list(); + if (CollUtil.isNotEmpty(preList)) { + virtualPartTypeEnum = virtualPartTypeEnum | VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue(); + } + root.setVirtrualPackageEnum(virtualPartTypeEnum); + this.updateById(root); + + } + } + if (root.getMaterialNo().startsWith("21")) { + + List list = getChild(root.getRowId()); + List makeList = list.stream().filter(u -> VirtualPackageTypeEnum.MAKING_PACKAGE.equalsValue(u.getVirtualPartType())).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(makeList)) { + Integer virtualPartTypeEnum = VirtualPackageTypeEnum.MAKING_PACKAGE.getValue() | VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue(); + List preList = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, makeList.get(0).getBomRowId()) + .eq(BomNewEbomChildEntity::getVirtualPartType, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()).list(); + if (CollUtil.isNotEmpty(preList)) { + virtualPartTypeEnum = virtualPartTypeEnum | VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue(); + } + root.setVirtrualPackageEnum(virtualPartTypeEnum); + this.updateById(root); + + } + } + } + + + } + /** * 生成虚拟包 @@ -588,7 +628,11 @@ public class BomNewEbomParentService extends ServiceImpl delSet = eBomToPBom.getVirtualPackageCompositionResult().stream().map(u -> StrUtil.join("-", u.getVirtualPackageMaterialNo(), u.getParentMaterialNo())).collect(Collectors.toSet()); for (String s : delSet) { String[] split = StrUtil.split(s, "-"); - virtualPackageCompositionService.getBaseMapper().delByVnoAndParentNo(split[0],split[1]); + virtualPackageCompositionService.getBaseMapper().delByVnoAndParentNo(split[0], split[1]); } virtualPackageCompositionService.saveOrUpdateBatch(eBomToPBom.getVirtualPackageCompositionResult()); - } - else { + } else { //记录变更影响 if (CollUtil.isNotEmpty(eBomToPBom.getUpgradeChangeResult())) { - List vNos = eBomToPBom.getUpgradeChangeResult().stream().map(u -> StrUtil.join( u.getMaterialNo(),u.getRelMaterialNo())).collect(Collectors.toList()); - if(CollUtil.isNotEmpty(vNos)){ + List vNos = eBomToPBom.getUpgradeChangeResult().stream().map(u -> StrUtil.join(u.getMaterialNo(), u.getRelMaterialNo())).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(vNos)) { upgradeChangeService.getBaseMapper().delByVNo(vNos); } upgradeChangeService.saveOrUpdateBatch(eBomToPBom.getUpgradeChangeResult()); @@ -673,7 +716,7 @@ public class BomNewEbomParentService extends ServiceImpl delSet = eBomToPBom.getUpgradeChangeDetailResult().stream().map(u -> StrUtil.join("-", u.getVirtualPackageMaterialNo(), u.getParentMaterialNo())).collect(Collectors.toSet()); for (String s : delSet) { String[] split = StrUtil.split(s, "-"); - updateDetailService.getBaseMapper().delByVnoAndParentNo(split[0],split[1]); + updateDetailService.getBaseMapper().delByVnoAndParentNo(split[0], split[1]); } updateDetailService.saveOrUpdateBatch(eBomToPBom.getUpgradeChangeDetailResult()); } @@ -704,7 +747,7 @@ public class BomNewEbomParentService extends ServiceImpl existEnt = this.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parent.getMaterialNo()).lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list(); //含发布前版本则无需升级 - if(CollUtil.isEmpty(existEnt)) { + if (CollUtil.isEmpty(existEnt)) { List child = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, bomRowId).list(); BomNewEbomParentEntity newParent = new BomNewEbomParentEntity(); BeanUtil.copyProperties(parent, newParent); @@ -866,21 +909,17 @@ public class BomNewEbomParentService extends ServiceImpl= 0) { + } else if (StrUtil.isBlank(baseMaterialVO.getMaterialNo()) || Objects.isNull(baseMaterialVO.getNum()) || BigDecimal.ZERO.compareTo(baseMaterialVO.getNum()) >= 0) { baseMaterialVO.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue()); - } - - else if (StrUtil.isNotBlank(baseMaterialVO.getMaterialNo()) && Objects.isNull(baseMaterialVO.getMaterialState())) { + } else if (StrUtil.isNotBlank(baseMaterialVO.getMaterialNo()) && Objects.isNull(baseMaterialVO.getMaterialState())) { baseMaterialVO.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue()); } @@ -1400,7 +1435,7 @@ public class BomNewEbomParentService extends ServiceImpl computeLevelNumAndRootState()); @@ -1473,7 +1508,7 @@ public class BomNewEbomParentService extends ServiceImpl computeLevelNumAndRootState()); return true; @@ -1530,34 +1565,31 @@ public class BomNewEbomParentService extends ServiceImpl childList=getChild(dto.getParent().getBomRowId()); + List childList = getChild(dto.getParent().getBomRowId()); List tmp1 = dto.getDatas().stream().filter(item -> (Objects.nonNull(item.getRowId()) && item.getRowId() > 0)).collect(Collectors.toList()); //相同rowid 不同物料号 - List unionEdit = tmp1.stream().filter(u->{ - return childList.stream().filter(e-> - Objects.equals(u.getRowId(),e.getRowId() ) - && !Objects.equals(u.getMaterialNo(),e.getMaterialNo()) - ).count()>0; + List unionEdit = tmp1.stream().filter(u -> { + return childList.stream().filter(e -> + Objects.equals(u.getRowId(), e.getRowId()) + && !Objects.equals(u.getMaterialNo(), e.getMaterialNo()) + ).count() > 0; }).collect(Collectors.toList()); - - //相同rowid 相同物料号 - List union2 = tmp1.stream().filter(u->{ - return childList.stream().filter(e-> - Objects.equals(u.getRowId(),e.getRowId() ) - && Objects.equals(u.getMaterialNo(),e.getMaterialNo()) - ).count()>0; + List union2 = tmp1.stream().filter(u -> { + return childList.stream().filter(e -> + Objects.equals(u.getRowId(), e.getRowId()) + && Objects.equals(u.getMaterialNo(), e.getMaterialNo()) + ).count() > 0; }).collect(Collectors.toList()); - Map> groupList=childList.stream().collect(Collectors.groupingBy(BomNewEbomParentVO::getRowId)); + Map> groupList = childList.stream().collect(Collectors.groupingBy(BomNewEbomParentVO::getRowId)); - // Map> groupUnionEdit=unionEdit.stream().collect(Collectors.groupingBy(BomNewEbomParentVO::getRowId)); + // Map> groupUnionEdit=unionEdit.stream().collect(Collectors.groupingBy(BomNewEbomParentVO::getRowId)); List tmp2 = dto.getDatas().stream().filter(item -> Objects.isNull(item.getRowId()) || item.getRowId() == 0).collect(Collectors.toList()); @@ -1566,7 +1598,6 @@ public class BomNewEbomParentService extends ServiceImpl returnList=new ArrayList<>(); + List returnList = new ArrayList<>(); - if(CollectionUtil.isNotEmpty(unionEdit)){ - unionEdit.forEach(item->{ + if (CollectionUtil.isNotEmpty(unionEdit)) { + unionEdit.forEach(item -> { // if(item.getMaterialUnit().contains("KG")){ // item.setUnitWeight(null); // }else{ @@ -1592,25 +1623,24 @@ public class BomNewEbomParentService extends ServiceImpl{ - if(Objects.isNull(item.getMaterialNo())) { - BeanUtil.copyProperties(item,groupList.get(item.getRowId()).get(0)); + if (CollectionUtil.isNotEmpty(union2)) { + union2.forEach(item -> { + if (Objects.isNull(item.getMaterialNo())) { + BeanUtil.copyProperties(item, groupList.get(item.getRowId()).get(0)); } }); returnList.addAll(union2); } - if (CollectionUtil.isNotEmpty(tmp2)) { for (BomNewEbomParentVO vo : tmp2) { 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 1484f981..432eeea8 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 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 order by created_time desc diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml index 2c1c7a42..75ddde80 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml @@ -207,6 +207,7 @@ #{item} + order by created_time desc