Browse Source

小修改

xiaoshushu 4 years ago
parent
commit
8278a65eab

+ 1 - 1
ruoyi-app/src/main/java/com/ruoyi/app/controller/base/AppCommonController.java

@@ -1,9 +1,9 @@
 package com.ruoyi.app.controller.base;
 
-import com.ruoyi.app.util.ImageCompressUtil;
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.ImageCompressUtil;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.common.utils.file.FileUtils;

+ 16 - 15
ruoyi-app/src/main/java/com/ruoyi/app/util/ImageCompressUtil.java → ruoyi-common/src/main/java/com/ruoyi/common/utils/ImageCompressUtil.java

@@ -1,17 +1,14 @@
-package com.ruoyi.app.util;
+package com.ruoyi.common.utils;
 
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.Image;
+import javax.imageio.ImageIO;
+import java.awt.*;
 import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 
-import javax.imageio.ImageIO;
-
 /**
- * 图片压缩
+ * 图片等比例压缩
  */
 public class ImageCompressUtil {
     /**
@@ -34,22 +31,26 @@ public class ImageCompressUtil {
             int w1 = w;
             int h1 = h;
             //对于小400分辨率的图不压缩
-            if (w < 1000 && w > 400) {
-                w1 = (int) (w - w * 0.3);
-                h1 = (int) (h - h * 0.3);
+            if (w < 300 && w > 100) {
+                w1 = (int) (w - w * 0.35);
+                h1 = (int) (h - h * 0.35);
             }
-            if (w < 1600 && w > 1000) {
+            if (w < 1000 && w > 300) {
                 w1 = (int) (w - w * 0.45);
                 h1 = (int) (h - h * 0.45);
             }
-            if (w < 2500 && w > 1600) {
-                w1 = (int) (w - w * 0.6);
-                h1 = (int) (h - h * 0.6);
+            if (w < 1600 && w > 1000) {
+                w1 = (int) (w - w * 0.65);
+                h1 = (int) (h - h * 0.65);
             }
-            if (w > 2500) {
+            if (w < 2500 && w > 1600) {
                 w1 = (int) (w - w * 0.75);
                 h1 = (int) (h - h * 0.75);
             }
+            if (w > 2500) {
+                w1 = (int) (w - w * 0.9);
+                h1 = (int) (h - h * 0.9);
+            }
             String srcImgPath = newFile.getAbsoluteFile().toString();
             String subfix = "jpg";
             subfix = srcImgPath.substring(srcImgPath.lastIndexOf(".") + 1, srcImgPath.length());

+ 1 - 1
ruoyi-common/src/main/java/com/ruoyi/common/utils/PushUtil.java

@@ -116,7 +116,7 @@ public class PushUtil {
         style.setChannelLevel(3); //设置通知渠道重要性
         template.setStyle(style);
 
-        template.setTransmissionType(2);  // 透传消息接受方式设置,1:立即启动APP,2:客户端收到消息后需要自行处理
+        template.setTransmissionType(1);  // 透传消息接受方式设置,1:立即启动APP,2:客户端收到消息后需要自行处理
         JSONObject obj=new JSONObject();
         obj.put("title",title);
         obj.put("text",text);