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

Merge branch 'master' of http://47.100.37.243:10080/wutt/manHourHousekeeper

ZhouRuiTing пре 5 година
родитељ
комит
677f5ffb4a

+ 4 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/constant/Constant.java

@@ -13,8 +13,10 @@ import java.util.List;
  */
 @Component
 public class Constant {
-    public static final String API_KEY = "gtImOYhgcFBzwuT29tB7tM0Z";//百度文字识别apiKey
-    public static final String SECRET_KEY = "RipT5kfF3Zqp7S2vTXPlNcMiYcA76jfq";//百度文字识别secretKey
+//    public static final String API_KEY = "gtImOYhgcFBzwuT29tB7tM0Z";//百度文字识别apiKey
+//    public static final String SECRET_KEY = "RipT5kfF3Zqp7S2vTXPlNcMiYcA76jfq";//百度文字识别secretKey
+    public static final String API_KEY = "UgceK95dGkVbQKicVDU9D6s2";//百度文字识别apiKey
+    public static final String SECRET_KEY = "fGCbfC9CR1v8Pf1u6kG4fM9KEXHgitAA";//百度文字识别secretKey
     public static final Integer UN_HANDLE = 0;//定时任务未处理的状态码
     public static final String PIC_PATH_PREFIX = "";//定时任务未处理的状态码
     public static final String COMMON_SOFTWARE_KEYWORDS = "keyWords";//常用软件关键字

+ 29 - 25
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ScreenshotServiceImpl.java

@@ -144,19 +144,23 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
 //        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
 //        LocalDateTime l = LocalDateTime.parse("2019-02-03",dateTimeFormatter);
         Map<String, Object> picResultMap = CheckPicUtil.generalPicTextContentMap(path + filePath.substring("/upload/".length()), accessToken);
-        List<String> textContents = (List<String>) picResultMap.get("wordsList");
-        screenshot.setPicContext((String) picResultMap.get("picContent"));
-        Set<Object> members = new HashSet<>();
-        if (redisUtil.existsKey(Constant.COMMON_SOFTWARE_KEYWORDS)) {
-            members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
-        } else {
-            List<PicContentKeywords> picContentKeywords = picContentKeywordsMapper.selectList(null);
-            for (PicContentKeywords keyWord : picContentKeywords) {
-                redisUtil.sSetJsonString("keyWords", keyWord);
-            }
-            //由于存入数据库的对象被序列化成了json字符串,所以从redis里拿方便
-            members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
+        List<String> textContents = new ArrayList<String>();
+        if (picResultMap != null) {
+            textContents = (List<String>) picResultMap.get("wordsList");
+            screenshot.setPicContext((String) picResultMap.get("picContent"));
         }
+
+//        Set<Object> members = new HashSet<>();
+//        if (redisUtil.existsKey(Constant.COMMON_SOFTWARE_KEYWORDS)) {
+//            members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
+//        } else {
+//            List<PicContentKeywords> picContentKeywords = picContentKeywordsMapper.selectList(null);
+//            for (PicContentKeywords keyWord : picContentKeywords) {
+//                redisUtil.sSetJsonString("keyWords", keyWord);
+//            }
+//            //由于存入数据库的对象被序列化成了json字符串,所以从redis里拿方便
+//            members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
+//        }
         File picFile = new File((String)fileMap.get("newFile"));
         if (isNovel(textContents)) {
             screenshot.setPicType(6);
@@ -290,7 +294,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
     }
 
     public static void main(String[] args) throws Exception {
-//        String b = isDevelop(new File("C:\\Users\\seya\\Desktop\\proj.jpg"));
+//        String b = isDevelop(new File("C:\\Users\\seya\\Desktop\\wtt.jpg"));
 //        System.out.println("结果:"+b);
     }
 
@@ -409,7 +413,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
                 File[] targetFile = subFolder.listFiles();
                 boolean isMatch = false;
                 for (File targetPic : targetFile) {
-                    System.out.println("targetPic==" + targetPic.getAbsolutePath());
+//                    System.out.println("targetPic==" + targetPic.getAbsolutePath());
                     boolean matchPic = ImageReconizeUtil.isTemplateMatch(pic.getAbsolutePath(), targetPic.getAbsolutePath());
                     if (matchPic) {
                         isMatch = true;
@@ -425,7 +429,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
         }
     }
 
-    //判断是否是浏览器
+    //判断是否是开发
     private String isDevelop(File pic) {
         File folder = new File(developFolder);
 //        File folder = new File("C:\\picrecongnize\\develop\\");
@@ -440,7 +444,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
             String toolName = null;
             boolean isMatch = false;
             for (File targetPic : files) {
-                System.out.println("targetPic==" + targetPic.getAbsolutePath());
+//                System.out.println("targetPic==" + targetPic.getAbsolutePath());
                 boolean matchPic = ImageReconizeUtil.isTemplateMatch(pic.getAbsolutePath(), targetPic.getAbsolutePath());
                 if (matchPic) {
                     toolName = targetPic.getName();
@@ -487,8 +491,8 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
             int height = img.getHeight();
             int minx = img.getMinX();
             int miny = img.getMinY();
-            System.out.println("width=" + width + ",height=" + height + ".");
-            System.out.println("minx=" + minx + ",miniy=" + miny + ".");
+//            System.out.println("width=" + width + ",height=" + height + ".");
+//            System.out.println("minx=" + minx + ",miniy=" + miny + ".");
             //统计出现最多的一个色值,计算所占比重
             int totalPixl = 0;
             HashMap<Integer, Integer> colorCntMap = new HashMap<Integer, Integer>();
@@ -522,12 +526,12 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
             Integer k2 = (Integer) it.next();
             Integer color1 = sMap.get(k1);
             Integer color2 = sMap.get(k2);
-            System.out.println("kkkk==" + k1 + "," + color1 + "," + k2 + "," + color2);
-            System.out.println("最.." + maxCnt + ", key=" + key);
+//            System.out.println("kkkk==" + k1 + "," + color1 + "," + k2 + "," + color2);
+//            System.out.println("最.." + maxCnt + ", key=" + key);
             rgb[0] = (key & 0xff0000) >> 16;
             rgb[1] = (key & 0xff00) >> 8;
             rgb[2] = (key & 0xff);
-            System.out.println("色值为: " + rgb[0] + ", " + rgb[1] + ", " + rgb[2]);
+//            System.out.println("色值为: " + rgb[0] + ", " + rgb[1] + ", " + rgb[2]);
             //计算比例, 应该不低于50%
             int colorPercent = maxCnt * 100 / totalPixl;
             if (colorPercent < 50) {
@@ -536,8 +540,8 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
                 rgb[0] = (color2 & 0xff0000) >> 16;
                 rgb[1] = (color2 & 0xff00) >> 8;
                 rgb[2] = (color2 & 0xff);
-                System.out.println("二级底色色值为: " + rgb[0] + ", " + rgb[1] + ", " + rgb[2]);
-                System.out.println("二级底色比例==" + secPercent);
+//                System.out.println("二级底色色值为: " + rgb[0] + ", " + rgb[1] + ", " + rgb[2]);
+//                System.out.println("二级底色比例==" + secPercent);
                 colorPercent = (k1 + k2) * 100 / totalPixl;
             }
             System.out.println("总底色比例==" + colorPercent);
@@ -554,9 +558,9 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
                     }
                 }
             }
-            log.info("pureColorBlockCnt===" + pureColorBlockCnt);
+//            log.info("pureColorBlockCnt===" + pureColorBlockCnt);
             int pureColorBlackPercent = pureColorBlockCnt * 100 / totalBlockCnt;
-            log.info("pureColorBlackPercent===" + pureColorBlackPercent);
+//            log.info("pureColorBlackPercent===" + pureColorBlackPercent);
             if (colorPercent < 50 && pureColorBlackPercent < 30) {
                 return true;
             }

+ 12 - 8
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/ImageReconizeUtil.java

@@ -11,7 +11,7 @@ import static java.lang.Math.E;
 import static org.opencv.imgproc.Imgproc.*;
 
 public class ImageReconizeUtil {
-    public static final double YUZHI = 1*Math.pow(0.1, 11);
+    public static final double YUZHI = 1*Math.pow(0.1, 10);
     static {
         System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
         //注意程序运行的时候需要在VM option添加该行 指明opencv的dll文件所在路径
@@ -103,16 +103,20 @@ public class ImageReconizeUtil {
 //        }
         System.out.println("匹配度=="+matchVal);
         System.out.println("x="+x+", y=" + y);
-        //我们匹配的图像在左上角,考虑到用户可能拖动窗口,但是不应该偏差很大。 这里增加判断标准:坐标需要处在第一象限
-        if (x > templete.width()/2 || y > templete.height()) {
+        //我们匹配的图像在左上角,考虑到用户可能拖动窗口,但是不应该偏差很大。 这里增加判断标准:坐标处在左上方
+        if (x > templete.width()/4 || y > templete.height()/4) {
             System.out.println("坐标非第一象限");
             return 1;
         }
-//        Imgproc.rectangle(templete,new Point(x,y),new Point(x+demo.cols(),y+demo.rows()),new Scalar( 0, 0, 255),2,Imgproc.LINE_AA);
-//        Imgproc.putText(templete,"Match Success",new Point(x,y),Imgproc.FONT_HERSHEY_SCRIPT_COMPLEX, 1.0, new Scalar(0, 255, 0),1,Imgproc.LINE_AA);
-//        // 8 显示结果
-//        HighGui.imshow("模板匹配", templete);
-//        HighGui.waitKey(0);
+
+//        if (Math.abs(matchVal) < YUZHI) {
+//            Imgproc.rectangle(templete,new Point(x,y),new Point(x+demo.cols(),y+demo.rows()),new Scalar( 0, 0, 255),2,Imgproc.LINE_AA);
+//            Imgproc.putText(templete,"Match Success",new Point(x,y),Imgproc.FONT_HERSHEY_SCRIPT_COMPLEX, 1.0, new Scalar(0, 255, 0),1,Imgproc.LINE_AA);
+//            // 8 显示结果
+//            HighGui.imshow("模板匹配", templete);
+//            HighGui.waitKey(0);
+//        }
+
         return matchVal;
     }
 

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -28,7 +28,7 @@
     <select id="getProjectCost" resultType="java.util.Map">
         SELECT b.name, SUM(a.working_time) AS cost
         FROM report AS a
-        JOIN USER AS b ON a.creator_id = b.id
+        JOIN user AS b ON a.creator_id = b.id
         WHERE a.project_id = #{projectId}
         GROUP BY b.id
         ORDER BY b.id ASC