提交 | 用户 | 时间
|
20ca11
|
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.AlarmMessageRespDTO; |
|
5 |
import com.iailab.module.model.api.mcs.dto.ScheduleSuggestRespDTO; |
|
6 |
import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; |
|
7 |
import com.iailab.module.model.api.mdk.MdkApi; |
|
8 |
import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; |
|
9 |
import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; |
|
10 |
import com.iailab.module.model.enums.CommonConstant; |
|
11 |
import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; |
|
12 |
import org.apache.commons.lang3.StringUtils; |
|
13 |
import org.slf4j.Logger; |
|
14 |
import org.slf4j.LoggerFactory; |
|
15 |
import org.springframework.beans.factory.annotation.Autowired; |
|
16 |
import org.springframework.stereotype.Component; |
|
17 |
import org.springframework.util.CollectionUtils; |
|
18 |
|
|
19 |
import java.util.*; |
|
20 |
|
|
21 |
/** |
|
22 |
* 06 |
|
23 |
* 氧气班平衡计划 |
|
24 |
* 法夜空建议送出量 faAdvice |
|
25 |
* 盈德低压建议送出量 yingDiAdvice |
|
26 |
* 盈德中压建议送出量 yingZhongAdvice |
|
27 |
* 宏昌建议送出量 hongAdvice |
|
28 |
* 润忠建议送出量 RunAdvice |
|
29 |
* 调整值 adviceValues |
17633f
|
30 |
* |
20ca11
|
31 |
* 05 |
潘 |
32 |
* 氧气系统优化调度决策 |
|
33 |
* 盈德中压建议调整量 yingdiAdvice |
|
34 |
* 法夜空建议调整量 faAdvice |
|
35 |
* 宏昌建议调整量 hongAdvice |
|
36 |
* 润忠建议调整量 RunAdvice |
17633f
|
37 |
* |
潘 |
38 |
* 01 |
|
39 |
* 氮气预警模型 |
|
40 |
* 预警信号 advice |
20ca11
|
41 |
* |
潘 |
42 |
* @author PanZhibao |
|
43 |
* @Description |
|
44 |
* @createTime 2025年01月07日 |
|
45 |
*/ |
|
46 |
@Component("runScheduleOnaOptTask") |
|
47 |
public class RunScheduleOnaOptTask implements ITask { |
|
48 |
private Logger logger = LoggerFactory.getLogger(getClass()); |
|
49 |
|
|
50 |
@Autowired |
|
51 |
private McsApi mcsApi; |
|
52 |
|
|
53 |
@Autowired |
|
54 |
private MdkApi mdkApi; |
|
55 |
|
|
56 |
private Map<String, StScheduleSchemeDTO> schemeMap = new HashMap<>(); |
|
57 |
|
|
58 |
private static final String CODE06 = "06"; |
|
59 |
|
|
60 |
private static final String CODE05 = "05"; |
17633f
|
61 |
|
潘 |
62 |
private static final String CODE01 = "01"; |
20ca11
|
63 |
|
潘 |
64 |
@Override |
|
65 |
public void run(String params) { |
|
66 |
logger.info("RunScheduleOnaOptTask,参数为:{}", params); |
|
67 |
try { |
|
68 |
Calendar calendar = Calendar.getInstance(); |
|
69 |
calendar.set(Calendar.MILLISECOND, 0); |
|
70 |
calendar.set(Calendar.SECOND, 0); |
|
71 |
Date scheduleTime = calendar.getTime(); |
|
72 |
if (StringUtils.isEmpty(params)) { |
|
73 |
logger.info("参数为空"); |
|
74 |
return; |
|
75 |
} |
|
76 |
|
|
77 |
// 根据条件查找方案 |
|
78 |
List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); |
|
79 |
if (CollectionUtils.isEmpty(schemeList)) { |
|
80 |
logger.info("方案为空"); |
|
81 |
return; |
|
82 |
} |
|
83 |
schemeMap.clear(); |
|
84 |
Map<String, MdkScheduleRespDTO> resultMap = new HashMap<String, MdkScheduleRespDTO>(); |
|
85 |
schemeList.forEach(item -> { |
|
86 |
schemeMap.put(item.getCode(), item); |
|
87 |
StScheduleSchemeDTO scheme = schemeList.get(0); |
|
88 |
MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); |
|
89 |
dto.setScheduleTime(scheduleTime); |
|
90 |
dto.setScheduleCode(scheme.getCode()); |
|
91 |
MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); |
|
92 |
resultMap.put(item.getCode(), mdkScheduleRespDTO); |
|
93 |
}); |
|
94 |
if (CollectionUtils.isEmpty(resultMap)) { |
|
95 |
logger.info("resultMap为空"); |
|
96 |
return; |
|
97 |
} |
|
98 |
for (Map.Entry<String, MdkScheduleRespDTO> entry : resultMap.entrySet()) { |
|
99 |
if (CommonConstant.MDK_STATUS_100.equals(entry.getValue().getStatusCode())) { |
|
100 |
logger.info("调度结果异常,STATUS=" + entry.getValue().getStatusCode()); |
|
101 |
continue; |
|
102 |
} |
|
103 |
|
|
104 |
if (entry.getKey().equals(CODE06)) { |
|
105 |
// 氧气班平衡计划,建议值写入测点 |
|
106 |
mdkApi.scheduleModelOut(entry.getValue()); |
|
107 |
} else if (entry.getKey().equals(CODE05)) { |
|
108 |
String scheduleObj = schemeMap.get(CODE05).getScheduleObj(); |
|
109 |
// double[] adviceValues = (double[]) entry.getValue().getResult().get("adviceValues"); |
|
110 |
String yingdiAdvice = entry.getValue().getResult().get("yingdiAdvice").toString(); |
|
111 |
saveScheduleSuggest("盈德中压建议调整量", yingdiAdvice, scheduleObj, scheduleTime); |
|
112 |
String faAdvice = entry.getValue().getResult().get("faAdvice").toString(); |
|
113 |
saveScheduleSuggest("法夜空建议调整量", faAdvice, scheduleObj, scheduleTime); |
|
114 |
String hongAdvice = entry.getValue().getResult().get("hongAdvice").toString(); |
|
115 |
saveScheduleSuggest("宏昌建议调整量", hongAdvice, scheduleObj, scheduleTime); |
|
116 |
String runAdvice = entry.getValue().getResult().get("RunAdvice").toString(); |
|
117 |
saveScheduleSuggest("宏昌建议调整量", runAdvice, scheduleObj, scheduleTime); |
17633f
|
118 |
} else if (entry.getKey().equals(CODE01)) { |
1a9bad
|
119 |
String scheduleObj = schemeMap.get(CODE01).getScheduleObj(); |
17633f
|
120 |
String advice = entry.getValue().getResult().get("advice").toString(); |
潘 |
121 |
saveScheduleSuggest("氮气预警", advice, scheduleObj, scheduleTime); |
20ca11
|
122 |
} |
潘 |
123 |
} |
|
124 |
logger.info(params + "调度方案执行完成"); |
|
125 |
} catch (Exception ex) { |
|
126 |
logger.error("RunScheduleOnaOptTask运行异常"); |
|
127 |
ex.printStackTrace(); |
|
128 |
} |
|
129 |
logger.info("RunScheduleOnaOptTask运行完成"); |
|
130 |
} |
|
131 |
|
|
132 |
private void saveScheduleSuggest(String title, String content, String scheduleObj, Date scheduleTime) { |
|
133 |
if (StringUtils.isBlank(content)) { |
|
134 |
return; |
|
135 |
} |
|
136 |
ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); |
|
137 |
suggest.setTitle(title); |
|
138 |
suggest.setContent(content); |
|
139 |
suggest.setScheduleObj(scheduleObj); |
|
140 |
suggest.setScheduleTime(scheduleTime); |
|
141 |
suggest.setSort(0); |
|
142 |
mcsApi.createScheduleSuggest(suggest); |
|
143 |
} |
|
144 |
} |