|
@@ -56,13 +56,40 @@ public class QcTypeFacade extends QcTypeServiceImpl {
|
|
|
* @param qcTypeVO
|
|
|
*/
|
|
|
public RespDTO<List<QcType>> indexData(QcTypeVO qcTypeVO) {
|
|
|
- List<QcType> list = this.list(new QueryWrapper<QcType>()
|
|
|
- .eq("hospital_id", qcTypeVO.getHospitalId())
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .ne("id",qcTypeVO.getId())
|
|
|
- .isNull("parent_type_id")
|
|
|
- .orderByAsc("name")
|
|
|
- );
|
|
|
+ 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());
|
|
|
+ });
|
|
|
+ //修改
|
|
|
+ if(null != qcTypeVO.getId()){
|
|
|
+ list = this.list(new QueryWrapper<QcType>()
|
|
|
+ .eq("hospital_id", qcTypeVO.getHospitalId())
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .notIn("id",parTypeIdSet)
|
|
|
+ .ne("id",qcTypeVO.getId())
|
|
|
+ .isNull("parent_type_id")
|
|
|
+ .orderByAsc("name"));
|
|
|
+ }else{
|
|
|
+ //新增操作
|
|
|
+ //未质控的质控id包含了父类
|
|
|
+
|
|
|
+ list = this.list(new QueryWrapper<QcType>()
|
|
|
+ .eq("hospital_id", qcTypeVO.getHospitalId())
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .notIn("id",parTypeIdSet)
|
|
|
+ .isNull("parent_type_id")
|
|
|
+ .orderByAsc("name"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return RespDTO.onSuc(list);
|
|
|
}
|
|
|
/**
|
|
@@ -71,14 +98,21 @@ public class QcTypeFacade extends QcTypeServiceImpl {
|
|
|
* @param cancelTypeVO
|
|
|
*/
|
|
|
public RespDTO getOrCancel(CancelTypeVO cancelTypeVO) {
|
|
|
+ QcType qcType = new QcType();
|
|
|
+ List<QcType> parentList = new ArrayList<>();
|
|
|
//修改和删除都会触发操作
|
|
|
if (cancelTypeVO.getId() != null&& null == cancelTypeVO.getCancel()) {
|
|
|
- //判断关联关系
|
|
|
- QcType qcType = this.getOne(new QueryWrapper<QcType>()
|
|
|
+ //子类判断关联关系
|
|
|
+ qcType = this.getOne(new QueryWrapper<QcType>()
|
|
|
.eq("hospital_id", cancelTypeVO.getHospitalId())
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
.eq("id", cancelTypeVO.getId()));
|
|
|
- //存在关联 给出提示
|
|
|
+ //父类判断关联关系
|
|
|
+ parentList = this.list(new QueryWrapper<QcType>()
|
|
|
+ .eq("hospital_id", cancelTypeVO.getHospitalId())
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("parent_type_id", cancelTypeVO.getId()));
|
|
|
+ //子类存在关联 一对一给出提示
|
|
|
if (null != qcType.getParentTypeId()) {
|
|
|
QcType qcTypeMain= this.getOne(new QueryWrapper<QcType>()
|
|
|
.eq("hospital_id", cancelTypeVO.getHospitalId())
|
|
@@ -88,23 +122,41 @@ public class QcTypeFacade extends QcTypeServiceImpl {
|
|
|
respDTO.code = "00000005";
|
|
|
respDTO.msg = "该类型已被" + "\"" + qcTypeMain.getName() + "\"" + "类型绑定,确定需要解绑?";
|
|
|
return respDTO;
|
|
|
+ //父类存在关联 一对多给出提示
|
|
|
+ }else if(ListUtil.isNotEmpty(parentList)){
|
|
|
+ RespDTO respDTO = new RespDTO();
|
|
|
+ respDTO.code = "00000006";
|
|
|
+ respDTO.msg = "该质控类型已被关联,删除将解绑其关联类型,是否删除?";
|
|
|
+ return respDTO;
|
|
|
}
|
|
|
+ //如果父类关联子类,同样提示
|
|
|
}
|
|
|
//删除关联状态
|
|
|
- if (cancelTypeVO.getId() != null && 1 == cancelTypeVO.getCancel()) {
|
|
|
- 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)
|
|
|
- );
|
|
|
+ if(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 = "00000005";
|
|
|
respDTO.msg = "解绑成功";
|
|
|
return respDTO;
|
|
|
- }else{
|
|
|
- return new RespDTO();
|
|
|
+
|
|
|
}
|
|
|
+ return new RespDTO();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -114,8 +166,6 @@ public class QcTypeFacade extends QcTypeServiceImpl {
|
|
|
* @param qcTypeSaveVO
|
|
|
*/
|
|
|
public RespDTO saveOrUpdate(QcTypeSaveVO qcTypeSaveVO) {
|
|
|
-
|
|
|
- try {
|
|
|
//初始化参数
|
|
|
CommonParam param = initCommonParam();
|
|
|
// 保存主表
|
|
@@ -124,9 +174,6 @@ public class QcTypeFacade extends QcTypeServiceImpl {
|
|
|
saveQcTypeCasesEntry(qcTypeSaveVO, param);
|
|
|
//质控类型进行关联
|
|
|
getTypeConnections(qcTypeSaveVO, param);
|
|
|
- } catch (Exception e) {
|
|
|
- return RespDTO.onError("保存失败");
|
|
|
- }
|
|
|
return RespDTO.onSuc("保存成功");
|
|
|
|
|
|
}
|