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