提交 | 用户 | 时间
|
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 |
* 执行模块预测定时任务 |
|
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); |
5cc4c8
|
35 |
Date predictTime = calendar.getTime(); |
潘 |
36 |
if (StringUtils.isEmpty(params)) { |
|
37 |
logger.info("参数为空"); |
|
38 |
return; |
|
39 |
} |
|
40 |
List<String> moduleTypeList = Arrays.asList(params.split(",")); |
|
41 |
moduleTypeList.forEach(type -> { |
|
42 |
MdkPredictReqDTO dto = new MdkPredictReqDTO(); |
|
43 |
dto.setPredictTime(predictTime); |
|
44 |
dto.setModuleType(type); |
|
45 |
mdkApi.predictModule(dto); |
|
46 |
logger.info(type + "模块预测完成。"); |
|
47 |
Map<String, Object> msg = new HashMap<>(); |
|
48 |
msg.put("moduleType", type); |
|
49 |
msg.put("predictTime", predictTime); |
|
50 |
rabbitTemplate.convertAndSend(RoutingConstant.EXCHANGE, RoutingConstant.Iailab_Model_PredictFinish, msg); |
|
51 |
}); |
94c44e
|
52 |
} catch (Exception ex) { |
D |
53 |
logger.error("runPredictModuleTask运行异常"); |
|
54 |
ex.printStackTrace(); |
|
55 |
} |
|
56 |
logger.info("runPredictModuleTask运行完成"); |
|
57 |
} |
|
58 |
} |