Browse Source

优化sql

lihong 5 months ago
parent
commit
b07b23e821

+ 5 - 5
src/main/java/cn/hnthyy/thmz/controller/zy/APatientMiController.java

@@ -254,11 +254,11 @@ public class APatientMiController {
             resultMap.put("message", "病人出生地址不能为空");
             return true;
         }
-        if (StringUtils.isBlank(aPatientMi.getInpatientNo())) {
-            resultMap.put("code", -1);
-            resultMap.put("message", "住院号不能为空或不能包含中文");
-            return true;
-        }
+        //if (StringUtils.isBlank(aPatientMi.getInpatientNo())) {
+        //    resultMap.put("code", -1);
+        //    resultMap.put("message", "住院号不能为空或不能包含中文");
+        //    return true;
+        //}
         if (Tools.containsChinese(aPatientMi.getInpatientNo())) {
             resultMap.put("code", -1);
             resultMap.put("message", "住院号不能包含中文");

+ 4 - 4
src/main/java/cn/hnthyy/thmz/mapper/his/mz/ChargeFeeVoMapper.java

@@ -1031,7 +1031,7 @@ public interface ChargeFeeVoMapper {
             "           a.times=b.times and  " +
             "           a.receipt_no=b.receipt_no and " +
             "           a.real_no=b.receipt_sn 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 " +
+            "           case a.charge_bill_code when 'BILL10' then 'BILL01' when 'BILL11' then 'BILL28' when 'BILL12' then 'BILL02' else a.charge_bill_code end in (select code from zd_charge_item ) and " +
             "           isnull(c.audit_code,'81')=d.code and " +
             "           a.serial_no=b.serial_no and " +
             "            a.bill_item_code<>'TC' " +
@@ -1138,7 +1138,7 @@ public interface ChargeFeeVoMapper {
             "  and  a.serial_no = c.serial_no  " +
             "    and         a.real_no = c.receipt_sn  " +
             "  and         case a.charge_bill_code " +
-            "  when 'BILL10' then 'BILL01' when 'BILL11' then 'BILL28' when 'BILL12' then 'BILL02' else a.charge_bill_code end *=d.code " +
+            "  when 'BILL10' then 'BILL01' when 'BILL11' then 'BILL28' when 'BILL12' then 'BILL02' else a.charge_bill_code end in (select code from zd_charge_item) " +
             "  and         isnull(d.audit_code,'61')=e.code) mzsr  where mzsr.je <![CDATA[<>]]> 0 " +
             "  and  case '1' when #{caseType} then mzsr.charge_date else  CONVERT(varchar(100), mzsr.dcount_date, 20) end <![CDATA[>=]]>#{beginDate,jdbcType=TIMESTAMP} " +
             "  and  case '1' when #{caseType} then mzsr.charge_date else  CONVERT(varchar(100), mzsr.dcount_date, 20) end <![CDATA[<]]>#{endDate,jdbcType=TIMESTAMP} " +
@@ -1257,8 +1257,8 @@ public interface ChargeFeeVoMapper {
             "<when test='warnDept!=null'>",
             " and a.warn_dept =#{warnDept} ",
             "</when>" +
-                    "    and a.charge_bill_code *=b.code  " +
-                    "    and (case when isnull(a.warn_dept,'')='' then  a.exec_dept else a.warn_dept end)*=e.code  " +
+                    "    and a.charge_bill_code in (select code from zd_charge_item)  " +
+                    "    and (case when isnull(a.warn_dept,'')='' then  a.exec_dept else a.warn_dept end) in (select code from zd_unit_code)  " +
                     "group by a.doctor_code,isnull(b.audit_code,a.charge_bill_code),e.name " +
                     "</script>"})
     List<Map<String, Object>> selectDoctorPerformanceStatistics(@Param("beginDate") String beginDate, @Param("endDate") String endDate, @Param("doctorCode") String doctorCode, @Param("warnDept") String warnDept);

+ 8 - 17
src/main/java/cn/hnthyy/thmz/mapper/his/zy/ZyDailySettlementMapper.java

@@ -272,14 +272,11 @@ public interface ZyDailySettlementMapper {
             "         charge28=sum(b.charge28),  " +
             "         name=max(c.name)," +
             "         receipt_no=max(b.receipt_no) " +
-            "    FROM  zy_ledger_file a,zy_receipt b,a_patient_mi c " +
+            "    FROM zy_ledger_file a join zy_receipt b on a.inpatient_no = b.inpatient_no and a.admiss_times = b.admiss_times " +
+            "     left join  a_patient_mi c on a.inpatient_no = b.inpatient_no " +
             "    WHERE a.cash_date >  #{beginTime} and " +
             " a.cash_date <= #{endTime}  and " +
-            "          (a.cash_id =#{opId} or a.cash_id is null)  and " +
-            "          a.inpatient_no=b.inpatient_no and " +
-            "          a.admiss_times=b.admiss_times and " +
-            "          a.ledger_sn   =b.ledger_sn    and " +
-            "          a.inpatient_no*=c.inpatient_no " +
+            "          (a.cash_id =#{opId} or a.cash_id is null)   " +
             " group by a.inpatient_no,a.admiss_times ,a.ledger_sn " +
             " order by receipt_no,a.inpatient_no")
     List<Map<String, Object>> selectZyChargeDetail(@Param("opId") String opId, @Param("beginTime") Date beginTime, @Param("endTime") Date endTime);
@@ -344,23 +341,17 @@ public interface ZyDailySettlementMapper {
             "        charge_tk   =isnull(max(d.charge_tk),0) ," +
             "        deposit     =case when a.ledger_sn<0 then 0 - abs(max(a.deposit)) else max(a.deposit) end  ," +
             "        receipt_no  =max(c.receipt_no)," +
-            "ledger_sn=a.ledger_sn " +
-            " from  zy_ledger_file a,zy_receipt c," +
-            "        (select inpatient_no,admiss_times,ledger_sn," +
+            " ledger_sn=a.ledger_sn " +
+            "          from zy_ledger_file a join zy_receipt c on a.inpatient_no=c.inpatient_no and a.admiss_times=c.admiss_times and a.ledger_sn = c.ledger_sn " +
+            "    left join    (select inpatient_no,admiss_times,ledger_sn," +
             "                charge_bk=sum(case when status in ('1','3','4','5') and depo_type <>'2' then depo_amount else 0 end)," +
             "                charge_tk=sum(case when status='2' then depo_amount else 0 end) " +
             "         from zy_deposit_file " +
             "         where  window_no='2' and depo_date > #{beginTime} and depo_date <=#{endTime} and status  in ('1','2','3','4','5') " +
-            "         group by inpatient_no,admiss_times,ledger_sn) as d " +
+            "         group by inpatient_no,admiss_times,ledger_sn) as d on a.inpatient_no = d.inpatient_no and a.admiss_times = d.admiss_times and a.ledger_sn=d.ledger_sn  " +
             " where   a.cash_date > #{beginTime}   and " +
             " a.cash_date <= #{endTime}   and " +
-            "        isnull(a.cash_id,a.op_id_code) =#{opId} and " +
-            "        a.inpatient_no=c.inpatient_no and " +
-            "        a.admiss_times=c.admiss_times and " +
-            "        a.ledger_sn   =c.ledger_sn    and " +
-            "        a.inpatient_no*=d.inpatient_no and " +
-            "        a.admiss_times*=d.admiss_times and " +
-            "        a.ledger_sn   *=d.ledger_sn  " +
+            "        isnull(a.cash_id,a.op_id_code) =#{opId}  " +
             " and  c.receipt_sn<>4 " +
             " group by a.inpatient_no,a.admiss_times,a.ledger_sn ) as z,${tableName} y " +
             " where z.in_no=y.inpatient_no and " +

+ 4 - 2
src/main/java/cn/hnthyy/thmz/service/impl/his/zy/ZyActpatientServiceImpl.java

@@ -722,7 +722,7 @@ public class ZyActpatientServiceImpl implements ZyActpatientService {
         String doorUrl = dictDataService.queryDictValueNotCach("3.1", "door_url", "");
         Map<String, Object> param = new HashMap<>();
         param.put("patNo",patNo);
-        ResultVo response = null;
+        ResultVo response = new ResultVo();
         if(StrUtil.isNotBlank(doorUrl)){
             try {
                 String res = HttpRequest.post(doorUrl+"/thyy/api/haikang/door/createPatient")
@@ -731,11 +731,13 @@ public class ZyActpatientServiceImpl implements ZyActpatientService {
                         .body();
                 response = (ResultVo)JsonUtil.jsontoObject(res, ResultVo.class);
             }catch (Exception e){
+                if(response == null){
+                    new ResultVo();
+                }
                 response.setCode(-1);
                 response.setMessage("创建门禁患者信息错误:"+e.getMessage());
             }
         }else {
-            response = new ResultVo();
             response.setCode(-2);
             response.setMessage("创建门禁患者信息未上线.....");
         }