|
@@ -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();
|
|
|
+ }
|
|
|
+}
|