Przeglądaj źródła

解决消息通知问题

dzx 1 rok temu
rodzic
commit
0ea4f55de2

+ 11 - 11
src/main/java/com/xjrsoft/module/job/AttendanceMessageTask.java

@@ -2,10 +2,12 @@ package com.xjrsoft.module.job;
 
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.db.Entity;
 import cn.hutool.extra.spring.SpringUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.common.utils.WeChatUtil;
 import com.xjrsoft.config.CommonPropertiesConfig;
@@ -137,8 +139,7 @@ public class AttendanceMessageTask {
                 characterKey = "character_string18";
                 //获取最近的时间
                 recentlyTime = getRecentlyTime(ruleDetails, now);
-                long seconds = Math.abs(ChronoUnit.SECONDS.between(now, recentlyTime));
-                if(seconds >= 60){
+                if(recentlyTime.getHour() != now.getHour() || (recentlyTime.getHour() == now.getHour() && recentlyTime.getMinute() != now.getMinute())){
                     log.info("未到时间,不进行推送");
                     continue;
                 }
@@ -155,8 +156,7 @@ public class AttendanceMessageTask {
                 wechatTemplate = weChatUtil.getAttendanceMsgAbsenceTemplate();
                 recentlyTime = getRecentlyOverTime(ruleDetails, now);
                 characterKey = "character_string36";
-                long seconds = Math.abs(ChronoUnit.SECONDS.between(now, recentlyTime));
-                if(seconds >= 60){
+                if(recentlyTime.getHour() != now.getHour() || (recentlyTime.getHour() == now.getHour() && recentlyTime.getMinute() != now.getMinute())){
                     log.info("未到时间,不进行推送");
                     continue;
                 }
@@ -291,13 +291,13 @@ public class AttendanceMessageTask {
                 }
             }
 
-            WechatMessageLog messageLog = new WechatMessageLog();
-            messageLog.setTemplateId(wechatTemplate);
-            messageLog.setSendTime(recentlyTime);
-
-            messageLog.setCreateDate(new Date());
-            messageLog.setContent("消息推送人数:" + userCount);
-            wechatMessageLogService.save(messageLog);
+            String table = "wechat_message_log";
+            Entity entity = Entity.create(table);
+            entity.set("content", "消息推送人数:" + userCount);
+            entity.set("create_date", new Date());
+            entity.set("template_id", wechatTemplate);
+            entity.set("send_time", recentlyTime);
+            SqlRunnerAdapter.db().dynamicInsert(table, entity);
         }
     }