lihong il y a 3 mois
Parent
commit
932f1198b9

+ 21 - 26
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzPharmacyMapper.java

@@ -299,19 +299,16 @@ public interface MzPharmacyMapper {
             "         yp_mz_fytj.refund_medicine_remark  ," +
             "         real_no=yp_mz_fytj.real_no," +
             "         win_no = yp_mz_fytj.win_no " +
-            "    FROM yp_mz_fytj WITH(NOLOCK) , " +
-            "         yp_zd_dict c WITH(NOLOCK), " +
-            "         yp_zd_manufactory d WITH(NOLOCK) " +
-            "   WHERE  yp_mz_fytj.patient_id = #{patientId}  AND  " +
+            "    FROM yp_mz_fytj WITH(NOLOCK) " +
+            "    JOIN yp_zd_dict c WITH(NOLOCK) ON yp_mz_fytj.charge_item_code = c.code AND yp_mz_fytj.serial = c.serial " +
+            "    LEFT JOIN yp_zd_manufactory d WITH(NOLOCK) ON c.manu_code = d.code " +
+            "   WHERE yp_mz_fytj.patient_id = #{patientId}  AND  " +
             "          yp_mz_fytj.times = #{times}  AND  " +
             "          yp_mz_fytj.receipt_no = #{receiptNo}  AND  " +
             "          yp_mz_fytj.order_no = #{orderNo}  AND  " +
             "         yp_mz_fytj.group_no_out = #{groupNoOut} AND  " +
-            "          yp_mz_fytj.charge_item_code = c.code  and  " +
-            "          yp_mz_fytj.serial = c.serial  and  " +
             "         yp_mz_fytj.confirm_flag = #{confirmFlag}   and " +
-            "         yp_mz_fytj.serial_no <![CDATA[<]]> 0 and " +
-            "         c.manu_code *= d.code " +
+            "         yp_mz_fytj.serial_no <![CDATA[<]]> 0 " +
             "ORDER BY yp_mz_fytj.item_no ASC ",
             "</script>"})
     List<Map<String, Object>> selectPrescriptionYpMx(ChargeFeeParamsVo chargeFeeParamsVo);
@@ -678,9 +675,9 @@ public interface MzPharmacyMapper {
             "         a.frequency," +
             "         a.drug_quan," +
             "         drug_unit=case when a.group_no in ('81', '83') then c.pack_unit else isnull(a.drug_unit,'') end," +
-            "yp_unit=c.pack_unit," +
-            " c.mini_unit," +
-            " c.national_code," +
+            "         yp_unit=c.pack_unit," +
+            "         c.mini_unit," +
+            "         c.national_code," +
             "         a.order_days," +
             "         doctor_code=a.doctor_code," +
             "         a.charge_date," +
@@ -732,24 +729,22 @@ public interface MzPharmacyMapper {
             "         abbr_name=case when isnull(d.abbr_name,'')='' then d.name else d.abbr_name end," +
             "         try_result = a.try_result," +
             "         yb_zf_flag=a.yb_zf_flag," +
-            " a.confirm_id," +
+            "         a.confirm_id," +
             "         print_flag_yj=isnull(a.print_flag_yj,'')," +
             "         confirm_flag_b=confirm_flag," +
             "         a.manu_no" +
-            "    FROM mz_charge_detail a WITH(NOLOCK), yp_base_yf b WITH(NOLOCK),yp_zd_dict c WITH(NOLOCK),yp_zd_manufactory d WITH(NOLOCK)" +
-            " where    a.patient_id=#{patientId} and" +
-            "         a.times     =#{times} and" +
-            "         a.receipt_no=#{receiptNo} and" +
-            "         a.order_no =#{orderNo}   and" +
-            "         a.charge_item_code =b.charge_code and " +
-            "         a.serial   =b.serial and " +
-            "         b.group_no =#{groupNo} and  " +
-            "         b.group_no =a.group_no and  " +
-            "         a.bill_item_code <![CDATA[<>]]>'TC'and" +
-            "         a.charge_item_code=c.code and" +
-            "         a.serial=c.serial and" +
-            "         c.manu_code *= d.code and" +
-            "         a.real_no = #{realNo} ",
+            "    FROM mz_charge_detail a WITH(NOLOCK)" +
+            "    JOIN yp_base_yf b WITH(NOLOCK) ON a.charge_item_code = b.charge_code AND a.serial = b.serial" +
+            "    JOIN yp_zd_dict c WITH(NOLOCK) ON a.charge_item_code = c.code AND a.serial = c.serial" +
+            "    LEFT JOIN yp_zd_manufactory d WITH(NOLOCK) ON c.manu_code = d.code" +
+            "    WHERE a.patient_id = #{patientId} and" +
+            "          a.times = #{times} and" +
+            "          a.receipt_no = #{receiptNo} and" +
+            "          a.order_no = #{orderNo} and" +
+            "          b.group_no = #{groupNo} and" +
+            "          b.group_no = a.group_no and" +
+            "          a.bill_item_code <![CDATA[<>]]> 'TC' and" +
+            "          a.real_no = #{realNo}" +
             "</script>"})
     List<MzSendMedicineVo> selectFyclPrescriptionDetail(MzChargeDetail mzChargeDetail);
 

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

