Sfoglia il codice sorgente

分主体处理发送

xueyiming 1 mese fa
parent
commit
5408da8637

+ 20 - 22
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComHistoryDataJob.java

@@ -91,41 +91,39 @@ public class WeComHistoryDataJob {
     @Autowired
     private WeComSendService weComSendService;
 
-    private static final String START_TIME_KEY = "start_time_key";
+    private static final String START_TIME_KEY = "start_time_key_%s";
 
     @XxlJob("saveHistoryMessageJob1")
     public ReturnT<String> saveHistoryMessageJob1(String param) {
-        Integer startTimeVal = (Integer) redisTemplate.opsForValue().get(START_TIME_KEY);
-        Long dayStartTime = DateUtil.getBeforeDayStart(0);
-        Long startTime;
-        if (startTimeVal == null) {
-            startTime = DateUtil.getBeforeDayStart(0);
-        } else {
-            if (dayStartTime > startTimeVal) {
-                startTime = dayStartTime;
-            } else {
-                startTime = (long) startTimeVal;
-            }
-        }
-
-        Long endTime = System.currentTimeMillis() / 1000;
         CorpExample example = new CorpExample();
         List<Corp> corps = corpMapper.selectByExample(example);
         if (CollectionUtils.isEmpty(corps)) {
             return ReturnT.SUCCESS;
         }
         for (Corp corp : corps) {
+            String key = String.format(START_TIME_KEY, corp.getId());
+            Integer startTimeVal = (Integer) redisTemplate.opsForValue().get(key);
+            Long dayStartTime = DateUtil.getBeforeDayStart(0);
+            Long startTime;
+            if (startTimeVal == null) {
+                startTime = DateUtil.getBeforeDayStart(0);
+            } else {
+                if (dayStartTime > startTimeVal) {
+                    startTime = dayStartTime;
+                } else {
+                    startTime = (long) startTimeVal;
+                }
+            }
+            Long endTime = System.currentTimeMillis() / 1000;
             selectGroupMsgList(startTime, endTime, corp.getId(), null);
-        }
-        boolean isAllSend = true;
-        for (Corp corp : corps) {
+            boolean isAllSend = true;
             long notSentCount = newSelectAlertHistoryMessage(startTime, endTime + TimeConstant.HOUR, corp.getId(), corp.getName());
             if (notSentCount > 0) {
                 isAllSend = false;
             }
-        }
-        if (isAllSend) {
-            redisTemplate.opsForValue().set(START_TIME_KEY, endTime, 1, TimeUnit.DAYS);
+            if (isAllSend) {
+                redisTemplate.opsForValue().set(key, endTime, 1, TimeUnit.DAYS);
+            }
         }
         return ReturnT.SUCCESS;
     }
@@ -177,7 +175,7 @@ public class WeComHistoryDataJob {
                 LarkRobotUtil.sendMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
                 LarkRobotUtil.sendTipMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
                 //8点前报警
-                if (DateUtil.getHourOfDay() < 8) {
+                if (DateUtil.getHourOfDay() < 8 && corpId == 1) {
                     LarkRobotUtil.sendNotPushMessage("<at user_id=\"all\">所有人</at> " + sendDetail.getRemark() + " 存在未发送记录,请检查");
                 }
             }