From 203223860baa19deb6860eb2ba3181910d662980 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期四, 17 四月 2025 14:22:59 +0800
Subject: [PATCH] 1. 轮灌组被终止时灌溉时长为实际数值。2. 计划历史表按照创建时间倒排序。3. 发布计划时判断是否同项目下未完成计划,是否其他项目下使用了本计划的轮灌组且计划未完成。4. 根据计划ID获取计划最新状态。
---
pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/files/FileCtrl.java | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/files/FileCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/files/FileCtrl.java
index f8e6734..02626f9 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/files/FileCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/files/FileCtrl.java
@@ -3,14 +3,16 @@
import com.dy.common.util.NumUtil;
import com.dy.pipIrrWebFile.util.*;
import lombok.extern.slf4j.Slf4j;
+import org.jcodec.scale.AWTUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
-import java.io.File;
-import java.io.InputStream;
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.*;
/**
* web鏂囦欢涓婁紶, 鍐呴儴璋冪敤锛屽嵆鐢卞叾浠栧瓙妯″潡璋冪敤锛�
@@ -24,6 +26,9 @@
@Value("${dy.photoZipWidth}")
private String photoZipWidthStr ;
+
+ private static final String VideoZipPicFileType = "jpg";
+ private static final Integer VideoZipPicFromFrame = 5 ;
/**
* web鍒嗗竷寮忔枃浠剁郴缁熶繚瀛樼収鐗囨枃浠�
@@ -65,7 +70,7 @@
String zipFilePath1 = filePath.substring(0, index) ;
String zipFilePath2 = filePath.substring(index) ;
String zipFilePath = zipFilePath1 + "_" + zipFilePath2 ;
- InputStream zipFileInput = null ;
+ InputStream zipFileInput ;
if(zipFilePath2.equalsIgnoreCase(".png")){
zipFileInput = ZipImg.zipToPng(fPic, photoZipWidth, photoZipWidth) ;
}else{
@@ -152,6 +157,26 @@
String filePath = absolutePath + fileRelativePath ;
if(!fUtil.saveFile(filePath, input)){
fileRelativePath = null ;
+ }else {
+ //瀛樺偍鎴愬姛, 鐢熸垚缂╃暐鍥�
+ BufferedImage bufImg = new VideoUtils(VideoZipPicFileType, VideoZipPicFromFrame).fetchFrame(file) ;
+ // 鍚戝彸鏃嬭浆90搴�
+ // bufImg = AWTUtil.rotate90ToRight(bufImg) ;
+ String zipFilePath = filePath.substring(0, filePath.lastIndexOf(".")) + "_." + VideoZipPicFileType ;
+ Integer photoZipWidth = 400 ;
+ if(photoZipWidthStr != null && NumUtil.isPlusIntNumber(photoZipWidthStr)){
+ photoZipWidth = Integer.parseInt(photoZipWidthStr) ;
+ }
+ InputStream zipFileInput = ZipImg.zipToJpg(bufImg, photoZipWidth, photoZipWidth) ;
+ if(zipFileInput.available() > 0){
+ new FileUtil().saveFile(zipFilePath, zipFileInput) ;
+ }else{
+ //濡傛灉鍘嬬缉鏂囦欢涓嶅瓨鍦ㄦ垨鐢熸垚澶辫触锛屽垯澶嶅埗婧愭枃浠�
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ ImageIO.write(bufImg, VideoZipPicFileType, os);
+ InputStream in = new ByteArrayInputStream(os.toByteArray());
+ new FileUtil().saveFile(zipFilePath, in) ;
+ }
}
}
}
@@ -199,4 +224,31 @@
return fileRelativePath ;
}
+
+ public static void main(String[] args) throws Exception{
+ String photoZipWidthStr = "400" ;
+ String VideoZipPicFileType = "jpg";
+ //瀛樺偍鎴愬姛, 鐢熸垚缂╃暐鍥�
+ String filePath = "D:\\mp4\\test.mp4" ;
+ BufferedImage bufImg = new VideoUtils("jpg", 0).fetchFrame(filePath) ;
+ int index = filePath.lastIndexOf(".") ;
+ String basePath = filePath.substring(0, index) ;
+ Integer photoZipWidth = 400 ;
+ if(photoZipWidthStr != null && NumUtil.isPlusIntNumber(photoZipWidthStr)){
+ photoZipWidth = Integer.parseInt(photoZipWidthStr) ;
+ }
+ String zipFilePath = basePath + "_." + VideoZipPicFileType ;
+ InputStream zipFileInput = null ;
+ zipFileInput = ZipImg.zipToJpg(bufImg, photoZipWidth, photoZipWidth) ;
+ if(zipFileInput.available() > 0){
+ new FileUtil().saveFile(zipFilePath, zipFileInput) ;
+ }else{
+ //濡傛灉鍘嬬缉鏂囦欢涓嶅瓨鍦ㄦ垨鐢熸垚澶辫触锛屽垯澶嶅埗婧愭枃浠�
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ ImageIO.write(bufImg, VideoZipPicFileType, os);
+ InputStream in = new ByteArrayInputStream(os.toByteArray());
+ new FileUtil().saveFile(zipFilePath, in) ;
+ }
+ }
+
}
--
Gitblit v1.8.0