|
@@ -12,9 +12,7 @@ import cn.hnthyy.thmz.mapper.his.zd.ZdUnitCodeMapper;
|
|
|
import cn.hnthyy.thmz.mapper.thmz.ConfigMapper;
|
|
|
import cn.hnthyy.thmz.pageDto.ZdUnitCodePageDto;
|
|
|
import cn.hnthyy.thmz.service.his.zd.ZdUnitCodeService;
|
|
|
-import cn.hnthyy.thmz.service.thmz.ButtonService;
|
|
|
import cn.hnthyy.thmz.service.thmz.HaiCiAdapterService;
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -85,25 +83,22 @@ public class ZdUnitCodeServiceImpl implements ZdUnitCodeService {
|
|
|
@Override
|
|
|
public int saveZdUnitCode(ZdUnitCode zdUnitCode) throws MzException {
|
|
|
if (zdUnitCode.getClassCode() == null) {
|
|
|
- throw new MzException("分类码不能为空!");
|
|
|
+ throw new MzException("分类不能为空!");
|
|
|
}
|
|
|
ClassCodeEnum classCodeEnum = ClassCodeEnum.getClassCodeByCode(zdUnitCode.getClassCode());
|
|
|
if (classCodeEnum == null) {
|
|
|
- throw new MzException("分类码不正确!");
|
|
|
+ throw new MzException("分类不正确!");
|
|
|
}
|
|
|
- ZdUnitCode dbZdUnitCode = zdUnitCodeMapper.selectLastZdUnitCodeByCode(classCodeEnum.unitCodePrefix + "%");
|
|
|
- String code = null;
|
|
|
- if (dbZdUnitCode == null) {
|
|
|
- //如果没有的分类,直接设置901开头的科室编码
|
|
|
- dbZdUnitCode = zdUnitCodeMapper.selectLastZdUnitCodeByCode("901%");
|
|
|
+ if (zdUnitCode.getMzClass() == null) {
|
|
|
+ throw new MzException("门诊分类码不能为空!");
|
|
|
}
|
|
|
- if (dbZdUnitCode == null) {
|
|
|
- code = "9010000";
|
|
|
- } else {
|
|
|
- Integer tempCode = Integer.valueOf(dbZdUnitCode.getCode());
|
|
|
- tempCode++;
|
|
|
- code = tempCode.toString();
|
|
|
+ if (zdUnitCode.getMzClass().trim().length() != 2) {
|
|
|
+ throw new MzException("门诊分类码长度不正确!(门诊分类码长度应为 2 位)");
|
|
|
}
|
|
|
+ ZdUnitCode dbZdUnitCode = zdUnitCodeMapper.selectLastZdUnitCodeByCode(classCodeEnum.unitCodePrefix + "%");
|
|
|
+ String code = dbZdUnitCode == null ?
|
|
|
+ zdUnitCode.getClassCode() + zdUnitCode.getMzClass() + "0001" :
|
|
|
+ String.valueOf(Integer.parseInt(dbZdUnitCode.getCode()) + 1);
|
|
|
zdUnitCode.setCode(code);
|
|
|
if(zdUnitCode.getUnitNum() == null){
|
|
|
zdUnitCode.setUnitNum(5);
|
|
@@ -154,10 +149,10 @@ public class ZdUnitCodeServiceImpl implements ZdUnitCodeService {
|
|
|
* @param yesNoEnum 强制刷新缓存标记
|
|
|
*/
|
|
|
private void initMap(String code, YesNoEnum yesNoEnum) {
|
|
|
- if (YesNoEnum.YES.equals(yesNoEnum) || map.size() == 0 || (code != null && map.get(code) == null)) {
|
|
|
+ if (YesNoEnum.YES.equals(yesNoEnum) || map.isEmpty() || (code != null && map.get(code) == null)) {
|
|
|
List<ZdUnitCode> zdUnitCodes = zdUnitCodeMapper.selectAll();
|
|
|
- if (zdUnitCodes != null && zdUnitCodes.size() > 0) {
|
|
|
- zdUnitCodes.stream().forEach(zdUnitCode -> {
|
|
|
+ if (zdUnitCodes != null && !zdUnitCodes.isEmpty()) {
|
|
|
+ zdUnitCodes.forEach(zdUnitCode -> {
|
|
|
if (zdUnitCode != null) {
|
|
|
map.put(zdUnitCode.getCode(), zdUnitCode);
|
|
|
}
|