Forráskód Böngészése

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/TimeCalculationServiceImpl.java
Reiskuchen 5 éve
szülő
commit
a99792be44

+ 5 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -120,7 +120,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             style.setDataFormat(HSSFDataFormat.getBuiltinFormat("yy/mm/dd hh:mm"));
             //新增数据行 并且装填数据
             int rowNum = 1;
-            for (Map<String, Object> map : reportMapper.getAllReportByDate(date)) {
+            List<Map<String, Object>> allReportByDate = reportMapper.getAllReportByDate(date);
+            for (Map<String, Object> map : allReportByDate) {
                 HSSFRow row = sheet.createRow(rowNum);
                 row.createCell(0).setCellValue(rowNum);
                 row.createCell(1).setCellValue((String) map.get("name"));
@@ -167,10 +168,11 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             //以下区间被认为是工作时间
             Integer[] workType = {-1, 0, 1, 2, 3, 4, 5};
             //工作时间筛选
-            for (TimeCalculation timeCalculation : timeCalculationMapper.selectList(new QueryWrapper<TimeCalculation>()
+            List<TimeCalculation> timeCalculations = timeCalculationMapper.selectList(new QueryWrapper<TimeCalculation>()
                     .eq("date", LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd")))
                     .eq("user_id", userId)
-                    .in("action_type", workType))) {
+                    .in("action_type", workType));
+            for (TimeCalculation timeCalculation : timeCalculations) {
                 totalWorkingTime += timeCalculation.getDuration();
             }
             //把总秒数转为double后换算为小时并保留两位小数

+ 44 - 15
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ScreenshotServiceImpl.java

@@ -55,6 +55,8 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
     private String browserFolder;
     @Value(value = "${picrecongnize.develop}")
     private String developFolder;
+    @Value(value = "${picrecongnize.im}")
+    private String imFolder;
 
     @Value("classpath:novel_words.data")
     private org.springframework.core.io.Resource novelWords;
@@ -88,8 +90,8 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
             //获取本人当天结束时间为准的最后一条记录
             TimeCalculation latestRecord = timeCalculationMapper.selectOne(new QueryWrapper<TimeCalculation>()
                     .eq("user_id", screenshot.getUid())
-                    .eq("date", screenshot.getIndate().toLocalDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
-                    .orderByDesc("id")
+                    .eq("date", screenshot.getIndate().toLocalDate())
+                    .orderByDesc("end_time")
                     .last("LIMIT 1"));
             //截图时间
             LocalTime currentTime = screenshot.getIndate().toLocalTime();
@@ -127,8 +129,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
                         .setStartTime(currentTime)
                         .setEndTime(currentTime)
                         //第一次的持续时间默认为最少单位1秒
-                        .setDuration(1)
-                        .setPicUrl(screenshot.getPicUrl());
+                        .setDuration(1);
                 timeCalculationMapper.insert(timeCalculation);
                 if (isConsecutive) {
                     //然后如果只是类型不同但是能连上的话
@@ -255,7 +256,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
     @Override
     public HttpRespMsg saveAndProcessImage(ScreenshotVO screenshotvo) {
         Map<String, Object> fileMap = UploadFileToFileNameUtil.uploadFile(screenshotvo.getFile(), path);
-        String filePath = (String) fileMap.get("sqlFilePath");
+        String filePath = (String)fileMap.get("sqlFilePath");
         Screenshot screenshot = new Screenshot();
         BeanUtils.copyProperties(screenshotvo, screenshot);
         screenshot.setPicUrl(filePath);
@@ -291,8 +292,11 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
 //            //由于存入数据库的对象被序列化成了json字符串,所以从redis里拿方便
 //            members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
 //        }
-        File picFile = new File((String) fileMap.get("newFile"));
-        if (isNovel(textContents)) {
+        File picFile = new File((String)fileMap.get("newFile"));
+        System.out.println("File:"+picFile.getAbsolutePath());
+        if (isIM(picFile) != null) {
+            screenshot.setPicType(9);//聊天
+        } if (isNovel(textContents)) {
             screenshot.setPicType(6);
         } else if (isDocument(textContents)) {
             screenshot.setPicType(2);//看文档
@@ -309,7 +313,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
                 File f = new File(prePath);
                 if (f.exists()) {
                     ImageCompare comp = new ImageCompare();
-                    if (comp.isMoviePlay((String) fileMap.get("newFile"), prePath)) {
+                    if (comp.isMoviePlay((String)fileMap.get("newFile"), prePath)) {
                         screenshot.setPicType(7);
                         //前面那条也更新
                         if (preShot.getPicType() != null && preShot.getPicType() != 7) {
@@ -323,10 +327,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
         if (screenshot.getPicType() == null) {
             //默认设置为查资料
             try {
-                String browserName = isBrowser(new File((String) fileMap.get("newFile")));
-                System.out.println(
-                        "找到浏览器==" + browserName
-                );
+                String browserName = isBrowser(picFile);
                 if (browserName != null) {
                     screenshot.setPicType(1);
                 }
@@ -349,7 +350,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
         File pic = new File(filePath);
         String devName = isDevelop(pic);
         HttpRespMsg msg = new HttpRespMsg();
-        if (devName != null) {
+        if(devName != null) {
             msg.data = devName;
         } else {
             try {
@@ -367,8 +368,8 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
     @Override
     public HttpRespMsg updateRedisPicContentKeywords() {
         List<PicContentKeywords> picContentKeywords = picContentKeywordsMapper.selectList(null);
-        for (PicContentKeywords keyWord : picContentKeywords) {
-            redisUtil.sSetJsonString("keyWords", keyWord);
+        for (PicContentKeywords  keyWord : picContentKeywords) {
+            redisUtil.sSetJsonString("keyWords",keyWord);
         }
         HttpRespMsg msg = new HttpRespMsg();
         msg.data = redisUtil.members("keyWords");
@@ -451,6 +452,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
     }
 
 
+
     private static boolean isPureColor(BufferedImage img, int colorPixel) {
         int with = img.getWidth();
         int height = img.getHeight();
@@ -542,6 +544,33 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
         return null;
     }
 
+    //判断是否是聊天
+    private String isIM(File pic) {
+        File folder = new File(imFolder);
+//        File folder = new File("C:\\picrecongnize\\im\\");
+        if (!folder.exists()) {
+            try {
+                throw new Exception("没有设置图片上传的聊天比对模板库");
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        } else {
+            File[] files = folder.listFiles();
+            String toolName = null;
+            boolean isMatch = false;
+            for (File targetPic : files) {
+//                System.out.println("targetPic==" + targetPic.getAbsolutePath());
+                boolean matchPic = ImageReconizeUtil.isWholeTemplateMatch(pic.getAbsolutePath(), targetPic.getAbsolutePath());
+                if (matchPic) {
+                    toolName = targetPic.getName();
+                    break;
+                }
+            }
+            return toolName;
+        }
+        return null;
+    }
+
     /**
      * 判断是否是看文档, 具体类型为word, excel, pdf, ppt
      *

+ 19 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/ImageReconizeUtil.java

@@ -35,7 +35,18 @@ public class ImageReconizeUtil {
     }
 
     public static boolean isTemplateMatch(String sourcePic, String targetPic) {
-        double matchVal = templete(Imgproc.TM_SQDIFF_NORMED, sourcePic, targetPic);
+        double matchVal = templete(Imgproc.TM_SQDIFF_NORMED, sourcePic, targetPic,true);
+        if (Math.abs(matchVal) < YUZHI) {
+            System.out.println("找到啦");
+            return true;
+        } else {
+            System.out.println("没匹配上");
+            return false;
+        }
+    }
+
+    public static boolean isWholeTemplateMatch(String sourcePic, String targetPic) {
+        double matchVal = templete(Imgproc.TM_SQDIFF_NORMED, sourcePic, targetPic, false);
         if (Math.abs(matchVal) < YUZHI) {
             System.out.println("找到啦");
             return true;
@@ -59,14 +70,16 @@ public class ImageReconizeUtil {
      * @return: void
      * @date: 2019年5月7日12:16:55
      */
-    public static double templete(int method, String sourcePic, String targetPic) {
+    public static double templete(int method, String sourcePic, String targetPic, boolean cutMatch) {
         // 1 获取待匹配图片
 //        System.out.println("sourcePic="+sourcePic+", targetPic="+targetPic);
         Mat templete=Imgcodecs.imread(sourcePic);
-        //先裁减,左上角1/4的截图,提高比对速度。
-        Rect rect = new Rect(0,0,templete.width()/4, templete.height()/4);
-        Mat subMat = new Mat(templete, rect);
-        subMat.copyTo(templete);
+        if (cutMatch) {
+            //先裁减,左上角1/4的截图,提高比对速度。
+            Rect rect = new Rect(0,0,templete.width()/4, templete.height()/4);
+            Mat subMat = new Mat(templete, rect);
+            subMat.copyTo(templete);
+        }
 
         //将rgb灰化处理
 //        Imgproc.cvtColor(templete, templete,Imgproc.COLOR_BGR2GRAY);

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/application-dev.yml

@@ -83,7 +83,7 @@ upload:
 picrecongnize:
   browser: E:/picrecongnize/browser/
   develop: E:/picrecongnize/develop/
-
+  im: E:/picrecongnize/im/
 
 
 

+ 1 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/application-prod.yml

@@ -84,6 +84,7 @@ upload:
 picrecongnize:
   browser: /www/webapps/worktime/picrecongnize/browser/
   develop: /www/webapps/worktime/picrecongnize/develop/
+  im: /www/webapps/worktime/picrecongnize/im/
 
 
 

+ 1 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/application.yml

@@ -84,5 +84,6 @@ upload:
 picrecongnize:
   browser: C:/picrecongnize/browser/
   develop: C:/picrecongnize/develop/
+  im: C:/picrecongnize/im/