Browse Source

任务列表新增发文链接

lqc 4 years ago
parent
commit
97795291be

+ 1 - 0
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxCashScheduleTaskListMapper.xml

@@ -13,6 +13,7 @@
         <result column="remark" property="remark" />
         <result column="task_content" property="taskContent" />
         <result column="gh_id" property="ghId" />
+        <result column="send_url" property="sendUrl" />
         <result column="status" property="status" />
         <result column="type" property="type" />
         <result column="err_info" property="errInfo" />

+ 14 - 0
src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxCashScheduleTaskList.java

@@ -69,6 +69,11 @@ public class FosterwxCashScheduleTaskList extends Model<FosterwxCashScheduleTask
     private String ghId;
 
     /**
+     * 发文链接
+     */
+    private String sendUrl;
+
+    /**
      * 状态(1、待生成;2、已生成;3、生成失败;4、待发送;5、已发送;6、已取消)
      */
     private Integer status;
@@ -190,6 +195,14 @@ public class FosterwxCashScheduleTaskList extends Model<FosterwxCashScheduleTask
         this.ghId = ghId;
     }
 
+    public String getSendUrl() {
+        return sendUrl;
+    }
+
+    public void setSendUrl(String sendUrl) {
+        this.sendUrl = sendUrl;
+    }
+
     public Integer getStatus() {
         return status;
     }
@@ -288,6 +301,7 @@ public class FosterwxCashScheduleTaskList extends Model<FosterwxCashScheduleTask
                 ", remark=" + remark +
                 ", taskContent=" + taskContent +
                 ", ghId=" + ghId +
+                ", sendUrl=" + sendUrl +
                 ", status=" + status +
                 ", type=" + type +
                 ", errInfo=" + errInfo +

+ 47 - 0
src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxCash.java

@@ -0,0 +1,47 @@
+package com.mokamrp.privates.task.pangu;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashScheduleTaskList;
+import com.mokamrp.privates.service.pangu.FosterwxCashScheduleTaskListService;
+import lombok.extern.slf4j.Slf4j;
+import net.javacrumbs.shedlock.core.SchedulerLock;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.List;
+
+/**
+ * 同步变现任务到缓存 供H5页面展示
+ */
+@Component
+@Slf4j
+public class SyncFosterwxCash {
+    @Autowired
+    private StringRedisTemplate stringRedisTemplate;
+
+    @Autowired
+    private FosterwxCashScheduleTaskListService fosterwxCashScheduleTaskListService;
+
+    /**
+     * 每隔一分钟扫描今天待发送以及已经发送的任务
+     */
+    @Scheduled(cron = "10 */1 * * * ?")
+    @SchedulerLock(name = "pangu:SyncFosterwxCash", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
+    public void syncFosterwxCash() {
+        // 获取当前时间
+        LocalDateTime minDateTime = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
+        LocalDateTime localDateTime = LocalDateTime.now();
+
+        List<FosterwxCashScheduleTaskList> fosterwxCashScheduleTaskLists = fosterwxCashScheduleTaskListService.list(
+                new LambdaQueryWrapper<FosterwxCashScheduleTaskList>().
+                        eq(FosterwxCashScheduleTaskList::getType, 1).
+                        between(FosterwxCashScheduleTaskList::getSendTime, minDateTime, localDateTime));
+
+        stringRedisTemplate.opsForHash().put("pan_fosterwx_cash_group_id:", null, null);
+    }
+}