|
@@ -3,6 +3,7 @@ package thyyxxk.webserver.service.highreport;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.dao.his.highreport.AllStatisticsDao;
|
|
|
import thyyxxk.webserver.dao.his.highreport.HighReportDao;
|
|
|
import thyyxxk.webserver.entity.HeadInfo;
|
|
@@ -13,6 +14,7 @@ import thyyxxk.webserver.utils.DecimalUtil;
|
|
|
import thyyxxk.webserver.utils.ExcelUtil;
|
|
|
import thyyxxk.webserver.utils.ReportUtil;
|
|
|
import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
+import thyyxxk.webserver.utils.StringUtil;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
@@ -517,4 +519,121 @@ public class AllStatisticsService {
|
|
|
ExcelUtil.exportExcelReport(response, list, sortHeadInfo, exportName);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Description 查询住院工作量统计
|
|
|
+ * @Author hsh
|
|
|
+ * @param dto 查询条件
|
|
|
+ * @return map 住院工作量统计
|
|
|
+ * @Date 2024/8/20 11:26
|
|
|
+ */
|
|
|
+ public ResultVo<Map<String, Object>> selectWorkFeeStatistics(HighReportDto dto) {
|
|
|
+ Map<String, Object> results = new HashMap<>();
|
|
|
+ if(StringUtil.isBlank(dto.getReportId())){
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有配置报表id,请检查!");
|
|
|
+ }
|
|
|
+ // 查询费用相关信息
|
|
|
+ ReportBaseInfo report = highReportDao.selectReportPortalMenu(dto.getReportId(), null, null);
|
|
|
+ String sql = ReportUtil.sqlFormat(dto, report.getBaseSql());
|
|
|
+ List<Map<String, Object>> list = dao.executeSqlByZb(sql);
|
|
|
+ if(list.isEmpty()){
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "查询不到相应的报表数据,请检查!");
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> zyInDaysList = dao.selectZyInDays(dto.getStartTime(), dto.getEndTime(), dto.getDept());
|
|
|
+ Map<String, List<Map<String, Object>>> doctorNameMap = list.stream().collect(Collectors.groupingBy(f->String.valueOf(f.get("doctorName"))));
|
|
|
+ Map<String, List<Map<String, Object>>> inDaysMap = zyInDaysList.stream().collect(Collectors.groupingBy(f->String.valueOf(f.get("doctorName"))));
|
|
|
+ // 拼接数据展示内容
|
|
|
+ List<HeadInfo> headList = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<Map<String, Object>> listHead = list.stream().sorted(Comparator.comparing(e -> String.valueOf(e.get("code")))).collect(Collectors.toList());
|
|
|
+ Map<String, List<Map<String, Object>>> mapHead = listHead.stream().collect(Collectors.groupingBy(m -> (String) m.get("code")));
|
|
|
+ // 拼接列表表头
|
|
|
+ HeadInfo info = new HeadInfo();
|
|
|
+ info.setName("doctorName");
|
|
|
+ info.setDisplay("医生姓名");
|
|
|
+ info.setSort(1);
|
|
|
+ headList.add(info);
|
|
|
+ int index = 2;
|
|
|
+ for (Map.Entry<String, List<Map<String, Object>>> entryHead : mapHead.entrySet()) {
|
|
|
+ HeadInfo info1 = new HeadInfo();
|
|
|
+ String o = entryHead.getKey();
|
|
|
+ List<Map<String, Object>> l = entryHead.getValue();
|
|
|
+ info1.setName(o);
|
|
|
+ info1.setDisplay((String) l.get(0).get("name"));
|
|
|
+ info1.setSort(index);
|
|
|
+ headList.add(info1);
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ info = new HeadInfo();
|
|
|
+ info.setName("inDays");
|
|
|
+ info.setDisplay("管床天数");
|
|
|
+ info.setSort(index + 1);
|
|
|
+ headList.add(info);
|
|
|
+ // 拼接列表数据
|
|
|
+ for(Map.Entry<String, List<Map<String, Object>>> entry : doctorNameMap.entrySet()){
|
|
|
+ String key = entry.getKey();
|
|
|
+ List<Map<String, Object>> dataList = entry.getValue();
|
|
|
+ Map<String, Object> m1 = new HashMap<>();
|
|
|
+ if(StringUtil.notBlank(key) && !"null".equals(key)){
|
|
|
+ m1.put("doctorName", key);
|
|
|
+ } else {
|
|
|
+ m1.put("doctorName", "其他");
|
|
|
+ }
|
|
|
+ for(Map<String, Object> m : dataList){
|
|
|
+ m1.put(String.valueOf(m.get("code")), m.get("fee"));
|
|
|
+ }
|
|
|
+ //拼接医生的管床天数
|
|
|
+ if(!inDaysMap.isEmpty()){
|
|
|
+ if(StringUtil.isBlank(key) || "null".equals(key)){
|
|
|
+ if(null != inDaysMap.get(key)){
|
|
|
+ List<Map<String, Object>> inDays = inDaysMap.get(key);
|
|
|
+ int day = 0;
|
|
|
+ for (Map<String, Object> m2 : inDays) {
|
|
|
+ String d = String.valueOf(m2.get("day"));
|
|
|
+ day = day + Integer.parseInt(d);
|
|
|
+ }
|
|
|
+ m1.put("inDays", day);
|
|
|
+ }
|
|
|
+ } else if(null != inDaysMap.get(key)){
|
|
|
+ List<Map<String, Object>> inDays = inDaysMap.get(key);
|
|
|
+ m1.put("inDays", inDays.get(0).get("day"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultList.add(m1);
|
|
|
+ }
|
|
|
+
|
|
|
+ results.put("headList", headList);
|
|
|
+ results.put("resultList", resultList);
|
|
|
+ return ResultVoUtil.success(results);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description 住院工作量统计导出
|
|
|
+ * @Author hsh
|
|
|
+ * @param dto 导出条件
|
|
|
+ * @return map
|
|
|
+ * @Date 2024/8/20 11:27
|
|
|
+ */
|
|
|
+ public ResultVo<Map<String, Object>> exportWorkFeeStatisticsInfo(HttpServletResponse response, HighReportDto dto) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ ResultVo<Map<String, Object>> resultVo = selectWorkFeeStatistics(dto);
|
|
|
+ Map<String, Object> data = resultVo.getData();
|
|
|
+ // 数据
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) data.get("resultList");
|
|
|
+ list.add(dto.getTotal());
|
|
|
+
|
|
|
+ // 导出标题
|
|
|
+ String exportName = dto.getExportName();
|
|
|
+
|
|
|
+ // 组装表头
|
|
|
+ List<HeadInfo> headInfoList = (List<HeadInfo>) data.get("headList");
|
|
|
+ List<HeadInfo> sortHeadInfo = headInfoList.stream().sorted(Comparator.comparing(HeadInfo::getSort)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 导出
|
|
|
+ ExcelUtil.exportExcelReport(response, list, sortHeadInfo, exportName);
|
|
|
+
|
|
|
+ map.put("code", 0);
|
|
|
+ map.put("massage", "导出成功!");
|
|
|
+ return ResultVoUtil.success(map);
|
|
|
+ }
|
|
|
}
|