Explorar o código

Merge branch 'mrman20201130_5.4.1' into develop

chengyao %!s(int64=4) %!d(string=hai) anos
pai
achega
9bcae005ff

+ 9 - 2
common/src/main/java/com/diagbot/dto/RespDTO.java

@@ -20,6 +20,13 @@ public class RespDTO<T> implements Serializable {
         return resp;
     }
 
+    public static RespDTO onSucBoth(String code,String msg,Object data) {
+        RespDTO resp = new RespDTO();
+        resp.code = code;
+        resp.msg = msg;
+        resp.data = data;
+        return resp;
+    }
     public static RespDTO onError(String errMsg) {
         RespDTO resp = new RespDTO();
         resp.code = "-1";
@@ -30,8 +37,8 @@ public class RespDTO<T> implements Serializable {
     @Override
     public String toString() {
         return "RespDTO{" +
-                "code=" + code +
-                ", error='" + msg + '\'' +
+                "code='" + code + '\'' +
+                ", msg='" + msg + '\'' +
                 ", data=" + data +
                 '}';
     }

+ 4 - 0
common/src/main/java/com/diagbot/exception/CommonErrorCode.java

@@ -12,6 +12,9 @@ public enum CommonErrorCode implements ErrorCode {
     OK("0", "操作成功"),
     FAIL("00000001", "操作失败"),
     RPC_ERROR("00000002", "远程调度失败"),
+    CHECK_CONNECTION("00000005","是否解除绑定"),
+    SAVE_SUCCESSFUL("00000007","添加成功"),
+    ALTER_SUCCESSFUL("00000009","修改成功"),
     PARAM_ERROR("00029999", "%s"), //参数错误
     NOT_EXISTS("00020001", "该数据不存在!"),
     INSERT_DATA_FAILED("00020002", "数据库写入失败!"),
@@ -34,6 +37,7 @@ public enum CommonErrorCode implements ErrorCode {
     NOTVALID_ERROR("20020007", "该产品未在有效服务期内,无法使用"),
     EXPIRE_ERROR("20020008", "该产品已超出有效服务期,无法使用");
 
+
     private String code;
     private String msg;
 

+ 3 - 0
mrman-service/src/main/java/com/diagbot/dto/QcTypeDTO.java

@@ -3,6 +3,7 @@ package com.diagbot.dto;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -22,4 +23,6 @@ public class QcTypeDTO {
     private String name;
     // 质控类型和质控条目对应关系
     private Map<String, List<QcCasesEntrySimpleDTO>> entryMap;
+    // 已选择质控类型列表
+    private List<QcTypeSimpDTO> qcTypeSimpDTOList = new ArrayList<>();
 }

+ 5 - 0
mrman-service/src/main/java/com/diagbot/entity/QcType.java

@@ -31,6 +31,11 @@ public class QcType implements Serializable {
      */
     private Long hospitalId;
 
+    /**
+     * 质控父id
+     */
+    private Long parentTypeId;
+
     /**
      * 质控类型名称
      */

+ 187 - 25
mrman-service/src/main/java/com/diagbot/facade/QcTypeFacade.java

@@ -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.metadata.IPage;
 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.IsDeleteEnum;
 import com.diagbot.exception.CommonErrorCode;
@@ -21,22 +17,17 @@ import com.diagbot.util.DateUtil;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
 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.Qualifier;
 import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
 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:
@@ -56,18 +47,127 @@ public class QcTypeFacade extends QcTypeServiceImpl {
     QcCacesEntryFacade qcCacesEntryFacade;
     @Autowired
     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
      */
-    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());
         }
         BeanUtil.copyProperties(qcTypeSaveVO, qcType);
+        //判断相同名称类型的质控id是否存在
         List<QcType> qcTypeList = this.list(new QueryWrapper<QcType>()
                 .eq("name", qcTypeSaveVO.getName())
                 .eq("is_deleted", IsDeleteEnum.N.getKey())
@@ -177,6 +278,56 @@ public class QcTypeFacade extends QcTypeServiceImpl {
         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,
                     "当前质控类型不存在或已删除【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);
         List<QcCasesEntrySimpleDTO> list = qcTypeCasesEntryFacade.getByTypeIdFac(qcTypeVO);
         Map<String, List<QcCasesEntrySimpleDTO>> entryMap = EntityUtil.makeEntityListMap(list, "modeName");
@@ -228,7 +390,7 @@ public class QcTypeFacade extends QcTypeServiceImpl {
      * @param deleteQcTypeVO
      * @return
      */
-    public Boolean deleteByIdsFac(DeleteQcTypeVO deleteQcTypeVO) {
+    public RespDTO deleteByIdsFac(DeleteQcTypeVO deleteQcTypeVO) {
         Date now = DateUtil.now();
         String person = UserUtils.getCurrentPrincipleID();
         // 更新主表
@@ -246,7 +408,7 @@ public class QcTypeFacade extends QcTypeServiceImpl {
                     .in("type_id", deleteQcTypeVO.getIds())
             );
         }
-        return true;
+        return  RespDTO.onSuc("删除成功");
     }
 
 }

+ 20 - 0
mrman-service/src/main/java/com/diagbot/vo/CancelTypeVO.java

@@ -0,0 +1,20 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: zhoutg
+ * @time: 2018/8/6 10:16
+ */
+@Getter
+@Setter
+public class CancelTypeVO {
+    private Long id;
+    private Long hospitalId;
+    //是否解除相关质控类型绑定(0-不解除 1-解除)
+    private Integer cancel = 0;
+    //操作标示(0-修改 1-删除)
+    private Integer oper = 1;
+}

+ 2 - 0
mrman-service/src/main/java/com/diagbot/vo/QcTypeSaveVO.java

@@ -21,4 +21,6 @@ public class QcTypeSaveVO {
     private String name;
     // 质控类型和质控条目关联信息
     private List<QcTypeCasesEntryVO> qcTypeCasesEntryVOList = new ArrayList<>();
+    // 需要关联的质控类型id列表
+    private List<Long> typeIdList;
 }

+ 25 - 6
mrman-service/src/main/java/com/diagbot/web/QcTypeController.java

@@ -7,6 +7,7 @@ import com.diagbot.dto.QcTypeDTO;
 import com.diagbot.dto.QcTypePageDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.QcQuestionInfo;
+import com.diagbot.entity.QcType;
 import com.diagbot.facade.QcTypeFacade;
 import com.diagbot.vo.*;
 import io.swagger.annotations.Api;
@@ -44,11 +45,30 @@ public class QcTypeController {
     @PostMapping("/saveOrUpdate")
     @SysLogger("saveOrUpdate")
     @Transactional
-    public RespDTO<Boolean> saveOrUpdate(@RequestBody QcTypeSaveVO qcTypeSaveVO) {
-        qcTypeFacade.saveOrUpdate(qcTypeSaveVO);
-        return RespDTO.onSuc(true);
+    public RespDTO saveOrUpdate(@RequestBody QcTypeSaveVO qcTypeSaveVO) {
+        return qcTypeFacade.saveOrUpdate(qcTypeSaveVO);
     }
 
+    @ApiOperation(value = "关联质控条目检索[by:cy]",
+            notes =  "id: 质控类型<br>" +
+                     "hospitalId: 医院id;")
+    @PostMapping("/indexData")
+    @SysLogger("indexData")
+    public RespDTO<List<QcType>> indexData(@RequestBody QcTypeVO qcTypeVO) {
+
+        return  qcTypeFacade.indexData(qcTypeVO);}
+
+    @ApiOperation(value = "判断质控类型是否关联[by:cy]",
+            notes = "id: 质控类型<br>" +
+                    "hospitalId: 医院id<br>" +
+                    "cancel: 是否解绑;")
+    @PostMapping("/getOrCancel")
+    @SysLogger("getOrCancel")
+    @Transactional
+    public RespDTO getOrCancel(@RequestBody CancelTypeVO cancelTypeVO) {
+
+        return qcTypeFacade.getOrCancel(cancelTypeVO);
+    }
 
     @ApiOperation(value = "分页列表[by:zhoutg]",
             notes = "    // 名称\n" +
@@ -90,9 +110,8 @@ public class QcTypeController {
     @PostMapping("/delete")
     @SysLogger("delete")
     @Transactional
-    public RespDTO<Boolean> delete(@Valid @RequestBody DeleteQcTypeVO deleteQcTypeVO) {
-        qcTypeFacade.deleteByIdsFac(deleteQcTypeVO);
-        return RespDTO.onSuc(true);
+    public RespDTO delete(@Valid @RequestBody DeleteQcTypeVO deleteQcTypeVO) {
+        return  qcTypeFacade.deleteByIdsFac(deleteQcTypeVO);
     }
 
     @ApiOperation(value = "根据id返回内容[by:zhoutg]",