Selaa lähdekoodia

数据统计-数据初始化

黄远 5 vuotta sitten
vanhempi
commit
77e950a0c4

+ 31 - 0
lift-batch-service/src/main/java/cn/com/ty/lift/batch/applet/runner/AppletDataRunner.java

@@ -0,0 +1,31 @@
+package cn.com.ty.lift.batch.applet.runner;
+
+import cn.com.ty.lift.batch.applet.util.DataInitUtil;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+/**
+ * @author huangyuan
+ * @date 2020/2/10
+ * @description 初始化工具
+ */
+@Component
+public class AppletDataRunner implements ApplicationRunner {
+
+    @Resource
+    private DataInitUtil dataInitUtil;
+
+    /**
+     * @param
+     * @return
+     * @description 项目启动时数据初始化
+     * @date 2020/2/10 12:32 下午
+     */
+    @Override
+    public void run(ApplicationArguments args) {
+        dataInitUtil.initAppletData();
+    }
+}

+ 67 - 0
lift-batch-service/src/main/java/cn/com/ty/lift/batch/applet/util/DataInitUtil.java

@@ -0,0 +1,67 @@
+package cn.com.ty.lift.batch.applet.util;
+
+import cn.com.ty.lift.batch.applet.dao.model.request.CommonRequest;
+import cn.com.ty.lift.batch.applet.service.*;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+/**
+ * @author huangyuan
+ * @date 2020/2/10
+ * @description 数据初始化工具
+ */
+@Component
+@Slf4j
+public class DataInitUtil {
+
+    @Resource
+    private MaintenanceDataService maintenanceDataService;
+
+    @Resource
+    private EmergencyRepairDataService emergencyRepairDataService;
+
+    @Resource
+    private PaymentDataService paymentDataService;
+
+    @Resource
+    private LiftDataService liftDataService;
+
+    @Resource
+    private ContractDataService contractDataService;
+
+    @Resource
+    private AnnualInspectionDataService annualInspectionDataService;
+
+    /**
+     * @param
+     * @return
+     * @description 小程序初始化放入缓存中
+     * @date 2020/2/10 11:55 上午
+     */
+    public void initAppletData() {
+        //除维保以外其他统计类数据获取数据时间段: 3年前 - 当前时间
+        CommonRequest otherCommonRequest = DataStatisticsUtil.initCommonRequest(-3L);
+        //初始化急修数据
+        emergencyRepairDataService.putEmergencyRepairDataListToRedis(otherCommonRequest);
+        log.info("初始化急修数据成功");
+        //初始化收款数据
+        paymentDataService.putPaymentDataToRedis(otherCommonRequest);
+        log.info("初始化收款数据成功");
+        //初始化电梯数据
+        liftDataService.putLiftDataListToRedis(otherCommonRequest);
+        log.info("初始化电梯数据成功");
+        //初始化合同数据
+        contractDataService.putContractDataToRedis(otherCommonRequest);
+        log.info("初始化合同数据成功");
+        //初始化年检数据
+        annualInspectionDataService.putAnnualInspectionDataToRedis(otherCommonRequest);
+        log.info("初始化年检数据成功");
+        //维保数据获取数据的时间段: 1年前 - 当前时间
+        CommonRequest maintenanceCommonRequest = DataStatisticsUtil.initCommonRequest(-1L);
+        maintenanceDataService.putMaintenanceDataListToRedis(maintenanceCommonRequest);
+        log.info("初始化维保数据成功");
+    }
+
+}