1.新增毒品检材送缴量统计模块(目前仅实现了时间范围和送缴单位统计)
master
陈江保 16 hours ago
parent 315fe488e0
commit f9ec26bbbb
  1. 2
      src/main/java/digital/laboratory/platform/imr/component/DateUtils.java
  2. 30
      src/main/java/digital/laboratory/platform/imr/controller/DrugHandingOverStatisticController.java
  3. 1
      src/main/java/digital/laboratory/platform/imr/dto/InRepositoryDTO.java
  4. 32
      src/main/java/digital/laboratory/platform/imr/dto/InnerSampleOutbound.java
  5. 19
      src/main/java/digital/laboratory/platform/imr/dto/PrintTableDTO.java
  6. 24
      src/main/java/digital/laboratory/platform/imr/dto/PublicityDTO.java
  7. 29
      src/main/java/digital/laboratory/platform/imr/dto/QueryApplyDTO.java
  8. 33
      src/main/java/digital/laboratory/platform/imr/dto/QueryDTO.java
  9. 19
      src/main/java/digital/laboratory/platform/imr/dto/QuerySampleDTO.java
  10. 13
      src/main/java/digital/laboratory/platform/imr/dto/QueryStorageDTO.java
  11. 38
      src/main/java/digital/laboratory/platform/imr/dto/base/BaseQuery.java
  12. 29
      src/main/java/digital/laboratory/platform/imr/query/DrugStatisticQuery.java
  13. 16
      src/main/java/digital/laboratory/platform/imr/service/DrugHandingOverStatisticService.java
  14. 161
      src/main/java/digital/laboratory/platform/imr/service/impl/DrugHandingOverStatisticServiceImpl.java
  15. 24
      src/main/java/digital/laboratory/platform/imr/vo/DrugStatisticVO.java

