Browse Source

导入住院配置表

hurugang 4 years ago
parent
commit
a0ce558389

+ 32 - 0
src/main/java/cn/hnthyy/thmz/entity/his/ZyConfig.java

@@ -0,0 +1,32 @@
+package cn.hnthyy.thmz.entity.his;
+
+import lombok.Data;
+
+@Data
+public class ZyConfig {
+    //记录id
+    private Integer itemNo;
+    //住院流水号
+    private Integer zySerialNo;
+    //
+    private Integer delNo;
+    //
+    private Integer modifyNo;
+    //
+    private Integer depositNoType;
+    //
+    private Integer receiptNoType;
+    //
+    private Integer delNo2;
+    //家床号码
+    private Integer jcNo;
+    //
+    private Integer chargeCode;
+    //
+    private Integer fpZyType;
+    //住院号
+    private Integer inpatientNo;
+    //
+    private Integer ybYlh;
+
+}

+ 54 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/ZyConfigMapper.java

@@ -0,0 +1,54 @@
+package cn.hnthyy.thmz.mapper.his;
+
+import cn.hnthyy.thmz.entity.his.ZyConfig;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+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);
+
+    /**
+     * 查询住院配置表信息
+     * @return
+     */
+    @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>",
+            "</trim>"
+            ,"</script>"})
+    int updateZyConfig(ZyConfig zyConfig);
+
+
+
+}

+ 25 - 0
src/main/java/cn/hnthyy/thmz/service/his/ZyConfigService.java

@@ -0,0 +1,25 @@
+package cn.hnthyy.thmz.service.his;
+
+import cn.hnthyy.thmz.entity.MzException;
+
+public interface ZyConfigService {
+    /**
+     * 获取住院号
+     * @return
+     */
+    int getInpatientNo() throws MzException;
+
+    /**
+     * 获取家床号
+     * @return
+     */
+    String getJcNo() throws MzException;
+
+    /**
+     * 获取住院流水号
+     * @return
+     * @throws MzException
+     */
+    String getZySerialNo() throws MzException;
+
+}

+ 64 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/ZyConfigServiceImpl.java

@@ -0,0 +1,64 @@
+package cn.hnthyy.thmz.service.impl.his;
+
+import cn.hnthyy.thmz.entity.MzException;
+import cn.hnthyy.thmz.entity.his.ZyConfig;
+import cn.hnthyy.thmz.mapper.his.ZyConfigMapper;
+import cn.hnthyy.thmz.service.his.ZyConfigService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+@Service
+public class ZyConfigServiceImpl implements ZyConfigService {
+    @SuppressWarnings("all")
+    @Autowired
+    private ZyConfigMapper zyConfigMapper;
+    @Override
+    public int getInpatientNo() throws MzException {
+        zyConfigMapper.updateForBlock(new Date());
+        ZyConfig zyConfig = zyConfigMapper.selectZyConfig();
+        if (zyConfig == null) {
+            throw new MzException("住院序列号生成器不存在,请先设置!");
+        }
+        zyConfig.setInpatientNo(zyConfig.getInpatientNo() + 1);
+        int num = zyConfigMapper.updateZyConfig(zyConfig);
+        if (num == 0) {
+            throw new MzException("获取住院号失败,请重试!");
+        }
+        return zyConfig.getInpatientNo();
+    }
+
+    @Override
+    public String getJcNo() throws MzException {
+        zyConfigMapper.updateForBlock(new Date());
+        ZyConfig zyConfig = zyConfigMapper.selectZyConfig();
+        if (zyConfig == null) {
+            throw new MzException("家床号生成器不存在,请先设置!");
+        }
+        zyConfig.setJcNo(zyConfig.getJcNo() + 1);
+        int num = zyConfigMapper.updateZyConfig(zyConfig);
+        if (num == 0) {
+            throw new MzException("获取家床号失败,请重试!");
+        }
+        SimpleDateFormat smf = new SimpleDateFormat("yy");
+        return smf.format(new Date())+zyConfig.getJcNo();
+    }
+
+    @Override
+    public String getZySerialNo() throws MzException {
+        zyConfigMapper.updateForBlock(new Date());
+        ZyConfig zyConfig = zyConfigMapper.selectZyConfig();
+        if (zyConfig == null) {
+            throw new MzException("住院流水号生成器不存在,请先设置!");
+        }
+        zyConfig.setZySerialNo(zyConfig.getZySerialNo() + 1);
+        int num = zyConfigMapper.updateZyConfig(zyConfig);
+        if (num == 0) {
+            throw new MzException("获取流水号失败,请重试!");
+        }
+        SimpleDateFormat smf = new SimpleDateFormat("yyMMdd");
+        return smf.format(new Date())+zyConfig.getZySerialNo();
+    }
+}