2025-03-26

main
sunhao 1 week ago
parent c9826c3e96
commit d9548802b5

@ -197,34 +197,6 @@ public class SubController {
private static List<ChkLowResult> plistLowChkRsult= new ArrayList<>();
//endregion
@ApiOperation("求解处理")
@PostMapping("Solver")
@Permission(level = ResourceLevel.ORGANIZATION)
public JsonData Solver(@RequestBody PmSubHis pmSubHis) {
// 测试数据
long[] values = {360, 83, 59, 130, 431, 67, 230, 52, 93, 125, 670, 892, 600, 38, 48, 147,
78, 256, 63, 17, 120, 164, 432, 35, 92, 110, 22, 42, 50, 323, 514, 28, 87, 73, 78, 15, 26,
78, 210, 36, 85, 189, 274, 43, 33, 10, 19, 389, 276, 312};
long[][] weights = {{7, 1, 30, 22, 80, 94, 11, 81, 70, 64, 59, 18, 1, 36, 3, 8, 15, 42, 9,
1, 42, 47, 52, 32, 26, 48, 55, 6, 29, 84, 2, 4, 18, 56, 7, 29, 93, 44, 71, 3, 86, 66, 31,
65, 1, 79, 20, 65, 52, 13}};
long[] capacities = {7};
//初始化方案
Loader.loadNativeLibraries();
// 调用 solve 方法来解决问题
ArrayList<Long> ltInt = solve(values, weights, capacities);
for (int i = 0; i < ltInt.size(); i++) {
System.out.println(ltInt.get(i));
}
JsonData xx = new JsonData();
xx.setCode(0);
xx.setData(ltInt);
xx.setMsg("成功");
return xx;
}
@ApiOperation("数据处理")
@PostMapping("/SubData1")
@Permission(level = ResourceLevel.ORGANIZATION)
@ -352,211 +324,223 @@ public class SubController {
@ApiOperation("数据处理")
@PostMapping("/SubData")
@Permission(level = ResourceLevel.ORGANIZATION)
public JsonData SubData( PmSubHis pmSubHis, @PathVariable Long organizationId) {
SecurityTokenHelper.validTokenIgnoreInsert(pmSubHis);
String strSlab = pmSubHis.getSlabNo();
long subMode = 1;
if (strSlab == null || strSlab == "") {
subMode = 2;
}
long finalSubMode = subMode;
public JsonData SubData( PmSubHis pmSubHis, @PathVariable Long organizationId) {
SubParams subParams = new SubParams();
// @RequestBody
subParams.setSlabNo(strSlab);
return subService.SubData(pmSubHis, organizationId);
// //测试阶段需要指定板坯号
// if (strSlab==null || strSlab=="")
// {
// return null;
}
//
// @ApiOperation("数据处理")
// @PostMapping("/SubData")
// @Permission(level = ResourceLevel.ORGANIZATION)
// public JsonData SubData( PmSubHis pmSubHis, @PathVariable Long organizationId) {
//
// SecurityTokenHelper.validTokenIgnoreInsert(pmSubHis);
// String strSlab = pmSubHis.getSlabNo();
//
// long subMode = 1;
//
// if (strSlab == null || strSlab == "") {
// subMode = 2;
// }
//获取所有数据
GetDataInfo(subParams);
//数据预处理
SetPreData();
logger.info("***初次分组数量*** " + gltGrpOrderFir.size());
//被使用的订单数据实例化
plistOrdHis = new ArrayList<>();
// int intSlabCount = 0;
// 使用 AtomicInteger 替代 int 类型
AtomicInteger intSlabCount = new AtomicInteger(0);
//循环板坯
plistSlab.forEach(p -> {
PmSubLog subLog = new PmSubLog();
subLog.setSlabNo(p.getSlabNo());
subLog.setSubMode(finalSubMode);
subLog.setSubRslt("成功");
subLog.setTenantId(organizationId);
String subLogStr = "";
// 获取当前计数值
int intSlabCountAdd = intSlabCount.getAndIncrement();
logger.info("*************{}--板坯开始{}************* ",intSlabCountAdd, p.getSlabNo());
logger.info("***板坯信息:{} 厚宽长:{}*{}*{} 钢种:{} ", p.getSlabNo(), p.getSlabActThk(), p.getSlabActWid(), p.getSlabActLen(), p.getStNo());
//执行日志保存
subLogStr = "板坯信息 厚宽长:" + p.getSlabActThk() + "*" + p.getSlabActWid() + "*" + p.getSlabActLen();
// 判断板坯的长度是否在plistpmAutoSubSettingDO配置的范围内
if (p.getSlabActLen().compareTo(plistpmAutoSubSettingDO.get(0).getMatLenMin()) < 0 && p.getSlabActLen().compareTo(plistpmAutoSubSettingDO.get(0).getMatLenMax()) > 0) {
logger.info("***板坯信息被排除:{} 长度不在范围内 ", p.getSlabNo());
return;
}
// 判断板坯的宽度是否在plistpmAutoSubSettingDO配置的范围内
if (p.getSlabActWid().compareTo(plistpmAutoSubSettingDO.get(0).getMatWidthMin()) < 0 && p.getSlabActWid().compareTo(plistpmAutoSubSettingDO.get(0).getMatWidthMax()) > 0) {
logger.info("***板坯信息被排除:{} 宽度不在范围内 ", p.getSlabNo());
return;
}
// 判断板坯的厚度是否在plistpmAutoSubSettingDO配置的范围内
if (p.getSlabActThk().compareTo(plistpmAutoSubSettingDO.get(0).getMatThickMin()) < 0 && p.getSlabActThk().compareTo(plistpmAutoSubSettingDO.get(0).getMatThickMax()) > 0) {
logger.info("***板坯信息被排除:{} 厚度不在范围内 ", p.getSlabNo());
return;
}
//判断plistpmIrsubableSlabDO是否包含P.SlabNO范围内
if (plistpmIrsubableSlabDO.stream().anyMatch(x -> x.getSlabNo().equals(p.getSlabNo()))) {
logger.info("***板坯信息被排除:{} 不可组板 ", p.getSlabNo());
return;
}
//判断plistpmRetainStDO是否包含P的钢种判断这个板坯的钢种是否可组板
if (plistpmRetainStDO.stream().anyMatch(x -> x.getStNo().equals(p.getStNo()))) {
logger.info("***板坯信息被排除:{} 不可组板 ", p.getSlabNo());
return;
}
try {
gltGCalGrp = new ArrayList<>();
gltGCal2Grp = new ArrayList<>();
//低倍化学成分验证
chkChmAndLowApi(organizationId,p);
//二次分组
SetGrpDataBySlab(p);
logger.info("***一次次分组1数量*** " + gltGCalGrp.size());
//数据小的情况,计算拼板。数据量大不计算
if (gltGCalGrp.size()<=100)
{
try {
SetGrpConBinDataBySlab(p);
} catch (Exception e) {
}
}
//
// logger.info("***二次分组1数量*** " + gltGCalGrp.size());
//执行日志保存
subLogStr += "-----二次分组1数量" + gltGCalGrp.size();
logger.info("***二次分组2数量*** " + gltGCal2Grp.size());
//执行日志保存
subLogStr += "-----二次分组2数量" + gltGCal2Grp.size();
gltGCalGrp.addAll(gltGCal2Grp);
//分组设置ID
for (int i = 0; i < gltGCalGrp.size(); i++) {
gltGCalGrp.get(i).setIDValue(i + 1);
}
gltGGrpCalRslt = new ArrayList<>();
gltSelGGrpCalRslt = new ArrayList<>();
plistpmSubHisDO= new ArrayList<>();
plistpmSubOrdDO = new ArrayList<>();
pmPdSlabDOList = new ArrayList<>();
pmPdPlateCutDOList = new ArrayList<>();
pmPdBlockPosDOList = new ArrayList<>();
pmPdContSumDOList = new ArrayList<>();
pmSmallPltPosDOList = new ArrayList<>();
pmCmdSlabDOList = new ArrayList<>();
pmCmdLargePltDOList = new ArrayList<>();
pmCmdContDOList = new ArrayList<>();
pmCmdSmallPltDOList = new ArrayList<>();
if (gltGCalGrp.size() > 0) {
//板坯长度和宽度调换
if (p.getSlabActLen().compareTo(p.getSlabActWid()) <= 0) {
// 当 p.getSlabActLen() 小于或等于 p.getSlabActWid() 时执行的代码
p.setRemLen(p.getSlabActWid());
p.setRemWid(p.getSlabActLen());
} else {
p.setRemLen(p.getSlabActLen());
p.setRemWid(p.getSlabActWid());
}
SetGroupCalRslt(p);
logger.info("所有结果数据板坯号:{};数量:{}", p.getSlabNo(), gltGGrpCalRslt.size());
logger.info("选择结果数据板坯号:{};数量:{}", p.getSlabNo(), gltSelGGrpCalRslt.size());
//执行日志保存
subLogStr += "-----结果数据数量1" + gltGGrpCalRslt.size() + "-----结果数据数量2" + gltSelGGrpCalRslt.size();
}
subLog.setSubLog(subLogStr);
if (gltSelGGrpCalRslt.size() > 0) {
now = new Date();
//存储数据,组板结果
SaveHisData(p);
//数据整理
SetSaveDate(p,organizationId);
//开启事务
//TransactionStatus transactionStatus = transactionService.begin();
try {
//保存数据
SaveData(p,organizationId,subLog);
//transactionService.commit(transactionStatus);
} catch (Exception e) {
logger.error("保存事务回滚:" + p.getSlabNo(), e);
//回滚事务
//transactionService.rollback(transactionStatus);
}
}
} catch (Exception e) {
logger.error("板坯报错:" + p.getSlabNo(), e);
}
logger.info("*************板坯结束{}************* ", p.getSlabNo());
logger.info("");
}
);
logger.info("*****处理结束*****");
logger.info("");
return JsonData.buildSuccess();
}
// long finalSubMode = subMode;
//
// SubParams subParams = new SubParams();
//
// subParams.setSlabNo(strSlab);
//
//// //测试阶段需要指定板坯号
//// if (strSlab==null || strSlab=="")
//// {
//// return null;
//// }
//
// //获取所有数据
// GetDataInfo(subParams);
//
// //数据预处理
// SetPreData();
//
// logger.info("***初次分组数量*** " + gltGrpOrderFir.size());
//
// //被使用的订单数据实例化
// plistOrdHis = new ArrayList<>();
//// int intSlabCount = 0;
// // 使用 AtomicInteger 替代 int 类型
// AtomicInteger intSlabCount = new AtomicInteger(0);
// //循环板坯
// plistSlab.forEach(p -> {
//
// PmSubLog subLog = new PmSubLog();
// subLog.setSlabNo(p.getSlabNo());
// subLog.setSubMode(finalSubMode);
// subLog.setSubRslt("成功");
// subLog.setTenantId(organizationId);
//
// String subLogStr = "";
// // 获取当前计数值
// int intSlabCountAdd = intSlabCount.getAndIncrement();
//
// logger.info("*************{}--板坯开始{}************* ",intSlabCountAdd, p.getSlabNo());
//
// logger.info("***板坯信息:{} 厚宽长:{}*{}*{} 钢种:{} ", p.getSlabNo(), p.getSlabActThk(), p.getSlabActWid(), p.getSlabActLen(), p.getStNo());
// //执行日志保存
// subLogStr = "板坯信息 厚宽长:" + p.getSlabActThk() + "*" + p.getSlabActWid() + "*" + p.getSlabActLen();
//
// // 判断板坯的长度是否在plistpmAutoSubSettingDO配置的范围内
// if (p.getSlabActLen().compareTo(plistpmAutoSubSettingDO.get(0).getMatLenMin()) < 0 && p.getSlabActLen().compareTo(plistpmAutoSubSettingDO.get(0).getMatLenMax()) > 0) {
// logger.info("***板坯信息被排除:{} 长度不在范围内 ", p.getSlabNo());
// return;
// }
//
// // 判断板坯的宽度是否在plistpmAutoSubSettingDO配置的范围内
// if (p.getSlabActWid().compareTo(plistpmAutoSubSettingDO.get(0).getMatWidthMin()) < 0 && p.getSlabActWid().compareTo(plistpmAutoSubSettingDO.get(0).getMatWidthMax()) > 0) {
// logger.info("***板坯信息被排除:{} 宽度不在范围内 ", p.getSlabNo());
// return;
// }
//
// // 判断板坯的厚度是否在plistpmAutoSubSettingDO配置的范围内
// if (p.getSlabActThk().compareTo(plistpmAutoSubSettingDO.get(0).getMatThickMin()) < 0 && p.getSlabActThk().compareTo(plistpmAutoSubSettingDO.get(0).getMatThickMax()) > 0) {
// logger.info("***板坯信息被排除:{} 厚度不在范围内 ", p.getSlabNo());
// return;
// }
//
// //判断plistpmIrsubableSlabDO是否包含P.SlabNO范围内
// if (plistpmIrsubableSlabDO.stream().anyMatch(x -> x.getSlabNo().equals(p.getSlabNo()))) {
// logger.info("***板坯信息被排除:{} 不可组板 ", p.getSlabNo());
// return;
// }
//
// //判断plistpmRetainStDO是否包含P的钢种判断这个板坯的钢种是否可组板
// if (plistpmRetainStDO.stream().anyMatch(x -> x.getStNo().equals(p.getStNo()))) {
// logger.info("***板坯信息被排除:{} 不可组板 ", p.getSlabNo());
// return;
// }
//
// try {
//
// gltGCalGrp = new ArrayList<>();
//
// gltGCal2Grp = new ArrayList<>();
//
// //低倍化学成分验证
// chkChmAndLowApi(organizationId,p);
//
// //二次分组
// SetGrpDataBySlab(p);
//
// logger.info("***一次次分组1数量*** " + gltGCalGrp.size());
//
// //数据小的情况,计算拼板。数据量大不计算
// if (gltGCalGrp.size()<=100)
// {
// try {
// SetGrpConBinDataBySlab(p);
// } catch (Exception e) {
//
// }
// }
////
//// logger.info("***二次分组1数量*** " + gltGCalGrp.size());
//
// //执行日志保存
// subLogStr += "-----二次分组1数量" + gltGCalGrp.size();
//
// logger.info("***二次分组2数量*** " + gltGCal2Grp.size());
//
// //执行日志保存
// subLogStr += "-----二次分组2数量" + gltGCal2Grp.size();
//
// gltGCalGrp.addAll(gltGCal2Grp);
//
// //分组设置ID
// for (int i = 0; i < gltGCalGrp.size(); i++) {
//
// gltGCalGrp.get(i).setIDValue(i + 1);
//
// }
//
// gltGGrpCalRslt = new ArrayList<>();
//
// gltSelGGrpCalRslt = new ArrayList<>();
//
// plistpmSubHisDO= new ArrayList<>();
//
// plistpmSubOrdDO = new ArrayList<>();
//
// pmPdSlabDOList = new ArrayList<>();
//
// pmPdPlateCutDOList = new ArrayList<>();
//
// pmPdBlockPosDOList = new ArrayList<>();
//
// pmPdContSumDOList = new ArrayList<>();
//
// pmSmallPltPosDOList = new ArrayList<>();
//
// pmCmdSlabDOList = new ArrayList<>();
//
// pmCmdLargePltDOList = new ArrayList<>();
//
// pmCmdContDOList = new ArrayList<>();
//
// pmCmdSmallPltDOList = new ArrayList<>();
//
// if (gltGCalGrp.size() > 0) {
//
// //板坯长度和宽度调换
// if (p.getSlabActLen().compareTo(p.getSlabActWid()) <= 0) {
// // 当 p.getSlabActLen() 小于或等于 p.getSlabActWid() 时执行的代码
// p.setRemLen(p.getSlabActWid());
// p.setRemWid(p.getSlabActLen());
// } else {
// p.setRemLen(p.getSlabActLen());
// p.setRemWid(p.getSlabActWid());
// }
//
// SetGroupCalRslt(p);
//
// logger.info("所有结果数据板坯号:{};数量:{}", p.getSlabNo(), gltGGrpCalRslt.size());
// logger.info("选择结果数据板坯号:{};数量:{}", p.getSlabNo(), gltSelGGrpCalRslt.size());
// //执行日志保存
// subLogStr += "-----结果数据数量1" + gltGGrpCalRslt.size() + "-----结果数据数量2" + gltSelGGrpCalRslt.size();
// }
// subLog.setSubLog(subLogStr);
// if (gltSelGGrpCalRslt.size() > 0) {
// now = new Date();
// //存储数据,组板结果
// SaveHisData(p);
// //数据整理
// SetSaveDate(p,organizationId);
// //开启事务
// //TransactionStatus transactionStatus = transactionService.begin();
// try {
// //保存数据
// SaveData(p,organizationId,subLog);
// //transactionService.commit(transactionStatus);
// } catch (Exception e) {
// logger.error("保存事务回滚:" + p.getSlabNo(), e);
// //回滚事务
// //transactionService.rollback(transactionStatus);
// }
// }
//
// } catch (Exception e) {
// logger.error("板坯报错:" + p.getSlabNo(), e);
// }
// logger.info("*************板坯结束{}************* ", p.getSlabNo());
// logger.info("");
// }
//
// );
// logger.info("*****处理结束*****");
// logger.info("");
//
// return JsonData.buildSuccess();
// }
public void SaveHisData(SlabInfoDO SInfo) {
String strMaxSeq = subService.GetMaxSeq(SInfo.getPono());
@ -578,13 +562,13 @@ public class SubController {
//获取虚拟板坯号
plistpmSubHisDO.get(i).setVirtualSlabNo(virtualSlabNo);
// subService.InsertPmSubHisDO(plistpmSubHisDO.get(i));
// InsertPmSubHisDO(plistpmSubHisDO.get(i));
//删选plistpmSubOrdDO中虚拟板坯号等于strGuid的信息
plistpmSubOrdDO.stream()
.filter(f -> f.getRelKey().equals(strGuid))
.collect(Collectors.toList()).forEach(m -> {
m.setVirtualSlabNo(virtualSlabNo);
// subService.InsertPmSubOrdDO(m);
// InsertPmSubOrdDO(m);
});
gltSelGGrpCalRslt.stream()
.filter(f -> f.getRelKey().equals(strGuid))
@ -606,13 +590,13 @@ public class SubController {
// //获取虚拟板坯号
// e.setVirtualSlabNo(virtualSlabNo);
//
// subService.InsertPmSubHisDO(e);
// InsertPmSubHisDO(e);
// //删选plistpmSubOrdDO中虚拟板坯号等于strGuid的信息
// plistpmSubOrdDO.stream()
// .filter(f -> !f.getRelKey().equals(strGuid))
// .collect(Collectors.toList()).forEach(m -> {
// m.setVirtualSlabNo(virtualSlabNo);
// subService.InsertPmSubOrdDO(m);
// InsertPmSubOrdDO(m);
// });
// gltSelGGrpCalRslt.stream()
// .filter(f -> !f.getRelKey().equals(strGuid))
@ -677,7 +661,7 @@ public class SubController {
//5生产合同产品属性表
tasks.add(() -> {
// plistPmProContProdAttrDO = subService.getPmProCountProdAttr();
// plistPmProContProdAttrDO = getPmProCountProdAttr();
Thread.sleep(1000); // 休眠1秒钟
//logger.info("******5生产合同产品属性表数据获取完毕*******");
return null;

@ -3,13 +3,17 @@ package com.xisc.pm.app.service;
import com.xisc.pm.api.dto.PmPdRecDTO;
import com.xisc.pm.api.dto.model.*;
import com.xisc.pm.domain.entity.*;
import com.xisc.pm.domain.vo.util.JsonData;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.List;
public interface SubService {
JsonData SubData(PmSubHis pmSubHis, Long organizationId);
//获取板坯信息
List<SlabInfoDO> getSlabInfo(SubParams subParams);

Loading…
Cancel
Save