Browse Source

1.修复 由于 OSS 中 文件名 转换 源文件大小 中 文件名未去除"/"以及文件后缀 导致的转换错误

xuzip 2 months ago
parent
commit
8e3d442e22

+ 48 - 3
src/main/java/com/yeechart/dotMatrix/signage/SignageFileUtil.java

@@ -136,7 +136,7 @@ public class SignageFileUtil {
             String fileName = null;
             Integer ogSize = null;
 
-            byte[] data1 = new byte[ SignageDrawUtil.height * SignageDrawUtil.width ] ;//默认使用完整图
+            byte[] data1 = new byte[ SignageDrawUtil.height * SignageDrawUtil.width + 4] ;//默认使用完整图
 
             int length = 0;
 
@@ -145,13 +145,16 @@ public class SignageFileUtil {
             for (Map.Entry<String, byte[]> entry : sortedMap.entrySet()) {
                 fileName = entry.getKey();
 
-                ogSize = TypeCodeUtil.fileNameToLastFileSize(fileName);
+                ogSize = SignageFileUtil.fileNameToLastFileSize(fileName);
+
+//                System.out.println("文件大小 ogSize " +ogSize+"  fileName " +fileName);
 
                 byte[] dataBytes = entry.getValue();
 
                 //解压缩
                 byte[] dataBytes2 = new byte[ogSize];
                 MInt outL2 = new MInt();
+
                 MiniLZO.lzo1x_decompress(dataBytes, ogSize, dataBytes2, outL2);
 
 //                logger.info("解压缩后的长度 outLen  len:" +outL2.v);
@@ -167,7 +170,7 @@ public class SignageFileUtil {
 
             }
             byte[] data  ;
-            if(length == SignageDrawUtil.height * SignageDrawUtil.width){
+            if(length == SignageDrawUtil.height * SignageDrawUtil.width + 4){
                 data = data1;
             }else{
                 data = new byte[length ] ;
@@ -274,4 +277,46 @@ public class SignageFileUtil {
     }
 
 
+
+
+
+    /**
+     * 由于不使用数据库以及,OSS中不能存在原字节大小的问题
+     * 根据type 得到最后一个文件的大小
+     * @param fileName
+     * @return
+     */
+    public static int fileNameToLastFileSize(String fileName){
+
+        /**
+         *  03 8884
+         * 000000 01010100 01010101 00010000 00010001
+         * 010001FF00 010001FF01 010001FF02 010001FF03 010001FF04   010001FF05 010001FFFE
+         * 02 3764
+         * 0100010000 0100010001 0100010002 0100010003 0100010004 0100010005
+         * 01000100FE 01000101FF 01000102FF 01000103FF
+         */
+
+        fileName = fileName.replace(ROOT_FILE_TYPE_NAME,"");
+        fileName = fileName.replace("/","");
+
+        String typeCode = fileName.substring(0,fileName.length()-2);
+
+        int fileNumber = Integer.parseInt(fileName.substring(fileName.length()-2));
+        if(fileNumber <=1){
+            return 10000;
+        }
+        if( typeCode.startsWith("00") // 关机画面
+                ||  "01".equals(typeCode.substring(2,4)) //右屏相关
+                ||  "FF".equals(typeCode.substring(typeCode.length() - 4,typeCode.length() - 2))//倒数第二个为FF
+        ){
+            if(fileNumber ==2 ){
+                return 10000;
+            }
+            return 8884;
+        }else{
+            return 3764;
+        }
+    }
+
 }

+ 0 - 32
src/main/java/com/yeechart/dotMatrix/signage/TypeCodeUtil.java

@@ -223,36 +223,4 @@ public class TypeCodeUtil {
 
     }
 
-
-    /**
-     * 由于不使用数据库以及,OSS中不能存在原字节大小的问题
-     * 根据type 得到最后一个文件的大小
-     * @param fileName
-     * @return
-     */
-    public static int fileNameToLastFileSize(String fileName){
-
-        /**
-         *  03 8884
-         * 000000 01010100 01010101 00010000 00010001
-         * 010001FF00 010001FF01 010001FF02 010001FF03 010001FF04   010001FF05 010001FFFE
-         * 02 3764
-         * 0100010000 0100010001 0100010002 0100010003 0100010004 0100010005
-         * 01000100FE 01000101FF 01000102FF 01000103FF
-         */
-
-        String typeCode = fileName.substring(0,fileName.length()-2);
-        int fileNumber = Integer.parseInt(fileName.substring(fileName.length()-2));
-        if(fileNumber <=1){
-            return 10000;
-        }
-        if( typeCode.startsWith("00") // 关机画面
-                ||  "01".equals(typeCode.substring(2,4)) //右屏相关
-                ||  "FF".equals(typeCode.substring(typeCode.length() - 4,typeCode.length() - 24))//倒数第二个为FF
-            ){
-            return 8884;
-        }else{
-            return 3764;
-        }
-    }
 }