|
|
@@ -0,0 +1,95 @@
|
|
|
+package cn.com.ctop.job.bytedance.handler;
|
|
|
+
|
|
|
+
|
|
|
+import cn.com.ctop.job.bytedance.data.service.IZtPolicyRunService;
|
|
|
+import cn.com.ctop.job.bytedance.data.utils.Check;
|
|
|
+import com.xxl.job.core.context.XxlJobHelper;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
+
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class ZtPolicyKob {
|
|
|
+ @Autowired
|
|
|
+ private IZtPolicyRunService policyRunService;
|
|
|
+ private static ExecutorService halfHourExecutorService = Executors.newFixedThreadPool(5);
|
|
|
+ private static ExecutorService oneHourExecutorService = Executors.newFixedThreadPool(5);
|
|
|
+ private static ExecutorService oneDayExecutorService = Executors.newFixedThreadPool(5);
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 智投助手-半小时
|
|
|
+ *
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+
|
|
|
+ @XxlJob("halfHourJob")
|
|
|
+ public void halfHourJob() throws Exception {
|
|
|
+ String param = XxlJobHelper.getJobParam(); // 执行参数
|
|
|
+ if (Check.isNull(param)) {
|
|
|
+ log.error("入参为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Long policyId = Long.valueOf(param);
|
|
|
+ halfHourExecutorService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ policyRunService.run(policyId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 智投助手-一小时
|
|
|
+ *
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+
|
|
|
+ @XxlJob("oneHourJob")
|
|
|
+ public void oneHourJob() throws Exception {
|
|
|
+ String param = XxlJobHelper.getJobParam(); // 执行参数
|
|
|
+ if (Check.isNull(param)) {
|
|
|
+ log.error("入参为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Long policyId = Long.valueOf(param);
|
|
|
+ oneHourExecutorService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ policyRunService.run(policyId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 智投助手-一天
|
|
|
+ *
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+
|
|
|
+ @XxlJob("oneDayJob")
|
|
|
+ public void oneDayJob() throws Exception {
|
|
|
+ String param = XxlJobHelper.getJobParam(); // 执行参数
|
|
|
+ if (Check.isNull(param)) {
|
|
|
+ log.error("入参为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Long policyId = Long.valueOf(param);
|
|
|
+ oneDayExecutorService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ policyRunService.run(policyId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|