|
@@ -8,6 +8,9 @@ import com.rongwei.rwapsserver.aps.score.ApsConstraintProvider;
|
|
|
import com.rongwei.rwapsserver.aps.service.ApsService;
|
|
|
import com.rongwei.rwapsserver.aps.service.DdApsService;
|
|
|
import com.rongwei.rwapsserver.aps.service.ProductionScheduleService;
|
|
|
+import com.rongwei.rwapsserver.aps.taskassigning.tado.ApsSolutionTa;
|
|
|
+import com.rongwei.rwapsserver.aps.taskassigning.tado.EquipmentTa;
|
|
|
+import com.rongwei.rwapsserver.aps.taskassigning.tado.ProductionProcessesTa;
|
|
|
import com.rongwei.rwapsserver.aps.util.ApsConstants;
|
|
|
import com.rongwei.rwapsserver.aps.util.ApsException;
|
|
|
import com.rongwei.rwapsserver.aps.util.ApsUtils;
|
|
@@ -53,8 +56,8 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
@Override
|
|
|
public ProductionScheduleRetVo productionSchedule(ProductionScheduleVo productionScheduleVo) throws Exception{
|
|
|
List<String> blankids = new ArrayList<>();
|
|
|
- blankids.add("3917c2948ba446698afd93342757c6b9");
|
|
|
- blankids.add("caec67974fd04302b37e2fd848815a68");
|
|
|
+ blankids.add("3dffee02b25141cfb6a38624e855f9b2");
|
|
|
+ blankids.add("133bea9029db4db4b199a3c578a5695c");
|
|
|
// blankids.add("7efe679a8e3c4942b88758617cdbc312");
|
|
|
// blankids.add("acf4460f9488459780c0dc7d8038f1f9");
|
|
|
// blankids.add("efeb1f8d01b04cdb9921c0d1711bb967");
|
|
@@ -1825,6 +1828,14 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
* @return
|
|
|
*/
|
|
|
public ProductionScheduleRetVo tuiHuoSchedule(ProductionScheduleVo productionScheduleVo) throws Exception{
|
|
|
+ /*List<String> blankids = new ArrayList<>();
|
|
|
+ blankids.add("3dffee02b25141cfb6a38624e855f9b2");
|
|
|
+ blankids.add("133bea9029db4db4b199a3c578a5695c");
|
|
|
+ List<ProductionProcesses> collect = productionScheduleVo.getProcesses().stream().filter(v ->
|
|
|
+ blankids.contains(v.getProduceOrder().get(0).getId())
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ productionScheduleVo.setProcesses(collect);*/
|
|
|
+
|
|
|
log.info("*************** 退火调度排程开始:"+productionScheduleVo.getProductionScheduleId()+" *******************");
|
|
|
if(productionScheduleVo.getScheduleType().getScheduleType() == null){
|
|
|
productionScheduleVo.getScheduleType().setScheduleType("default");
|
|
@@ -1896,11 +1907,42 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
.withSolutionClass(ApsSolution.class)
|
|
|
.withEntityClasses(ProductionProcesses.class)
|
|
|
.withConstraintProviderClass(ApsConstraintProvider.class)
|
|
|
-// .withTerminationSpentLimit(Duration.ofSeconds(runPlanSeconds1))
|
|
|
- .withTerminationConfig(new TerminationConfig().withUnimprovedSecondsSpentLimit(120L))
|
|
|
+// .withTerminationSpentLimit(Duration.ofSeconds(300))
|
|
|
+ .withTerminationConfig(new TerminationConfig().withUnimprovedSecondsSpentLimit(60L))
|
|
|
.withMoveThreadCount(cores)
|
|
|
);
|
|
|
Solver<ApsSolution> solver1 = solverFactory1.buildSolver();
|
|
|
+ solver1.addEventListener(new SolverEventListener<ApsSolution>() {
|
|
|
+ public void bestSolutionChanged(BestSolutionChangedEvent<ApsSolution> event) {
|
|
|
+ if(solver1.isEveryProblemChangeProcessed()) {
|
|
|
+ event.getNewBestSolution().setConstructionHeuristicEnd(true);
|
|
|
+ if(event.getNewBestSolution().getStepBestProcessesList() == null){
|
|
|
+ List<ProductionProcesses> processesList = new ArrayList<>();
|
|
|
+ for (ProductionProcesses productionProcesses : event.getNewBestSolution().getProcessesList()) {
|
|
|
+ ProductionProcesses newPro = new ProductionProcesses();
|
|
|
+ newPro.setId(productionProcesses.getId());
|
|
|
+ newPro.setEquipmentId(productionProcesses.getEquipmentId());
|
|
|
+ Equipment eq = new Equipment();
|
|
|
+ if(productionProcesses.getEquipment() != null){
|
|
|
+ eq.setId(productionProcesses.getEquipment().getId());
|
|
|
+ }
|
|
|
+ newPro.setEquipment(eq);
|
|
|
+ newPro.setProduceTime(productionProcesses.getProduceTime());
|
|
|
+ newPro.setStartTime(productionProcesses.getStartTime());
|
|
|
+ newPro.setEndTime(productionProcesses.getEndTime());
|
|
|
+ newPro.setVolumeWidth(productionProcesses.getVolumeWidth());
|
|
|
+ newPro.setSinglerollweight(productionProcesses.getSinglerollweight());
|
|
|
+ processesList.add(newPro);
|
|
|
+
|
|
|
+ productionProcesses.setApsStatus("LS");
|
|
|
+ }
|
|
|
+ event.getNewBestSolution().setStepBestProcessesList(processesList);
|
|
|
+ }
|
|
|
+ System.out.println("************"+event.getNewBestScore()+"************");
|
|
|
+ log.info("************"+event.getNewBestScore()+"************");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
// 退火调度排序
|
|
|
List<ProductionProcesses> hapres = new ArrayList<>();
|
|
|
List<ProductionProcesses> nothapres = new ArrayList<>();
|
|
@@ -1929,11 +1971,37 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
|
|
|
ApsSolution solvedBalance = solver1.solve(apsSolutionTh);
|
|
|
|
|
|
+
|
|
|
+ // test
|
|
|
+ /*List<ProductionProcesses> test1 = new ArrayList<>();
|
|
|
+ List<ProductionProcesses> test3 = new ArrayList<>();
|
|
|
+ test1.addAll(solvedBalance.getProcessesList());
|
|
|
+ Map<String, List<ProductionProcesses>> orderProcess = test1.stream().collect(Collectors.groupingBy(ProductionProcesses::getEquipmentId));
|
|
|
+ orderProcess.forEach((kk,vv)->{
|
|
|
+ List<ProductionProcesses> test2 = new ArrayList<>();
|
|
|
+ test2.addAll(vv);
|
|
|
+ Collections.sort(test2,Comparator.comparing(ProductionProcesses::getStartTime));
|
|
|
+ for (int i = 0; i < test2.size()-1; i++) {
|
|
|
+ ProductionProcesses p1 = test2.get(i);
|
|
|
+ ProductionProcesses p2 = test2.get(i+1);
|
|
|
+ if(p2.getStartTime().compareTo(p1.getEndTime()) < 0 && p2.getStartTime().compareTo(p1.getStartTime()) > 0){
|
|
|
+ List<ProductionProcesses> ps1 = test3.stream().filter(v -> v.getId().equals(p1.getId())).collect(Collectors.toList());
|
|
|
+ if(ps1 == null || ps1.size() == 0){
|
|
|
+ test3.add(p1);
|
|
|
+ }
|
|
|
+ test3.add(p2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
log.info("**************退火排程评分分析***************");
|
|
|
SolutionManager<ApsSolution, HardSoftScore> scoreManager1 = SolutionManager.create(solverFactory1);
|
|
|
ScoreExplanation<ApsSolution, HardSoftScore> explain1 = scoreManager1.explain(solvedBalance);
|
|
|
log.info(explain1.toString());
|
|
|
log.info("**************退火排程评分分析***************");
|
|
|
+ productionScheduleRetVo.setScoreResult(scoreManager1.explain(solvedBalance).toString());
|
|
|
|
|
|
solvedBalance.getProcessesList().addAll(hasLocks);
|
|
|
// 退火合并工序排程完拆分
|