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