|
@@ -0,0 +1,58 @@
|
|
|
+package com.ruoyi.web.controller.task;
|
|
|
+
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
+import com.ruoyi.common.constant.Constants;
|
|
|
+import com.ruoyi.common.utils.RedisUtils;
|
|
|
+import com.ruoyi.zhdd.service.*;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description: TODO
|
|
|
+ * @Author: huangcheng
|
|
|
+ * @Date: 2022/7/5
|
|
|
+ * @Version V1.0
|
|
|
+ */
|
|
|
+@Component
|
|
|
+@EnableScheduling // 1.开启定时任务
|
|
|
+@EnableAsync // 2.开启多线程
|
|
|
+@Slf4j
|
|
|
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
|
|
+public class ScheduleTask {
|
|
|
+
|
|
|
+ private final IChemicalDataService chemicalDataService;
|
|
|
+ private final IDutyReportService dutyReportService;
|
|
|
+ private final IDutyReportRecordService dutyReportRecordService;
|
|
|
+ private final IIncidentService incidentService;
|
|
|
+ private final IIncidentProcessService incidentProcessService;
|
|
|
+ private final IIncidentTaskService incidentTaskService;
|
|
|
+ private final IPlanService planService;
|
|
|
+ private final IResourceService resourceService;
|
|
|
+ private final IResourceDetailService resourceDetailService;
|
|
|
+
|
|
|
+
|
|
|
+ @Async
|
|
|
+ @Scheduled(cron = "0 0 0/1 * * ?")
|
|
|
+ public void countTable() {
|
|
|
+ log.info("开始计算表数据量");
|
|
|
+ long count = chemicalDataService.count();
|
|
|
+ long count1 = dutyReportService.count();
|
|
|
+ long count2 = dutyReportRecordService.count();
|
|
|
+ long count3 = incidentService.count();
|
|
|
+ long count4 = incidentProcessService.count();
|
|
|
+ long count5 = incidentTaskService.count();
|
|
|
+ long count6 = planService.count();
|
|
|
+ long count7 = resourceService.count();
|
|
|
+ long count8 = resourceDetailService.count();
|
|
|
+ BigDecimal add = NumberUtil.add(count, count1, count2, count3, count4, count5, count6, count7, count8);
|
|
|
+ RedisUtils.setCacheObject(Constants.DATA_TOTAL_COUNT, add);
|
|
|
+ }
|
|
|
+}
|