|
@@ -0,0 +1,75 @@
|
|
|
|
+package com.yideb.audit.task.dynamic;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
|
+import com.yideb.audit.config.GlobalConstant;
|
|
|
|
+import com.yideb.audit.entity.hub.BasicStatistic;
|
|
|
|
+import com.yideb.audit.service.audit.IStatisticConfigService;
|
|
|
|
+import com.yideb.audit.service.audit.ITopService;
|
|
|
|
+import com.yideb.audit.service.hub.IBasicStatisticService;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * <b>Application name:</b> yideb-audit-statistic <br>
|
|
|
|
+ * <b>Application describing: </b> <br>
|
|
|
|
+ * <b>Copyright:</b> Copyright © 2019 明医众禾科技(北京)有限责任公司 版权所有。<br>
|
|
|
|
+ * <b>Company:</b> 明医众禾科技(北京)有限责任公司 <br>
|
|
|
|
+ * <b>@Date:</b> 2020/8/5 18:36 <br>
|
|
|
|
+ * <b>@author:</b> <a href="mailto:Lijing@miyzh.com"> Lijing </a> <br>
|
|
|
|
+ */
|
|
|
|
+@Slf4j
|
|
|
|
+@Component
|
|
|
|
+public class PrescriptionTask {
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private ITopService topDataService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IStatisticConfigService statisticConfigService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IBasicStatisticService basicStatisticService;
|
|
|
|
+
|
|
|
|
+ @Scheduled(cron = "0/5 * * * * ?")
|
|
|
|
+ public void execute() {
|
|
|
|
+ log.info("头部数据刷新任务开始");
|
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
|
+ // 读取数据库配置
|
|
|
|
+ log.info("读取配置表信息开始");
|
|
|
|
+ Map<Integer, Double> configMap = statisticConfigService.allConfigs();
|
|
|
|
+ Double prescriptionMultiple = configMap.getOrDefault(GlobalConstant.BusinessType.PRESCRIPTION.getCode(), 5.0);
|
|
|
|
+ log.info("读取配置表信息结束");
|
|
|
|
+ log.info("读取配置表,花费时间:{}", System.currentTimeMillis() - startTime);
|
|
|
|
+
|
|
|
|
+ // 数据容器
|
|
|
|
+ BasicStatistic dataVo = new BasicStatistic();
|
|
|
|
+ // 今天
|
|
|
|
+ String todayStartTime = DateUtil.beginOfDay(new Date()).toString(DatePattern.NORM_DATETIME_PATTERN);
|
|
|
|
+ String todayEndTime = DateUtil.endOfDay(new Date()).toString(DatePattern.NORM_DATETIME_PATTERN);
|
|
|
|
+
|
|
|
|
+ log.info("查询头部信息开始");
|
|
|
|
+ // 累计审核处方
|
|
|
|
+ Integer totalPrescriptionCount = topDataService.queryPrescriptionCount(null, null);
|
|
|
|
+ // 今日处方总量
|
|
|
|
+ Integer todayPrescriptionCount = topDataService.queryPrescriptionCount(todayStartTime, todayEndTime);
|
|
|
|
+ log.info("查询头部信息结束");
|
|
|
|
+ log.info("查询头部信息,花费时间:{}", System.currentTimeMillis() - startTime);
|
|
|
|
+
|
|
|
|
+ // 写数据
|
|
|
|
+ dataVo.setTotalPrescriptionCount((int) (totalPrescriptionCount * prescriptionMultiple));
|
|
|
|
+ dataVo.setTodayPrescriptionCount((int) (todayPrescriptionCount * prescriptionMultiple));
|
|
|
|
+
|
|
|
|
+ log.info("写数据到远程数据库开始");
|
|
|
|
+ basicStatisticService.update(dataVo);
|
|
|
|
+ log.info("写数据到远程数据库结束");
|
|
|
|
+ log.info("写数据到远程数据库,花费时间:{}", System.currentTimeMillis() - startTime);
|
|
|
|
+
|
|
|
|
+ log.info("头部数据刷新任务结束");
|
|
|
|
+ log.info("消耗时间:{}", System.currentTimeMillis() - startTime);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|