Browse Source

报表优化

hurugang 5 years ago
parent
commit
ff907e910e

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

@@ -125,7 +125,7 @@ public class MzChargeDetailController {
         }catch (MzException e) {
             log.error("查询费用列表失败,错误信息{}", e.getMessage());
             resultMap.put("code", -1);
-            resultMap.put("message", "查询费用列表失败");
+            resultMap.put("message", "查询费用列表失败"+e.getMessage());
             return resultMap;
         }  catch (Exception e) {
             e.printStackTrace();

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

@@ -375,16 +375,16 @@ public interface ChargeFeeVoMapper {
                     "sum ( amount) zjss," +
                     "sum ( case when pay_mark ='0'  then amount else 0 end ) zjsk," +
                     "sum ( case when pay_mark  <![CDATA[<>]]>'0'  then amount else 0 end ) zjtk," +
-                    "sum ( case when (cheque_type='W' or (cheque_type='E' and op_id ='99999')) then amount else 0 end ) wxzzss," +
-                    "sum ( case when (cheque_type='W' or (cheque_type='E' and op_id ='99999')) and pay_mark ='0'  then amount else 0 end ) wxzzsk," +
-                    "sum ( case when (cheque_type='M' or (cheque_type='F' and op_id ='99999')) then amount else 0 end ) zfbzzss," +
-                    "sum ( case when (cheque_type='M' or (cheque_type='F' and op_id ='99999')) and pay_mark ='0'  then amount else 0 end ) zfbzzsk," +
-                    "count ( distinct case when (cheque_type='W' or (cheque_type='E' and op_id ='99999')) and pay_mark ='0' then receipt_sn else null end ) wxzzbs," +
-                    " count ( distinct case when (cheque_type='W' or (cheque_type='E' and op_id ='99999')) and pay_mark &gt; '0' then receipt_sn else null end ) wxzztfbs," +
-                    "sum ( case when (cheque_type='W' or (cheque_type='E' and op_id ='99999')) and pay_mark ='1' then amount else 0 end ) wxzztf," +
-                    "sum ( case when (cheque_type='M' or (cheque_type='F' and op_id ='99999')) and pay_mark ='1' then amount else 0 end ) zfbzztf," +
-                    "count ( distinct case when (cheque_type='M' or (cheque_type='F' and op_id ='99999')) and pay_mark ='0' then receipt_sn else null end ) zfbzzbs," +
-                    " count ( distinct case when (cheque_type='M' or (cheque_type='F' and op_id ='99999')) and pay_mark &gt; '0' then receipt_sn else null end ) zfbzztfbs," +
+                    "sum ( case when ((cheque_type='W' or cheque_type='E') and op_id ='99999') then amount else 0 end ) wxzzss," +
+                    "sum ( case when ((cheque_type='W' or cheque_type='E') and op_id ='99999') and pay_mark ='0'  then amount else 0 end ) wxzzsk," +
+                    "sum ( case when ((cheque_type='M' or cheque_type='F') and op_id ='99999') then amount else 0 end ) zfbzzss," +
+                    "sum ( case when ((cheque_type='M' or cheque_type='F') and op_id ='99999') and pay_mark ='0'  then amount else 0 end ) zfbzzsk," +
+                    "count ( distinct case when ((cheque_type='W' or cheque_type='E') and op_id ='99999') and pay_mark ='0' then receipt_sn else null end ) wxzzbs," +
+                    " count ( distinct case when ((cheque_type='W' or cheque_type='E') and op_id ='99999') and pay_mark &gt; '0' then receipt_sn else null end ) wxzztfbs," +
+                    "sum ( case when ((cheque_type='W' or cheque_type='E') and op_id ='99999') and pay_mark ='1' then amount else 0 end ) wxzztf," +
+                    "sum ( case when ((cheque_type='M' or cheque_type='F') and op_id ='99999') and pay_mark ='1' then amount else 0 end ) zfbzztf," +
+                    "count ( distinct case when ((cheque_type='M' or cheque_type='F') and op_id ='99999') and pay_mark ='0' then receipt_sn else null end ) zfbzzbs," +
+                    " count ( distinct case when ((cheque_type='M' or cheque_type='F') and op_id ='99999') and pay_mark &gt; '0' then receipt_sn else null end ) zfbzztfbs," +
                     "count ( distinct case when cheque_type ='1' and pay_mark ='0' then receipt_sn else null end ) xjbs," +
                     "  count ( distinct case when ( cheque_type ='5' or cheque_type ='3' ) and pay_mark ='0' then receipt_sn else null end ) yhsbs," +
                     "  count ( distinct case when cheque_type ='6' and pay_mark ='0' then receipt_sn else null end ) sybbs," +
@@ -595,60 +595,60 @@ public interface ChargeFeeVoMapper {
     @Select({
             "<script>",
             "SELECT " +
-                    " count ( case when cancel_mark ='0' and (paymode ='1' or paymode is null) then 1 else null end ) + count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and (paymode ='1' or paymode is null) then 1 else null end ) xjhs," +
-                    " sum ( case when cancel_mark ='0' and (paymode ='1' or paymode is null) then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) +ABS( sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and (paymode ='1' or paymode is null) then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) xjsk, " +
-                    " count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and (paymode ='1' or paymode is null) then 1 else null end ) xjthhs," +
-                    " ABS( sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and (paymode ='1' or paymode is null) then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) xjth, " +
-                    " count ( case when cancel_mark ='0' and (paymode ='1' or paymode is null) then 1 else null end ) xjsshs," +
+                    " count ( case when times  <![CDATA[>]]> 0 and (paymode ='1' or paymode is null) then 1 else null end ) + count ( case when times  <![CDATA[<]]> 0 and (paymode ='1' or paymode is null) then 1 else null end ) xjhs," +
+                    " sum ( case when times  <![CDATA[>]]> 0 and (paymode ='1' or paymode is null) then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) +ABS( sum ( case when times  <![CDATA[<]]> 0 and (paymode ='1' or paymode is null) then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) xjsk, " +
+                    " count ( case when  times  <![CDATA[<]]> 0 and (paymode ='1' or paymode is null) then 1 else null end ) xjthhs," +
+                    " ABS( sum ( case when times  <![CDATA[<]]> 0 and (paymode ='1' or paymode is null) then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) xjth, " +
+                    " count ( case when times  <![CDATA[>]]> 0 and (paymode ='1' or paymode is null) then 1 else null end ) xjsshs," +
                     " sum ( case when paymode ='1' or paymode is null then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) xjss, " +
-                    " count ( case when cancel_mark ='0' and paymode ='3' then 1 else null end ) + count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='3'  then 1 else null end ) yhkhs," +
-                    " sum ( case when cancel_mark ='0' and paymode ='3'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) + ABS(sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='3' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ))yhksk, " +
-                    " count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='3' then 1 else null end ) yhkthhs," +
-                    " ABS(sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='3' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) yhkth, " +
-                    " count ( case when cancel_mark ='0' and paymode ='3'  then 1 else null end ) yhksshs," +
+                    " count ( case when times  <![CDATA[>]]> 0 and paymode ='3' then 1 else null end ) + count ( case when times  <![CDATA[<]]> 0 and paymode ='3'  then 1 else null end ) yhkhs," +
+                    " sum ( case when times  <![CDATA[>]]> 0 and paymode ='3'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) + ABS(sum ( case when  times  <![CDATA[<]]> 0 and paymode ='3' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ))yhksk, " +
+                    " count ( case when  times  <![CDATA[<]]> 0 and paymode ='3' then 1 else null end ) yhkthhs," +
+                    " ABS(sum ( case when times  <![CDATA[<]]> 0 and paymode ='3' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) yhkth, " +
+                    " count ( case when times  <![CDATA[>]]> 0 and paymode ='3'  then 1 else null end ) yhksshs," +
                     " sum ( case when paymode ='3'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) yhkss," +
-                    " count ( case when cancel_mark ='0' and paymode ='6' then 1 else null end ) + count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='6'  then 1 else null end )ybkhs," +
-                    " sum ( case when cancel_mark ='0' and paymode ='6'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) + ABS(sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='6' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) ybksk, " +
-                    " count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='6' then 1 else null end ) ybkthhs," +
-                    " ABS(sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='6' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) ybkth, " +
-                    " count ( case when cancel_mark ='0' and paymode ='6'  then 1 else null end ) ybksshs," +
+                    " count ( case when times  <![CDATA[>]]> 0 and paymode ='6' then 1 else null end ) + count ( case when times  <![CDATA[<]]> 0 and paymode ='6'  then 1 else null end )ybkhs," +
+                    " sum ( case when times  <![CDATA[>]]> 0 and paymode ='6'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) + ABS(sum ( case when  times  <![CDATA[<]]> 0 and paymode ='6' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) ybksk, " +
+                    " count ( case when times  <![CDATA[<]]> 0 and paymode ='6' then 1 else null end ) ybkthhs," +
+                    " ABS(sum ( case when times  <![CDATA[<]]> 0 and paymode ='6' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) ybkth, " +
+                    " count ( case when times  <![CDATA[>]]> 0 and paymode ='6'  then 1 else null end ) ybksshs," +
                     " sum ( case when paymode ='6'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) ybkss," +
-                    " count ( case when cancel_mark ='0' and paymode ='F' then 1 else null end ) + count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='F'  then 1 else null end )zfbhs," +
-                    " sum ( case when cancel_mark ='0' and paymode ='F'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) + ABS(sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='F' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) zfbsk, " +
-                    " count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='F' then 1 else null end ) zfbthhs," +
-                    " ABS(sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='F' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) zfbth, " +
-                    " count ( case when cancel_mark ='0' and paymode ='F'  then 1 else null end ) zfbsshs," +
+                    " count ( case when times  <![CDATA[>]]> 0 and paymode ='F' then 1 else null end ) + count ( case when  times  <![CDATA[<]]> 0 and paymode ='F'  then 1 else null end )zfbhs," +
+                    " sum ( case when times  <![CDATA[>]]> 0 and paymode ='F'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) + ABS(sum ( case when times  <![CDATA[<]]> 0 and paymode ='F' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) zfbsk, " +
+                    " count ( case when times  <![CDATA[<]]> 0 and paymode ='F' then 1 else null end ) zfbthhs," +
+                    " ABS(sum ( case when times  <![CDATA[<]]> 0 and paymode ='F' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) zfbth, " +
+                    " count ( case when times  <![CDATA[>]]> 0 and paymode ='F'  then 1 else null end ) zfbsshs," +
                     " sum ( case when paymode ='F'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) zfbss," +
-                    " count ( case when cancel_mark ='0' and paymode ='E' then 1 else null end ) +count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='E'  then 1 else null end ) wxhs," +
-                    " sum ( case when cancel_mark ='0' and paymode ='E'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) + ABS(sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='E' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) wxsk, " +
-                    " count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='E' then 1 else null end ) wxthhs," +
-                    " ABS(sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='E' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) wxth, " +
-                    " count ( case when cancel_mark ='0' and paymode ='E'  then 1 else null end ) wxsshs," +
+                    " count ( case when times  <![CDATA[>]]> 0 and paymode ='E' then 1 else null end ) +count ( case when  times  <![CDATA[<]]> 0 and paymode ='E'  then 1 else null end ) wxhs," +
+                    " sum ( case when times  <![CDATA[>]]> 0 and paymode ='E'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) + ABS(sum ( case when  times  <![CDATA[<]]> 0 and paymode ='E' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) wxsk, " +
+                    " count ( case when times  <![CDATA[<]]> 0 and paymode ='E' then 1 else null end ) wxthhs," +
+                    " ABS(sum ( case when times  <![CDATA[<]]> 0 and paymode ='E' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) wxth, " +
+                    " count ( case when times  <![CDATA[>]]> 0 and paymode ='E'  then 1 else null end ) wxsshs," +
                     " sum ( case when paymode ='E'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) wxss," +
-                    " count ( case when cancel_mark ='0' and paymode ='Y' then 1 else null end ) + count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='Y'  then 1 else null end ) byjzhs," +
-                    " sum ( case when cancel_mark ='0' and paymode ='Y'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) +ABS(sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='Y' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) byjzsk, " +
-                    " count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='Y' then 1 else null end ) byjzthhs," +
-                    " ABS(sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='Y' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) byjzth, " +
-                    " count ( case when cancel_mark ='0' and paymode ='Y'  then 1 else null end ) byjzsshs," +
+                    " count ( case when times  <![CDATA[>]]> 0 and paymode ='Y' then 1 else null end ) + count ( case when times  <![CDATA[<]]> 0 and paymode ='Y'  then 1 else null end ) byjzhs," +
+                    " sum ( case when times  <![CDATA[>]]> 0 and paymode ='Y'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) +ABS(sum ( case when  times  <![CDATA[<]]> 0 and paymode ='Y' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) byjzsk, " +
+                    " count ( case when times  <![CDATA[<]]> 0 and paymode ='Y' then 1 else null end ) byjzthhs," +
+                    " ABS(sum ( case when times  <![CDATA[<]]> 0 and paymode ='Y' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) byjzth, " +
+                    " count ( case when times  <![CDATA[>]]> 0 and paymode ='Y'  then 1 else null end ) byjzsshs," +
                     " sum ( case when paymode ='Y'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) byjzss," +
-                    " count ( case when cancel_mark ='0' and (paymode <![CDATA[<]]> 'hospital_z' or paymode is null) then 1 else null end ) +count ( case when cancel_mark ='1' and (paymode <![CDATA[<]]> 'hospital_z' or paymode is null)  and times  <![CDATA[<]]> 0 then 1 else null end ) hjhs," +
-                    " sum ( case when cancel_mark ='0' and (paymode <![CDATA[<]]> 'hospital_z' or paymode is null) then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) +ABS(sum ( case when cancel_mark ='1' and (paymode <![CDATA[<]]> 'hospital_z' or paymode is null) and times  <![CDATA[<]]> 0 then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ))hjsk, " +
-                    " count ( case when cancel_mark ='1' and (paymode <![CDATA[<]]> 'hospital_z' or paymode is null)  and times  <![CDATA[<]]> 0 then 1 else null end ) hjthhs," +
-                    " ABS(sum ( case when cancel_mark ='1' and (paymode <![CDATA[<]]> 'hospital_z' or paymode is null) and times  <![CDATA[<]]> 0 then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) hjth, " +
-                    " count ( case when cancel_mark ='0' and (paymode <![CDATA[<]]> 'hospital_z' or paymode is null) then 1 else null end ) hjsshs," +
+                    " count ( case when times  <![CDATA[>]]> 0 and (paymode <![CDATA[<]]> 'hospital_z' or paymode is null) then 1 else null end ) +count ( case when  (paymode <![CDATA[<]]> 'hospital_z' or paymode is null)  and times  <![CDATA[<]]> 0 then 1 else null end ) hjhs," +
+                    " sum ( case when times  <![CDATA[>]]> 0 and (paymode <![CDATA[<]]> 'hospital_z' or paymode is null) then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) +ABS(sum ( case when  (paymode <![CDATA[<]]> 'hospital_z' or paymode is null) and times  <![CDATA[<]]> 0 then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ))hjsk, " +
+                    " count ( case when (paymode <![CDATA[<]]> 'hospital_z' or paymode is null)  and times  <![CDATA[<]]> 0 then 1 else null end ) hjthhs," +
+                    " ABS(sum ( case when (paymode <![CDATA[<]]> 'hospital_z' or paymode is null) and times  <![CDATA[<]]> 0 then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) hjth, " +
+                    " count ( case when times  <![CDATA[>]]> 0 and (paymode <![CDATA[<]]> 'hospital_z' or paymode is null) then 1 else null end ) hjsshs," +
                     " sum ( case when paymode <![CDATA[<]]> 'hospital_z' or paymode is null then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) hjss," +
-                    " count ( case when cancel_mark ='0' and paymode ='WX' then 1 else null end ) + count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='WX' then 1 else null end ) wxzzhs," +
-                    " sum ( case when cancel_mark ='0' and paymode ='WX'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) +ABS( sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='WX'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) wxzzsk, " +
-                    " count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='WX' then 1 else null end ) wxzzthhs," +
-                    " ABS( sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='WX'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) wxzzth, " +
-                    " count ( case when cancel_mark ='0' and paymode ='WX' then 1 else null end ) wxzzsshs," +
-                    " sum ( case when paymode ='WX' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) wxzzss, " +
-                    " count ( case when cancel_mark ='0' and paymode ='ZFB' then 1 else null end ) + count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='ZFB' then 1 else null end ) zfbzzhs," +
-                    " sum ( case when cancel_mark ='0' and paymode ='ZFB'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) +ABS( sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='ZFB'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) zfbzzsk, " +
-                    " count ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='ZFB' then 1 else null end ) zfbzzthhs," +
-                    " ABS( sum ( case when cancel_mark ='1'  and times  <![CDATA[<]]> 0 and paymode ='ZFB'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) zfbzzth, " +
-                    " count ( case when cancel_mark ='0' and paymode ='ZFB' then 1 else null end ) zfbzzsshs," +
-                    " sum ( case when paymode ='ZFB' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) zfbzzss, " +
+                    " count ( case when times  <![CDATA[>]]> 0 and paymode ='WX' then 1 else null end ) + count ( case when  op_id='99999' and times  <![CDATA[<]]> 0 and paymode ='WX' then 1 else null end ) wxzzhs," +
+                    " sum ( case when times  <![CDATA[>]]> 0 and paymode ='WX'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) +ABS( sum ( case when op_id='99999' and   times  <![CDATA[<]]> 0 and paymode ='WX'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) wxzzsk, " +
+                    " count ( case when op_id='99999' and  times  <![CDATA[<]]> 0 and paymode ='WX' then 1 else null end ) wxzzthhs," +
+                    " ABS( sum ( case when op_id='99999' and   times  <![CDATA[<]]> 0 and paymode ='WX'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) wxzzth, " +
+                    " count ( case when times  <![CDATA[>]]> 0 and paymode ='WX' then 1 else null end ) wxzzsshs," +
+                    " sum ( case when op_id='99999' and paymode ='WX' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) wxzzss, " +
+                    " count ( case when times  <![CDATA[>]]> 0 and paymode ='ZFB' then 1 else null end ) + count ( case when op_id='99999' and times  <![CDATA[<]]> 0 and paymode ='ZFB' then 1 else null end ) zfbzzhs," +
+                    " sum ( case when times  <![CDATA[>]]> 0 and paymode ='ZFB'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) +ABS( sum ( case when op_id='99999' and   times  <![CDATA[<]]> 0 and paymode ='ZFB'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) zfbzzsk, " +
+                    " count ( case when op_id='99999' and    times  <![CDATA[<]]> 0 and paymode ='ZFB' then 1 else null end ) zfbzzthhs," +
+                    " ABS( sum ( case when  op_id='99999' and   times  <![CDATA[<]]> 0 and paymode ='ZFB'  then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end )) zfbzzth, " +
+                    " count ( case when times  <![CDATA[>]]> 0 and paymode ='ZFB' then 1 else null end ) zfbzzsshs," +
+                    " sum ( case when op_id='99999' and paymode ='ZFB' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) zfbzzss, " +
                     " sum ( case when isnull ( paymode , '1' ) = 'Y' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) ghjejz," +
                     " sum ( case when isnull ( paymode , '1' ) <![CDATA[<>]]> 'Y' then req_fee + oth_fee + clinic_fee + isnull ( brochure_fee , 0 ) + isnull ( bl_fee , 0 ) + isnull ( ck_fee , 0 ) else 0 end ) ghjebhjz," +
                     " sum ( clinic_fee ) zcsr," +

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

@@ -26,9 +26,9 @@ public interface JcJyItemChargeMapper {
      */
     @Select({"<script>",
             "select rtrim(code) code,rtrim(charge_code) charge_code,amount,rtrim(charge_type) charge_type,rtrim(tc_no) tc_no,rtrim(zy_flag) zy_flag,",
-            "rtrim(mz_flag) mz_flag,${reqType} as req_type from ${tableName} ",
+            "rtrim(mz_flag) mz_flag,${reqType} as req_type from ${tableName} where  charge_code <![CDATA[<>]]> '' and charge_code is not null ",
             "<when test='codes!=null'>",
-            " where code in",
+            " and code in",
             "<foreach item='item' index='index' collection='codes' open='(' separator=',' close=')'>",
             "#{item}",
             "</foreach>",

+ 1 - 1
src/main/java/cn/hnthyy/thmz/mapper/his/MzYjReqMapper.java

@@ -62,7 +62,7 @@ public interface MzYjReqMapper {
             "<when test='patientId!=null'>",
             " and patient_id=#{patientId,jdbcType=CHAR}",
             "</when>",
-            " and pay_mark='5' and status_flag <![CDATA[ <> ]]> 'z' and   (datediff(day,req_date,getdate()) <![CDATA[ <= ]]> 30) group by patient_id,times",
+            " and pay_mark='5' and status_flag <![CDATA[ <> ]]> 'z' and   (datediff(day,req_date,getdate()) <![CDATA[ <= ]]> 3) group by patient_id,times",
             "</script>"})
     List<Map<String, Object>> selectUnPaidYjReq(@Param(value = "patientId") String patientId);
 

+ 27 - 7
src/main/java/cn/hnthyy/thmz/mapper/his/MzyRequestMapper.java

@@ -51,6 +51,7 @@ public interface MzyRequestMapper {
 
     /**
      * 按照主键查询所选号表数据
+     *
      * @param id 主键
      */
     @Select(" select id,request_day,ampm,rtrim(unit_code) unit_code,group_code,rtrim(doctor_code) doctor_code,charge_type,op_id,total_num,left_num,bespeak_no,check_fee,sys_date,del_flag" +
@@ -58,17 +59,29 @@ public interface MzyRequestMapper {
     MzyRequest selectMzyRequestById(@Param("id") Long id);
 
     /**
-     * 更新剩余卡号与当前就诊号
+     * 更新新号表剩余卡号与当前就诊号
+     *
      * @param mzyRequest
      * @return
      */
-    @Update("update mzy_request_new set left_num=#{leftNum,jdbcType=INTEGER}, bespeak_no=#{bespeakNo,jdbcType=SMALLINT} where " +
-            "id = #{id,jdbcType=BIGINT} and left_num=#{orgiLeftNum,jdbcType=INTEGER} and bespeak_no=#{orgiBespeakNo,jdbcType=SMALLINT}")
+    @Update("update mzy_request_new set left_num=#{leftNum,jdbcType=INTEGER}, bespeak_no=#{bespeakNo,jdbcType=SMALLINT} where id = #{id,jdbcType=BIGINT}")
     int updateMzyRequest(MzyRequest mzyRequest);
 
+
+    /**
+     * 更新原号表剩余卡号与当前就诊号  (临时功能,全部切换新系统不会使用)
+     *
+     * @param mzyRequest
+     * @return
+     */
+    @Update("update mzy_request set left_num=#{leftNum,jdbcType=INTEGER}, bespeak_no=#{bespeakNo,jdbcType=SMALLINT} where " +
+            "request_day = #{requestDay,jdbcType=DATE} and unit_code=#{unitCode,jdbcType=CHAR} and ampm =#{ampm,jdbcType=CHAR}  and charge_type=#{chargeType}  and doctor_code=#{doctorCode}")
+    int updateOriMzyRequest(MzyRequest mzyRequest);
+
     /**
      * 同步排班表
-      * @return
+     *
+     * @return
      */
     @Insert("insert into mzy_request_new(request_day,ampm,unit_code,group_code,doctor_code,charge_type,op_id,total_num,left_num,bespeak_no,check_fee,sys_date,del_flag) " +
             "select request_day,ampm,unit_code,group_code,doctor_code,charge_type,op_id,total_num,left_num,bespeak_no,check_fee,sys_date,del_flag " +
@@ -87,6 +100,7 @@ public interface MzyRequestMapper {
 
     /**
      * 查询当天最新的排班信息
+     *
      * @return
      */
     @Select("select request_day,ampm,unit_code,group_code,doctor_code,charge_type,op_id,total_num,left_num,bespeak_no,check_fee,sys_date,del_flag " +
@@ -95,6 +109,7 @@ public interface MzyRequestMapper {
 
     /**
      * 根据所以筛选条件查询号表
+     *
      * @param mzyRequest
      * @return
      */
@@ -103,6 +118,7 @@ public interface MzyRequestMapper {
 
     /**
      * 保存排班表
+     *
      * @return
      */
     @Insert("insert into mzy_request_new(request_day,ampm,unit_code,group_code,doctor_code,charge_type,op_id,total_num,left_num,bespeak_no,check_fee,sys_date,del_flag) " +
@@ -110,7 +126,6 @@ public interface MzyRequestMapper {
     int insertRequest(MzyRequest mzyRequest);
 
 
-
     /**
      * 按日期和时间区间以及部门编码以及收费类型查询老排班表中的最新数据
      *
@@ -119,6 +134,11 @@ public interface MzyRequestMapper {
      * @param ampm
      * @return
      */
-    @Select("select * from mzy_request where request_day = #{requestDay,jdbcType=DATE} and unit_code=#{unitCode,jdbcType=CHAR} and ampm =#{ampm,jdbcType=CHAR}  and charge_type=#{chargeType} and left_num>0")
-    List<MzyRequest> selectOldRequestByRequestDay(@Param("requestDay") String requestDay, @Param("unitCode") String unitCode, @Param("ampm") String ampm, @Param("chargeType") String chargeType);
+    @Select({"<script>",
+            "select * from mzy_request where request_day = #{requestDay,jdbcType=DATE} and unit_code=#{unitCode,jdbcType=CHAR} and ampm =#{ampm,jdbcType=CHAR}  and charge_type=#{chargeType} and left_num>0 ",
+            "<when test='doctorCode!=null'>",
+            " and doctor_code=#{doctorCode} ",
+            "</when>",
+            "</script>"})
+    List<MzyRequest> selectOldRequestByRequestDay(@Param("requestDay") String requestDay, @Param("unitCode") String unitCode, @Param("ampm") String ampm, @Param("chargeType") String chargeType, @Param("doctorCode") String doctorCode);
 }

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

@@ -17,7 +17,8 @@ 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  code = #{code,jdbcType=VARCHAR}  and (del_flag != 1 or del_flag is null) ")
+            "yb_flag_new,yb_comment_new,yb_bl_new from zd_charge_item where  code = #{code,jdbcType=VARCHAR} ")
+       //     " and (del_flag != 1 or del_flag is null) " )
     ZdChargeItem selectZdChargeItemByCode(@Param("code") String code);
 
     /**

+ 25 - 18
src/main/java/cn/hnthyy/thmz/service/impl/his/MzChargeDetailServiceImpl.java

@@ -296,11 +296,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
                 }catch (ClassCastException e){
                     mzChargeDetail.setTimes(Integer.valueOf((Short) map.get("times")));
                 }
-                try {
-                    returnMzChargeDetails.add(unPaidToFullChargeDetail(mzChargeDetail));
-                } catch (Exception e) {
-                    log.warn("将未缴费的处方转成收费明细记录出错,病人编号或者就诊次数为空,错误信息{}", e.getMessage());
-                }
+                returnMzChargeDetails.add(unPaidToFullChargeDetail(mzChargeDetail));
             }
         }
         return returnMzChargeDetails;
@@ -732,6 +728,8 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
             mz.setCharge19(BigDecimal.ZERO.subtract(mz.getCharge19()));
             mz.setCharge20(BigDecimal.ZERO.subtract(mz.getCharge20()));
             mz.setChequeType(Constants.CASH);
+            mz.setDcountNo(YesNoEnum.NO.code);
+            mz.setDcountDate(null);
             mz.setChargeDcountDate(null);
             mz.setChargeDcountNo(YesNoEnum.NO.code);
             newReceiptSerials.add(mz);
@@ -811,7 +809,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
                     amount=amount.add(ms.getAmount());
                 }
             }
-            temp.setAmount(amount);
+            temp.setAmount(BigDecimal.ZERO.subtract(amount));
             if (!allRefund) {
                 MzDepositFile m = mzDepositFiles.get(0);
                 m.setTimes(times);
@@ -1495,14 +1493,14 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
                 newMzChargeDetail.setName(mzPatientMi.getName());
                 newMzChargeDetail.setGroupNo(Constants.YJ_GROUP_NO);
                 newMzChargeDetail.setDrugWin(1);
-                newMzChargeDetail.setPriceId(mzChargeDetailList.get(0).getPriceId());
-                newMzChargeDetail.setPriceTime(mzChargeDetailList.get(0).getPriceTime());
-                newMzChargeDetail.setExecDept(mzChargeDetailList.get(0).getExecDept());
+                newMzChargeDetail.setPriceId(temp.get(0).getPriceId());
+                newMzChargeDetail.setPriceTime(temp.get(0).getPriceTime());
+                newMzChargeDetail.setExecDept(temp.get(0).getExecDept());
                 newMzChargeDetail.setPrintFlag(YesNoEnum.NO.code.toString());
                 newMzChargeDetail.setConfirmFlag(ConfirmFlagEnum.NOT_CONFIRM.code);
-                newMzChargeDetail.setWarnDept(mzChargeDetailList.get(0).getWarnDept());
-                newMzChargeDetail.setJzFlag(mzChargeDetailList.get(0).getJzFlag());
-                newMzChargeDetail.setDoctorCode(mzChargeDetailList.get(0).getDoctorCode());
+                newMzChargeDetail.setWarnDept(temp.get(0).getWarnDept());
+                newMzChargeDetail.setJzFlag(temp.get(0).getJzFlag());
+                newMzChargeDetail.setDoctorCode(temp.get(0).getDoctorCode());
                 newMzChargeDetail.setDoctorFlag(YesNoEnum.YES.code.toString());
                 newMzChargeDetail.setInjectRes(Double.valueOf(YesNoEnum.YES.code));
                 newMzChargeDetail.setRealNo(0);
@@ -1536,7 +1534,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
      * @param jianYans
      * @return
      */
-    private Integer formatCxFeeItem(MzChargeDetail mzChargeDetail, List<MzChargeDetail> mzChargeDetails, MzPatientMi mzPatientMi, Integer maxOrderNo, Integer itemNo, Map<String, MzYjReq> mzYjReqMap, List<String> jianYans, Map<String, MzChargeDetail> tcNoMap, String priceId, Date priceTime) {
+    private Integer formatCxFeeItem(MzChargeDetail mzChargeDetail, List<MzChargeDetail> mzChargeDetails, MzPatientMi mzPatientMi, Integer maxOrderNo, Integer itemNo, Map<String, MzYjReq> mzYjReqMap, List<String> jianYans, Map<String, MzChargeDetail> tcNoMap, String priceId, Date priceTime) throws MzException {
         List<JyZdItem> jyZdItems = jyZdItemService.queryCxTimesByCodeList(jianYans);
         MzYjReq mzYjReq = mzYjReqMap.get(jianYans.get(0));
         if (jyZdItems != null && jyZdItems.size() > 0) {
@@ -1550,7 +1548,10 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
             }
             ZdChargeItem zdChargeItem = zdChargeItemService.queryZdChargeItemByCode("008910");
             if (zdChargeItem == null) {
-                return itemNo;
+                throw new MzException("【收费编码:008910】不存在,请联系物价科确认!");
+            }
+            if (YesNoEnum.YES.code.equals(zdChargeItem.getDelFlag())) {
+                throw new MzException("【"+zdChargeItem.getName()+"】被停用,请联系物价科确认!");
             }
             MzChargeDetail newMzChargeDetail = new MzChargeDetail();
             newMzChargeDetail.setPatientId(mzChargeDetail.getPatientId());
@@ -1616,12 +1617,15 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
      * @param jyZdItem
      * @return
      */
-    private Integer formatVesselFee(MzChargeDetail mzChargeDetail, List<MzChargeDetail> mzChargeDetails, MzPatientMi mzPatientMi, Integer maxOrderNo, Integer itemNo, MzYjReq mzYjReq, Set<String> vesselSets, JyZdItem jyZdItem, Map<String, MzChargeDetail> tcNoMap, String priceId, Date priceTime) {
+    private Integer formatVesselFee(MzChargeDetail mzChargeDetail, List<MzChargeDetail> mzChargeDetails, MzPatientMi mzPatientMi, Integer maxOrderNo, Integer itemNo, MzYjReq mzYjReq, Set<String> vesselSets, JyZdItem jyZdItem, Map<String, MzChargeDetail> tcNoMap, String priceId, Date priceTime) throws MzException {
         JyZdTubeCharge jyZdTubeCharge = jyZdTubeChargeService.queryJyZdTubeChargeByCode(jyZdItem.getVessel());
         if (jyZdTubeCharge != null) {
             ZdChargeItem zdChargeItem = zdChargeItemService.queryZdChargeItemByCode(jyZdTubeCharge.getChargeCode());
             if (zdChargeItem == null) {
-                return itemNo;
+                throw new MzException("【收费编码:"+jyZdTubeCharge.getChargeCode()+"】不存在,请联系物价科确认!");
+            }
+            if (YesNoEnum.YES.code.equals(zdChargeItem.getDelFlag())) {
+                throw new MzException("【"+zdChargeItem.getName()+"】被停用,请联系物价科确认!");
             }
             MzChargeDetail newMzChargeDetail = new MzChargeDetail();
             newMzChargeDetail.setPatientId(mzChargeDetail.getPatientId());
@@ -1819,11 +1823,14 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
      * @param jcJyItemCharge
      * @return
      */
-    private Integer formatYjDetailChargeDetail(MzChargeDetail mzChargeDetail, List<MzChargeDetail> mzChargeDetails, Integer maxOrderNo, MzPatientMi mzPatientMi, Integer itemNo, Map<String, MzYjReq> mzYjReqMap, JcJyItemCharge jcJyItemCharge, Map<String, MzChargeDetail> tcNoMap, String priceId, Date priceTime) {
+    private Integer formatYjDetailChargeDetail(MzChargeDetail mzChargeDetail, List<MzChargeDetail> mzChargeDetails, Integer maxOrderNo, MzPatientMi mzPatientMi, Integer itemNo, Map<String, MzYjReq> mzYjReqMap, JcJyItemCharge jcJyItemCharge, Map<String, MzChargeDetail> tcNoMap, String priceId, Date priceTime) throws MzException {
         MzYjReq mzYjReq = mzYjReqMap.get(jcJyItemCharge.getCode());
         ZdChargeItem zdChargeItem = zdChargeItemService.queryZdChargeItemByCode(jcJyItemCharge.getChargeCode());
         if (zdChargeItem == null) {
-            return itemNo;
+            throw new MzException("【收费编码:"+jcJyItemCharge.getChargeCode()+"】不存在,请联系物价科确认!");
+        }
+        if (YesNoEnum.YES.code.equals(zdChargeItem.getDelFlag())) {
+            throw new MzException("【"+zdChargeItem.getName()+"】被停用,请联系物价科确认!");
         }
         MzChargeDetail newMzChargeDetail = new MzChargeDetail();
         newMzChargeDetail.setPatientId(mzChargeDetail.getPatientId());

+ 22 - 5
src/main/java/cn/hnthyy/thmz/service/impl/his/MzyRequestServiceImpl.java

@@ -9,6 +9,7 @@ import cn.hnthyy.thmz.mapper.his.MzyRequestMapper;
 import cn.hnthyy.thmz.mapper.his.MzyZdChargeTypeMapper;
 import cn.hnthyy.thmz.service.his.MzyRequestService;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -63,7 +64,7 @@ public class MzyRequestServiceImpl implements MzyRequestService {
         List<MzyZdChargeType> list = new ArrayList<>();
         chargeTypes.forEach(ct -> {
             if (StringUtils.isNotBlank(ct)) {
-                List<MzyRequest> mzyRequests=mzyRequestMapper.selectOldRequestByRequestDay(requestDay, unitCode, ampm,ct);
+                List<MzyRequest> mzyRequests=mzyRequestMapper.selectOldRequestByRequestDay(requestDay, unitCode, ampm,ct,null);
                 if(mzyRequests!=null && mzyRequests.size()>0){
                     MzyZdChargeType mzct = mzyZdChargeTypeMapper.selectByCode(ct);
                     if (mzct != null) {
@@ -81,11 +82,27 @@ public class MzyRequestServiceImpl implements MzyRequestService {
         if(mzyRequest==null){
             throw new MzException("没有查询到匹配的可挂号表,请先创建!");
         }
-        mzyRequest.setOrgiBespeakNo(mzyRequest.getBespeakNo());
-        mzyRequest.setOrgiLeftNum(mzyRequest.getLeftNum());
-        mzyRequest.setBespeakNo(mzyRequest.getBespeakNo()+1);
-        mzyRequest.setLeftNum(mzyRequest.getLeftNum()-1);
+
+        List<MzyRequest> mzyRequests=mzyRequestMapper.selectOldRequestByRequestDay(DateFormatUtils.format(mzyRequest.getRequestDay(), "yyyy-MM-dd"), mzyRequest.getUnitCode(), mzyRequest.getAmpm(),mzyRequest.getChargeType(),mzyRequest.getDoctorCode());
+        if(mzyRequests==null || mzyRequests.size()==0){
+            throw new MzException("没有查询到匹配的可挂号表,请先创建!");
+        }
+        MzyRequest oldMzyRequest=mzyRequests.get(0);
+        Integer oldBespeakNo=oldMzyRequest.getBespeakNo();
+        Integer bespeakNo=mzyRequest.getBespeakNo();
+        Integer leftNum = mzyRequest.getLeftNum();
+        if(oldBespeakNo>bespeakNo){
+            bespeakNo=oldBespeakNo;
+            leftNum = oldMzyRequest.getLeftNum();
+        }
+        mzyRequest.setOrgiBespeakNo(bespeakNo);
+        mzyRequest.setOrgiLeftNum(leftNum);
+        Integer newBespeakNo=bespeakNo+1;
+        Integer newLeftNum=leftNum-1;
+        mzyRequest.setBespeakNo(newBespeakNo);
+        mzyRequest.setLeftNum(newLeftNum);
         int num=mzyRequestMapper.updateMzyRequest(mzyRequest);
+        mzyRequestMapper.updateOriMzyRequest(mzyRequest);
         if(num==0){
             throw new MzException("更新挂号表信息出错,请重试或者联系管理员!");
         }

+ 3 - 3
src/main/resources/static/js/registration.js

@@ -1650,12 +1650,12 @@ function prn1Print(patientId, times) {
                 }
                 LODOP = getLodop();
                 var temp = res.data;
-                LODOP.PRINT_INITA(6, 0, "120mm", "93.5mm", "泰和门诊发票打印");
+                LODOP.PRINT_INITA(6, 0, "120mm", "93mm", "泰和门诊发票打印");
                 //设置默认打印机
                 LODOP.SET_PRINTER_INDEX(printIndex);
                 LODOP.SET_SHOW_MODE("BKIMG_WIDTH", "120mm");
-                LODOP.SET_SHOW_MODE("BKIMG_HEIGHT", "93.5mm");
-                LODOP.SET_PRINT_PAGESIZE(1, "120mm", "93.5mm", "CreateCustomPage");
+                LODOP.SET_SHOW_MODE("BKIMG_HEIGHT", "93mm");
+                LODOP.SET_PRINT_PAGESIZE(1, "120mm", "93mm", "CreateCustomPage");
                 LODOP.SET_PRINT_MODE("CREATE_CUSTOM_PAGE_NAME", "门诊发票");//对新建的纸张重命名
                 LODOP.SET_PRINT_STYLE("FontSize", 11); //字体大小
                 LODOP.ADD_PRINT_TEXT("6mm", "0mm", "45mm", "3mm", "湖南泰和医院管理有限公司");