소스 검색

Merge branch 'master' of https://172.16.32.165/lighter/web-server

xiaochan 2 년 전
부모
커밋
872ac82076

+ 10 - 15
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiSettleApplyDao.java

@@ -21,33 +21,27 @@ public interface SiSettleApplyDao {
             "and status_flag > '1' and isnull(group_no, '00')='00' and order_code in ('06026','06053','05973') and status_flag <> '6'  ")
     Date selectActOrderDisDate(@Param("table") String table, @Param("patNo") String patNo, @Param("times") Integer times);
 
-    @Select("select status,handle_comment,type,settle_datetime,acct_used_flag,death_flag from t_si_settle_apply with(nolock) " +
-            "where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledger} and type=#{type}")
+    @Select("select top 1 status,handle_comment,type,settle_datetime,acct_used_flag,death_flag,sort_no from t_si_settle_apply " +
+            "where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledger} and type=#{type} order by sort_no desc")
     SiSettleApply selectSettleApply(@Param("patNo") String patNo,
                                     @Param("times") int times,
                                     @Param("ledger") int ledger,
                                     @Param("type") int type);
 
-    @Delete("delete from t_si_settle_apply where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledger} and type=#{type}")
-    void deleteSettleApply(@Param("patNo") String patNo,
-                           @Param("times") int times,
-                           @Param("ledger") int ledger,
-                           @Param("type") int type);
-
     @Insert("insert into t_si_settle_apply (pat_no,times,ledger_sn,input_staff,input_comment,input_datetime,status,type," +
-            "settle_datetime,settled,acct_used_flag,death_flag) values (#{patNo},#{times},#{ledgerSn},#{inputStaff}," +
-            "#{inputComment},getdate(),0,#{type},#{settleDatetime},0,#{acctUsedFlag},#{deathFlag})")
+            "settle_datetime,settled,acct_used_flag,death_flag,sort_no) values (#{patNo},#{times},#{ledgerSn},#{inputStaff}," +
+            "#{inputComment},getdate(),0,#{type},#{settleDatetime},0,#{acctUsedFlag},#{deathFlag},#{sortNo})")
     void insertSettleApply(SiSettleApply apply);
 
     @Select("select a.pat_no,a.times,a.ledger_sn,a.status,a.type,c.sex as gender,rtrim(c.name) as name,b.med_type, " +
-            "wardName=(select rtrim(name) from zd_unit_code with(nolock) where code=c.ward),a.death_flag " +
+            "wardName=(select rtrim(name) from zd_unit_code with(nolock) where code=c.ward),a.death_flag,a.sort_no " +
             "from t_si_settle_apply a with(nolock), t_si_pat_info b with(nolock), zy_actpatient c with(nolock) " +
             "where a.settled=0 and a.pat_no=b.pat_no and a.times=b.times " +
             "and a.ledger_sn=b.ledger_sn and a.pat_no=c.inpatient_no")
     List<SiSettleApply> selectUnhandledApplies();
 
     @Select("select a.pat_no,a.times,a.ledger_sn,a.input_staff,a.input_comment,a.input_datetime,a.status,a.handle_staff,a.acct_used_flag, " +
-            "a.handle_comment,a.handle_datetime,a.type,a.settle_datetime,b.med_type, b.insuplc_admdvs,b.insutype,b.mdtrt_id, " +
+            "a.handle_comment,a.handle_datetime,a.type,a.settle_datetime,b.med_type, b.insuplc_admdvs,b.insutype,b.mdtrt_id,a.sort_no, " +
             "detailTotalCharge=(select isnull(sum(charge_fee),0) from zy_detail_charge c with(nolock) where c.inpatient_no=a.pat_no " +
             "and c.admiss_times=a.times and c.ledger_sn=a.ledger_sn), " +
             "ledgerTotalCharge=(select isnull(total_charge,0) from zy_ledger_file c with(nolock) where c.inpatient_no=a.pat_no " +
@@ -57,7 +51,7 @@ public interface SiSettleApplyDao {
             "fundpay=(select isnull(charge_yb,0) from zy_ledger_file c with(nolock) where c.inpatient_no=a.pat_no " +
             "and c.admiss_times=a.times and c.ledger_sn=a.ledger_sn),death_flag " +
             "from t_si_settle_apply a with(nolock), t_si_pat_info b with(nolock) where a.pat_no=#{patNo} and a.times=#{times} and " +
-            "a.ledger_sn=#{ledgerSn} and a.type=#{type} and a.pat_no=b.pat_no and a.times=b.times and a.ledger_sn=b.ledger_sn")
+            "a.ledger_sn=#{ledgerSn} and a.type=#{type} and a.sort_no=#{sortNo} and a.pat_no=b.pat_no and a.times=b.times and a.ledger_sn=b.ledger_sn")
     SiSettleApply selectCurrentApply(SiSettleApply apply);
 
     @Select("select detailTotalCharge=(select isnull(sum(charge_fee),0) from zy_detail_charge c with(nolock) where " +
@@ -70,7 +64,8 @@ public interface SiSettleApplyDao {
     List<ZyDisYbSrgry> selectSurgeries(@Param("patNo") String patNo,
                                        @Param("times") int times);
 
-    @Update("update t_si_settle_apply set status=#{status},handle_staff=#{handleStaff},handle_comment=#{handleComment}, " +
-            "handle_datetime=getdate() where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn} and type=#{type}")
+    @Update("update t_si_settle_apply set status=#{status},handle_staff=#{handleStaff}, " +
+            "handle_comment=#{handleComment},handle_datetime=getdate() where pat_no=#{patNo} " +
+            "and times=#{times} and ledger_sn=#{ledgerSn} and type=#{type} and sort_no=#{sortNo}")
     void handleApply(SiSettleApply apply);
 }

+ 5 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/inpatient/SiSettleApply.java

@@ -25,6 +25,11 @@ public class SiSettleApply implements Serializable {
 	 */
 	private Integer ledgerSn;
 
+	/**
+	 * 序号
+	 * */
+	private Integer sortNo;
+
 	/**
 	 * 申请人
 	 */

+ 8 - 4
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiSettleApplyService.java

@@ -36,6 +36,9 @@ public class SiSettleApplyService {
     private final RedisLikeService redis;
     private final PatientService ptntSrvc;
     private final CaseFrontSheetMainService csfrntSrvc;
+    private static final Integer APPROVED = 1;
+    private static final Integer REAL_SETTLE = 1;
+    private static final Integer MIDDLE_SETTLE = 2;
 
     public SiSettleApplyService(SiSettleApplyDao dao, RedisLikeService redis, PatientService ptntSrvc, CaseFrontSheetMainService csfrntSrvc) {
         this.dao = dao;
@@ -48,15 +51,15 @@ public class SiSettleApplyService {
         String mdtrtId = dao.selectMdtrtId(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
         if (StringUtil.isBlank(mdtrtId)) {
             SiSettleApply apply = new SiSettleApply();
-            apply.setStatus(1);
+            apply.setStatus(APPROVED);
             return ResultVoUtil.success(apply);
         }
         if (null == p.getMidSetl()) {
             p.setMidSetl(false);
         }
-        int type = p.getMidSetl() ? 2 : 1;
+        int type = p.getMidSetl() ? MIDDLE_SETTLE : REAL_SETTLE;
         Date disdate = null;
-        if (type == 1) {
+        if (type == REAL_SETTLE) {
             disdate = dao.selectActOrderDisDate("yz_act_order", p.getInpatientNo(), p.getAdmissTimes());
             if (null == disdate) {
                 disdate = dao.selectActOrderDisDate("yz_inact_order", p.getInpatientNo(), p.getAdmissTimes());
@@ -68,6 +71,7 @@ public class SiSettleApplyService {
         SiSettleApply apply = dao.selectSettleApply(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), type);
         if (null == apply) {
             apply = new SiSettleApply();
+            apply.setSortNo(0);
             if (type == 1) {
                 apply.setSettleDatetime(disdate);
             }
@@ -80,8 +84,8 @@ public class SiSettleApplyService {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "申请理由不能为空!");
         }
         apply.setStatus(0);
+        apply.setSortNo(apply.getSortNo() + 1);
         apply.setInputStaff(TokenUtil.getTokenUserId());
-        dao.deleteSettleApply(apply.getPatNo(), apply.getTimes(), apply.getLedgerSn(), apply.getType());
         dao.insertSettleApply(apply);
         return ResultVoUtil.success("提交成功。");
     }