|
|
@@ -0,0 +1,75 @@
|
|
|
+package com.mokamrp.privates.tast.pangu;
|
|
|
+
|
|
|
+import com.mokamrp.privates.entity.ResHandle;
|
|
|
+import com.mokamrp.privates.entity.pangu.GetForsterwxMobileHandle;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
|
|
|
+import com.mokamrp.privates.service.pangu.FosterwxMobileService;
|
|
|
+import com.mokamrp.privates.service.pangu.FosterwxStationService;
|
|
|
+import com.mokamrp.privates.service.pangu.FosterwxTaskScheduleService;
|
|
|
+import com.mokamrp.privates.utils.Cmd;
|
|
|
+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.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+@Component
|
|
|
+public class StationMobileNotice {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public FosterwxTaskScheduleService fosterwxTaskScheduleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public FosterwxStationService fosterwxStationService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public FosterwxMobileService fosterwxMobileService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public StringRedisTemplate stringRedisTemplate;
|
|
|
+
|
|
|
+ private String feishu = "https://open.feishu.cn/open-apis/bot/v2/hook/60fa2762-e0a0-4eb8-97ce-8dc0938057de";
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 0 9 * * ?")
|
|
|
+ public void execute() {
|
|
|
+ System.out.println("[cronjob]:每日站点账号新增统计通知");
|
|
|
+ GetForsterwxMobileHandle getForsterwxMobileHandle = new GetForsterwxMobileHandle();
|
|
|
+ String lastDay = LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ getForsterwxMobileHandle.setCreateDate(lastDay);
|
|
|
+ getForsterwxMobileHandle.setPage(1);
|
|
|
+ getForsterwxMobileHandle.setPagesize(9999);
|
|
|
+ ResHandle<List<FosterwxMobile>> res = fosterwxMobileService.getList(getForsterwxMobileHandle);
|
|
|
+ List<FosterwxMobile> list = res.getList();
|
|
|
+ Map<String,String> sendMap = new HashMap<>();
|
|
|
+ List<FosterwxStation> fosterwxStationList = fosterwxStationService.list();
|
|
|
+ for (FosterwxMobile fosterwxMobile : list){
|
|
|
+ FosterwxStation fosterwxStationInfo = this.getStationInfo(fosterwxMobile.getStationId(),fosterwxStationList);
|
|
|
+ String stationNm = fosterwxStationInfo.getStationName();
|
|
|
+ if (sendMap.get(stationNm) == null || sendMap.get(stationNm).isEmpty()){
|
|
|
+ sendMap.put(stationNm,fosterwxMobile.getMobileCode().toString());
|
|
|
+ }else{
|
|
|
+ sendMap.put(stationNm,sendMap.get(stationNm)+"、"+fosterwxMobile.getMobileCode().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String sendMsg = "[站点账号新增 "+lastDay+"]\r\n";
|
|
|
+ for (String key : sendMap.keySet()){
|
|
|
+ sendMsg += "站点编号:"+key+" ";
|
|
|
+ sendMsg += "手机编号:"+sendMap.get(key)+"\r\n";
|
|
|
+ }
|
|
|
+ Cmd.sendFeishuMsg(feishu, sendMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ public FosterwxStation getStationInfo(Integer stationId,List<FosterwxStation> rows){
|
|
|
+ for (FosterwxStation fosterwxStation : rows){
|
|
|
+ if (fosterwxStation.getId().equals(stationId)){
|
|
|
+ return fosterwxStation;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|