提交 | 用户 | 时间
|
94c44e
|
1 |
package com.iailab.module.shasteel.job.task; |
D |
2 |
|
|
3 |
import com.iailab.module.model.api.mdk.MdkApi; |
|
4 |
import com.iailab.module.model.api.mdk.dto.MdkPredictReqDTO; |
cf56eb
|
5 |
import com.iailab.module.shasteel.mq.common.constant.RoutingConstant; |
5cc4c8
|
6 |
import org.apache.commons.lang3.StringUtils; |
94c44e
|
7 |
import org.slf4j.Logger; |
D |
8 |
import org.slf4j.LoggerFactory; |
9788d4
|
9 |
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
94c44e
|
10 |
import org.springframework.beans.factory.annotation.Autowired; |
D |
11 |
import org.springframework.stereotype.Component; |
|
12 |
|
5cc4c8
|
13 |
import java.util.*; |
94c44e
|
14 |
|
D |
15 |
/** |
|
16 |
* 执行模块预测定时任务 |
d92c31
|
17 |
* 1、高炉 |
潘 |
18 |
* 2、焦炉 |
|
19 |
* 3、转炉 |
|
20 |
* 3.1、氧气 |
|
21 |
* 3.2、蒸汽 |
|
22 |
* 4、氮气 |
94c44e
|
23 |
*/ |
D |
24 |
@Component("runPredictModuleTask") |
|
25 |
public class RunPredictModuleTask implements ITask { |
|
26 |
private Logger logger = LoggerFactory.getLogger(getClass()); |
|
27 |
|
|
28 |
@Autowired |
9788d4
|
29 |
private MdkApi mdkApi; |
c9ff6a
|
30 |
|
9788d4
|
31 |
@Autowired |
D |
32 |
private RabbitTemplate rabbitTemplate; |
94c44e
|
33 |
|
D |
34 |
@Override |
|
35 |
public void run(String params) { |
c9ff6a
|
36 |
logger.info("runPredictModuleTask定时任务正在执行,参数为:{}", params); |
94c44e
|
37 |
try { |
D |
38 |
Calendar calendar = Calendar.getInstance(); |
c9ff6a
|
39 |
calendar.set(Calendar.SECOND, 0); |
潘 |
40 |
calendar.set(Calendar.MILLISECOND, 0); |
5cc4c8
|
41 |
Date predictTime = calendar.getTime(); |
潘 |
42 |
if (StringUtils.isEmpty(params)) { |
|
43 |
logger.info("参数为空"); |
|
44 |
return; |
|
45 |
} |
|
46 |
List<String> moduleTypeList = Arrays.asList(params.split(",")); |
|
47 |
moduleTypeList.forEach(type -> { |
|
48 |
MdkPredictReqDTO dto = new MdkPredictReqDTO(); |
|
49 |
dto.setPredictTime(predictTime); |
|
50 |
dto.setModuleType(type); |
|
51 |
mdkApi.predictModule(dto); |
|
52 |
logger.info(type + "模块预测完成。"); |
|
53 |
Map<String, Object> msg = new HashMap<>(); |
|
54 |
msg.put("moduleType", type); |
|
55 |
msg.put("predictTime", predictTime); |
|
56 |
rabbitTemplate.convertAndSend(RoutingConstant.EXCHANGE, RoutingConstant.Iailab_Model_PredictFinish, msg); |
|
57 |
}); |
94c44e
|
58 |
} catch (Exception ex) { |
D |
59 |
logger.error("runPredictModuleTask运行异常"); |
|
60 |
ex.printStackTrace(); |
|
61 |
} |
|
62 |
logger.info("runPredictModuleTask运行完成"); |
|
63 |
} |
|
64 |
} |