Przeglądaj źródła

计数+全部bug直接交付

梅杰 5 lat temu
rodzic
commit
4e8e7880f6

+ 12 - 15
src/main/java/com/mooctest/controller/FinalReportController.java

@@ -1,7 +1,9 @@
 package com.mooctest.controller;
 
+import com.mooctest.data.BugDTO;
 import com.mooctest.data.FinalReportDTO;
 import com.mooctest.data.TaskDTO;
+import com.mooctest.service.BugReportService;
 import com.mooctest.service.FinalReportService;
 import com.mooctest.service.TaskService;
 import com.mooctest.util.ReportUtil;
@@ -26,6 +28,9 @@ public class FinalReportController {
     @Autowired
     TaskService taskService;
 
+    @Autowired
+    BugReportService bugReportService;
+
     @PostMapping("final_report")
     @ResponseBody
     public FinalReportDTO createReport(@RequestBody FinalReportDTO dto) {
@@ -74,21 +79,13 @@ public class FinalReportController {
         return finalReportService.getExportReportAddr(task);
     }
 
-    @RequestMapping(value = "/yourEndPoint")
+    @RequestMapping(value = "/appendBugToFinalReport")
+    @ResponseBody
     public void processRequest(
-            @RequestParam("url") String fileToDownloadUri,
-            HttpServletResponse response) {
-        RestTemplate restTemplate = new RestTemplate();
-
-        response.setStatus(HttpStatus.OK.value());
-
-        restTemplate.execute(
-                fileToDownloadUri,
-                HttpMethod.GET,
-                (ClientHttpRequest requestCallback) -> {},
-                responseExtractor -> {
-                    IOUtils.copy(responseExtractor.getBody(), response.getOutputStream());
-                    return null;
-                });
+            @RequestParam("examId") long examId,
+            @RequestParam("caseId") long caseId) {
+        List<BugDTO> allBugs = bugReportService.getAllBugs(examId, caseId);
+
+        finalReportService.transAllBug2FinalReport(allBugs, examId, caseId);
     }
 }

+ 2 - 0
src/main/java/com/mooctest/controller/ReportController.java

@@ -173,11 +173,13 @@ public class ReportController {
             bugsMap.get(masterId).setStatus(mrMap.get(masterId).getStatus());
         });
 
+
         model.addAttribute("master2BugIdsMap", master2BugIdsMap);
         model.addAttribute("bugMap", bugsMap);
         model.addAttribute("examId", examId);
         model.addAttribute("caseId", caseId);
         model.addAttribute("task", task);
+        model.addAttribute("aggNum", masterReportService.getAggNum(examId, caseId));
         return "agg_report_list";
     }
 }

+ 26 - 2
src/main/java/com/mooctest/service/FinalReportService.java

@@ -3,8 +3,10 @@ package com.mooctest.service;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.mooctest.dao.FinalReportDao;
+import com.mooctest.data.BugDTO;
 import com.mooctest.data.FinalReportDTO;
 import com.mooctest.data.TaskDTO;
+import com.mooctest.model.Bug;
 import com.mooctest.model.FinalReport;
 import com.mooctest.util.HttpUtil;
 import com.mooctest.util.ReportUtil;
@@ -14,11 +16,9 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
-import org.springframework.http.converter.StringHttpMessageConverter;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
-import java.nio.charset.Charset;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -125,4 +125,28 @@ public class FinalReportService {
         });
         return arr;
     }
+
+    public void transAllBug2FinalReport(List<BugDTO> bugs, long examId, long caseId) {
+        List<FinalReport> finalReports = bugs.parallelStream().map(bug -> {
+            FinalReport finalReport = new FinalReport();
+            finalReport.setDescription(bug.getDescription());
+            finalReport.setImgUrls(String.join(",", bug.getImgUrls()));
+            finalReport.setSeverity(bug.getSeverity());
+            finalReport.setRecurrent(bug.getRecurrent());
+            Integer category = ReportUtil.string2Category.get(bug.getBugCategory());
+            if (category == null) {
+                category = 7;
+            }
+            finalReport.setCategory(category);
+            finalReport.setCreateTime(new Date());
+            finalReport.setWriterId(1);
+            finalReport.setExamId(examId);
+            finalReport.setCaseId(caseId);
+            return finalReport;
+        }).collect(Collectors.toList());
+
+        finalReportDao.save(finalReports);
+    }
+
+
 }

+ 5 - 0
src/main/java/com/mooctest/service/MasterReportService.java

