提交 | 用户 | 时间
|
ee3d9f
|
1 |
package com.iailab.module.shasteel.job.task; |
潘 |
2 |
|
5c8ce5
|
3 |
import com.iailab.module.model.api.mcs.McsApi; |
潘 |
4 |
import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; |
ee3d9f
|
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; |
5c8ce5
|
8 |
import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; |
ee3d9f
|
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; |
5c8ce5
|
14 |
import org.springframework.util.CollectionUtils; |
ee3d9f
|
15 |
|
5c8ce5
|
16 |
import java.util.*; |
ee3d9f
|
17 |
|
潘 |
18 |
/** |
|
19 |
* 压空,计算机组比功率,计算结果写入测点 |
|
20 |
* 定时出发,5 0/1 * * * ? |
|
21 |
* |
|
22 |
* @author PanZhibao |
|
23 |
* @Description |
|
24 |
* @createTime 2024年12月31日 |
|
25 |
*/ |
|
26 |
@Component("runScheduleAirTask") |
|
27 |
public class RunScheduleAirTask implements ITask { |
|
28 |
private Logger logger = LoggerFactory.getLogger(getClass()); |
|
29 |
|
|
30 |
@Autowired |
5c8ce5
|
31 |
private McsApi mcsApi; |
潘 |
32 |
|
|
33 |
@Autowired |
ee3d9f
|
34 |
private MdkApi mdkApi; |
潘 |
35 |
|
|
36 |
@Override |
|
37 |
public void run(String params) { |
|
38 |
logger.info("RunScheduleAirTask,参数为:{}", params); |
|
39 |
try { |
|
40 |
Calendar calendar = Calendar.getInstance(); |
5c8ce5
|
41 |
calendar.set(Calendar.MILLISECOND, 0); |
潘 |
42 |
calendar.set(Calendar.SECOND, 0); |
ee3d9f
|
43 |
Date scheduleTime = calendar.getTime(); |
潘 |
44 |
if (StringUtils.isEmpty(params)) { |
|
45 |
logger.info("参数为空"); |
|
46 |
return; |
|
47 |
} |
5c8ce5
|
48 |
|
潘 |
49 |
// 根据条件查找方案 |
7c1d91
|
50 |
List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); |
5c8ce5
|
51 |
if (CollectionUtils.isEmpty(schemeList)) { |
潘 |
52 |
logger.info("方案为空"); |
|
53 |
return; |
|
54 |
} |
|
55 |
for (StScheduleSchemeDTO scheme : schemeList) { |
ee3d9f
|
56 |
MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); |
5c8ce5
|
57 |
dto.setScheduleTime(scheduleTime); |
潘 |
58 |
dto.setScheduleCode(scheme.getCode()); |
ee3d9f
|
59 |
MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); |
潘 |
60 |
|
|
61 |
// 结果写入测点 |
|
62 |
|
|
63 |
|
|
64 |
} |
|
65 |
logger.info(params + "调度方案执行完成"); |
|
66 |
} catch (Exception ex) { |
|
67 |
logger.error("RunScheduleAirTask运行异常"); |
|
68 |
ex.printStackTrace(); |
|
69 |
} |
|
70 |
logger.info("RunScheduleAirTask运行完成"); |
|
71 |
} |
|
72 |
} |