瀏覽代碼

优化所有枷锁处理逻辑

hurugang 3 年之前
父節點
當前提交
9451d2ae31

+ 23 - 23
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzDrugWinMapper.java

@@ -9,14 +9,14 @@ import java.util.List;
 
 
 public interface MzDrugWinMapper {
-    /**
-     * 加锁
-     *
-     * @param winNo
-     * @return
-     */
-    @Update("update mz_drug_win set patient_num=patient_num where win_no = #{winNo,jdbcType=CHAR}")
-    int updateForBlock(String winNo);
+//    /**
+//     * 加锁
+//     *
+//     * @param winNo
+//     * @return
+//     */
+//    @Update("update mz_drug_win set patient_num=patient_num where win_no = #{winNo,jdbcType=CHAR}")
+//    int updateForBlock(String winNo);
 
 
     /**
@@ -29,21 +29,21 @@ public interface MzDrugWinMapper {
             " mz_drug_win WITH(NOLOCK) where group_no =#{groupNo,jdbcType=CHAR} and win_cate = '0'  order by patient_num asc ")
     MzDrugWin selectMinMzDrugWin(@Param("groupNo") String groupNo);
 
-    /**
-     * 更新药房的排队人数
-     *
-     * @param mzDrugWin
-     * @return
-     */
-    @Update({"<script>",
-            "update mz_drug_win ",
-            "<trim prefix='set' prefixOverrides=',' suffix=' where win_no = #{winNo,jdbcType=CHAR}' >",
-            "<when test='patientNum!=null'>",
-            "patient_num =#{patientNum,jdbcType=INTEGER}",
-            "</when>",
-            "</trim>"
-            , "</script>"})
-    int updateMzDrugWin(MzDrugWin mzDrugWin);
+//    /**
+//     * 更新药房的排队人数
+//     *
+//     * @param mzDrugWin
+//     * @return
+//     */
+//    @Update({"<script>",
+//            "update mz_drug_win ",
+//            "<trim prefix='set' prefixOverrides=',' suffix=' where win_no = #{winNo,jdbcType=CHAR}' >",
+//            "<when test='patientNum!=null'>",
+//            "patient_num =#{patientNum,jdbcType=INTEGER}",
+//            "</when>",
+//            "</trim>"
+//            , "</script>"})
+//    int updateMzDrugWin(MzDrugWin mzDrugWin);
 
     /**
      * 按照组号与窗口号查询窗口名称

+ 55 - 24
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzSerialNoMapper.java

@@ -10,13 +10,13 @@ import java.util.Date;
 public interface MzSerialNoMapper {
 
 
-    /**
-     * 加锁
-     * @param updateTime
-     * @return
-     */
-    @Update("update mz_serial_no set update_time=#{updateTime,jdbcType=TIMESTAMP} where id = 1")
-    int updateForBlock(@Param("updateTime") Date updateTime);
+//    /**
+//     * 加锁
+//     * @param updateTime
+//     * @return
+//     */
+//    @Update("update mz_serial_no set update_time=#{updateTime,jdbcType=TIMESTAMP} where id = 1")
+//    int updateForBlock(@Param("updateTime") Date updateTime);
 
     /**
      * 查询序列号记录
@@ -25,24 +25,55 @@ public interface MzSerialNoMapper {
     @Select("select serial_no,rtrim(outpatient_no) outpatient_no,inject_no,serial_out,prior_no,serial_new,hzyl_no from mz_serial_no WITH(NOLOCK) where id = 1")
     MzSerialNo selectMzSerialNo();
 
+//    /**
+//     * 更新序列号
+//     * @param mzSerialNo
+//     * @return
+//     */
+//    @Update({"<script>",
+//            "update mz_serial_no ",
+//            "<trim prefix='set' prefixOverrides=',' suffix=' where id =1 ' >",
+//               "<when test='newOutpatientNo!=null'>",
+//                  "outpatient_no =#{newOutpatientNo,jdbcType=VARCHAR}",
+//               "</when>",
+//               "<when test='newSerialOut!=null'>",
+//                  ",serial_out =#{newSerialOut,jdbcType=INTEGER}",
+//               "</when>",
+//               "<when test='newSerialNew!=null'>",
+//                  ",serial_new =#{newSerialNew,jdbcType=INTEGER}",
+//               "</when>",
+//            "</trim>"
+//            ,"</script>"})
+//    int updateMzSerialNo(MzSerialNo mzSerialNo);
+
+    /**
+     * 更新门诊挂号流水号
+     * @param serialOut
+     * @param newSerialOut
+     * @return
+     */
+    @Update("update mz_serial_no set serial_out =#{newSerialOut} where id =1 and serial_out =#{serialOut} ")
+    int updateSerialOut(@Param("serialOut")Integer serialOut, @Param("newSerialOut")Integer newSerialOut);
+
+
+
+    /**
+     * 更新病人ID流水号
+     * @param outpatientNo
+     * @param newOutpatientNo
+     * @return
+     */
+    @Update("update mz_serial_no set outpatient_no =#{newOutpatientNo} where id =1 and outpatient_no =#{outpatientNo} ")
+    int updateOutpatientNo(@Param("outpatientNo")String outpatientNo, @Param("newOutpatientNo")String newOutpatientNo);
+
+
+
     /**
-     * 更新序列号
-     * @param mzSerialNo
+     * 更新收费流水号
+     * @param serialNew
+     * @param newSerialNew
      * @return
      */
-    @Update({"<script>",
-            "update mz_serial_no ",
-            "<trim prefix='set' prefixOverrides=',' suffix=' where id =1 ' >",
-               "<when test='newOutpatientNo!=null'>",
-                  "outpatient_no =#{newOutpatientNo,jdbcType=VARCHAR}",
-               "</when>",
-               "<when test='newSerialOut!=null'>",
-                  ",serial_out =#{newSerialOut,jdbcType=INTEGER}",
-               "</when>",
-               "<when test='newSerialNew!=null'>",
-                  ",serial_new =#{newSerialNew,jdbcType=INTEGER}",
-               "</when>",
-            "</trim>"
-            ,"</script>"})
-    int updateMzSerialNo(MzSerialNo mzSerialNo);
+    @Update("update mz_serial_no set serial_new =#{newSerialNew} where id =1 and serial_new =#{serialNew} ")
+    int updateSerialNew(@Param("serialNew")Integer serialNew, @Param("newSerialNew")Integer newSerialNew);
 }

