Explorar o código

排程时间优化

fangpy hai 1 ano
pai
achega
ac1a0c45f6

+ 9 - 4
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/service/impl/ProductionScheduleServiceImpl.java

@@ -48,9 +48,14 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
             throw new ApsException("缺少全局流转时间配置");
         }
         // 排程运行时长
-        Integer planSeconds = productionScheduleVo.getPlanSeconds();
-        if(planSeconds == null || planSeconds <= 0){
-            planSeconds = 60;
+        Integer maxPlanSeconds = productionScheduleVo.getPlanSeconds();
+        int processNum = productionScheduleVo.getProcesses().size();
+        int runPlanSeconds = (processNum/10 + 1)*60;
+        if(maxPlanSeconds == null || maxPlanSeconds <= 0){
+            maxPlanSeconds = 1800;
+        }
+        if(runPlanSeconds > maxPlanSeconds){
+            throw new ApsException("所选排程作业太多,预计排程时间太长,请分开排程");
         }
 
         EnvironmentMode mode = EnvironmentMode.REPRODUCIBLE;
@@ -66,7 +71,7 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
                 .withEntityClasses(ProductionProcesses.class)
                 .withConstraintProviderClass(ApsConstraintProvider.class)
 //                .withTerminationConfig(new TerminationConfig().withUnimprovedSecondsSpentLimit(10L))
-                .withTerminationSpentLimit(Duration.ofSeconds(planSeconds))
+                .withTerminationSpentLimit(Duration.ofSeconds(runPlanSeconds))
                 .withMoveThreadCount(cores)
         );
         Solver<ApsSolution> solver = solverFactory.buildSolver();