From c19de84fa332a00c651f28e3a52292fd14f143a1 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期二, 23 九月 2025 17:30:07 +0800
Subject: [PATCH] 陆常丽反应软件系统财务对账时而数据不准确,分析源码,找到bug原因是,财务对账统计只有用户点击后才会触发统计功能,把历史上及当天进行了统计,如果当天统计时未下班,例如是中午触发统计了,而下午又进行了充值售水,但下班后未再点击触发对账统计,那么今天的对账统计完成了但数据不对。编写自动任务,在下半夜进行对账统计。
---
pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/ZipImg.java | 81 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 81 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/ZipImg.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/ZipImg.java
new file mode 100644
index 0000000..fecc46f
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/ZipImg.java
@@ -0,0 +1,81 @@
+package com.dy.pipIrrWebFile.util;
+
+import net.coobird.thumbnailator.Thumbnails;
+
+import javax.imageio.ImageIO;
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+
+/**
+ * 鐢熸垚鍥剧墖鐨勭缉鐣ュ浘
+ */
+public class ZipImg {
+ public static InputStream zipToJpg(File file, int xSize, int ySize) throws Exception{
+ return zip(file, "jpg", xSize, ySize) ;
+ }
+
+ public static InputStream zipToJpg(BufferedImage buf, int xSize, int ySize) throws Exception{
+ return zip(buf, "jpg", xSize, ySize) ;
+ }
+
+ public static InputStream zipToPng(File file, int xSize, int ySize) throws Exception{
+ return zip(file, "png", xSize, ySize) ;
+ }
+
+ public static InputStream zipToPng(BufferedImage buf, int xSize, int ySize) throws Exception{
+ return zip(buf, "png", xSize, ySize) ;
+ }
+
+ public static void zipToFile(File file, File toFile, int xSize, int ySize) throws Exception{
+ Thumbnails.of(file).size(xSize, ySize).outputQuality(0.5f).toFile(toFile);//0f-1f 璐ㄩ噺瓒婇珮
+ }
+
+
+ private static InputStream zip(File file, String type, int xSize, int ySize) throws Exception{
+ BufferedImage bi = Thumbnails.of(file).size(xSize, ySize).outputQuality(1f).asBufferedImage();
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ ImageIO.write(bi, type, os);
+ InputStream in = new ByteArrayInputStream(os.toByteArray());
+ bi = null ;
+ os = null ;
+ return in ;
+ }
+
+ private static InputStream zip(BufferedImage buf, String type, int xSize, int ySize) throws Exception{
+ BufferedImage bi = Thumbnails.of(buf).size(xSize, ySize).outputQuality(1f).asBufferedImage();
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ ImageIO.write(bi, type, os);
+ InputStream in = new ByteArrayInputStream(os.toByteArray());
+ bi = null ;
+ os = null ;
+ return in ;
+ }
+
+ public static void main(String[] args){
+ File f = new File("D:/test.jpg") ;
+ String name = f.getName() ;
+ String path = f.getPath() ;
+ System.out.println(name);
+ System.out.println(path);
+
+ int index = path.lastIndexOf(".") ;
+ String s1 = path.substring(0, index) ;
+ String s2 = path.substring(index) ;
+ System.out.println(s1);
+ System.out.println(s2);
+
+ String newFilePath = s1 + "_" + s2 ;
+ try {
+ InputStream input = zipToJpg(f, 400, 400) ;
+ new FileUtil().saveFile(newFilePath, input) ;
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+}
--
Gitblit v1.8.0