|
@@ -255,7 +255,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,7 +291,8 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
|
// //由于存入数据库的对象被序列化成了json字符串,所以从redis里拿方便
|
|
|
// members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
|
|
|
// }
|
|
|
- File picFile = new File((String) fileMap.get("newFile"));
|
|
|
+ File picFile = new File((String)fileMap.get("newFile"));
|
|
|
+ System.out.println("File:"+picFile.getAbsolutePath());
|
|
|
if (isNovel(textContents)) {
|
|
|
screenshot.setPicType(6);
|
|
|
} else if (isDocument(textContents)) {
|
|
@@ -309,7 +310,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 +324,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);
|
|
|
}
|
|
@@ -341,11 +339,34 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
|
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
|
|
|
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");
|
|
@@ -427,6 +448,8 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
|
// System.out.println("结果:"+b);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
private static boolean isPureColor(BufferedImage img, int colorPixel) {
|
|
|
int with = img.getWidth();
|
|
|
int height = img.getHeight();
|
|
@@ -476,7 +499,6 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
|
File[] targetFile = subFolder.listFiles();
|
|
|
boolean isMatch = false;
|
|
|
for (File targetPic : targetFile) {
|
|
|
-// System.out.println("targetPic==" + targetPic.getAbsolutePath());
|
|
|
boolean matchPic = ImageReconizeUtil.isTemplateMatch(pic.getAbsolutePath(), targetPic.getAbsolutePath());
|
|
|
if (matchPic) {
|
|
|
isMatch = true;
|
|
@@ -529,11 +551,11 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
|
boolean find = false;
|
|
|
for (int i = 0; i < textContents.size() && i <= 2; i++) {//出现在前三行
|
|
|
String text = textContents.get(i).trim();
|
|
|
- if (text.endsWith("Word")
|
|
|
- || text.endsWith("Excel")
|
|
|
- || text.endsWith("Ecel")
|
|
|
- || text.endsWith("Power Point")
|
|
|
- || text.endsWith("Adobe Reader")) {
|
|
|
+ if (text.contains("Word")
|
|
|
+ || text.contains("Excel")
|
|
|
+ || text.contains("Ecel")
|
|
|
+ || text.contains("Power Point")
|
|
|
+ || text.contains("Adobe Reader")) {
|
|
|
find = true;
|
|
|
break;
|
|
|
}
|