|
@@ -6,10 +6,13 @@ import com.rongwei.rwapsserver.aps.domain.Equipment;
|
|
|
import com.rongwei.rwapsserver.aps.domain.ProductionProcesses;
|
|
|
import com.rongwei.rwapsserver.aps.score.ApsConstraintProvider;
|
|
|
import com.rongwei.rwapsserver.aps.service.ProductionScheduleService;
|
|
|
+import com.rongwei.rwapsserver.aps.util.ApsConstants;
|
|
|
import com.rongwei.rwapsserver.aps.util.ApsException;
|
|
|
import com.rongwei.rwapsserver.aps.vo.ProductionScheduleRetVo;
|
|
|
import com.rongwei.rwapsserver.aps.vo.ProductionScheduleVo;
|
|
|
+import org.optaplanner.core.api.score.ScoreExplanation;
|
|
|
import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore;
|
|
|
+import org.optaplanner.core.api.score.constraint.ConstraintMatch;
|
|
|
import org.optaplanner.core.api.solver.SolutionManager;
|
|
|
import org.optaplanner.core.api.solver.Solver;
|
|
|
import org.optaplanner.core.api.solver.SolverFactory;
|
|
@@ -42,7 +45,7 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
// 排程运行时长
|
|
|
Integer planSeconds = productionScheduleVo.getPlanSeconds();
|
|
|
if(planSeconds == null || planSeconds <= 0){
|
|
|
- planSeconds = 300;
|
|
|
+ planSeconds = 60;
|
|
|
}
|
|
|
|
|
|
// optaplanner 求解器配置实例化
|
|
@@ -63,7 +66,8 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
System.out.println("*****************************");
|
|
|
// System.out.println(solvedBalance);
|
|
|
SolutionManager<ApsSolution, HardSoftScore> scoreManager = SolutionManager.create(solverFactory);
|
|
|
- System.out.println(scoreManager.explain(solvedBalance));
|
|
|
+ ScoreExplanation<ApsSolution, HardSoftScore> explain = scoreManager.explain(solvedBalance);
|
|
|
+ System.out.println(explain);
|
|
|
System.out.println("*****************************");
|
|
|
productionScheduleRetVo.setScoreResult(scoreManager.explain(solvedBalance).toString());
|
|
|
|
|
@@ -74,10 +78,47 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
productionProcesses.getEquipment().setProcessesList(null);
|
|
|
productionProcesses.setPreviousStep(null);
|
|
|
}
|
|
|
+ // 得分分析
|
|
|
+ softExplain(explain,solvedBalance.getProcessesList());
|
|
|
productionScheduleRetVo.setProcesses(solvedBalance.getProcessesList());
|
|
|
return productionScheduleRetVo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 最终得分分析
|
|
|
+ * @param explain
|
|
|
+ * @param processes
|
|
|
+ */
|
|
|
+ private void softExplain(ScoreExplanation<ApsSolution, HardSoftScore> explain,List<ProductionProcesses> processes){
|
|
|
+ if(explain != null && explain.getConstraintMatchTotalMap() != null && explain.getConstraintMatchTotalMap().size()>0){
|
|
|
+ explain.getConstraintMatchTotalMap().forEach((k,v)->{
|
|
|
+ String constraintName = v.getConstraintName();
|
|
|
+ if(constraintName != null){
|
|
|
+ String desc = ApsConstants.constraintDesc.get(constraintName);
|
|
|
+ if(desc != null && v.getConstraintMatchSet() != null && v.getConstraintMatchSet().size()>0){
|
|
|
+ for (ConstraintMatch<HardSoftScore> hardSoftScoreConstraintMatch : v.getConstraintMatchSet()) {
|
|
|
+ if(hardSoftScoreConstraintMatch.getIndictedObjectList() != null && hardSoftScoreConstraintMatch.getIndictedObjectList().size() > 0){
|
|
|
+ for (Object o : hardSoftScoreConstraintMatch.getIndictedObjectList()) {
|
|
|
+ if(o instanceof ProductionProcesses){
|
|
|
+ ProductionProcesses productionProcesses = (ProductionProcesses)o;
|
|
|
+ productionProcesses.setHasConflict("y");
|
|
|
+ productionProcesses.setConflictDes(desc);
|
|
|
+ } else if (o instanceof ArrayList) {
|
|
|
+ List<ProductionProcesses> processesList = (ArrayList)o;
|
|
|
+ for (ProductionProcesses productionProcesses : processesList) {
|
|
|
+ productionProcesses.setHasConflict("y");
|
|
|
+ productionProcesses.setConflictDes(desc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 业务数据模型转换前置处理
|
|
|
* @param productionScheduleVo
|