leon преди 4 години
родител
ревизия
d5f23d5b2e

+ 2 - 0
src/main/java/com/mokamrp/privates/constant/RedisKey.java

@@ -39,6 +39,8 @@ public class RedisKey {
     public static final String PanWxFosterStationInfo = "pan_wxfoster_station_info";
     //.盘古 活码报警记录
     public static final String PanPromoteNoticeRecode = "pan_promote_notice_recode:";
+    //.盘古 微信养号视频库
+    public static final String PanWxFosterTeachingVideo = "pan_wxfoster_teaching_video_info";
 
 }
 

+ 3 - 0
src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxTaskSchedule.java

@@ -104,6 +104,9 @@ public class FosterwxTaskSchedule extends Model<FosterwxTaskSchedule> {
      */
     private Integer delFlg;
 
+    @TableField(exist = false)
+    private Integer videoId;
+
     /**
      * 创建人
      */

+ 3 - 0
src/main/java/com/mokamrp/privates/service/impl/WorkEmployeeFriendcircleServiceImpl.java

@@ -78,6 +78,9 @@ public class WorkEmployeeFriendcircleServiceImpl extends ServiceImpl<WorkEmploye
             if (corp == null){
                 throw new Exception(row.get(i).get("corpName") + "不存在");
             }
+            if (!row.get(i).get("type").equals("1") && !row.get(i).get("type").equals("2")){
+                throw new Exception("发送类型不正确");
+            }
             Map<String, String> cell = row.get(i);
             WorkEmployeeFriendcircle workEmployeeFriendcircle = new WorkEmployeeFriendcircle();
             workEmployeeFriendcircle.setDeviceCode(row.get(i).get("deviceCode"));

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

@@ -43,7 +43,7 @@ public class CheckPromoteView {
 
     private final String feishu = "https://open.feishu.cn/open-apis/bot/v2/hook/d2b5556d-30fb-400e-b10f-cb9310dbc705";
 
-    @Scheduled(cron = "* */1 * * * ?") //.间隔 5分钟
+    @Scheduled(cron = "0 */2 * * * ?") //.间隔 5分钟
     @SchedulerLock(name = "pangu:CheckPromoteView", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
     public void execute() {
         System.out.println("[cronjob]:检测个微活码访问上限");

+ 52 - 0
src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxVideoInfo.java

@@ -0,0 +1,52 @@
+package com.mokamrp.privates.task.pangu;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.mokamrp.privates.constant.RedisKey;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxTeachingVideo;
+import com.mokamrp.privates.service.pangu.*;
+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.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class SyncFosterwxVideoInfo {
+
+    @Autowired
+    public FosterwxTaskScheduleService fosterwxTaskScheduleService;
+
+    @Autowired
+    public FosterwxStationService fosterwxStationService;
+
+    @Autowired
+    public FosterwxMobileService fosterwxMobileService;
+
+    @Autowired
+    public FosterwxMobileWxfriendService fosterwxMobileWxfriendService;
+
+    @Autowired
+    public StringRedisTemplate stringRedisTemplate;
+
+    @Autowired
+    public FosterwxTeachingVideoService fosterwxTeachingVideoService;
+
+    @Scheduled(cron = "0 */1 * * * ?")
+    @SchedulerLock(name = "pangu:SyncFosterwxVideoInfo", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
+    public void execute() {
+        System.out.println("[cronjob]:同步微信养号视频信息到REDIS");
+        List<FosterwxTeachingVideo> list = fosterwxTeachingVideoService.list(new QueryWrapper<FosterwxTeachingVideo>().eq("del_flg",1));
+        for (FosterwxTeachingVideo fosterwxTeachingVideo : list){
+            stringRedisTemplate.opsForHash().put(RedisKey.PanWxFosterTeachingVideo,fosterwxTeachingVideo.getId().toString(),JSON.toJSONString(fosterwxTeachingVideo));
+        }
+    }
+}

+ 20 - 15
src/main/java/com/mokamrp/privates/task/pangu/SyncNewFosterwxTask.java

@@ -6,8 +6,10 @@ import com.mokamrp.privates.constant.RedisKey;
 import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.entity.pangu.FosterwxTaskScheduleHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxTaskList;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxTaskSchedule;
 import com.mokamrp.privates.service.pangu.FosterwxStationService;
+import com.mokamrp.privates.service.pangu.FosterwxTaskListService;
 import com.mokamrp.privates.service.pangu.FosterwxTaskScheduleService;
 import net.javacrumbs.shedlock.core.SchedulerLock;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +31,9 @@ public class SyncNewFosterwxTask {
     public FosterwxStationService fosterwxStationService;
 
     @Autowired
+    public FosterwxTaskListService fosterwxTaskListService;
+
+    @Autowired
     public StringRedisTemplate stringRedisTemplate;
 
     @Scheduled(cron = "0 */1 * * * ?")
@@ -38,7 +43,7 @@ public class SyncNewFosterwxTask {
         List<LocalDateTime> dates = new ArrayList<>();
         dates.add(LocalDateTime.now().plusDays(-1)); //.昨天
         dates.add(LocalDateTime.now()); //.今天
-        for (Integer i =0;i<dates.size();i++){
+        for (Integer i = 0; i < dates.size(); i++) {
             LocalDateTime nowDate = dates.get(i);
             LocalDateTime startTime = LocalDateTime.of(nowDate.toLocalDate(), LocalTime.MIN);
             List<FosterwxStation> fosterwxStationList = fosterwxStationService.list();
@@ -52,7 +57,7 @@ public class SyncNewFosterwxTask {
                 fosterwxTaskScheduleHandle.setPagesize(99999);
                 ResHandle<List<FosterwxTaskSchedule>> resHandle = fosterwxTaskScheduleService.getList(fosterwxTaskScheduleHandle);
                 List<FosterwxTaskSchedule> fosterwxTaskScheduleList = resHandle.getList();
-                Map<String,List<FosterwxTaskSchedule>> saveRedis = new HashMap<>();
+                Map<String, List<FosterwxTaskSchedule>> saveRedis = new HashMap<>();
                 for (FosterwxTaskSchedule fosterwxTaskSchedule : fosterwxTaskScheduleList) {
                     String sendDate = fosterwxTaskSchedule.getSendDate().toString();
                     FosterwxTaskScheduleHandle handle = new FosterwxTaskScheduleHandle();
@@ -64,32 +69,32 @@ public class SyncNewFosterwxTask {
                         continue;
                     }
                     tasks.add(fosterwxTaskSchedule.getTaskId());
+                    //.视频信息
+                    FosterwxTaskList fosterwxTaskInfo = fosterwxTaskListService.getById(fosterwxTaskSchedule.getTaskId());
+                    fosterwxTaskSchedule.setVideoId(fosterwxTaskInfo.getVideoId());
+                    //.任务详细信息
                     fosterwxTaskSchedule.setMobileCount(taskInfo.getMobileCount());
                     fosterwxTaskSchedule.setComment(taskInfo.getComment());
-                    //.昨日数据直接设置为过期任务
-//                    if (i.equals(0)){
-//                        fosterwxTaskSchedule.setTaskStatus(2);
-//                    }
                     List<FosterwxTaskSchedule> sendDateDetail = saveRedis.get(sendDate);
-                    if (sendDateDetail == null){
+                    if (sendDateDetail == null) {
                         List<FosterwxTaskSchedule> firstAdd = new ArrayList<>();
                         firstAdd.add(fosterwxTaskSchedule);
-                        saveRedis.put(sendDate,firstAdd);
-                    }else{
+                        saveRedis.put(sendDate, firstAdd);
+                    } else {
                         sendDateDetail.add(fosterwxTaskSchedule);
-                        saveRedis.put(sendDate,sendDateDetail);
+                        saveRedis.put(sendDate, sendDateDetail);
                     }
                 }
                 for (Map.Entry<String, List<FosterwxTaskSchedule>> entry : saveRedis.entrySet()) {
                     stringRedisTemplate.opsForHash().put(RedisKey.PanWxfosterTask + stationId, entry.getKey(), JSON.toJSONString(entry.getValue()));
                 }
                 //.任务状态改为 已发送
-                if (tasks.size() > 0){
-                    FosterwxTaskSchedule save =  new FosterwxTaskSchedule();
+                if (tasks.size() > 0) {
+                    FosterwxTaskSchedule save = new FosterwxTaskSchedule();
                     save.setTaskSendStatus(1);
-                    fosterwxTaskScheduleService.update(save,new QueryWrapper<FosterwxTaskSchedule>()
-                            .eq("station_id",fosterwxStation.getId())
-                            .in("task_id",tasks)
+                    fosterwxTaskScheduleService.update(save, new QueryWrapper<FosterwxTaskSchedule>()
+                            .eq("station_id", fosterwxStation.getId())
+                            .in("task_id", tasks)
                             .apply("UNIX_TIMESTAMP(send_time) >= UNIX_TIMESTAMP('" + startTime + "')")
                             .apply("UNIX_TIMESTAMP(send_time) <= UNIX_TIMESTAMP('" + nowDate + "')")
                     );