|
@@ -0,0 +1,65 @@
|
|
|
+package com.gyee.gaia.cause.job;
|
|
|
+
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.gyee.gaia.cause.entity.PointData;
|
|
|
+import com.gyee.gaia.cause.entity.StateCause;
|
|
|
+import com.gyee.gaia.cause.service.CalculateService;
|
|
|
+import com.gyee.gaia.cause.service.IStateCauseService;
|
|
|
+import com.gyee.gaia.common.data.point.TestingPoint;
|
|
|
+import com.gyee.gaia.dao.sql.point.ITestingPointService;
|
|
|
+import com.gyee.gaia.init.CacheContext;
|
|
|
+import com.xxl.job.core.biz.model.ReturnT;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import org.springframework.boot.ApplicationArguments;
|
|
|
+import org.springframework.boot.ApplicationRunner;
|
|
|
+import org.springframework.core.annotation.Order;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import static com.xxl.job.core.biz.model.ReturnT.SUCCESS_CODE;
|
|
|
+
|
|
|
+
|
|
|
+@Order(2)
|
|
|
+@Component
|
|
|
+public class CauseJobHandler implements ApplicationRunner {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ITestingPointService testingPointService;
|
|
|
+ @Resource
|
|
|
+ private IStateCauseService stateCauseService;
|
|
|
+ @Resource
|
|
|
+ private CalculateService calculateService;
|
|
|
+
|
|
|
+ @XxlJob("WindCauseJobHandler")
|
|
|
+ public ReturnT<String> windCauseJobHandler() {
|
|
|
+ return new ReturnT(SUCCESS_CODE, "调度成功111");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run(ApplicationArguments args) throws Exception {
|
|
|
+ QueryWrapper<StateCause> scWrapper = new QueryWrapper<>();
|
|
|
+ scWrapper.select("max(end_time)");
|
|
|
+ Map<String, Object> map = stateCauseService.getMap(scWrapper);
|
|
|
+ if (map == null) {
|
|
|
+ map = new HashMap<>();
|
|
|
+ map.put("max", DateUtil.yesterday().getTime());
|
|
|
+ }
|
|
|
+ Object max = map.get("max");
|
|
|
+ if (max == null) max = DateUtil.yesterday().getTime();
|
|
|
+
|
|
|
+ Map<TestingPoint, List<PointData>> value = calculateService.getValue(CacheContext.state8Point, (long) max, System.currentTimeMillis());
|
|
|
+ calculateService.calculate(value);
|
|
|
+ //String command = XxlJobHelper.getJobParam();
|
|
|
+ //Map<String, String> map = JSON.parseObject(command, Map.class);
|
|
|
+ QueryWrapper<TestingPoint> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq("uniform_code", "FJZT8");
|
|
|
+ List<TestingPoint> list = testingPointService.list(wrapper);
|
|
|
+
|
|
|
+ }
|
|
|
+}
|