|
@@ -324,13 +324,13 @@ public class ApsServiceImpl implements ApsService {
|
|
|
// CPU核数
|
|
|
String cores = Runtime.getRuntime().availableProcessors() + "";
|
|
|
SolverFactory<ApsSolution> solverFactory1 = SolverFactory.create(new SolverConfig()
|
|
|
- .withEnvironmentMode(EnvironmentMode.FULL_ASSERT)
|
|
|
- .withSolutionClass(ApsSolution.class)
|
|
|
- .withEntityClasses(ProductionProcesses.class)
|
|
|
- .withConstraintProviderClass(ApsConstraintProvider.class)
|
|
|
+ .withEnvironmentMode(EnvironmentMode.REPRODUCIBLE)
|
|
|
+ .withSolutionClass(ApsSolution.class)
|
|
|
+ .withEntityClasses(ProductionProcesses.class)
|
|
|
+ .withConstraintProviderClass(ApsConstraintProvider.class)
|
|
|
// .withTerminationSpentLimit(Duration.ofSeconds(runPlanSeconds1))
|
|
|
- .withTerminationConfig(new TerminationConfig().withUnimprovedSecondsSpentLimit(60L))
|
|
|
- .withMoveThreadCount(cores)
|
|
|
+ .withTerminationConfig(new TerminationConfig().withUnimprovedSecondsSpentLimit(60L))
|
|
|
+ .withMoveThreadCount(cores)
|
|
|
);
|
|
|
Solver<ApsSolution> solver1 = solverFactory1.buildSolver();
|
|
|
// 按照宽度排序
|
|
@@ -346,32 +346,41 @@ public class ApsServiceImpl implements ApsService {
|
|
|
// 宽度
|
|
|
BigDecimal prowidth1 = v1.getVolumeWidth();
|
|
|
BigDecimal prowidth2 = v2.getVolumeWidth();
|
|
|
- if(prowidth1.compareTo(prowidth2) == 0){
|
|
|
- // 合金
|
|
|
- if(alloy1.compareTo(alloy2) == 0){
|
|
|
- // 合金状态
|
|
|
- if(alloystatus1 == null || alloystatus2 == null || alloystatus1.compareTo(alloystatus2) == 0){
|
|
|
- if(v1.getApsOverallConfig().getStartTime().compareTo(v2.getApsOverallConfig().getStartTime()) == 0){
|
|
|
- a = v2.getVolumeWidth().compareTo(v1.getVolumeWidth());
|
|
|
- }else{
|
|
|
- a = v2.getApsOverallConfig().getStartTime().compareTo(v1.getApsOverallConfig().getStartTime());
|
|
|
- }
|
|
|
+// if(prowidth1.compareTo(prowidth2) == 0){
|
|
|
+ // 合金
|
|
|
+ if(alloy1.compareTo(alloy2) == 0){
|
|
|
+ // 合金状态
|
|
|
+ if(alloystatus1 == null || alloystatus2 == null || alloystatus1.compareTo(alloystatus2) == 0){
|
|
|
+ if(v1.getApsOverallConfig().getStartTime().compareTo(v2.getApsOverallConfig().getStartTime()) == 0){
|
|
|
+ a = v2.getVolumeWidth().compareTo(v1.getVolumeWidth());
|
|
|
+// a = 0;
|
|
|
}else{
|
|
|
- a = alloystatus1.compareTo(alloystatus2);
|
|
|
+ a = v2.getApsOverallConfig().getStartTime().compareTo(v1.getApsOverallConfig().getStartTime());
|
|
|
}
|
|
|
}else{
|
|
|
- a = alloy1.compareTo(alloy2);
|
|
|
+ a = alloystatus1.compareTo(alloystatus2);
|
|
|
}
|
|
|
}else{
|
|
|
- a = prowidth2.compareTo(prowidth1);
|
|
|
+ a = alloy1.compareTo(alloy2);
|
|
|
}
|
|
|
+ /*}else{
|
|
|
+ a = prowidth2.compareTo(prowidth1);
|
|
|
+ }*/
|
|
|
return a;
|
|
|
});
|
|
|
ApsSolution solvedBalance1 = solver1.solve(apsSolutionTh);
|
|
|
/*for (ProductionProcesses productionProcesses : solvedBalance1.getProcessesList()) {
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- LocalDateTime parsedDateTime = LocalDateTime.parse("2025-01-02 07:00:00", formatter);
|
|
|
- productionProcesses.setStartTime(parsedDateTime);
|
|
|
+ if(productionProcesses.getId().equals("b80ec7b7fceb45658ba3db980ab25694")){
|
|
|
+ productionProcesses.setDelay(1);
|
|
|
+ LocalDateTime parsedDateTime = LocalDateTime.parse("2025-03-01 11:00:00", formatter);
|
|
|
+ productionProcesses.setStartTime(parsedDateTime);
|
|
|
+ for (Equipment optionalProviderEquipment : productionProcesses.getOptionalProviderEquipments()) {
|
|
|
+ if(optionalProviderEquipment.getId().equals("ea772303eebe4feda4a83d5c9b31887b")){
|
|
|
+ productionProcesses.setEquipment(optionalProviderEquipment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}*/
|
|
|
log.info("**************退火排程评分分析***************");
|
|
|
SolutionManager<ApsSolution, HardSoftScore> scoreManager1 = SolutionManager.create(solverFactory1);
|
|
@@ -492,98 +501,132 @@ public class ApsServiceImpl implements ApsService {
|
|
|
ProductionProcesses mainTh = thOrdersMerge(hbThPros, otherThproces, allProMap,apsSolution);
|
|
|
apsSolution.getProcessesList().sort(Comparator.comparing(ProductionProcesses::getOrderMark));
|
|
|
// 退火后一道工序如果是精整类别的则合并
|
|
|
- List<ProductionProcesses> lastProMerge = new ArrayList<>();
|
|
|
- if(mainTh.getNextProcesses() != null && mainTh.getNextProcesses().size()>0){
|
|
|
- for (ProductionProcesses productionProcesses : mainTh.getNextProcesses()) {
|
|
|
- if(productionProcesses.getProcessCategory() != null && "40".equals(productionProcesses.getProcessCategory())
|
|
|
- && (productionProcesses.getNextProcesses() == null || productionProcesses.getNextProcesses().size() == 0)
|
|
|
- && !productionProcesses.getIfLock()
|
|
|
- ){
|
|
|
- lastProMerge.add(productionProcesses);
|
|
|
- }
|
|
|
- }
|
|
|
+ jzMerge(mainTh,apsSolution);
|
|
|
+ // 退火前一道工序合并
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 退火后一道工序如果是精整类别的则合并
|
|
|
+ * @param mainTh
|
|
|
+ * @param apsSolution
|
|
|
+ */
|
|
|
+ private void jzMerge(ProductionProcesses mainTh,ApsSolution apsSolution){
|
|
|
+ List<ProductionProcesses> lastProMerge = new ArrayList<>();
|
|
|
+ if(mainTh.getNextProcesses() != null && mainTh.getNextProcesses().size()>0){
|
|
|
+ for (ProductionProcesses productionProcesses : mainTh.getNextProcesses()) {
|
|
|
+ if(productionProcesses.getProcessCategory() != null && "40".equals(productionProcesses.getProcessCategory())
|
|
|
+ && (productionProcesses.getNextProcesses() == null || productionProcesses.getNextProcesses().size() == 0)
|
|
|
+ && !productionProcesses.getIfLock()
|
|
|
+ ){
|
|
|
+ lastProMerge.add(productionProcesses);
|
|
|
}
|
|
|
- if(lastProMerge.size()>0){
|
|
|
- Map<String, List<ProductionProcesses>> orderProcess = lastProMerge.stream().collect(Collectors.groupingBy(ProductionProcesses::getProcessType));
|
|
|
- orderProcess.forEach((k1,v1)->{
|
|
|
- if(v1.size()>1){
|
|
|
- List<String> sameEqs = new ArrayList<>();
|
|
|
- boolean issameeq = true;
|
|
|
- for (ProductionProcesses productionProcesses : v1) {
|
|
|
- if(sameEqs.size() == 0){
|
|
|
- sameEqs.addAll(productionProcesses.getOptionalEquipments());
|
|
|
- }else{
|
|
|
- List<String> a = new ArrayList<>();
|
|
|
- for (String sameEq : sameEqs) {
|
|
|
- for (String optionalEquipment : productionProcesses.getOptionalEquipments()) {
|
|
|
- if(sameEq.equals(optionalEquipment)){
|
|
|
- a.add(sameEq);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(a.size()>0){
|
|
|
- sameEqs = a;
|
|
|
- }else{
|
|
|
- issameeq = false;
|
|
|
- break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(lastProMerge.size()>0){
|
|
|
+ Map<String, List<ProductionProcesses>> orderProcess = lastProMerge.stream().collect(Collectors.groupingBy(ProductionProcesses::getProcessType));
|
|
|
+ orderProcess.forEach((k1,v1)->{
|
|
|
+ if(v1.size()>1){
|
|
|
+ List<String> sameEqs = new ArrayList<>();
|
|
|
+ boolean issameeq = true;
|
|
|
+ for (ProductionProcesses productionProcesses : v1) {
|
|
|
+ if(sameEqs.size() == 0){
|
|
|
+ sameEqs.addAll(productionProcesses.getOptionalEquipments());
|
|
|
+ }else{
|
|
|
+ List<String> a = new ArrayList<>();
|
|
|
+ for (String sameEq : sameEqs) {
|
|
|
+ for (String optionalEquipment : productionProcesses.getOptionalEquipments()) {
|
|
|
+ if(sameEq.equals(optionalEquipment)){
|
|
|
+ a.add(sameEq);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(issameeq && sameEqs.size()>0){
|
|
|
- ProductionProcesses mergePro = v1.get(0);
|
|
|
- List<String> mergeProOrders = new ArrayList<>();
|
|
|
- if(mergePro.getMergeProOrders() != null && mergePro.getMergeProOrders().size()>0){
|
|
|
- mergeProOrders.addAll(mergePro.getMergeProOrders());
|
|
|
+ if(a.size()>0){
|
|
|
+ sameEqs = a;
|
|
|
+ }else{
|
|
|
+ issameeq = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(issameeq && sameEqs.size()>0){
|
|
|
+ ProductionProcesses mergePro = v1.get(0);
|
|
|
+ List<String> mergeProOrders = new ArrayList<>();
|
|
|
+ if(mergePro.getMergeProOrders() != null && mergePro.getMergeProOrders().size()>0){
|
|
|
+ mergeProOrders.addAll(mergePro.getMergeProOrders());
|
|
|
+ }else{
|
|
|
+ mergeProOrders.add(mergePro.getId());
|
|
|
+ }
|
|
|
+ mergePro.setMergeProOrders(mergeProOrders);
|
|
|
+ mergePro.setOptionalEquipments(sameEqs);
|
|
|
+ for (int i = 0; i < v1.size(); i++) {
|
|
|
+ if(i>0){
|
|
|
+ if(v1.get(i).getMergeProOrders() != null && v1.get(i).getMergeProOrders().size()>0){
|
|
|
+ mergePro.getMergeProOrders().addAll(v1.get(i).getMergeProOrders());
|
|
|
}else{
|
|
|
- mergeProOrders.add(mergePro.getId());
|
|
|
+ mergePro.getMergeProOrders().add(v1.get(i).getId());
|
|
|
}
|
|
|
- mergePro.setMergeProOrders(mergeProOrders);
|
|
|
- mergePro.setOptionalEquipments(sameEqs);
|
|
|
- for (int i = 0; i < v1.size(); i++) {
|
|
|
- if(i>0){
|
|
|
- if(v1.get(i).getMergeProOrders() != null && v1.get(i).getMergeProOrders().size()>0){
|
|
|
- mergePro.getMergeProOrders().addAll(v1.get(i).getMergeProOrders());
|
|
|
- }else{
|
|
|
- mergePro.getMergeProOrders().add(v1.get(i).getId());
|
|
|
- }
|
|
|
- // 设置待合并退火的主ID
|
|
|
- v1.get(i).setMergeThMainId(v1.get(0).getId());
|
|
|
- mergePro.setOpeProducePcNum(mergePro.getOpeProducePcNum()+v1.get(i).getOpeProducePcNum());
|
|
|
- mergePro.setProduceTime(mergePro.getProduceTime()+v1.get(i).getProduceTime());
|
|
|
- if(mergePro.getOrderMark()<v1.get(i).getOrderMark()){
|
|
|
- mergePro.setOrderMark(v1.get(i).getOrderMark());
|
|
|
- }
|
|
|
- // 前后道工序关联关系设置
|
|
|
- List<String> preids = new ArrayList<>();
|
|
|
- preids.add(mainTh.getId());
|
|
|
- List<ProductionProcesses> prepros = new ArrayList<>();
|
|
|
- prepros.add(mainTh);
|
|
|
- mergePro.setPreviousProcessesIds(preids);
|
|
|
- mergePro.setPreviousProcesses(prepros);
|
|
|
- String vid1 = v1.get(i).getId();
|
|
|
- if(mainTh.getNextProcessesIds().contains(v1.get(i).getId())){
|
|
|
- mainTh.getNextProcessesIds().remove(v1.get(i).getId());
|
|
|
- List<ProductionProcesses> vidpros1 = mainTh.getNextProcesses().stream().filter(v2 -> !v2.getId().equals(vid1)).collect(Collectors.toList());
|
|
|
- mainTh.setNextProcesses(vidpros1);
|
|
|
- }
|
|
|
- // 小卷退火卷数合并
|
|
|
- if(v1.get(i).getProcessType().equals("小卷成退")){
|
|
|
- v1.get(0).setMinThPcNum(v1.get(0).getMinThPcNum()+v1.get(i).getMinThPcNum());
|
|
|
- }
|
|
|
-
|
|
|
- List<ProductionProcesses> collect = apsSolution.getProcessesList().stream().filter(va -> !va.getId().equals(vid1)).collect(Collectors.toList());
|
|
|
- apsSolution.setProcessesList(collect);
|
|
|
- }
|
|
|
+ // 设置待合并退火的主ID
|
|
|
+ v1.get(i).setMergeThMainId(v1.get(0).getId());
|
|
|
+ mergePro.setOpeProducePcNum(mergePro.getOpeProducePcNum()+v1.get(i).getOpeProducePcNum());
|
|
|
+ mergePro.setProduceTime(mergePro.getProduceTime()+v1.get(i).getProduceTime());
|
|
|
+ if(mergePro.getOrderMark()<v1.get(i).getOrderMark()){
|
|
|
+ mergePro.setOrderMark(v1.get(i).getOrderMark());
|
|
|
+ }
|
|
|
+ // 前后道工序关联关系设置
|
|
|
+ List<String> preids = new ArrayList<>();
|
|
|
+ preids.add(mainTh.getId());
|
|
|
+ List<ProductionProcesses> prepros = new ArrayList<>();
|
|
|
+ prepros.add(mainTh);
|
|
|
+ mergePro.setPreviousProcessesIds(preids);
|
|
|
+ mergePro.setPreviousProcesses(prepros);
|
|
|
+ String vid1 = v1.get(i).getId();
|
|
|
+ if(mainTh.getNextProcessesIds().contains(v1.get(i).getId())){
|
|
|
+ mainTh.getNextProcessesIds().remove(v1.get(i).getId());
|
|
|
+ List<ProductionProcesses> vidpros1 = mainTh.getNextProcesses().stream().filter(v2 -> !v2.getId().equals(vid1)).collect(Collectors.toList());
|
|
|
+ mainTh.setNextProcesses(vidpros1);
|
|
|
+ }
|
|
|
+ // 小卷退火卷数合并
|
|
|
+ if(v1.get(i).getProcessType().equals("小卷成退")){
|
|
|
+ v1.get(0).setMinThPcNum(v1.get(0).getMinThPcNum()+v1.get(i).getMinThPcNum());
|
|
|
}
|
|
|
+
|
|
|
+ List<ProductionProcesses> collect = apsSolution.getProcessesList().stream().filter(va -> !va.getId().equals(vid1)).collect(Collectors.toList());
|
|
|
+ apsSolution.setProcessesList(collect);
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
- // 退火前一道工序合并
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 小卷成退分组按宽度从大到小手动合并
|
|
|
+ * @param otherThproces
|
|
|
+ * @param allProMap
|
|
|
+ * @param apsSolution
|
|
|
+ */
|
|
|
+ /*private void xjctOrdersMerge(List<ProductionProcesses> otherThproces,Map<String,ProductionProcesses> allProMap,ApsSolution apsSolution){
|
|
|
+ // 小卷成退作业集合
|
|
|
+ List<ProductionProcesses> processesList = apsSolution.getProcessesList().stream().filter(v->"小卷成退".equals(v.getProcessType())).collect(Collectors.toList());
|
|
|
+ if(processesList != null && processesList.size()>0){
|
|
|
+ // 小卷成退分组
|
|
|
+ Map<String, List<ProductionProcesses>> ppss = processesList.stream().filter(v->StrUtil.isNotBlank(v.getGroupname()))
|
|
|
+ .collect(Collectors.groupingBy(ProductionProcesses::getGroupname));
|
|
|
+ if(ppss != null && ppss.size()>0){
|
|
|
+ // 每一组待合并的工序
|
|
|
+ for(Map.Entry<String, List<ProductionProcesses>> entry : ppss.entrySet()){
|
|
|
+ List<ProductionProcesses> processess = entry.getValue();
|
|
|
+ // 每一组按照宽度从大到小合并
|
|
|
+ Collections.sort(processess, (pro1, pro2) -> {return pro2.getVolumeWidth().compareTo(pro1.getVolumeWidth());});
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
|
|
|
private ProductionProcesses thOrdersMerge(List<ProductionProcesses> thps,List<ProductionProcesses> otherThproces
|
|
|
,Map<String,ProductionProcesses> allProMap,ApsSolution apsSolution){
|
|
@@ -591,6 +634,7 @@ public class ApsServiceImpl implements ApsService {
|
|
|
if(thps != null && thps.size()>0){
|
|
|
// 根据排程时间从大到小排序
|
|
|
Collections.sort(thps,(v1,v2)->v2.getProduceTime().compareTo(v1.getProduceTime()));
|
|
|
+ mergePro = thps.get(0);
|
|
|
for (int i = 0; i < thps.size(); i++) {
|
|
|
if(i>0){
|
|
|
// 设置待合并退火的主ID
|
|
@@ -603,6 +647,9 @@ public class ApsServiceImpl implements ApsService {
|
|
|
// 合并后关联关系重置
|
|
|
if(!prepro.getNextProcessesIds().contains(thps.get(0).getId())){
|
|
|
int i1 = prepro.getNextProcessesIds().indexOf(thps.get(i).getId());
|
|
|
+ if(i1 == -1){
|
|
|
+ int aa = 0;
|
|
|
+ }
|
|
|
prepro.getNextProcessesIds().set(i1,thps.get(0).getId());
|
|
|
}
|
|
|
List<String> list = new ArrayList<>();
|
|
@@ -653,6 +700,9 @@ public class ApsServiceImpl implements ApsService {
|
|
|
nextpro.setPreviousProcesses(nextprepros);
|
|
|
|
|
|
// 设置合并退火作业下一道工序
|
|
|
+ if(thps.get(0).getNextProcessesIds() == null){
|
|
|
+ thps.get(0).setNextProcessesIds(new ArrayList<>());
|
|
|
+ }
|
|
|
thps.get(0).getNextProcessesIds().add(nextProcessesId);
|
|
|
List<ProductionProcesses> thnexts = new ArrayList<>();
|
|
|
for (String pid : thps.get(0).getNextProcessesIds()) {
|
|
@@ -665,6 +715,7 @@ public class ApsServiceImpl implements ApsService {
|
|
|
if(thps.get(i).getProcessType().equals("小卷成退")){
|
|
|
thps.get(0).setMinThPcNum(thps.get(0).getMinThPcNum()+thps.get(i).getMinThPcNum());
|
|
|
}
|
|
|
+ mergePro.setTotalSinglerollweight(mergePro.getTotalSinglerollweight().add(thps.get(i).getTotalSinglerollweight()));
|
|
|
// 排程排序字段重新设置,取最小的排序字段值
|
|
|
if(thps.get(i).getOrderMark()<thps.get(0).getOrderMark()){
|
|
|
thps.get(0).setOrderMark(thps.get(i).getOrderMark());
|
|
@@ -675,9 +726,7 @@ public class ApsServiceImpl implements ApsService {
|
|
|
}
|
|
|
}
|
|
|
// 取第一个作业作为合并作业
|
|
|
- mergePro = thps.get(0);
|
|
|
mergePro.setVolumeWidth(mergePro.getVolumeWidth().multiply(new BigDecimal(thps.size())));
|
|
|
- mergePro.setSinglerollweight(mergePro.getSinglerollweight().multiply(new BigDecimal(thps.size())));
|
|
|
mergePro.setOpeProducePcNum(thps.size());
|
|
|
|
|
|
// 重新设置前道工序的排序字段值
|
|
@@ -1013,10 +1062,17 @@ public class ApsServiceImpl implements ApsService {
|
|
|
// 按订单分组
|
|
|
Map<String, List<ProductionProcesses>> orderProcess = processes.stream().collect(Collectors.groupingBy(ProductionProcesses::getOrderId));
|
|
|
orderProcess.forEach((orderId,orderpss)->{
|
|
|
+ if("6639310eb2204f77ac9d36a2f289039c".equals(orderId)){
|
|
|
+ int a = 1;
|
|
|
+ }
|
|
|
// 退火作业集合
|
|
|
Map<String,List<ProductionProcesses>> thproMap = new HashMap<>();
|
|
|
for (ProductionProcesses process : orderpss) {
|
|
|
if("成退".equals(process.getProcessType()) || "中退".equals(process.getProcessType()) || "小卷成退".equals(process.getProcessType())){
|
|
|
+ // 锁定的不参与合并
|
|
|
+ /*if(process.getIfLock()){
|
|
|
+ mergeprocesses.add(process);
|
|
|
+ }else{*/
|
|
|
String bsproid = process.getBsProcessesId().get(0);
|
|
|
List<ProductionProcesses> bsprocess = thproMap.get(bsproid);
|
|
|
if(bsprocess == null){
|
|
@@ -1024,6 +1080,7 @@ public class ApsServiceImpl implements ApsService {
|
|
|
}
|
|
|
bsprocess.add(process);
|
|
|
thproMap.put(bsproid,bsprocess);
|
|
|
+// }
|
|
|
}else{
|
|
|
mergeprocesses.add(process);
|
|
|
|
|
@@ -1040,6 +1097,7 @@ public class ApsServiceImpl implements ApsService {
|
|
|
// 退火合并
|
|
|
if(thproMap != null && thproMap.size()>0){
|
|
|
thproMap.forEach((k,v)->{
|
|
|
+ // 未锁定的退火合并
|
|
|
if(v.size()>1){
|
|
|
// 作业卷数大于1,合并退火
|
|
|
List<Equipment> equipments = equipmentList.stream().filter(eq -> eq.getId().equals(v.get(0).getOptionalEquipments().get(0))).collect(Collectors.toList());
|
|
@@ -1053,15 +1111,16 @@ public class ApsServiceImpl implements ApsService {
|
|
|
if(b<a){
|
|
|
a = b;
|
|
|
}
|
|
|
- }
|
|
|
- // 最大装炉卷数
|
|
|
- Integer maxheatroll = v.get(0).getProduceOrder().get(0).getMaxheatroll();
|
|
|
- if(maxheatroll != null && maxheatroll < a){
|
|
|
- a = maxheatroll;
|
|
|
- }
|
|
|
- if(equipment.getEquipmentParameter() != null && equipment.getEquipmentParameter().getMaxfurance() != null && equipment.getEquipmentParameter().getMaxfurance()>0){
|
|
|
- if(equipment.getEquipmentParameter().getMaxfurance() < a){
|
|
|
- a = equipment.getEquipmentParameter().getMaxfurance();
|
|
|
+
|
|
|
+ // 最大装炉卷数
|
|
|
+ Integer maxheatroll = v.get(0).getProduceOrder().get(0).getMaxheatroll();
|
|
|
+ if(maxheatroll != null && maxheatroll < a){
|
|
|
+ a = maxheatroll;
|
|
|
+ }
|
|
|
+ if(equipment.getEquipmentParameter() != null && equipment.getEquipmentParameter().getMaxfurance() != null && equipment.getEquipmentParameter().getMaxfurance()>0){
|
|
|
+ if(equipment.getEquipmentParameter().getMaxfurance() < a){
|
|
|
+ a = equipment.getEquipmentParameter().getMaxfurance();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1082,12 +1141,15 @@ public class ApsServiceImpl implements ApsService {
|
|
|
}
|
|
|
|
|
|
List<List<ProductionProcesses>> chunks = new ArrayList<>();
|
|
|
- if(v.get(0).getIfLock()){
|
|
|
- Collections.sort(v,(p1,p2)->{
|
|
|
+
|
|
|
+ List<ProductionProcesses> lockpps = v.stream().filter(m -> m.getIfLock()).collect(Collectors.toList());
|
|
|
+ List<ProductionProcesses> notlockpps = v.stream().filter(m -> !m.getIfLock()).collect(Collectors.toList());
|
|
|
+ if(lockpps != null && lockpps.size()>0){
|
|
|
+ Collections.sort(lockpps,(p1,p2)->{
|
|
|
return p1.getStartTime().compareTo(p2.getStartTime());
|
|
|
});
|
|
|
Map<String, List<ProductionProcesses>> map = new TreeMap<>();
|
|
|
- for (ProductionProcesses productionProcesses : v) {
|
|
|
+ for (ProductionProcesses productionProcesses : lockpps) {
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
String startStr = productionProcesses.getStartTime().format(formatter);
|
|
|
if(map.containsKey(startStr)){
|
|
@@ -1103,10 +1165,11 @@ public class ApsServiceImpl implements ApsService {
|
|
|
chunks.add(entry.getValue());
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
- int listSize = v.size();
|
|
|
+ }
|
|
|
+ if(notlockpps != null && notlockpps.size()>0) {
|
|
|
+ int listSize = notlockpps.size();
|
|
|
for (int i = 0; i < listSize; i += a) {
|
|
|
- chunks.add(v.subList(i, Math.min(i + a, listSize)));
|
|
|
+ chunks.add(notlockpps.subList(i, Math.min(i + a, listSize)));
|
|
|
}
|
|
|
}
|
|
|
// 合并退火作业
|
|
@@ -1320,6 +1383,9 @@ public class ApsServiceImpl implements ApsService {
|
|
|
// 根据订单分组
|
|
|
Map<String, List<ProductionProcesses>> orderProcess = mergeprocesses.stream().collect(Collectors.groupingBy(ProductionProcesses::getOrderId));
|
|
|
orderProcess.forEach((k,processes)->{
|
|
|
+ if("6639310eb2204f77ac9d36a2f289039c".equals(k)){
|
|
|
+ int a = 1;
|
|
|
+ }
|
|
|
// 退火工序过滤
|
|
|
List<ProductionProcesses> thpros = new ArrayList<>();
|
|
|
// 所有单卷作业集合
|
|
@@ -1339,7 +1405,17 @@ public class ApsServiceImpl implements ApsService {
|
|
|
} else if (mergeprocess.getProcessType().equals("铸轧")) {
|
|
|
othermergeprocesses.add(mergeprocess);
|
|
|
} else {
|
|
|
- if(("是".equals(mergeprocess.getIssubsection()) && mergeprocess.getNextProcesses() != null && mergeprocess.getNextProcesses().size()>0) || mergeprocess.getIfLock()){
|
|
|
+ boolean hasnotxjct = false;
|
|
|
+ if(mergeprocess.getNextProcesses() != null && mergeprocess.getNextProcesses().size()>0){
|
|
|
+ for (ProductionProcesses nextProcess : mergeprocess.getNextProcesses()) {
|
|
|
+ if(!nextProcess.getProcessType().equals("小卷成退")){
|
|
|
+ hasnotxjct = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(("是".equals(mergeprocess.getIssubsection()) && mergeprocess.getNextProcesses() != null && mergeprocess.getNextProcesses().size()>0
|
|
|
+ && hasnotxjct) || mergeprocess.getIfLock()){
|
|
|
othermergeprocesses.add(mergeprocess);
|
|
|
}else {
|
|
|
/*if(mergeprocess.getPreviousProcessesIds() == null || mergeprocess.getPreviousProcessesIds().size() == 0){
|
|
@@ -1358,7 +1434,9 @@ public class ApsServiceImpl implements ApsService {
|
|
|
}
|
|
|
// 两次退火卷数不一样、退火后道工序需要特殊处理
|
|
|
List<ProductionProcesses> thNexts = new ArrayList<>();
|
|
|
-
|
|
|
+ /*if(othermergeprocesses != null && othermergeprocesses.size()>0){
|
|
|
+ hasMerge.addAll(othermergeprocesses.stream().map(ProductionProcesses::getId).collect(Collectors.toList()));
|
|
|
+ }*/
|
|
|
// 根据退火合并作业
|
|
|
if(thpros != null && thpros.size()>0){
|
|
|
for (ProductionProcesses thpro : thpros) {
|
|
@@ -1581,9 +1659,12 @@ public class ApsServiceImpl implements ApsService {
|
|
|
&& !nextProcesses.get(0).getProcessType().equals("中退") && !nextProcesses.get(0).getProcessType().equals("小卷成退")
|
|
|
// && nextProcesses.get(0).getPreviousProcessesIds() != null && nextProcesses.get(0).getPreviousProcessesIds().size()>0
|
|
|
){
|
|
|
+ // 判断是否存在锁定工序
|
|
|
+ List<ProductionProcesses> lockpps = nextProcesses.stream().filter(v -> v.getIfLock()).collect(Collectors.toList());
|
|
|
// 分卷工序
|
|
|
- if(("是".equals(nextProcesses.get(0).getIssubsection()) && nextProcesses.get(0).getNextProcesses() != null && nextProcesses.get(0).getNextProcesses().size()>0)
|
|
|
- || nextProcesses.get(0).getIfLock()){
|
|
|
+ if(("是".equals(nextProcesses.get(0).getIssubsection()) && nextProcesses.get(0).getNextProcesses() != null && nextProcesses.get(0).getNextProcesses().size()>0
|
|
|
+ && !nextProcesses.get(0).getNextProcesses().get(0).getProcessType().equals("小卷成退"))
|
|
|
+ || (lockpps != null && lockpps.size()>0)){
|
|
|
for (ProductionProcesses nextProcess : nextProcesses) {
|
|
|
List<ProductionProcesses> pres = new ArrayList<>();
|
|
|
List<String> preids = new ArrayList<>();
|
|
@@ -1603,6 +1684,15 @@ public class ApsServiceImpl implements ApsService {
|
|
|
hasMerge.addAll(proids);
|
|
|
}
|
|
|
}
|
|
|
+ // 判断合并后待排程的列表是否存在当前作业明细,不存在则新增
|
|
|
+ if(nextProcesses != null && nextProcesses.size()>0){
|
|
|
+ for (ProductionProcesses nextProcess : nextProcesses) {
|
|
|
+ List<ProductionProcesses> pps = mergeprocesses.stream().filter(v -> v.getId().equals(nextProcess.getId())).collect(Collectors.toList());
|
|
|
+ if(pps == null || pps.size() == 0){
|
|
|
+ mergeprocesses.add(nextProcess);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}else{
|
|
|
List<ProductionProcesses> mergePres = new ArrayList<>();
|
|
|
mergePres.addAll(nextProcesses);
|
|
@@ -1684,14 +1774,31 @@ public class ApsServiceImpl implements ApsService {
|
|
|
private void thPreProMerge(ProductionProcesses thps,List<ProductionProcesses> notMergeProces,List<ProductionProcesses> mergeprocesses
|
|
|
,Map<String,List<ProductionProcesses>> bsProceses,List<String> hasMerge,Map<String,ProductionProcesses> allProMap,List<ProductionProcesses> thNexts){
|
|
|
List<ProductionProcesses> previousProcesses = thps.getPreviousProcesses();
|
|
|
+
|
|
|
+ /*List<ProductionProcesses> pretestids = previousProcesses.stream().filter(v -> v.getId().equals("f24555b13a0349938e9fd72814c66199")).collect(Collectors.toList());
|
|
|
+ if(pretestids != null && pretestids.size()>0){
|
|
|
+ int a = 1;
|
|
|
+ }*/
|
|
|
if(previousProcesses != null && previousProcesses.size()>0){
|
|
|
// 铸轧、退火、和第一道工序不合并
|
|
|
if(!previousProcesses.get(0).getProcessType().equals("铸轧") && !previousProcesses.get(0).getProcessType().equals("成退")
|
|
|
&& !previousProcesses.get(0).getProcessType().equals("中退") && !previousProcesses.get(0).getProcessType().equals("小卷成退")
|
|
|
// && previousProcesses.get(0).getPreviousProcessesIds() != null && previousProcesses.get(0).getPreviousProcessesIds().size()>0
|
|
|
){
|
|
|
+ //判断是否存在小卷成退其它的工序
|
|
|
+ boolean hasnotxjct = false;
|
|
|
+ if(previousProcesses.get(0).getNextProcesses() != null && previousProcesses.get(0).getNextProcesses().size()>0){
|
|
|
+ for (ProductionProcesses nextProcess : previousProcesses.get(0).getNextProcesses()) {
|
|
|
+ if(!nextProcess.getProcessType().equals("小卷成退")){
|
|
|
+ hasnotxjct = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 判断是否存在锁定工序
|
|
|
+ List<ProductionProcesses> lockpps = previousProcesses.stream().filter(v -> v.getIfLock()).collect(Collectors.toList());
|
|
|
// 分卷工序
|
|
|
- if("是".equals(previousProcesses.get(0).getIssubsection()) || previousProcesses.get(0).getIfLock()){
|
|
|
+ if(("是".equals(previousProcesses.get(0).getIssubsection()) && hasnotxjct) || (lockpps != null && lockpps.size()>0)){
|
|
|
for (ProductionProcesses preProcess : previousProcesses) {
|
|
|
List<ProductionProcesses> nexts = new ArrayList<>();
|
|
|
if(preProcess.getNextProcesses().size()>1){
|
|
@@ -1719,6 +1826,15 @@ public class ApsServiceImpl implements ApsService {
|
|
|
hasMerge.addAll(proids);
|
|
|
}
|
|
|
}
|
|
|
+ // 判断合并后待排程的列表是否存在当前作业明细,不存在则新增
|
|
|
+ if(previousProcesses != null && previousProcesses.size()>0){
|
|
|
+ for (ProductionProcesses previousProcess : previousProcesses) {
|
|
|
+ List<ProductionProcesses> pps = mergeprocesses.stream().filter(v -> v.getId().equals(previousProcess.getId())).collect(Collectors.toList());
|
|
|
+ if(pps == null || pps.size() == 0){
|
|
|
+ mergeprocesses.add(previousProcess);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}else{
|
|
|
List<ProductionProcesses> mergePres = new ArrayList<>();
|
|
|
mergePres.addAll(previousProcesses);
|
|
@@ -2125,6 +2241,9 @@ public class ApsServiceImpl implements ApsService {
|
|
|
// 已合并处理过作业ID
|
|
|
List<String> hasMid = new ArrayList<>();
|
|
|
for (ProductionProcesses rootPro : rootPros) {
|
|
|
+ if(rootPro.getId().equals("deaf796d6e2b416dbc243201b9ad5795")){
|
|
|
+ int a = 1;
|
|
|
+ }
|
|
|
getLzBzSeries(rootPro,lzbzMerges,null,null,null,hasMid);
|
|
|
}
|
|
|
if(lzbzMerges != null && lzbzMerges.size()>0){
|
|
@@ -2394,7 +2513,7 @@ public class ApsServiceImpl implements ApsService {
|
|
|
for (ProductionProcesses productionProcesses : zzprocesList) {
|
|
|
String cplx = productionProcesses.getProducttype().split("-")[0];
|
|
|
// 客户订单ID+合金+产品类型+宽度 作为合并的key
|
|
|
- String keystr = productionProcesses.getProduceOrder().get(0).getCustomerOrderId()+productionProcesses.getVolumeMetal()+cplx+productionProcesses.getVolumeWidth();
|
|
|
+ String keystr = productionProcesses.getProduceOrder().get(0).getCustomerOrderId()+productionProcesses.getVolumeMetal()+productionProcesses.getProducttype()+cplx+productionProcesses.getVolumeWidth();
|
|
|
if(bsPros.containsKey(keystr)){
|
|
|
bsPros.get(keystr).add(productionProcesses);
|
|
|
}else{
|
|
@@ -2474,13 +2593,13 @@ public class ApsServiceImpl implements ApsService {
|
|
|
// CPU核数
|
|
|
String cores = Runtime.getRuntime().availableProcessors() + "";
|
|
|
SolverFactory<ApsSolution> solverFactory1 = SolverFactory.create(new SolverConfig()
|
|
|
- .withEnvironmentMode(mode)
|
|
|
- .withSolutionClass(ApsSolution.class)
|
|
|
- .withEntityClasses(ProductionProcesses.class)
|
|
|
- .withConstraintProviderClass(ApsConstraintProvider.class)
|
|
|
+ .withEnvironmentMode(mode)
|
|
|
+ .withSolutionClass(ApsSolution.class)
|
|
|
+ .withEntityClasses(ProductionProcesses.class)
|
|
|
+ .withConstraintProviderClass(ApsConstraintProvider.class)
|
|
|
// .withTerminationSpentLimit(Duration.ofSeconds(runPlanSeconds1))
|
|
|
- .withTerminationConfig(new TerminationConfig().withUnimprovedSecondsSpentLimit(120L))
|
|
|
- .withMoveThreadCount(cores)
|
|
|
+ .withTerminationConfig(new TerminationConfig().withUnimprovedSecondsSpentLimit(120L))
|
|
|
+ .withMoveThreadCount(cores)
|
|
|
);
|
|
|
Solver<ApsSolution> solver1 = solverFactory1.buildSolver();
|
|
|
solver1.addEventListener(new SolverEventListener<ApsSolution>() {
|