|
@@ -0,0 +1,48 @@
|
|
|
+package com.fdkankan.contro.schedule;
|
|
|
+
|
|
|
+import com.fdkankan.contro.service.IScene3dNumService;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+@Log4j2
|
|
|
+@Component
|
|
|
+public class ScheduleJob {
|
|
|
+
|
|
|
+// @Value("${rocketmq.autoScaling.num.normal}")
|
|
|
+// private String baseNum;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private RabbitMqProducer rabbitMqProducer;
|
|
|
+//
|
|
|
+// @Value("${queue.modeling.modeling-call}")
|
|
|
+// private String queueModelingCall;
|
|
|
+ @Autowired
|
|
|
+ private IScene3dNumService scene3dNumService;
|
|
|
+
|
|
|
+
|
|
|
+// @Scheduled(cron = "${rocketmq.autoScaling.corn:0 0/5 8-21 * * ?}")
|
|
|
+// public void job8() {
|
|
|
+// try {
|
|
|
+// //当mq排队数大于指定数量时使用弹性升缩
|
|
|
+// int mqNum = rabbitMqProducer.getMessageCount(queueModelingCall);
|
|
|
+// log.info("每5分钟查询一次排队队列,mqNum:" + mqNum);
|
|
|
+// if(mqNum - Integer.parseInt(baseNum) > 0){
|
|
|
+// log.info("使用弹性升缩开启一台ECS");
|
|
|
+// log.info(scalingService.createEcs());
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("弹性升缩开启失败!", e);
|
|
|
+// log.error(e.getMessage());
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 定时生成场景码,间隔1小时执行一次,项目启动一秒后执行一次
|
|
|
+ */
|
|
|
+ @Scheduled(fixedDelay = 60*60*1000, initialDelay = 1000)
|
|
|
+ public void generateSceneNum() {
|
|
|
+ scene3dNumService.generateSceneNumHandler();
|
|
|
+ }
|
|
|
+}
|