|
@@ -2,13 +2,19 @@ package com.yideb.audit.task;
|
|
|
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
import cn.hutool.core.date.DatePattern;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
-import com.yideb.audit.entity.vo.TopDataVo;
|
|
|
|
-import com.yideb.audit.service.ITopDataService;
|
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
|
+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.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <b>Application name:</b> yideb-audit-statistic <br>
|
|
* <b>Application name:</b> yideb-audit-statistic <br>
|
|
@@ -18,16 +24,33 @@ import java.util.Date;
|
|
* <b>@Date:</b> 2020/8/5 18:36 <br>
|
|
* <b>@Date:</b> 2020/8/5 18:36 <br>
|
|
* <b>@author:</b> <a href="mailto:Lijing@miyzh.com"> Lijing </a> <br>
|
|
* <b>@author:</b> <a href="mailto:Lijing@miyzh.com"> Lijing </a> <br>
|
|
*/
|
|
*/
|
|
|
|
+@Slf4j
|
|
@Component
|
|
@Component
|
|
public class TopScheduleTask {
|
|
public class TopScheduleTask {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- private ITopDataService topDataService;
|
|
|
|
|
|
+ private ITopService topDataService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IStatisticConfigService statisticConfigService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IBasicStatisticService basicStatisticService;
|
|
|
|
|
|
- @Scheduled(cron = "0 0 * * * ?")
|
|
|
|
|
|
+ @Scheduled(cron = "0 0 0/1 * * ?")
|
|
public void execute() {
|
|
public void execute() {
|
|
|
|
+ log.info("头部数据刷新任务开始");
|
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
|
+ // 读取数据库配置
|
|
|
|
+ log.info("读取配置表信息开始");
|
|
|
|
+ Map<Integer, Integer> configMap = statisticConfigService.allConfigs();
|
|
|
|
+ Integer storeMultiple = configMap.getOrDefault(GlobalConstant.BusinessType.STORE.getCode(), 1);
|
|
|
|
+ Integer prescriptionMultiple = configMap.getOrDefault(GlobalConstant.BusinessType.PRESCRIPTION.getCode(), 1);
|
|
|
|
+ Integer acceptMultiple = configMap.getOrDefault(GlobalConstant.BusinessType.ACCEPT.getCode(), 1);
|
|
|
|
+ Integer auditMultiple = configMap.getOrDefault(GlobalConstant.BusinessType.AUDIT.getCode(), 1);
|
|
|
|
+ log.info("读取配置表信息结束");
|
|
|
|
+ log.info("读取配置表,花费时间:{}", System.currentTimeMillis() - startTime);
|
|
|
|
+
|
|
// 数据容器
|
|
// 数据容器
|
|
- TopDataVo dataVo = new TopDataVo();
|
|
|
|
|
|
+ BasicStatistic dataVo = new BasicStatistic();
|
|
// 星期时间
|
|
// 星期时间
|
|
String weekStartTime = DateUtil.offsetDay(DateUtil.beginOfDay(new Date()), -6).toString(DatePattern.NORM_DATETIME_PATTERN);
|
|
String weekStartTime = DateUtil.offsetDay(DateUtil.beginOfDay(new Date()), -6).toString(DatePattern.NORM_DATETIME_PATTERN);
|
|
String weekEndTime = DateUtil.endOfDay(new Date()).toString(DatePattern.NORM_DATETIME_PATTERN);
|
|
String weekEndTime = DateUtil.endOfDay(new Date()).toString(DatePattern.NORM_DATETIME_PATTERN);
|
|
@@ -35,30 +58,41 @@ public class TopScheduleTask {
|
|
String todayStartTime = DateUtil.beginOfDay(new Date()).toString(DatePattern.NORM_DATETIME_PATTERN);
|
|
String todayStartTime = DateUtil.beginOfDay(new Date()).toString(DatePattern.NORM_DATETIME_PATTERN);
|
|
String todayEndTime = DateUtil.endOfDay(new Date()).toString(DatePattern.NORM_DATETIME_PATTERN);
|
|
String todayEndTime = DateUtil.endOfDay(new Date()).toString(DatePattern.NORM_DATETIME_PATTERN);
|
|
|
|
|
|
|
|
+ log.info("查询头部信息开始");
|
|
// 累计注册药店
|
|
// 累计注册药店
|
|
Integer totalClinicRegCount = topDataService.queryClinicRegCount(null, null);
|
|
Integer totalClinicRegCount = topDataService.queryClinicRegCount(null, null);
|
|
// 累计审核处方
|
|
// 累计审核处方
|
|
- Integer auditCount = topDataService.queryAuditCount(null, null);
|
|
|
|
|
|
+ Integer totalPrescriptionCount = topDataService.queryPrescriptionCount(null, null);
|
|
// 本周注册药店
|
|
// 本周注册药店
|
|
Integer weekClinicRegCount = topDataService.queryClinicRegCount(weekStartTime, weekEndTime);
|
|
Integer weekClinicRegCount = topDataService.queryClinicRegCount(weekStartTime, weekEndTime);
|
|
// 今日处方总量
|
|
// 今日处方总量
|
|
- Integer todayAuditCount = topDataService.queryAuditCount(todayStartTime, todayEndTime);
|
|
|
|
|
|
+ Integer todayPrescriptionCount = topDataService.queryPrescriptionCount(todayStartTime, todayEndTime);
|
|
// 今日药店数量
|
|
// 今日药店数量
|
|
Integer todayClinicCount = topDataService.queryClinicCount(todayStartTime, todayEndTime);
|
|
Integer todayClinicCount = topDataService.queryClinicCount(todayStartTime, todayEndTime);
|
|
// 今日医生数量
|
|
// 今日医生数量
|
|
Integer todayDoctorCount = topDataService.queryDoctorCount(todayStartTime, todayEndTime);
|
|
Integer todayDoctorCount = topDataService.queryDoctorCount(todayStartTime, todayEndTime);
|
|
// 今日药师数量
|
|
// 今日药师数量
|
|
Integer todayPharmacistCount = topDataService.queryPharmacistCount(todayStartTime, todayEndTime);
|
|
Integer todayPharmacistCount = topDataService.queryPharmacistCount(todayStartTime, todayEndTime);
|
|
-
|
|
|
|
- dataVo.setTotalClinicRegCount(totalClinicRegCount);
|
|
|
|
- dataVo.setAuditCount(auditCount);
|
|
|
|
- dataVo.setWeekClinicRegCount(weekClinicRegCount);
|
|
|
|
- dataVo.setTodayAuditCount(todayAuditCount);
|
|
|
|
- dataVo.setTodayClinicCount(todayClinicCount);
|
|
|
|
- dataVo.setTodayDoctorCount(todayDoctorCount);
|
|
|
|
- dataVo.setTodayPharmacistCount(todayPharmacistCount);
|
|
|
|
|
|
+ log.info("查询头部信息结束");
|
|
|
|
+ log.info("查询头部信息,花费时间:{}", System.currentTimeMillis() - startTime);
|
|
|
|
|
|
// 写数据
|
|
// 写数据
|
|
|
|
+ dataVo.setId(IdUtil.simpleUUID());
|
|
|
|
+ dataVo.setTotalClinicRegCount(totalClinicRegCount * storeMultiple);
|
|
|
|
+ dataVo.setTotalPrescriptionCount(totalPrescriptionCount * prescriptionMultiple);
|
|
|
|
+ dataVo.setWeekClinicRegCount(weekClinicRegCount * storeMultiple);
|
|
|
|
+ dataVo.setTodayPrescriptionCount(todayPrescriptionCount * prescriptionMultiple);
|
|
|
|
+ dataVo.setTodayClinicCount(todayClinicCount * storeMultiple);
|
|
|
|
+ dataVo.setTodayDoctorCount(todayDoctorCount * acceptMultiple);
|
|
|
|
+ dataVo.setTodayPharmacistCount(todayPharmacistCount * auditMultiple);
|
|
|
|
+
|
|
|
|
+ log.info("写数据到远程数据库开始");
|
|
|
|
+ basicStatisticService.flushDb(dataVo);
|
|
|
|
+ log.info("写数据到远程数据库结束");
|
|
|
|
+ log.info("写数据到远程数据库,花费时间:{}", System.currentTimeMillis() - startTime);
|
|
|
|
+
|
|
|
|
+ log.info("头部数据刷新任务结束");
|
|
|
|
+ log.info("消耗时间:{}", System.currentTimeMillis() - startTime);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|