提交 | 用户 | 时间
|
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.consumer.PredictFinishMessage; |
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 |
|
|
13 |
import java.util.Calendar; |
|
14 |
|
|
15 |
/** |
|
16 |
* 执行模块预测定时任务 |
|
17 |
* |
|
18 |
*/ |
|
19 |
@Component("runPredictModuleTask") |
|
20 |
public class RunPredictModuleTask implements ITask { |
|
21 |
private Logger logger = LoggerFactory.getLogger(getClass()); |
|
22 |
|
|
23 |
@Autowired |
9788d4
|
24 |
private MdkApi mdkApi; |
D |
25 |
@Autowired |
|
26 |
private RabbitTemplate rabbitTemplate; |
94c44e
|
27 |
|
D |
28 |
|
|
29 |
@Override |
|
30 |
public void run(String params) { |
|
31 |
logger.info("runPredictModuleTask定时任务正在执行,参数为:{}",params ); |
|
32 |
try { |
|
33 |
Calendar calendar = Calendar.getInstance(); |
|
34 |
calendar.set(Calendar.SECOND,0); |
|
35 |
calendar.set(Calendar.MILLISECOND,0); |
|
36 |
|
|
37 |
MdkPredictReqDTO dto = new MdkPredictReqDTO(); |
|
38 |
dto.setPredictTime(calendar.getTime()); |
|
39 |
dto.setModuleType(params); |
9788d4
|
40 |
MdkPredictModuleRespDTO mdkPredictModuleRespDTO = mdkApi.predictModule(dto); |
D |
41 |
logger.info(params + "模块预测完成," + mdkPredictModuleRespDTO); |
|
42 |
rabbitTemplate.convertAndSend(PredictFinishMessage.EXCHANGE, PredictFinishMessage.PREDICTFINISH_ROUTING_KEY, mdkPredictModuleRespDTO); |
94c44e
|
43 |
|
D |
44 |
} catch (Exception ex) { |
|
45 |
logger.error("runPredictModuleTask运行异常"); |
|
46 |
ex.printStackTrace(); |
|
47 |
} |
|
48 |
logger.info("runPredictModuleTask运行完成"); |
|
49 |
} |
|
50 |
} |