parent
315fe488e0
commit
f9ec26bbbb
@ -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,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,42 +1,17 @@ |
|||||||
package digital.laboratory.platform.imr.dto; |
package digital.laboratory.platform.imr.dto; |
||||||
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONField; |
import digital.laboratory.platform.imr.dto.base.BaseQuery; |
||||||
import com.fasterxml.jackson.annotation.JsonFormat; |
|
||||||
import digital.laboratory.platform.imr.component.DateUtils; |
|
||||||
import io.swagger.annotations.ApiModel; |
import io.swagger.annotations.ApiModel; |
||||||
import io.swagger.annotations.ApiModelProperty; |
import io.swagger.annotations.ApiModelProperty; |
||||||
import lombok.Data; |
import lombok.Data; |
||||||
|
|
||||||
import java.time.LocalDate; |
|
||||||
@Data |
@Data |
||||||
@ApiModel(value="查询申请通用DTO") |
@ApiModel(value="查询申请通用DTO") |
||||||
public class QueryApplyDTO { |
public class QueryApplyDTO extends BaseQuery { |
||||||
|
|
||||||
@ApiModelProperty(value = "申请类型(1.外带//2.销毁)") |
@ApiModelProperty(value = "申请类型(1.外带//2.销毁)") |
||||||
private Integer applyType;//名称
|
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 = "当前申请的状态") |
@ApiModelProperty(value = "当前申请的状态") |
||||||
private Integer status;//状态
|
private Integer status;//状态
|
||||||
/** |
|
||||||
* 当前页 |
|
||||||
*/ |
|
||||||
@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…
Reference in new issue