Переглянути джерело

aps-调度排程增加开始时间的传入

sucheng 5 місяців тому
батько
коміт
f3741ff996

+ 1 - 1
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/ApsBlankOrderService.java

@@ -70,7 +70,7 @@ public interface ApsBlankOrderService extends IService<ApsBlankOrderDo> {
 
     R checkAddMaterial(AddMaterialReq req);
 
-    void apsScheduleRestart(Integer hour);
+    void apsScheduleRestart(Integer hour,String chongpaiStartDateStr,String chongpaiEndDateStr);
 
     void sortLenZha(DateTime chongpaiEndDate);
 

+ 2 - 1
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/ApsService.java

@@ -1,5 +1,6 @@
 package com.rongwei.bscommon.sys.service;
 
+import cn.hutool.core.date.DateTime;
 import com.rongwei.bsentity.vo.ApsBlankOrderVo;
 import com.rongwei.bsentity.vo.ApsTypeVo;
 import com.rongwei.bsentity.vo.ProductionScheduleVo;
@@ -11,7 +12,7 @@ import java.util.Map;
 
 public interface ApsService {
 
-    void apsSchedule(List<ApsBlankOrderVo> apsBlankOrders, ApsTypeVo apsType, SysUserVo currentUser,List<String> needUnLockProcessIdList);
+    void apsSchedule(List<ApsBlankOrderVo> apsBlankOrders, ApsTypeVo apsType, SysUserVo currentUser, List<String> needUnLockProcessIdList, DateTime scheduleStartDate);
 
     ProductionScheduleVo apsProductionScheduleInit(List<ApsBlankOrderVo> apsBlankOrders, Date apsPlanStartDate,List<String> needUnLockProcessIdList);
 

+ 29 - 22
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ApsBlankOrderServiceImpl.java

@@ -736,7 +736,7 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
      */
     @Override
     public void blankOrderAps(List<ApsBlankOrderVo> apsBlankOrders) {
-        apsService.apsSchedule(apsBlankOrders, new ApsTypeVo(), null, null);
+        apsService.apsSchedule(apsBlankOrders, new ApsTypeVo(), null, null, null);
 //        //调度排程
 //        //判断是否是 18:00:00-24:00:00/00:00:00-5:00:00
 //        // 获取当前时间
@@ -3443,7 +3443,7 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
     public void insertSchedule(Map<String, Object> params) {
         List<ApsBlankOrderVo> apsBlankOrders = apsBlankOrderDao.getByOrderBlanckId(params.get("PRODUCTIONORDERID").toString(), params.get("BLANKORDERID").toString());
         if (apsBlankOrders != null && apsBlankOrders.size() > 0) {
-            apsService.apsSchedule(apsBlankOrders, new ApsTypeVo(), null, null);
+            apsService.apsSchedule(apsBlankOrders, new ApsTypeVo(), null, null, null);
         }
     }
 
@@ -4144,30 +4144,37 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
     }
 
     @Override
-    public void apsScheduleRestart(Integer hour) {
+    public void apsScheduleRestart(Integer hour, String chongpaiStartDateStr, String chongpaiEndDateStr) {
         ApsUtils.checkScheduling(null);
         String needScheduleDate = "";
-        DateTime nowDate = DateUtil.date();
-        String time1 = DateUtil.format(nowDate, "yyyy-MM-dd 00:00:00");
-        String time2 = DateUtil.format(nowDate, "yyyy-MM-dd 12:00:00");
-        String time3 = DateUtil.format(nowDate, "yyyy-MM-dd 23:59:59");
-        String now = DateUtil.format(nowDate, "yyyy-MM-dd HH:mm:ss");
-        //如果当前时间在0-12点,重排明天的
-        //如果当前时间在12-24点,重排后天的
-        if (now.compareTo(time1) >= 0 && now.compareTo(time2) < 0) {
-            needScheduleDate = DateUtil.format(DateUtil.offsetDay(nowDate, 1), "yyyy-MM-dd");
-        }
-        if (now.compareTo(time2) >= 0 && now.compareTo(time3) <= 0) {
-            needScheduleDate = DateUtil.format(DateUtil.offsetDay(nowDate, 2), "yyyy-MM-dd");
-        }
-
-        if (ObjectUtil.isNotEmpty(needScheduleDate)) {
+        DateTime chongpaiStartDate = null;
+        DateTime chongpaiEndDate = null;
+        if (ObjectUtil.isEmpty(chongpaiStartDateStr) || ObjectUtil.isEmpty(chongpaiEndDateStr)) {
+            DateTime nowDate = DateUtil.date();
+            String time1 = DateUtil.format(nowDate, "yyyy-MM-dd 00:00:00");
+            String time2 = DateUtil.format(nowDate, "yyyy-MM-dd 12:00:00");
+            String time3 = DateUtil.format(nowDate, "yyyy-MM-dd 23:59:59");
+            String now = DateUtil.format(nowDate, "yyyy-MM-dd HH:mm:ss");
+            //如果当前时间在0-12点,重排明天的
+            //如果当前时间在12-24点,重排后天的
+            if (now.compareTo(time1) >= 0 && now.compareTo(time2) < 0) {
+                needScheduleDate = DateUtil.format(DateUtil.offsetDay(nowDate, 1), "yyyy-MM-dd");
+            }
+            if (now.compareTo(time2) >= 0 && now.compareTo(time3) <= 0) {
+                needScheduleDate = DateUtil.format(DateUtil.offsetDay(nowDate, 2), "yyyy-MM-dd");
+            }
             //计算重排开始时间和结束时间
-            DateTime chongpaiStartDate = DateUtil.parseDate(needScheduleDate);
-            DateTime chongpaiEndDate = DateUtil.endOfDay(chongpaiStartDate);
+            chongpaiStartDate = DateUtil.parseDate(needScheduleDate);
+            chongpaiEndDate = DateUtil.endOfDay(chongpaiStartDate);
             if (ObjectUtil.isNotEmpty(hour)) {
                 chongpaiEndDate = DateUtil.offsetHour(chongpaiStartDate, hour);
             }
+        } else {
+            chongpaiStartDate = DateUtil.parseDate(chongpaiEndDateStr);
+            chongpaiEndDate = DateUtil.parseDate(chongpaiEndDateStr);
+            needScheduleDate = DateUtil.format(chongpaiStartDate, "yyyy-MM-dd");
+        }
+        if (ObjectUtil.isNotEmpty(needScheduleDate)) {
 
             //将实际完工时间大于明天的作业挪到实际完工时间
             this.baseMapper.updateFinishDateAboutProcessEqu(needScheduleDate, CXCommonUtils.getCurrentUserFactoryId(null));
@@ -4453,7 +4460,7 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
         needUnLockProcessIdList.addAll(notNeedUnLockProcessIdList);
         needUnLockProcessIdList = needUnLockProcessIdList.stream().distinct().collect(Collectors.toList());
         log.info("所有传入退火排程的作业ID:{}", needUnLockProcessIdList);
-        apsService.apsSchedule(new ArrayList<>(), apsTypeVo, null, needUnLockProcessIdList);
+        apsService.apsSchedule(new ArrayList<>(), apsTypeVo, null, needUnLockProcessIdList, chongpaiStartDate);
 
     }
 
@@ -4617,7 +4624,7 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
         needUnLockProcessIdList.addAll(notNeedUnLockProcessIdList);
         needUnLockProcessIdList = needUnLockProcessIdList.stream().distinct().collect(Collectors.toList());
         log.info("所有传入冷轧排程的作业ID:{}", needUnLockProcessIdList);
-        apsService.apsSchedule(new ArrayList<>(), apsTypeVo, null, needUnLockProcessIdList);
+        apsService.apsSchedule(new ArrayList<>(), apsTypeVo, null, needUnLockProcessIdList, chongpaiStartDate);
 
     }
 

+ 19 - 20
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ApsServiceImpl.java

@@ -93,7 +93,7 @@ public class ApsServiceImpl implements ApsService {
      * @param needUnLockProcessIdList 需要过滤的工序作业ID集合
      */
     @Override
-    public void apsSchedule(List<ApsBlankOrderVo> apsBlankOrders,ApsTypeVo apsType,SysUserVo currentUser,List<String> needUnLockProcessIdList) {
+    public void apsSchedule(List<ApsBlankOrderVo> apsBlankOrders,ApsTypeVo apsType,SysUserVo currentUser,List<String> needUnLockProcessIdList,DateTime scheduleStartDate) {
         logger.info("**********排程请求开始**********");
         if(apsType.getScheduleType() == null){
             apsType.setScheduleType("default");
@@ -151,7 +151,7 @@ public class ApsServiceImpl implements ApsService {
                 }
                 // 冷轧连续性问题重排
                 if(apsType != null && StrUtil.isNotBlank(apsType.getScheduleType()) && "dd".equals(apsType.getScheduleType())){
-                    lzlxOrderSchedule(apsBlankOrders,currentUser,apsType,needUnLockProcessIdList);
+                    lzlxOrderSchedule(apsBlankOrders,currentUser,apsType,needUnLockProcessIdList,scheduleStartDate);
                 }else{
                     apsOrderScheduleNew(apsBlankOrders,currentUser,apsType,needUnLockProcessIdList);
                 }
@@ -497,7 +497,7 @@ public class ApsServiceImpl implements ApsService {
      * @param apsBlankOrders
      * @param currentUser
      */
-    private void lzlxOrderSchedule(List<ApsBlankOrderVo> apsBlankOrders,SysUserVo currentUser,ApsTypeVo apsType,List<String> needUnLockProcessIdList){
+    private void lzlxOrderSchedule(List<ApsBlankOrderVo> apsBlankOrders,SysUserVo currentUser,ApsTypeVo apsType,List<String> needUnLockProcessIdList,DateTime scheduleStartDate){
         logger.info("调度排程开始...");
         // 坯料计划排序
         Collections.sort(apsBlankOrders,(v1,v2)->{
@@ -586,23 +586,22 @@ public class ApsServiceImpl implements ApsService {
 //                apsPlanStartDate = DateUtil.date().offset(DateField.HOUR, a);
 //            }
 //        }
-        String needScheduleDate = "";
-        DateTime nowDate = DateUtil.date();
-        String time1 = DateUtil.format(nowDate, "yyyy-MM-dd 00:00:00");
-        String time2 = DateUtil.format(nowDate, "yyyy-MM-dd 12:00:00");
-        String time3 = DateUtil.format(nowDate, "yyyy-MM-dd 23:59:59");
-        String now = DateUtil.format(nowDate, "yyyy-MM-dd HH:mm:ss");
-        //如果当前时间在0-12点,重排明天的
-        //如果当前时间在12-24点,重排后天的
-        if (now.compareTo(time1) >= 0 && now.compareTo(time2) < 0) {
-            needScheduleDate = DateUtil.format(DateUtil.offsetDay(nowDate, 1), "yyyy-MM-dd");
-        }
-        if (now.compareTo(time2) >= 0 && now.compareTo(time3) <= 0) {
-            needScheduleDate = DateUtil.format(DateUtil.offsetDay(nowDate, 2), "yyyy-MM-dd");
-        }
-        DateTime chongpaiStartDate = DateUtil.parseDate(needScheduleDate);
-        Date finalApsPlanStartDate = chongpaiStartDate;
-        apsOrderScheduleApsNew(apsBlankOrders,currentUser,allEqs, finalApsPlanStartDate,apsType,needUnLockProcessIdList);
+//        String needScheduleDate = "";
+//        DateTime nowDate = DateUtil.date();
+//        String time1 = DateUtil.format(nowDate, "yyyy-MM-dd 00:00:00");
+//        String time2 = DateUtil.format(nowDate, "yyyy-MM-dd 12:00:00");
+//        String time3 = DateUtil.format(nowDate, "yyyy-MM-dd 23:59:59");
+//        String now = DateUtil.format(nowDate, "yyyy-MM-dd HH:mm:ss");
+//        //如果当前时间在0-12点,重排明天的
+//        //如果当前时间在12-24点,重排后天的
+//        if (now.compareTo(time1) >= 0 && now.compareTo(time2) < 0) {
+//            needScheduleDate = DateUtil.format(DateUtil.offsetDay(nowDate, 1), "yyyy-MM-dd");
+//        }
+//        if (now.compareTo(time2) >= 0 && now.compareTo(time3) <= 0) {
+//            needScheduleDate = DateUtil.format(DateUtil.offsetDay(nowDate, 2), "yyyy-MM-dd");
+//        }
+//        DateTime chongpaiStartDate = DateUtil.parseDate(needScheduleDate);
+        apsOrderScheduleApsNew(apsBlankOrders,currentUser,allEqs, scheduleStartDate,apsType,needUnLockProcessIdList);
     }
 
     private void apsOrderScheduleApsNew(List<ApsBlankOrderVo> apsBlankOrders,SysUserVo currentUser,Map<String,Equipment> allEqs,Date apsPlanStartDate,ApsTypeVo apsType,List<String> needUnLockProcessIdList){

+ 4 - 2
cx-aps/cx-aps-server/src/main/java/com/rongwei/bsserver/controller/ApsBlankOrderController.java

@@ -65,8 +65,10 @@ public class ApsBlankOrderController {
      * 自动调度
      */
     @GetMapping("/apsScheduleRestart")
-    public R apsScheduleRestart(@RequestParam(required = false) Integer hour) {
-        apsBlankOrderService.apsScheduleRestart(hour);
+    public R apsScheduleRestart(@RequestParam(required = false) Integer hour,
+                                @RequestParam(required = false) String chongpaiStartDate,
+                                @RequestParam(required = false) String chongpaiEndDate) {
+        apsBlankOrderService.apsScheduleRestart(hour,chongpaiStartDate,chongpaiEndDate);
         return R.ok();
     }