|
|
@@ -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;
|
|
|
+ }
|
|
|
}
|