|
@@ -5,18 +5,23 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import thyyxxk.webserver.dao.his.highreport.AllStatisticsDao;
|
|
|
import thyyxxk.webserver.dao.his.highreport.HighReportDao;
|
|
|
+import thyyxxk.webserver.entity.HeadInfo;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
import thyyxxk.webserver.entity.highreport.HighReportDto;
|
|
|
import thyyxxk.webserver.entity.highreport.ReportBaseInfo;
|
|
|
import thyyxxk.webserver.utils.DecimalUtil;
|
|
|
+import thyyxxk.webserver.utils.ExcelUtil;
|
|
|
import thyyxxk.webserver.utils.ReportUtil;
|
|
|
import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 全部报表
|
|
@@ -395,4 +400,109 @@ public class AllStatisticsService {
|
|
|
return ResultVoUtil.success(results);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Description 住院(申请/执行)科室核算收入报表
|
|
|
+ * @Author hsh
|
|
|
+ * @param dto 查询条件
|
|
|
+ * @return map
|
|
|
+ * @Date 2024/6/11 16:01
|
|
|
+ */
|
|
|
+ public ResultVo<Map<String, Object>> selectInpatientDeptAccountingReport(HighReportDto dto){
|
|
|
+ Map<String, Object> results = new HashMap<>();
|
|
|
+ // 执行科室
|
|
|
+ String suffer;
|
|
|
+ if("1".equals(dto.getType())){
|
|
|
+ suffer = "exec_unit";
|
|
|
+ } else {
|
|
|
+ suffer = "ward_code";
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> list = dao.selectInpatientDeptAccountingReport(dto.getStartTime(), dto.getEndTime(), suffer);
|
|
|
+ List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
+ List<HeadInfo> headList = new ArrayList<>();
|
|
|
+ Map<String, Map<String, List<Map<String, Object>>>> map =
|
|
|
+ list.stream().collect(Collectors.groupingBy(m -> (String) m.get("flm"), Collectors.groupingBy(m -> (String) m.get("hsm"))));
|
|
|
+ // 拼接列表表头
|
|
|
+ HeadInfo info = new HeadInfo();
|
|
|
+ info.setName("flm");
|
|
|
+ info.setDisplay("父类码");
|
|
|
+ info.setSort(1);
|
|
|
+ headList.add(info);
|
|
|
+ info = new HeadInfo();
|
|
|
+ info.setName("hsm");
|
|
|
+ info.setDisplay("核算码");
|
|
|
+ info.setSort(2);
|
|
|
+ headList.add(info);
|
|
|
+ List<Map<String, Object>> listHead = list.stream().sorted(Comparator.comparing(e -> String.valueOf(e.get("ksid")))).collect(Collectors.toList());
|
|
|
+ Map<String, List<Map<String, Object>>> mapHead = listHead.stream().collect(Collectors.groupingBy(m -> (String) m.get("ksid")));
|
|
|
+ int index = 3;
|
|
|
+ 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("ksmc"));
|
|
|
+ info1.setSort(index);
|
|
|
+ headList.add(info1);
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ // 拼接列表数据(还要计算小计!!!)
|
|
|
+ for (Map.Entry<String, Map<String, List<Map<String, Object>>>> entry1 : map.entrySet()) {
|
|
|
+ String key1 = entry1.getKey();
|
|
|
+ Map<String, List<Map<String, Object>>> map1 = entry1.getValue();
|
|
|
+ Map<String, Object> mapHj = new HashMap<>();
|
|
|
+ mapHj.put("flm", "小计:");
|
|
|
+ mapHj.put("hsm", "");
|
|
|
+ for (Map.Entry<String, List<Map<String, Object>>> entry2 : map1.entrySet()) {
|
|
|
+ Map<String, Object> m = new HashMap<>();
|
|
|
+ String key2 = entry2.getKey();
|
|
|
+ List<Map<String, Object>> l = entry2.getValue();
|
|
|
+ if(!l.isEmpty()){
|
|
|
+ m.put("flm", l.get(0).get("flmc"));
|
|
|
+ m.put("hsm", l.get(0).get("hsmc"));
|
|
|
+ for(Map<String, Object> map2 : l){
|
|
|
+ String ksId = (String) map2.get("ksid");
|
|
|
+ m.put(ksId, map2.get("totalCharge"));
|
|
|
+ Object k = mapHj.get(ksId);
|
|
|
+ if(null == k){
|
|
|
+ mapHj.put(ksId, DecimalUtil.add(BigDecimal.ZERO, (BigDecimal) map2.get("totalCharge")));
|
|
|
+ } else {
|
|
|
+ mapHj.put(ksId, DecimalUtil.add((BigDecimal) mapHj.get(ksId), (BigDecimal) map2.get("totalCharge")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataList.add(m);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataList.add(mapHj);
|
|
|
+ }
|
|
|
+ results.put("headList", headList);
|
|
|
+ results.put("dataList", dataList);
|
|
|
+ return ResultVoUtil.success(results);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description 住院(申请/执行)科室核算收入报表导出
|
|
|
+ * @Author hsh
|
|
|
+ * @param dto 条件
|
|
|
+ * @Date 2024/6/14 13:51
|
|
|
+ */
|
|
|
+ public void exportInpatientDeptAccountingReport(HttpServletResponse response, HighReportDto dto){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ ResultVo<Map<String, Object>> resultVo = selectInpatientDeptAccountingReport(dto);
|
|
|
+ Map<String, Object> report = resultVo.getData();
|
|
|
+ if(null == report){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 数据
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) report.get("dataList");
|
|
|
+ // 导出标题
|
|
|
+ String exportName = dto.getExportName();
|
|
|
+ // 组装表头
|
|
|
+ List<HeadInfo> headInfoList = (List<HeadInfo>) report.get("headList");
|
|
|
+ List<HeadInfo> sortHeadInfo = headInfoList.stream().sorted(Comparator.comparing(HeadInfo::getSort)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 导出
|
|
|
+ ExcelUtil.exportExcelReport(response, list, sortHeadInfo, exportName);
|
|
|
+ }
|
|
|
+
|
|
|
}
|