|
|
@@ -6,7 +6,9 @@ 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.mapper.pangu.pojo.FosterwxCashScheduleTaskList;
|
|
|
import com.mokamrp.privates.service.pangu.FosterwxCashAccountScheduleService;
|
|
|
+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;
|
|
|
@@ -32,8 +34,14 @@ public class SyncCreateCashTask {
|
|
|
private FosterwxCashAccountScheduleService fosterwxCashAccountScheduleService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private FosterwxCashScheduleTaskListService fosterwxCashScheduleTaskListService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
+ /**
|
|
|
+ * 每天下午五点生成第二天的任务及链接
|
|
|
+ */
|
|
|
@Scheduled(cron = "0 0 17 * * ?")
|
|
|
@SchedulerLock(name = "pangu:SyncCreateCashTask", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
|
|
|
public void syncCreateCashTask() {
|
|
|
@@ -65,31 +73,84 @@ public class SyncCreateCashTask {
|
|
|
body.put("msg_type", "post");
|
|
|
JSONArray content = new JSONArray();
|
|
|
res.getList().forEach(fosterwxCashAccountSchedule -> {
|
|
|
- JSONArray rowData = new JSONArray();
|
|
|
- rowData.add(new JSONObject() {
|
|
|
- {
|
|
|
- {
|
|
|
- put("tag", "text");
|
|
|
- put("text", "排期日期:" + fosterwxCashAccountSchedule.getScheduleDate() + " 账号组: " + fosterwxCashAccountSchedule.getGroupName() + " 任务失败数量:" + (fosterwxCashAccountSchedule.getTotalCount() - fosterwxCashAccountSchedule.getCreatedCount()) + "个");
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- content.add(rowData);
|
|
|
+ content.add(getJsonArray("排期日期:" + fosterwxCashAccountSchedule.getScheduleDate() + " 账号组: " + fosterwxCashAccountSchedule.getGroupName() + " 任务失败数量:" + (fosterwxCashAccountSchedule.getTotalCount() - fosterwxCashAccountSchedule.getCreatedCount()) + "个"));
|
|
|
+ });
|
|
|
+
|
|
|
+ if (content.size() > 0) {
|
|
|
+ JSONObject post = new JSONObject();
|
|
|
+ JSONObject zh_cn = new JSONObject();
|
|
|
+ JSONObject outContent = new JSONObject();
|
|
|
+ zh_cn.put("title", "飞书汇总提醒任务失败详情:");
|
|
|
+ sendTofeishu(body, content, post, zh_cn, outContent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查微信公众号封禁情况 封禁的情况下 需要重新换公众号重新生成
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "0 */1 * * * ?")
|
|
|
+ @SchedulerLock(name = "pangu:TaskInfoNotify", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
|
|
|
+ public void checkGhidStatus() {
|
|
|
+ // 获取待发送状态的封禁的任务
|
|
|
+ List<FosterwxCashScheduleTaskList> fosterwxCashScheduleTaskLists = fosterwxCashScheduleTaskListService.getBannedGhid();
|
|
|
+
|
|
|
+ Map<String, Object> body = new HashMap<>(1);
|
|
|
+ body.put("msg_type", "post");
|
|
|
+ JSONArray content = new JSONArray();
|
|
|
+
|
|
|
+ fosterwxCashScheduleTaskLists.forEach(fosterwxCashScheduleTaskList -> {
|
|
|
+ // 飞书通知消息设置
|
|
|
+ content.add(getJsonArray("任务ID:" + fosterwxCashScheduleTaskList.getId() + " 公众号: " + fosterwxCashScheduleTaskList.getGhId() + " 发送时间:" + fosterwxCashScheduleTaskList.getSendTime()));
|
|
|
+ // 重新创建
|
|
|
+ fosterwxCashScheduleTaskListService.create(fosterwxCashScheduleTaskList);
|
|
|
});
|
|
|
- JSONObject post = new JSONObject();
|
|
|
- JSONObject zh_cn = new JSONObject();
|
|
|
- JSONObject outContent = new JSONObject();
|
|
|
- zh_cn.put("title", "飞书汇总提醒任务失败详情:");
|
|
|
+
|
|
|
+ if (content.size() > 0) {
|
|
|
+ JSONObject post = new JSONObject();
|
|
|
+ JSONObject zh_cn = new JSONObject();
|
|
|
+ JSONObject outContent = new JSONObject();
|
|
|
+ zh_cn.put("title", "飞书汇总公众号封禁任务:");
|
|
|
+
|
|
|
+ // 重新生成提醒
|
|
|
+ content.add(getJsonArray("以上任务已重新生成!"));
|
|
|
+
|
|
|
+ sendTofeishu(body, content, post, zh_cn, outContent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送到飞书
|
|
|
+ * @param body
|
|
|
+ * @param content
|
|
|
+ * @param post
|
|
|
+ * @param zh_cn
|
|
|
+ * @param outContent
|
|
|
+ */
|
|
|
+ private void sendTofeishu(Map<String, Object> body, JSONArray content, JSONObject post, JSONObject zh_cn, JSONObject outContent) {
|
|
|
zh_cn.put("content", content);
|
|
|
post.put("zh_cn", zh_cn);
|
|
|
outContent.put("post", post);
|
|
|
body.put("content", outContent);
|
|
|
HttpEntity<Map<String, Object>> httpEntity = new HttpEntity<>(body, null);
|
|
|
- if (content.size() > 0) {
|
|
|
- JSONObject result = restTemplate.exchange(FEISHU_ROBOT, HttpMethod.POST, httpEntity, JSONObject.class).getBody();
|
|
|
- log.info("{}", result);
|
|
|
- } else {
|
|
|
- log.info("没有错误数据");
|
|
|
- }
|
|
|
+ // 发送飞书提醒
|
|
|
+ restTemplate.exchange(FEISHU_ROBOT, HttpMethod.POST, httpEntity, JSONObject.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 飞书提醒格式化
|
|
|
+ * @param text
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private JSONArray getJsonArray(String text) {
|
|
|
+ JSONArray rowData = new JSONArray();
|
|
|
+ rowData.add(new JSONObject() {
|
|
|
+ {
|
|
|
+ {
|
|
|
+ put("tag", "text");
|
|
|
+ put("text", text);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return rowData;
|
|
|
}
|
|
|
}
|