|
@@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.poi.ss.usermodel.DateUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
@@ -102,4 +103,31 @@ public class RatAnalogTask {
|
|
|
.build();
|
|
|
hadVoList.add(hadDataLogVO);
|
|
|
}
|
|
|
+
|
|
|
+// @Scheduled(cron = "*/5 * * * * ?")
|
|
|
+ @Scheduled(cron = "0 0 0 */1 * ?")
|
|
|
+ public void addHadJob(){
|
|
|
+ List<HtAnalogData> list = null;
|
|
|
+ Integer index = 1;
|
|
|
+ Date date = new Date();
|
|
|
+ do {
|
|
|
+ Page<HtAnalogData> page = new Page<>(index, 4000);
|
|
|
+ page = htAnalogDataMapper.page(page, DateUtils.getDayStartTime(date),DateUtils.getDayEndTime(date),null);
|
|
|
+ list = page.getRecords();
|
|
|
+ if (!CollectionUtils.isEmpty(list)){
|
|
|
+ List<HtAnalogData> collect = list.stream().sorted(Comparator.comparing(HtAnalogData::getSiteId)).collect(Collectors.toList());
|
|
|
+ List<List<HtAnalogData>> rsList = Lists.partition(collect, 2000);
|
|
|
+ for (List<HtAnalogData> logVOS:rsList) {
|
|
|
+ ArrayList<HtAnalogData> distant = logVOS.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(HtAnalogData::getSiteId))), ArrayList::new));
|
|
|
+ List<Integer> siteList = distant.stream().map(HtAnalogData::getSiteId).collect(Collectors.toList());
|
|
|
+ HadDataLog hadDataLog = new HadDataLog();
|
|
|
+ hadDataLog.setDataTime(DateUtils.getDayStartTime(date));
|
|
|
+ hadDataLog.setSiteIdList(JsonUtils.toJson(siteList));
|
|
|
+ hadDataLog.setHadData(JsonUtils.toJson(logVOS));
|
|
|
+ hadDataLogMapper.insert(hadDataLog);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }while (!CollectionUtils.isEmpty(list));
|
|
|
+ log.info("处理完成");
|
|
|
+ }
|
|
|
}
|