Parcourir la source

Merge branch 'master' of http://47.100.37.243:10080/wutt/manHourHousekeeper

# Conflicts:
#	fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/UserService.java
wutt il y a 5 ans
Parent
commit
5f57cf4661

+ 13 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ScreenshotServiceImpl.java

@@ -123,7 +123,9 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
     @Override
     public HttpRespMsg saveAndProcessImage(ScreenshotVO screenshotvo) {
         System.out.println("uid===" + screenshotvo.getUid());
-        String filePath = UploadFileToFileNameUtil.uploadFile(screenshotvo.getFile(), path);
+        System.out.println("path===" + path);
+        Map<String, Object> fileMap = UploadFileToFileNameUtil.uploadFile(screenshotvo.getFile(), path);
+        String filePath = (String)fileMap.get("sqlFilePath");
         Screenshot screenshot = new Screenshot();
         BeanUtils.copyProperties(screenshotvo, screenshot);
         screenshot.setPicUrl(filePath);
@@ -198,14 +200,14 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
         screenshot.setIsHandle(1);
         if (screenshot.getPicType() == null) {
             //判断是否是娱乐:看电影, 打游戏
-            if (isEntertainment(new File(filePath))) {
+            if (isEntertainment(new File((String)fileMap.get("newFile")))) {
                 screenshot.setPicType(7);
             }
         }
         if (screenshot.getPicType() == null) {
             //默认设置为查资料
             try {
-                String browserName = isBrowser(new File(filePath));
+                String browserName = isBrowser(new File((String)fileMap.get("newFile")));
                 System.out.println(
                         "找到浏览器==" + browserName
                 );
@@ -315,6 +317,11 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
     public static boolean isEntertainment(File pic) {
         try {
             int[] rgb = new int[3];
+            if (!pic.exists()) {
+                System.err.println("文件不存在" + pic.getAbsolutePath());
+            } else {
+                System.out.println("找到文件"  + pic.getAbsolutePath());
+            }
             BufferedImage img = ImageIO.read(pic);
             int width = img.getWidth();
             int height = img.getHeight();
@@ -442,9 +449,9 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
     //每次获取到截屏后计算并处理
     private void calculateTime(Screenshot screenshot) {
         try {
-            //如果图片类型为空 则认为是0-编程
-            if(screenshot.getPicType() == null){
-                screenshot.setPicType(0);
+            //如果图片类型为空 则认为是-1-其他
+            if(null == screenshot.getPicType()){
+                screenshot.setPicType(-1);
             }
             //默认状态为不连续 如果下面判断是连续才会修改为true
             Boolean isConsecutive = false;

+ 8 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/UploadFileToFileNameUtil.java

@@ -4,6 +4,8 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.UUID;
 
 /**
@@ -14,7 +16,8 @@ import java.util.UUID;
  */
 public class UploadFileToFileNameUtil {
 
-    public static String uploadFile(MultipartFile file, String path) {
+    public static Map<String, Object> uploadFile(MultipartFile file, String path) {
+        Map<String,Object> map = new HashMap<String, Object>();
         String afterUploadFileName = "";
         if (file != null) {
             File dir = null;
@@ -32,10 +35,12 @@ public class UploadFileToFileNameUtil {
                 String sufix = fileName.substring(pos);
                 fileName = rand + sufix;
                 afterUploadFileName = "/upload/" + fileName;
+                map.put("sqlFilePath",afterUploadFileName);
                 File saveFile = new File(dir, fileName);
                 try {
                     saveFile.createNewFile();
                     file.transferTo(saveFile);
+                    map.put("newFile",saveFile.getAbsolutePath());
                 } catch (IOException e) {
                     e.printStackTrace();
                 } catch (Exception e) {
@@ -43,6 +48,7 @@ public class UploadFileToFileNameUtil {
                 }
             }
         }
-        return afterUploadFileName;
+
+        return map;
     }
 }