Explorar o código

调整一下代码

尚正平 %!s(int64=2) %!d(string=hai) anos
pai
achega
98e450e320

+ 29 - 60
src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

@@ -1563,36 +1563,24 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         BeanUtil.copyProperties(analyzeRunVO, analyzeVO);
         Long hospitalId = analyzeVO.getHospitalId();
         // 获取病历信息
-        BehospitalInfo behospitalInfo = this.getOne(new QueryWrapper<BehospitalInfo>()
-                .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .eq("hospital_id", analyzeRunVO.getHospitalId())
-                .eq("behospital_code", analyzeRunVO.getBehospitalCode()), false
-        );
-        if (null == behospitalInfo) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该病历不存在或已删除!");
-        }
+        BehospitalInfo behospitalInfo = this.getOne(new QueryWrapper<BehospitalInfo>().eq("is_deleted", IsDeleteEnum.N.getKey()).eq("hospital_id", analyzeRunVO.getHospitalId()).eq("behospital_code", analyzeRunVO.getBehospitalCode()), false);
+        if (null == behospitalInfo) throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该病历不存在或已删除!");
+        
         // 处理公共数据
         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());
-            }
+            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);
+        List<String> codeList = new ArrayList<>(); // 质控编码列表
+        Map<String, String> codeToInfoMap = new LinkedHashMap<>();  // code和info的映射map
+        setCodeData(outputInfo, codeList, codeToInfoMap);	// 对codeList 和 codeToInfoMap进行赋值
         AlgorithmDTO algorithmDTO = new AlgorithmDTO();
