123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package com.gyee.power.fitting.schedule;
- import com.gyee.power.fitting.common.constants.Constants;
- import com.gyee.power.fitting.common.spring.InitialRunner;
- import com.gyee.power.fitting.common.util.DateUtil;
- import com.gyee.power.fitting.model.Powerfittinganalysis;
- import com.gyee.power.fitting.model.Windturbine;
- import com.gyee.power.fitting.service.PowerfittinganalysisService;
- import com.gyee.power.fitting.service.custom.curve.DataPrepareService;
- import com.gyee.power.fitting.service.custom.curve.DataProcessService;
- import org.springframework.scheduling.annotation.Scheduled;
- import org.springframework.stereotype.Component;
- import javax.annotation.Resource;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- import java.util.stream.Collectors;
- @Component
- public class DeviateAnalysisTask {
- @Resource
- private DataPrepareService prepareService;
- @Resource
- private DataProcessService processService;
- @Resource
- private PowerfittinganalysisService powerService;
- /**
- * 元数据缓存
- */
- @Scheduled(cron = "0 0 1 1 * ?") //每月1号凌晨1点执行
- public void dataPrepare(){
- Date month = DateUtil.addMonths(new Date(), -1);
- Date st = DateUtil.dateZeroFormat(month); //上月1号0点值
- Date et = DateUtil.dateZeroFormat(new Date()); //当月1号0点值
- Map<String, List<Windturbine>> wpMap = InitialRunner.wpMap;
- wpMap.forEach((k, v) -> {
- List<String> wtIds = v.stream().map(m -> m.getId()).collect(Collectors.toList());
- prepareService.dataPrepare(k, wtIds, st.getTime(), et.getTime(), 10 * 60);
- });
- }
- /**
- * 根据缓存的文件进行数据预处理
- */
- @Scheduled(cron = "0 0 22 1 * ?") //每月1号22点执行
- public void dataProcess(){
- List<Powerfittinganalysis> list = powerService.selectListByIsCal(Constants.DATA_PROCESS, 0);
- if (list == null || list.size() == 0)
- return;
- List<String> ids = list.stream().map(m -> m.getId()).collect(Collectors.toList());
- processService.dataProcess(ids, 25.0, 0.0, 2500.0, 0.0, true, true, true, true, true, true, 3);
- }
- }
|