Procházet zdrojové kódy

优化医嘱编码新生成功能

hurugang před 2 roky
rodič
revize
4ffb824633

+ 6 - 1
src/main/java/cn/hnthyy/thmz/Utils/SignUtil.java

@@ -56,7 +56,12 @@ public class SignUtil {
         if(lastCode==null || org.apache.commons.lang3.StringUtils.isBlank(lastCode)){
             newCode="01";
         }else {
-            Integer codeI = Integer.valueOf(lastCode);
+            Integer codeI =null;
+            try {
+                codeI = Integer.valueOf(lastCode);
+            }catch (NumberFormatException e){
+                codeI=Double.valueOf(lastCode).intValue();
+            }
             codeI++;
             if(codeI<10){
                 newCode="0"+codeI;

+ 25 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/yz/YzSequenceMapper.java

@@ -0,0 +1,25 @@
+package cn.hnthyy.thmz.mapper.his.yz;
+
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+public interface YzSequenceMapper {
+
+    /**
+     * 查询医嘱码
+     *
+     * @return
+     */
+    @Select("select order_code from yz_sequence")
+    String selectZyOrderCode();
+
+    /**
+     * 更新医嘱号
+     * @param newOrderCode 新编码
+     * @param oldOrderCode 旧编码
+     * @return
+     */
+    @Update("update yz_sequence set order_code=#{newOrderCode} where order_code=#{oldOrderCode}")
+    int updateZyOrderCode(@Param("newOrderCode") String newOrderCode,@Param("oldOrderCode") String oldOrderCode);
+}

+ 6 - 1
src/main/java/cn/hnthyy/thmz/service/impl/his/zd/JcZdItemServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hnthyy.thmz.Utils.SignUtil;
 import cn.hnthyy.thmz.entity.his.yz.YzOrderItem;
 import cn.hnthyy.thmz.entity.his.zd.JcZdItem;
 import cn.hnthyy.thmz.mapper.his.yz.YzOrderItemMapper;
+import cn.hnthyy.thmz.mapper.his.yz.YzSequenceMapper;
 import cn.hnthyy.thmz.mapper.his.zd.JcZdItemMapper;
 import cn.hnthyy.thmz.mapper.his.zd.JyZdItemMapper;
 import cn.hnthyy.thmz.service.his.zd.JcZdItemService;
@@ -27,6 +28,9 @@ public class JcZdItemServiceImpl implements JcZdItemService {
     @SuppressWarnings("all")
     @Autowired
     private YzOrderItemMapper yzOrderItemMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    private YzSequenceMapper yzSequenceMapper;
     @Override
     public JcZdItem queryJcZdItemByCode(String code) {
         return jcZdItemMapper.selectJcZdItemByCode(code);
@@ -66,12 +70,13 @@ public class JcZdItemServiceImpl implements JcZdItemService {
                 newCode="0"+newCode;
             }
             jcZdItem.setCode(newCode);
-            String lastZyOrderCode=yzOrderItemMapper.selectLastZyOrderCode();
+            String lastZyOrderCode=yzSequenceMapper.selectZyOrderCode();
             String newZyCode= SignUtil.getNewCoder(lastZyOrderCode);
             while (newZyCode.length()<5){
                 newZyCode="0"+newZyCode;
             }
             jcZdItem.setZyOrderCode(newZyCode);
+            yzSequenceMapper.updateZyOrderCode(newZyCode,lastZyOrderCode);
             String lastMzCode=jcZdItemMapper.selectLastMzCode();
             String lastJyMzCode=jyZdItemMapper.selectLastMzCode();
             if(Integer.parseInt(lastJyMzCode)>Integer.parseInt(lastMzCode)){

+ 6 - 1
src/main/java/cn/hnthyy/thmz/service/impl/his/zd/JyZdItemServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hnthyy.thmz.Utils.SignUtil;
 import cn.hnthyy.thmz.entity.his.yz.YzOrderItem;
 import cn.hnthyy.thmz.entity.his.zd.JyZdItem;
 import cn.hnthyy.thmz.mapper.his.yz.YzOrderItemMapper;
+import cn.hnthyy.thmz.mapper.his.yz.YzSequenceMapper;
 import cn.hnthyy.thmz.mapper.his.zd.JcZdItemMapper;
 import cn.hnthyy.thmz.mapper.his.zd.JyZdItemMapper;
 import cn.hnthyy.thmz.service.his.zd.JyZdItemService;
@@ -27,6 +28,9 @@ public class JyZdItemServiceImpl implements JyZdItemService {
     @SuppressWarnings("all")
     @Autowired
     private YzOrderItemMapper yzOrderItemMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    private YzSequenceMapper yzSequenceMapper;
     @Override
     public JyZdItem queryJyZdItemByCode(String code) {
         return jyZdItemMapper.selectJyZdItemByCode(code);
@@ -71,12 +75,13 @@ public class JyZdItemServiceImpl implements JyZdItemService {
                 newCode="0"+newCode;
             }
             jyZdItem.setCode(newCode);
-            String lastZyOrderCode=yzOrderItemMapper.selectLastZyOrderCode();
+            String lastZyOrderCode=yzSequenceMapper.selectZyOrderCode();
             String newZyCode= SignUtil.getNewCoder(lastZyOrderCode);
             while (newZyCode.length()<5){
                 newZyCode="0"+newZyCode;
             }
             jyZdItem.setZyOrderCode(newZyCode);
+            yzSequenceMapper.updateZyOrderCode(newZyCode,lastZyOrderCode);
             String lastMzCode=jcZdItemMapper.selectLastMzCode();
             String lastJyMzCode=jyZdItemMapper.selectLastMzCode();
             if(Integer.parseInt(lastJyMzCode)>Integer.parseInt(lastMzCode)){