Kaynağa Gözat

新增计划发送站内信的扫描机制

车车 9 ay önce
ebeveyn
işleme
39dd5344eb

+ 34 - 0
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/job/PlanSendMessJob.java

@@ -0,0 +1,34 @@
+package cn.iocoder.yudao.module.iscs.job;
+
+import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
+import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
+import cn.iocoder.yudao.module.iscs.service.notifyconfig.NotifyMessagePlanService;
+import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * 计划发送站内信机制
+ *
+ * @author cgj
+ */
+@Slf4j
+@Component
+public class PlanSendMessJob implements JobHandler {
+
+    @Resource
+    private NotifyMessagePlanService notifyMessagePlanService;
+    /**
+     * 扫描定时发送的消息
+     *
+     * @param param 参数
+     * @return
+     */
+    @Override
+    @TenantJob
+    public String execute(String param) {
+        Integer i = notifyMessagePlanService.checkPlanSend();
+        return String.format("扫描发送站内信[" + i + "]条!");
+    }
+
+}

+ 1 - 1
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/service/notifyconfig/NotifyMessagePlanService.java

@@ -58,6 +58,6 @@ public interface NotifyMessagePlanService extends IService<NotifyMessagePlanDO>
      * 检测未发送的消息立即发送
      * @return
      */
-    Boolean checkPlanSend();
+    Integer checkPlanSend();
 
 }

+ 2 - 2
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/service/notifyconfig/NotifyMessagePlanServiceImpl.java

@@ -70,7 +70,7 @@ public class NotifyMessagePlanServiceImpl extends ServiceImpl<NotifyMessagePlanM
     }
 
     @Override
-    public Boolean checkPlanSend() {
+    public Integer checkPlanSend() {
         LocalDateTime now = LocalDateTime.now();
         List<NotifyMessagePlanDO> list = list(Wrappers.<NotifyMessagePlanDO>lambdaQuery()
                 .le(NotifyMessagePlanDO::getPlanSendTime, now)
@@ -96,7 +96,7 @@ public class NotifyMessagePlanServiceImpl extends ServiceImpl<NotifyMessagePlanM
                         .set(NotifyMessagePlanDO::getSendStatus, 1));
             }
         }
-        return true;
+        return list.size();
     }
 
 }