|  | @@ -63,5 +63,129 @@ public interface AllStatisticsDao {
 | 
	
		
			
				|  |  |      List<Map<String, Object>> selectInpatientDeptAccountingReport(
 | 
	
		
			
				|  |  |              @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("suffer") String suffer);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Select("select " +
 | 
	
		
			
				|  |  | +            "   z.name as ksmc, " +
 | 
	
		
			
				|  |  | +            "   z.code as ksid, " +
 | 
	
		
			
				|  |  | +            "   sum ( a.charge_fee ) as totalCharge, " +
 | 
	
		
			
				|  |  | +            "   max ( d.parent_code ) as flm, " +
 | 
	
		
			
				|  |  | +            "   max ( e.name ) as flmc, " +
 | 
	
		
			
				|  |  | +            "   max ( d.name ) as hsmc, " +
 | 
	
		
			
				|  |  | +            "   c.audit_code as hsm " +
 | 
	
		
			
				|  |  | +            "from " +
 | 
	
		
			
				|  |  | +            " zy_detail_charge a ( nolock ), " +
 | 
	
		
			
				|  |  | +            " zd_charge_item c, " +
 | 
	
		
			
				|  |  | +            " zy_zd_audit_item d, " +
 | 
	
		
			
				|  |  | +            " zy_zd_audit_report e, " +
 | 
	
		
			
				|  |  | +            " zd_unit_code z, " +
 | 
	
		
			
				|  |  | +            " zy_patient f  " +
 | 
	
		
			
				|  |  | +            "where " +
 | 
	
		
			
				|  |  | +            "   a.charge_code = c.code  " +
 | 
	
		
			
				|  |  | +            " and c.audit_code *= d.code " +
 | 
	
		
			
				|  |  | +            " and d.parent_code = e.code " +
 | 
	
		
			
				|  |  | +            " and ( case when isnull( a.exec_unit, '' ) = '' then ( " +
 | 
	
		
			
				|  |  | +            "   case when isnull( f.zk_ward, '' ) = '' then a.ward_code else f.zk_ward end ) else a.exec_unit end ) *= z.code  " +
 | 
	
		
			
				|  |  | +            " and a.charge_date >= #{startTime}  " +
 | 
	
		
			
				|  |  | +            " and a.charge_date <= #{endTime}  " +
 | 
	
		
			
				|  |  | +            " and a.charge_status >= 2 " +
 | 
	
		
			
				|  |  | +            " and a.inpatient_no = f.inpatient_no  " +
 | 
	
		
			
				|  |  | +            " and a.admiss_times = f.admiss_times  " +
 | 
	
		
			
				|  |  | +            " group by " +
 | 
	
		
			
				|  |  | +            "   z.name, " +
 | 
	
		
			
				|  |  | +            "   z.code, " +
 | 
	
		
			
				|  |  | +            "   c.audit_code")
 | 
	
		
			
				|  |  | +    List<Map<String, Object>> selectInpatientDeptAccountingReportZyExecDept(
 | 
	
		
			
				|  |  | +            @Param("startTime") String startTime, @Param("endTime") String endTime);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Select("select  " +
 | 
	
		
			
				|  |  | +            "   z.name as ksmc,  " +
 | 
	
		
			
				|  |  | +            "   z.code as ksid,  " +
 | 
	
		
			
				|  |  | +            "   sum ( a.charge_fee ) as totalCharge,  " +
 | 
	
		
			
				|  |  | +            "   max ( d.parent_code ) as flm,  " +
 | 
	
		
			
				|  |  | +            "   max ( e.name ) as flmc,  " +
 | 
	
		
			
				|  |  | +            "   max ( d.name ) as hsmc,  " +
 | 
	
		
			
				|  |  | +            "   c.audit_code as hsm  " +
 | 
	
		
			
				|  |  | +            "from  " +
 | 
	
		
			
				|  |  | +            " zy_detail_charge a ( nolock ),  " +
 | 
	
		
			
				|  |  | +            " zd_charge_item c,  " +
 | 
	
		
			
				|  |  | +            " zy_zd_audit_item d,  " +
 | 
	
		
			
				|  |  | +            " zy_zd_audit_report e,  " +
 | 
	
		
			
				|  |  | +            " zd_unit_code z,  " +
 | 
	
		
			
				|  |  | +            " zy_patient f   " +
 | 
	
		
			
				|  |  | +            "where  " +
 | 
	
		
			
				|  |  | +            "   a.charge_code = c.code   " +
 | 
	
		
			
				|  |  | +            " and c.audit_code *= d.code   " +
 | 
	
		
			
				|  |  | +            " and a.ward_code *= z.code   " +
 | 
	
		
			
				|  |  | +            " and d.parent_code = e.code  " +
 | 
	
		
			
				|  |  | +            " and a.charge_date >= #{startTime}   " +
 | 
	
		
			
				|  |  | +            " and a.charge_date <= #{endTime}   " +
 | 
	
		
			
				|  |  | +            " and a.charge_status >= 2 )   " +
 | 
	
		
			
				|  |  | +            " and a.inpatient_no= f.inpatient_no   " +
 | 
	
		
			
				|  |  | +            " and a.admiss_times= f.admiss_times   " +
 | 
	
		
			
				|  |  | +            " group by  " +
 | 
	
		
			
				|  |  | +            "   z.name,  " +
 | 
	
		
			
				|  |  | +            "   z.code,  " +
 | 
	
		
			
				|  |  | +            "   c.audit_code")
 | 
	
		
			
				|  |  | +    List<Map<String, Object>> selectInpatientDeptAccountingReportZyWardCode(
 | 
	
		
			
				|  |  | +            @Param("startTime") String startTime, @Param("endTime") String endTime);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Select(" select z.name as ksmc, " +
 | 
	
		
			
				|  |  | +            "        z.code as ksid, " +
 | 
	
		
			
				|  |  | +            "        max(d.parent_code) as flm, " +
 | 
	
		
			
				|  |  | +            "        max(e.name) as flmc, " +
 | 
	
		
			
				|  |  | +            "        isnull(sum(round(convert(decimal(18,3),((convert(decimal(18,3),unit_price)) * (quantity * isnull(drug_win,1)))),2)),0) as totalCharge, " +
 | 
	
		
			
				|  |  | +            "        max(d.name) as hsmc, " +
 | 
	
		
			
				|  |  | +            "        c.audit_code as hsm " +
 | 
	
		
			
				|  |  | +            "   from mz_charge_detail a(nolock),    " +
 | 
	
		
			
				|  |  | +            "        (select distinct patient_id,times,receipt_no, serial_no,receipt_sn from mz_receipt_serial " +
 | 
	
		
			
				|  |  | +            "         where charge_date >= #{startTime}   " +
 | 
	
		
			
				|  |  | +            "           and charge_date <= #{endTime}) as b, " +
 | 
	
		
			
				|  |  | +            "        zd_charge_item c, " +
 | 
	
		
			
				|  |  | +            "        zy_zd_audit_item d, " +
 | 
	
		
			
				|  |  | +            "        zy_zd_audit_report e, " +
 | 
	
		
			
				|  |  | +            "        zd_unit_code z  " +
 | 
	
		
			
				|  |  | +            "  where a.patient_id = b.patient_id  " +
 | 
	
		
			
				|  |  | +            "    and a.times = b.times  " +
 | 
	
		
			
				|  |  | +            "    and a.receipt_no = b.receipt_no    " +
 | 
	
		
			
				|  |  | +            "    and a.real_no = b.receipt_sn   " +
 | 
	
		
			
				|  |  | +            "    and d.parent_code = e.code " +
 | 
	
		
			
				|  |  | +            "    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.bill_item_code <> 'TC' " +
 | 
	
		
			
				|  |  | +            "    and (case when isnull(a.exec_dept,'') = '' or a.exec_dept = 'null' then a.warn_dept else a.exec_dept end) *= z.code  " +
 | 
	
		
			
				|  |  | +            "    and a.exec_dept <> '0000000' " +
 | 
	
		
			
				|  |  | +            "  group by z.name, z.code, c.audit_code")
 | 
	
		
			
				|  |  | +    List<Map<String, Object>> selectInpatientDeptAccountingReportMzExecDept(
 | 
	
		
			
				|  |  | +            @Param("startTime") String startTime, @Param("endTime") String endTime);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Select(" select z.name as ksmc, " +
 | 
	
		
			
				|  |  | +            "        z.code as ksid, " +
 | 
	
		
			
				|  |  | +            "        max(d.parent_code) as flm, " +
 | 
	
		
			
				|  |  | +            "        max(e.name) as flmc, " +
 | 
	
		
			
				|  |  | +            "        isnull(sum(round(convert(decimal(18,3),((convert(decimal(18,3),unit_price)) * (quantity * isnull(drug_win,1)))),2)),0) as totalCharge, " +
 | 
	
		
			
				|  |  | +            "        max(d.name) as hsmc, " +
 | 
	
		
			
				|  |  | +            "        c.audit_code as hsm " +
 | 
	
		
			
				|  |  | +            "   from mz_charge_detail a(nolock),    " +
 | 
	
		
			
				|  |  | +            "        (select distinct patient_id,times,receipt_no, serial_no,receipt_sn from mz_receipt_serial " +
 | 
	
		
			
				|  |  | +            "         where charge_date >= #{startTime}   " +
 | 
	
		
			
				|  |  | +            "           and charge_date <= #{endTime}) as b, " +
 | 
	
		
			
				|  |  | +            "        zd_charge_item c, " +
 | 
	
		
			
				|  |  | +            "        zy_zd_audit_item d, " +
 | 
	
		
			
				|  |  | +            "        zy_zd_audit_report e, " +
 | 
	
		
			
				|  |  | +            "        zd_unit_code z  " +
 | 
	
		
			
				|  |  | +            "  where a.patient_id = b.patient_id  " +
 | 
	
		
			
				|  |  | +            "    and a.times = b.times  " +
 | 
	
		
			
				|  |  | +            "    and a.receipt_no = b.receipt_no    " +
 | 
	
		
			
				|  |  | +            "    and a.real_no = b.receipt_sn   " +
 | 
	
		
			
				|  |  | +            "    and d.parent_code = e.code " +
 | 
	
		
			
				|  |  | +            "    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.bill_item_code <> 'TC' " +
 | 
	
		
			
				|  |  | +            "    and (case when isnull(a.warn_dept,'') = '' or a.warn_dept = 'null' then a.exec_dept else a.warn_dept end) *= z.code  " +
 | 
	
		
			
				|  |  | +            "    and a.exec_dept <> '0000000' " +
 | 
	
		
			
				|  |  | +            "  group by z.name, z.code, c.audit_code")
 | 
	
		
			
				|  |  | +    List<Map<String, Object>> selectInpatientDeptAccountingReportMzWardDept(
 | 
	
		
			
				|  |  | +            @Param("startTime") String startTime, @Param("endTime") String endTime);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  }
 |