【工艺路线】获取PBOM列表,SAP排序字符串和项目类别

This commit is contained in:
10001392 2024-12-09 10:52:32 +08:00
parent d56a6257d6
commit 5f9fdf4cff
3 changed files with 98 additions and 1 deletions

View File

@ -113,4 +113,13 @@ public class BomNewPBomVO extends BaseMaterialVO {
private String parentMaterialDesc; private String parentMaterialDesc;
@ApiModelProperty(value = "SAP排序字符串")
private String sapOrderNum = "0040";
/**
* 是否有BOM: 0- 1-
*/
@ApiModelProperty(value = "是否有BOM: 0-否 1-是")
private Integer bomExist = 0;
} }

View File

@ -22,6 +22,7 @@ import com.nflg.product.technology.mapper.master.ProcessRouteTaskProcessesMapper
import com.nflg.product.technology.pojo.entity.*; import com.nflg.product.technology.pojo.entity.*;
import com.nflg.product.technology.pojo.query.ProcessRouteTaskQuery; import com.nflg.product.technology.pojo.query.ProcessRouteTaskQuery;
import com.nflg.product.technology.pojo.vo.*; import com.nflg.product.technology.pojo.vo.*;
import com.nflg.product.technology.util.BomUtil;
import nflg.product.common.constant.STATE; import nflg.product.common.constant.STATE;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -305,7 +306,7 @@ public class ProcessRouteTaskService extends ServiceImpl<ProcessRouteTaskMapper,
// nodesList.add(rootNode); // nodesList.add(rootNode);
List<BomNewPbomParentVO> bomList = bomDetailAndParent(rootParent); List<BomNewPbomParentVO> bomList = bomDetailAndParent(rootParent);
materialMainService.intiMaterialInfo(bomList, ""); materialMainService.intiMaterialInfo(bomList, "projectType");
List<BomNewPBomVO> convertBomList = Convert.convert(new TypeReference<List<BomNewPBomVO>>() { List<BomNewPBomVO> convertBomList = Convert.convert(new TypeReference<List<BomNewPBomVO>>() {
}, bomList); }, bomList);
@ -323,6 +324,8 @@ public class ProcessRouteTaskService extends ServiceImpl<ProcessRouteTaskMapper,
item.setParentMaterialNo(parents.get(0).getMaterialNo()); item.setParentMaterialNo(parents.get(0).getMaterialNo());
item.setParentMaterialDesc(parents.get(0).getMaterialDesc()); item.setParentMaterialDesc(parents.get(0).getMaterialDesc());
} }
item.setSapOrderNum(BomUtil.generateSapOrderNum(item.getProjectType(), item.getMaterialCategoryCode()
, item.getFacCode(), item.getMaterialNo(), item.getBomExist()));
}); });
// 最顶级不返回 // 最顶级不返回
nodesList.remove(0); nodesList.remove(0);

View File

@ -0,0 +1,85 @@
package com.nflg.product.technology.util;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import java.math.BigDecimal;
import java.util.Objects;
/**
* @author 曹鹏飞
* @date 2024-04-02 10:26:21
*/
public class BomUtil {
/**
* 计算总重量四舍五入小数点后4位
* @param num 数量
* @param unitWeight 单重
* @return 总重精度四舍五入小数点后4位
*/
public static BigDecimal calculateTotalWeight(BigDecimal num, BigDecimal unitWeight) {
if (Objects.isNull(num) || Objects.isNull(unitWeight)) {
return null;
}
return NumberUtil.round(NumberUtil.mul(num, unitWeight), 4);
}
/**
* 去除末尾多余的0
* @param old 待转换的数据
* @return 去除末尾多余的0后的数据
*/
public static BigDecimal totalWeightToDisplay(BigDecimal old) {
if (Objects.isNull(old)) {
return null;
}
return new BigDecimal(NumberUtil.toStr(old));
}
public static String generateSapOrderNum(String projectType, String categoryCode, String factoryCode, String materialNo, Integer bomExist) {
String orderNum = "";
if (StrUtil.equals(projectType, "F")) {
if (StrUtil.equals(factoryCode, "1010")) {
orderNum = "0080";
} else if (StrUtil.equals(factoryCode, "1020")) {
orderNum = "0090";
}
if (StrUtil.equals(materialNo, "1100013148") && StrUtil.equals(factoryCode, "1010")) {
orderNum = "0020";
}
if (StrUtil.equals(materialNo, "1100000090") && StrUtil.equals(factoryCode, "1020")) {
orderNum = "0020";
}
if (StrUtil.equals(materialNo, "1100000091") && StrUtil.equals(factoryCode, "1020")) {
orderNum = "0020";
}
} else if (StrUtil.equals(projectType, "T")) {
orderNum = "0040";
} else {
orderNum = "0099";
if (StrUtil.isNotBlank(categoryCode) && categoryCode.length() > 6) {
categoryCode = categoryCode.substring(0, 6);
}
if (StrUtil.equals(categoryCode, "100101")) {
orderNum = "0010";
}
if (StrUtil.equals(categoryCode, "102101")) {
orderNum = "0020";
}
if (StrUtil.isNotBlank(categoryCode)) {
if (Integer.parseInt(categoryCode) >= 100102 && Integer.parseInt(categoryCode) <= 100104) {
orderNum = "0020";
}
}
if (StrUtil.equals(categoryCode, "100301") && StrUtil.equals(factoryCode, "1010")) {
orderNum = "0050";
}
if (bomExist == 1) {
orderNum = "0040";
}
}
return orderNum;
}
}