@@ -20,7 +20,16 @@ public interface YpZdClassMapper {
      *
      * @return
      */
-    @Select("SELECT dl_code=a.code,dl_name=a.name,xl_code=b.code,xl_name=b.name FROM jy_zd_class  a WITH(NOLOCK),jy_zd_item b WITH(NOLOCK) where  a.code*=b.class and isnull(b.del_flag,'') <> '1'  and isnull(b.mz_flag,'') <> '1'  order  by a.code ")
+    @Select("SELECT " +
+            "   dl_code = a.code, " +
+            "   dl_name = a.name, " +
+            "   xl_code = b.code, " +
+            "   xl_name = b.name " +
+            "FROM jy_zd_class a WITH(NOLOCK) " +
+            "LEFT JOIN jy_zd_item b WITH(NOLOCK) ON a.code = b.class " +
+            "WHERE ISNULL(b.del_flag,'') <> '1' " +
+            "  AND ISNULL(b.mz_flag,'') <> '1' " +
+            "ORDER BY a.code")
     List<Map<String, Object>> selectJyZdClasses();
 
 
@@ -29,9 +38,27 @@ public interface YpZdClassMapper {
      *
      * @return
      */
-    @Select("SELECT dl_code=a.code+b.bw_code,dl_name=rtrim(a.name)+' '+ltrim(c.name),xl_code=b.code,xl_name=b.name FROM jc_zd_class a WITH(NOLOCK),jc_zd_item b WITH(NOLOCK),ysh_zd_part_code c WITH(NOLOCK) " +
-            "where a.code*=b.class and isnull(b.del_flag,'') <> '1' and isnull(b.mz_flag,'') <> '1' and b.bw_code=c.code union SELECT dl_code=a.code,dl_name=rtrim(a.name),xl_code=b.code,xl_name=b.name FROM jc_zd_class " +
-            " a WITH(NOLOCK),jc_zd_item b WITH(NOLOCK) where a.code*=b.class and isnull(b.del_flag,'') <> '1' and isnull(b.mz_flag,'') <> '1' and (b.bw_code is null or b.bw_code='') order by dl_name,xl_name ")
+    @Select(
+            "SELECT " +
+            "   dl_code = a.code + ISNULL(b.bw_code, ''), " +
+            "   dl_name = RTRIM(a.name) + CASE WHEN b.bw_code IS NOT NULL AND b.bw_code != '' THEN ' ' + LTRIM(c.name) ELSE '' END, " +
+            "   xl_code = b.code, " +
+            "   xl_name = b.name " +
+            "FROM jc_zd_class a WITH(NOLOCK) " +
+            "LEFT JOIN jc_zd_item b WITH(NOLOCK) ON a.code = b.class AND ISNULL(b.del_flag, '') <> '1' AND ISNULL(b.mz_flag, '') <> '1' " +
+            "LEFT JOIN ysh_zd_part_code c WITH(NOLOCK) ON b.bw_code = c.code " +
+            "WHERE (b.bw_code IS NOT NULL AND b.bw_code != '') " +
+            " UNION ALL " +
+            " SELECT " +
+            "   dl_code = a.code, " +
+            "   dl_name = RTRIM(a.name), " +
+            "   xl_code = b.code, " +
+            "   xl_name = b.name " +
+            " FROM jc_zd_class a WITH(NOLOCK) " +
+            " LEFT JOIN jc_zd_item b WITH(NOLOCK) ON a.code = b.class AND ISNULL(b.del_flag, '') <> '1' AND ISNULL(b.mz_flag, '') <> '1' " +
+            " WHERE (b.bw_code IS NULL OR b.bw_code = '') " +
+            " ORDER BY dl_name, xl_name"
+           )
     List<Map<String, Object>> selectJcZdClasses();
 
     /**

+ 29 - 28
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpMzFytjMapper.java

@@ -159,20 +159,17 @@ public interface YpMzFytjMapper {
             "         real_no=yp_mz_fytj.real_no," +
             "         win_no = yp_mz_fytj.win_no, " +
             "         yp_mz_fytj.manu_no " +
-            "    FROM yp_mz_fytj WITH(NOLOCK) , " +
-            "         yp_zd_dict c WITH(NOLOCK), " +
-            "         yp_zd_manufactory d WITH(NOLOCK) " +
-            "   WHERE  yp_mz_fytj.patient_id = #{patientId}  AND  " +
+            "    FROM yp_mz_fytj WITH(NOLOCK) " +
+            "    JOIN yp_zd_dict c WITH(NOLOCK) ON yp_mz_fytj.charge_item_code = c.code AND yp_mz_fytj.serial = c.serial " +
+            "    LEFT JOIN yp_zd_manufactory d WITH(NOLOCK) ON c.manu_code = d.code " +
+            "   WHERE yp_mz_fytj.patient_id = #{patientId}  AND  " +
             "          yp_mz_fytj.times = #{times}  AND  " +
             "          yp_mz_fytj.receipt_no = #{receiptNo}  AND  " +
             "          yp_mz_fytj.order_no = #{orderNo}  AND  " +
-            "         yp_mz_fytj.group_no_out = #{groupNoOut} AND  " +
-            "          yp_mz_fytj.charge_item_code = c.code  and  " +
-            "          yp_mz_fytj.serial = c.serial  and  " +
-            "         yp_mz_fytj.confirm_flag = '1'   and " +
-            "         yp_mz_fytj.serial_no > 0 and " +
-            "         c.manu_code *= d.code " +
-            "ORDER BY yp_mz_fytj.item_no ASC ",
+            "          yp_mz_fytj.group_no_out = #{groupNoOut} AND  " +
+            "          yp_mz_fytj.confirm_flag = '1'   and " +
+            "          yp_mz_fytj.serial_no > 0 " +
+            "ORDER BY yp_mz_fytj.item_no ASC " +
             "</script>"})
     List<Map<String,Object>> selectYpMx(ChargeFeeParamsVo chargeFeeParamsVo);
 
@@ -222,7 +219,7 @@ public interface YpMzFytjMapper {
             "         yp_mz_fytj.receipt_no,   " +
             "         drugname=c.name+'('+isnull(d.abbr_name,isnull(d.name,''))+')',   " +
             "         specification=c.specification,   " +
-            "         quantity= case when yp_mz_fytj.cy_fy is not null and yp_mz_fytj.cy_fy >0   then yp_mz_fytj.quantity * cy_fy else yp_mz_fytj.quantity end,   " +
+            "         quantity= case when yp_mz_fytj.cy_fy is not null and yp_mz_fytj.cy_fy > 0 then yp_mz_fytj.quantity * cy_fy else yp_mz_fytj.quantity end,   " +
             "         yp_mz_fytj.unit_price,   " +
             "         yp_mz_fytj.item_no,   " +
             "         yp_mz_fytj.drug_flag,   " +
@@ -241,27 +238,31 @@ public interface YpMzFytjMapper {
             "         yp_mz_fytj.drugname,   " +
             "         yp_mz_fytj.doctor_name,   " +
             "         yp_mz_fytj.doctor_id,   " +
-            "         dec_amount=case when yp_mz_fytj.cy_fy is not null and yp_mz_fytj.cy_fy >0   then yp_mz_fytj.quantity * cy_fy else yp_mz_fytj.quantity end  ,       " +
+            "         dec_amount=case when yp_mz_fytj.cy_fy is not null and yp_mz_fytj.cy_fy > 0 then yp_mz_fytj.quantity * cy_fy else yp_mz_fytj.quantity end,       " +
             "         warn_dept=yp_mz_fytj.warn_dept,   " +
             "         yp_mz_fytj.country_flag,   " +
             "         yp_mz_fytj.confirm_flag,   " +
             "         yp_mz_fytj.self_flag,   " +
             "         yp_mz_fytj.response_type,   " +
-            "         yp_mz_fytj.warn_dept  ," +
-            "         real_no=yp_mz_fytj.real_no," +
-            "         win_no = yp_mz_fytj.win_no, " +
-            "         yp_mz_fytj.manu_no " +
-            "    FROM  (select * from yp_mz_fytj WITH(NOLOCK) where patient_id = #{patientId} and times = #{times} and receipt_no = #{receiptNo} and quantity  <![CDATA[>]]> 0 ) yp_mz_fytj , " +
-            "         yp_zd_dict c WITH(NOLOCK), " +
-            "         yp_zd_manufactory d WITH(NOLOCK) " +
-            "   WHERE  yp_mz_fytj.order_no = #{orderNo}  AND  " +
-            "         yp_mz_fytj.group_no_out = #{groupNoOut} AND  " +
-            "          yp_mz_fytj.charge_item_code = c.code  and  " +
-            "          yp_mz_fytj.serial = c.serial  and  " +
-            "         yp_mz_fytj.confirm_flag = '2'   and " +
-            "         yp_mz_fytj.serial_no <![CDATA[<]]> 0 and " +
-            "         c.manu_code *= d.code " +
-            "ORDER BY yp_mz_fytj.item_no ASC ",
+            "         yp_mz_fytj.warn_dept,   " +
+            "         real_no=yp_mz_fytj.real_no,   " +
+            "         win_no = yp_mz_fytj.win_no,   " +
+            "         yp_mz_fytj.manu_no   " +
+            "    FROM (SELECT * FROM yp_mz_fytj WITH(NOLOCK) " +
+            "           WHERE patient_id = #{patientId} " +
+            "             AND times = #{times} " +
+            "             AND receipt_no = #{receiptNo} " +
+            "             AND quantity <![CDATA[>]]> 0) yp_mz_fytj   " +
+            "    JOIN yp_zd_dict c WITH(NOLOCK) " +
+            "      ON yp_mz_fytj.charge_item_code = c.code " +
+            "     AND yp_mz_fytj.serial = c.serial   " +
+            "    LEFT JOIN yp_zd_manufactory d WITH(NOLOCK) " +
+            "      ON c.manu_code = d.code   " +
+            "   WHERE yp_mz_fytj.order_no = #{orderNo}   " +
+            "     AND yp_mz_fytj.group_no_out = #{groupNoOut}   " +
+            "     AND yp_mz_fytj.confirm_flag = '2'   " +
+            "     AND yp_mz_fytj.serial_no <![CDATA[<]]> 0   " +
+            "ORDER BY yp_mz_fytj.item_no ASC   " +
             "</script>"})
     List<Map<String,Object>> selectRefundMedicineDetail(ChargeFeeParamsVo chargeFeeParamsVo);
     /**

+ 6 - 6
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpZdDeptMapper.java

@@ -45,12 +45,12 @@ public interface YpZdDeptMapper {
             " use_flag=isnull(c.use_flag,'0')," +
             "                         a.code as charge_code," +
             "                         a.name" +
-            " FROM yp_zd_dict  a WITH(NOLOCK) ,yp_base_yf b WITH(NOLOCK),yp_zd_dept c WITH(NOLOCK)" +
-            " where a.code=b.charge_code and" +
-            "      a.code *=c.charge_code and" +
-            "               b.group_no=#{groupNo} and" +
-            "               c.dept_code=#{deptCode} and (py_code like '%${searchText}%' or a.name like '%${searchText}%' or a.code like '%${searchText}%') " +
-            " group by a.code,name,use_flag)AS A WHERE RowNumber >${rows}*${page-1} order by RowNumber asc" +
+            " FROM yp_zd_dict a WITH(NOLOCK)" +
+            " INNER JOIN yp_base_yf b WITH(NOLOCK) ON a.code = b.charge_code" +
+            " LEFT JOIN yp_zd_dept c WITH(NOLOCK) ON a.code = c.charge_code AND c.dept_code = #{deptCode}" +
+            " where b.group_no = #{groupNo} and" +
+            "      (py_code like '%${searchText}%' or a.name like '%${searchText}%' or a.code like '%${searchText}%') " +
+            " group by a.code, a.name, c.use_flag) AS A WHERE RowNumber > ${rows}*(${page}-1) order by RowNumber asc" +
             "</script>")
     List<YpZdDept> selectYpZdDeptPage(@Param("deptCode") String deptCode, @Param("groupNo") Integer groupNo, @Param("searchText") String searchText, @Param("page") Integer page, @Param("rows") Integer rows);