Преглед изворни кода

修改测试人员任务统计接口

linyk пре 2 година
родитељ
комит
909c9ec8b1

+ 25 - 5
site/src/main/java/com/mooctest/crowd/site/controller/TesterController.java

@@ -1,13 +1,16 @@
 package com.mooctest.crowd.site.controller;
 
 import com.mooctest.crowd.domain.domainobject.Defect;
+import com.mooctest.crowd.domain.domainobject.TestCase;
 import com.mooctest.crowd.domain.domainobject.User;
 import com.mooctest.crowd.domain.env.Seriousness;
+import com.mooctest.crowd.domain.env.TestCaseExamStatus;
 import com.mooctest.crowd.domain.util.Converter;
 import com.mooctest.crowd.site.data.response.ResponseVO;
 import com.mooctest.crowd.site.data.response.ServerCode;
 import com.mooctest.crowd.site.data.vo.TesterTaskVO;
 import com.mooctest.crowd.site.service.DefectService;
+import com.mooctest.crowd.site.service.TestCaseService;
 import com.mooctest.crowd.site.service.UserService;
 import com.mooctest.crowd.site.util.RequestUtils;
 import io.swagger.annotations.Api;
@@ -29,10 +32,29 @@ public class TesterController {
     private DefectService defectService;
     @Autowired
     private UserService userService;
+    @Autowired
+    private TestCaseService testCaseService;
 
     @GetMapping(value = "/task/{userId}/{taskCode}")
     public ResponseVO<TesterTaskVO> getTesterTaskInfo(HttpServletRequest request,  @PathVariable("userId") Long userId, @PathVariable("taskCode") String taskCode){
+        List<TestCase> testCases = testCaseService.find(userId, RequestUtils.getUserId(request), taskCode, 0, 1000, null).getDatas();
         List<Defect> defects = defectService.findUserDefects(userId, RequestUtils.getUserId(request), taskCode, 0, 1000).getDatas();
+        TesterTaskVO.TestCaseCountInfoVO testCaseCountInfoVO = new TesterTaskVO.TestCaseCountInfoVO();
+        testCases.forEach(testCase -> {
+            testCaseCountInfoVO.setTestCaseCount(testCaseCountInfoVO.getTestCaseCount() + 1);
+            switch(testCase.getExamStatus()) {
+                case VALID:
+                    testCaseCountInfoVO.setValidTestCaseCount(testCaseCountInfoVO.getValidTestCaseCount() + 1);
+                    break;
+                case INVALID:
+                    testCaseCountInfoVO.setInvalidTestCaseCount(testCaseCountInfoVO.getInvalidTestCaseCount() + 1);
+                    break;
+                case WAIT:
+                    testCaseCountInfoVO.setNoExamedTestCaseCount(testCaseCountInfoVO.getNoExamedTestCaseCount() + 1);
+                    break;
+            }
+
+        });
         List<TesterTaskVO.DefectInfoVO> defectInfoVOs = new ArrayList();
         Map<String, Integer> defectSeriCountMap = new LinkedHashMap() {{
             put(Seriousness.VERY_HIGH.getName(), 0);
@@ -49,18 +71,16 @@ public class TesterController {
             defectInfoVO.setCommitTime(DateUtils.formatDate(new Date(defect.getCommitTime().getTime()), "yy-MM-dd HH:mm"));
             defectInfoVOs.add(defectInfoVO);
             defectSeriCountMap.put(seriName, defectSeriCountMap.get(seriName) + 1);
+            testCaseCountInfoVO.setDefectCount(testCaseCountInfoVO.getDefectCount() + 1);
         });
-        List<Integer> defectSeriCounts = new ArrayList();
-        for(String key: defectSeriCountMap.keySet()) {
-            defectSeriCounts.add(defectSeriCountMap.get(key));
-        }
         User user = userService.getById(userId);
         TesterTaskVO.TesterInfoVO testerInfo = Converter.convert(TesterTaskVO.TesterInfoVO.class, user);
         testerInfo.setCreateTime(DateUtils.formatDate(new Date(user.getCreateTime().getTime()), "yyyy-MM-dd HH:mm"));
         TesterTaskVO testerTaskVO = new TesterTaskVO();
         testerTaskVO.setTester(testerInfo);
         testerTaskVO.setDefects(defectInfoVOs);
-        testerTaskVO.setDefectSeriCounts(defectSeriCounts);
+        testerTaskVO.setDefectSeriCounts(defectSeriCountMap);
+        testerTaskVO.setTestCaseCountInfo(testCaseCountInfoVO);
         return new ResponseVO<>(ServerCode.SUCCESS, testerTaskVO);
     }
 

+ 12 - 1
site/src/main/java/com/mooctest/crowd/site/data/vo/TesterTaskVO.java

@@ -3,12 +3,14 @@ package com.mooctest.crowd.site.data.vo;
 import lombok.Data;
 
 import java.util.List;
+import java.util.Map;
 
 @Data
 public class TesterTaskVO {
     private TesterInfoVO tester;
     private List<DefectInfoVO> defects;
-    private List<Integer> defectSeriCounts;
+    private Map<String, Integer> defectSeriCounts;
+    private TestCaseCountInfoVO testCaseCountInfo;
 
     @Data
     public static class TesterInfoVO {
@@ -30,4 +32,13 @@ public class TesterTaskVO {
         private String descr;
         private String commitTime;
     }
+
+    @Data
+    public static class TestCaseCountInfoVO {
+        private int testCaseCount;
+        private int validTestCaseCount;
+        private int invalidTestCaseCount;
+        private int noExamedTestCaseCount;
+        private int defectCount;
+    }
 }