Преглед на файлове

影藏导出报告html,修复导出报告excel的跳转,完善图片上传的私有化

郭超 преди 4 години
родител
ревизия
a9e9ddb902

+ 0 - 1
src/main/java/com/mooctest/event/TaskStartListener.java

@@ -27,7 +27,6 @@ public class TaskStartListener implements InitializingBean {
 
     @Subscribe
     public void aggretate(TaskStartEvent event) {
-
         AggTaskStatus aggTaskStatus = aggTaskStatusService.create(event.getExamId(), event.getCaseId());
         aggregationService.aggregate(event.getExamId(), event.getCaseId());
         AggTaskStatus result = aggTaskStatusService.updateStatus(aggTaskStatus.getTaskId(), aggTaskStatus.getStartTime());

+ 1 - 1
src/main/java/com/mooctest/image/ImageDownload.java

@@ -15,7 +15,7 @@ public class ImageDownload {
     public static void createImage(String imgurl, String taskId, String filePath) throws Exception {
 
         String path = ImageUtil.IMAGE_PATH + taskId + "/" + filePath;
-
+        System.out.println("imagePath " + path);
         File imageFile = new File(path);
         if (checkExist(imageFile)) {
             System.out.println("数据已存在");

+ 0 - 3
src/main/java/com/mooctest/service/AggregationService.java

@@ -5,7 +5,6 @@ import com.mooctest.cluster.Group;
 import com.mooctest.data.BugDTO;
 import com.mooctest.data.DiffImg;
 import com.mooctest.data.DiffText;
-import com.mooctest.data.ReportDTO;
 import com.mooctest.image.ImageDownload;
 import com.mooctest.nlp.DistanceMatrix;
 import org.apache.commons.collections4.CollectionUtils;
@@ -126,11 +125,9 @@ public class  AggregationService {
                     if (imgUrls[i] == null || !imgUrls[i].startsWith("http")) {
                         continue;
                     }
-
                     String fileName = bug.getId() + "_" + i;
                     System.out.println("正在下载 " + fileName);
                     try {
-
                         ImageDownload.createImage(imgUrls[i], taskId, fileName);
                     } catch (Exception e) {
                         System.out.println(imgUrls[i]);

+ 4 - 0
src/main/java/com/mooctest/service/FinalReportService.java

@@ -155,8 +155,12 @@ public class FinalReportService {
     }
 
     public void transAllBug2FinalReport(List<BugDTO> bugs, long examId, long caseId) {
+
         List<FinalReport> finalReports = bugs.parallelStream().map(bug -> {
             FinalReport finalReport = new FinalReport();
+            long count = finalReportDao.count();
+            count = count + 1;
+            finalReport.setId(count);
             finalReport.setDescription(bug.getDescription());
             finalReport.setImgUrls(String.join(",", bug.getImgUrls()));
             finalReport.setSeverity(bug.getSeverity());

+ 8 - 6
src/main/java/com/mooctest/service/impl/NginxFileService.java

@@ -12,8 +12,10 @@ import java.io.*;
 @ConditionalOnExpression("${useOss}==false")
 public class NginxFileService implements FileService {
 
-    @Value("${filePath}")
-    private String filePath;
+    @Value("${save.path}")
+    private String savePath;
+	@Value("${save.json}")
+	private String jsonPath;
     @Value("${baseUrl.urlPath}")
     private String urlPath;
 
@@ -25,7 +27,7 @@ public class NginxFileService implements FileService {
     @Override
     public String uploadFile(MultipartFile file) {
         String fileName = System.currentTimeMillis()+ file.getOriginalFilename();
-        File saveFile = new File(filePath + fileName);
+        File saveFile = new File(savePath + jsonPath + fileName);
         //判断文件父目录是否存在
 //        System.out.println(saveFile.getParentFile());
         if (!saveFile.getParentFile().exists()) {
@@ -43,7 +45,7 @@ public class NginxFileService implements FileService {
     @Override
     public String uploadJson(String content,long taskId) {
         String fileName = taskId+".json";
-        File saveFile = new File(filePath + fileName);
+        File saveFile = new File(savePath + jsonPath + fileName);
         //判断文件父目录是否存在
 //        System.out.println(saveFile.getParentFile());
         if (!saveFile.getParentFile().exists()) {
@@ -54,8 +56,8 @@ public class NginxFileService implements FileService {
             write.write(content);
             write.flush();
             write.close();
-            System.out.println("上传三级菜单的json " + filePath + fileName);
-            return filePath + fileName;
+            System.out.println("上传三级菜单的json " + savePath + jsonPath + fileName);
+            return savePath + jsonPath + fileName;
         } catch (IOException e) {
             e.printStackTrace();
             return null;

+ 16 - 3
src/main/java/com/mooctest/util/ImageUtil.java

@@ -1,19 +1,32 @@
 package com.mooctest.util;
 
 import com.mooctest.image.FingerPrint;
+import org.springframework.beans.factory.annotation.Value;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
 
 public class ImageUtil {
+
+    @Value("${save.path}")
+    public static String savePath;
+
+    @Value("${save.image}")
+    private static String imagePath;
+
+    public void setSavePath(String savePath){
+        ImageUtil.savePath = savePath;
+    }
+
+    public void setImagePath(String imagePath){
+        ImageUtil.imagePath = imagePath;
+    }
     /**
      * 图像指纹的尺寸,将图像resize到指定的尺寸,来计算哈希数组
      */
     private static final int HASH_SIZE=16;
 
-    public static final String IMAGE_PATH = "/Users/major/Desktop/data/";
+    public static final String IMAGE_PATH = savePath + imagePath;
 
     public static File checkFileExist(String filePath) {
         File f1 = new File(filePath);

+ 6 - 3
src/main/resources/application.yml

@@ -44,7 +44,7 @@ baseUrl:
   taskDistribute: http://47.102.206.109:6379/
   report:
     export: http://47.99.140.117:9002/generateReport
-    excel: http://localhost:9003/generateReport
+    excel: http://127.0.0.1:9003/generateReport
     host: 127.0.0.1:8090
   urlPath: http://47.98.174.59:8100/resourcesXinchuang/
 
@@ -67,9 +67,12 @@ baseUrl:
   taskDistribute: http://47.102.206.109:6379/
   report:
     export: http://47.99.140.117:9002/generateReport
-    excel: http://47.98.174.59:8095/generateReport
+    excel: http://127.0.0.1:9003/generateReport
     host: 127.0.0.1:8090
   urlPath: http://47.98.174.59:8100/resourcesXinchuang/
 
 useOss: false
-filePath: /Users/guochao/Desktop/corwd-file/xinchuang/json/
+save:
+  path: /Users/guochao/Desktop/corwd-file/xinchuang
+  json: /json/
+  image: /image/

+ 14 - 13
src/main/resources/templates/final_report_list.html

@@ -39,24 +39,24 @@
     <section class="content container-fluid">
 
         <!-- Report List Table -->
-        <div class="assign-div pull-right">
-            <button id="export-btn" class="btn btn-sm btn-assign pull-right">
-                <i class="fa fa-coffee" style="margin-right: 3px;"></i>
-                <span>导出报告(Html)</span>
-            </button>
-        </div>
+<!--        <div class="assign-div pull-right">-->
+<!--            <button id="export-btn" class="btn btn-sm btn-assign pull-right">-->
+<!--                <i class="fa fa-coffee" style="margin-right: 3px;"></i>-->
+<!--                <span>导出报告(Html)</span>-->
+<!--            </button>-->
+<!--        </div>-->
         <div class="assign-div pull-right">
             <button id="export-btn-excel" class="btn btn-sm btn-assign pull-right">
                 <i class="fa fa-coffee" style="margin-right: 3px;"></i>
                 <span>导出报告(Excel)</span>
             </button>
         </div>
-        <div class="assign-div pull-right">
-            <button id="block-chain-btn" class="btn btn-sm btn-assign pull-right">
-                <i class="fa fa-coffee" style="margin-right: 3px;"></i>
-                <span>将数据导入区块链</span>
-            </button>
-        </div>
+<!--        <div class="assign-div pull-right">-->
+<!--            <button id="block-chain-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>
             <tr>
@@ -234,8 +234,9 @@
                 console.log(result)
 
                 if(result=='wait'){
-                    alert("报告生成中预计半小时后出结果,请耐心等待")
+                    alert("报告生成中预计几分钟后出结果,请耐心等待")
                 }else{
+                    console.log("window.open ", result)
                     window.open(result, '_blank');
                 }
             });

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

@@ -250,10 +250,10 @@
                 <i class="fa fa-coffee" style="margin-right: 3px;"></i>
                 <span>查看大盘</span>
             </a>
-            <button th:if="${!aggregated}" id="assign-btn" class="btn btn-sm btn-assign pull-right">
-                <i class="fa fa-coffee" style="margin-right: 3px;"></i>
-                <span>自动融合</span>
-            </button>
+<!--            <button th:if="${!aggregated}" id="assign-btn" class="btn btn-sm btn-assign pull-right">-->
+<!--                <i class="fa fa-coffee" style="margin-right: 3px;"></i>-->
+<!--                <span>自动融合</span>-->
+<!--            </button>-->
             <a th:if="${aggregated}" id="agg-view" class="btn btn-sm btn-assign pull-right" th:href="'/agg_report_list?examId=' + ${examId} + '&amp;caseId=' + ${caseId}">
                 <i class="fa fa-eye" style="margin-right: 3px;"></i>
                 <span>聚合视图</span>