浏览代码

aps-排程定时任务

sucheng 4 月之前
父节点
当前提交
f434cc9414

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

@@ -16,7 +16,7 @@ import java.util.Map;
 
 public interface ApsService {
 
-    void apsSchedule(List<ApsBlankOrderVo> apsBlankOrders, ApsTypeVo apsType, SysUserVo currentUser, List<String> needUnLockProcessIdList, DateTime scheduleStartDate);
+    void apsSchedule(List<ApsBlankOrderVo> apsBlankOrders, ApsTypeVo apsType, SysUserVo currentUser, List<String> needUnLockProcessIdList, DateTime scheduleStartDate, DateTime apsPlanEndDate);
 
     ProductionScheduleVo apsProductionScheduleInit(List<ApsBlankOrderVo> apsBlankOrders, Date apsPlanStartDate,List<String> needUnLockProcessIdList,
                                                    List<ApsProcessOperationDo> baseApsProcessOperationList,

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

@@ -746,7 +746,7 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
      */
     @Override
     public void blankOrderAps(List<ApsBlankOrderVo> apsBlankOrders) {
-        apsService.apsSchedule(apsBlankOrders, new ApsTypeVo(), null, null, null);
+        apsService.apsSchedule(apsBlankOrders, new ApsTypeVo(), null, null, null,null);
 //        //调度排程
 //        //判断是否是 18:00:00-24:00:00/00:00:00-5:00:00
 //        // 获取当前时间
@@ -3492,7 +3492,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, null);
+            apsService.apsSchedule(apsBlankOrders, new ApsTypeVo(), null, null, null,null);
         }
     }
 
@@ -4394,6 +4394,7 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
 
 
         Thread thread = new Thread(() -> {
+            log.info("线程1开始执行:{}", bancaiTenantId);
             SysUserVo currentUser = new SysUserVo();
             currentUser.setId("8672bf72ab274bec83052868ae336b38");
             currentUser.setName("管理员");
@@ -4420,13 +4421,14 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
                 //调度排程之后,进行预排程
                 //查询待排程的订单
                 List<ApsBlankOrderVo> resBlankList = apsBlankOrderDao.getNeedScheduleList(bancaiTenantId);
-                apsService.apsSchedule(resBlankList, new ApsTypeVo(), currentUser, null, null);
+                apsService.apsSchedule(resBlankList, new ApsTypeVo(), currentUser, null, null,null);
             }
-            log.info("线程执行完成:{}", bancaiTenantId);
+            log.info("线程1执行完成:{}", bancaiTenantId);
         });
         thread.start();
 
         Thread thread1 = new Thread(() -> {
+            log.info("线程2开始执行:{}", bocaiTenantId);
             SysUserVo currentUser = new SysUserVo();
             currentUser.setId("8672bf72ab274bec83052868ae336b38");
             currentUser.setName("管理员");
@@ -4453,10 +4455,15 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
                 //调度排程之后,进行预排程
                 //查询待排程的订单
                 List<ApsBlankOrderVo> resBlankList = apsBlankOrderDao.getNeedScheduleList(bocaiTenantId);
-                apsService.apsSchedule(resBlankList, new ApsTypeVo(), currentUser, null, null);
+                apsService.apsSchedule(resBlankList, new ApsTypeVo(), currentUser, null, null,null);
             }
-            log.info("线程执行完成:{}", bocaiTenantId);
+            log.info("线程2执行完成:{}", bocaiTenantId);
         });
+        try {
+            Thread.sleep(320000);
+        } catch (InterruptedException e) {
+            throw new RuntimeException(e);
+        }
         thread1.start();
     }
 
@@ -4672,7 +4679,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, currentUser, needUnLockProcessIdList, chongpaiStartDate);
+        apsService.apsSchedule(new ArrayList<>(), apsTypeVo, currentUser, needUnLockProcessIdList, chongpaiStartDate,chongpaiEndDate);
 
     }
 
@@ -4844,7 +4851,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, currentUser, needUnLockProcessIdList, chongpaiStartDate);
+        apsService.apsSchedule(new ArrayList<>(), apsTypeVo, currentUser, needUnLockProcessIdList, chongpaiStartDate,chongpaiEndDate);
 
     }
 

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

