DeviateAnalysisTask.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package com.gyee.power.fitting.schedule;
  2. import com.gyee.power.fitting.common.constants.Constants;
  3. import com.gyee.power.fitting.common.spring.InitialRunner;
  4. import com.gyee.power.fitting.common.util.DateUtil;
  5. import com.gyee.power.fitting.model.Powerfittinganalysis;
  6. import com.gyee.power.fitting.model.Windturbine;
  7. import com.gyee.power.fitting.service.PowerfittinganalysisService;
  8. import com.gyee.power.fitting.service.custom.curve.DataPrepareService;
  9. import com.gyee.power.fitting.service.custom.curve.DataProcessService;
  10. import org.springframework.scheduling.annotation.Scheduled;
  11. import org.springframework.stereotype.Component;
  12. import javax.annotation.Resource;
  13. import java.util.Date;
  14. import java.util.List;
  15. import java.util.Map;
  16. import java.util.stream.Collectors;
  17. @Component
  18. public class DeviateAnalysisTask {
  19. @Resource
  20. private DataPrepareService prepareService;
  21. @Resource
  22. private DataProcessService processService;
  23. @Resource
  24. private PowerfittinganalysisService powerService;
  25. /**
  26. * 元数据缓存
  27. */
  28. @Scheduled(cron = "0 0 1 1 * ?") //每月1号凌晨1点执行
  29. public void dataPrepare(){
  30. Date month = DateUtil.addMonths(new Date(), -1);
  31. Date st = DateUtil.dateZeroFormat(month); //上月1号0点值
  32. Date et = DateUtil.dateZeroFormat(new Date()); //当月1号0点值
  33. Map<String, List<Windturbine>> wpMap = InitialRunner.wpMap;
  34. wpMap.forEach((k, v) -> {
  35. List<String> wtIds = v.stream().map(m -> m.getId()).collect(Collectors.toList());
  36. prepareService.dataPrepare(k, wtIds, st.getTime(), et.getTime(), 10 * 60);
  37. });
  38. }
  39. /**
  40. * 根据缓存的文件进行数据预处理
  41. */
  42. @Scheduled(cron = "0 0 22 1 * ?") //每月1号22点执行
  43. public void dataProcess(){
  44. List<Powerfittinganalysis> list = powerService.selectListByIsCal(Constants.DATA_PROCESS, 0);
  45. if (list == null || list.size() == 0)
  46. return;
  47. List<String> ids = list.stream().map(m -> m.getId()).collect(Collectors.toList());
  48. processService.dataProcess(ids, 25.0, 0.0, 2500.0, 0.0, true, true, true, true, true, true, 3);
  49. }
  50. }