leon hace 5 años
padre
commit
4c0bc3271c

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

@@ -27,5 +27,10 @@ public class RedisKey {
     public static final String WorkEmployeeFriendcircleJob = "work_employee_friendcircle_job";
     //.盘古 微信养号任务
     public static final String PanWxfosterTask = "pan_wxfoster_task:";
+    //.盘古 微信养号站点内账号列表
+    public static final String PanWxFosterMobileInfo = "pan_wxfoster_mobile_info:";
+    //.盘古 微信养号账号修改异步操作
+    public static final String PanWxFosterMobileSync = "pan_wxfoster_mobile_sync";
+
 }
 

+ 10 - 9
src/main/java/com/mokamrp/privates/controller/pangu/CustserviceController.java

@@ -73,15 +73,16 @@ public class CustserviceController extends BaseController<Custservice> {
         if (bindingResult.hasErrors()) {
             return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
         }
-        QueryWrapper<Custservice> QueryWrapper = new QueryWrapper<>();
-        String[] ids = delHandle.getIds().split(",");
-        QueryWrapper.in("id", ids);
-        boolean res = service.remove(QueryWrapper);
-        if (!res) {
-            this.sync();
-            return AjaxResult.error("删除失败");
-        }
-        return AjaxResult.success(Constants.SUCCESS, res);
+        return AjaxResult.error("删除失败");
+//        QueryWrapper<Custservice> QueryWrapper = new QueryWrapper<>();
+//        String[] ids = delHandle.getIds().split(",");
+//        QueryWrapper.in("id", ids);
+//        boolean res = service.remove(QueryWrapper);
+//        if (!res) {
+//            this.sync();
+//            return AjaxResult.error("删除失败");
+//        }
+//        return AjaxResult.success(Constants.SUCCESS, res);
     }
 
     @PostMapping("/add")

+ 69 - 0
src/main/java/com/mokamrp/privates/tast/pangu/SyncFosterwxEdit.java

@@ -0,0 +1,69 @@
+package com.mokamrp.privates.tast.pangu;
+
+import com.alibaba.fastjson.JSON;
+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.service.pangu.FosterwxMobileService;
+import com.mokamrp.privates.service.pangu.FosterwxStationService;
+import com.mokamrp.privates.service.pangu.FosterwxTaskScheduleService;
+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 SyncFosterwxEdit {
+
+    @Autowired
+    public FosterwxTaskScheduleService fosterwxTaskScheduleService;
+
+    @Autowired
+    public FosterwxStationService fosterwxStationService;
+
+    @Autowired
+    public FosterwxMobileService fosterwxMobileService;
+
+    @Autowired
+    public StringRedisTemplate stringRedisTemplate;
+
+    @Scheduled(cron = "*/5 * * * * ?")
+    public void execute() {
+        System.out.println("[cronjob]:异步执行微信养号账号信息修改/新增操作");
+        Integer cnt = 1;
+        while (true){
+            cnt ++;
+            if (cnt > 1000){
+                break;
+            }
+            try {
+                Thread.sleep(200);
+                String info = stringRedisTemplate.opsForList().rightPop(RedisKey.PanWxFosterMobileSync);
+                if (info == null || info.isEmpty()){
+                    continue;
+                }
+                FosterwxMobile fosterwxMobile = JSON.parseObject(info,FosterwxMobile.class);
+                if (fosterwxMobile.getStationId().equals(0)){
+                    continue;
+                }
+                if (fosterwxMobile.getId().equals(0)){
+                    //.新增
+                    fosterwxMobileService.save(fosterwxMobile);
+                }else{
+                    //.更新
+                    fosterwxMobileService.update(fosterwxMobile,new QueryWrapper<FosterwxMobile>().eq("id",fosterwxMobile.getId()));
+                }
+                //.立刻更新账号REDIS
+                List<FosterwxMobile> fosterwxMobileList = fosterwxMobileService.list(new QueryWrapper<FosterwxMobile>().eq("station_id",fosterwxMobile.getStationId()));
+                stringRedisTemplate.opsForValue().set(RedisKey.PanWxFosterMobileInfo+fosterwxMobile.getStationId(),JSON.toJSONString(fosterwxMobileList));
+            } catch (InterruptedException ie) {
+                Thread.currentThread().interrupt();
+            }
+        }
+    }
+}

+ 58 - 0
src/main/java/com/mokamrp/privates/tast/pangu/SyncFosterwxMobile.java

@@ -0,0 +1,58 @@
+package com.mokamrp.privates.tast.pangu;
+
+import com.alibaba.fastjson.JSON;
+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.FosterwxMobile;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxTaskSchedule;
+import com.mokamrp.privates.service.pangu.FosterwxMobileService;
+import com.mokamrp.privates.service.pangu.FosterwxStationService;
+import com.mokamrp.privates.service.pangu.FosterwxTaskScheduleService;
+import org.checkerframework.checker.units.qual.A;
+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.text.SimpleDateFormat;
+import java.util.*;
+
+@Component
+public class SyncFosterwxMobile {
+
+    @Autowired
+    public FosterwxTaskScheduleService fosterwxTaskScheduleService;
+
+    @Autowired
+    public FosterwxStationService fosterwxStationService;
+
+    @Autowired
+    public FosterwxMobileService fosterwxMobileService;
+
+    @Autowired
+    public StringRedisTemplate stringRedisTemplate;
+
+    @Scheduled(cron = "0 */1 * * * ?")
+    public void execute() {
+        System.out.println("[cronjob]:同步微信养号站点账号到REDIS");
+        List<FosterwxMobile> fosterwxMobileList = fosterwxMobileService.list();
+        Map<String,List<FosterwxMobile>> add = new HashMap<>();
+        for (FosterwxMobile fosterwxMobile : fosterwxMobileList){
+            Integer stationId = fosterwxMobile.getStationId();
+            if (add.get(stationId.toString()) == null || add.get(stationId.toString()).isEmpty()){
+                List<FosterwxMobile> data = new ArrayList<>();
+                data.add(fosterwxMobile);
+                add.put(stationId.toString(),data);
+            }else{
+                List<FosterwxMobile> data = add.get(stationId.toString());
+                data.add(fosterwxMobile);
+                add.put(stationId.toString(),data);
+            }
+        }
+        for(Map.Entry<String,List<FosterwxMobile>> entry : add.entrySet()){
+            stringRedisTemplate.opsForValue().set(RedisKey.PanWxFosterMobileInfo+entry.getKey(),JSON.toJSONString(entry.getValue()));
+        }
+    }
+}