@@ -100,7 +100,7 @@ public class ApsServiceImpl implements ApsService {
      * @param needUnLockProcessIdList 需要过滤的工序作业ID集合
      */
     @Override
-    public void apsSchedule(List<ApsBlankOrderVo> apsBlankOrders, ApsTypeVo apsType, SysUserVo currentUser, List<String> needUnLockProcessIdList, DateTime scheduleStartDate) {
+    public void apsSchedule(List<ApsBlankOrderVo> apsBlankOrders, ApsTypeVo apsType, SysUserVo currentUser, List<String> needUnLockProcessIdList, DateTime scheduleStartDate, DateTime apsPlanEndDate) {
         logger.info("**********排程请求开始**********");
         DateTime startTime = DateUtil.date();
         if (apsType.getScheduleType() == null) {
@@ -163,7 +163,7 @@ public class ApsServiceImpl implements ApsService {
                 redisService.redisCatchInit("aps-blankids-" + tenantId, bidsStr, 3600 * 24);
                 // 冷轧连续性问题重排
                 if (apsType != null && StrUtil.isNotBlank(apsType.getScheduleType()) && "dd".equals(apsType.getScheduleType())) {
-                    lzlxOrderSchedule(apsBlankOrders, currentUser, apsType, needUnLockProcessIdList, scheduleStartDate, startTime);
+                    lzlxOrderSchedule(apsBlankOrders, currentUser, apsType, needUnLockProcessIdList, scheduleStartDate, apsPlanEndDate, startTime);
                 } else {
                     apsOrderScheduleNew(apsBlankOrders, currentUser, apsType, needUnLockProcessIdList, startTime);
                 }
@@ -399,7 +399,7 @@ public class ApsServiceImpl implements ApsService {
         Date finalApsPlanStartDate = apsPlanStartDate;
         if (cdorders != null && cdorders.size() > 0) {
             try {
-                apsOrderScheduleApsNew(cdorders, currentUser, allEqs, finalApsPlanStartDate, apsType, needUnLockProcessIdList, startTime);
+                apsOrderScheduleApsNew(cdorders, currentUser, allEqs, finalApsPlanStartDate, null, apsType, needUnLockProcessIdList, startTime);
             } catch (Exception e) {
                 e.printStackTrace();
                 logger.info("排程异常", e);
@@ -495,7 +495,7 @@ public class ApsServiceImpl implements ApsService {
                         }
                         return a;
                     });
-                    apsOrderScheduleApsNew(v, currentUser, allEqs, finalApsPlanStartDate, apsType, null, startTime);
+                    apsOrderScheduleApsNew(v, currentUser, allEqs, finalApsPlanStartDate, null, apsType, null, startTime);
                 } catch (Exception e) {
                     e.printStackTrace();
                     logger.info("排程异常", e);
@@ -526,7 +526,7 @@ public class ApsServiceImpl implements ApsService {
      * @param apsBlankOrders
      * @param currentUser
      */
-    private void lzlxOrderSchedule(List<ApsBlankOrderVo> apsBlankOrders, SysUserVo currentUser, ApsTypeVo apsType, List<String> needUnLockProcessIdList, DateTime scheduleStartDate, DateTime startTime) {
+    private void lzlxOrderSchedule(List<ApsBlankOrderVo> apsBlankOrders, SysUserVo currentUser, ApsTypeVo apsType, List<String> needUnLockProcessIdList, DateTime scheduleStartDate, DateTime apsPlanEndDate, DateTime startTime) {
         logger.info("调度排程开始...");
         // 坯料计划排序
         Collections.sort(apsBlankOrders, (v1, v2) -> {
@@ -630,10 +630,10 @@ public class ApsServiceImpl implements ApsService {
 //            needScheduleDate = DateUtil.format(DateUtil.offsetDay(nowDate, 2), "yyyy-MM-dd");
 //        }
 //        DateTime chongpaiStartDate = DateUtil.parseDate(needScheduleDate);
-        apsOrderScheduleApsNew(apsBlankOrders, currentUser, allEqs, scheduleStartDate, apsType, needUnLockProcessIdList, startTime);
+        apsOrderScheduleApsNew(apsBlankOrders, currentUser, allEqs, scheduleStartDate, apsPlanEndDate, apsType, needUnLockProcessIdList, startTime);
     }
 
-    private void apsOrderScheduleApsNew(List<ApsBlankOrderVo> apsBlankOrders, SysUserVo currentUser, Map<String, Equipment> allEqs, Date apsPlanStartDate, ApsTypeVo apsType, List<String> needUnLockProcessIdList, DateTime startTime) {
+    private void apsOrderScheduleApsNew(List<ApsBlankOrderVo> apsBlankOrders, SysUserVo currentUser, Map<String, Equipment> allEqs, Date apsPlanStartDate, Date apsPlanEndDate, ApsTypeVo apsType, List<String> needUnLockProcessIdList, DateTime startTime) {
         // 设备数据每批次开始清空
         allEqs.clear();
         // 排程前解锁所有待排程订单
@@ -784,7 +784,7 @@ public class ApsServiceImpl implements ApsService {
             //日志写入文件
             logWriter(JSONUtil.toJsonStr(apsProductionSchedule, jsonConfig), JSONUtil.toJsonStr(productionScheduleRetVo, jsonConfig), apsType.getScheduleType());
             //排程日志存入数据库
-            logSave(currentUser, startTime, endTime, apsType, apsPlanStartDate, productionScheduleRetVo);
+            logSave(currentUser, startTime, endTime, apsType, apsPlanStartDate, apsPlanEndDate, productionScheduleRetVo);
             if (!"200".equals(productionScheduleRetVo.getCode())) {
                 logger.info("排程异常,坯料计划ID:" + blankOrderIds);
                 // 排程异常后恢复历史排程结果为锁定状态
@@ -857,7 +857,7 @@ public class ApsServiceImpl implements ApsService {
         }
     }
 
-    private void logSave(SysUserVo currentUser, DateTime startTime, DateTime endTime, ApsTypeVo apsType, Date apsPlanStartDate, ProductionScheduleRetVo productionScheduleRetVo) {
+    private void logSave(SysUserVo currentUser, DateTime startTime, DateTime endTime, ApsTypeVo apsType, Date apsPlanStartDate, Date apsPlanEndDate, ProductionScheduleRetVo productionScheduleRetVo) {
         try {
             ApsScheduleLogDo apsScheduleLogDo = new ApsScheduleLogDo();
             apsScheduleLogDo.setId(SecurityUtil.getUUID());
@@ -869,7 +869,7 @@ public class ApsServiceImpl implements ApsService {
             if ("dd".equals(apsType.getScheduleType())) {
                 apsScheduleLogDo.setScheduletype("调度排程");
                 apsScheduleLogDo.setSchedulestarttime(apsPlanStartDate);
-                apsScheduleLogDo.setScheduleendtime(DateUtil.endOfDay(apsPlanStartDate));
+                apsScheduleLogDo.setScheduleendtime(apsPlanEndDate);
             } else {
                 apsScheduleLogDo.setScheduletype("预排程");
             }