Sfoglia il codice sorgente

影像压缩修改

BifronsV 3 anni fa
parent
commit
db972c2772

+ 0 - 10
pom.xml

@@ -554,16 +554,6 @@
                 <version>3.1.0</version>
             </plugin>
 
-            <plugin>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.8.1</version>
-                <configuration>
-                    <compilerArguments>
-                        <verbose />
-                        <bootclasspath>${java.home}/lib/rt.jar;${java.home}/lib/jce.jar</bootclasspath>
-                    </compilerArguments>
-                </configuration>
-            </plugin>
 <!--            <plugin>-->
 <!--                <groupId>org.apache.maven.plugins</groupId>-->
 <!--                <artifactId>maven-compiler-plugin</artifactId>-->

+ 2 - 2
src/main/java/com/ydtech/modules/order/entity/api/zm/request/QuotedPriceRequest.java

@@ -297,9 +297,9 @@ public class QuotedPriceRequest extends BaseRequest {
                 LocalDate localDate = LocalDate.parse(startDate, formatter);
                 LocalDate nextYears = localDate.plus(1, ChronoUnit.YEARS);
                 if (startDate.contains(TimeConstants.START_TIME)) {
-                    LocalDate expiryDate = nextYears.minus(1, ChronoUnit.DAYS);
+                    LocalDate expiry = nextYears.minus(1, ChronoUnit.DAYS);
                     this.validDate = riskInfoVo.getStartDate();
-                    this.expiryDate = expiryDate + " " + TimeConstants.END_TIME;
+                    this.expiryDate = expiry + " " + TimeConstants.END_TIME;
                     this.reinsuranceFlag = "0";
                 } else {
                     // 及时

+ 4 - 2
src/main/java/com/ydtech/modules/order/service/impl/InsUploadFilesServiceImpl.java

@@ -23,6 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.*;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.UUID;
 
 /**
  * @author wenks
@@ -73,19 +74,20 @@ public class InsUploadFilesServiceImpl extends ServiceImpl<InsUploadFilesMapper,
         // 存储路劲
         String storagePath = uploadPath + objectName;
         File file = new File(storagePath);
+        insUploadFiles.setFilePath(storagePath);
         try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
             if (FileType.IMAGE.getType().equals(type)){
                 // 图片格式需要压缩
                 byte[] compressPicByte = ImageCompressionUtils.compressPic(multipartFile.getInputStream(), suffix, uploadFilePath);
                 byte[] bytes = ImageCompressionUtils.compressPicForScale(compressPicByte, 100);
                 fileOutputStream.write(bytes);
-                insUploadFiles.setFilePath(storagePath);
             }else {
-                multipartFile.transferTo(file);
+                fileOutputStream.write(multipartFile.getBytes());
             }
             save(insUploadFiles);
             return insUploadFiles;
         } catch (Exception e) {
+            e.printStackTrace();
             log.info("上传过程中出错:{}", e.getMessage());
             throw new SystemException("上传过程中出错" + e.getMessage());
         }

+ 1 - 5
src/main/java/com/ydtech/utils/ImageCompressionUtils.java

@@ -1,8 +1,5 @@
 package com.ydtech.utils;
 
-import cn.hutool.core.io.IoUtil;
-import com.sun.image.codec.jpeg.JPEGCodec;
-import com.sun.image.codec.jpeg.JPEGImageEncoder;
 import com.ydtech.exception.SystemException;
 import lombok.extern.slf4j.Slf4j;
 import net.coobird.thumbnailator.Thumbnails;
@@ -52,8 +49,7 @@ public class ImageCompressionUtils {
             int height = image.getHeight();
             BufferedImage bfImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
             bfImage.getGraphics().drawImage(image.getScaledInstance(width, height, Image.SCALE_SMOOTH), 0, 0, null);
-            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
-            encoder.encode(bfImage);
+            ImageIO.write(bfImage, suffix.replace(".", ""), os);
         } catch (IOException e) {
             e.printStackTrace();
         }