提交 | 用户 | 时间
|
b50a43
|
1 |
package com.iailab.module.shasteel.job.task; |
J |
2 |
|
|
3 |
import com.iailab.module.model.api.mcs.McsApi; |
|
4 |
import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; |
|
5 |
import com.iailab.module.model.api.mdk.MdkApi; |
|
6 |
import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; |
|
7 |
import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; |
|
8 |
import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; |
|
9 |
import org.apache.commons.lang3.StringUtils; |
|
10 |
import org.slf4j.Logger; |
|
11 |
import org.slf4j.LoggerFactory; |
|
12 |
import org.springframework.beans.factory.annotation.Autowired; |
|
13 |
import org.springframework.stereotype.Component; |
|
14 |
import org.springframework.util.CollectionUtils; |
|
15 |
|
|
16 |
import javax.annotation.Resource; |
|
17 |
import java.util.*; |
|
18 |
|
|
19 |
/** |
17d968
|
20 |
* 压缩空气运行指标(周) |
潘 |
21 |
* 最近7天的数据 |
|
22 |
* 每天更新,20 0 0 1/1 * ? |
b50a43
|
23 |
* |
J |
24 |
* @author PanZhibao |
|
25 |
* @Description |
17d968
|
26 |
* @createTime 2025年01月03日 |
b50a43
|
27 |
*/ |
17d968
|
28 |
@Component("runScheduleAirIndexWeekTask") |
潘 |
29 |
public class RunScheduleAirIndexWeekTask implements ITask { |
b50a43
|
30 |
private Logger logger = LoggerFactory.getLogger(getClass()); |
J |
31 |
|
|
32 |
@Resource |
|
33 |
private McsApi mcsApi; |
|
34 |
|
|
35 |
@Autowired |
|
36 |
private MdkApi mdkApi; |
|
37 |
|
|
38 |
@Override |
|
39 |
public void run(String params) { |
17d968
|
40 |
logger.info("RunScheduleAirIndexWeekTask,参数为:{}", params); |
b50a43
|
41 |
try { |
J |
42 |
Calendar calendar = Calendar.getInstance(); |
|
43 |
calendar.set(Calendar.MILLISECOND, 0); |
|
44 |
calendar.set(Calendar.SECOND, 0); |
|
45 |
Date scheduleTime = calendar.getTime(); |
|
46 |
if (StringUtils.isEmpty(params)) { |
|
47 |
logger.info("参数为空"); |
|
48 |
return; |
|
49 |
} |
|
50 |
// 根据条件查找方案 |
|
51 |
List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); |
|
52 |
if (CollectionUtils.isEmpty(schemeList)) { |
|
53 |
logger.info("方案为空"); |
|
54 |
return; |
|
55 |
} |
|
56 |
for (StScheduleSchemeDTO scheme : schemeList) { |
|
57 |
MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); |
|
58 |
dto.setScheduleTime(scheduleTime); |
|
59 |
dto.setScheduleCode(scheme.getCode()); |
d8b11e
|
60 |
MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); |
b50a43
|
61 |
// 结果写入测点 |
J |
62 |
mdkApi.scheduleModelOut(mdkScheduleRespDTO); |
|
63 |
} |
|
64 |
logger.info(params + "调度方案执行完成"); |
|
65 |
} catch (Exception ex) { |
17d968
|
66 |
logger.error("RunScheduleAirIndexWeekTask运行异常"); |
b50a43
|
67 |
ex.printStackTrace(); |
J |
68 |
} |
17d968
|
69 |
logger.info("RunScheduleAirIndexWeekTask运行完成"); |
b50a43
|
70 |
} |
J |
71 |
} |