|
@@ -4,16 +4,32 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.diagbot.dto.HospitalInfoDTO;
|
|
import com.diagbot.dto.HospitalInfoDTO;
|
|
|
|
+import com.diagbot.entity.DeptConfig;
|
|
import com.diagbot.entity.DiseaseConfig;
|
|
import com.diagbot.entity.DiseaseConfig;
|
|
|
|
+import com.diagbot.entity.DrugConfig;
|
|
import com.diagbot.entity.HospitalInfo;
|
|
import com.diagbot.entity.HospitalInfo;
|
|
|
|
+import com.diagbot.entity.LisConfig;
|
|
|
|
+import com.diagbot.entity.OperationConfig;
|
|
|
|
+import com.diagbot.entity.PacsConfig;
|
|
|
|
+import com.diagbot.entity.Plan;
|
|
|
|
+import com.diagbot.entity.TransfusionConfig;
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
import com.diagbot.exception.CommonException;
|
|
import com.diagbot.exception.CommonException;
|
|
|
|
+import com.diagbot.service.DeptConfigService;
|
|
|
|
+import com.diagbot.service.DiseaseConfigService;
|
|
|
|
+import com.diagbot.service.DrugConfigService;
|
|
import com.diagbot.service.HospitalInfoService;
|
|
import com.diagbot.service.HospitalInfoService;
|
|
|
|
+import com.diagbot.service.LisConfigService;
|
|
|
|
+import com.diagbot.service.OperationConfigService;
|
|
|
|
+import com.diagbot.service.PacsConfigService;
|
|
|
|
+import com.diagbot.service.TransfusionConfigService;
|
|
import com.diagbot.service.impl.HospitalInfoServiceImpl;
|
|
import com.diagbot.service.impl.HospitalInfoServiceImpl;
|
|
import com.diagbot.util.BeanUtil;
|
|
import com.diagbot.util.BeanUtil;
|
|
|
|
+import com.diagbot.util.Cn2SpellUtil;
|
|
import com.diagbot.util.DateUtil;
|
|
import com.diagbot.util.DateUtil;
|
|
import com.diagbot.util.ListUtil;
|
|
import com.diagbot.util.ListUtil;
|
|
|
|
+import com.diagbot.util.StringUtil;
|
|
import com.diagbot.util.UserUtils;
|
|
import com.diagbot.util.UserUtils;
|
|
import com.diagbot.vo.HospitalInfoListVO;
|
|
import com.diagbot.vo.HospitalInfoListVO;
|
|
import com.diagbot.vo.HospitalInfoPageVO;
|
|
import com.diagbot.vo.HospitalInfoPageVO;
|
|
@@ -38,6 +54,22 @@ public class HospitalInfoFacade extends HospitalInfoServiceImpl {
|
|
@Autowired
|
|
@Autowired
|
|
@Qualifier("hospitalInfoServiceImpl")
|
|
@Qualifier("hospitalInfoServiceImpl")
|
|
private HospitalInfoService hospitalInfoService;
|
|
private HospitalInfoService hospitalInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private DeptConfigService deptConfigService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private DiseaseConfigService diseaseConfigService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private DrugConfigService drugConfigService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private LisConfigService lisConfigService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private OperationConfigService operationConfigService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private PacsConfigService pacsConfigService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private TransfusionConfigService transfusionConfigService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private PlanFacade planFacade;
|
|
|
|
|
|
public List<HospitalInfoDTO> getHospitalInfo() {
|
|
public List<HospitalInfoDTO> getHospitalInfo() {
|
|
QueryWrapper<HospitalInfo> hospitalInfo = new QueryWrapper<>();
|
|
QueryWrapper<HospitalInfo> hospitalInfo = new QueryWrapper<>();
|
|
@@ -59,10 +91,43 @@ public class HospitalInfoFacade extends HospitalInfoServiceImpl {
|
|
Date now = DateUtil.now();
|
|
Date now = DateUtil.now();
|
|
hospitalInfo.setModifier(userId);
|
|
hospitalInfo.setModifier(userId);
|
|
hospitalInfo.setGmtModified(now);
|
|
hospitalInfo.setGmtModified(now);
|
|
|
|
+ QueryWrapper<HospitalInfo> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
|
+ if (StringUtil.isNotBlank(hospitalInfo.getName())) {
|
|
|
|
+ queryWrapper.eq("name", hospitalInfo.getName());
|
|
|
|
+ HospitalInfo oldRecord = this.getOne(queryWrapper, false);
|
|
|
|
+ if (hospitalInfo.getId() == null
|
|
|
|
+ && oldRecord != null) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.IS_EXISTS, "该医院名称已存在");
|
|
|
|
+ }
|
|
|
|
+ if (hospitalInfo.getId() != null
|
|
|
|
+ && oldRecord != null
|
|
|
|
+ && !hospitalInfo.getId().equals(oldRecord.getId())) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.IS_EXISTS, "该医院名称已存在");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (StringUtil.isNotBlank(hospitalInfo.getCode())) {
|
|
|
|
+ queryWrapper.eq("code", hospitalInfo.getCode());
|
|
|
|
+ HospitalInfo oldRecord = this.getOne(queryWrapper, false);
|
|
|
|
+ if (hospitalInfo.getId() == null
|
|
|
|
+ && oldRecord != null) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.IS_EXISTS, "该医院编码已存在");
|
|
|
|
+ }
|
|
|
|
+ if (hospitalInfo.getId() != null
|
|
|
|
+ && oldRecord != null
|
|
|
|
+ && !hospitalInfo.getId().equals(oldRecord.getId())) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.IS_EXISTS, "该医院编码已存在");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//新增数据
|
|
//新增数据
|
|
if (hospitalInfo.getId() == null) {
|
|
if (hospitalInfo.getId() == null) {
|
|
hospitalInfo.setCreator(userId);
|
|
hospitalInfo.setCreator(userId);
|
|
hospitalInfo.setGmtCreate(now);
|
|
hospitalInfo.setGmtCreate(now);
|
|
|
|
+ hospitalInfo.setConnect(1);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtil.isBlank(hospitalInfo.getSpell())) {
|
|
|
|
+ hospitalInfo.setSpell(Cn2SpellUtil.converterToFirstSpell(hospitalInfo.getName()));
|
|
}
|
|
}
|
|
if (hospitalInfo.getIsDeleted() == null) {
|
|
if (hospitalInfo.getIsDeleted() == null) {
|
|
hospitalInfo.setIsDeleted(IsDeleteEnum.N.getKey());
|
|
hospitalInfo.setIsDeleted(IsDeleteEnum.N.getKey());
|
|
@@ -111,6 +176,66 @@ public class HospitalInfoFacade extends HospitalInfoServiceImpl {
|
|
if (hospitalInfo.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
|
|
if (hospitalInfo.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
|
|
throw new CommonException(CommonErrorCode.NOT_EXISTS, "数据已删除");
|
|
throw new CommonException(CommonErrorCode.NOT_EXISTS, "数据已删除");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //校验关联数据
|
|
|
|
+ List<DeptConfig> deptConfigList
|
|
|
|
+ = deptConfigService.list(new QueryWrapper<DeptConfig>()
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("hospital_id", idVO.getId()));
|
|
|
|
+ if (ListUtil.isNotEmpty(deptConfigList)) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该医院存在关联数据,无法删除");
|
|
|
|
+ }
|
|
|
|
+ List<DiseaseConfig> diseaseConfigList
|
|
|
|
+ = diseaseConfigService.list(new QueryWrapper<DiseaseConfig>()
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("hospital_id", idVO.getId()));
|
|
|
|
+ if (ListUtil.isNotEmpty(diseaseConfigList)) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该医院存在关联数据,无法删除");
|
|
|
|
+ }
|
|
|
|
+ List<DrugConfig> drugConfigList
|
|
|
|
+ = drugConfigService.list(new QueryWrapper<DrugConfig>()
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("hospital_id", idVO.getId()));
|
|
|
|
+ if (ListUtil.isNotEmpty(drugConfigList)) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该医院存在关联数据,无法删除");
|
|
|
|
+ }
|
|
|
|
+ List<LisConfig> lisConfigList
|
|
|
|
+ = lisConfigService.list(new QueryWrapper<LisConfig>()
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("hospital_id", idVO.getId()));
|
|
|
|
+ if (ListUtil.isNotEmpty(lisConfigList)) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该医院存在关联数据,无法删除");
|
|
|
|
+ }
|
|
|
|
+ List<OperationConfig> operationConfigList
|
|
|
|
+ = operationConfigService.list(new QueryWrapper<OperationConfig>()
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("hospital_id", idVO.getId()));
|
|
|
|
+ if (ListUtil.isNotEmpty(operationConfigList)) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该医院存在关联数据,无法删除");
|
|
|
|
+ }
|
|
|
|
+ List<PacsConfig> pacsConfigList
|
|
|
|
+ = pacsConfigService.list(new QueryWrapper<PacsConfig>()
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("hospital_id", idVO.getId()));
|
|
|
|
+ if (ListUtil.isNotEmpty(pacsConfigList)) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该医院存在关联数据,无法删除");
|
|
|
|
+ }
|
|
|
|
+ List<TransfusionConfig> transfusionConfigList
|
|
|
|
+ = transfusionConfigService.list(new QueryWrapper<TransfusionConfig>()
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("hospital_id", idVO.getId()));
|
|
|
|
+ if (ListUtil.isNotEmpty(transfusionConfigList)) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该医院存在关联数据,无法删除");
|
|
|
|
+ }
|
|
|
|
+ List<Plan> planList
|
|
|
|
+ = planFacade.list(new QueryWrapper<Plan>()
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("hospital_id", idVO.getId()));
|
|
|
|
+ if (ListUtil.isNotEmpty(planList)) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该医院存在关联数据,无法删除");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
hospitalInfo.setIsDeleted(IsDeleteEnum.Y.getKey());
|
|
hospitalInfo.setIsDeleted(IsDeleteEnum.Y.getKey());
|
|
hospitalInfo.setModifier(userId);
|
|
hospitalInfo.setModifier(userId);
|
|
hospitalInfo.setGmtModified(now);
|
|
hospitalInfo.setGmtModified(now);
|