leon 5 gadi atpakaļ
vecāks
revīzija
dd8d7eb9de

+ 1 - 1
src/main/java/com/mokamrp/privates/controller/WorkEmployeeFriendcircleController.java

@@ -63,7 +63,7 @@ public class WorkEmployeeFriendcircleController extends BaseController<WorkEmplo
     @PostMapping("/import")
     public Object uploadFile(@RequestBody MultipartFile file, @AuthUser User authUser) {
         Map<String, Object> map = new HashMap<>(16);
-        Map<Integer, String> feild = new HashMap<>(5);
+        Map<Integer, String> feild = new HashMap<>(8);
         feild.put(0, "deviceCode");
         feild.put(1, "corpId");
         feild.put(2, "type");

+ 15 - 0
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxStationController.java

@@ -1,8 +1,10 @@
 package com.mokamrp.privates.controller.pangu;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.mokamrp.privates.constant.Constants;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.entity.AddHandle;
+import com.mokamrp.privates.entity.EditHandle;
 import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.mokamrp.privates.entity.pangu.LoginStationHandle;
 import com.mokamrp.privates.help.AjaxResult;
@@ -49,6 +51,19 @@ public class FosterwxStationController extends BaseController<FosterwxStation> {
         return AjaxResult.success(res);
     }
 
+    @PostMapping("/edit")
+    public Object edit(@Valid @RequestBody EditHandle<FosterwxStation> editHandle, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
+        }
+        this.onUpdate(editHandle);
+        String boxShareUrl = editHandle.getRaw().getBoxShareUrl();
+        if (boxShareUrl != null && !boxShareUrl.isEmpty()){
+            editHandle.getRaw().setBoxShareUrl(fosterwxStationService.makeBoxShareUrl(boxShareUrl,editHandle.getIds()));
+        }
+        service.update(editHandle.getRaw(), new QueryWrapper<FosterwxStation>().in("id", editHandle.getIds()));
+        return AjaxResult.success(Constants.SUCCESS, true);
+    }
 
     @PostMapping("/addPro")
     public Object addPro(@Valid @RequestBody AddHandle<FosterwxStation> addHandle, @AuthUser User user, BindingResult bindingResult) {

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

@@ -139,6 +139,9 @@ public class FosterwxMobile extends Model<FosterwxMobile> {
     @TableField(exist = false)
     private List<FosterwxMobileWxfriend> friend;
 
+    @TableField(exist = false)
+    private Object friends;
+
     /**
      * 任务开始时间
      */

+ 2 - 0
src/main/java/com/mokamrp/privates/service/pangu/FosterwxStationService.java

@@ -23,4 +23,6 @@ public interface FosterwxStationService extends IService<FosterwxStation> {
     public Map<String, Object> login(LoginStationHandle loginStationHandle);
     //.@Leon 通过站点ID和TOKEN获取用户登录信息
     public FosterwxStation getAuthInfo(String token);
+    //.@leon 加密小程序分享链接
+    public String makeBoxShareUrl(String boxShareUrl,String stationId);
 }

+ 14 - 0
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxStationServiceImpl.java

@@ -10,6 +10,7 @@ import com.mokamrp.privates.mapper.pangu.FosterwxStationMapper;
 import com.mokamrp.privates.service.pangu.FosterwxStationService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.mokamrp.privates.utils.StringUtils;
+import com.mokamrp.privates.utils.sign.Base64;
 import com.mokamrp.privates.utils.sign.Md5Utils;
 import io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueue;
 import org.springframework.data.redis.core.StringRedisTemplate;
@@ -97,4 +98,17 @@ public class FosterwxStationServiceImpl extends ServiceImpl<FosterwxStationMappe
         FosterwxStation fosterwxStation = JSON.parseObject(jsonStr,FosterwxStation.class);
         return fosterwxStation;
     }
+
+    /**
+     * 加密小程序分享链接
+     * @param boxShareUrl
+     * @param stationId
+     * @return
+     */
+    public String makeBoxShareUrl(String boxShareUrl,String stationId){
+        String key = StringUtils.getRandomString(10)+stationId+StringUtils.getRandomString(5);
+        byte[] keyB = key.getBytes();
+        String newBoxShareUrl = boxShareUrl + "?station="+ Base64.encode(keyB);
+        return newBoxShareUrl;
+    }
 }

+ 32 - 1
src/main/java/com/mokamrp/privates/tast/pangu/SyncFosterwxEdit.java

@@ -3,8 +3,11 @@ 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.entity.pangu.AddFosterwxMobileHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
 import com.mokamrp.privates.service.pangu.FosterwxMobileService;