@ -17,6 +17,8 @@ public class DateUtils {
public static final String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
public static final String yyyy_MM_dd = "yyyy-MM-dd";
public static final String yyyy_MM = "yyyy-MM";
public static final String TIME_ZONE = "GMT+8";

@ -0,0 +1,30 @@
package digital.laboratory.platform.imr.controller;
import digital.laboratory.platform.common.core.util.R;
import digital.laboratory.platform.imr.query.DrugStatisticQuery;
import digital.laboratory.platform.imr.service.DrugHandingOverStatisticService;
import digital.laboratory.platform.imr.vo.DrugStatisticVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("/drugStatistic")
public class DrugHandingOverStatisticController {
@Resource
private DrugHandingOverStatisticService drugHandingOverStatisticService;
@ApiOperation("获取统计图的数据, 根据时间范围, 送缴单位,毒品种类返回数据")
@PostMapping()
public R statistic(@RequestBody DrugStatisticQuery query) {
DrugStatisticVO vo = drugHandingOverStatisticService.statistic(query);
return R.ok(vo);
}
}

@ -1,7 +1,6 @@
package digital.laboratory.platform.imr.dto;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@ -1,32 +0,0 @@
package digital.laboratory.platform.imr.dto;
import java.time.LocalDateTime;
/**
* 内部样本出库DTO
*/
public class InnerSampleOutbound {
/**
* id
* 样本id
*/
private String id;
/**
* 领取人Id
*/
private String recipientId;
/**
* 归还时间
*/
private LocalDateTime returnDate;
/**
* 原因
*/
private String cause;
}

@ -1,18 +1,14 @@
package digital.laboratory.platform.imr.dto;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import digital.laboratory.platform.imr.component.DateUtils;
import digital.laboratory.platform.imr.dto.base.BaseQuery;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
@Data
@ApiModel(value = "按时间或委托生成检材出入库登记表")
public class PrintTableDTO {
public class PrintTableDTO extends BaseQuery {
@ApiModelProperty(value = "打印筛选条件1.委托/任务;2.时间")
private Integer type;
@ -28,15 +24,4 @@ public class PrintTableDTO {
@ApiModelProperty(value = "事件名称")
private String EventName;
@ApiModelProperty(value = "开始时间")
@JsonFormat(pattern = DateUtils.yyyy_MM_dd, timezone = DateUtils.TIME_ZONE)
@JSONField(format = DateUtils.yyyy_MM_dd)
private LocalDate beginDate;
@ApiModelProperty(value = "结束时间")
@JsonFormat(pattern = DateUtils.yyyy_MM_dd, timezone = DateUtils.TIME_ZONE)
@JSONField(format = DateUtils.yyyy_MM_dd)
private LocalDate finishDate;
}

@ -3,6 +3,7 @@ package digital.laboratory.platform.imr.dto;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import digital.laboratory.platform.imr.component.DateUtils;
import digital.laboratory.platform.imr.dto.base.BaseQuery;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -10,30 +11,9 @@ import lombok.Data;
import java.time.LocalDate;
@Data
@ApiModel(value = "PublicityDTO",description = "销毁与公示dto")
public class PublicityDTO {
public class PublicityDTO extends BaseQuery {
@ApiModelProperty(value = "开始时间")
@JsonFormat(pattern = DateUtils.yyyy_MM_dd, timezone = DateUtils.TIME_ZONE)
@JSONField(format = DateUtils.yyyy_MM_dd)
private LocalDate beginDate;
@ApiModelProperty(value = "结束时间")
@JsonFormat(pattern = DateUtils.yyyy_MM_dd, timezone = DateUtils.TIME_ZONE)
@JSONField(format = DateUtils.yyyy_MM_dd)
private LocalDate finishDate;
@ApiModelProperty(value = "当前申请的状态")
private Integer status;//状态
/**
* 当前页
*/
@ApiModelProperty(value = "当前页")
private Integer current;
/**
* 每页显示条数
*/
@ApiModelProperty(value = "每页显示条数")
private Integer size;
}

@ -1,42 +1,17 @@
package digital.laboratory.platform.imr.dto;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import digital.laboratory.platform.imr.component.DateUtils;
import digital.laboratory.platform.imr.dto.base.BaseQuery;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
@Data
@ApiModel(value="查询申请通用DTO")
public class QueryApplyDTO {
public class QueryApplyDTO extends BaseQuery {
@ApiModelProperty(value = "申请类型(1.外带//2.销毁)")
private Integer applyType;//名称
@ApiModelProperty(value = "开始时间")
@JsonFormat(pattern = DateUtils.yyyy_MM_dd, timezone = DateUtils.TIME_ZONE)
@JSONField(format = DateUtils.yyyy_MM_dd)
private LocalDate beginDate;
@ApiModelProperty(value = "结束时间")
@JsonFormat(pattern = DateUtils.yyyy_MM_dd, timezone = DateUtils.TIME_ZONE)
@JSONField(format = DateUtils.yyyy_MM_dd)
private LocalDate finishDate;
@ApiModelProperty(value = "当前申请的状态")
private Integer status;//状态
/**
* 当前页
*/
@ApiModelProperty(value = "当前页")
private Integer current;
/**
* 每页显示条数
*/
@ApiModelProperty(value = "每页显示条数")
private Integer size;
}

@ -1,19 +1,14 @@
package digital.laboratory.platform.imr.dto;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import digital.laboratory.platform.imr.component.DateUtils;
import digital.laboratory.platform.imr.dto.base.BaseQuery;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
import java.util.List;
@Data
@ApiModel(value = "通用的查询参数dto--选择其中部分数据作为查询参数")
public class QueryDTO {
public class QueryDTO extends BaseQuery {
//以下为查询条件
@ -24,29 +19,8 @@ public class QueryDTO {
@ApiModelProperty(value = "样本id集合")
private String sampleIds;//名称
@ApiModelProperty(value = "开始时间")
@JsonFormat(pattern = DateUtils.yyyy_MM_dd, timezone = DateUtils.TIME_ZONE)
@JSONField(format = DateUtils.yyyy_MM_dd)
private LocalDate beginDate;
@ApiModelProperty(value = "结束时间")
@JsonFormat(pattern = DateUtils.yyyy_MM_dd, timezone = DateUtils.TIME_ZONE)
@JSONField(format = DateUtils.yyyy_MM_dd)
private LocalDate finishDate;
@ApiModelProperty(value = "状态--必带参数")
private Integer status;//状态
/**
* 当前页
*/
@ApiModelProperty(value = "当前页")
private Integer current;
/**
* 每页显示条数
*/
@ApiModelProperty(value = "每页显示条数")
private Integer size;
@ApiModelProperty(value = "总量")
private Integer total;
@ -59,7 +33,4 @@ public class QueryDTO {
private String roomNo;
}

@ -3,6 +3,7 @@ package digital.laboratory.platform.imr.dto;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import digital.laboratory.platform.imr.component.DateUtils;
import digital.laboratory.platform.imr.dto.base.BaseQuery;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -15,7 +16,7 @@ import java.time.LocalDateTime;
*/
@Data
@ApiModel(value = "仓库查询样本dto")
public class QuerySampleDTO {
public class QuerySampleDTO extends BaseQuery {
@ApiModelProperty(value = "样本名称")
private String name;//名称
@ -25,24 +26,8 @@ public class QuerySampleDTO {
// private String sampleNo;//编号
@ApiModelProperty(value = "入库开始时间")
@JsonFormat(pattern = DateUtils.yyyy_MM_dd, timezone = DateUtils.TIME_ZONE)
@JSONField(format = DateUtils.yyyy_MM_dd)
private LocalDate beginDate;
@ApiModelProperty(value = "入库结束时间")
@JsonFormat(pattern = DateUtils.yyyy_MM_dd, timezone = DateUtils.TIME_ZONE)
@JSONField(format = DateUtils.yyyy_MM_dd)
private LocalDate finishDate;
@ApiModelProperty(value = "状态--必带参数")
private Integer status;//状态
@ApiModelProperty(value = "当前页")
private Integer current;
/**
* 每页显示条数
*/
@ApiModelProperty(value = "每页显示条数")
private Integer size;
}

@ -1,6 +1,7 @@
package digital.laboratory.platform.imr.dto;
import digital.laboratory.platform.imr.dto.base.BaseQuery;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -11,7 +12,7 @@ import lombok.Data;
@Data
@ApiModel(value = "查询存储相关的dto")
public class QueryStorageDTO {
public class QueryStorageDTO extends BaseQuery {
@ApiModelProperty(value = "id--这个id可以是房间/柜子")
private String id;
@ -19,14 +20,4 @@ public class QueryStorageDTO {
@ApiModelProperty(value = "name--这个name可以是房间/柜子")
private String name;
@ApiModelProperty(value = "当前页")
private Integer current;
@ApiModelProperty(value = "每页显示条数")
private Integer size;
}

@ -0,0 +1,38 @@
package digital.laboratory.platform.imr.dto.base;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import digital.laboratory.platform.imr.component.DateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
@Data
@ApiModel(value = "BaseQuery", description = "基础查询DTO类")
public class BaseQuery {
@ApiModelProperty(value = "开始时间")
@JsonFormat(pattern = DateUtils.yyyy_MM_dd, timezone = DateUtils.TIME_ZONE)
@JSONField(format = DateUtils.yyyy_MM_dd)
private LocalDate beginDate;
@ApiModelProperty(value = "结束时间")
@JsonFormat(pattern = DateUtils.yyyy_MM_dd, timezone = DateUtils.TIME_ZONE)
@JSONField(format = DateUtils.yyyy_MM_dd)
private LocalDate finishDate;
/**
* 当前页
*/
@ApiModelProperty(value = "当前页")
private Integer current;
/**
* 每页显示条数
*/
@ApiModelProperty(value = "每页显示条数")
private Integer size;
}

@ -0,0 +1,29 @@
package digital.laboratory.platform.imr.query;
import com.fasterxml.jackson.annotation.JsonFormat;
import digital.laboratory.platform.imr.component.DateUtils;
import digital.laboratory.platform.imr.dto.base.BaseQuery;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
@Data
@ApiModel(value = "DrugStatisticQuery", description = "毒品送缴量统计 - 查询对象")
public class DrugStatisticQuery {
@ApiModelProperty(value = "开始日期")
@JsonFormat(pattern = DateUtils.yyyy_MM_dd)
private LocalDate startDate;
@ApiModelProperty(value = "结束日期")
@JsonFormat(pattern = DateUtils.yyyy_MM_dd)
private LocalDate endDate;
@ApiModelProperty(value = "送缴单位 统计")
private String orgId;
@ApiModelProperty(value = "毒品种类")
private String drugType;
}

@ -0,0 +1,16 @@
package digital.laboratory.platform.imr.service;
import digital.laboratory.platform.imr.query.DrugStatisticQuery;
import digital.laboratory.platform.imr.vo.DrugStatisticVO;
/**
* 毒品库送缴量统计 服务处接口
*/
public interface DrugHandingOverStatisticService {
/**
* 获取统计图的数据 根据时间范围, 送缴单位毒品种类返回数据
* @param query
* @return
*/
DrugStatisticVO statistic(DrugStatisticQuery query);
}

@ -0,0 +1,161 @@
package digital.laboratory.platform.imr.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import digital.laboratory.platform.imr.component.DateUtils;
import digital.laboratory.platform.imr.entity.DrugCaseInfo;
import digital.laboratory.platform.imr.entity.DrugMaterialInfo;
import digital.laboratory.platform.imr.mapper.DrugMaterialInfoMapper;
import digital.laboratory.platform.imr.query.DrugStatisticQuery;
import digital.laboratory.platform.imr.service.CommonFeignService;
import digital.laboratory.platform.imr.service.DrugCaseInfoService;
import digital.laboratory.platform.imr.service.DrugHandingOverStatisticService;
import digital.laboratory.platform.imr.vo.DrugMaterialInfoVO;
import digital.laboratory.platform.imr.vo.DrugStatisticVO;
import digital.laboratory.platform.sys.entity.SysOrg;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 毒品库送缴量统计 服务处接口 -- 实现类
*/
@Service
public class DrugHandingOverStatisticServiceImpl implements DrugHandingOverStatisticService {
@Resource
private DrugMaterialInfoMapper drugMaterialInfoMapper;
@Resource
private DrugCaseInfoService drugCaseInfoService;
@Resource
private CommonFeignService commonFeignService;
/**
* 获取统计图的数据 根据时间范围, 送缴单位毒品种类返回数据
* @param query
* @return
*/
@Override
public DrugStatisticVO statistic(DrugStatisticQuery query) {
List<List<Object>> lineChartData = buildLineChartData(query);
List<List<Object>> barChartData = buildBarChartData(query);
DrugStatisticVO drugStatisticVO = new DrugStatisticVO();
drugStatisticVO.setBarChartDataList(barChartData);
drugStatisticVO.setLineChartDataList(lineChartData);
return drugStatisticVO;
}
/**
* 构建柱状图的数据
* @param query
* @return
*/
private List<List<Object>> buildBarChartData(DrugStatisticQuery query) {
List<List<Object>> barChartData = new ArrayList<>();
List<Object> orgNameList = new ArrayList<>();
List<Object> dataList = new ArrayList<>();
// 根据案件表取所有的送缴单位
List<DrugCaseInfo> drugCaseInfoList = drugCaseInfoService.list();
Map<String, SysOrg> sysOrgMap = drugCaseInfoList.stream()
.collect(Collectors.toMap(
DrugCaseInfo::getHandingOverOrg,
drugCaseInfo -> commonFeignService.remoteGetSysOrg(drugCaseInfo.getHandingOverOrg()),
(existing, replacement) -> existing
)
);
// 根据时间点获取检材
List<DrugMaterialInfoVO> drugMaterialInfoVOList = drugMaterialInfoMapper.getDrugMaterialVO(
Wrappers.<DrugMaterialInfo>query()
.ge(query.getStartDate() != null, "dc.handing_over_date", query.getStartDate())
.le(query.getEndDate() != null, "dc.handing_over_date", query.getEndDate())
);
Map<String, List<DrugMaterialInfoVO>> groupByHandingOverOrgMap = drugMaterialInfoVOList.stream().collect(Collectors.groupingBy(DrugMaterialInfoVO::getHandingOverOrg));
sysOrgMap.forEach((orgId, sysOrg) -> {
List<DrugMaterialInfoVO> voList = groupByHandingOverOrgMap.get(orgId);
if (CollUtil.isNotEmpty(voList)) {
orgNameList.add(sysOrg.getAlias());
dataList.add(voList.size());
}
});
barChartData.add(orgNameList);
barChartData.add(dataList);
return barChartData;
}
/**
* 构建折线图的数据
* @param query
* @return
*/
private List<List<Object>> buildLineChartData(DrugStatisticQuery query) {
List<List<Object>> lineChartData = new ArrayList<>(); // 存储结果值
List<Object> monthsList = new ArrayList<>(); // 存储月份
List<Object> dataList = new ArrayList<>(); // 对应月份送缴的数量
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DateUtils.yyyy_MM); // 规定日期格式
LocalDate startDate = query.getStartDate();
LocalDate endDate = query.getEndDate();
// 判断当前查询的模式
if (startDate == null && endDate == null) {
// 默认统计 一年内的
LocalDate currentDate = LocalDate.now();
for (int i = 11; i >= 0; i--) {
fillLineChartData(monthsList, dataList, dateTimeFormatter, currentDate, i);
}
} else if (startDate != null && endDate != null) {
// 计算查询开始时间和接受时间相差的月份数量
long between = ChronoUnit.MONTHS.between(startDate, endDate);
for (int i = (int) (between -1); i >= 0; i--) {
fillLineChartData(monthsList, dataList, dateTimeFormatter, startDate, i);
}
} else if (startDate == null && endDate != null) {
// 只返回1年内的数据
for (int i = 11; i >= 0; i--) {
fillLineChartData(monthsList, dataList, dateTimeFormatter, endDate, i);
}
} else {
// 只返回1年内的数据
for (int i = 11; i >= 0; i--) {
fillLineChartData(monthsList, dataList, dateTimeFormatter, startDate.minusMonths(11), i);
}
}
lineChartData.add(monthsList);
lineChartData.add(dataList);
return lineChartData;
}
/**
* 填充折线图数据
*
* @param monthsList 月份列表用于存储月份字符串
* @param dataList 数据列表用于存储数据对象
* @param dateTimeFormatter 日期时间格式化器用于格式化日期
* @param startDate 起始日期
* @param i 月份偏移量
*/
private void fillLineChartData(List<Object> monthsList, List<Object> dataList, DateTimeFormatter dateTimeFormatter, LocalDate startDate, int i) {
LocalDate localDate = startDate.minusMonths(i);
LocalDate withDayOfMonth = localDate.withDayOfMonth(1);
dataList.add(
drugMaterialInfoMapper.getDrugMaterialVO(
Wrappers.<DrugMaterialInfo>query()
.ge("dc.handing_over_date", withDayOfMonth.atStartOfDay())
.le("dc.handing_over_date",
withDayOfMonth.plusMonths(1).minusDays(1).atTime(LocalTime.MAX))
).size()
);
monthsList.add(localDate.format(dateTimeFormatter));
}
}

@ -0,0 +1,24 @@
package digital.laboratory.platform.imr.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(value = "DrugStatisticVO", description = "毒品送缴量统计 -返回给前端显示的VO对象 ")
public class DrugStatisticVO {
@ApiModelProperty(value = "折线图数据")
private List<List<Object>> lineChartDataList;
@ApiModelProperty(value = "柱状图数据")
private List<List<Object>> barChartDataList;
@ApiModelProperty(value = "饼图数据")
private List<List<Object>> pieChartDataList;
@ApiModelProperty(value = "树状图数据")
private String treeChartDateList;
}
Loading…
Cancel
Save