3 次代码提交 cb9df18c62 ... f962df6f96

作者 SHA1 备注 提交日期
  linyk f962df6f96 Merge branch 'dev' of git.mooctest.com:cofortest/cofortest-backend 2 年之前
  linyk 909c9ec8b1 修改测试人员任务统计接口 2 年之前
  linyk 634c81398e 修复上传缺陷文档报错的问题 2 年之前

+ 1 - 1
core/src/main/java/com/mooctest/crowd/domain/model/ExceptionLogPO.java

@@ -15,7 +15,7 @@ public class ExceptionLogPO {
     private Long id;
     @Column(name = "exception", columnDefinition = "text", nullable = false)
     private String exception;
-    @Column(name = "uri", length = 50, nullable = true)
+    @Column(name = "uri", length = 100, nullable = true)
     private String uri;
     @Column(name = "params", length = 500, nullable = true)
     private String params;

+ 3 - 0
core/src/main/java/com/mooctest/crowd/domain/repository/DefectRepo.java

@@ -112,6 +112,9 @@ public class DefectRepo implements IDefectRepo{
     }
 
     private Defect poToDO(DefectPO defectPO) {
+        if (defectPO == null) {
+            return null;
+        }
         Defect defect = Converter.convert(Defect.class, defectPO);
         if (StringUtils.isNotEmpty(defectPO.getFiles())) {
             defect.setFiles(Arrays.asList(defectPO.getFiles().split(",")));

+ 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;
+    }
 }