Merge branch 'feature/DM/nflg-bom' of http://112.74.186.154:3000/nflj/nflg_project into feature/DM/nflg-bom
This commit is contained in:
commit
8c2b28999a
|
|
@ -17,6 +17,7 @@ import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO;
|
|||
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
||||
import com.nflg.product.bomnew.service.BomNewOriginalParentService;
|
||||
import com.nflg.product.bomnew.service.MaterialMainService;
|
||||
import com.nflg.product.bomnew.service.UserRoleService;
|
||||
import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageBase;
|
||||
import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageFor31;
|
||||
import com.nflg.product.bomnew.util.EecExcelUtil;
|
||||
|
|
@ -61,6 +62,9 @@ public class EbomApi extends BaseApi {
|
|||
@Resource
|
||||
private MaterialMainService materialMainService;
|
||||
|
||||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
|
||||
|
||||
@PostMapping("workDetailsListByPage")
|
||||
@ApiOperation("Ebom-工作明细列表")
|
||||
|
|
@ -102,8 +106,12 @@ public class EbomApi extends BaseApi {
|
|||
bomNewEbomParentService.generateVirtualPackage(paramDto);
|
||||
VUtils.isTure(true).throwMessage("请选择30开头的或200401类型的物料");
|
||||
return ResultVO.success(true);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("generateRolePost")
|
||||
@ApiOperation("获取用户角色岗位")
|
||||
public ResultVO<List<String>> generateRolePost() {
|
||||
return ResultVO.success(userRoleService.getUserPost());
|
||||
}
|
||||
|
||||
@PostMapping("convertToPBom")
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.nflg.product.base.core.api.BaseApi;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewEbomChildMapper;
|
||||
import com.nflg.product.bomnew.pojo.dto.BomNewOriginalExcelDTO;
|
||||
import com.nflg.product.bomnew.pojo.dto.OriginalSaveBomDTO;
|
||||
import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
|
||||
|
|
@ -52,6 +53,9 @@ public class OriginalBomApi extends BaseApi {
|
|||
@Resource
|
||||
MaterialService materialService;
|
||||
|
||||
@Resource
|
||||
BomNewEbomChildMapper bomNewEbomChildMapper;
|
||||
|
||||
@PostMapping("bomPage")
|
||||
@ApiOperation("原始BOM-列表")
|
||||
public ResultVO<Page<BomOriginalListVO>> bomPage(@RequestBody OriginalBomQuery query) {
|
||||
|
|
@ -120,7 +124,10 @@ public class OriginalBomApi extends BaseApi {
|
|||
|
||||
VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要转换的BOM");
|
||||
VUtils.isTure(bomRowIds.size()>20).throwMessage("你选择的BOM数据大于20");
|
||||
return ResultVO.success(originalParentService.convertToEBom(bomRowIds));
|
||||
originalParentService.convertToEBom(bomRowIds);
|
||||
//更新物料使用
|
||||
bomNewEbomChildMapper.updateEBomMaterialUse();
|
||||
return ResultVO.success(true);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,15 +8,16 @@ import lombok.Getter;
|
|||
@Getter
|
||||
public enum VirtualPackageTypeEnum implements ValueEnum<Integer>{
|
||||
//1-发货包 2-制作包 4-直发包 8-发货前装配包
|
||||
DELIVERY_PACKAGE(1,"发货包","发货" ,"201101"),
|
||||
MAKING_PACKAGE(2,"制作包","制作","201101"),
|
||||
DIRECT_DELIVERY_PACKAGE(4,"直发包","直发","201101"),
|
||||
PRE_ASSEMBLY_PACKAGE(8,"发货前装配包","发货前装配","201201");
|
||||
DELIVERY_PACKAGE(1,"发货包","发货" ,"201101", ""),
|
||||
MAKING_PACKAGE(2,"制作包","制作","201101",""),
|
||||
DIRECT_DELIVERY_PACKAGE(4,"直发包","直发","201101","F"),
|
||||
PRE_ASSEMBLY_PACKAGE(8,"发货前装配包","发货前装配","201201","Z");
|
||||
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
private final String conMaterialName;
|
||||
private final String materialCategoryCode;
|
||||
private final String productTypeKey;
|
||||
|
||||
|
||||
public static Integer getAll(){
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
package com.nflg.product.bomnew.service.domain.EBom;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -19,12 +21,108 @@ public class EBomToPBom {
|
|||
private List<BomNewEbomParentVO> allBomDetail;
|
||||
|
||||
|
||||
private List<BomNewEbomParentVO> result = new ArrayList<>();
|
||||
|
||||
|
||||
@Getter
|
||||
private List<BomNewEbomParentVO> parentResult = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
private List<BomNewEbomParentVO> childResult = new ArrayList<>();
|
||||
|
||||
|
||||
private Map<String, String> generateDrawingNoMap = new HashMap<>();
|
||||
|
||||
|
||||
public EBomToPBom(BomNewEbomParentVO inParent, List<BomNewEbomParentVO> inAllBomDetail) {
|
||||
this.parent = inParent;
|
||||
this.allBomDetail = inAllBomDetail;
|
||||
|
||||
generateDrawingNo(allBomDetail, inParent.getRowId(), "");
|
||||
}
|
||||
|
||||
|
||||
public void buildResult(){
|
||||
|
||||
parentResult=result.stream().filter(u->u.getBomRowId()>0).collect(Collectors.toList());
|
||||
parentResult.add(parent);
|
||||
childResult=result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 31項体层
|
||||
*/
|
||||
private void handlerProjectFor31() {
|
||||
|
||||
|
||||
for (BomNewEbomParentVO vo : allBomDetail) {
|
||||
|
||||
if (vo.getProjectType().equals(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey())) {
|
||||
BomNewEbomParentVO lastVirtualPackage = getLastVirtualPackage(vo, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
||||
if (Objects.nonNull(lastVirtualPackage)) {
|
||||
vo.setParentRowId(lastVirtualPackage.getBomRowId());
|
||||
result.add(vo);
|
||||
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (vo.getProjectType().equals(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey())) {
|
||||
BomNewEbomParentVO lastVirtualPackage = getLastVirtualPackage(vo, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
|
||||
if (Objects.nonNull(lastVirtualPackage)) {
|
||||
vo.setParentRowId(lastVirtualPackage.getBomRowId());
|
||||
result.add(vo);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
result.add(vo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 21项体层
|
||||
*/
|
||||
private void handlerProjectFor21() {
|
||||
|
||||
|
||||
for (BomNewEbomParentVO vo : allBomDetail) {
|
||||
|
||||
if (vo.getProjectType().equals(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey())) {
|
||||
BomNewEbomParentVO lastVirtualPackage = getLastVirtualPackage(vo, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
||||
if (Objects.nonNull(lastVirtualPackage)) {
|
||||
vo.setParentRowId(lastVirtualPackage.getBomRowId());
|
||||
result.add(vo);
|
||||
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (vo.getProjectType().equals(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey())) {
|
||||
BomNewEbomParentVO lastVirtualPackage = getVirtualPackageByName(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
|
||||
if (Objects.nonNull(lastVirtualPackage)) {
|
||||
vo.setParentRowId(lastVirtualPackage.getBomRowId());
|
||||
result.add(vo);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
result.add(vo);
|
||||
}
|
||||
}
|
||||
|
||||
private BomNewEbomParentVO getLastVirtualPackage(BomNewEbomParentVO vo, VirtualPackageTypeEnum virtualPackageTypeEnum) {
|
||||
List<BomNewEbomParentVO> zhiFaList = allBomDetail.stream().filter(u -> vo.getLevelNumber().compareTo(u.getLevelNumber()) > 0 && u.getMaterialName().contains(virtualPackageTypeEnum.getConMaterialName())).collect(Collectors.toList());
|
||||
return Collections.max(zhiFaList, Comparator.comparing(BomNewEbomParentVO::getLevelNumber));
|
||||
|
||||
}
|
||||
|
||||
|
||||
private BomNewEbomParentVO getVirtualPackageByName( VirtualPackageTypeEnum virtualPackageTypeEnum) {
|
||||
List<BomNewEbomParentVO> list = allBomDetail.stream().filter(u -> u.getMaterialName().contains(virtualPackageTypeEnum.getConMaterialName())).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(list)){
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -42,11 +140,11 @@ public class EBomToPBom {
|
|||
for (BomNewEbomParentVO firstLevelBom : firstLevelBoms) {
|
||||
String key = StrUtil.join("-", bomRowID.toString(), firstLevelBom.getMaterialNo());
|
||||
if (generateDrawingNoMap.containsKey(key)) {
|
||||
// firstLevelBom.setLevelNumber(generateDrawingNoMap.get(key));
|
||||
firstLevelBom.setLevelNumber(levelToNum(generateDrawingNoMap.get(key)));
|
||||
continue;
|
||||
}
|
||||
|
||||
firstLevelBom.setDrawingNo(StrUtil.isNotBlank(parentDrawingNo) ? StrUtil.join("-", parentDrawingNo, gNo.toString()) : gNo.toString());
|
||||
String levelKey = StrUtil.isNotBlank(parentDrawingNo) ? StrUtil.join("-", parentDrawingNo, gNo.toString()) : gNo.toString();
|
||||
firstLevelBom.setLevelNumber(levelToNum(levelKey));
|
||||
gNo++;
|
||||
generateDrawingNo(saveBomDetailParamDTO, firstLevelBom.getChildBomRowId(), firstLevelBom.getDrawingNo());
|
||||
|
||||
|
|
@ -57,5 +155,31 @@ public class EBomToPBom {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换层级号为数字
|
||||
*
|
||||
* @param strLevel
|
||||
* @return
|
||||
*/
|
||||
private BigDecimal levelToNum(String strLevel) {
|
||||
if (StrUtil.isEmpty(strLevel)) {
|
||||
return null;
|
||||
}
|
||||
if (strLevel.indexOf('-') == -1) {
|
||||
return new BigDecimal(strLevel);
|
||||
}
|
||||
String[] fromArray = strLevel.split("-");
|
||||
String reuslt = "";
|
||||
for (int i = 0; i < fromArray.length; i++) {
|
||||
if (i == 0) {
|
||||
reuslt = fromArray[i] + '.';
|
||||
} else {
|
||||
reuslt += StrUtil.padPre(fromArray[i], 2, '0');
|
||||
}
|
||||
|
||||
}
|
||||
return new BigDecimal(reuslt);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue