瀏覽代碼

压缩图片

Levi 3 年之前
父節點
當前提交
ac686feab4

+ 7 - 2
src/main/java/com/ebei/screen/common/util/ParkUtils.java

@@ -411,13 +411,18 @@ public class ParkUtils {
      * 获取附件图片字节数组
      *
      * @param photo
+     * @param flag  是否开启压缩 true开启
      * @return
      */
-    public static byte[] getExcelPhotoUrl(Object photo) {
+    public static byte[] getExcelPhotoUrl(Object photo, boolean flag) {
         try {
             String url = (String) photo;
             String imgUrlById = getImgUrlById(url);
-            return StringUtils.isNotBlank(imgUrlById) ? imageSet(Base64.getDecoder().decode(imgUrlById)) : null;
+            if (flag) {
+                return StringUtils.isNotBlank(imgUrlById) ? imageSet(Base64.getDecoder().decode(imgUrlById)) : null;
+            } else {
+                return StringUtils.isNotBlank(imgUrlById) ? Base64.getDecoder().decode(imgUrlById) : null;
+            }
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 1 - 1
src/main/java/com/ebei/screen/service/impl/ParkSystemServiceImpl.java

@@ -889,7 +889,7 @@ public class ParkSystemServiceImpl implements ParkSystemService {
                 List<Map> objects = dataList != null ? dataList.toJavaList(Map.class) : new ArrayList<>();
                 List<Map> maps = ParkUtils.sortDateList(objects, ParkType.EXCEPTION.getSort(), true);
                 if (CollUtil.isNotEmpty(maps)) {
-                    maps.forEach(x -> x.put("photoUrl", ParkUtils.getExcelPhotoUrl(x.get("imageUrl") == null ? (x.get("outCarPhoto") == null ? x.get("inCarPhoto") : x.get("outCarPhoto")) : x.get("imageUrl"))));
+                    maps.forEach(x -> x.put("photoUrl", ParkUtils.getExcelPhotoUrl(x.get("imageUrl") == null ? (x.get("outCarPhoto") == null ? x.get("inCarPhoto") : x.get("outCarPhoto")) : x.get("imageUrl"), paramsCode.equals("noCard"))));
                 }
                 InputStream inputStream = ResourceUtil.getStream("temp/exception.xlsx");
                 File ex = File.createTempFile("exception", ".xlsx");