Bladeren bron

修复以前bug

insomniaLee 5 jaren geleden
bovenliggende
commit
8ef9e9de50

+ 24 - 2
src/main/java/com/mooctest/controller/BugReviewController.java

@@ -21,10 +21,32 @@ public class BugReviewController {
 
 
     //审核报告 -- 单个报告   之后更新报告所在
+//    @PutMapping("/single_bug_review")
+//    @ResponseBody
+//    public String singlaBugReview(@RequestParam("reportId") String reportId) {
+//        boolean flag  =  bugReviewService.singleReportReview(reportId);
+//        return flag?"success":"fail";
+//    }
+
+    //审核报告 -- 单个报告   之后更新报告所在
     @PutMapping("/single_bug_review")
     @ResponseBody
-    public String singlaBugReview(@RequestParam("reportId") String reportId) {
-        boolean flag  =  bugReviewService.singleReportReview(reportId);
+    public String singlaBugReview2(@RequestParam("reportId") String reportId) {
+        boolean flag  =  bugReviewService.singleReportReview2(reportId);
+        return flag?"success":"fail";
+    }
+
+    @PutMapping("/master_review")
+    @ResponseBody
+    public String masterBugReview2(@RequestParam("reportId") String reportId) {
+        boolean flag  =  bugReviewService.masterReview2(reportId);
+        return flag?"success":"fail";
+    }
+
+    @PutMapping("/tree_review")
+    @ResponseBody
+    public String treeBugReview2(@RequestParam("reportId") String reportId) {
+        boolean flag  =  bugReviewService.treeReview2(reportId);
         return flag?"success":"fail";
     }
 

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

@@ -28,7 +28,7 @@ public final class FingerPrint {
     private final byte[] binaryzationMatrix;
     public FingerPrint(byte[] hashValue) {
         if(hashValue.length!=HASH_SIZE*HASH_SIZE)
-            throw new IllegalArgumentException(String.format("length of hashValue must be %d",HASH_SIZE*HASH_SIZE ));
+            throw new IllegalArgumentException(String.format("length of hashValue must be %d now is ",HASH_SIZE*HASH_SIZE,hashValue.length ));
         this.binaryzationMatrix=hashValue;
     }
     public FingerPrint(String hashValue) {

+ 26 - 0
src/main/java/com/mooctest/service/BugReviewService.java

@@ -77,6 +77,32 @@ public class BugReviewService {
 //        });
 //    }
 
+    public boolean masterReview2(String masterId ){
+        List<MasterReport> mrs = masterReportDao.findByMasterId(masterId);
+        List<String> bugIds = mrs.stream().map(MasterReport::getBugId).collect(Collectors.toList());
+        updateBugReviewed(bugIds);
+        return true;
+    }
+
+    public boolean treeReview2(String treeId){
+        // 仅仅是将这一份报告的状态设置为已经review, 如果这个报告还有tree报告或者master报告还没review 就提示无法review。
+        //如果是树状的root 和master报告就要看是不是下面的报告已经都审核了
+        List<String> childs = historyService.getSingleRootReports(treeId);
+        childs.add(treeId);
+        updateBugReviewed(childs);
+        return true;
+    }
+
+    /**
+     *
+     * @param reportId
+     * @return 是否审核成功
+     */
+    public boolean singleReportReview2 (String reportId){ //
+        updateSingleBugReview(reportId);
+        return true;
+    }
+
 
     /**
      *

+ 18 - 13
src/main/java/com/mooctest/service/DiffImgService.java

@@ -104,21 +104,26 @@ public class DiffImgService {
     private boolean isSimilarWithMasterReport(BugDTO masterReport, File imgFile, String taskId) {
 
         String[] masterImgs = masterReport.getImgUrls();
-        FingerPrint reportImgFingerPrint = readImgFingerPrint(imgFile);
-        for (int i = 0; i < masterImgs.length; i++) {
-            String imgPath2 = genImagePath(taskId, masterReport.getId(), i);
-            File img = checkFileExist(imgPath2);
-            if (img == null) {
-                continue;
-            }
-            FingerPrint masterImgFingerPrint = readImgFingerPrint(img);
-            float sim = masterImgFingerPrint.compare(reportImgFingerPrint);
-            if (sim > 0.85) {
-                return true;
+        try {
+            FingerPrint reportImgFingerPrint = readImgFingerPrint(imgFile);
+            if(reportImgFingerPrint==null) return false;
+            for (int i = 0; i < masterImgs.length; i++) {
+                String imgPath2 = genImagePath(taskId, masterReport.getId(), i);
+                File img = checkFileExist(imgPath2);
+                if (img == null) {
+                    continue;
+                }
+                FingerPrint masterImgFingerPrint = readImgFingerPrint(img);
+                if(masterImgFingerPrint==null) return false;
+                float sim = masterImgFingerPrint.compare(reportImgFingerPrint);
+                if (sim > 0.85) {
+                    return true;
+                }
             }
+            return false;
+        }catch (Exception e){
+            return false;
         }
-
-        return false;
     }
 
 }

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

@@ -8,6 +8,10 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 
 public class ImageUtil {
+    /**
+     * 图像指纹的尺寸,将图像resize到指定的尺寸,来计算哈希数组
+     */
+    private static final int HASH_SIZE=16;
 
     public static final String IMAGE_PATH = "/Users/major/Desktop/data/";
 
@@ -24,12 +28,16 @@ public class ImageUtil {
             fis1 = new FileInputStream(img);
             fis1.read(b1);
             fp = new FingerPrint(b1);
+            if (fp.getBinaryzationMatrix().length!=HASH_SIZE*HASH_SIZE){
+                return null;
+            }
+
             fis1.close();
 
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
+        } catch (Exception e) {
+            System.out.println("debug-catch the exception");
             e.printStackTrace();
+            return null;
         }
         return fp;
     }

+ 1 - 1
src/main/resources/templates/agg_report_new.html

@@ -709,7 +709,7 @@
 
     function reviewConfirm() {
         $.ajax({
-            url: '/single_bug_review?reportId='+masterId,
+            url: '/master_review?reportId='+masterId,
             type: 'PUT',
             success: function (result) {
                 if(result=="success"){

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

@@ -637,10 +637,10 @@
     }
 
 
-    //////////////////////////
+    
     function reviewConfirm() {
         $.ajax({
-            url: '/single_bug_review?reportId='+treeId,
+            url: '/tree_review?reportId='+treeId,
             type: 'PUT',
             success: function (result) {
                 if(result=="success"){