fangpy 1 рік тому
батько
коміт
17446459d8

+ 14 - 1
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/controller/ApsSchedulingController.java

@@ -2,6 +2,7 @@ package com.rongwei.rwapsserver.aps.controller;
 
 import com.rongwei.rwapsserver.aps.domain.EquipmentRunTime;
 import com.rongwei.rwapsserver.aps.service.ProductionScheduleService;
+import com.rongwei.rwapsserver.aps.util.ApsException;
 import com.rongwei.rwapsserver.aps.vo.ProductionScheduleRetVo;
 import com.rongwei.rwapsserver.aps.vo.ProductionScheduleVo;
 import lombok.extern.slf4j.Slf4j;
@@ -29,7 +30,19 @@ public class ApsSchedulingController {
      */
     @PostMapping("/productionSchedule")
     public ProductionScheduleRetVo productionSchedule(@RequestBody ProductionScheduleVo productionScheduleVo) throws Exception{
-        ProductionScheduleRetVo productionScheduleRetVo = productionScheduleService.productionSchedule(productionScheduleVo);
+        ProductionScheduleRetVo productionScheduleRetVo = null;
+        try{
+            productionScheduleRetVo = productionScheduleService.productionSchedule(productionScheduleVo);
+            productionScheduleRetVo.setCode("200");
+        }catch(ApsException ae){
+            productionScheduleRetVo = new ProductionScheduleRetVo();
+            productionScheduleRetVo.setCode("500");
+            productionScheduleRetVo.setMsg(ae.getMessage());
+        }catch(Exception e){
+            productionScheduleRetVo = new ProductionScheduleRetVo();
+            productionScheduleRetVo.setCode("500");
+            productionScheduleRetVo.setMsg("排程异常,请联系管理员");
+        }
         return productionScheduleRetVo;
     }
 

+ 1 - 1
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/listener/TaskStartTimeListener.java

@@ -53,7 +53,7 @@ public class TaskStartTimeListener implements VariableListener<ApsSolution, Prod
     }
 
     protected void updateResponseTime(ScoreDirector<ApsSolution> scoreDirector, ProductionProcesses process) {
-        if(process.getEquipment() != null){
+        if(process.getEquipment() != null && !process.getIfLock()){
 //            System.out.println(process.getEquipment().getId()+"-"+process.getEquipment().getEquipmentType());
             /*scoreDirector.beforeVariableChanged(process, "startTime");
             // 时间设定

+ 1 - 1
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/service/ProductionScheduleService.java

@@ -5,6 +5,6 @@ import com.rongwei.rwapsserver.aps.vo.ProductionScheduleVo;
 
 public interface ProductionScheduleService {
 
-    ProductionScheduleRetVo productionSchedule(ProductionScheduleVo productionScheduleVo);
+    ProductionScheduleRetVo productionSchedule(ProductionScheduleVo productionScheduleVo) throws Exception;
 
 }

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

@@ -1,5 +1,6 @@
 package com.rongwei.rwapsserver.aps.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import com.rongwei.rwapsserver.aps.domain.ApsOverallConfig;
 import com.rongwei.rwapsserver.aps.domain.ApsSolution;
@@ -38,7 +39,7 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
      * @return
      */
     @Override
-    public ProductionScheduleRetVo productionSchedule(ProductionScheduleVo productionScheduleVo) {
+    public ProductionScheduleRetVo productionSchedule(ProductionScheduleVo productionScheduleVo) throws Exception{
         // 排程结果对象
         ProductionScheduleRetVo productionScheduleRetVo = new ProductionScheduleRetVo();
         // 排程校验
@@ -241,6 +242,9 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
                         providedEq.add(equipment);
                     }
                 }
+                if(providedEq.size() == 0){
+                    throw new ApsException("500","作业ID:"+ CollUtil.join(process.getBsProcessesId(),",") + "可选设备不能为空");
+                }
                 process.setOptionalProviderEquipments(providedEq);
             }
             // 上机时间和下机时间如果为null,设置为0

+ 9 - 0
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/vo/ProductionScheduleRetVo.java

@@ -8,6 +8,15 @@ import java.util.List;
 @Data
 public class ProductionScheduleRetVo {
 
+    /**
+     * 返回状态码
+     */
+    private String code;
+    /**
+     * 返回错误信息
+     */
+    private String msg;
+
     private String scoreResult;
 
     /**