瀏覽代碼

修复报表问题

hurugang 5 年之前
父節點
當前提交
a792ac9c6e

+ 49 - 11
src/main/java/cn/hnthyy/thmz/controller/MzChargeDetailController.java

@@ -43,6 +43,8 @@ public class MzChargeDetailController {
     private MzPatientMiService mzPatientMiService;
     @Autowired
     private ZyZdAuditItemService zyZdAuditItemService;
+    @Autowired
+    private ZdChargeItemService zdChargeItemService;
 
     /**
      * 查询费用列表
@@ -988,19 +990,55 @@ public class MzChargeDetailController {
             Map<String, List<String>> parentMap = new HashMap<>();
             List<ZyZdAuditItem> zyZdAuditItems= zyZdAuditItemService.querytAll();
             //实际项目与父类码对应关系,因为数据查询中的父类码不准
-            Map<String, String> auditMap =  zyZdAuditItems.stream().collect(Collectors.toMap(ZyZdAuditItem::getName,ZyZdAuditItem::getParentCode));
-            for (Map<String, Object> map : depetBusinessReports) {
-                repeatSet.add((Date) map.get("charge_dcount_date"));
-                map.put("parent",auditMap.get(map.get("audit_code")));
-                fomartData(mzBillItemMap, parentList, depetList, depetSet, parentMap, map);
+            Map<String, ZyZdAuditItem> auditMap =  zyZdAuditItems.stream().collect(Collectors.toMap(ZyZdAuditItem::getCode,zyZdAuditItem->zyZdAuditItem));
+            if(depetBusinessReports.size()>0){
+                List<String> chargeBillCodes= new ArrayList<>(depetBusinessReports.stream().map(d-> (String)d.get("charge_bill_code")).collect(Collectors.toSet()));
+                //构造收费编码与核算码关系
+                List<ZdChargeItem> zdChargeItemList=zdChargeItemService.queryZdChargeItemByCodeList(chargeBillCodes);
+                Map<String, String> zdChargeItemMap = new HashMap<>();
+                for (ZdChargeItem zdChargeItem:zdChargeItemList){
+                    zdChargeItemMap.put(zdChargeItem.getCode(),zdChargeItem.getAuditCode());
+                }
+               // Map<String, String> zdChargeItemMap = zdChargeItemList.stream().collect(Collectors.toMap(ZdChargeItem::getCode, ZdChargeItem::getAuditCode));
+                for (Map<String, Object> map : depetBusinessReports) {
+                    repeatSet.add((Date) map.get("charge_dcount_date"));
+                    String auditCode= zdChargeItemMap.get(map.get("charge_bill_code"));
+                    ZyZdAuditItem zyZdAuditItem=auditMap.get(auditCode);
+                    if(zyZdAuditItem!=null){
+                        map.put("parent",zyZdAuditItem.getParentCode());
+                        map.put("audit_code",zyZdAuditItem.getName());
+                    }else {
+                        log.info("");
+                    }
+                    map.put("exec_dept",zdUnitCodeService.queryDeptNameByIdInCache((String) map.get("exec_dept")));
+                    fomartData(mzBillItemMap, parentList, depetList, depetSet, parentMap, map);
+                }
+
             }
-            for (Map<String, Object> map : depetBusinessReportsHis) {
-                if (repeatSet.contains(map.get("charge_dcount_date"))) {
-                    continue;
+            if(depetBusinessReportsHis.size()>0){
+                List<String> chargeBillCodes= new ArrayList<>(depetBusinessReportsHis.stream().map(d-> (String)d.get("charge_bill_code")).collect(Collectors.toSet()));
+                //构造收费编码与核算码关系
+                List<ZdChargeItem> zdChargeItemList=zdChargeItemService.queryZdChargeItemByCodeList(chargeBillCodes);
+                Map<String, String> zdChargeItemMap = new HashMap<>();
+                for (ZdChargeItem zdChargeItem:zdChargeItemList){
+                    zdChargeItemMap.put(zdChargeItem.getCode(),zdChargeItem.getAuditCode());
+                }
+                for (Map<String, Object> map : depetBusinessReportsHis) {
+                    if (repeatSet.contains(map.get("charge_dcount_date"))) {
+                        continue;
+                    }
+                    String auditCode= zdChargeItemMap.get(map.get("charge_bill_code"));
+                    ZyZdAuditItem zyZdAuditItem=auditMap.get(auditCode);
+                    if(zyZdAuditItem!=null){
+                        map.put("parent",zyZdAuditItem.getParentCode());
+                        map.put("audit_code",zyZdAuditItem.getName());
+                    }else {
+                        log.info("");
+                    }
+                    map.put("exec_dept",zdUnitCodeService.queryDeptNameByIdInCache((String) map.get("exec_dept")));
+                    depetBusinessReports.add(map);
+                    fomartData(mzBillItemMap, parentList, depetList, depetSet, parentMap, map);
                 }
-                map.put("parent",auditMap.get(map.get("audit_code")));
-                depetBusinessReports.add(map);
-                fomartData(mzBillItemMap, parentList, depetList, depetSet, parentMap, map);
             }
             Map<String,BigDecimal> formatMap = new HashMap<>();
 

+ 98 - 37
src/main/java/cn/hnthyy/thmz/mapper/his/MzChargeDetailMapper.java

@@ -830,50 +830,111 @@ public interface MzChargeDetailMapper {
      */
     @Select({"<script>",
             "SELECT " +
-                    "  exec_dept= z.name," +
-                    "       charge_bill_code= case a.charge_bill_code when 'BILL10' then 'BILL01' when 'BILL11' then 'BILL28' when 'BILL12' then 'BILL02' else a.charge_bill_code end," +
-                    "         parent=max( d.parent_code )," +
-                    "         total_charge= isnull(sum(round(convert(decimal(18,2),((case when convert(decimal(18,2),unit_price)=0.00 then 0.01 else convert(decimal(18,2),unit_price) end) * (quantity * isnull(drug_win,1)))),2)),0) ," +
-                    "         audit_code=case when isnull(a.group_no,'00')='71' then max(d.name)+'(门诊)' when isnull(a.group_no,'00')='72' then max(d.name)+'(急诊)' else max(d.name) end," +
-                    " charge_dcount_date=b.charge_dcount_date  " +
-                    "    FROM ${firstTableName} a(nolock),   " +
-                    "         (select distinct patient_id,times,receipt_no, serial_no,receipt_sn,charge_dcount_date,pay_id from ${secondTableName} " +
-                    "          where (case 1 when '0' then charge_date " +
-                    "                 else charge_dcount_date end) <![CDATA[>=]]> #{beginDate} and " +
-                    "                (case 1 when '0' then charge_date " +
-                    "                 else charge_dcount_date end) <![CDATA[<=]]> #{endDate} and " +
-                    " (fp_flag <![CDATA[<>]]> 'Y' or fp_flag is null) and " +
-                    "                (case 1 when '0' then isnull(dcount_no,0) " +
-                    "                 else 1 end) = isnull(dcount_no,0) ) as b, " +
-                    "         zd_charge_item c," +
-                    "         zy_zd_audit_item d, zd_unit_code  z " +
-                    "   WHERE ( a.patient_id = b.patient_id )    and  " +
-                    "           a.times=b.times and " +
-                    "           a.receipt_no=b.receipt_no and   " +
-                    "           case a.charge_bill_code when 'BILL10' then 'BILL01' when 'BILL11' then 'BILL28' when 'BILL12' then 'BILL02' else a.charge_bill_code end*=c.code and " +
-                    "           isnull(c.audit_code,d.code)=d.code and " +
-                    "           a.serial_no=b.serial_no and " +
-                    "           a.real_no=b.receipt_sn and " +
-                    "            a.bill_item_code <![CDATA[<>]]> 'TC'  " +
-                    "  and ( case 1 when #{caseType} then " +
-                    "      case when isnull(a.warn_dept,'')='' then  a.exec_dept else a.warn_dept end " +
-                    "      else  " +
-                    "     case when isnull(a.exec_dept,'') ='' then a.warn_dept else a.exec_dept end " +
-                    "  end )*=z.code " +
-
-//                    "          and isnull(a.dept_no,'') like '%' " +
+                    " exec_dept = (" +
+                    " CASE " +
+                    " 1 " +
+                    " WHEN ${caseType} THEN " +
+                    " CASE " +
+                    " WHEN isnull( a.warn_dept, '' ) = '' THEN " +
+                    " a.exec_dept ELSE a.warn_dept " +
+                    " END ELSE " +
+                    " CASE " +
+                    " WHEN isnull( a.exec_dept, '' ) = '' THEN " +
+                    " a.warn_dept ELSE a.exec_dept " +
+                    " END " +
+                    " END " +
+                    " )," +
+                    " charge_bill_code = " +
+                    " CASE " +
+                    " a.charge_bill_code " +
+                    " WHEN 'BILL10' THEN " +
+                    " 'BILL01' " +
+                    " WHEN 'BILL11' THEN " +
+                    " 'BILL28' " +
+                    " WHEN 'BILL12' THEN " +
+                    " 'BILL02' ELSE a.charge_bill_code " +
+                    " END, " +
+                    " total_charge = isnull(" +
+                    "SUM(" +
+                    " round( " +
+                    " CONVERT (" +
+                    "DECIMAL ( 18, 2 )," +
+                    " ( " +
+                    " ( " +
+                    " CASE " +
+                    " WHEN CONVERT ( DECIMAL ( 18, 2 ), unit_price ) = 0.00 THEN " +
+                    " 0.01 ELSE CONVERT ( DECIMAL ( 18, 2 ), unit_price ) " +
+                    " END  " +
+                    " ) * ( quantity * isnull( drug_win, 1 ) )  " +
+                    " )  " +
+                    " ), " +
+                    " 2  " +
+                    " )  " +
+                    " ), " +
+                    " 0  " +
+                    " ), " +
+                    " charge_dcount_date = b.charge_dcount_date  " +
+                    " FROM " +
+                    " ${firstTableName} a ( nolock ), " +
+                    " ( " +
+                    " SELECT DISTINCT " +
+                    " patient_id, " +
+                    " times, " +
+                    " receipt_no, " +
+                    " serial_no, " +
+                    " receipt_sn, " +
+                    " charge_dcount_date, " +
+                    " pay_id  " +
+                    " FROM " +
+                    " ${secondTableName} " +
+                    " WHERE " +
+                    " ( CASE 1 WHEN 0 THEN charge_date ELSE charge_dcount_date END ) <![CDATA[>=]]> #{beginDate}  " +
+                    " AND ( CASE 1 WHEN 0 THEN charge_date ELSE charge_dcount_date END ) <![CDATA[<=]]> #{endDate}  " +
+                    " AND ( fp_flag  <![CDATA[<>]]> 'Y' OR fp_flag IS NULL )  " +
+                    " AND ( CASE 1 WHEN 0 THEN isnull( charge_dcount_no, 0 ) ELSE 1 END ) = isnull( charge_dcount_no, 0 )  " +
+                    " ) AS b  " +
+                    " WHERE " +
+                    " ( a.patient_id = b.patient_id )  " +
+                    " AND a.times = b.times  " +
+                    " AND a.receipt_no = b.receipt_no  " +
+                    " AND a.serial_no = b.serial_no " +
+                    " AND a.real_no = b.receipt_sn  " +
+                    " AND a.bill_item_code <![CDATA[<>]]> 'TC'  " +
                     "<when test='execDept!=null'>",
-            "          and ( case '1' when #{caseType} then " +
+                    "          and ( case '1' when #{caseType} then " +
                     "      case when isnull(a.warn_dept,'')='' then  a.exec_dept else a.warn_dept end " +
                     "      else  " +
                     "     case when isnull(a.exec_dept,'') ='' then a.warn_dept else a.exec_dept end " +
                     "  end " +
                     ") =#{execDept} " +
                     "</when>" +
-                    " group by " +
-                    "z.name,c.audit_code,isnull(a.group_no,'00')," +
-                    " case a.charge_bill_code when 'BILL10' then 'BILL01' when 'BILL11' then 'BILL28' when 'BILL12' then 'BILL02' else a.charge_bill_code end" +
-                    ",b.charge_dcount_date,b.pay_id ",
+                    " GROUP BY " +
+                    " isnull( a.group_no, '00' ), " +
+                    " CASE " +
+                    " a.charge_bill_code  " +
+                    " WHEN 'BILL10' THEN " +
+                    " 'BILL01'  " +
+                    " WHEN 'BILL11' THEN " +
+                    " 'BILL28'  " +
+                    " WHEN 'BILL12' THEN " +
+                    " 'BILL02' ELSE a.charge_bill_code  " +
+                    " END, " +
+                    " b.charge_dcount_date, " +
+                    " b.pay_id, " +
+                    " ( " +
+                    " CASE " +
+                    " 1  " +
+                    " WHEN ${caseType} THEN " +
+                    " CASE " +
+                    " WHEN isnull( a.warn_dept, '' ) = '' THEN " +
+                    " a.exec_dept ELSE a.warn_dept  " +
+                    " END ELSE " +
+                    " CASE " +
+                    " WHEN isnull( a.exec_dept, '' ) = '' THEN " +
+                    " a.warn_dept ELSE a.exec_dept " +
+                    " END  " +
+                    " END  " +
+                    ")",
             "</script>"})
     List<Map<String, Object>> selectDepetBusinessReport(ThmzmxsrParamsVo thmzmxsrParamsVo);
 

+ 5 - 2
src/main/java/cn/hnthyy/thmz/mapper/his/ZdChargeItemMapper.java

@@ -21,6 +21,8 @@ public interface ZdChargeItemMapper {
        //     " and (del_flag != 1 or del_flag is null) " )
     ZdChargeItem selectZdChargeItemByCode(@Param("code") String code);
 
+
+
     /**
      * 根据收费项目编码集合查询所包含的收费项目
      *
@@ -32,9 +34,10 @@ public interface ZdChargeItemMapper {
             "rtrim(self_flag) self_flag,rtrim(separate_flag) separate_flag,rtrim(suppress_flag) suppress_flag,py_code,d_code wb_code,bill_item_zy,bill_item_mz,",
             "charge_unit,percent_group_zy,percent_group_mz,rtrim(in_out_flag) in_out_flag,n_code yn_code,class_code,s_code bz_code,discription,rtrim(del_flag) del_flag, ",
             "rtrim(yp_flag) yp_flag,bill_item_code,rtrim(xnh_flag) xnh_flag,add_date,hnsyb_code,hnsyb_name,xnh_code,xnh_name,xnh_ratio,xnh_quotamoney,rtrim(xnh_status) xnh_status,",
-            "yb_flag_new,yb_comment_new,yb_bl_new from zd_charge_item where (del_flag != 1 or del_flag is null) ",
+           // "yb_flag_new,yb_comment_new,yb_bl_new from zd_charge_item where (del_flag != 1 or del_flag is null) ",
+            "yb_flag_new,yb_comment_new,yb_bl_new from zd_charge_item  ",
             "<when test='codes!=null'>",
-            " and code in",
+            " where code in",
             "<foreach item='item' index='index' collection='codes' open='(' separator=',' close=')'>",
             "#{item}",
             "</foreach>",