|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.management.platform.constant.Constant;
|
|
import com.management.platform.constant.Constant;
|
|
|
|
+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.vo.ScreenshotVO;
|
|
import com.management.platform.entity.vo.ScreenshotVO;
|
|
@@ -11,6 +12,7 @@ import com.management.platform.mapper.ScreenshotMapper;
|
|
import com.management.platform.service.ScreenshotService;
|
|
import com.management.platform.service.ScreenshotService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.management.platform.util.*;
|
|
import com.management.platform.util.*;
|
|
|
|
+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;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -37,6 +39,8 @@ import java.util.Set;
|
|
@Transactional
|
|
@Transactional
|
|
public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screenshot> implements ScreenshotService {
|
|
public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screenshot> implements ScreenshotService {
|
|
|
|
|
|
|
|
+ public static Logger log = Logger.getLogger(ScreenshotServiceImpl.class);
|
|
|
|
+
|
|
@Value(value = "${upload.path}")
|
|
@Value(value = "${upload.path}")
|
|
private String path;
|
|
private String path;
|
|
|
|
|
|
@@ -46,6 +50,14 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
@Resource
|
|
@Resource
|
|
private ScreenshotMapper screenshotMapper;
|
|
private ScreenshotMapper screenshotMapper;
|
|
|
|
|
|
|
|
+ //获取所有人最新的截图
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg getLatestScreenshotList() {
|
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
+ httpRespMsg.data = screenshotMapper.getLatestScreenshotList();
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg saveAndProcessImage(ScreenshotVO screenshotvo) {
|
|
public HttpRespMsg saveAndProcessImage(ScreenshotVO screenshotvo) {
|
|
String filePath = UploadFileToFileNameUtil.uploadFile(screenshotvo.getFile(), path);
|
|
String filePath = UploadFileToFileNameUtil.uploadFile(screenshotvo.getFile(), path);
|
|
@@ -54,13 +66,14 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
screenshot.setPicUrl(filePath);
|
|
screenshot.setPicUrl(filePath);
|
|
screenshot.setDateStr(DateTimeFormatter.ofPattern("yyyy-MM-dd").format(screenshotvo.getIndate()));
|
|
screenshot.setDateStr(DateTimeFormatter.ofPattern("yyyy-MM-dd").format(screenshotvo.getIndate()));
|
|
String accessToken = "";
|
|
String accessToken = "";
|
|
- if (redisUtil.existsKey("accessToken")) {
|
|
|
|
- accessToken = redisUtil.getKey("accessToken");
|
|
|
|
|
|
+ if (redisUtil.existsKey(Parameter.ACCESS_TOKEN.getName())) {
|
|
|
|
+ accessToken = redisUtil.getKey(Parameter.ACCESS_TOKEN.getName());
|
|
} else {
|
|
} else {
|
|
Map<String, Object> map = AuthService.getAuth(Constant.API_KEY, Constant.SECRET_KEY);
|
|
Map<String, Object> map = AuthService.getAuth(Constant.API_KEY, Constant.SECRET_KEY);
|
|
- accessToken = (String) map.get("access_token");
|
|
|
|
- redisUtil.setKeyWithExpireTime("accessToken", accessToken, (Long) map.get("expires_in"));
|
|
|
|
|
|
+ accessToken = (String) map.get(Parameter.ACCESS_TOKEN.getName());
|
|
|
|
+ redisUtil.setKeyWithExpireTime(Parameter.ACCESS_TOKEN.getName(), accessToken, (Long) map.get(Parameter.EXPIRES_IN.getName()));
|
|
}
|
|
}
|
|
|
|
+ log.info("accessToken-->" + accessToken);
|
|
//利用token去检测
|
|
//利用token去检测
|
|
// DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
// DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
// LocalDateTime l = LocalDateTime.parse("2019-02-03",dateTimeFormatter);
|
|
// LocalDateTime l = LocalDateTime.parse("2019-02-03",dateTimeFormatter);
|
|
@@ -68,19 +81,20 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
|
|
List<String> textContents = (List<String>) picResultMap.get("wordsList");
|
|
List<String> textContents = (List<String>) picResultMap.get("wordsList");
|
|
screenshot.setPicContext((String) picResultMap.get("picContent"));
|
|
screenshot.setPicContext((String) picResultMap.get("picContent"));
|
|
Set<Object> members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
|
|
Set<Object> members = redisUtil.members(Constant.COMMON_SOFTWARE_KEYWORDS);
|
|
|
|
+ List<String> exeprocessList = ProcessUtil.getExeprocessListfromProcessStr(screenshotvo.getProcessList());
|
|
for (String textContent : textContents) {
|
|
for (String textContent : textContents) {
|
|
for (Object member : members) {
|
|
for (Object member : members) {
|
|
//由于redis里存储的member是一个PicContentKeywords类型的json字符串,所以取出关键字内容比较
|
|
//由于redis里存储的member是一个PicContentKeywords类型的json字符串,所以取出关键字内容比较
|
|
JSONObject jsonMember = JSON.parseObject((String) member);
|
|
JSONObject jsonMember = JSON.parseObject((String) member);
|
|
- System.out.println(jsonMember.getString("content"));
|
|
|
|
- System.out.println("textContent----->"+textContent);
|
|
|
|
- if (textContent.contains(jsonMember.getString("content"))) {
|
|
|
|
- System.out.println("进来了判断=====");
|
|
|
|
- System.out.println("content=====" + jsonMember.getString("content"));
|
|
|
|
- System.out.println("textContent=====" + textContent);
|
|
|
|
- //包含关键字们可以简单认为是在用常用开发软件
|
|
|
|
- //确定图片是哪个类型的图片
|
|
|
|
- screenshot.setPicType(jsonMember.getInteger("type"));
|
|
|
|
|
|
+ if (textContent.toLowerCase().contains(jsonMember.getString("content").toLowerCase())) {
|
|
|
|
+ log.info("图片文字中包含了关键词--->" + jsonMember.getString("content"));
|
|
|
|
+ log.info("图片文字识别出的类型--->" + jsonMember.getInteger("type"));
|
|
|
|
+ //找到对应关键字,确定图片是哪个类型的图片
|
|
|
|
+ //结合进程判断
|
|
|
|
+ if (exeprocessList.contains(jsonMember.getString("processName").toLowerCase())) {
|
|
|
|
+ log.info("图片中关键字对应的进程名--->" + jsonMember.getString("processName"));
|
|
|
|
+ screenshot.setPicType(jsonMember.getInteger("type"));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|