Эх сурвалжийг харах

获取量表详情异常处理

zsf 1 жил өмнө
parent
commit
f2bb090f1f

+ 25 - 19
src/main/java/com/rf/psychological/rest/ServerController.java

@@ -892,26 +892,32 @@ public class ServerController extends BaseController {
     @ApiOperation(value = "根据flag查询量表新版本详情")
     @GetMapping("subjectInfo/getSubjectByFlagV2/{flag}")
     public Result getSubjectByFlagV2(@PathVariable String flag) {
-        List<SubjectEntity> subjectEntityList = this.subjectService.getSubjectByFlag(flag);
-        List<SubjectEntityDto2> subjectEntityDto2List = new ArrayList<>();
-        if(subjectEntityList != null && subjectEntityList.size()>0){
-            subjectEntityList.forEach(subjectEntity -> {
-                SubjectEntityDto2 subjectEntityDto2 = new SubjectEntityDto2(subjectEntity);
-                PromotionInfo infoBySubjectId = this.promotionInfoService.findInfoBySubjectId(subjectEntity.getId());
-                subjectEntityDto2.setPrice(infoBySubjectId == null ? 0.0:infoBySubjectId.getPrice());
-                List<ScaleEntity> scaleEntityList = this.scaleService.getScaleByFlag(subjectEntity.getFlag());
-                subjectEntityDto2.setTitleNum(scaleEntityList.size());
-                int estimatedTime = scaleEntityList.size() / Constant.TEST_PLAN_STATUS_RUNNING + (scaleEntityList.size() % Constant.TEST_PLAN_STATUS_RUNNING != 0 ? 1 : 0);
-                subjectEntityDto2.setEstimatedTime(estimatedTime);
-                subjectEntityDto2List.add(subjectEntityDto2);
-            });
+        try {
+            List<SubjectEntity> subjectEntityList = this.subjectService.getSubjectByFlag(flag);
+            List<SubjectEntityDto2> subjectEntityDto2List = new ArrayList<>();
+            if(subjectEntityList != null && subjectEntityList.size()>0){
+                subjectEntityList.forEach(subjectEntity -> {
+                    SubjectEntityDto2 subjectEntityDto2 = new SubjectEntityDto2(subjectEntity);
+                    PromotionInfo infoBySubjectId = this.promotionInfoService.findInfoBySubjectId(subjectEntity.getId());
+                    subjectEntityDto2.setPrice(infoBySubjectId == null ? 0.0:infoBySubjectId.getPrice());
+                    List<ScaleEntity> scaleEntityList = this.scaleService.getScaleByFlag(subjectEntity.getFlag());
+                    subjectEntityDto2.setTitleNum(scaleEntityList.size());
+                    int estimatedTime = scaleEntityList.size() / Constant.TEST_PLAN_STATUS_RUNNING + (scaleEntityList.size() % Constant.TEST_PLAN_STATUS_RUNNING != 0 ? 1 : 0);
+                    subjectEntityDto2.setEstimatedTime(estimatedTime);
+                    subjectEntityDto2List.add(subjectEntityDto2);
+                });
+            }
+            ScaleDetailsEntity scaleDetailsEntity = this.scaleDetailsService.getSubjectDetailsByFlag(flag);
+            scaleDetailsEntity.setTestNum(subjectEntityList.get(0).getTestNum());
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("subjectEntityDto2List", subjectEntityDto2List);
+            jsonObject.put("ScaleDetailsEntity", scaleDetailsEntity);
+            return success(jsonObject);
+        }catch (Exception e){
+            log.error(e.getMessage());
+            return fail("操作失败");
         }
-        ScaleDetailsEntity scaleDetailsEntity = this.scaleDetailsService.getSubjectDetailsByFlag(flag);
-        scaleDetailsEntity.setTestNum(subjectEntityList.get(0).getTestNum());
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("subjectEntityDto2List", subjectEntityDto2List);
-        jsonObject.put("ScaleDetailsEntity", scaleDetailsEntity);
-        return success(jsonObject);
+
     }
 
     /**