+import com.mokamrp.privates.service.pangu.FosterwxMobileWxfriendService;
 import com.mokamrp.privates.service.pangu.FosterwxStationService;
 import com.mokamrp.privates.service.pangu.FosterwxTaskScheduleService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,9 +33,14 @@ public class SyncFosterwxEdit {
     public FosterwxMobileService fosterwxMobileService;
 
     @Autowired
+    public FosterwxMobileWxfriendService fosterwxMobileWxfriendService;
+
+    @Autowired
     public StringRedisTemplate stringRedisTemplate;
 
-    @Scheduled(cron = "*/5 * * * * ?")
+    public List<FosterwxMobileWxfriend> fosterwxMobileWxfriendList;
+
+    @Scheduled(cron = "* */1 * * * ?")
     public void execute() {
         System.out.println("[cronjob]:异步执行微信养号账号信息修改/新增操作");
         Integer cnt = 1;
@@ -58,12 +66,35 @@ public class SyncFosterwxEdit {
                     //.更新
                     fosterwxMobileService.update(fosterwxMobile,new QueryWrapper<FosterwxMobile>().eq("id",fosterwxMobile.getId()));
                 }
+                //.更新微信好友信息
+                if (fosterwxMobile.getFriend() != null){
+                    AddFosterwxMobileHandle addFosterwxMobileHandle = new AddFosterwxMobileHandle();
+                    addFosterwxMobileHandle.setMobileId(fosterwxMobile.getId());
+                    addFosterwxMobileHandle.setFriends(fosterwxMobile.getFriend());
+                    fosterwxMobileWxfriendService.removeAndAdd(addFosterwxMobileHandle);
+                }
                 //.立刻更新账号REDIS
                 List<FosterwxMobile> fosterwxMobileList = fosterwxMobileService.list(new QueryWrapper<FosterwxMobile>().eq("station_id",fosterwxMobile.getStationId()));
+                List<Integer> mobileIds = new ArrayList<>();
+                for (FosterwxMobile obj : fosterwxMobileList){
+                    mobileIds.add(obj.getId());
+                }
+                this.fosterwxMobileWxfriendList = fosterwxMobileWxfriendService.list(new QueryWrapper<FosterwxMobileWxfriend>().in("mobile_id",mobileIds));
+                List<FosterwxMobileWxfriend> friends = this.getMobileWxfriendByMobileId(fosterwxMobile.getId());
+                fosterwxMobile.setFriend(friends);
                 stringRedisTemplate.opsForValue().set(RedisKey.PanWxFosterMobileInfo+fosterwxMobile.getStationId(),JSON.toJSONString(fosterwxMobileList));
             } catch (InterruptedException ie) {
                 Thread.currentThread().interrupt();
             }
         }
     }
+    public List<FosterwxMobileWxfriend> getMobileWxfriendByMobileId(Integer mobileId){
+        List<FosterwxMobileWxfriend> res = new ArrayList<FosterwxMobileWxfriend>();
+        for (FosterwxMobileWxfriend fosterwxMobileWxfriend : this.fosterwxMobileWxfriendList){
+            if (fosterwxMobileWxfriend.getMobileId().equals(mobileId)){
+                res.add(fosterwxMobileWxfriend);
+            }
+        }
+        return res;
+    }
 }

+ 33 - 9
src/main/java/com/mokamrp/privates/tast/pangu/SyncFosterwxMobile.java

@@ -1,13 +1,16 @@
 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.entity.ResHandle;
 import com.mokamrp.privates.entity.pangu.FosterwxTaskScheduleHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
 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.FosterwxMobileWxfriendService;
 import com.mokamrp.privates.service.pangu.FosterwxStationService;
 import com.mokamrp.privates.service.pangu.FosterwxTaskScheduleService;
 import org.checkerframework.checker.units.qual.A;
@@ -32,27 +35,48 @@ public class SyncFosterwxMobile {
     public FosterwxMobileService fosterwxMobileService;
 
     @Autowired
+    public FosterwxMobileWxfriendService fosterwxMobileWxfriendService;
+
+    @Autowired
     public StringRedisTemplate stringRedisTemplate;
 
-    @Scheduled(cron = "0 */1 * * * ?")
+    public List<FosterwxMobileWxfriend> fosterwxMobileWxfriendList;
+
+    public List<FosterwxMobile> fosterwxMobileList;
+
+    @Scheduled(cron = "* */1 * * * ?")
     public void execute() {
         System.out.println("[cronjob]:同步微信养号站点账号到REDIS");
-        List<FosterwxMobile> fosterwxMobileList = fosterwxMobileService.list();
+        List<Integer> mobileIds = new ArrayList<>();
+        this.fosterwxMobileList = fosterwxMobileService.list();
+        //.查询所有账号下微信好友
+        this.fosterwxMobileWxfriendList = fosterwxMobileWxfriendService.list();
         Map<String,List<FosterwxMobile>> add = new HashMap<>();
-        for (FosterwxMobile fosterwxMobile : fosterwxMobileList){
+        for (FosterwxMobile fosterwxMobile : this.fosterwxMobileList){
             Integer stationId = fosterwxMobile.getStationId();
+            List<FosterwxMobile> data = new ArrayList<>();
             if (add.get(stationId.toString()) == null || add.get(stationId.toString()).isEmpty()){
-                List<FosterwxMobile> data = new ArrayList<>();
-                data.add(fosterwxMobile);
-                add.put(stationId.toString(),data);
+                data = new ArrayList<FosterwxMobile>();
             }else{
-                List<FosterwxMobile> data = add.get(stationId.toString());
-                data.add(fosterwxMobile);
-                add.put(stationId.toString(),data);
+                data = add.get(stationId.toString());
             }
+            List<FosterwxMobileWxfriend> friends = this.getMobileWxfriendByMobileId(fosterwxMobile.getId());
+            fosterwxMobile.setFriends(friends);
+            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()));
         }
     }
+
+    public List<FosterwxMobileWxfriend> getMobileWxfriendByMobileId(Integer mobileId){
+        List<FosterwxMobileWxfriend> res = new ArrayList<FosterwxMobileWxfriend>();
+        for (FosterwxMobileWxfriend fosterwxMobileWxfriend : this.fosterwxMobileWxfriendList){
+            if (fosterwxMobileWxfriend.getMobileId().equals(mobileId)){
+                res.add(fosterwxMobileWxfriend);
+            }
+        }
+        return res;
+    }
 }

BIN
src/main/resources/static/导入站点绑定公众号&小程序.xls