1.修改统计逻辑中对于送缴单位的处理,当前端传递的orgId不为空时需要查询子机构
master
陈江保 15 hours ago
parent f9ec26bbbb
commit c9d58304d2
  1. 9
      src/main/java/digital/laboratory/platform/imr/service/CommonFeignService.java
  2. 19
      src/main/java/digital/laboratory/platform/imr/service/impl/CommonFeignServiceImpl.java
  3. 37
      src/main/java/digital/laboratory/platform/imr/service/impl/DrugHandingOverStatisticServiceImpl.java

@ -22,6 +22,15 @@ public interface CommonFeignService {
*/
SysOrg remoteGetSysOrg(String orgId);
/**
* 根据机构id远程获取系统子机构信息
*
* @param orgId 用户信息
* @return 对应的远程系统机构信息
* @throws RuntimeException 如果未找到对应的机构信息则抛出运行时异常
*/
List<SysOrg> remoteGetSysOrgByParentId(String orgId);
/**
* 远程调用获取用户信息
* @param username

@ -70,6 +70,25 @@ public class CommonFeignServiceImpl implements CommonFeignService {
return sysOrg;
}
/**
* 根据机构id远程获取系统子机构信息
*
* @param orgId 用户信息
* @return 对应的远程系统机构信息
* @throws RuntimeException 如果未找到对应的机构信息则抛出运行时异常
*/
@Override
public List<SysOrg> remoteGetSysOrgByParentId(String orgId) {
SysOrg sysOrg = new SysOrg();
sysOrg.setParentId(orgId);
R<List<SysOrg>> r = remoteOrgService.innerGetOrgList(sysOrg);
if (r != null && r.getCode() == CommonConstants.SUCCESS) {
return r.getData();
} else {
throw new RuntimeException(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", orgId));
}
}
/**
* 远程调用或者用户信息
* @param username

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

Loading…
Cancel
Save