|
@@ -0,0 +1,54 @@
|
|
|
+package com.tzld.longarticle.recommend.server.service;
|
|
|
+
|
|
|
+import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
|
|
|
+import com.tzld.longarticle.recommend.server.model.dto.NotPublishPlan;
|
|
|
+import com.tzld.longarticle.recommend.server.util.DateUtils;
|
|
|
+import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
|
|
|
+import com.xxl.job.core.biz.model.ReturnT;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class XxlJobService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AigcBaseMapper aigcBaseMapper;
|
|
|
+
|
|
|
+ @XxlJob("checkPublishPlan")
|
|
|
+ public ReturnT<String> checkPublishPlan(String param) {
|
|
|
+ List<NotPublishPlan> notPublishPlan = aigcBaseMapper.getNotPublishPlan();
|
|
|
+ for (NotPublishPlan publishPlan : notPublishPlan) {
|
|
|
+ Long now = System.currentTimeMillis();
|
|
|
+ int nowHour = DateUtils.getHourByTimestamp(now / 1000);
|
|
|
+ int nowMinute = DateUtils.getMinuteByTimestamp(now / 1000);
|
|
|
+ if (!StringUtils.hasText(publishPlan.getPublishWindowStart())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String[] planTime = publishPlan.getPublishWindowStart().split(":");
|
|
|
+ int planHour = Integer.parseInt(planTime[0]);
|
|
|
+ int planMinute = Integer.parseInt(planTime[1]);
|
|
|
+ if (nowHour - planHour == 1 && nowMinute > planMinute) {
|
|
|
+ sendFeishuPublishPlanNotPushWarn(publishPlan);
|
|
|
+ } else if (nowHour - planHour > 1) {
|
|
|
+ sendFeishuPublishPlanNotPushWarn(publishPlan);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendFeishuPublishPlanNotPushWarn(NotPublishPlan publishPlan) {
|
|
|
+ FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
|
|
|
+ "发布计划超1H未发送完成\n"
|
|
|
+ + "发布计划ID: " + publishPlan.getPlanId() + "\n"
|
|
|
+ + "发布计划名称: " + publishPlan.getPlanName() + "\n"
|
|
|
+ + "发布时间: " + publishPlan.getPublishWindowStart() + "\n"
|
|
|
+ + "<at user_id=\"all\">所有人</at> ");
|
|
|
+ }
|
|
|
+
|
|
|
+}
|