|
@@ -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
|
|
|
*
|