+ 9 - 8
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzfzConfigMappper.java

@@ -1,22 +1,23 @@
 package cn.hnthyy.thmz.mapper.his.mz;
 
 import cn.hnthyy.thmz.entity.his.mz.MzfzConfig;
+import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 
 public interface MzfzConfigMappper {
-    /**
-     * 加锁
-     * @return
-     */
-    @Update("update mzfz_config set gh_no =gh_no where item_no = 1")
-    int updateForBlock();
+//    /**
+//     * 加锁
+//     * @return
+//     */
+//    @Update("update mzfz_config set gh_no =gh_no where item_no = 1")
+//    int updateForBlock();
 
     @Select("select * from mzfz_config  WITH(NOLOCK) where item_no = 1")
     MzfzConfig selectMzfzConfig();
 
-    @Update("update mzfz_config set gh_no =#{ghNo} where item_no = 1")
-    int updateMzfzConfig(MzfzConfig mzfzConfig);
+    @Update("update mzfz_config set gh_no =#{newGhNo} where item_no = 1 and gh_no =#{ghNo} ")
+    int updateMzfzConfig(@Param("ghNo")Integer ghNo, @Param("newGhNo")Integer newGhNo);
 
 
 

+ 68 - 30
src/main/java/cn/hnthyy/thmz/mapper/his/zy/ZyConfigMapper.java

@@ -9,13 +9,13 @@ import java.util.Date;
 
 public interface ZyConfigMapper {
 
-    /**
-     * 加锁
-     * @param updateTime
-     * @return
-     */
-    @Update("update zy_config set update_time=#{updateTime,jdbcType=TIMESTAMP} where item_no = 1")
-    int updateForBlock(@Param("updateTime") Date updateTime);
+//    /**
+//     * 加锁
+//     * @param updateTime
+//     * @return
+//     */
+//    @Update("update zy_config set update_time=#{updateTime,jdbcType=TIMESTAMP} where item_no = 1")
+//    int updateForBlock(@Param("updateTime") Date updateTime);
 
     /**
      * 查询住院配置表信息
@@ -24,34 +24,72 @@ public interface ZyConfigMapper {
     @Select(" select * from zy_config where item_no = 1")
     ZyConfig selectZyConfig();
 
+//
+//    /**
+//     * 更新序列号
+//     * @param zyConfig
+//     * @return
+//     */
+//    @Update({"<script>",
+//            "update zy_config ",
+//            "<trim prefix='set' prefixOverrides=',' suffix=' where item_no =1 ' >",
+//            "<when test='inpatientNo!=null'>",
+//            "inpatient_no =#{inpatientNo,jdbcType=INTEGER}",
+//            "</when>",
+//            "<when test='zySerialNo!=null'>",
+//            ",zy_serial_no =#{zySerialNo,jdbcType=INTEGER}",
+//            "</when>",
+//            "<when test='delNo!=null'>",
+//            ",del_no =#{delNo,jdbcType=INTEGER}",
+//            "</when>",
+//            "<when test='jcNo!=null'>",
+//            ",jc_no =#{jcNo,jdbcType=INTEGER}",
+//            "</when>",
+//            "<when test='chargeCode!=null'>",
+//            ",charge_code =#{chargeCode,jdbcType=INTEGER}",
+//            "</when>",
+//            "</trim>"
+//            ,"</script>"})
+//    int updateZyConfig(ZyConfig zyConfig);
+
+
 
     /**
-     * 更新序列号
-     * @param zyConfig
+     * 更新住院号
+     * @param inpatientNo
+     * @param newInpatientNo
      * @return
      */
-    @Update({"<script>",
-            "update zy_config ",
-            "<trim prefix='set' prefixOverrides=',' suffix=' where item_no =1 ' >",
-            "<when test='inpatientNo!=null'>",
-            "inpatient_no =#{inpatientNo,jdbcType=INTEGER}",
-            "</when>",
-            "<when test='zySerialNo!=null'>",
-            ",zy_serial_no =#{zySerialNo,jdbcType=INTEGER}",
-            "</when>",
-            "<when test='delNo!=null'>",
-            ",del_no =#{delNo,jdbcType=INTEGER}",
-            "</when>",
-            "<when test='jcNo!=null'>",
-            ",jc_no =#{jcNo,jdbcType=INTEGER}",
-            "</when>",
-            "<when test='chargeCode!=null'>",
-            ",charge_code =#{chargeCode,jdbcType=INTEGER}",
-            "</when>",
-            "</trim>"
-            ,"</script>"})
-    int updateZyConfig(ZyConfig zyConfig);
+    @Update("update zy_config set inpatient_no =#{newInpatientNo} where item_no =1 and inpatient_no =#{inpatientNo} ")
+    int updateInpatientNo(@Param("inpatientNo")Integer inpatientNo, @Param("newInpatientNo")Integer newInpatientNo);
 
 
+    /**
+     * 更新家床号码
+     * @param jcNo
+     * @param newJcNo
+     * @return
+     */
+    @Update("update zy_config set jc_no =#{newJcNo} where item_no =1 and jc_no =#{jcNo} ")
+    int updateJcNo(@Param("jcNo")Integer jcNo, @Param("newJcNo")Integer newJcNo);
+
+
+    /**
+     * 更新住院流水号
+     * @param zySerialNo
+     * @param newZySerialNo
+     * @return
+     */
+    @Update("update zy_config set zy_serial_no =#{newZySerialNo} where item_no =1 and zy_serial_no =#{zySerialNo} ")
+    int updateZySerialNo(@Param("zySerialNo")Integer zySerialNo, @Param("newZySerialNo")Integer newZySerialNo);
+
+    /**
+     * 更新收费编码
+     * @param chargeCode
+     * @param newChargeCode
+     * @return
+     */
+    @Update("update zy_config set charge_code =#{newChargeCode} where item_no =1 and charge_code =#{chargeCode} ")
+    int updateChargeCode(@Param("chargeCode")Integer chargeCode, @Param("newChargeCode")Integer newChargeCode);
 
 }

+ 7 - 7
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzDrugWinServiceImpl.java

@@ -23,17 +23,17 @@ public class MzDrugWinServiceImpl implements MzDrugWinService {
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     @Override
     public MzDrugWin queryMinMzDrugWin(String groupNo) throws MzException {
-        mzDrugWinMapper.updateForBlock(groupNo);
+       // mzDrugWinMapper.updateForBlock(groupNo);
         MzDrugWin mzDrugWin=mzDrugWinMapper.selectMinMzDrugWin(groupNo);
         if (mzDrugWin == null) {
             throw new MzException("当前药房【"+groupNo+"】没有在使用中的发药窗口,请先设置!");
         }
-        if(mzDrugWin.getPatientNum()==null){
-            mzDrugWin.setPatientNum(1);
-        }else {
-            mzDrugWin.setPatientNum(mzDrugWin.getPatientNum()+1);
-        }
-        mzDrugWinMapper.updateMzDrugWin(mzDrugWin);
+//        if(mzDrugWin.getPatientNum()==null){
+//            mzDrugWin.setPatientNum(1);
+//        }else {
+//            mzDrugWin.setPatientNum(mzDrugWin.getPatientNum()+1);
+//        }
+//        mzDrugWinMapper.updateMzDrugWin(mzDrugWin);
         return mzDrugWin;
     }
 

+ 6 - 6
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzSerialNoServiceImpl.java

@@ -22,13 +22,13 @@ public class MzSerialNoServiceImpl implements MzSerialNoService {
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     @Override
     public int getMzSerialNo() throws MzException {
-        mzSerialNoMapper.updateForBlock(new Date());
+       // mzSerialNoMapper.updateForBlock(new Date());
         MzSerialNo mzSerialNo = mzSerialNoMapper.selectMzSerialNo();
         if (mzSerialNo == null) {
             throw new MzException("序列号生成器不存在,请先设置!");
         }
         mzSerialNo.setNewSerialOut(mzSerialNo.getSerialOut() + 1);
-        int num = mzSerialNoMapper.updateMzSerialNo(mzSerialNo);
+        int num = mzSerialNoMapper.updateSerialOut(mzSerialNo.getSerialOut(),mzSerialNo.getNewSerialOut());
         if (num == 0) {
             throw new MzException("获取挂号流水号失败,请重试!");
         }
@@ -38,14 +38,14 @@ public class MzSerialNoServiceImpl implements MzSerialNoService {
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     @Override
     public String getMzPatientNo() throws MzException {
-        mzSerialNoMapper.updateForBlock(new Date());
+        //mzSerialNoMapper.updateForBlock(new Date());
         MzSerialNo mzSerialNo = mzSerialNoMapper.selectMzSerialNo();
         if (mzSerialNo == null) {
             throw new MzException("序列号生成器不存在,请先设置!");
         }
         Integer newOutpatientNo=Integer.valueOf(mzSerialNo.getOutpatientNo()) + 1;
         mzSerialNo.setNewOutpatientNo(newOutpatientNo.toString());
-        int num = mzSerialNoMapper.updateMzSerialNo(mzSerialNo);
+        int num = mzSerialNoMapper.updateOutpatientNo(mzSerialNo.getOutpatientNo(),mzSerialNo.getNewOutpatientNo());
         if (num == 0) {
             throw new MzException("获取挂号流水号失败,请重试!");
         }
@@ -55,13 +55,13 @@ public class MzSerialNoServiceImpl implements MzSerialNoService {
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     @Override
     public int getSerialNo() throws MzException {
-        mzSerialNoMapper.updateForBlock(new Date());
+        //mzSerialNoMapper.updateForBlock(new Date());
         MzSerialNo mzSerialNo = mzSerialNoMapper.selectMzSerialNo();
         if (mzSerialNo == null) {
             throw new MzException("序列号生成器不存在,请先设置!");
         }
         mzSerialNo.setNewSerialNew(mzSerialNo.getSerialNew() + 1);
-        int num = mzSerialNoMapper.updateMzSerialNo(mzSerialNo);
+        int num = mzSerialNoMapper.updateSerialNew(mzSerialNo.getSerialNew(),mzSerialNo.getNewSerialNew());
         if (num == 0) {
             throw new MzException("获取缴费流水号失败,请重试!");
         }

+ 3 - 2
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzfzConfigServiceImpl.java

@@ -19,13 +19,14 @@ public class MzfzConfigServiceImpl implements MzfzConfigService {
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     @Override
     public int getGhNo() throws MzException {
-        mzfzConfigMappper.updateForBlock();
+        //mzfzConfigMappper.updateForBlock();
         MzfzConfig mzfzConfig = mzfzConfigMappper.selectMzfzConfig();
         if (mzfzConfig == null) {
             throw new MzException("序列号生成器不存在,请先设置!");
         }
+        Integer oldGhNo=mzfzConfig.getGhNo();
         mzfzConfig.setGhNo(mzfzConfig.getGhNo() + 1);
-        int num = mzfzConfigMappper.updateMzfzConfig(mzfzConfig);
+        int num = mzfzConfigMappper.updateMzfzConfig(oldGhNo,mzfzConfig.getGhNo());
         if (num == 0) {
             throw new MzException("获取序号失败,请重试!");
         }

+ 11 - 8
src/main/java/cn/hnthyy/thmz/service/impl/his/zy/ZyConfigServiceImpl.java

@@ -18,13 +18,14 @@ public class ZyConfigServiceImpl implements ZyConfigService {
     private ZyConfigMapper zyConfigMapper;
     @Override
     public int getInpatientNo() throws MzException {
-        zyConfigMapper.updateForBlock(new Date());
+        //zyConfigMapper.updateForBlock(new Date());
         ZyConfig zyConfig = zyConfigMapper.selectZyConfig();
         if (zyConfig == null) {
             throw new MzException("住院序列号生成器不存在,请先设置!");
         }
+        Integer old=zyConfig.getInpatientNo();
         zyConfig.setInpatientNo(zyConfig.getInpatientNo() + 1);
-        int num = zyConfigMapper.updateZyConfig(zyConfig);
+        int num = zyConfigMapper.updateInpatientNo(old,zyConfig.getInpatientNo());
         if (num == 0) {
             throw new MzException("获取住院号失败,请重试!");
         }
@@ -33,13 +34,14 @@ public class ZyConfigServiceImpl implements ZyConfigService {
 
     @Override
     public String getJcNo() throws MzException {
-        zyConfigMapper.updateForBlock(new Date());
+        //zyConfigMapper.updateForBlock(new Date());
         ZyConfig zyConfig = zyConfigMapper.selectZyConfig();
         if (zyConfig == null) {
             throw new MzException("家床号生成器不存在,请先设置!");
         }
+        Integer old=zyConfig.getJcNo();
         zyConfig.setJcNo(zyConfig.getJcNo() + 1);
-        int num = zyConfigMapper.updateZyConfig(zyConfig);
+        int num = zyConfigMapper.updateJcNo(old,zyConfig.getJcNo());
         if (num == 0) {
             throw new MzException("获取家床号失败,请重试!");
         }
@@ -49,13 +51,14 @@ public class ZyConfigServiceImpl implements ZyConfigService {
 
     @Override
     public String getZySerialNo() throws MzException {
-        zyConfigMapper.updateForBlock(new Date());
+        //zyConfigMapper.updateForBlock(new Date());
         ZyConfig zyConfig = zyConfigMapper.selectZyConfig();
         if (zyConfig == null) {
             throw new MzException("住院流水号生成器不存在,请先设置!");
         }
+        Integer old=zyConfig.getZySerialNo();
         zyConfig.setZySerialNo(zyConfig.getZySerialNo() + 1);
-        int num = zyConfigMapper.updateZyConfig(zyConfig);
+        int num = zyConfigMapper.updateZySerialNo(old,zyConfig.getZySerialNo());
         if (num == 0) {
             throw new MzException("获取流水号失败,请重试!");
         }
@@ -65,14 +68,14 @@ public class ZyConfigServiceImpl implements ZyConfigService {
 
     @Override
     public String getChargeCode(String classCode) throws MzException {
-        zyConfigMapper.updateForBlock(new Date());
+        //zyConfigMapper.updateForBlock(new Date());
         ZyConfig zyConfig = zyConfigMapper.selectZyConfig();
         if (zyConfig == null) {
             throw new MzException("收费项目编码生成器不存在,请先设置!");
         }
         Integer chargeCode =zyConfig.getChargeCode();
         zyConfig.setChargeCode(zyConfig.getChargeCode() + 1);
-        int num = zyConfigMapper.updateZyConfig(zyConfig);
+        int num = zyConfigMapper.updateChargeCode(chargeCode,zyConfig.getChargeCode());
         if (num == 0) {
             throw new MzException("获取收费项目编码失败,请重试!");
         }