提交 | 用户 | 时间
|
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; |
17d968
|
17 |
import java.util.Calendar; |
潘 |
18 |
import java.util.Date; |
|
19 |
import java.util.List; |
b50a43
|
20 |
|
J |
21 |
/** |
17d968
|
22 |
* 压缩空气运行指标(班) |
潘 |
23 |
* 8*60=480 数据 |
|
24 |
* 每班更新,20 0 0,8,16 * * ? * |
b50a43
|
25 |
* |
J |
26 |
* @author PanZhibao |
|
27 |
* @Description |
17d968
|
28 |
* @createTime 2025年01月03日 |
b50a43
|
29 |
*/ |
3bdd91
|
30 |
@Component("runScheduleAirIndexClassTask") |
17d968
|
31 |
public class RunScheduleAirIndexClassTask implements ITask { |
b50a43
|
32 |
private Logger logger = LoggerFactory.getLogger(getClass()); |
J |
33 |
|
|
34 |
@Resource |
|
35 |
private McsApi mcsApi; |
|
36 |
|
|
37 |
@Autowired |
|
38 |
private MdkApi mdkApi; |
|
39 |
|
|
40 |
@Override |
|
41 |
public void run(String params) { |
17d968
|
42 |
logger.info("RunScheduleAirIndexClassTask,参数为:{}", params); |
b50a43
|
43 |
try { |
J |
44 |
Calendar calendar = Calendar.getInstance(); |
|
45 |
calendar.set(Calendar.MILLISECOND, 0); |
|
46 |
calendar.set(Calendar.SECOND, 0); |
|
47 |
Date scheduleTime = calendar.getTime(); |
|
48 |
if (StringUtils.isEmpty(params)) { |
|
49 |
logger.info("参数为空"); |
|
50 |
return; |
|
51 |
} |
|
52 |
// 根据条件查找方案 |
|
53 |
List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); |
|
54 |
if (CollectionUtils.isEmpty(schemeList)) { |
|
55 |
logger.info("方案为空"); |
|
56 |
return; |
|
57 |
} |
|
58 |
for (StScheduleSchemeDTO scheme : schemeList) { |
|
59 |
MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); |
|
60 |
dto.setScheduleTime(scheduleTime); |
|
61 |
dto.setScheduleCode(scheme.getCode()); |
d8b11e
|
62 |
MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); |
b50a43
|
63 |
// 结果写入测点 |
J |
64 |
mdkApi.scheduleModelOut(mdkScheduleRespDTO); |
|
65 |
} |
|
66 |
logger.info(params + "调度方案执行完成"); |
|
67 |
} catch (Exception ex) { |
17d968
|
68 |
logger.error("RunScheduleAirIndexClassTask运行异常"); |
b50a43
|
69 |
ex.printStackTrace(); |
J |
70 |
} |
17d968
|
71 |
logger.info("RunScheduleAirIndexClassTask运行完成"); |
b50a43
|
72 |
} |
J |
73 |
} |