提交 | 用户 | 时间
|
94c44e
|
1 |
package com.iailab.module.shasteel.job.task; |
D |
2 |
|
|
3 |
import com.iailab.module.model.api.mdk.MdkApi; |
9788d4
|
4 |
import com.iailab.module.model.api.mdk.dto.MdkPredictModuleRespDTO; |
94c44e
|
5 |
import com.iailab.module.model.api.mdk.dto.MdkPredictReqDTO; |
9788d4
|
6 |
import com.iailab.module.shasteel.mq.common.RoutingConstant; |
D |
7 |
import com.iailab.module.shasteel.mq.consumer.AlarmMessage; |
|
8 |
import com.iailab.module.shasteel.mq.consumer.PredictFinishMessage; |
94c44e
|
9 |
import org.slf4j.Logger; |
D |
10 |
import org.slf4j.LoggerFactory; |
9788d4
|
11 |
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
94c44e
|
12 |
import org.springframework.beans.factory.annotation.Autowired; |
D |
13 |
import org.springframework.stereotype.Component; |
|
14 |
|
9788d4
|
15 |
import javax.annotation.Resource; |
94c44e
|
16 |
import java.util.Calendar; |
D |
17 |
|
|
18 |
/** |
|
19 |
* 执行模块预测定时任务 |
|
20 |
* |
|
21 |
*/ |
|
22 |
@Component("runPredictModuleTask") |
|
23 |
public class RunPredictModuleTask implements ITask { |
|
24 |
private Logger logger = LoggerFactory.getLogger(getClass()); |
|
25 |
|
|
26 |
@Autowired |
9788d4
|
27 |
private MdkApi mdkApi; |
D |
28 |
@Autowired |
|
29 |
private RabbitTemplate rabbitTemplate; |
94c44e
|
30 |
|
D |
31 |
|
|
32 |
@Override |
|
33 |
public void run(String params) { |
|
34 |
logger.info("runPredictModuleTask定时任务正在执行,参数为:{}",params ); |
|
35 |
try { |
|
36 |
Calendar calendar = Calendar.getInstance(); |
|
37 |
calendar.set(Calendar.SECOND,0); |
|
38 |
calendar.set(Calendar.MILLISECOND,0); |
|
39 |
|
|
40 |
MdkPredictReqDTO dto = new MdkPredictReqDTO(); |
|
41 |
dto.setPredictTime(calendar.getTime()); |
|
42 |
dto.setModuleType(params); |
9788d4
|
43 |
MdkPredictModuleRespDTO mdkPredictModuleRespDTO = mdkApi.predictModule(dto); |
D |
44 |
logger.info(params + "模块预测完成," + mdkPredictModuleRespDTO); |
|
45 |
rabbitTemplate.convertAndSend(PredictFinishMessage.EXCHANGE, PredictFinishMessage.PREDICTFINISH_ROUTING_KEY, mdkPredictModuleRespDTO); |
94c44e
|
46 |
|
D |
47 |
} catch (Exception ex) { |
|
48 |
logger.error("runPredictModuleTask运行异常"); |
|
49 |
ex.printStackTrace(); |
|
50 |
} |
|
51 |
logger.info("runPredictModuleTask运行完成"); |
|
52 |
} |
|
53 |
} |