Pārlūkot izejas kodu

运行对外接口调整

chengyao 4 gadi atpakaļ
vecāks
revīzija
6ba7694fa2

+ 82 - 35
src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

@@ -1566,20 +1566,37 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
     /**
      * 评分api
      *
-     * @param analyzeApiVO
+     * @param analyzeRunVO
      * @return
      */
-    public Map<String, Object> analyzeApi(AnalyzeApiVO analyzeApiVO) {
-        AnalyzeVO analyzeVO = new AnalyzeVO();
-        BeanUtil.copyProperties(analyzeApiVO, analyzeVO);
-        // 评分
-        analyze(analyzeVO);
-        // 获取结果
-        GetDetailVO getDetailVO = new GetDetailVO();
-        getDetailVO.setHospitalId(analyzeApiVO.getHospitalId());
-        getDetailVO.setBehospitalCode(analyzeApiVO.getBehospitalCode());
-        getDetailVO.setNeedGroup(analyzeApiVO.getNeedGroup());
-        return getByBehospitalCodeApi(getDetailVO);
+    public AnalyzeRunDTO analyzeApi(AnalyzeRunVO analyzeRunVO) {
+        List<MsgDTO> msgDTOList = this.getMsgByBehospitalCode(analyzeRunVO);
+        //返回参数组装
+        AnalyzeRunDTO analyzeRunDTO = new AnalyzeRunDTO();
+        //缺陷总扣分
+        BigDecimal numScore = msgDTOList
+                .stream()
+                .map(MsgDTO::getScore)
+                .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+        //缺陷总数
+        Long num = msgDTOList
+                .stream()
+                .filter(Objects::nonNull)
+                .count();
+        analyzeRunDTO.setNum(num);
+        analyzeRunDTO.setNumScore(numScore);
+        QcresultInfo qcresultInfo = qcresultInfoFacade.getOne(new QueryWrapper<QcresultInfo>()
+                .eq("behospital_code", analyzeRunVO.getBehospitalCode())
+                .eq("hospital_id", analyzeRunVO.getHospitalId())
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .select("behospital_code", "level", "score_res"));
+        BigDecimal bigDecimal = new BigDecimal(0);
+        if(null != qcresultInfo){
+            analyzeRunDTO.setLevel(qcresultInfo.getLevel()==null?"":qcresultInfo.getLevel());
+            analyzeRunDTO.setScoreRes(qcresultInfo.getScoreRes() ==null ? bigDecimal : qcresultInfo.getScoreRes());
+        }
+        analyzeRunDTO.setMsgDTOList(msgDTOList);
+        return analyzeRunDTO;
     }
 
 
@@ -1668,31 +1685,61 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
      * @return
      */
     public AnalyzeRunDTO analyzeRun(AnalyzeRunVO analyzeRunVO) {
-        List<MsgDTO> msgDTOList = this.getMsgByBehospitalCode(analyzeRunVO);
+        AnalyzeVO analyzeVO = new AnalyzeVO();
+        BeanUtil.copyProperties(analyzeRunVO, analyzeVO);
+        Long hospitalId = analyzeVO.getHospitalId();
+
+        // 处理公共数据
+            QueryVo queryVo = dealCommonData(hospitalId, analyzeVO);
+        //  调用质控接口
+        Response<OutputInfo> response = qcServiceClient.extract(queryVo);
+        if (response == null || response.getData() == null) {
+            if (null == response) {
+                throw new CommonException(CommonErrorCode.RPC_ERROR, "远程质控接口没有返回数据!【" + analyzeVO.getBehospitalCode() + "】");
+            } else {
+                throw new CommonException(CommonErrorCode.RPC_ERROR,
+                        "远程质控接口没有返回数据!【" + analyzeVO.getBehospitalCode() + "】错误原因:" + response.getMsg());
+            }
+        }
+        OutputInfo outputInfo = response.getData();
+        // 质控编码列表
+        List<String> codeList = new ArrayList<>();
+        // code和info的映射map
+        Map<String, String> codeToInfoMap = new LinkedHashMap<>();
+        // 对codeList 和 codeToInfoMap进行赋值
+        setCodeData(outputInfo, codeList, codeToInfoMap);
+
+        // 如果是1,说明已是终末质控,不再保存质控结果数据;如果是0,则保存质控结果数据
+        if ("0".equals(analyzeRunVO.getIsPlacefile())) {
+            // 计算分值并保存结果至数据库
+            Map<String, Object> resMap = calScoreAndSave(outputInfo, codeList, codeToInfoMap, analyzeVO, queryVo.getBehospitalInfo().getIsPlacefile());
+        }
+
+        // 返回缺陷提示信息
+        List<MsgDTO> msgDTOList = new ArrayList<>();
+        if (ListUtil.isNotEmpty(codeList)) {
+            AnalyzeCodeVO analyzeCodeVO = new AnalyzeCodeVO();
+            analyzeCodeVO.setCodeList(codeList);
+            analyzeCodeVO.setHospitalId(hospitalId);
+            analyzeCodeVO.setModeId(analyzeRunVO.getModeId());
+
+            // 获取缺陷条目信息
+            msgDTOList = getMsgByEntryCode(analyzeCodeVO);
+            // 设置info信息
+            if (codeToInfoMap != null && !codeToInfoMap.isEmpty()) {
+                for (MsgDTO msgDTO : msgDTOList) {
+                    String info = codeToInfoMap.get(msgDTO.getCode());
+                    if (StringUtil.isNotBlank(info)) {
+                        msgDTO.setInfo(info);
+                    }
+                }
+            }
+        }
+
         //返回参数组装
         AnalyzeRunDTO analyzeRunDTO = new AnalyzeRunDTO();
-        //缺陷总扣分
-        BigDecimal numScore = msgDTOList
-                .stream()
-                .map(MsgDTO::getScore)
-                .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
-        //缺陷总数
-        Long num = msgDTOList
-                .stream()
-                .filter(Objects::nonNull)
-                .count();
-        analyzeRunDTO.setNum(num);
-        analyzeRunDTO.setNumScore(numScore);
-        QcresultInfo qcresultInfo = qcresultInfoFacade.getOne(new QueryWrapper<QcresultInfo>()
-                .eq("behospital_code", analyzeRunVO.getBehospitalCode())
-                .eq("hospital_id", analyzeRunVO.getHospitalId())
-                .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .select("behospital_code", "level", "score_res"));
-        BigDecimal bigDecimal = new BigDecimal(0);
-        if(null != qcresultInfo){
-            analyzeRunDTO.setLevel(qcresultInfo.getLevel()==null?"":qcresultInfo.getLevel());
-            analyzeRunDTO.setScoreRes(qcresultInfo.getScoreRes() ==null ? bigDecimal : qcresultInfo.getScoreRes());
-        }
+        // analyzeRunDTO.setScoreRes(algorithmDTO.getScore());
+        // analyzeRunDTO.setLevel(algorithmDTO.getLevel());
         analyzeRunDTO.setMsgDTOList(msgDTOList);
         return analyzeRunDTO;
     }

+ 2 - 2
src/main/java/com/diagbot/web/BehospitalInfoController.java

@@ -122,8 +122,8 @@ public class BehospitalInfoController {
     @SysLogger("analyze_api")
     @Transactional
     //    @ApiIgnore
-    public RespDTO<Map<String, Object>> analyzeApi(@RequestBody AnalyzeApiVO analyzeApiVO) {
-        return RespDTO.onSuc(behospitalInfoFacade.analyzeApi(analyzeApiVO));
+    public RespDTO<AnalyzeRunDTO> analyzeApi(@RequestBody AnalyzeRunVO analyzeRunVO) {
+        return RespDTO.onSuc(behospitalInfoFacade.analyzeApi(analyzeRunVO));
     }