-        // 如果是1,说明已是终末质控,不再保存质控结果数据;如果是0,则保存质控结果数据
-        if ("0".equals(analyzeRunVO.getIsPlacefile())) {
+        if ("0".equals(analyzeRunVO.getIsPlacefile())) {	 // 如果是1,说明已是终末质控,不再保存质控结果数据;如果是0,则保存质控结果数据
             Map<String, Object> resMap = calScoreAndSave(outputInfo, codeList, codeToInfoMap, analyzeVO, queryVo.getBehospitalInfo().getIsPlacefile());
             algorithmDTO = (AlgorithmDTO) resMap.get("algorithmDTO");
         }else{
@@ -1602,17 +1590,13 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         }
 
         List<MsgDTO> msgDTOList = getMsg(analyzeVO);
-        if (ListUtil.isNotEmpty(msgDTOList)) {
-            // 从qc_question_info的cases_entry_ids获取
+        if (ListUtil.isNotEmpty(msgDTOList)) {  // 从qc_question_info的cases_entry_ids获取
             Map<String, Object> paramMap = new HashMap<>();
             paramMap.put("hospitalId",  analyzeRunVO.getHospitalId());
             paramMap.put("casesEntryIds", msgDTOList.stream().map(r -> r.getCasesEntryId()).collect(Collectors.toList()));
             Map<Long, List<QuestionEntryDTO>> quesEntryMap = qcQuestionFacade.getByCaseEntryIdsFac(paramMap);
             for (MsgDTO msgDTO : msgDTOList) {
-                if (quesEntryMap.get(msgDTO.getCasesEntryId()) != null) {
-                    msgDTO.setPageKeyList(quesEntryMap.get(msgDTO.getCasesEntryId())
-                            .stream().map(r -> r.getId()).collect(Collectors.toList()));
-                }
+                if (quesEntryMap.get(msgDTO.getCasesEntryId()) != null) msgDTO.setPageKeyList(quesEntryMap.get(msgDTO.getCasesEntryId()).stream().map(r -> r.getId()).collect(Collectors.toList()));
             }
         }
 
@@ -1621,42 +1605,27 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         BigDecimal res = new BigDecimal(120);
         BigDecimal resPr = new BigDecimal(100);
         String reNum = "0";
-        SysHospitalSet sysHospitalSet
-                = sysHospitalSetFacade.getOne(new QueryWrapper<SysHospitalSet>()
-                        .eq("is_deleted", IsDeleteEnum.N.getKey())
-                        .eq("hospital_id", analyzeRunVO.getHospitalId())
-                , false);
-        if (null != sysHospitalSet && sysHospitalSet.getValue().equals("1")) {
-            //百分制
+        SysHospitalSet sysHospitalSet = sysHospitalSetFacade.getOne(new QueryWrapper<SysHospitalSet>().eq("is_deleted", IsDeleteEnum.N.getKey()).eq("hospital_id", analyzeRunVO.getHospitalId()), false);
+        if (null != sysHospitalSet && sysHospitalSet.getValue().equals("1")) { //百分制
             reNum = "1";
         }
         QcResultApiDTO qcResultApiDTO = new QcResultApiDTO();
         if(StringUtils.isNotEmpty(algorithmDTO.getLevel()) && algorithmDTO.getScore()!=null && msgDTOList != null){
-            if("1".equals(reNum)) {
-                bigDecimal = resPr.subtract(algorithmDTO.getScore());
-            }else if("0".equals(reNum)){
-                bigDecimal = res.subtract(algorithmDTO.getScore().multiply(new BigDecimal(120))
-                        .divide(new BigDecimal(100), 1, RoundingMode.HALF_UP));
-            }
-
-        //缺陷总数
-        Long num = msgDTOList
-                .stream()
-                .filter(Objects::nonNull)
-                .count();
-            qcResultApiDTO.setScoreRes(algorithmDTO.getScore());
-            qcResultApiDTO.setLevel(algorithmDTO.getLevel());
-            qcResultApiDTO.setNum(num);
-            qcResultApiDTO.setNumScore(bigDecimal);
-            resMapData.put("result", qcResultApiDTO);
-            List<MsgApiDTO> msgApiDTOList = BeanUtil.listCopyTo(msgDTOList, MsgApiDTO.class);
-            if (analyzeRunVO.getNeedGroup() == 0) {
-                resMapData.put("details", msgApiDTOList);
-            } else {
-                Map<String, List<MsgApiDTO>> msgMap = EntityUtil.makeEntityListMap(msgApiDTOList, "modelName");
-                resMapData.put("details", msgMap);
-            }
-        };
+            if("1".equals(reNum)) bigDecimal = resPr.subtract(algorithmDTO.getScore());
+            else if("0".equals(reNum)) bigDecimal = res.subtract(algorithmDTO.getScore().multiply(new BigDecimal(120)).divide(new BigDecimal(100), 1, RoundingMode.HALF_UP));
+	        //缺陷总数
+	        Long num = msgDTOList.stream().filter(Objects::nonNull).count();
+	        qcResultApiDTO.setScoreRes(algorithmDTO.getScore());
+	        qcResultApiDTO.setLevel(algorithmDTO.getLevel());
+	        qcResultApiDTO.setNum(num);
+	        qcResultApiDTO.setNumScore(bigDecimal);
+	        resMapData.put("result", qcResultApiDTO);
+	        List<MsgApiDTO> msgApiDTOList = BeanUtil.listCopyTo(msgDTOList, MsgApiDTO.class);
+	        if (analyzeRunVO.getNeedGroup() == 0) resMapData.put("details", msgApiDTOList);
+	        else resMapData.put("details", EntityUtil.makeEntityListMap(msgApiDTOList, "modelName"));
+        }
+        
+        
         return resMapData;
     }
 

+ 23 - 22
src/main/java/com/diagbot/web/BehospitalInfoController.java

@@ -1,15 +1,25 @@
 package com.diagbot.web;
 
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.AnalyzeDTO;
 import com.diagbot.dto.AnalyzeRunDTO;
 import com.diagbot.dto.BehospitalInfoDTO;
-import com.diagbot.dto.OutputInfo;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.BehospitalInfoFacade;
 import com.diagbot.facade.QcresultInfoFacade;
-import com.diagbot.vo.AnalyzeApiVO;
 import com.diagbot.vo.AnalyzeCdsVO;
 import com.diagbot.vo.AnalyzeRunVO;
 import com.diagbot.vo.AnalyzeVO;
@@ -18,20 +28,11 @@ import com.diagbot.vo.ExportQcresultVO;
 import com.diagbot.vo.GetDetailVO;
 import com.diagbot.vo.QcresultVO;
 import com.diagbot.vo.TaskVO;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import springfox.documentation.annotations.ApiIgnore;
 
-import javax.servlet.http.HttpServletResponse;
-import javax.validation.Valid;
-import java.util.Map;
-
 /**
  * <p>
  * 住院病历信息 前端控制器
@@ -115,20 +116,20 @@ public class BehospitalInfoController {
         return RespDTO.onSuc(behospitalInfoFacade.analyze(analyzeVO));
     }
 
-
-    @ApiOperation(value = "评分-对外api接口[by:zhoutg]",
-            notes = "")
-    @PostMapping("/analyze_api")
-    @SysLogger("analyze_api")
     @Transactional
-    //    @ApiIgnore
+    @SysLogger("analyze_api")
+    @PostMapping("/analyze_api")
+    @ApiOperation(value = "评分-对外api接口[by:zhoutg]")
     public RespDTO<Map<String, Object> > analyzeApi(@RequestBody AnalyzeRunVO analyzeRunVO) {
-        return RespDTO.onSuc(behospitalInfoFacade.analyzeApi(analyzeRunVO));
+    	new Thread() {
+    		public void run() {
+    			behospitalInfoFacade.analyzeApi(analyzeRunVO);
+    		}
+    	}.start();
+        return RespDTO.onSuc(null);
     }
 
-
-    @ApiOperation(value = "新增质控条目[by:zhoutg]",
-            notes = "")
+    @ApiOperation(value = "新增质控条目[by:zhoutg]")
     @PostMapping("/addCase")
     @SysLogger("addCase")
     @Transactional