@@ -121,4 +121,9 @@ public class MasterReportService {
     public void deleteAll(long examId, long caseId) {
         masterReportDao.deleteByExamIdAndCaseId(examId, caseId);
     }
+
+    public long getAggNum(long examId, long caseId) {
+        List<MasterReport> mrs = masterReportDao.findByExamIdAndCaseId(examId, caseId);
+        return mrs.stream().map(MasterReport::getMasterId).distinct().count();
+    }
 }

+ 10 - 0
src/main/java/com/mooctest/util/ReportUtil.java

@@ -22,6 +22,16 @@ public class ReportUtil {
         put(7, "其他");
     }};
 
+    public static Map<String, Integer> string2Category = new HashMap<String, Integer>() {{
+        put("用户体验", 5);
+        put("页面布局缺陷", 4);
+        put("性能", 3);
+        put("功能不完整", 2);
+        put("安全", 1);
+        put("不正常退出", 6);
+        put("其他", 7);
+    }};
+
     public static Map<Short, String> recurrent2String = new HashMap<Short, String>() {{
         put((short)5, "必现");
         put((short)4, "大概率复现");

+ 1 - 0
src/main/resources/static/css/app_info.css

@@ -3,6 +3,7 @@
 	color: #fff;
 	background-color: #337ab7;
 	border-color: #337ab7;
+	margin-right: 5px;
 }
 
 .btn-manual-assign, .btn-manual-assign:hover, .btn-manual-assign:focus {

+ 33 - 21
src/main/resources/static/js/app_info.js

@@ -1,33 +1,45 @@
 $(function () {
-	// collapse click, toggle itself
+    // collapse click, toggle itself
     var urlParams = new URLSearchParams(window.location.search);
     var examId = urlParams.get('examId');
     var caseId = urlParams.get('caseId');
-	$('table#report-list .collapse').click(function () {
-		$(this).collapse('toggle');
-	});
+    $('table#report-list .collapse').click(function () {
+        $(this).collapse('toggle');
+    });
 // load table
     var reportListTable = $('#report-list').DataTable({
         searching: false,
         pageLength: 25
     });
-	// assign click
-	$('#assign-btn').click(function () {
+    // assign click
+    $('#assign-btn').click(function () {
         // 修改assign-btn的文字以及让其处于不可用状态
         $(this).attr('disabled', true);
         $(this).find('span').text('融合中...');
 
-		$.get('/aggregate', {examId: examId, caseId: caseId}, function () {
-			setInterval(function () {
-                $.get('/agg_task_status', {examId: examId, caseId: caseId}, function(result) {
-                	if (result == 1) {
+        $.get('/aggregate', {examId: examId, caseId: caseId}, function () {
+            setInterval(function () {
+                $.get('/agg_task_status', {examId: examId, caseId: caseId}, function (result) {
+                    if (result == 1) {
 
-                    	agg_success();
-					}
-				});
-			}, 10000)
+                        agg_success();
+                    }
+                });
+            }, 10000)
         });
-	});
+    });
+
+    $('#deliver-btn').click(function () {
+        if (confirm("是否确定全部交付?") == true) {
+            $(this).attr('disabled', true);
+            $(this).find('span').text('处理中...');
+            $.get('/appendBugToFinalReport', {examId: examId, caseId: caseId}, function () {
+
+                alert("处理完成");
+                location.reload();
+            });
+        }
+    });
 
 });
 
@@ -46,15 +58,15 @@ function agg_success() {
             // get value
             var _id = $(el).children('td.report-id').attr('value');
 
-            $.get('/aggregate_info', { bugId: _id }, function(data) {
+            $.get('/aggregate_info', {bugId: _id}, function (data) {
                 var aggregator = data.masterId;
                 var printAggregator = 'ML-AG-' + data.masterId.substring(10);
 
                 function fadeInAggreagator() {
                     // $(el).children('td.report-aggregator').hide();
-                    if($.trim(aggregator)) {//找到了重复报告
+                    if ($.trim(aggregator)) {//找到了重复报告
                         $(el).children('td.report-aggregator').attr('value', aggregator);
-                        var aggregatorHtml = "<a href=/report?masterId="+aggregator+"&examId="+examId+"&caseId="+caseId+">"+printAggregator+"</a>";
+                        var aggregatorHtml = "<a href=/report?masterId=" + aggregator + "&examId=" + examId + "&caseId=" + caseId + ">" + printAggregator + "</a>";
                         $(el).children('td.report-aggregator').html(aggregatorHtml).fadeIn(rand * 2);
                     }
                 }
@@ -62,7 +74,7 @@ function agg_success() {
                 function fadeInStatus() {
                     $(el).find('td:last').hide();
                     // 如果data.assignee 不为None,则最后添加对勾图标,否则添加叉叉图标
-                    if($.trim(aggregator)) {//找到了负责人
+                    if ($.trim(aggregator)) {//找到了负责人
                         $(el).find('td:last').html('<i class=\'fa fa-check-circle text-inverse\'></i>').fadeIn(rand * 2);
                         $(el).find('td:last').addClass('row-success');
 
@@ -75,11 +87,11 @@ function agg_success() {
                 setTimeout(fadeInAggreagator, 0);
                 setTimeout(fadeInStatus, rand);
             });
-        }, rand * 3 *i);
+        }, rand * 3 * i);
     });
 
     //假设此time之后所有assign操作均已完成
     setTimeout(function () {
         location.reload();
-    }, rand * 3 * (count+1));
+    }, rand * 3 * (count + 1));
 };

+ 1 - 18
src/main/resources/templates/agg_report_list.html

@@ -73,7 +73,7 @@
     <section class="content container-fluid">
         <div class="box">
             <div class="box-header with-border">
-                <h3 class="box-title">聚合视图</h3>
+                <h3 class="box-title">聚合视图 <span class="badge badge-info" th:text="${aggNum}"></span></h3>
                 <div class="box-tools pull-right">
                     <a class="btn btn-sm btn-primary" th:href="'/task_detail?examId='+${examId}+'&amp;caseId='+${caseId}">
                         <i class="fa fa-list-alt" style="margin-right: 5px;"></i>
@@ -124,23 +124,6 @@
                                     <div style="margin-top: 5px" th:text="${bugMap.get(bugId).description}">
                                         {{ report.description }}
                                     </div>
-
-                                    <!--<div style="margin-top: 5px;">-->
-                                    <!--<small class="text-muted">-->
-                                    <!--Created By {{ report.worker }} At {{ report.print_datestamp }}-->
-                                    <!--{% if report.status != 0 %}-->
-                                    <!--<br>-->
-                                    <!--Be Assigned To-->
-                                    <!--{{ report.last_assignment.developer_name }}-->
-                                    <!--{% if report.last_assignment.assign_method == 2 %}-->
-                                    <!--Automatically-->
-                                    <!--{% else %}-->
-                                    <!--Manually-->
-                                    <!--{% endif %}-->
-                                    <!--At {{ report.last_assignment.print_datestamp }}-->
-                                    <!--{% endif %}-->
-                                    <!--</small>-->
-                                    <!--</div>-->
                                 </li>
                             </ul>
                         </div>

+ 2 - 2
src/main/resources/templates/final_report_list.html

@@ -113,14 +113,14 @@
 
                     </td>
                     <td class="report-aggregator">
-                        <a th:href="'report?masterId='+${report.sourceId}+'&amp;examId='+${examId}+'&amp;caseId='+${caseId}"
+                        <a th:if="${report.sourceId}" th:href="'report?masterId='+${report.sourceId}+'&amp;examId='+${examId}+'&amp;caseId='+${caseId}"
                            th:text="|ML-AG-${report.sourceId.substring(10)}|"></a>
                     </td>
                     <td class="report-assignee">
                         管理员
                     </td>
                     <td>
-                        <a th:href="'report?masterId='+${report.sourceId}+'&amp;examId='+${examId}+'&amp;caseId='+${caseId}+'&amp;finalReportId='+${report.id}">编辑</a>
+                        <a th:if="${report.sourceId}" th:href="'report?masterId='+${report.sourceId}+'&amp;examId='+${examId}+'&amp;caseId='+${caseId}+'&amp;finalReportId='+${report.id}">编辑</a>
                         <a href="#" th:onclick="'deleteReport('+ ${report.id} +')'">删除</a>
                     </td>
                 </tr>

+ 4 - 0
src/main/resources/templates/task_detail.html

@@ -131,6 +131,10 @@
                 <i class="fa fa-eye" style="margin-right: 3px;"></i>
                 <span>聚合视图</span>
             </a>
+            <button  id="deliver-btn" class="btn btn-sm btn-assign pull-right">
+                <i class="fa fa-coffee" style="margin-right: 3px;"></i>
+                <span>全部交付</span>
+            </button>
         </div>
         <table id="report-list" class="table table-striped table-bordered" cellpadding="0" width="100%">
             <thead>