|
|
|
@ -19,6 +19,7 @@ import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.*;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static net.xdclass.shopmanager.model.PmSmallPltPosDO.SMALL_PLATE_DIV_NO;
|
|
|
|
@ -69,6 +70,8 @@ public class SubController {
|
|
|
|
|
//命令小板表
|
|
|
|
|
private static List<PmCmdSmallPltDO> pmCmdSmallPltDOList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 全局变量,使用 ConcurrentHashMap 和 AtomicInteger 确保线程安全
|
|
|
|
|
private final ConcurrentHashMap<String, AtomicInteger> counterMap = new ConcurrentHashMap<>();
|
|
|
|
|
|
|
|
|
|
private static int intOrdNum = 0;
|
|
|
|
|
|
|
|
|
@ -128,6 +131,10 @@ public class SubController {
|
|
|
|
|
private static List<PmPdSlabInfoDO> plistPmPdSlabInfoDO; //TODO 需要添加此表信息的查询
|
|
|
|
|
//TODO 需要添加 QD_TO_PO_ORDER 的查询记录
|
|
|
|
|
private static Date now;
|
|
|
|
|
//组板履历表
|
|
|
|
|
private static List<PmSubHisDO> plistpmSubHisDO=new ArrayList<>();
|
|
|
|
|
//组板订单详细表
|
|
|
|
|
private static List<PmSubOrdDO> plistpmSubOrdDO=new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// //加热炉板坯最小长度
|
|
|
|
|
// private static int gintSlabMinLen;
|
|
|
|
@ -1406,6 +1413,9 @@ public class SubController {
|
|
|
|
|
p.setWid_Add(maxAddWidth.orElse(0));
|
|
|
|
|
//切边余量
|
|
|
|
|
p.setTrimming(intTrimWid);
|
|
|
|
|
//切缝
|
|
|
|
|
p.setPlate_Cut_Wid(intPlateCutWidth);
|
|
|
|
|
|
|
|
|
|
//订单合计长度+切缝 TODO:取样长度是否加入计算,后续再优化
|
|
|
|
|
int intSumOrderLen = p.getLtActInfoGPreOrder().stream().mapToInt(GPreOrder::getLen).sum();
|
|
|
|
|
int intSumPlateCutWid = p.getLtActInfoGPreOrder().size() * intPlateCutWidth;
|
|
|
|
@ -1534,13 +1544,14 @@ public class SubController {
|
|
|
|
|
//选择最优结果
|
|
|
|
|
ChosBestRsl(SInfo);
|
|
|
|
|
|
|
|
|
|
//小于最小入炉尺寸
|
|
|
|
|
if (SInfo.getRemLen().intValue() <2200)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
SetGroupCalRslt(SInfo);
|
|
|
|
|
}
|
|
|
|
|
//递归
|
|
|
|
|
// //小于最小入炉尺寸
|
|
|
|
|
// if (SInfo.getRemLen().intValue() <2200)
|
|
|
|
|
// {
|
|
|
|
|
//
|
|
|
|
|
// }else{
|
|
|
|
|
// SetGroupCalRslt(SInfo);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ChosBestRsl(SlabInfoDO SInfo) {
|
|
|
|
@ -1558,8 +1569,108 @@ public class SubController {
|
|
|
|
|
// 将筛选出的数据添加到 gltSelGGrpCalRslt 中
|
|
|
|
|
maxWeightMaxYieldRate.ifPresent(gltSelGGrpCalRslt::add);
|
|
|
|
|
|
|
|
|
|
if (maxWeightMaxYieldRate.isPresent()) {
|
|
|
|
|
|
|
|
|
|
GGrpCalRslt maxRate = maxWeightMaxYieldRate.get();
|
|
|
|
|
|
|
|
|
|
PmSubHisDO pmSubHisDO = new PmSubHisDO();
|
|
|
|
|
pmSubHisDO.setSlabNo(SInfo.getSlabNo()); // 板坯号
|
|
|
|
|
// 生成虚拟板坯号
|
|
|
|
|
String virtualSlabNo = generateVirtualSlabNo(SInfo.getPono());
|
|
|
|
|
pmSubHisDO.setVirtualSlabNo(virtualSlabNo); // 虚拟板坯号
|
|
|
|
|
|
|
|
|
|
// 手动为每个字段赋值
|
|
|
|
|
pmSubHisDO.setSlabThick(maxRate.getVirtualSlab_Thk()); // 厚度
|
|
|
|
|
pmSubHisDO.setSlabWid(BigDecimal.valueOf(maxRate.getVirtualSlab_Wid())); // 宽度
|
|
|
|
|
pmSubHisDO.setSlabLen(BigDecimal.valueOf(maxRate.getVirtualSlab_Len())); // 长度
|
|
|
|
|
pmSubHisDO.setSlabWt(maxRate.getVirtualSlab_Wgt()); // 重量
|
|
|
|
|
pmSubHisDO.setSubYield(maxRate.getRate()); // 替代率
|
|
|
|
|
pmSubHisDO.setRelYield(maxRate.getRate()); // 利用率,假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setSubResult(""); // 处理结果,假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setSubInfo(""); // 处理内容,假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setProcessCode(""); // 进程代码,假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setFormPlateMode(""); // 组板方式,假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setStNo(""); // 内部钢种,假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setSubTime(new Date()); // 替代时间,假设没有对应字段,设置为当前时间
|
|
|
|
|
pmSubHisDO.setCreationDate(new Date()); // 创建时间
|
|
|
|
|
pmSubHisDO.setCreatedBy(BigDecimal.valueOf(781L)); // 创建人ID,假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setLastUpdatedBy(BigDecimal.valueOf(781L)); // 最近更新人ID,假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setLastUpdateDate(new Date()); // 最近更新时间
|
|
|
|
|
pmSubHisDO.setTenantId(BigDecimal.ZERO); // 租户ID,假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setObjectVersionNumber(BigDecimal.ZERO); // 行版本号,用来处理锁,假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setAttribute1(""); // 假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setAttribute2(""); // 假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setAttribute3(""); // 假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setAttribute4(""); // 假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setAttribute5(""); // 假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setRollThk(maxRate.getVirtualSlab_Thk()); // 轧件厚
|
|
|
|
|
pmSubHisDO.setRollWid(BigDecimal.valueOf(maxRate.getVirtualSlab_Wid())); // 轧件宽
|
|
|
|
|
pmSubHisDO.setRollLen(BigDecimal.valueOf(maxRate.getVirtualSlab_Len())); // 轧件长
|
|
|
|
|
pmSubHisDO.setHeadCut(BigDecimal.valueOf(maxRate.getHead_Len())); // 头部切舍量
|
|
|
|
|
pmSubHisDO.setTailCut(BigDecimal.valueOf(maxRate.getTail_Len())); // 尾部切舍量
|
|
|
|
|
pmSubHisDO.setWidCut(BigDecimal.valueOf(maxRate.getTrimming())); // 切边宽度,假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubHisDO.setSlitLen(BigDecimal.valueOf(maxRate.getPlate_Cut_Wid())); // 切缝长度
|
|
|
|
|
pmSubHisDO.setNeedSlabLen(BigDecimal.valueOf(maxRate.getVirtualSlab_Len())); // 必要板坯长度
|
|
|
|
|
pmSubHisDO.setNeedSlabWt(maxRate.getVirtualSlab_Wgt()); // 必要板坯重量
|
|
|
|
|
|
|
|
|
|
plistpmSubHisDO.add(pmSubHisDO);
|
|
|
|
|
//子表信息
|
|
|
|
|
// 使用 AtomicInteger 获取索引
|
|
|
|
|
AtomicInteger index = new AtomicInteger(0);
|
|
|
|
|
AtomicInteger intX = new AtomicInteger(maxRate.getHead_Len());
|
|
|
|
|
maxRate.getLtActInfoGPreOrder().forEach(
|
|
|
|
|
gPreOrder -> {
|
|
|
|
|
int currentIndex = index.getAndIncrement();
|
|
|
|
|
|
|
|
|
|
// 实例化 PmSubOrdDO 对象
|
|
|
|
|
PmSubOrdDO pmSubOrdDO = new PmSubOrdDO();
|
|
|
|
|
|
|
|
|
|
// 生成虚拟板坯号
|
|
|
|
|
pmSubOrdDO.setVirtualSlabNo(virtualSlabNo); // 虚拟板坯号
|
|
|
|
|
|
|
|
|
|
// 手动为每个字段赋值
|
|
|
|
|
pmSubOrdDO.setOrderNo(gPreOrder.getOrderNo()); // 合同号
|
|
|
|
|
pmSubOrdDO.setSgSign(gPreOrder.getInfoPmProContProdAttrDO().getSgSign()); // 牌号
|
|
|
|
|
pmSubOrdDO.setStNo(SInfo.getStNo()); // 内部钢种
|
|
|
|
|
pmSubOrdDO.setOrderThick(gPreOrder.getThk()); // 订货厚度
|
|
|
|
|
pmSubOrdDO.setOrderWidth(BigDecimal.valueOf(gPreOrder.getWid())); // 订货宽度
|
|
|
|
|
pmSubOrdDO.setLenAim(BigDecimal.valueOf(gPreOrder.getIntActLen())); // 订货长度
|
|
|
|
|
|
|
|
|
|
pmSubOrdDO.setPosX(BigDecimal.valueOf( intX.intValue())); // X坐标,假设默认为0
|
|
|
|
|
intX.addAndGet(gPreOrder.getLen()+5);//X坐标
|
|
|
|
|
pmSubOrdDO.setPosY(BigDecimal.valueOf(maxRate.getTrimming()+gPreOrder.getWid())); // Y坐标,假设默认为0
|
|
|
|
|
|
|
|
|
|
pmSubOrdDO.setDelivyDate(new Date()); // 交货日期,假设默认为当前时间
|
|
|
|
|
pmSubOrdDO.setAxisOrd(gPreOrder.getOrderNo()); // 轴合同
|
|
|
|
|
pmSubOrdDO.setLackNum(BigDecimal.ZERO); // 欠量,假设默认为0
|
|
|
|
|
pmSubOrdDO.setOverNum(BigDecimal.ZERO); // 超投,假设默认为0
|
|
|
|
|
pmSubOrdDO.setCreationDate(new Date()); // 创建时间
|
|
|
|
|
pmSubOrdDO.setCreatedBy(BigDecimal.valueOf(781L)); // 创建人ID,假设默认为781
|
|
|
|
|
pmSubOrdDO.setLastUpdatedBy(BigDecimal.valueOf(781L)); // 最近更新人ID,假设默认为781
|
|
|
|
|
pmSubOrdDO.setLastUpdateDate(new Date()); // 最近更新时间
|
|
|
|
|
pmSubOrdDO.setTenantId(BigDecimal.ZERO); // 租户ID,假设默认为0
|
|
|
|
|
pmSubOrdDO.setObjectVersionNumber(BigDecimal.ZERO); // 行版本号,假设默认为0
|
|
|
|
|
pmSubOrdDO.setAttribute1(""); // 假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubOrdDO.setAttribute2(""); // 假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubOrdDO.setAttribute3(""); // 假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubOrdDO.setAttribute4(""); // 假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubOrdDO.setAttribute5(""); // 假设没有对应字段,设置为默认值
|
|
|
|
|
pmSubOrdDO.setOrderSeqNo(String.valueOf(currentIndex)); // 合同顺序号,假设使用合同号作为顺序号
|
|
|
|
|
|
|
|
|
|
// 将 PmSubOrdDO 对象添加到列表中
|
|
|
|
|
plistpmSubOrdDO.add(pmSubOrdDO);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 生成虚拟板坯号的方法
|
|
|
|
|
private String generateVirtualSlabNo(String pono) {
|
|
|
|
|
AtomicInteger counter = counterMap.computeIfAbsent(pono, k -> new AtomicInteger(0));
|
|
|
|
|
int currentCounter = counter.incrementAndGet();
|
|
|
|
|
return pono + "S9" + String.format("%03d", currentCounter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置保存数据
|
|
|
|
|