|
|
@ -1,6 +1,7 @@ |
|
|
|
package digital.laboratory.platform.imr.service.impl; |
|
|
|
package digital.laboratory.platform.imr.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import digital.laboratory.platform.imr.component.DateUtils; |
|
|
|
import digital.laboratory.platform.imr.component.DateUtils; |
|
|
|
import digital.laboratory.platform.imr.entity.DrugCaseInfo; |
|
|
|
import digital.laboratory.platform.imr.entity.DrugCaseInfo; |
|
|
@ -21,8 +22,10 @@ import java.time.LocalTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.temporal.ChronoUnit; |
|
|
|
import java.time.temporal.ChronoUnit; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -65,15 +68,22 @@ public class DrugHandingOverStatisticServiceImpl implements DrugHandingOverStati |
|
|
|
List<Object> orgNameList = new ArrayList<>(); |
|
|
|
List<Object> orgNameList = new ArrayList<>(); |
|
|
|
List<Object> dataList = new ArrayList<>(); |
|
|
|
List<Object> dataList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 存储机构的map
|
|
|
|
|
|
|
|
Map<String, SysOrg> sysOrgMap = new HashMap<>(); |
|
|
|
// 根据案件表取所有的送缴单位
|
|
|
|
// 根据案件表取所有的送缴单位
|
|
|
|
|
|
|
|
if (StrUtil.isBlank(query.getOrgId())) { |
|
|
|
List<DrugCaseInfo> drugCaseInfoList = drugCaseInfoService.list(); |
|
|
|
List<DrugCaseInfo> drugCaseInfoList = drugCaseInfoService.list(); |
|
|
|
Map<String, SysOrg> sysOrgMap = drugCaseInfoList.stream() |
|
|
|
sysOrgMap = drugCaseInfoList.stream() |
|
|
|
.collect(Collectors.toMap( |
|
|
|
.collect(Collectors.toMap( |
|
|
|
DrugCaseInfo::getHandingOverOrg, |
|
|
|
DrugCaseInfo::getHandingOverOrg, |
|
|
|
drugCaseInfo -> commonFeignService.remoteGetSysOrg(drugCaseInfo.getHandingOverOrg()), |
|
|
|
drugCaseInfo -> commonFeignService.remoteGetSysOrg(drugCaseInfo.getHandingOverOrg()), |
|
|
|
(existing, replacement) -> existing |
|
|
|
(existing, replacement) -> existing |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
List<SysOrg> sysOrgList = commonFeignService.remoteGetSysOrgByParentId(query.getOrgId()); |
|
|
|
|
|
|
|
sysOrgMap = sysOrgList.stream().collect(Collectors.toMap(SysOrg::getOrgId, Function.identity())); |
|
|
|
|
|
|
|
} |
|
|
|
// 根据时间点获取检材
|
|
|
|
// 根据时间点获取检材
|
|
|
|
List<DrugMaterialInfoVO> drugMaterialInfoVOList = drugMaterialInfoMapper.getDrugMaterialVO( |
|
|
|
List<DrugMaterialInfoVO> drugMaterialInfoVOList = drugMaterialInfoMapper.getDrugMaterialVO( |
|
|
|
Wrappers.<DrugMaterialInfo>query() |
|
|
|
Wrappers.<DrugMaterialInfo>query() |
|
|
@ -112,23 +122,23 @@ public class DrugHandingOverStatisticServiceImpl implements DrugHandingOverStati |
|
|
|
// 默认统计 一年内的
|
|
|
|
// 默认统计 一年内的
|
|
|
|
LocalDate currentDate = LocalDate.now(); |
|
|
|
LocalDate currentDate = LocalDate.now(); |
|
|
|
for (int i = 11; i >= 0; i--) { |
|
|
|
for (int i = 11; i >= 0; i--) { |
|
|
|
fillLineChartData(monthsList, dataList, dateTimeFormatter, currentDate, i); |
|
|
|
fillLineChartData(monthsList, dataList, dateTimeFormatter, currentDate, query.getOrgId(), i); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (startDate != null && endDate != null) { |
|
|
|
} else if (startDate != null && endDate != null) { |
|
|
|
// 计算查询开始时间和接受时间相差的月份数量
|
|
|
|
// 计算查询开始时间和接受时间相差的月份数量
|
|
|
|
long between = ChronoUnit.MONTHS.between(startDate, endDate); |
|
|
|
long between = ChronoUnit.MONTHS.between(startDate, endDate); |
|
|
|
for (int i = (int) (between -1); i >= 0; i--) { |
|
|
|
for (int i = (int) (between -1); i >= 0; i--) { |
|
|
|
fillLineChartData(monthsList, dataList, dateTimeFormatter, startDate, i); |
|
|
|
fillLineChartData(monthsList, dataList, dateTimeFormatter, startDate, query.getOrgId(), i); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (startDate == null && endDate != null) { |
|
|
|
} else if (startDate == null && endDate != null) { |
|
|
|
// 只返回1年内的数据
|
|
|
|
// 只返回1年内的数据
|
|
|
|
for (int i = 11; i >= 0; i--) { |
|
|
|
for (int i = 11; i >= 0; i--) { |
|
|
|
fillLineChartData(monthsList, dataList, dateTimeFormatter, endDate, i); |
|
|
|
fillLineChartData(monthsList, dataList, dateTimeFormatter, endDate, query.getOrgId(), i); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// 只返回1年内的数据
|
|
|
|
// 只返回1年内的数据
|
|
|
|
for (int i = 11; i >= 0; i--) { |
|
|
|
for (int i = 11; i >= 0; i--) { |
|
|
|
fillLineChartData(monthsList, dataList, dateTimeFormatter, startDate.minusMonths(11), i); |
|
|
|
fillLineChartData(monthsList, dataList, dateTimeFormatter, startDate.minusMonths(11), query.getOrgId(), i); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
lineChartData.add(monthsList); |
|
|
|
lineChartData.add(monthsList); |
|
|
@ -145,12 +155,13 @@ public class DrugHandingOverStatisticServiceImpl implements DrugHandingOverStati |
|
|
|
* @param startDate 起始日期 |
|
|
|
* @param startDate 起始日期 |
|
|
|
* @param i 月份偏移量 |
|
|
|
* @param i 月份偏移量 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void fillLineChartData(List<Object> monthsList, List<Object> dataList, DateTimeFormatter dateTimeFormatter, LocalDate startDate, int i) { |
|
|
|
private void fillLineChartData(List<Object> monthsList, List<Object> dataList, DateTimeFormatter dateTimeFormatter, LocalDate startDate, String orgId, int i) { |
|
|
|
LocalDate localDate = startDate.minusMonths(i); |
|
|
|
LocalDate localDate = startDate.minusMonths(i); |
|
|
|
LocalDate withDayOfMonth = localDate.withDayOfMonth(1); |
|
|
|
LocalDate withDayOfMonth = localDate.withDayOfMonth(1); |
|
|
|
dataList.add( |
|
|
|
dataList.add( |
|
|
|
drugMaterialInfoMapper.getDrugMaterialVO( |
|
|
|
drugMaterialInfoMapper.getDrugMaterialVO( |
|
|
|
Wrappers.<DrugMaterialInfo>query() |
|
|
|
Wrappers.<DrugMaterialInfo>query() |
|
|
|
|
|
|
|
.eq(StrUtil.isNotBlank(orgId), "dc.handing_over_org", orgId) |
|
|
|
.ge("dc.handing_over_date", withDayOfMonth.atStartOfDay()) |
|
|
|
.ge("dc.handing_over_date", withDayOfMonth.atStartOfDay()) |
|
|
|
.le("dc.handing_over_date", |
|
|
|
.le("dc.handing_over_date", |
|
|
|
withDayOfMonth.plusMonths(1).minusDays(1).atTime(LocalTime.MAX)) |
|
|
|
withDayOfMonth.plusMonths(1).minusDays(1).atTime(LocalTime.MAX)) |
|
|
|