提交 | 用户 | 时间
|
c6686e
|
1 |
package com.iailab.module.shasteel.job.task; |
潘 |
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 java.util.Calendar; |
|
17 |
import java.util.Date; |
|
18 |
import java.util.List; |
|
19 |
|
|
20 |
/** |
|
21 |
* 压缩空气产消比例 |
cc5af7
|
22 |
* 定时触发,30 0/1 * * * ? |
c6686e
|
23 |
* |
潘 |
24 |
* @author PanZhibao |
|
25 |
* @Description |
|
26 |
* @createTime 2025年01月06日 |
|
27 |
*/ |
|
28 |
@Component("runScheduleAirRatioTask") |
|
29 |
public class RunScheduleAirRatioTask implements ITask { |
|
30 |
private Logger logger = LoggerFactory.getLogger(getClass()); |
|
31 |
|
|
32 |
@Autowired |
|
33 |
private McsApi mcsApi; |
|
34 |
|
|
35 |
@Autowired |
|
36 |
private MdkApi mdkApi; |
|
37 |
|
|
38 |
@Override |
|
39 |
public void run(String params) { |
|
40 |
logger.info("RunScheduleAirRatioTask,参数为:{}", params); |
|
41 |
try { |
|
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 |
// 根据条件查找方案 |
|
52 |
List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); |
|
53 |
if (CollectionUtils.isEmpty(schemeList)) { |
|
54 |
logger.info("方案为空"); |
|
55 |
return; |
|
56 |
} |
|
57 |
for (StScheduleSchemeDTO scheme : schemeList) { |
|
58 |
MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); |
|
59 |
dto.setScheduleTime(scheduleTime); |
|
60 |
dto.setScheduleCode(scheme.getCode()); |
|
61 |
MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); |
|
62 |
// 结果写入测点 |
|
63 |
mdkApi.scheduleModelOut(mdkScheduleRespDTO); |
|
64 |
} |
|
65 |
logger.info(params + "调度方案执行完成"); |
|
66 |
} catch (Exception ex) { |
|
67 |
logger.error("RunScheduleAirRatioTask运行异常"); |
|
68 |
ex.printStackTrace(); |
|
69 |
} |
|
70 |
logger.info("RunScheduleAirRatioTask运行完成"); |
|
71 |
} |
|
72 |
} |