Просмотр исходного кода

Merge branch 'dev-lqc' into test

lqc 4 лет назад
Родитель
Сommit
3c1e8fb7c5

+ 71 - 15
src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxCashAccountSchedule.java

@@ -1,12 +1,14 @@
 package com.mokamrp.privates.mapper.pangu.pojo;
 
-import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+
+import java.io.Serializable;
 import java.time.LocalDate;
-import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
-import java.io.Serializable;
 
 /**
  * <p>
@@ -24,7 +26,7 @@ public class FosterwxCashAccountSchedule extends Model<FosterwxCashAccountSchedu
     /**
      * id
      */
-      @TableId(value = "id", type = IdType.AUTO)
+    @TableId(value = "id", type = IdType.AUTO)
     private Integer id;
 
     /**
@@ -72,6 +74,20 @@ public class FosterwxCashAccountSchedule extends Model<FosterwxCashAccountSchedu
      */
     private LocalDateTime updateAt;
 
+    @TableField(exist = false)
+    private String groupName;
+
+    @TableField(exist = false)
+    private String templateName;
+
+    @TableField(exist = false)
+    private Integer createdCount;
+
+    @TableField(exist = false)
+    private Integer sendedCount;
+
+    @TableField(exist = false)
+    private Integer totalCount;
 
     public Integer getId() {
         return id;
@@ -158,19 +174,59 @@ public class FosterwxCashAccountSchedule extends Model<FosterwxCashAccountSchedu
         return this.id;
     }
 
+    public String getGroupName() {
+        return groupName;
+    }
+
+    public void setGroupName(String groupName) {
+        this.groupName = groupName;
+    }
+
+    public String getTemplateName() {
+        return templateName;
+    }
+
+    public void setTemplateName(String templateName) {
+        this.templateName = templateName;
+    }
+
+    public Integer getCreatedCount() {
+        return createdCount;
+    }
+
+    public void setCreatedCount(Integer createdCount) {
+        this.createdCount = createdCount;
+    }
+
+    public Integer getSendedCount() {
+        return sendedCount;
+    }
+
+    public void setSendedCount(Integer sendedCount) {
+        this.sendedCount = sendedCount;
+    }
+
+    public Integer getTotalCount() {
+        return totalCount;
+    }
+
+    public void setTotalCount(Integer totalCount) {
+        this.totalCount = totalCount;
+    }
+
     @Override
     public String toString() {
         return "FosterwxCashAccountSchedule{" +
-        "id=" + id +
-        ", scheduleDate=" + scheduleDate +
-        ", groupId=" + groupId +
-        ", templateId=" + templateId +
-        ", status=" + status +
-        ", createUid=" + createUid +
-        ", createUser=" + createUser +
-        ", updateUid=" + updateUid +
-        ", createAt=" + createAt +
-        ", updateAt=" + updateAt +
-        "}";
+                "id=" + id +
+                ", scheduleDate=" + scheduleDate +
+                ", groupId=" + groupId +
+                ", templateId=" + templateId +
+                ", status=" + status +
+                ", createUid=" + createUid +
+                ", createUser=" + createUser +
+                ", updateUid=" + updateUid +
+                ", createAt=" + createAt +
+                ", updateAt=" + updateAt +
+                "}";
     }
 }

+ 53 - 1
src/main/java/com/mokamrp/privates/task/pangu/SyncCreateCashTask.java

@@ -1,25 +1,39 @@
 package com.mokamrp.privates.task.pangu;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.entity.pangu.FosterwxCashAccountScheduleHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashAccountSchedule;
 import com.mokamrp.privates.service.pangu.FosterwxCashAccountScheduleService;
 import net.javacrumbs.shedlock.core.SchedulerLock;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
 import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.web.client.RestTemplate;
 
 import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 每天五点定时生成第二天的任务列表
  */
 public class SyncCreateCashTask {
+    public static final String FEISHU_ROBOT = "https://open.feishu.cn/open-apis/bot/v2/hook/9bc38791-e7d1-48a1-ae64-0df632e81a36";
     @Autowired
     private FosterwxCashAccountScheduleService fosterwxCashAccountScheduleService;
 
+    @Autowired
+    private RestTemplate restTemplate;
+
     @Scheduled(cron = "0 0 17 * * ?")
     @SchedulerLock(name = "pangu:SyncCreateCashTask", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
-    public void execute() {
+    public void syncCreateCashTask() {
         // 获取明天日期
         LocalDate nextDay = LocalDate.now().plusDays(1);
 
@@ -27,4 +41,42 @@ public class SyncCreateCashTask {
 
         fosterwxCashAccountSchedules.forEach(fosterwxCashAccountSchedule -> fosterwxCashAccountScheduleService.createTask(fosterwxCashAccountSchedule.getId()));
     }
+
+    /**
+     * 每天起点飞书提醒 任务失败详情
+     */
+    @Scheduled(cron = "0 0 7 * * ?")
+    @SchedulerLock(name = "pangu:TaskInfoNotify", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
+    public void taskInfoNotify() {
+        // 获取当天日期
+        LocalDate localDate = LocalDate.now();
+
+        FosterwxCashAccountScheduleHandle handle = new FosterwxCashAccountScheduleHandle();
+        handle.setScheduleDate(localDate);
+        handle.setPage(1);
+        handle.setPageSize(999999999);
+
+        ResHandle<List<FosterwxCashAccountSchedule>> res = fosterwxCashAccountScheduleService.getList(handle);
+
+        Map<String, Object> body = new HashMap<>(1);
+        body.put("msg_type", "post");
+        JSONArray content = new JSONArray();
+        res.getList().forEach(fosterwxCashAccountSchedule -> {
+            JSONArray rowData = new JSONArray();
+            rowData.add(new ArrayList<JSONObject>() {
+                {
+                    {
+                        add(new JSONObject() {{
+                            put("tag", "text");
+                            put("text", "排期日期:" + fosterwxCashAccountSchedule.getScheduleDate() + " 账号组" + fosterwxCashAccountSchedule.getGroupName() + " 任务失败数量:" + (fosterwxCashAccountSchedule.getTotalCount() - fosterwxCashAccountSchedule.getCreatedCount()) + "个");
+                        }});
+                    }
+                }
+            });
+            content.add(rowData);
+        });
+        body.put("content", content);
+        HttpEntity<Map<String, Object>> httpEntity = new HttpEntity<>(body, null);
+        JSONObject result = restTemplate.exchange(FEISHU_ROBOT, HttpMethod.POST, httpEntity, JSONObject.class).getBody();
+    }
 }