|
@@ -1,22 +1,17 @@
|
|
package com.management.platform.service.impl;
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.management.platform.constant.Constant;
|
|
import com.management.platform.constant.Constant;
|
|
import com.management.platform.constant.Parameter;
|
|
import com.management.platform.constant.Parameter;
|
|
import com.management.platform.entity.PicContentKeywords;
|
|
import com.management.platform.entity.PicContentKeywords;
|
|
import com.management.platform.entity.Screenshot;
|
|
import com.management.platform.entity.Screenshot;
|
|
import com.management.platform.entity.TimeCalculation;
|
|
import com.management.platform.entity.TimeCalculation;
|
|
-import com.management.platform.entity.User;
|
|
|
|
|
|
+import com.management.platform.entity.TimeCalculationShow;
|
|
import com.management.platform.entity.vo.ScreenshotVO;
|
|
import com.management.platform.entity.vo.ScreenshotVO;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.mapper.*;
|
|
-import com.management.platform.mapper.PicContentKeywordsMapper;
|
|
|
|
import com.management.platform.service.ScreenshotService;
|
|
import com.management.platform.service.ScreenshotService;
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
import com.management.platform.util.*;
|
|
import com.management.platform.util.*;
|
|
-import net.sourceforge.tess4j.Word;
|
|
|
|
import org.apache.log4j.Logger;
|
|
import org.apache.log4j.Logger;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -68,15 +63,150 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private ScreenshotMapper screenshotMapper;
|
|
private ScreenshotMapper screenshotMapper;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
private PicContentKeywordsMapper picContentKeywordsMapper;
|
|
private PicContentKeywordsMapper picContentKeywordsMapper;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
private TimeCalculationMapper timeCalculationMapper;
|
|
private TimeCalculationMapper timeCalculationMapper;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
private UserMapper userMapper;
|
|
private UserMapper userMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private TimeCalculationShowMapper timeCalculationShowMapper;
|
|
|
|
+
|
|
|
|
+ //每次获取到截屏后计算并处理
|
|
|
|
+ private void calculateTime(Screenshot screenshot) {
|
|
|
|
+ try {
|
|
|
|
+ //首先拿去处理show表
|
|
|
|
+ calculateShowTime(screenshot);
|
|
|
|
+
|
|
|
|
+ //如果图片类型为空 则认为是 -1 - 其他
|
|
|
|
+ if (null == screenshot.getPicType()) {
|
|
|
|
+ screenshot.setPicType(-1);
|
|
|
|
+ }
|
|
|
|
+ //默认状态为不连续 如果下面判断是连续才会修改为true
|
|
|
|
+ Boolean isConsecutive = false,
|
|
|
|
+ isSameType = false;
|
|
|
|
+ //获取本人当天结束时间为准的最后一条记录
|
|
|
|
+ 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")
|
|
|
|
+ .last("LIMIT 1"));
|
|
|
|
+ //截图时间
|
|
|
|
+ LocalTime currentTime = screenshot.getIndate().toLocalTime();
|
|
|
|
+ //如果有上一条记录
|
|
|
|
+ if (latestRecord != null) {
|
|
|
|
+ //前后两张是否相同类型
|
|
|
|
+ isSameType = latestRecord.getActionType().equals(screenshot.getPicType());
|
|
|
|
+ //前后两张时间是否连续 这个目前为600秒
|
|
|
|
+ LocalTime estimatedTime = latestRecord.getEndTime();
|
|
|
|
+ Integer durationSecond = ((currentTime.getHour() - estimatedTime.getHour()) * 3600
|
|
|
|
+ + (currentTime.getMinute() - estimatedTime.getMinute()) * 60
|
|
|
|
+ + (currentTime.getSecond() - estimatedTime.getSecond()));
|
|
|
|
+ //断层不大于一定时间的话 用来判断是否连续
|
|
|
|
+ isConsecutive = durationSecond <= DETECTION_INTERVAL;
|
|
|
|
+ }
|
|
|
|
+ if (isConsecutive && isSameType) {
|
|
|
|
+ //如果时间连续 且是同一类型的话 修改上一条记录的最后时间和持续时间
|
|
|
|
+ LocalTime startTime = latestRecord.getStartTime();
|
|
|
|
+ //计算新的间隔
|
|
|
|
+ Integer duration = ((currentTime.getHour() - startTime.getHour()) * 3600
|
|
|
|
+ + (currentTime.getMinute() - startTime.getMinute()) * 60
|
|
|
|
+ + (currentTime.getSecond() - startTime.getSecond()));
|
|
|
|
+ //设置新的结束时间和持续时间 保存记录
|
|
|
|
+ latestRecord.setEndTime(currentTime).setDuration(duration);
|
|
|
|
+ timeCalculationMapper.updateById(latestRecord);
|
|
|
|
+ } else {
|
|
|
|
+ //如果不是连续的话 新增一个记录
|
|
|
|
+ TimeCalculation timeCalculation = new TimeCalculation();
|
|
|
|
+ timeCalculation
|
|
|
|
+ .setUserId(screenshot.getUid())
|
|
|
|
+ //根据截图种类设置行为代号
|
|
|
|
+ .setActionType(screenshot.getPicType())
|
|
|
|
+ .setDate(screenshot.getIndate().toLocalDate())
|
|
|
|
+ //设置开始时间和结束时间都为当前时间
|
|
|
|
+ .setStartTime(currentTime)
|
|
|
|
+ .setEndTime(currentTime)
|
|
|
|
+ //第一次的持续时间默认为最少单位1秒
|
|
|
|
+ .setDuration(1)
|
|
|
|
+ .setPicUrl(screenshot.getPicUrl());
|
|
|
|
+ timeCalculationMapper.insert(timeCalculation);
|
|
|
|
+ if (isConsecutive) {
|
|
|
|
+ //然后如果只是类型不同但是能连上的话
|
|
|
|
+ LocalTime startTime = latestRecord.getStartTime();
|
|
|
|
+ //计算新的间隔
|
|
|
|
+ Integer duration = ((currentTime.getHour() - startTime.getHour()) * 3600
|
|
|
|
+ + (currentTime.getMinute() - startTime.getMinute()) * 60
|
|
|
|
+ + (currentTime.getSecond() - startTime.getSecond()));
|
|
|
|
+ //设置新的结束时间和持续时间 保存记录
|
|
|
|
+ latestRecord.setEndTime(currentTime).setDuration(duration);
|
|
|
|
+ timeCalculationMapper.updateById(latestRecord);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /*之后可能还需要处理跨越一天的情况*/
|
|
|
|
+ } catch (NullPointerException e) {
|
|
|
|
+ //凡是有空指针说明缺少用户id或者时间数据
|
|
|
|
+ log.info("工作时长统计失败 缺少用户或时间数据");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //每次获取到截屏后计算并处理
|
|
|
|
+ private void calculateShowTime(Screenshot screenshot) {
|
|
|
|
+ try {
|
|
|
|
+ //如果图片类型为空 则认为是 -1 - 其他
|
|
|
|
+ if (null == screenshot.getPicType()) {
|
|
|
|
+ screenshot.setPicType(-1);
|
|
|
|
+ }
|
|
|
|
+ //默认状态为不连续 如果下面判断是连续才会修改为true
|
|
|
|
+ Boolean isConsecutive = false;
|
|
|
|
+ //获取本人当天结束时间为准的最后一条记录
|
|
|
|
+ TimeCalculationShow latestRecord = timeCalculationShowMapper.selectOne(
|
|
|
|
+ new QueryWrapper<TimeCalculationShow>()
|
|
|
|
+ .eq("user_id", screenshot.getUid())
|
|
|
|
+ .eq("date", screenshot.getIndate().toLocalDate())
|
|
|
|
+ .orderByDesc("end_time")
|
|
|
|
+ .last("LIMIT 1"));
|
|
|
|
+ //截图时间
|
|
|
|
+ LocalTime currentTime = screenshot.getIndate().toLocalTime();
|
|
|
|
+ //如果有上一条记录
|
|
|
|
+ if (latestRecord != null) {
|
|
|
|
+ //前后两张时间是否连续 这个目前为600秒
|
|
|
|
+ LocalTime estimatedTime = latestRecord.getEndTime();
|
|
|
|
+ Integer durationSecond = ((currentTime.getHour() - estimatedTime.getHour()) * 3600
|
|
|
|
+ + (currentTime.getMinute() - estimatedTime.getMinute()) * 60
|
|
|
|
+ + (currentTime.getSecond() - estimatedTime.getSecond()));
|
|
|
|
+ //断层不大于一定时间的话 用来判断是否连续
|
|
|
|
+ isConsecutive = durationSecond <= DETECTION_INTERVAL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (isConsecutive) {
|
|
|
|
+ //如果是连续的话 修改上一条记录的最后时间和持续时间
|
|
|
|
+ LocalTime startTime = latestRecord.getStartTime();
|
|
|
|
+ //计算新的间隔
|
|
|
|
+ Integer duration = ((currentTime.getHour() - startTime.getHour()) * 3600
|
|
|
|
+ + (currentTime.getMinute() - startTime.getMinute()) * 60
|
|
|
|
+ + (currentTime.getSecond() - startTime.getSecond()));
|
|
|
|
+ //设置新的结束时间和持续时间 保存记录
|
|
|
|
+ latestRecord.setEndTime(currentTime).setDuration(duration);
|
|
|
|
+ timeCalculationShowMapper.updateById(latestRecord);
|
|
|
|
+ } else {
|
|
|
|
+ //如果不是连续的话 新增一个记录
|
|
|
|
+ TimeCalculationShow timeCalculationShow = new TimeCalculationShow();
|
|
|
|
+ timeCalculationShow
|
|
|
|
+ .setUserId(screenshot.getUid())
|
|
|
|
+ .setDate(screenshot.getIndate().toLocalDate())
|
|
|
|
+ //设置开始时间和结束时间都为当前时间
|
|
|
|
+ .setStartTime(currentTime)
|
|
|
|
+ .setEndTime(currentTime)
|
|
|
|
+ //第一次的持续时间默认为最少单位1秒
|
|
|
|
+ .setDuration(1);
|
|
|
|
+ timeCalculationShowMapper.insert(timeCalculationShow);
|
|
|
|
+ }
|
|
|
|
+ /*之后可能还需要处理跨越一天的情况*/
|
|
|
|
+ } catch (NullPointerException e) {
|
|
|
|
+ //凡是有空指针说明缺少用户id或者时间数据
|
|
|
|
+ log.info("工作时长统计失败 缺少用户或时间数据");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
//获取所有人最新的截图
|
|
//获取所有人最新的截图
|
|
@Override
|
|
@Override
|
|
@@ -126,7 +256,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg saveAndProcessImage(ScreenshotVO screenshotvo) {
|
|
public HttpRespMsg saveAndProcessImage(ScreenshotVO screenshotvo) {
|
|
Map<String, Object> fileMap = UploadFileToFileNameUtil.uploadFile(screenshotvo.getFile(), path);
|
|
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();
|
|
Screenshot screenshot = new Screenshot();
|
|
BeanUtils.copyProperties(screenshotvo, screenshot);
|
|
BeanUtils.copyProperties(screenshotvo, screenshot);
|
|
screenshot.setPicUrl(filePath);
|
|
screenshot.setPicUrl(filePath);
|
|
@@ -162,7 +292,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
// //由于存入数据库的对象被序列化成了json字符串,所以从redis里拿方便
|
|
// //由于存入数据库的对象被序列化成了json字符串,所以从redis里拿方便
|
|
// members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
|
|
// members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
|
|
// }
|
|
// }
|
|
- File picFile = new File((String)fileMap.get("newFile"));
|
|
|
|
|
|
+ File picFile = new File((String) fileMap.get("newFile"));
|
|
if (isNovel(textContents)) {
|
|
if (isNovel(textContents)) {
|
|
screenshot.setPicType(6);
|
|
screenshot.setPicType(6);
|
|
} else if (isDocument(textContents)) {
|
|
} else if (isDocument(textContents)) {
|
|
@@ -180,7 +310,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
File f = new File(prePath);
|
|
File f = new File(prePath);
|
|
if (f.exists()) {
|
|
if (f.exists()) {
|
|
ImageCompare comp = new ImageCompare();
|
|
ImageCompare comp = new ImageCompare();
|
|
- if (comp.isMoviePlay((String)fileMap.get("newFile"), prePath)) {
|
|
|
|
|
|
+ if (comp.isMoviePlay((String) fileMap.get("newFile"), prePath)) {
|
|
screenshot.setPicType(7);
|
|
screenshot.setPicType(7);
|
|
//前面那条也更新
|
|
//前面那条也更新
|
|
if (preShot.getPicType() != null && preShot.getPicType() != 7) {
|
|
if (preShot.getPicType() != null && preShot.getPicType() != 7) {
|
|
@@ -194,7 +324,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
if (screenshot.getPicType() == null) {
|
|
if (screenshot.getPicType() == null) {
|
|
//默认设置为查资料
|
|
//默认设置为查资料
|
|
try {
|
|
try {
|
|
- String browserName = isBrowser(new File((String)fileMap.get("newFile")));
|
|
|
|
|
|
+ String browserName = isBrowser(new File((String) fileMap.get("newFile")));
|
|
System.out.println(
|
|
System.out.println(
|
|
"找到浏览器==" + browserName
|
|
"找到浏览器==" + browserName
|
|
);
|
|
);
|
|
@@ -212,11 +342,34 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
return new HttpRespMsg();
|
|
return new HttpRespMsg();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg reTestPicMatch(int id) {
|
|
|
|
+ Screenshot item = screenshotMapper.selectById(id);
|
|
|
|
+ String fileName = item.getPicUrl().replaceAll("/upload/", "");
|
|
|
|
+ String filePath = path + fileName;
|
|
|
|
+ File pic = new File(filePath);
|
|
|
|
+ String devName = isDevelop(pic);
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ if (devName != null) {
|
|
|
|
+ msg.data = devName;
|
|
|
|
+ } else {
|
|
|
|
+ try {
|
|
|
|
+ String browserName = isBrowser(pic);
|
|
|
|
+ if (browserName != null) {
|
|
|
|
+ msg.data = browserName;
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg updateRedisPicContentKeywords() {
|
|
public HttpRespMsg updateRedisPicContentKeywords() {
|
|
List<PicContentKeywords> picContentKeywords = picContentKeywordsMapper.selectList(null);
|
|
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();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
msg.data = redisUtil.members("keyWords");
|
|
msg.data = redisUtil.members("keyWords");
|
|
@@ -250,7 +403,6 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
//第二步,匹配小说常见词汇,超过5次,认为是小说
|
|
//第二步,匹配小说常见词汇,超过5次,认为是小说
|
|
try {
|
|
try {
|
|
//填充小说关键字到内存,减少重复读取
|
|
//填充小说关键字到内存,减少重复读取
|
|
@@ -299,6 +451,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
// System.out.println("结果:"+b);
|
|
// System.out.println("结果:"+b);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
private static boolean isPureColor(BufferedImage img, int colorPixel) {
|
|
private static boolean isPureColor(BufferedImage img, int colorPixel) {
|
|
int with = img.getWidth();
|
|
int with = img.getWidth();
|
|
int height = img.getHeight();
|
|
int height = img.getHeight();
|
|
@@ -318,7 +471,6 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
return !hasDifferent;
|
|
return !hasDifferent;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 是否全是汉字<br>
|
|
* 是否全是汉字<br>
|
|
* 根据汉字编码范围进行判断<br>
|
|
* 根据汉字编码范围进行判断<br>
|
|
@@ -335,71 +487,6 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
return pattern.matcher(str).matches();
|
|
return pattern.matcher(str).matches();
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- //每次获取到截屏后计算并处理
|
|
|
|
- private void calculateTime(Screenshot screenshot) {
|
|
|
|
- try {
|
|
|
|
- //如果图片类型为空 则认为是-1-其他
|
|
|
|
- if(null == screenshot.getPicType()){
|
|
|
|
- screenshot.setPicType(-1);
|
|
|
|
- }
|
|
|
|
- //默认状态为不连续 如果下面判断是连续才会修改为true
|
|
|
|
- Boolean isConsecutive = false;
|
|
|
|
- //获取本人当天结束时间为准的最后一条记录
|
|
|
|
- TimeCalculation latestRecord = timeCalculationMapper.selectOne(new QueryWrapper<TimeCalculation>()
|
|
|
|
- .eq("user_id", screenshot.getUid())
|
|
|
|
- .eq("date", screenshot.getIndate().toLocalDate())
|
|
|
|
- .orderByDesc("end_time")
|
|
|
|
- .last("LIMIT 1"));
|
|
|
|
- //单独记录当前的时间以便使用
|
|
|
|
- LocalTime currentTime = screenshot.getIndate().toLocalTime();
|
|
|
|
- if (latestRecord != null) {
|
|
|
|
- //首先对比类型 同一种行为才有可能合并
|
|
|
|
- if (latestRecord.getActionType().equals(screenshot.getPicType())) {
|
|
|
|
- //如果有记录的话 计算上次结束和新的开始的时间差
|
|
|
|
- LocalTime estimatedTime = latestRecord.getEndTime();
|
|
|
|
- Integer durationSecond = ((currentTime.getHour() - estimatedTime.getHour()) * 3600
|
|
|
|
- + (currentTime.getMinute() - estimatedTime.getMinute()) * 60
|
|
|
|
- + (currentTime.getSecond() - estimatedTime.getSecond()));
|
|
|
|
- //断层不大于一定时间的话 这个定义目前为600秒
|
|
|
|
- if (durationSecond <= DETECTION_INTERVAL) {
|
|
|
|
- //确认连续 将状态改为连续
|
|
|
|
- isConsecutive = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (isConsecutive) {
|
|
|
|
- //如果是连续的话 修改上一条记录的最后时间和持续时间
|
|
|
|
- LocalTime startTime = latestRecord.getStartTime();
|
|
|
|
- //计算新的间隔
|
|
|
|
- Integer duration = ((currentTime.getHour() - startTime.getHour()) * 3600
|
|
|
|
- + (currentTime.getMinute() - startTime.getMinute()) * 60
|
|
|
|
- + (currentTime.getSecond() - startTime.getSecond()));
|
|
|
|
- //设置新的结束时间和持续时间 保存记录
|
|
|
|
- latestRecord.setEndTime(currentTime).setDuration(duration);
|
|
|
|
- timeCalculationMapper.updateById(latestRecord);
|
|
|
|
- } else {
|
|
|
|
- //如果不是连续的话 新增一个记录
|
|
|
|
- TimeCalculation timeCalculation = new TimeCalculation();
|
|
|
|
- timeCalculation
|
|
|
|
- .setUserId(screenshot.getUid())
|
|
|
|
- //根据截图种类设置行为代号
|
|
|
|
- .setActionType(screenshot.getPicType())
|
|
|
|
- .setDate(screenshot.getIndate().toLocalDate())
|
|
|
|
- //设置开始时间和结束时间都为当前时间
|
|
|
|
- .setStartTime(currentTime)
|
|
|
|
- .setEndTime(currentTime)
|
|
|
|
- //第一次的持续时间默认为最少单位1秒 不然我看一眼就成了0秒了
|
|
|
|
- .setDuration(1);
|
|
|
|
- timeCalculationMapper.insert(timeCalculation);
|
|
|
|
- }
|
|
|
|
- /*之后可能还需要处理跨越一天的情况*/
|
|
|
|
- } catch (NullPointerException e) {
|
|
|
|
- //凡是有空指针说明缺少用户id或者时间数据
|
|
|
|
- log.info("工作时长统计失败 缺少用户或时间数据");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
//判断是否是浏览器
|
|
//判断是否是浏览器
|
|
private String isBrowser(File pic) throws Exception {
|
|
private String isBrowser(File pic) throws Exception {
|
|
// System.out.println("picrecongnizeFolder=="+browserFolder);
|
|
// System.out.println("picrecongnizeFolder=="+browserFolder);
|
|
@@ -414,7 +501,6 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
File[] targetFile = subFolder.listFiles();
|
|
File[] targetFile = subFolder.listFiles();
|
|
boolean isMatch = false;
|
|
boolean isMatch = false;
|
|
for (File targetPic : targetFile) {
|
|
for (File targetPic : targetFile) {
|
|
-// System.out.println("targetPic==" + targetPic.getAbsolutePath());
|
|
|
|
boolean matchPic = ImageReconizeUtil.isTemplateMatch(pic.getAbsolutePath(), targetPic.getAbsolutePath());
|
|
boolean matchPic = ImageReconizeUtil.isTemplateMatch(pic.getAbsolutePath(), targetPic.getAbsolutePath());
|
|
if (matchPic) {
|
|
if (matchPic) {
|
|
isMatch = true;
|
|
isMatch = true;
|
|
@@ -466,11 +552,12 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
public static boolean isDocument(List<String> textContents) {
|
|
public static boolean isDocument(List<String> textContents) {
|
|
boolean find = false;
|
|
boolean find = false;
|
|
for (int i = 0; i < textContents.size() && i <= 2; i++) {//出现在前三行
|
|
for (int i = 0; i < textContents.size() && i <= 2; i++) {//出现在前三行
|
|
- String text = textContents.get(i);
|
|
|
|
- if (text.endsWith("Word")
|
|
|
|
- || text.endsWith("Excel")
|
|
|
|
- || text.endsWith("Power Point")
|
|
|
|
- || text.endsWith("Adobe Reader")) {
|
|
|
|
|
|
+ String text = textContents.get(i).trim();
|
|
|
|
+ if (text.contains("Word")
|
|
|
|
+ || text.contains("Excel")
|
|
|
|
+ || text.contains("Ecel")
|
|
|
|
+ || text.contains("Power Point")
|
|
|
|
+ || text.contains("Adobe Reader")) {
|
|
find = true;
|
|
find = true;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -485,7 +572,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
if (!pic.exists()) {
|
|
if (!pic.exists()) {
|
|
System.err.println("文件不存在" + pic.getAbsolutePath());
|
|
System.err.println("文件不存在" + pic.getAbsolutePath());
|
|
} else {
|
|
} else {
|
|
- System.out.println("找到文件" + pic.getAbsolutePath());
|
|
|
|
|
|
+ System.out.println("找到文件" + pic.getAbsolutePath());
|
|
}
|
|
}
|
|
BufferedImage img = ImageIO.read(pic);
|
|
BufferedImage img = ImageIO.read(pic);
|
|
int width = img.getWidth();
|
|
int width = img.getWidth();
|