|
@@ -4,12 +4,8 @@ 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.client.UserServiceClient;
|
|
import com.diagbot.client.UserServiceClient;
|
|
-import com.diagbot.dto.QcCasesEntrySimpleDTO;
|
|
|
|
-import com.diagbot.dto.QcTypeDTO;
|
|
|
|
-import com.diagbot.dto.QcTypePageDTO;
|
|
|
|
-import com.diagbot.entity.CommonParam;
|
|
|
|
-import com.diagbot.entity.QcType;
|
|
|
|
-import com.diagbot.entity.QcTypeCasesEntry;
|
|
|
|
|
|
+import com.diagbot.dto.*;
|
|
|
|
+import com.diagbot.entity.*;
|
|
import com.diagbot.enums.InsertOrUpdateEnum;
|
|
import com.diagbot.enums.InsertOrUpdateEnum;
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
@@ -21,22 +17,17 @@ import com.diagbot.util.DateUtil;
|
|
import com.diagbot.util.EntityUtil;
|
|
import com.diagbot.util.EntityUtil;
|
|
import com.diagbot.util.ListUtil;
|
|
import com.diagbot.util.ListUtil;
|
|
import com.diagbot.util.UserUtils;
|
|
import com.diagbot.util.UserUtils;
|
|
-import com.diagbot.vo.DeleteQcTypeVO;
|
|
|
|
-import com.diagbot.vo.QcEntryHospitalVO;
|
|
|
|
-import com.diagbot.vo.QcTypeCasesEntryVO;
|
|
|
|
-import com.diagbot.vo.QcTypeIndexVO;
|
|
|
|
-import com.diagbot.vo.QcTypePageVO;
|
|
|
|
-import com.diagbot.vo.QcTypeSaveVO;
|
|
|
|
-import com.diagbot.vo.QcTypeVO;
|
|
|
|
|
|
+import com.diagbot.vo.*;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description:
|
|
* @Description:
|
|
@@ -56,18 +47,127 @@ public class QcTypeFacade extends QcTypeServiceImpl {
|
|
QcCacesEntryFacade qcCacesEntryFacade;
|
|
QcCacesEntryFacade qcCacesEntryFacade;
|
|
@Autowired
|
|
@Autowired
|
|
QcTypeCasesEntryFacade qcTypeCasesEntryFacade;
|
|
QcTypeCasesEntryFacade qcTypeCasesEntryFacade;
|
|
|
|
+ @Autowired
|
|
|
|
+ CasesEntryHospitalFacade casesEntryHospitalFacade;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 关联质控条目检索
|
|
|
|
+ *
|
|
|
|
+ * @param qcTypeVO
|
|
|
|
+ */
|
|
|
|
+ public RespDTO<List<QcType>> indexData(QcTypeVO qcTypeVO) {
|
|
|
|
+ List<QcType> list = new ArrayList<>();
|
|
|
|
+ Set<Long> parTypeIdSet = new HashSet<>();
|
|
|
|
+ List<QcType> parTypelist = this.list(new QueryWrapper<QcType>()
|
|
|
|
+ .eq("hospital_id", qcTypeVO.getHospitalId())
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .isNotNull("parent_type_id")
|
|
|
|
+ .orderByAsc("name"));
|
|
|
|
+
|
|
|
|
+ if(ListUtil.isNotEmpty(parTypelist)){
|
|
|
|
+ parTypelist.forEach(qcType -> {
|
|
|
|
+ parTypeIdSet.add(qcType.getParentTypeId());
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ QueryWrapper<QcType> qcTypeQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ qcTypeQueryWrapper.eq("hospital_id", qcTypeVO.getHospitalId());
|
|
|
|
+ qcTypeQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
|
+ if(!CollectionUtils.isEmpty(parTypeIdSet)){
|
|
|
|
+ qcTypeQueryWrapper.notIn("id",parTypeIdSet);
|
|
|
|
+ }
|
|
|
|
+ qcTypeQueryWrapper.isNull("parent_type_id");
|
|
|
|
+ //修改 非此判断为新增
|
|
|
|
+ if(null != qcTypeVO.getId()) {
|
|
|
|
+ qcTypeQueryWrapper.ne("id", qcTypeVO.getId());
|
|
|
|
+ }
|
|
|
|
+ qcTypeQueryWrapper.orderByAsc("name");
|
|
|
|
+ list = this.list(qcTypeQueryWrapper);
|
|
|
|
+ return RespDTO.onSuc(list);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 判断质控类型是否关联
|
|
|
|
+ *
|
|
|
|
+ * @param cancelTypeVO
|
|
|
|
+ */
|
|
|
|
+ public RespDTO getOrCancel(CancelTypeVO cancelTypeVO) {
|
|
|
|
+ //修改和删除都会触发操作
|
|
|
|
+ //子类判断关联关系
|
|
|
|
+ QcType qcType = this.getOne(new QueryWrapper<QcType>()
|
|
|
|
+ .eq("hospital_id", cancelTypeVO.getHospitalId())
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("id", cancelTypeVO.getId()));
|
|
|
|
+ //父类判断关联关系
|
|
|
|
+ List<QcType> parentList= this.list(new QueryWrapper<QcType>()
|
|
|
|
+ .eq("hospital_id", cancelTypeVO.getHospitalId())
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("parent_type_id", cancelTypeVO.getId()));
|
|
|
|
+ if (cancelTypeVO.getId() != null&& null == cancelTypeVO.getCancel()) {
|
|
|
|
+ //子类存在关联 一对一给出提示
|
|
|
|
+ if (null != qcType.getParentTypeId()) {
|
|
|
|
+ QcType qcTypeMain= this.getOne(new QueryWrapper<QcType>()
|
|
|
|
+ .eq("hospital_id", cancelTypeVO.getHospitalId())
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("id", qcType.getParentTypeId()));
|
|
|
|
+ RespDTO respDTO = new RespDTO();
|
|
|
|
+ respDTO.code = "00000005";
|
|
|
|
+ respDTO.msg = "该质控类型已被" + "\"" + qcTypeMain.getName() + "\"" + "类型绑定,需先将其解绑";
|
|
|
|
+ return respDTO;
|
|
|
|
+ //父类存在关联 一对多给出提示
|
|
|
|
+ }else if(ListUtil.isNotEmpty(parentList)&&1==cancelTypeVO.getOper()){
|
|
|
|
+ RespDTO respDTO = new RespDTO();
|
|
|
|
+ respDTO.code = "00000005";
|
|
|
|
+ respDTO.msg = "该质控类型存在绑定的子类型,需先将其解绑";
|
|
|
|
+ return respDTO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ //删除关联状态
|
|
|
|
+ if(cancelTypeVO.getCancel() != null && 1 == cancelTypeVO.getCancel()){
|
|
|
|
+ //子类存在关联 一对一删除
|
|
|
|
+ if (null != qcType.getParentTypeId()) {
|
|
|
|
+ this.update(new UpdateWrapper<QcType>()
|
|
|
|
+ .eq("hospital_id", cancelTypeVO.getHospitalId())
|
|
|
|
+ .eq("id", cancelTypeVO.getId())
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .set("parent_type_id", null)
|
|
|
|
+ );
|
|
|
|
+ //父类存在关联 一对多删除
|
|
|
|
+ }else if(ListUtil.isNotEmpty(parentList)){
|
|
|
|
+ this.update(new UpdateWrapper<QcType>()
|
|
|
|
+ .eq("hospital_id", cancelTypeVO.getHospitalId())
|
|
|
|
+ .eq("parent_type_id", cancelTypeVO.getId())
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .set("parent_type_id", null)
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ RespDTO respDTO = new RespDTO();
|
|
|
|
+ respDTO.code = "0";
|
|
|
|
+ respDTO.msg = "解绑成功";
|
|
|
|
+ return respDTO;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return new RespDTO();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 保存
|
|
* 保存
|
|
*
|
|
*
|
|
* @param qcTypeSaveVO
|
|
* @param qcTypeSaveVO
|
|
*/
|
|
*/
|
|
- public void saveOrUpdate(QcTypeSaveVO qcTypeSaveVO) {
|
|
|
|
- CommonParam param = initCommonParam();
|
|
|
|
- // 保存主表
|
|
|
|
- saveQcType(qcTypeSaveVO, param);
|
|
|
|
- // 保存质控类型和质控条目映射关系
|
|
|
|
- saveQcTypeCasesEntry(qcTypeSaveVO, param);
|
|
|
|
|
|
+ public RespDTO saveOrUpdate(QcTypeSaveVO qcTypeSaveVO) {
|
|
|
|
+ //初始化参数
|
|
|
|
+ CommonParam param = initCommonParam();
|
|
|
|
+ // 保存主表
|
|
|
|
+ saveQcType(qcTypeSaveVO, param);
|
|
|
|
+ // 保存质控类型和质控条目映射关系
|
|
|
|
+ saveQcTypeCasesEntry(qcTypeSaveVO, param);
|
|
|
|
+ //质控类型进行关联
|
|
|
|
+ getTypeConnections(qcTypeSaveVO, param);
|
|
|
|
+ return RespDTO.onSuc("保存成功");
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -136,6 +236,7 @@ public class QcTypeFacade extends QcTypeServiceImpl {
|
|
param.setInsertOrUpdate(InsertOrUpdateEnum.Update.getKey());
|
|
param.setInsertOrUpdate(InsertOrUpdateEnum.Update.getKey());
|
|
}
|
|
}
|
|
BeanUtil.copyProperties(qcTypeSaveVO, qcType);
|
|
BeanUtil.copyProperties(qcTypeSaveVO, qcType);
|
|
|
|
+ //判断相同名称类型的质控id是否存在
|
|
List<QcType> qcTypeList = this.list(new QueryWrapper<QcType>()
|
|
List<QcType> qcTypeList = this.list(new QueryWrapper<QcType>()
|
|
.eq("name", qcTypeSaveVO.getName())
|
|
.eq("name", qcTypeSaveVO.getName())
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
@@ -177,6 +278,56 @@ public class QcTypeFacade extends QcTypeServiceImpl {
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 质控类型维护关联
|
|
|
|
+ * @param qcTypeSaveVO,param
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public void getTypeConnections(QcTypeSaveVO qcTypeSaveVO, CommonParam param) {
|
|
|
|
+ QcTypeVO qcTypeVO = new QcTypeVO();
|
|
|
|
+ BeanUtil.copyProperties(qcTypeSaveVO, qcTypeVO);
|
|
|
|
+ List<Long> connectionIds = qcTypeSaveVO.getTypeIdList();
|
|
|
|
+ List<QcTypeCasesEntryVO> list = qcTypeSaveVO.getQcTypeCasesEntryVOList();
|
|
|
|
+ //修改操作
|
|
|
|
+ if(null !=qcTypeSaveVO.getId()){
|
|
|
|
+ //删除父类id
|
|
|
|
+ this.update(new UpdateWrapper<QcType>()
|
|
|
|
+ .eq("hospital_id", qcTypeVO.getHospitalId())
|
|
|
|
+ .eq("parent_type_id",qcTypeVO.getId())
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .set("parent_type_id",null)
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ if(ListUtil.isNotEmpty(connectionIds)){
|
|
|
|
+ for (Long id : connectionIds) {
|
|
|
|
+ //删除绑定质控id所有case_entry_id
|
|
|
|
+ qcTypeCasesEntryFacade.remove(new QueryWrapper<QcTypeCasesEntry>()
|
|
|
|
+ .eq("type_id", id)
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ );
|
|
|
|
+ //该医院质控id下的质控条目case_entry_id与主关联的保持一致
|
|
|
|
+ list.forEach(qcTypeCasesEntryVO->{
|
|
|
|
+ QcTypeCasesEntry qcTypeCaseEntry = new QcTypeCasesEntry();
|
|
|
|
+ qcTypeCaseEntry.setCaseEntryId(qcTypeCasesEntryVO.getCaseEntryId());
|
|
|
|
+ qcTypeCaseEntry.setTypeId(id);
|
|
|
|
+ qcTypeCaseEntry.setGmtCreate(param.getNow());
|
|
|
|
+ qcTypeCaseEntry.setGmtModified(param.getNow());
|
|
|
|
+ qcTypeCaseEntry.setCreator(param.getPerson());
|
|
|
|
+ qcTypeCaseEntry.setModifier(param.getPerson());
|
|
|
|
+ qcTypeCasesEntryFacade.save(qcTypeCaseEntry);
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ //设置父质控id
|
|
|
|
+ this.update(new UpdateWrapper<QcType>()
|
|
|
|
+ .eq("hospital_id", qcTypeSaveVO.getHospitalId())
|
|
|
|
+ .eq("id", id)
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .set("parent_type_id",qcTypeVO.getId())
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 新增时质控条目分组信息
|
|
* 新增时质控条目分组信息
|
|
*
|
|
*
|
|
@@ -215,6 +366,17 @@ public class QcTypeFacade extends QcTypeServiceImpl {
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
"当前质控类型不存在或已删除【id=" + qcTypeVO.getId() + "】");
|
|
"当前质控类型不存在或已删除【id=" + qcTypeVO.getId() + "】");
|
|
}
|
|
}
|
|
|
|
+ List<QcType> qcTypeList = this.list(new QueryWrapper<QcType>()
|
|
|
|
+ .eq("parent_type_id", qcTypeVO.getId())
|
|
|
|
+ .eq("is_deleted", "N"));
|
|
|
|
+ List<QcTypeSimpDTO> qcTypeSimpDTOList = new ArrayList<>();
|
|
|
|
+ qcTypeList.forEach( qcTypeOne->{
|
|
|
|
+ QcTypeSimpDTO qcTypeSimpDTO = new QcTypeSimpDTO();
|
|
|
|
+ qcTypeSimpDTO.setId(qcTypeOne.getId());
|
|
|
|
+ qcTypeSimpDTO.setName(qcTypeOne.getName());
|
|
|
|
+ qcTypeSimpDTOList.add(qcTypeSimpDTO);
|
|
|
|
+ } );
|
|
|
|
+ qcTypeDTO.setQcTypeSimpDTOList(qcTypeSimpDTOList);
|
|
BeanUtil.copyProperties(qcType, qcTypeDTO);
|
|
BeanUtil.copyProperties(qcType, qcTypeDTO);
|
|
List<QcCasesEntrySimpleDTO> list = qcTypeCasesEntryFacade.getByTypeIdFac(qcTypeVO);
|
|
List<QcCasesEntrySimpleDTO> list = qcTypeCasesEntryFacade.getByTypeIdFac(qcTypeVO);
|
|
Map<String, List<QcCasesEntrySimpleDTO>> entryMap = EntityUtil.makeEntityListMap(list, "modeName");
|
|
Map<String, List<QcCasesEntrySimpleDTO>> entryMap = EntityUtil.makeEntityListMap(list, "modeName");
|
|
@@ -228,7 +390,7 @@ public class QcTypeFacade extends QcTypeServiceImpl {
|
|
* @param deleteQcTypeVO
|
|
* @param deleteQcTypeVO
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public Boolean deleteByIdsFac(DeleteQcTypeVO deleteQcTypeVO) {
|
|
|
|
|
|
+ public RespDTO deleteByIdsFac(DeleteQcTypeVO deleteQcTypeVO) {
|
|
Date now = DateUtil.now();
|
|
Date now = DateUtil.now();
|
|
String person = UserUtils.getCurrentPrincipleID();
|
|
String person = UserUtils.getCurrentPrincipleID();
|
|
// 更新主表
|
|
// 更新主表
|
|
@@ -246,7 +408,7 @@ public class QcTypeFacade extends QcTypeServiceImpl {
|
|
.in("type_id", deleteQcTypeVO.getIds())
|
|
.in("type_id", deleteQcTypeVO.getIds())
|
|
);
|
|
);
|
|
}
|
|
}
|
|
- return true;
|
|
|
|
|
|
+ return RespDTO.onSuc("删除成功");
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|