From 8456b4e16a9fe4284c45b6d56d7dabeea1cb18e9 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期六, 19 十月 2024 11:21:44 +0800 Subject: [PATCH] 增加了分布式web文件系统 --- pipIrr-platform/pipIrr-web/pipIrr-web-file/.mvn/wrapper/maven-wrapper.properties | 20 pipIrr-platform/pipIrr-web/pipIrr-web-file/mvnw.cmd | 149 ++ pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FilePhotoUtil.java | 39 pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/ZipImg.java | 63 pipIrr-platform/pipIrr-global/src/main/resources/application-global(test测试系统).yml | 158 ++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileConstant.java | 28 pipIrr-platform/pipIrr-web/pipIrr-web-file/.gitattributes | 2 pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/DyFileSvConf.java | 155 ++ pipIrr-platform/pipIrr-web/pipIrr-web-file/pom.xml | 142 ++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/webCtrls/说明.txt | 1 pipIrr-platform/pipIrr-web/pipIrr-web-file/.gitignore | 34 pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FileRestVo.java | 28 pipIrr-platform/pipIrr-global/src/main/resources/application-global(ym元谋系统).yml | 158 ++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileVo.java | 35 pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FmCtrl.java | 133 + pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/说明.txt | 1 pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileConstant.java | 13 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/NameValue.java | 26 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/webCtrls/WebFileSv.java | 26 pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/files/FileCtrl.java | 202 +++ pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/resources/application.yml | 16 pipIrr-platform/pipIrr-global/src/main/resources/mapper/WebFileMapper.xml | 126 + pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/resources/log4j2.yml | 71 + pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/webCtrls/WebFileCtrl.java | 250 +++ pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/MurmurHash.java | 302 ++++ pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FileNameIdUtil.java | 112 + pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileUtil.java | 122 + pipIrr-platform/pipIrr-web/pipIrr-web-file/src/test/java/com/dy/pipIrrWebFile/PipIrrWebFileApplicationTests.java | 13 pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/PipIrrWebFileApplication.java | 29 pipIrr-platform/pipIrr-web/pom.xml | 8 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoFi/WebFile.java | 73 + pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/download/DownloadFileCtrl.java | 109 + pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/download/DownloadFileSv.java | 30 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileRestVo.java | 44 pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileVideoUtil.java | 39 pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/RestHashDeal.java | 95 + pipIrr-platform/pipIrr-global/src/main/resources/application-global(开发测试---166PC机).yml | 158 ++ pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_83_Up.java | 4 pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileDocumentUtil.java | 46 pipIrr-platform/pipIrr-web/pipIrr-web-file/mvnw | 259 +++ pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/DyFmListener.java | 67 + pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileOperate.java | 301 ++++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoFi/WebFileMapper.java | 22 pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml | 158 ++ pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileIconUtil.java | 38 pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FilePhoneUtil.java | 41 pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FileName.java | 20 47 files changed, 3,965 insertions(+), 1 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_83_Up.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_83_Up.java index b1d6fb2..1592fc1 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_83_Up.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_83_Up.java @@ -196,7 +196,9 @@ public static void main(String[] args) throws Exception { Cd_83_Up obj = new Cd_83_Up() ; - String hex = "683C68B08485353448830200000000001000282353FE739444000001000313000101211615000101210000000000000000000200019000011518000101210A7B16"; + //涓嬮潰涓ゆ潯涓婃姤鏁版嵁锛孖C鍗$紪鐮侀兘鏄潪BCD缂栫爜鑰屽紓甯� + //String hex = "683C68B08485353448830200000000001000282353FE739444000001000313000101211615000101210000000000000000000200019000011518000101210A7B16"; + String hex = "683C68B05301154CEA8306001000000004343638483BBBB9E0001000001603000101215907000101210000000000000000000500019000015308000101210AF716"; byte[] bs = ByteUtil.hex2Bytes(hex) ; Data data = new Data() ; diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/MurmurHash.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/MurmurHash.java new file mode 100644 index 0000000..822c87c --- /dev/null +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/MurmurHash.java @@ -0,0 +1,302 @@ +package com.dy.common.util; + +/** + * MurmurHash绠楁硶锛氶珮杩愮畻鎬ц兘锛屼綆纰版挒鐜囷紝鐢盇ustin Appleby鍒涘缓浜�2008骞达紝 + * 鐜板凡搴旂敤鍒癏adoop銆乴ibstdc++銆乶ginx銆乴ibmemcached绛夊紑婧愮郴缁熴��2011骞� + * Appleby琚獹oogle闆囦剑锛岄殢鍚嶨oogle鎺ㄥ嚭鍏跺彉绉嶇殑CityHash绠楁硶銆� + * + * 瀹樻柟缃戠珯锛歨ttps://sites.google.com/site/murmurhash/ + * + * MurmurHash绠楁硶锛岃嚜绉拌秴绾у揩鐨刪ash绠楁硶锛屾槸FNV鐨�4-5鍊嶃�傚畼鏂规暟鎹涓嬶細 + * + * OneAtATime 鈥� 354.163715 mb/sec + * FNV 鈥� 443.668038 mb/sec + * SuperFastHash 鈥� 985.335173 mb/sec + * lookup3 鈥� 988.080652 mb/sec + * MurmurHash 1.0 鈥� 1363.293480 mb/sec + * MurmurHash 2.0 鈥� 2056.885653 mb/sec + * + * 浣嗕篃鏈夋枃绔犲0绉帮紝鍙湁褰搆ey鐨勯暱搴﹀ぇ浜�10瀛楄妭鐨勬椂鍊欙紝MurmurHash鐨勮繍绠楅�� + * 搴︽墠蹇簬DJB銆備粠璁$畻閫熷害涓婃潵鐪嬶紝MurmurHash鍙�傜敤浜庡凡鐭ラ暱搴︾殑銆侀暱搴︽瘮 + * 杈冮暱鐨勫瓧绗︺�� + * + * 鍝堝笇鍊煎垎甯冮潪甯稿潎鍖�锛屽嵆浣庣鎾炵巼 + * 姣擟rc16鏇翠负鍧囧寑 + */ +public final class MurmurHash { + + private byte[] toBytesWithoutEncoding(String str) { + int len = str.length(); + int pos = 0; + byte[] buf = new byte[len << 1]; + for (int i = 0; i < len; i++) { + char c = str.charAt(i); + buf[pos++] = (byte) (c & 0xFF); + buf[pos++] = (byte) (c >> 8); + } + return buf; + } + + /** + * 鍒樻鼎鐜夊鍔犳柟娉曚簬2016-12-02 + * @param data + * @param length + * @return + */ + public int hash16_plus(final byte[] data, int length) { + int hash = hash32(data, length, 0x9747b28c); + hash = hash % 65535 ; + if(hash < 0){ + hash = - hash ; + } + return hash ; + } + /** + * 鍒樻鼎鐜夊鍔犳柟娉曚簬2016-12-02 + * @param data + * @return + */ + public int hash16_plus(final String data) { + byte[] bytes = toBytesWithoutEncoding(data); + int hash = hash32(bytes, bytes.length, 0x9747b28c); + hash = hash % 65535 ; + if(hash < 0){ + hash = - hash ; + } + return hash ; + } + + /** + * Generates 32 bit hash from byte array with default seed value. + * @param data byte array to hash + * @param length length of the array to hash + * @return 32 bit hash of the given array + */ + public int hash32(final byte[] data, int length) { + return hash32(data, length, 0x9747b28c); + } + + public int hash32(final String data) { + byte[] bytes = toBytesWithoutEncoding(data); + return hash32(bytes, bytes.length, 0x9747b28c); + } + + /** + * Generates 64 bit hash from byte array with default seed value. + * @param data byte array to hash + * @param length length of the array to hash + * @return 64 bit hash of the given string + */ + public long hash64(final byte[] data, int length) { + return hash64(data, length, 0xe17a1465); + } + + + public long hash64(final String data) { + byte[] bytes = toBytesWithoutEncoding(data); + return hash64(bytes, bytes.length); + } + /** + * Generates 32 bit hash from byte array of the given length and seed. + * @param data byte array to hash + * @param length length of the array + * @param seed initial seed value + * @return 32 bit hash of the given array + */ + public int hash32(final byte[] data, int length, int seed) { + // 'm' and 'r' are mixing constants generated offline. + // They're not really 'magic', they just happen to work well. + final int m = 0x5bd1e995; + final int r = 24; + // Initialize the hash to a random value + int h = seed ^ length; + int length4 = length / 4; + for (int i = 0; i < length4; i++) { + final int i4 = i * 4; + int k = (data[i4 + 0] & 0xff) + ((data[i4 + 1] & 0xff) << 8) + + ((data[i4 + 2] & 0xff) << 16) + + ((data[i4 + 3] & 0xff) << 24); + k *= m; + k ^= k >>> r; + k *= m; + h *= m; + h ^= k; + } + // Handle the last few bytes of the input array + switch (length % 4) { + case 3: + h ^= (data[(length & ~3) + 2] & 0xff) << 16; + case 2: + h ^= (data[(length & ~3) + 1] & 0xff) << 8; + case 1: + h ^= (data[length & ~3] & 0xff); + h *= m; + } + h ^= h >>> 13; + h *= m; + h ^= h >>> 15; + return h; + } + /** + * Generates 64 bit hash from byte array of the given length and seed. + * @param data byte array to hash + * @param length length of the array to hash + * @param seed initial seed value + * @return 64 bit hash of the given array + */ + public long hash64(final byte[] data, int length, int seed) { + final long m = 0xc6a4a7935bd1e995L; + final int r = 47; + long h = (seed & 0xffffffffl) ^ (length * m); + int length8 = length / 8; + for (int i = 0; i < length8; i++) { + final int i8 = i * 8; + long k = ((long) data[i8 + 0] & 0xff) + + (((long) data[i8 + 1] & 0xff) << 8) + + (((long) data[i8 + 2] & 0xff) << 16) + + (((long) data[i8 + 3] & 0xff) << 24) + + (((long) data[i8 + 4] & 0xff) << 32) + + (((long) data[i8 + 5] & 0xff) << 40) + + (((long) data[i8 + 6] & 0xff) << 48) + + (((long) data[i8 + 7] & 0xff) << 56); + k *= m; + k ^= k >>> r; + k *= m; + h ^= k; + h *= m; + } + switch (length % 8) { + case 7: + h ^= (long) (data[(length & ~7) + 6] & 0xff) << 48; + case 6: + h ^= (long) (data[(length & ~7) + 5] & 0xff) << 40; + case 5: + h ^= (long) (data[(length & ~7) + 4] & 0xff) << 32; + case 4: + h ^= (long) (data[(length & ~7) + 3] & 0xff) << 24; + case 3: + h ^= (long) (data[(length & ~7) + 2] & 0xff) << 16; + case 2: + h ^= (long) (data[(length & ~7) + 1] & 0xff) << 8; + case 1: + h ^= (long) (data[length & ~7] & 0xff); + h *= m; + } + ; + h ^= h >>> r; + h *= m; + h ^= h >>> r; + return h; + } + public static void main(String[] args) { + test1() ; + test2() ; + } + + public static void test1() { + String regionNum = "110000" ; + String temp = "" ; + String rtuAddr = "" ; + + int total0 = 0 ; + int total1 = 0 ; + int total2 = 0 ; + int total3 = 0 ; + int total4 = 0 ; + int total5 = 0 ; + int totalx = 0 ; + int totaly = 0 ; + MurmurHash mhash = new MurmurHash() ; + Long start = System.currentTimeMillis() ; + for(int i = 0 ; i < 10000; i++){ + temp = "" + i ; + while(temp.length() < 5){ + temp = "0" + temp ; + } + rtuAddr = regionNum + temp ; + int hash = mhash.hash16_plus(rtuAddr) ; + if(hash < 0){ + total0++ ; + } + if(hash >= 0 && hash < 1000){ + total1++ ; + } + if(hash >= 1000 && hash < 2000){ + total2++ ; + } + if(hash >= 2000 && hash < 3000){ + total3++ ; + } + if(hash >= 3000 && hash < 4000){ + total4++ ; + } + if(hash >= 4000 && hash < 5000){ + total5++ ; + } + if(hash >= 64535 && hash < 65535){ + totalx++ ; + } + if(hash > 65535){ + totaly++ ; + } + //System.out.println(rtuAddr + "-" + crc); + } + Long end = System.currentTimeMillis() ; + System.out.println("鐢ㄦ椂" + ":" + (end - start)); + System.out.println("0浠ヤ笅" + ":" + total0); + System.out.println("0-1000" + ":" + total1); + System.out.println("1000-2000" + ":" + total2); + System.out.println("2000-3000" + ":" + total3); + System.out.println("3000-4000" + ":" + total4); + System.out.println("5000-6000" + ":" + total5); + System.out.println("64535-65535" + ":" + totalx); + System.out.println("65535浠ヤ笂" + ":" + totaly); + System.out.println("================="); + } + public static void test2() { + String regionNum = "110000" ; + String temp = "" ; + String rtuAddr = "" ; + + int total1 = 0 ; + int total2 = 0 ; + int total3 = 0 ; + int total4 = 0 ; + int total5 = 0 ; + MurmurHash mhash = new MurmurHash() ; + Long start = System.currentTimeMillis() ; + for(int i = 0 ; i < 10000; i++){ + temp = "" ; + temp = "" + i ; + while(temp.length() < 5){ + temp = "0" + temp ; + } + rtuAddr = regionNum + temp ; + int hash = mhash.hash32(rtuAddr) ; + if(hash > 0 && hash < 10000000){ + total1++ ; + } + if(hash >= 10000000 && hash < 20000000){ + total2++ ; + } + if(hash >= 20000000 && hash < 30000000){ + total3++ ; + } + if(hash >= 30000000 && hash < 40000000){ + total4++ ; + } + if(hash >= 40000000 && hash < 50000000){ + total5++ ; + } + //System.out.println(rtuAddr + "-" + crc); + } + Long end = System.currentTimeMillis() ; + System.out.println("鐢ㄦ椂" + ":" + (end - start)); + System.out.println("0-10000000" + ":" + total1); + System.out.println("10000000-20000000" + ":" + total2); + System.out.println("20000000-30000000" + ":" + total3); + System.out.println("30000000-40000000" + ":" + total4); + System.out.println("50000000-60000000" + ":" + total5); + System.out.println("================="); + } +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoFi/WebFileMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoFi/WebFileMapper.java new file mode 100644 index 0000000..41a8e63 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoFi/WebFileMapper.java @@ -0,0 +1,22 @@ +package com.dy.pipIrrGlobal.daoFi; + +import com.dy.pipIrrGlobal.pojoFi.WebFile; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface WebFileMapper { + int deleteByPrimaryKey(Long id); + + int insert(WebFile record); + + int insertSelective(WebFile record); + + WebFile selectByPrimaryKey(Long id); + + int updateByPrimaryKeySelective(WebFile record); + + int updateByPrimaryKey(WebFile record); + +} \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileConstant.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileConstant.java new file mode 100644 index 0000000..2450546 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileConstant.java @@ -0,0 +1,28 @@ +package com.dy.pipIrrGlobal.dyFile; + +public class FileConstant { + public static final String NotRegionNum = "-1"; //鍦╳eb鏂囦欢绯荤粺dyFile涓紝濡傛灉琛屾斂鍖哄垝鏄�"-1"锛屽垯璁や负涓嶅瓨鍦ㄨ鏀垮尯鍒掑睘鎬� + + public static final String fmRequestMapping = "fm" ;//controller 璺緞 + public static final String fmPostMapping_create = "create" ;//鏂规硶璺緞 + public static final String fmPostMapping_create_paramName = "fileExtName" ;//鍙傛暟鍚嶇О + public static final String fmPostMapping_parsePath = "parsePath" ;//鏂规硶璺緞 + public static final String fmPostMapping_parsePath_paramName = "filePath" ;//鍙傛暟鍚嶇О + public static final String fmPostMapping_parsePathList = "parsePathList" ;//鏂规硶璺緞 + public static final String fmPostMapping_parsePathList_paramName = "filePaths" ;//鍙傛暟鍚嶇О + public static final String fmPostMapping_parseHashcode = "parseHashcode" ;//鏂规硶璺緞 + public static final String fmPostMapping_parseHashcode_paramName = "hashCode" ;//鍙傛暟鍚嶇О + + public static final String fileRequestMapping = "file" ;//controller 璺緞 + public static final String filePostMapping_photo = "savePhoto" ;//鏂规硶璺緞 + public static final String filePostMapping_phone = "savePhone" ;//涓婁紶璇煶鎺ュ彛璺緞 + public static final String filePostMapping_video = "saveVideo" ;//涓婁紶褰曞儚鎺ュ彛璺緞 + public static final String filePostMapping_document = "saveDocument" ;//涓婁紶鏂囨。鎺ュ彛璺緞 + + public static final String filePostMapping_paramName_file = "file" ;//鍙傛暟鍚嶇О + public static final String filePostMapping_paramName_regionNum = "regionNum" ;//鍙傛暟鍚嶇О + public static final String filePostMapping_paramName_json = "json" ;//鍙傛暟鍚嶇О + public static final String filePostMapping_paramName_absolutePath = "absolutePath" ;//鍙傛暟鍚嶇О + public static final String filePostMapping_paramName_relativePath = "relativePath" ;//鍙傛暟鍚嶇О + public static final String filePostMapping_paramName_fileName = "fileName" ;//鍙傛暟鍚嶇О +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileOperate.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileOperate.java new file mode 100644 index 0000000..ae52a49 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileOperate.java @@ -0,0 +1,301 @@ +package com.dy.pipIrrGlobal.dyFile; + +import com.dy.common.util.NumUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.multipart.MultipartFile; + +import java.util.Arrays; +import java.util.List; + +@Component +public class FileOperate { + + @Autowired + private RestTemplate restTemplate ; + + /** + * 鎷嗗垎涓婅浇鏂囦欢鐨勫悕绉� + * @param file + * @return + */ + public String[] splitFileName(MultipartFile file){ + String[] grp = new String[2] ; + if(file != null) { + String fileName = file.getOriginalFilename(); + int lastDotIndex = fileName.lastIndexOf('.'); + if (lastDotIndex >= 0) { + grp[0] = fileName.substring(0, lastDotIndex); + grp[1] = fileName.substring(lastDotIndex + 1); + if(grp[0].trim().equals("")){ + grp[0] = "鍖垮悕" ; + } + } + } + return grp ; + } + + /** + * 寰楀埌涓婅浇鐨勬枃浠舵墿灞曞悕 + * @param file + * @return + */ + public String getFileExtName(MultipartFile file){ + String fileExtName = null ; + if(file != null) { + String filename = file.getOriginalFilename(); + int lastDotIndex = filename.lastIndexOf('.'); + if (lastDotIndex >= 0) { + fileExtName = filename.substring(lastDotIndex + 1); + } + } + return fileExtName ; + } + + /** + * 寰楀埌涓婅浇鐨勬枃浠朵富鍚� + * @param fileName + * @return + */ + public String getFileMainName(String fileName){ + String fileMainName = null ; + if(fileName != null) { + int lastDotIndex = fileName.lastIndexOf('.'); + if (lastDotIndex >= 0) { + fileMainName = fileName.substring(0, lastDotIndex); + } + } + if(fileMainName == null){ + fileMainName = "noName" ; + } + return fileMainName ; + } + + /** + * 閫氳繃鐓х墖璺緞锛屽緱鍒板搴旂缉鐣ュ浘鐨勮矾寰� + * @param imgPath + * @return + */ + public String getImgFileZipPath(String imgPath){ + String path_ = null ; + String prePath = null ; + String tailPath = null ; + if(imgPath != null && !imgPath.trim().equals("")) { + int lastDotIndex = imgPath.lastIndexOf('.'); + if (lastDotIndex >= 0) { + prePath = imgPath.substring(0, lastDotIndex); + tailPath = imgPath.substring(lastDotIndex); + path_ = prePath + "_" + tailPath ; + } + } + if(path_ == null){ + path_ = imgPath ; + } + return path_ ; + } + + /** + * web鍒嗗竷寮忔枃浠剁郴缁熶繚瀛樻枃浠� + * @param file + * @param fmUrl + * @param fileCtrlRqMp + * @param fileMethodMp + * @param regionNum + * @param fileExtName + * @param json + * @return + * @throws Exception + */ + public FileRestVo saveFile(MultipartFile file, + String fmUrl, + String fileCtrlRqMp, + String fileMethodMp, + String regionNum, + String fileExtName, + String json) throws Exception{ + FileRestVo rvo = null ; + if(file != null && file.getBytes() != null && file.getBytes().length > 0){ + rvo = this.restCreateFileName(fmUrl, fileExtName) ; + if(rvo != null){ + String relativeFilePath = this.restSaveFile(fileCtrlRqMp, fileMethodMp, file, regionNum, json, rvo); + rvo.fileWebPath = relativeFilePath ; + //if(relativeFilePath != null){ + // rvo.createFilePath(relativeFilePath, rvo.fileNameHash); + //} + } + } + return rvo ; + } + + /** + * 鐢熸垚鏂囦欢鍚嶇О + * @return + */ + private FileRestVo restCreateFileName(String fmUrl, String fileExtName) throws Exception{ + // 鍑嗗璇锋眰鏁版嵁 + MultiValueMap<String, Object> multipartRequestData = new LinkedMultiValueMap<>(); + multipartRequestData.add(FileConstant.fmPostMapping_create_paramName, fileExtName); + + // 璁剧疆璇锋眰澶撮儴锛岃繖閲屽亣璁炬湇鍔″櫒鎺ユ敹multipart/form-data绫诲瀷鐨勬暟鎹� + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.MULTIPART_FORM_DATA); + + // 灏佽璇锋眰浣� + HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(multipartRequestData, headers); + + String webUrl = fmUrl + "/" + FileConstant.fmRequestMapping + "/" + FileConstant.fmPostMapping_create; + // 鍙戦�丳OST璇锋眰 + FileRestVo rvo = restTemplate.postForObject(webUrl, requestEntity, FileRestVo.class); + + return rvo ; + } + + /** + * 鎶婃枃浠跺瓨鍌ㄥ埌鏂囦欢绯荤粺涓� + * @param file + * @param regionNum + * @param json json鏁版嵁 + * @param rvo + * @return + * @throws Exception + */ + private String restSaveFile(String fileCtrlRqMp, + String fileMethodMp, + MultipartFile file, + String regionNum, + String json, + FileRestVo rvo) throws Exception{ + // 鍑嗗璇锋眰鏁版嵁 + MultiValueMap<String, Object> multipartRequestData = new LinkedMultiValueMap<>(); + multipartRequestData.add(FileConstant.filePostMapping_paramName_file, file.getResource()); + multipartRequestData.add(FileConstant.filePostMapping_paramName_regionNum, regionNum); + multipartRequestData.add(FileConstant.filePostMapping_paramName_json, (json==null?"":json)); + multipartRequestData.add(FileConstant.filePostMapping_paramName_absolutePath, rvo.fileSysAbsolutePath); + multipartRequestData.add(FileConstant.filePostMapping_paramName_relativePath, rvo.fileSysRelativePath); + multipartRequestData.add(FileConstant.filePostMapping_paramName_fileName, rvo.fileName); + + // 璁剧疆璇锋眰澶撮儴锛岃繖閲屽亣璁炬湇鍔″櫒鎺ユ敹multipart/form-data绫诲瀷鐨勬暟鎹� + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.MULTIPART_FORM_DATA); + //headers.setContentLength(file.getSize()); + + // 灏佽璇锋眰浣� + HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(multipartRequestData, headers); + + String fileRestUrl = rvo.fileSysRestUrl ; + if(!fileRestUrl.endsWith("/") && !fileRestUrl.endsWith("\\\\")){ + fileRestUrl += "/" ; + } + fileRestUrl += (fileCtrlRqMp + "/" + fileMethodMp) ; + + // 鍙戦�丳OST璇锋眰 + return restTemplate.postForObject(fileRestUrl, requestEntity, Object.class).toString(); + } + + /** + * 瑙f瀽鏂囦欢鍚嶇О + * @param fmUrl + * @param filePath + * @return + */ + public FileRestVo parse(String fmUrl, String filePath){ + // 鍑嗗璇锋眰鏁版嵁 + MultiValueMap<String, Object> multipartRequestData = new LinkedMultiValueMap<>(); + multipartRequestData.add(FileConstant.fmPostMapping_parsePath_paramName, filePath); + + // 璁剧疆璇锋眰澶撮儴锛岃繖閲屽亣璁炬湇鍔″櫒鎺ユ敹multipart/form-data绫诲瀷鐨勬暟鎹� + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.MULTIPART_FORM_DATA); + + // 灏佽璇锋眰浣� + HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(multipartRequestData, headers); + + String webUrl = fmUrl + "/" + FileConstant.fmRequestMapping + "/" + FileConstant.fmPostMapping_parsePath; + // 鍙戦�丳OST璇锋眰 + FileRestVo rvo = restTemplate.postForObject(webUrl, requestEntity, FileRestVo.class); + + return rvo ; + } + + + /** + * 瑙f瀽鏂囦欢鍚嶇О + * @param fmUrl + * @param filePaths + * @return + */ + public List<FileRestVo> parse(String fmUrl, List<String> filePaths) throws Exception{ + List<FileRestVo> rList = null ; + if(filePaths != null && filePaths.size() > 0) { + MultiValueMap<String, Object> multipartRequestData = new LinkedMultiValueMap<>(); + multipartRequestData.add(FileConstant.fmPostMapping_parsePathList_paramName, filePaths); + + // 璁剧疆璇锋眰澶撮儴锛岃繖閲屽亣璁炬湇鍔″櫒鎺ユ敹multipart/form-data绫诲瀷鐨勬暟鎹� + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.MULTIPART_FORM_DATA); + + // 灏佽璇锋眰浣� + HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(multipartRequestData, headers); + + String webUrl = fmUrl + "/" + FileConstant.fmRequestMapping + "/" + FileConstant.fmPostMapping_parsePathList; + // 鍙戦�丳OST璇锋眰 + FileRestVo[] rvos = restTemplate.postForObject(webUrl, requestEntity, FileRestVo[].class); + rList = Arrays.asList(rvos) ; + } + return rList ; + } + + /** + * 瑙f瀽鏂囦欢鍝堝笇鍊� + * @param fmUrl + * @param hashcode + * @return + */ + public FileRestVo parseHashcode(String fmUrl, Integer hashcode){ + // 鍑嗗璇锋眰鏁版嵁 + MultiValueMap<String, Object> multipartRequestData = new LinkedMultiValueMap<>(); + multipartRequestData.add(FileConstant.fmPostMapping_parseHashcode_paramName, hashcode); + + // 璁剧疆璇锋眰澶撮儴锛岃繖閲屽亣璁炬湇鍔″櫒鎺ユ敹multipart/form-data绫诲瀷鐨勬暟鎹� + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.MULTIPART_FORM_DATA); + + // 灏佽璇锋眰浣� + HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(multipartRequestData, headers); + + String webUrl = fmUrl + "/" + FileConstant.fmRequestMapping + "/" + FileConstant.fmPostMapping_parseHashcode; + // 鍙戦�丳OST璇锋眰 + FileRestVo rvo = restTemplate.postForObject(webUrl, requestEntity, FileRestVo.class); + + return rvo ; + } + + /** + * 瑙f瀽鏂囦欢鏂囦欢璺緞涓殑鍝堝笇鍊煎苟杩斿洖鍥剧墖瀹屾暣璺緞 + * @param fmUrl + * @param filePath + * @return + */ + public String getFilePath(String fmUrl, String filePath){ + FileRestVo rvo = null ; + if(filePath != null && !filePath.trim().equals("")){ + String[] strs = filePath.split("\\?") ; + String hashValStr = strs[strs.length - 1] ; + if(hashValStr != null && !hashValStr.trim().equals("") && NumUtil.isPlusIntNumber(hashValStr)){ + int hashVal = Integer.valueOf(hashValStr) ; + rvo = parseHashcode(fmUrl, hashVal) ; + } + } + if(rvo != null){ + return rvo.getFileWebUrl() + filePath ; + } + return null ; + } + +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileRestVo.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileRestVo.java new file mode 100644 index 0000000..be885b3 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileRestVo.java @@ -0,0 +1,44 @@ +package com.dy.pipIrrGlobal.dyFile; + +import lombok.Data; + +@Data +public class FileRestVo { + + + public String fileName ; //鐢熸垚鐨勬枃浠跺悕绉帮紝渚嬪20170818153254_100000007.jpg + public Integer fileNameHash ; //鏂囦欢鍚嶇О鐨勫搱甯屽�� + public String fileSysId; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢绯荤粺鐨刬d锛屽湪閰嶇疆鏂囦欢涓厤缃� + public String fileSysAbsolutePath; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢鏈�缁堝瓨鍌ㄧ粷瀵硅矾寰勪腑鐨勬牴鐩綍锛屽湪閰嶇疆鏂囦欢涓厤缃� + public String fileSysRelativePath; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢鏈�缁堝瓨鍌ㄧ浉瀵硅矾寰勭殑鐩綍锛屽湪閰嶇疆鏂囦欢涓厤缃� + public String fileSysRestUrl; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢绯荤粺鐨剅estful URL锛屽湪閰嶇疆鏂囦欢涓厤缃� + public String fileWebPath; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢绯荤粺鐨勬樉绀哄強涓嬭浇鏂囦欢鐨剋eb path锛屽姩鎬佺敓鎴� + public String fileWebUrl; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢绯荤粺鐨勬樉绀烘枃浠剁殑web URL锛屽湪閰嶇疆鏂囦欢涓厤缃� + public String fileWebDownloadPath; //涓嬭浇鏂囨。鐨凜ontroller鐨勭浉瀵硅矾寰� + + public String toString(){ + return "fileName=" + fileName + "\n" + + "fileNameHash=" + fileNameHash + "\n" + + "fileSysId=" + fileSysId + "\n" + + "fileSysAbsolutePath=" + fileSysAbsolutePath + "\n" + + "fileSysRelativePath=" + fileSysRelativePath + "\n" + + "fileSysRestUrl=" + fileSysRestUrl + "\n" + + "fileWebPath=" + fileWebPath + "\n" + + "fileWebUrl=" + fileWebUrl + "\n" + + "fileWebDownloadPath=" + fileWebDownloadPath; + } + + /** + * 姝ゆ柟娉曚笉鐢ㄤ簡锛屽洜涓烘枃浠跺悕绉板悗闈㈠姞涓� 锛焗ashcode鍚庯紝涓嬭浇鏂囦欢绫讳腑灏嗘壘鍒颁笉鏂囦欢 + * 閲嶆柊鍒涘缓fileSysWebUrl + * @param relativeFilePath + * @param hashcode + public void createFilePath(String relativeFilePath, Integer hashcode){ + if(relativeFilePath != null){ + if(relativeFilePath.indexOf("?") < 0){ + this.fileWebPath = relativeFilePath + "?" + hashcode; + } + } + } + */ +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileVo.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileVo.java new file mode 100644 index 0000000..5c916a2 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/FileVo.java @@ -0,0 +1,35 @@ +package com.dy.pipIrrGlobal.dyFile; + +import com.alibaba.fastjson2.annotation.JSONField; +import com.alibaba.fastjson2.writer.ObjectWriterImplToString; +import lombok.Data; + +@Data +public class FileVo { + @JSONField(serializeUsing= ObjectWriterImplToString.class) + public Long id ; //鏁版嵁搴撳疄浣撲富閿� + public Integer hash ;//鏂囦欢鍚峢ash + public String orgName ;//鏂囦欢鍘熷悕 + public String extName ;//鏂囦欢鎵╁睍鍚� + public String webPath ;//web鏂囦欢璁块棶璺緞 + public String webPathZip;//鐓х墖鏂囦欢缂╃暐鍥捐闂矾寰勶紝鍏朵粬绫诲瀷鏂囦欢姝ゅ睘鎬т负null + public String downloadPath;//web鏂囦欢涓嬭浇璺緞锛屽簲鐢ㄦ椂璺緞鍚庨潰鍔犱笂 ?id=[id] + + public FileVo(){} + + public FileVo(Long id, + Integer hash, + String orgName, + String extName, + String webPath, + String webPathZip, + String downloadPath){ + this.id = id ; + this.hash = hash ; + this.orgName = orgName ; + this.extName = extName ; + this.webPath = webPath ; + this.webPathZip = webPathZip ; + this.downloadPath = downloadPath ; + } +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/NameValue.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/NameValue.java new file mode 100644 index 0000000..45e6e8f --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/dyFile/NameValue.java @@ -0,0 +1,26 @@ +package com.dy.pipIrrGlobal.dyFile; + +public class NameValue { + + public String name ; + public String value ; + public NameValue(){ + } + public NameValue(String name, String value){ + this.name = name ; + this.value = value ; + } + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoFi/WebFile.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoFi/WebFile.java new file mode 100644 index 0000000..397ebfa --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoFi/WebFile.java @@ -0,0 +1,73 @@ +package com.dy.pipIrrGlobal.pojoFi; + + +import com.alibaba.fastjson2.annotation.JSONField; +import com.alibaba.fastjson2.writer.ObjectWriterImplToString; +import com.baomidou.mybatisplus.annotation.*; +import com.dy.common.po.BaseEntity; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.*; + +import java.util.Date; + +/** + * 涓婅浇鐨勬枃浠朵俊鎭� + */ + +@TableName(value="web_file", autoResultMap = true) +@Data +@Builder +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class WebFile implements BaseEntity { + + public static final long serialVersionUID = 202410190947001L; + /** + * 涓婚敭 + */ + /* 濡傛灉涓嶆槑纭� type绫诲瀷锛孧P灏嗚嚜鍔ㄤ负鍏惰祴鍊硷紙闆姳ID锛� + IdType: + AUTO(0), //鑷 + NONE(1), //鏈缃富閿� + INPUT(2), //鎵嬪姩杈撳叆 + ASSIGN_ID(3), //榛樿鍏ㄥ眬鍞竴ID + ASSIGN_UUID(4), //鍏ㄥ眬鍞竴鐨� uuid + */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) + @TableId(value = "id", type = IdType.INPUT) + public Long id; + + /** + * 鏂囦欢鍘熷悕绉� + */ + public String orgName; + + /** + * 鎵╁睍鍚� + */ + public String extName; + + /** + * 涓婁紶鏂囦欢鍚庣郴缁熻嚜鍔ㄧ粰鏂囦欢璧嬬殑鏂板悕绉� + */ + public String newName; + + /** + * 鏂囦欢hash鍊� + */ + public Integer hash; + + /** + * 鏂囦欢鍦ㄦ湇鍔$瀛樺偍鐨勭浉瀵硅矾寰� + */ + public String filePath; + + /** + * 鏂囦欢涓婅浇鏃ユ湡 + */ + @TableField(value = "dt", fill = FieldFill.INSERT) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + public Date dt; + +} \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/webCtrls/WebFileCtrl.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/webCtrls/WebFileCtrl.java new file mode 100644 index 0000000..1f0faac --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/webCtrls/WebFileCtrl.java @@ -0,0 +1,250 @@ +package com.dy.pipIrrGlobal.webCtrls; + + +import com.dy.common.aop.SsoAop; +import com.dy.common.webUtil.BaseResponse; +import com.dy.common.webUtil.BaseResponseUtils; +import com.dy.pipIrrGlobal.dyFile.FileConstant; +import com.dy.pipIrrGlobal.dyFile.FileOperate; +import com.dy.pipIrrGlobal.dyFile.FileRestVo; +import com.dy.pipIrrGlobal.dyFile.FileVo; +import com.dy.pipIrrGlobal.pojoFi.WebFile; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +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.util.Date; + +/** + * web鏂囦欢涓婁紶 + */ +@Slf4j +@RestController +@RequestMapping(path="webFile") +public class WebFileCtrl { + + @Autowired + private FileOperate fileOp ; + + @Autowired + private WebFileSv sv ; + + @Value("${dy.webFile.fmUrl}") + private String fmUrl ; + + //鏀寔鐨勬枃浠剁被鍨� + @Value("${dy.webFile.supportedFileTypes}") + private String supportedFileTypes ; + + /** + * 涓婁紶鐓х墖鍥剧墖鏂囦欢 锛堝綋鍓嶅彧瀵筽ng jpg鏍煎紡鍥剧墖鏀寔缂╃暐鍥撅級 + * @param file web绔笂浼犳枃浠剁殑post瀵硅薄 + * @return 杩斿洖缁撴灉 + */ + @PostMapping("/upPhoto") + @SsoAop() + //鍙傝�冿細https://blog.zhengru.top/posts/33486.html#%E5%8D%95%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0 + public BaseResponse<?> upPhoto(MultipartFile file) { + try { + if (file != null) { + String[] fileNameGrp = fileOp.splitFileName(file) ; + if(fileNameGrp != null && fileNameGrp[0] != null && fileNameGrp[1] != null){ + if(!fileNameGrp[1].trim().equals("")){ + FileRestVo frVo = fileOp.saveFile(file, + fmUrl, + FileConstant.fileRequestMapping, + FileConstant.filePostMapping_photo, + FileConstant.NotRegionNum, + fileNameGrp[1], + null); + String fileMainName = fileOp.getFileMainName(frVo.fileName) ; + Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath); + FileVo fvo = new FileVo(id, + frVo.fileNameHash, + fileNameGrp[0], + fileNameGrp[1], + (frVo.getFileWebUrl() + frVo.getFileWebPath()), + fileOp.getImgFileZipPath(frVo.getFileWebUrl() + frVo.getFileWebPath()), + frVo.fileWebDownloadPath + id) ; + return BaseResponseUtils.buildSuccess(fvo) ; + }else { + return BaseResponseUtils.buildError("鏈緱鍒颁笂浼犳枃浠剁殑鎵╁睍鍚�"); + } + }else { + return BaseResponseUtils.buildError("鏈兘鎷嗗垎涓婁紶鏂囦欢鍚嶇О"); + } + } else { + return BaseResponseUtils.buildError("鏈笂浼犳枃浠�"); + } + } catch (Exception e) { + log.error("涓婁紶鐓х墖鏂囦欢寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + + /** + * 涓婁紶褰曢煶闊抽鏂囦欢 + * @param file web绔笂浼犳枃浠剁殑post瀵硅薄 + * @return 杩斿洖缁撴灉 + */ + @PostMapping("/upPhone") + @SsoAop() + public BaseResponse<?> upPhone(MultipartFile file) { + try { + if (file != null) { + String[] fileNameGrp = fileOp.splitFileName(file) ; + if(fileNameGrp != null && fileNameGrp[0] != null && fileNameGrp[1] != null){ + if(!fileNameGrp[1].trim().equals("")){ + FileRestVo frVo = fileOp.saveFile(file, + fmUrl, + FileConstant.fileRequestMapping, + FileConstant.filePostMapping_phone, + FileConstant.NotRegionNum, + fileNameGrp[1], + null); + String fileMainName = fileOp.getFileMainName(frVo.fileName) ; + Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath); + FileVo fvo = new FileVo(id, + frVo.fileNameHash, + fileNameGrp[0], + fileNameGrp[1], + frVo.getFileWebUrl() + frVo.getFileWebPath(), + null, + frVo.fileWebDownloadPath + id) ; + return BaseResponseUtils.buildSuccess(fvo) ; + }else { + return BaseResponseUtils.buildError("鏈緱鍒颁笂浼犳枃浠剁殑鎵╁睍鍚�"); + } + }else { + return BaseResponseUtils.buildError("鏈兘鎷嗗垎涓婁紶鏂囦欢鍚嶇О"); + } + } else { + return BaseResponseUtils.buildError("鏈笂浼犳枃浠�"); + } + } catch (Exception e) { + log.error("涓婁紶鐓х墖鏂囦欢寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + + + /** + * 涓婁紶褰曞儚瑙嗛鏂囦欢 + * @param file web绔笂浼犳枃浠剁殑post瀵硅薄 + * @return 杩斿洖缁撴灉 + */ + @PostMapping("/upVideo") + @SsoAop() + public BaseResponse<?> upVideo(MultipartFile file) { + try { + if (file != null) { + String[] fileNameGrp = fileOp.splitFileName(file) ; + if(fileNameGrp != null && fileNameGrp[0] != null && fileNameGrp[1] != null){ + if(!fileNameGrp[1].trim().equals("")){ + FileRestVo frVo = fileOp.saveFile(file, + fmUrl, + FileConstant.fileRequestMapping, + FileConstant.filePostMapping_video, + FileConstant.NotRegionNum, + fileNameGrp[1], + null); + String fileMainName = fileOp.getFileMainName(frVo.fileName) ; + Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath); + FileVo fvo = new FileVo(id, + frVo.fileNameHash, + fileNameGrp[0], + fileNameGrp[1], + frVo.getFileWebUrl() + frVo.getFileWebPath(), + null, + frVo.fileWebDownloadPath + id) ; + return BaseResponseUtils.buildSuccess(fvo) ; + }else { + return BaseResponseUtils.buildError("鏈緱鍒颁笂浼犳枃浠剁殑鎵╁睍鍚�"); + } + }else { + return BaseResponseUtils.buildError("鏈兘鎷嗗垎涓婁紶鏂囦欢鍚嶇О"); + } + } else { + return BaseResponseUtils.buildError("鏈笂浼犳枃浠�"); + } + } catch (Exception e) { + log.error("涓婁紶鐓х墖鏂囦欢寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + + + /** + * 涓婁紶鏂囨。鏂囦欢 + * @param file web绔笂浼犳枃浠剁殑post瀵硅薄 + * @return 杩斿洖缁撴灉 + */ + @PostMapping("/upDocument") + @SsoAop() + public BaseResponse<?> upDocument(MultipartFile file) { + try { + if (file != null) { + String[] fileNameGrp = fileOp.splitFileName(file) ; + if(fileNameGrp != null && fileNameGrp[0] != null && fileNameGrp[1] != null){ + if(!fileNameGrp[1].trim().equals("")){ + String fileExtName = fileNameGrp[1]; + if(!supportedFileTypes.contains(fileExtName)){ + return BaseResponseUtils.buildError("璇蜂笂浼燱ord,Excel,PDF绫诲瀷鏂囨。"); + } + FileRestVo frVo = fileOp.saveFile(file, + fmUrl, + FileConstant.fileRequestMapping, + FileConstant.filePostMapping_document, + FileConstant.NotRegionNum, + fileNameGrp[1], + null); + String fileMainName = fileOp.getFileMainName(frVo.fileName) ; + Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath); + FileVo fvo = new FileVo(id, + frVo.fileNameHash, + fileNameGrp[0], fileNameGrp[1], + frVo.getFileWebUrl() + frVo.getFileWebPath(), + null, + frVo.fileWebDownloadPath + id) ; + return BaseResponseUtils.buildSuccess(fvo) ; + }else { + return BaseResponseUtils.buildError("鏈緱鍒颁笂浼犳枃浠剁殑鎵╁睍鍚�"); + } + }else { + return BaseResponseUtils.buildError("鏈兘鎷嗗垎涓婁紶鏂囦欢鍚嶇О"); + } + } else { + return BaseResponseUtils.buildError("鏈笂浼犳枃浠�"); + } + } catch (Exception e) { + log.error("涓婁紶鐓х墖鏂囦欢寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + + + /** + * 鏁版嵁搴撳瓨鍌� + * @param orgName 鏂囦欢鍘熷悕绉� + * @param extName 鏂囦欢鎵╁睍鍚� + * @param newName 鏂囦欢鏂板悕绉� + * @param hash 鏂囦欢鏂板悕绉扮殑鍝堝笇鍊� + * @param filePath 鏂囦欢鏈嶅姟绔瓨鍌ㄧ浉瀵硅矾寰� + * @return 鏁版嵁璁板綍涓婚敭 + */ + private Long saveFileInfo(String orgName, String extName, String newName, Integer hash, String filePath){ + WebFile po = new WebFile() ; + po.orgName = orgName ; + po.extName = extName ; + po.newName = newName ; + po.hash = hash ; + po.filePath = filePath ; + po.dt = new Date() ; + return this.sv.save(po) ; + } + +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/webCtrls/WebFileSv.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/webCtrls/WebFileSv.java new file mode 100644 index 0000000..cefae80 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/webCtrls/WebFileSv.java @@ -0,0 +1,26 @@ +package com.dy.pipIrrGlobal.webCtrls; + +import com.dy.pipIrrGlobal.daoFi.WebFileMapper; +import com.dy.pipIrrGlobal.pojoFi.WebFile; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Slf4j +@Service +public class WebFileSv { + + private WebFileMapper dao; + + @Autowired + public void setDao(WebFileMapper dao){ + this.dao = dao ; + } + + @Transactional + public Long save(WebFile po){ + this.dao.insertSelective(po) ; + return po.id ; + } +} diff --git "a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/webCtrls/\350\257\264\346\230\216.txt" "b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/webCtrls/\350\257\264\346\230\216.txt" new file mode 100644 index 0000000..85634cd --- /dev/null +++ "b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/webCtrls/\350\257\264\346\230\216.txt" @@ -0,0 +1 @@ +椤圭洰绾у叏灞�Controller锛屾墍鏈変緷璧杙ipIrr-global鐨勬ā鍧楅兘鏈夎繖浜涘叏灞�鐨凜ontroller \ No newline at end of file diff --git "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050test\346\265\213\350\257\225\347\263\273\347\273\237\051.yml" "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050test\346\265\213\350\257\225\347\263\273\347\273\237\051.yml" index 372823b..4fac75c 100644 --- "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050test\346\265\213\350\257\225\347\263\273\347\273\237\051.yml" +++ "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050test\346\265\213\350\257\225\347\263\273\347\273\237\051.yml" @@ -128,6 +128,164 @@ webPort: 8089 actutorPort: 9089 idSuffix: 11 + + + file: + idSuffix: 99 + file1: + webPort: 8180 + actutorPort: 9180 + file2: + webPort: 8181 + actutorPort: 9181 + file3: + webPort: 8182 + actutorPort: 9182 + file4: + webPort: 8183 + actutorPort: 9183 + file5: + webPort: 8184 + actutorPort: 9184 + file6: + webPort: 8185 + actutorPort: 9185 + file7: + webPort: 8186 + actutorPort: 9186 + file8: + webPort: 8187 + actutorPort: 9187 + file9: + webPort: 8188 + actutorPort: 9188 + file10: + webPort: 8189 + actutorPort: 9189 + file11: + webPort: 8190 + actutorPort: 9190 + file12: + webPort: 8191 + actutorPort: 9191 + + +#web鍒嗗竷寮忔枃浠剁郴缁� +dy: + photoZipWidth: 400 #缂╃暐鍥惧昂瀵� + webFile: + fmUrl: http://127.0.0.1:${pipIrr.file1.webPort}/file # fm鐨剋eb涓婁笅鏂� URL + supportedFileTypes: docx,xlsx,doc,xls,pdf #鏀寔鐨勬枃妗o紙闈炵収鐗囥�佸綍闊炽�佸綍鍍忥級鏂囦欢绫诲瀷 + sv1: + id: dyFile1 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile1 + hashStart: 0 + hashEnd: 5461 + restUrl: http://127.0.0.1:${pipIrr.file1.webPort}/file #file鏄笂涓嬫枃,ip涓哄眬鍩熺綉ip鎴栨湰鍦癐P + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ #nginx鏈嶅姟璺緞,瀹夎閮ㄧ讲鏃禝P鏀规垚澶栫綉IP鎴栧煙鍚� + webDownloadPath: http://127.0.0.1:${pipIrr.file1.webPort}/file/download/down?id= #瀹夎閮ㄧ讲鏃禝P鏀规垚澶栫綉IP鎴栧煙鍚� + sv2: + id: dyFile2 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile2 + hashStart: 5462 + hashEnd: 10923 + restUrl: http://127.0.0.1:${pipIrr.file2.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file2.webPort}/file/download/down?id= + sv3: + id: dyFile3 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile3 + hashStart: 10924 + hashEnd: 16385 + restUrl: http://127.0.0.1:${pipIrr.file3.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file3.webPort}/file/download/down?id= + sv4: + id: dyFile4 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile4 + hashStart: 16386 + hashEnd: 21847 + restUrl: http://127.0.0.1:${pipIrr.file4.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file4.webPort}/file/download/down?id= + sv5: + id: dyFile5 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile5 + hashStart: 21848 + hashEnd: 27309 + restUrl: http://127.0.0.1:${pipIrr.file5.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file5.webPort}/file/download/down?id= + sv6: + id: dyFile6 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile6 + hashStart: 27310 + hashEnd: 32767 + restUrl: http://127.0.0.1:${pipIrr.file6.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file6.webPort}/file/download/down?id= + sv7: + id: dyFile7 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile7 + hashStart: 32768 + hashEnd: 38229 + restUrl: http://127.0.0.1:${pipIrr.file7.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file7.webPort}/file/download/down?id= + sv8: + id: dyFile8 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile8 + hashStart: 38230 + hashEnd: 43691 + restUrl: http://127.0.0.1:${pipIrr.file8.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file8.webPort}/file/download/down?id= + sv9: + id: dyFile9 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile9 + hashStart: 43692 + hashEnd: 49153 + restUrl: http://127.0.0.1:${pipIrr.file9.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file9.webPort}/file/download/down?id= + sv10: + id: dyFile10 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile10 + hashStart: 49154 + hashEnd: 54615 + restUrl: http://127.0.0.1:${pipIrr.file10.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file10.webPort}/file/download/down?id= + sv11: + id: dyFile11 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile11 + hashStart: 54616 + hashEnd: 60077 + restUrl: http://127.0.0.1:${pipIrr.file11.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file11.webPort}/file/download/down?id= + sv12: + id: dyFile12 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile12 + hashStart: 60078 + hashEnd: 65535 + restUrl: http://127.0.0.1:${pipIrr.file12.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file12.webPort}/file/download/down?id= + + #椤圭洰缂栧彿 #projectCode: # ym: 100 diff --git "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050ym\345\205\203\350\260\213\347\263\273\347\273\237\051.yml" "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050ym\345\205\203\350\260\213\347\263\273\347\273\237\051.yml" index 2c4c521..e925bd5 100644 --- "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050ym\345\205\203\350\260\213\347\263\273\347\273\237\051.yml" +++ "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050ym\345\205\203\350\260\213\347\263\273\347\273\237\051.yml" @@ -128,6 +128,164 @@ webPort: 8089 actutorPort: 9089 idSuffix: 11 + + + file: + idSuffix: 99 + file1: + webPort: 8180 + actutorPort: 9180 + file2: + webPort: 8181 + actutorPort: 9181 + file3: + webPort: 8182 + actutorPort: 9182 + file4: + webPort: 8183 + actutorPort: 9183 + file5: + webPort: 8184 + actutorPort: 9184 + file6: + webPort: 8185 + actutorPort: 9185 + file7: + webPort: 8186 + actutorPort: 9186 + file8: + webPort: 8187 + actutorPort: 9187 + file9: + webPort: 8188 + actutorPort: 9188 + file10: + webPort: 8189 + actutorPort: 9189 + file11: + webPort: 8190 + actutorPort: 9190 + file12: + webPort: 8191 + actutorPort: 9191 + + +#web鍒嗗竷寮忔枃浠剁郴缁� +dy: + photoZipWidth: 400 #缂╃暐鍥惧昂瀵� + webFile: + fmUrl: http://127.0.0.1:${pipIrr.file1.webPort}/file # fm鐨剋eb涓婁笅鏂� URL + supportedFileTypes: docx,xlsx,doc,xls,pdf #鏀寔鐨勬枃妗o紙闈炵収鐗囥�佸綍闊炽�佸綍鍍忥級鏂囦欢绫诲瀷 + sv1: + id: dyFile1 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile1 + hashStart: 0 + hashEnd: 5461 + restUrl: http://127.0.0.1:${pipIrr.file1.webPort}/file #file鏄笂涓嬫枃,ip涓哄眬鍩熺綉ip鎴栨湰鍦癐P + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ #nginx鏈嶅姟璺緞,瀹夎閮ㄧ讲鏃禝P鏀规垚澶栫綉IP鎴栧煙鍚� + webDownloadPath: http://127.0.0.1:${pipIrr.file1.webPort}/file/download/down?id= #瀹夎閮ㄧ讲鏃禝P鏀规垚澶栫綉IP鎴栧煙鍚� + sv2: + id: dyFile2 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile2 + hashStart: 5462 + hashEnd: 10923 + restUrl: http://127.0.0.1:${pipIrr.file2.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file2.webPort}/file/download/down?id= + sv3: + id: dyFile3 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile3 + hashStart: 10924 + hashEnd: 16385 + restUrl: http://127.0.0.1:${pipIrr.file3.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file3.webPort}/file/download/down?id= + sv4: + id: dyFile4 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile4 + hashStart: 16386 + hashEnd: 21847 + restUrl: http://127.0.0.1:${pipIrr.file4.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file4.webPort}/file/download/down?id= + sv5: + id: dyFile5 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile5 + hashStart: 21848 + hashEnd: 27309 + restUrl: http://127.0.0.1:${pipIrr.file5.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file5.webPort}/file/download/down?id= + sv6: + id: dyFile6 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile6 + hashStart: 27310 + hashEnd: 32767 + restUrl: http://127.0.0.1:${pipIrr.file6.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file6.webPort}/file/download/down?id= + sv7: + id: dyFile7 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile7 + hashStart: 32768 + hashEnd: 38229 + restUrl: http://127.0.0.1:${pipIrr.file7.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file7.webPort}/file/download/down?id= + sv8: + id: dyFile8 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile8 + hashStart: 38230 + hashEnd: 43691 + restUrl: http://127.0.0.1:${pipIrr.file8.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file8.webPort}/file/download/down?id= + sv9: + id: dyFile9 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile9 + hashStart: 43692 + hashEnd: 49153 + restUrl: http://127.0.0.1:${pipIrr.file9.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file9.webPort}/file/download/down?id= + sv10: + id: dyFile10 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile10 + hashStart: 49154 + hashEnd: 54615 + restUrl: http://127.0.0.1:${pipIrr.file10.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file10.webPort}/file/download/down?id= + sv11: + id: dyFile11 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile11 + hashStart: 54616 + hashEnd: 60077 + restUrl: http://127.0.0.1:${pipIrr.file11.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file11.webPort}/file/download/down?id= + sv12: + id: dyFile12 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile12 + hashStart: 60078 + hashEnd: 65535 + restUrl: http://127.0.0.1:${pipIrr.file12.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file12.webPort}/file/download/down?id= + + #椤圭洰缂栧彿 #projectCode: # ym: 100 diff --git "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050\345\274\200\345\217\221\346\265\213\350\257\225---166PC\346\234\272\051.yml" "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050\345\274\200\345\217\221\346\265\213\350\257\225---166PC\346\234\272\051.yml" index 7c8cdc5..aa0e4cb 100644 --- "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050\345\274\200\345\217\221\346\265\213\350\257\225---166PC\346\234\272\051.yml" +++ "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050\345\274\200\345\217\221\346\265\213\350\257\225---166PC\346\234\272\051.yml" @@ -128,6 +128,164 @@ webPort: 8089 actutorPort: 9089 idSuffix: 11 + + + file: + idSuffix: 99 + file1: + webPort: 8180 + actutorPort: 9180 + file2: + webPort: 8181 + actutorPort: 9181 + file3: + webPort: 8182 + actutorPort: 9182 + file4: + webPort: 8183 + actutorPort: 9183 + file5: + webPort: 8184 + actutorPort: 9184 + file6: + webPort: 8185 + actutorPort: 9185 + file7: + webPort: 8186 + actutorPort: 9186 + file8: + webPort: 8187 + actutorPort: 9187 + file9: + webPort: 8188 + actutorPort: 9188 + file10: + webPort: 8189 + actutorPort: 9189 + file11: + webPort: 8190 + actutorPort: 9190 + file12: + webPort: 8191 + actutorPort: 9191 + + +#web鍒嗗竷寮忔枃浠剁郴缁� +dy: + photoZipWidth: 400 #缂╃暐鍥惧昂瀵� + webFile: + fmUrl: http://127.0.0.1:${pipIrr.file1.webPort}/file # fm鐨剋eb涓婁笅鏂� URL + supportedFileTypes: docx,xlsx,doc,xls,pdf #鏀寔鐨勬枃妗o紙闈炵収鐗囥�佸綍闊炽�佸綍鍍忥級鏂囦欢绫诲瀷 + sv1: + id: dyFile1 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile1 + hashStart: 0 + hashEnd: 5461 + restUrl: http://127.0.0.1:${pipIrr.file1.webPort}/file #file鏄笂涓嬫枃,ip涓哄眬鍩熺綉ip鎴栨湰鍦癐P + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ #nginx鏈嶅姟璺緞,瀹夎閮ㄧ讲鏃禝P鏀规垚澶栫綉IP鎴栧煙鍚� + webDownloadPath: http://127.0.0.1:${pipIrr.file1.webPort}/file/download/down?id= #瀹夎閮ㄧ讲鏃禝P鏀规垚澶栫綉IP鎴栧煙鍚� + sv2: + id: dyFile2 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile2 + hashStart: 5462 + hashEnd: 10923 + restUrl: http://127.0.0.1:${pipIrr.file2.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file2.webPort}/file/download/down?id= + sv3: + id: dyFile3 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile3 + hashStart: 10924 + hashEnd: 16385 + restUrl: http://127.0.0.1:${pipIrr.file3.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file3.webPort}/file/download/down?id= + sv4: + id: dyFile4 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile4 + hashStart: 16386 + hashEnd: 21847 + restUrl: http://127.0.0.1:${pipIrr.file4.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file4.webPort}/file/download/down?id= + sv5: + id: dyFile5 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile5 + hashStart: 21848 + hashEnd: 27309 + restUrl: http://127.0.0.1:${pipIrr.file5.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file5.webPort}/file/download/down?id= + sv6: + id: dyFile6 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile6 + hashStart: 27310 + hashEnd: 32767 + restUrl: http://127.0.0.1:${pipIrr.file6.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file6.webPort}/file/download/down?id= + sv7: + id: dyFile7 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile7 + hashStart: 32768 + hashEnd: 38229 + restUrl: http://127.0.0.1:${pipIrr.file7.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file7.webPort}/file/download/down?id= + sv8: + id: dyFile8 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile8 + hashStart: 38230 + hashEnd: 43691 + restUrl: http://127.0.0.1:${pipIrr.file8.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file8.webPort}/file/download/down?id= + sv9: + id: dyFile9 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile9 + hashStart: 43692 + hashEnd: 49153 + restUrl: http://127.0.0.1:${pipIrr.file9.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file9.webPort}/file/download/down?id= + sv10: + id: dyFile10 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile10 + hashStart: 49154 + hashEnd: 54615 + restUrl: http://127.0.0.1:${pipIrr.file10.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file10.webPort}/file/download/down?id= + sv11: + id: dyFile11 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile11 + hashStart: 54616 + hashEnd: 60077 + restUrl: http://127.0.0.1:${pipIrr.file11.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file11.webPort}/file/download/down?id= + sv12: + id: dyFile12 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile12 + hashStart: 60078 + hashEnd: 65535 + restUrl: http://127.0.0.1:${pipIrr.file12.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file12.webPort}/file/download/down?id= + + #椤圭洰缂栧彿 #projectCode: # ym: 100 diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml b/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml index 777fbf4..1c0b641 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml @@ -73,6 +73,8 @@ global: dev: false #鏄惁寮�鍙戦樁娈碉紝true鎴杅alse dsName: ym #寮�鍙戦樁娈碉紝璁剧疆涓存椂鐨勬暟鎹簱鍚嶇О + nginx: + webPort: 54321 mw: webPort: 8070 actutorPort: 9070 @@ -128,6 +130,162 @@ webPort: 8089 actutorPort: 9089 idSuffix: 11 + + file: + idSuffix: 99 + file1: + webPort: 8180 + actutorPort: 9180 + file2: + webPort: 8180 + actutorPort: 9180 + file3: + webPort: 8180 + actutorPort: 9180 + file4: + webPort: 8180 + actutorPort: 9180 + file5: + webPort: 8180 + actutorPort: 9180 + file6: + webPort: 8180 + actutorPort: 9180 + file7: + webPort: 8180 + actutorPort: 9180 + file8: + webPort: 8180 + actutorPort: 9180 + file9: + webPort: 8180 + actutorPort: 9180 + file10: + webPort: 8180 + actutorPort: 9180 + file11: + webPort: 8180 + actutorPort: 9180 + file12: + webPort: 8180 + actutorPort: 9180 + + +#web鍒嗗竷寮忔枃浠剁郴缁� +dy: + photoZipWidth: 400 #缂╃暐鍥惧昂瀵� + webFile: + fmUrl: http://127.0.0.1:${pipIrr.file1.webPort}/file # fm鐨剋eb涓婁笅鏂� URL + supportedFileTypes: docx,xlsx,doc,xls,pdf #鏀寔鐨勬枃妗o紙闈炲獟浣撴枃浠讹紝濡傜収鐗囥�佸綍闊炽�佸綍鍍忥級鏂囦欢绫诲瀷 + sv1: + id: dyFile1 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile1 + hashStart: 0 + hashEnd: 5461 + restUrl: http://127.0.0.1:${pipIrr.file1.webPort}/file #file鏄笂涓嬫枃,ip涓哄眬鍩熺綉ip鎴栨湰鍦癐P + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ #nginx鏈嶅姟璺緞,瀹夎閮ㄧ讲鏃禝P鏀规垚澶栫綉IP鎴栧煙鍚� + webDownloadPath: http://127.0.0.1:${pipIrr.file1.webPort}/file/download/down?id= #瀹夎閮ㄧ讲鏃禝P鏀规垚澶栫綉IP鎴栧煙鍚� + sv2: + id: dyFile2 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile2 + hashStart: 5462 + hashEnd: 10923 + restUrl: http://127.0.0.1:${pipIrr.file2.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file2.webPort}/file/download/down?id= + sv3: + id: dyFile3 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile3 + hashStart: 10924 + hashEnd: 16385 + restUrl: http://127.0.0.1:${pipIrr.file3.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file3.webPort}/file/download/down?id= + sv4: + id: dyFile4 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile4 + hashStart: 16386 + hashEnd: 21847 + restUrl: http://127.0.0.1:${pipIrr.file4.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file4.webPort}/file/download/down?id= + sv5: + id: dyFile5 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile5 + hashStart: 21848 + hashEnd: 27309 + restUrl: http://127.0.0.1:${pipIrr.file5.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file5.webPort}/file/download/down?id= + sv6: + id: dyFile6 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile6 + hashStart: 27310 + hashEnd: 32767 + restUrl: http://127.0.0.1:${pipIrr.file6.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file6.webPort}/file/download/down?id= + sv7: + id: dyFile7 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile7 + hashStart: 32768 + hashEnd: 38229 + restUrl: http://127.0.0.1:${pipIrr.file7.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file7.webPort}/file/download/down?id= + sv8: + id: dyFile8 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile8 + hashStart: 38230 + hashEnd: 43691 + restUrl: http://127.0.0.1:${pipIrr.file8.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file8.webPort}/file/download/down?id= + sv9: + id: dyFile9 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile9 + hashStart: 43692 + hashEnd: 49153 + restUrl: http://127.0.0.1:${pipIrr.file9.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file9.webPort}/file/download/down?id= + sv10: + id: dyFile10 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile10 + hashStart: 49154 + hashEnd: 54615 + restUrl: http://127.0.0.1:${pipIrr.file10.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file10.webPort}/file/download/down?id= + sv11: + id: dyFile11 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile11 + hashStart: 54616 + hashEnd: 60077 + restUrl: http://127.0.0.1:${pipIrr.file11.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file11.webPort}/file/download/down?id= + sv12: + id: dyFile12 + absolutePath: E:/java/nginx-1.24.0/html/webfiles/ + relativePath: webFile12 + hashStart: 60078 + hashEnd: 65535 + restUrl: http://127.0.0.1:${pipIrr.file12.webPort}/file + webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ + webDownloadPath: http://127.0.0.1:${pipIrr.file12.webPort}/file/download/down?id= + #椤圭洰缂栧彿 #projectCode: # ym: 100 diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/WebFileMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/WebFileMapper.xml new file mode 100644 index 0000000..e136766 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/WebFileMapper.xml @@ -0,0 +1,126 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.dy.pipIrrGlobal.daoFi.WebFileMapper"> + <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoFi.WebFile"> + <!--@mbg.generated--> + <!--@Table web_file--> + <id column="id" property="id" /> + <result column="org_name" property="orgName" /> + <result column="ext_name" property="extName" /> + <result column="new_name" property="newName" /> + <result column="hash" property="hash" /> + <result column="file_path" property="filePath" /> + <result column="dt" property="dt" /> + </resultMap> + <sql id="Base_Column_List"> + <!--@mbg.generated--> + id, org_name, ext_name, new_name, hash, file_path, dt + </sql> + + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <!--@mbg.generated--> + select + <include refid="Base_Column_List" /> + from web_file + where id = #{id} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + <!--@mbg.generated--> + delete from web_file + where id = #{id} + </delete> + <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoFi.WebFile"> + <!--@mbg.generated--> + insert into web_file (id, org_name, ext_name, new_name, hash, file_path, + dt) + values (#{id}, #{orgName}, #{extName}, #{newName}, #{hash}, #{filePath}, + #{dt}) + </insert> + <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoFi.WebFile"> + <!--@mbg.generated--> + insert into web_file + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + id, + </if> + <if test="orgName!= null and orgName !=''"> + org_name, + </if> + <if test="extName!= null and extName !=''"> + ext_name, + </if> + <if test="newName!= null and newName !=''"> + new_name, + </if> + <if test="hash!= null"> + hash, + </if> + <if test="filePath!= null and filePath !=''"> + file_path, + </if> + <if test="dt != null"> + dt, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id}, + </if> + <if test="orgName!= null and orgName !=''"> + #{orgName}, + </if> + <if test="extName!= null and extName !=''"> + #{extName}, + </if> + <if test="newName!= null and newName !=''"> + #{newName}, + </if> + <if test="hash!= null"> + #{hash}, + </if> + <if test="filePath!= null and filePath !=''"> + #{filePath}, + </if> + <if test="dt != null"> + #{dt}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoFi.WebFile"> + <!--@mbg.generated--> + update web_file + <set> + <if test="orgName!= null and orgName !=''"> + org_name = #{orgName}, + </if> + <if test="extName!= null and extName !=''"> + ext_name = #{extName}, + </if> + <if test="newName!= null and newName !=''"> + new_name = #{newName}, + </if> + <if test="hash!= null"> + hash = #{hash}, + </if> + <if test="filePath!= null and filePath !=''"> + file_path = #{filePath}, + </if> + <if test="dt != null"> + dt = #{dt}, + </if> + </set> + where id = #{id} + </update> + <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoFi.WebFile"> + <!--@mbg.generated--> + update web_file + set org_name = #{orgName}, + ext_name = #{extName}, + new_name = #{newName}, + hash = #{hash}, + file_path = #{filePath}, + dt = #{dt} + where id = #{id} + </update> + +</mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/.gitattributes b/pipIrr-platform/pipIrr-web/pipIrr-web-file/.gitattributes new file mode 100644 index 0000000..3b41682 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/.gitattributes @@ -0,0 +1,2 @@ +/mvnw text eol=lf +*.cmd text eol=crlf diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/.gitignore b/pipIrr-platform/pipIrr-web/pipIrr-web-file/.gitignore new file mode 100644 index 0000000..7667296 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/.gitignore @@ -0,0 +1,34 @@ +HELP.md +target/ +/pipIrr-web-file.iml +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/.mvn/wrapper/maven-wrapper.properties b/pipIrr-platform/pipIrr-web/pipIrr-web-file/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..fe9deed --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip +distributionSha256Sum=4ec3f26fb1a692473aea0235c300bd20f0f9fe741947c82c1234cefd76ac3a3c diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/mvnw b/pipIrr-platform/pipIrr-web/pipIrr-web-file/mvnw new file mode 100644 index 0000000..19529dd --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/mvnw @@ -0,0 +1,259 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.3.2 +# +# Optional ENV vars +# ----------------- +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output +# ---------------------------------------------------------------------------- + +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x + +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac + +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" + + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 + fi + fi + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi + fi +} + +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" + done + printf %x\\n $h +} + +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } + +die() { + printf %s\\n "$1" >&2 + exit 1 +} + +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} + +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash> +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} + +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" +fi + +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac + +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" +fi + +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" +fi + +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v + +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac + +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 + fi +fi + +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" +else + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" + +clean || : +exec_maven "$@" diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/mvnw.cmd b/pipIrr-platform/pipIrr-web/pipIrr-web-file/mvnw.cmd new file mode 100644 index 0000000..249bdf3 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/mvnw.cmd @@ -0,0 +1,149 @@ +<# : batch portion +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.3.2 +@REM +@REM Optional ENV vars +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output +@REM ---------------------------------------------------------------------------- + +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) +) +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash> +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/pom.xml b/pipIrr-platform/pipIrr-web/pipIrr-web-file/pom.xml new file mode 100644 index 0000000..541d7fe --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/pom.xml @@ -0,0 +1,142 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <artifactId>pipIrr-web</artifactId> + <groupId>com.dy</groupId> + <version>1.0.0</version> + <relativePath>../pom.xml</relativePath> + </parent> + + + <packaging>jar</packaging> + <artifactId>pipIrr-web-file</artifactId> + <name>pipIrr-web-file</name> + <description>web缃戠粶鏂囦欢绯荤粺</description> + + <dependencies> + + </dependencies> + + <build> + <plugins> + <!-- 鐢熸垚涓嶅寘鍚緷璧杍ar鐨勫彲鎵цjar鍖� + <plugin> + !- spring boot鎻愪緵鐨刴aven鎵撳寘鎻掍欢 - + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <executions> + <execution> + !- + <goals> + <goal>repackage</goal> + </goals> + - + <configuration> + !- 涓嶅姞鐨勮瘽鏈�缁堝寘鍚嶄负: ${artifactId}-${version}.jar, 鍔犱簡鐨勮瘽鏈�缁堝寘鍚�: ${artifactId}-${version}-${classifier}.jar - + <classifier>execute</classifier> + !- 涓嶆寚瀹氱敓鎴愯矾寰勭殑璇�, 榛樿淇濆瓨鍦� ${build.directory} 涓� - + <outputDirectory>${project.build.directory}/execute</outputDirectory> + <finalName>${artifactId}-${version}</finalName> + <layout>ZIP</layout> + <mainClass>com.dy.pipIrrBase.PipIrrBaseApplication</mainClass> + <includes> + <include> + <groupId>com.dy</groupId> + <artifactId>pipIrr-common</artifactId> + </include> + <include> + <groupId>com.dy</groupId> + <artifactId>pipIrr-global</artifactId> + </include> + </includes> + <excludes> + <exclude> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </exclude> + </excludes> + </configuration> + </execution> + </executions> + + </plugin> + --> + <!-- 鎷疯礉渚濊禆鐨刯ar鍖呭埌lib鐩綍--> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <executions> + <execution> + <configuration> + <!-- 涓嶅姞鐨勮瘽鏈�缁堝寘鍚嶄负: ${artifactId}-${version}.jar, 鍔犱簡鐨勮瘽鏈�缁堝寘鍚�: ${artifactId}-${version}-${classifier}.jar + <classifier>execute</classifier> + --> + <!-- ${project.build.directory}鏄痬aven鍙橀噺锛屽唴缃殑锛岃〃绀簍arget鐩綍,濡傛灉涓嶅啓锛屽皢鍦ㄦ牴鐩綍涓嬪垱寤�/lib --> + <outputDirectory>${project.build.directory}/lib</outputDirectory> + <!-- excludeTransitive:鏄惁涓嶅寘鍚棿鎺ヤ緷璧栧寘锛屾瘮濡傛垜浠緷璧朅锛屼絾鏄疉鍙堜緷璧栦簡B锛屾垜浠槸鍚︿篃瑕佹妸B鎵撹繘鍘� 榛樿涓嶆墦--> + <excludeTransitive>false</excludeTransitive> + <!-- 澶嶅埗鐨刯ar鏂囦欢鍘绘帀鐗堟湰淇℃伅 --> + <stripVersion>false</stripVersion> + <finalName>${project.artifactId}-${project.version}</finalName> + <layout>ZIP</layout> + <mainClass>com.dy.pipIrrBase.PipIrrBaseApplication</mainClass> + <includes> + <include> + <groupId>com.dy</groupId> + <artifactId>pipIrr-common</artifactId> + </include> + <include> + <groupId>com.dy</groupId> + <artifactId>pipIrr-global</artifactId> + </include> + </includes> + <excludes> + <exclude> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </exclude> + </excludes> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <!-- 璁剧疆java缂栬瘧鐗堟湰锛岃繍琛岀幆澧冪増鏈� --> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <!-- source锛� 婧愪唬鐮佺紪璇戠増鏈紱target锛� 鐩爣骞冲彴缂栬瘧鐗堟湰锛沞ncoding锛� 瀛楃闆嗙紪鐮併�� --> + <configuration> + <source>${java.version}</source> + <target>${java.version}</target> + <encoding>${encoding}</encoding> + </configuration> + </plugin> + <plugin> + <!-- 瑙e喅璧勬簮鏂囦欢鐨勭紪鐮侀棶棰� --> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <configuration> + <encoding>${encoding}</encoding> + </configuration> + </plugin> + <plugin> + <!-- maven閲屾墽琛屾祴璇曠敤渚嬬殑鎻掍欢 --> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <skipTests>true</skipTests> + </configuration> + </plugin> + <plugin> + <!-- 涓嬮潰瑙e喅锛氬綋杩涜Maven Lifecycle package鏃舵姤閿欙細Could not find artifact org.apache.mina:mina-core:bundle:2.2.1 in maven (https://repo1.maven.org/maven2/)--> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/PipIrrWebFileApplication.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/PipIrrWebFileApplication.java new file mode 100644 index 0000000..9b5d75d --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/PipIrrWebFileApplication.java @@ -0,0 +1,29 @@ +package com.dy.pipIrrWebFile; + +import com.dy.common.multiDataSource.EnableMultiDataSource; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.context.annotation.FilterType; + + +@SpringBootApplication +@EnableAspectJAutoProxy +@EnableMultiDataSource +@ComponentScan(basePackages = {"com.dy.common", "com.dy.pipIrrGlobal", "com.dy.pipIrrWebFile"}, + excludeFilters = { + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = { + com.dy.common.singleDataSource.DruidDataSourceConfig.class //鎺掗櫎鍗曟暟鎹簮 + }) + } +) +@MapperScan(basePackages={"com.dy.pipIrrGlobal.daoFi"}) +public class PipIrrWebFileApplication { + + public static void main(String[] args) { + SpringApplication.run(PipIrrWebFileApplication.class, args); + } + +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/download/DownloadFileCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/download/DownloadFileCtrl.java new file mode 100644 index 0000000..4eda17f --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/download/DownloadFileCtrl.java @@ -0,0 +1,109 @@ +package com.dy.pipIrrWebFile.download; + +import com.dy.pipIrrGlobal.dyFile.FileOperate; +import com.dy.pipIrrGlobal.dyFile.FileRestVo; +import com.dy.pipIrrGlobal.pojoFi.WebFile; +import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.io.File; +import java.io.FileInputStream; +import java.net.URLEncoder; + +/** + * web鏂囦欢涓嬭浇 + */ +@Slf4j +@RestController +@RequestMapping(path="download") +@SuppressWarnings("unchecked")//java鐗堟湰瓒婇珮锛屽娉涘瀷绾︽潫瓒婁弗锛屾墍浠ラ厤缃甋uppressWarnings("unchecked") +public class DownloadFileCtrl { + + @Autowired + private DownloadFileSv sv ; + + @Autowired + private FileOperate fileOp ; + + @Value("${dy.webFile.fmUrl}") + private String fmUrl ; + + + /** + * 閫氳繃web鏂囦欢鏁版嵁搴撳疄浣搃d涓嬭浇璇ユ枃浠� + * @param id + * @return + */ + @GetMapping("/down") + public void down(String id, HttpServletRequest req, HttpServletResponse rep){ + try{ + WebFile fPo = sv.selectById(id) ; + if(fPo != null){ + FileRestVo frVo = fileOp.parseHashcode(fmUrl, fPo.hash) ; + if(frVo.fileSysAbsolutePath != null){ + if(!frVo.fileSysAbsolutePath.endsWith("\\\\") && !frVo.fileSysAbsolutePath.endsWith("/") ){ + frVo.fileSysAbsolutePath = frVo.fileSysAbsolutePath + "/" ; + } + } + String filePath = frVo.fileSysAbsolutePath + fPo.filePath ; + File f = new File(filePath) ; + if(f.exists()){ + String fileReName = fPo.orgName + "." + fPo.extName ; + //URLEncoder.encode鍙互闃叉涓枃涔辩爜 + fileReName = URLEncoder.encode(fileReName, "UTF-8").replaceAll("\\+", "%20"); + rep.addHeader("content-type", "application/octet-stream"); + rep.addHeader("Content-Disposition", "attachment;fileName=" + fileReName); + + ServletOutputStream out = null; + FileInputStream in = null ; + try { + out = rep.getOutputStream() ; + } catch (Exception ee) { + out = null ; + }finally{ + if(out != null){ + byte[] bs = new byte[1024] ; + int len = -1 ; + try { + in = new FileInputStream(f); + len = in.read(bs) ; + while(len != -1){ + out.write(bs, 0, len); + len = in.read(bs) ; + } + } catch (Exception eee) { + } finally { + if(out != null){ + try{ + out.flush(); + out.close(); + }catch(Exception e){ + }finally{ + if(in != null){ + try{ + in.close(); + }catch(Exception e){ + } + } + } + } + } + } + } + }else{ + } + }else{ + } + }catch (Exception e){ + log.error("涓嬭浇鏂囦欢鏃跺紓甯�", e); + } + + } +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/download/DownloadFileSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/download/DownloadFileSv.java new file mode 100644 index 0000000..17403f2 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/download/DownloadFileSv.java @@ -0,0 +1,30 @@ +package com.dy.pipIrrWebFile.download; + + +import com.dy.common.util.NumUtil; +import com.dy.pipIrrGlobal.daoFi.WebFileMapper; +import com.dy.pipIrrGlobal.pojoFi.WebFile; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +public class DownloadFileSv { + @Autowired + private WebFileMapper dao; + + /** + * 鐢↖D鏌ヨ + * @param id + * @return + */ + public WebFile selectById(String id){ + if(NumUtil.isPlusIntNumber(id)){ + return dao.selectByPrimaryKey(Long.parseLong(id)) ; + }else{ + return null ; + } + } + +} 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 new file mode 100644 index 0000000..f8e6734 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/files/FileCtrl.java @@ -0,0 +1,202 @@ +package com.dy.pipIrrWebFile.files; + +import com.dy.common.util.NumUtil; +import com.dy.pipIrrWebFile.util.*; +import lombok.extern.slf4j.Slf4j; +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; + +/** + * web鏂囦欢涓婁紶, 鍐呴儴璋冪敤锛屽嵆鐢卞叾浠栧瓙妯″潡璋冪敤锛� + * 涓�鑸笉鐢卞墠绔郴缁熻皟鐢� + */ +@Slf4j +@RestController +@RequestMapping(path="file") +@SuppressWarnings("unchecked")//java鐗堟湰瓒婇珮锛屽娉涘瀷绾︽潫瓒婁弗锛屾墍浠ラ厤缃甋uppressWarnings("unchecked") +public class FileCtrl { + + @Value("${dy.photoZipWidth}") + private String photoZipWidthStr ; + + /** + * web鍒嗗竷寮忔枃浠剁郴缁熶繚瀛樼収鐗囨枃浠� + * @param file + * @param regionNum + * @param json 姘村嵃淇℃伅 + * @param absolutePath + * @param relativePath + * @param fileName + * @return + */ + @PostMapping("/savePhoto") + public String savePhoto(MultipartFile file, + String regionNum, + String json, + String absolutePath, + String relativePath, + String fileName) { + Integer photoZipWidth = 400 ; + if(photoZipWidthStr != null && NumUtil.isPlusIntNumber(photoZipWidthStr)){ + photoZipWidth = Integer.parseInt(photoZipWidthStr) ; + } + String fileRelativePath = null ; + try { + if (file != null) { + if(absolutePath != null && relativePath != null && fileName != null){ + InputStream input = file.getInputStream() ; + //鐢熸垚鏂版枃浠剁浉瀵硅矾寰� + FilePhotoUtil fUtil = new FilePhotoUtil() ; + fileRelativePath = fUtil.newFileRelativityPath(absolutePath, relativePath, regionNum) + fileName ; + String filePath = absolutePath + fileRelativePath ; + if(!fUtil.saveFile(filePath, input)){ + fileRelativePath = null ; + }else { + //瀛樺偍鎴愬姛 + File fPic = new File(filePath) ; + //鐢熸垚缂╃暐鍥� + int index = filePath.lastIndexOf(".") ; + String zipFilePath1 = filePath.substring(0, index) ; + String zipFilePath2 = filePath.substring(index) ; + String zipFilePath = zipFilePath1 + "_" + zipFilePath2 ; + InputStream zipFileInput = null ; + if(zipFilePath2.equalsIgnoreCase(".png")){ + zipFileInput = ZipImg.zipToPng(fPic, photoZipWidth, photoZipWidth) ; + }else{ + zipFileInput = ZipImg.zipToJpg(fPic, photoZipWidth, photoZipWidth) ; + } + if(zipFileInput.available() > 0){ + new FileUtil().saveFile(zipFilePath, zipFileInput) ; + }else{ + //濡傛灉鍘嬬缉鏂囦欢涓嶅瓨鍦ㄦ垨鐢熸垚澶辫触锛屽垯澶嶅埗婧愭枃浠� + new FileUtil().saveFile(zipFilePath, file.getInputStream()) ; + } + } + } + } + } catch (Exception e) { + log.error("淇濆瓨鐓х墖鏂囦欢寮傚父", e); + } + return fileRelativePath ; + } + + /** + * web鍒嗗竷寮忔枃浠剁郴缁熶繚瀛樺綍闊抽煶棰戞枃浠� + * @param file + * @param regionNum + * @param json 姘村嵃淇℃伅 + * @param absolutePath + * @param relativePath + * @param fileName + * @return + */ + @PostMapping("/savePhone") + public String savePhone(MultipartFile file, + String regionNum, + String json, + String absolutePath, + String relativePath, + String fileName) { + String fileRelativePath = null ; + try { + if (file != null) { + if(absolutePath != null && relativePath != null && fileName != null){ + InputStream input = file.getInputStream() ; + //鐢熸垚鏂版枃浠剁浉瀵硅矾寰� + FilePhoneUtil fUtil = new FilePhoneUtil() ; + fileRelativePath = fUtil.newFileRelativityPath(absolutePath, relativePath, regionNum) + fileName ; + String filePath = absolutePath + fileRelativePath ; + if(!fUtil.saveFile(filePath, input)){ + fileRelativePath = null ; + } + } + } + } catch (Exception e) { + log.error("淇濆瓨褰曢煶闊抽鏂囦欢寮傚父", e); + } + return fileRelativePath ; + } + + + /** + * web鍒嗗竷寮忔枃浠剁郴缁熶繚瀛樺綍鍍忚棰戞枃浠� + * @param file + * @param regionNum + * @param json 姘村嵃淇℃伅 + * @param absolutePath + * @param relativePath + * @param fileName + * @return + */ + @PostMapping("/saveVideo") + public String saveVideo(MultipartFile file, + String regionNum, + String json, + String absolutePath, + String relativePath, + String fileName) { + String fileRelativePath = null ; + try { + if (file != null) { + if(absolutePath != null && relativePath != null && fileName != null){ + InputStream input = file.getInputStream() ; + //鐢熸垚鏂版枃浠剁浉瀵硅矾寰� + FileVideoUtil fUtil = new FileVideoUtil() ; + fileRelativePath = fUtil.newFileRelativityPath(absolutePath, relativePath, regionNum) + fileName ; + String filePath = absolutePath + fileRelativePath ; + if(!fUtil.saveFile(filePath, input)){ + fileRelativePath = null ; + } + } + } + } catch (Exception e) { + log.error("淇濆瓨褰曞儚瑙嗛鏂囦欢寮傚父", e); + } + return fileRelativePath ; + } + + + /** + * web鍒嗗竷寮忔枃浠剁郴缁熶繚瀛樻枃妗f枃浠� + * @param file + * @param regionNum + * @param json 姘村嵃淇℃伅 + * @param absolutePath + * @param relativePath + * @param fileName + * @return + */ + @PostMapping("/saveDocument") + public String saveDocument(MultipartFile file, + String regionNum, + String json, + String absolutePath, + String relativePath, + String fileName) { + String fileRelativePath = null ; + try { + if (file != null) { + if(absolutePath != null && relativePath != null && fileName != null){ + InputStream input = file.getInputStream() ; + //鐢熸垚鏂版枃浠剁浉瀵硅矾寰� + FileDocumentUtil fUtil = new FileDocumentUtil() ; + fileRelativePath = fUtil.newFileRelativityPath(absolutePath, relativePath, regionNum) + fileName ; + String filePath = absolutePath + fileRelativePath ; + if(!fUtil.saveFile(filePath, input)){ + fileRelativePath = null ; + } + } + } + } catch (Exception e) { + log.error("淇濆瓨鏂囨。鏂囦欢寮傚父", e); + } + return fileRelativePath ; + } + +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/DyFileSvConf.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/DyFileSvConf.java new file mode 100644 index 0000000..57e54b5 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/DyFileSvConf.java @@ -0,0 +1,155 @@ +package com.dy.pipIrrWebFile.fm; + +import java.util.ArrayList; +import java.util.List; + +public class DyFileSvConf { + + public static class Group{ + public List<Vo> list ; + public Group(){ + this.list = new ArrayList<Vo>() ; + } + public void add(Vo vo)throws Exception{ + if(vo == null){ + throw new Exception("鍑洪敊锛岄鍔犲叆闆嗗悎Vo涓虹┖浜嗭紒") ; + } + if(list.size() > 0){ + for(Vo lvo : list){ + lvo.checkEqual(vo) ; + } + this.list.add(vo) ; + }else{ + this.list.add(vo) ; + } + } + public void check() throws Exception{ + Integer startV = 0 ; + doCheck(startV) ; + } + private void doCheck(Integer startV) throws Exception{ + boolean find = false ; + for(Vo vo : list){ + if(vo.hashStart.intValue() == startV.intValue()){ + startV = vo.hashEnd + 1; + find = true ; + break ; + } + } + if(!find){ + throw new Exception("涓ラ噸閿欒锛屾湭鍙戠幇鍝堝笇鍊间负" + startV + "鏂囦欢鏈嶅姟鍣紒") ; + } + if(startV.intValue() <= 65535){ + doCheck(startV) ; + } + } + } + + public static class Vo{ + public String id ;//id鎴栧悕绉� + public String fileSysAbsolutePath; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢鏈�缁堝瓨鍌ㄧ粷瀵硅矾寰勪腑鐨勬牴鐩綍锛屽湪閰嶇疆鏂囦欢涓厤缃� + public String fileSysRelativePath; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢鏈�缁堝瓨鍌ㄧ浉瀵硅矾寰勭殑鐩綍锛屽湪閰嶇疆鏂囦欢涓厤缃� + public String restUrl;//鏂囦欢绯荤粺璺緞 + public String webUrl ;//涓嬭浇鏂囨。鐨剋eb璺緞 + public String webDownloadPath ;//涓嬭浇鏂囨。鐨凜ontroller鐨勭浉瀵硅矾寰� + public Integer hashStart ;//鍝堝笇鍊煎惎濮嬪�硷紙鍖呭惈锛� + public Integer hashEnd ;//鍝堝笇鍊兼埅姝㈠�硷紙鍖呭惈锛� + + public Vo(){} + public Vo(String id, + String fileSysAbsolutePath, + String fileSysBasePath, + String restUrl, + String webUrl, + String webDownloadPath, + Integer hashStart, + Integer hashEnd)throws Exception{ + this.id = id ; + this.fileSysAbsolutePath = fileSysAbsolutePath ; + this.fileSysRelativePath = fileSysBasePath ; + this.restUrl = restUrl ; + this.webUrl = webUrl ; + this.webDownloadPath = webDownloadPath ; + this.hashStart = hashStart ; + this.hashEnd = hashEnd ; + if(this.id == null || this.id.trim().equals("")){ + throw new Exception("鍑洪敊锛宨d涓虹┖浜嗭紒") ; + }else{ + this.id = this.id.trim() ; + } + if(this.fileSysAbsolutePath == null || this.fileSysAbsolutePath.trim().equals("")){ + throw new Exception("鍑洪敊锛宖ileSysAbsolutePath涓虹┖浜嗭紒") ; + }else{ + this.fileSysAbsolutePath = this.fileSysAbsolutePath.trim() ; + this.fileSysAbsolutePath = this.fileSysAbsolutePath.replaceAll("\\\\", "/") ; + if(!this.fileSysAbsolutePath.endsWith("/")){ + this.fileSysAbsolutePath = this.fileSysAbsolutePath + "/" ; + } + } + if(this.fileSysRelativePath == null || this.fileSysRelativePath.trim().equals("")){ + throw new Exception("鍑洪敊锛宖ileSysBasePath涓虹┖浜嗭紒") ; + }else{ + this.fileSysRelativePath = this.fileSysRelativePath.trim() ; + } + if(this.webUrl == null || this.webUrl.trim().equals("")){ + throw new Exception("鍑洪敊锛寃ebUrl涓虹┖浜嗭紒") ; + }else{ + this.webUrl = this.webUrl.trim() ; + if(!this.webUrl.endsWith("/") && !this.webUrl.endsWith("\\")){ + this.webUrl += "/" ; + } + } + if(this.webDownloadPath == null || this.webDownloadPath.trim().equals("")){ + throw new Exception("鍑洪敊锛寃ebDownloadPath锛�") ; + } + + if(this.hashStart == null){ + throw new Exception("鍑洪敊锛宧ashStart涓虹┖浜嗭紒") ; + }else if(this.hashStart.intValue() < 0){ + throw new Exception("鍑洪敊锛宧ashStart灏忎簬0浜嗭紒") ; + }else if(this.hashStart.intValue() > 65535){ + throw new Exception("鍑洪敊锛宧ashStart澶т簬65535浜嗭紒") ; + } + if(this.hashEnd == null){ + throw new Exception("鍑洪敊锛宧ashEnd涓虹┖浜嗭紒") ; + }else if(this.hashEnd.intValue() < 0){ + throw new Exception("鍑洪敊锛宧ashEnd灏忎簬0浜嗭紒") ; + }else if(this.hashEnd.intValue() > 65535){ + throw new Exception("鍑洪敊锛宧ashEnd澶т簬65535浜嗭紒") ; + } + if(this.hashEnd < this.hashStart){ + throw new Exception("鍑洪敊锛宧ashEnd灏忎簬hashStart浜嗭紒") ; + } + } + public String toString(){ + return "id=" + id + "\n" + + "fileSysAbsolutePath=" + fileSysAbsolutePath + "\n" + + "fileSysBasePath=" + fileSysRelativePath + "\n" + + "restUrl=" + restUrl + "\n" + + "webUrl=" + webUrl + "\n" + + "webDownloadPath=" + webDownloadPath + "\n" + + "hashStart=" + hashStart + "\n" + + "hashEnd=" + hashEnd ; + } + + + private boolean checkEqual(Vo vo)throws Exception{ + if(this.id.equalsIgnoreCase(vo.id)){ + throw new Exception("鍑洪敊锛宨d鏈夐噸澶嶏紒") ; + } + if(this.hashStart.intValue() == vo.hashStart.intValue()){ + throw new Exception("鍑洪敊锛宧ashStart鏈夐噸澶嶏紒") ; + } + if(this.hashEnd.intValue() == vo.hashEnd.intValue()){ + throw new Exception("鍑洪敊锛宧ashEnd鏈夐噸澶嶏紒") ; + } + if(this.hashStart.intValue() == vo.hashEnd.intValue()){ + throw new Exception("鍑洪敊锛宧ashStart涓巋ashEnd鏈夐噸澶嶏紒") ; + } + if(this.hashEnd.intValue() == vo.hashStart.intValue()){ + throw new Exception("鍑洪敊锛宧ashEnd涓巋ashStart鏈夐噸澶嶏紒") ; + } + return true ; + } + } +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/DyFmListener.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/DyFmListener.java new file mode 100644 index 0000000..ae28607 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/DyFmListener.java @@ -0,0 +1,67 @@ +package com.dy.pipIrrWebFile.fm; + +import com.dy.common.util.NumUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.ApplicationListener; +import org.springframework.core.env.Environment; +import org.springframework.lang.NonNull; +import org.springframework.stereotype.Component; + +@Component +public class DyFmListener implements ApplicationListener<ApplicationReadyEvent> { + + @Autowired + private Environment env; + + public static DyFileSvConf.Group dyFileGroup = new DyFileSvConf.Group() ; + + /** + * SpringBoot瀹瑰櫒宸茬粡鍑嗗濂戒簡 + * @param event 浜嬩欢 + */ + @Override + public void onApplicationEvent(@NonNull ApplicationReadyEvent event) { + try { + //绛�1绉掞紝绛夊緟com.alibaba.druid.pool.DruidDataSource瀹炲鍖栧畬鎴� + Thread.sleep(1000L); + } catch (InterruptedException e) { + e.printStackTrace(); + }finally { + try{ + parseConfig() ; + }catch(Exception e){ + e.printStackTrace(); + dyFileGroup = null ; + } + } + } + private void parseConfig() throws Exception{ + String fmUrl = env.getProperty("dy.webFile.fmUrl"); + for(int i = 1 ; i <= 12 ; i++){ + String id = env.getProperty("dy.webFile.sv" + i + ".id"); + String absolutePath = env.getProperty("dy.webFile.sv" + i + ".absolutePath"); + String relativePath = env.getProperty("dy.webFile.sv" + i + ".relativePath"); + String hashStart = env.getProperty("dy.webFile.sv" + i + ".hashStart"); + String hashEnd = env.getProperty("dy.webFile.sv" + i + ".hashEnd"); + String restUrl = env.getProperty("dy.webFile.sv" + i + ".restUrl"); + String webUrl = env.getProperty("dy.webFile.sv" + i + ".webUrl"); + String webDownloadPath = env.getProperty("dy.webFile.sv" + i + ".webDownloadPath"); + if(!NumUtil.isPlusIntNumber(hashStart)){ + throw new Exception("閰嶇疆dy.webFile.sv" + i + ".hashStart 涓嶆槸鏁存暟") ; + } + if(!NumUtil.isPlusIntNumber(hashEnd)){ + throw new Exception("閰嶇疆dy.webFile.sv" + i + ".hashEnd 涓嶆槸鏁存暟") ; + } + dyFileGroup.add(new DyFileSvConf.Vo(id, + absolutePath, + relativePath, + restUrl, + webUrl, + webDownloadPath, + Integer.parseInt(hashStart), + Integer.parseInt(hashEnd))) ; + } + dyFileGroup.check(); + } +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FileName.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FileName.java new file mode 100644 index 0000000..5be5441 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FileName.java @@ -0,0 +1,20 @@ +package com.dy.pipIrrWebFile.fm; + +import com.dy.common.util.DateTime; + +public class FileName { + + + public static String createFileName(boolean useYmdhms, String id, String fileExtName){ + if(useYmdhms){ + return DateTime.yyyyMMddHHmmss() + "_" + id + "." + fileExtName ; + }else{ + return id + "." + fileExtName ; + } + } + + public static String createIconName(String clientId, String fileExtName){ + return clientId + "_" + DateTime.yyyyMMddHHmmss() + "." + fileExtName ; + } + +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FileNameIdUtil.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FileNameIdUtil.java new file mode 100644 index 0000000..ca41cfb --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FileNameIdUtil.java @@ -0,0 +1,112 @@ +package com.dy.pipIrrWebFile.fm; + +import java.util.Calendar; + +public class FileNameIdUtil { + + private static int add = 0 ; + private static int chengShu = 1000 ; + private static int maxAdd = 999 ; + private static long last = 0 ; + + //鍚庣紑 + //鍦ㄥ垎甯冨紡绯荤粺涓紝渚嬪澶氫釜涓氬姟涓棿浠禿ataMw锛屽涓郴缁熼兘浼氬悜鏁版嵁搴撲腑鎻掑叆鏁版嵁锛岀敤鐨勯兘鏄ID鐢熸垚鍣紝 + //姝D鐢熸垚鍣ㄥ湪鍚勪釜瀛愮郴缁熶腑闅惧厤涓哄悓涓�绫绘暟鎹敓鎴愮浉鍚岀殑ID锛岄�犳垚鏁版嵁搴撴彃鍏ュ洜涓婚敭鐩稿悓鑰屾姤閿�, + //鎵�浠ヨ璁℃鍚庣紑锛屾瘡涓瓙绯荤粺鍚庣紑涓嶅悓 + private static String suffix = "0" ; + + static { + last = current() ; + } + + /** + * 涓鸿嚜瀹炵幇绋嬪簭鎻愪緵鐨処D鐢熸垚鍣� + * 15闀垮害ID锛屽勾搴﹀彇涓や綅锛屽鏋滄槸17浣嶉暱搴D锛屽勾搴﹀彇鍥涗綅锛岄偅17浣嶆暟瀛楄秴鍑轰簡javascript鐨勮〃鏁拌寖鍥� + */ + public String generate(){ + return doGenerate() ; + } + + /** + * 璁剧疆鍚庣紑锛屼笉鍚屽瓙绯荤粺璁剧疆涓嶅悓鐨勫悗缂� + * @param suffix + */ + public static void setSuffix(String suffix)throws Exception{ + if(suffix == null || suffix.trim().equals("")){ + throw new Exception("鍚庣紑涓嶈兘涓虹┖") ; + } + FileNameIdUtil.suffix = suffix.trim() ; + } + + /** + * 鎵ц鐢熸垚 + * @return + */ + private synchronized String doGenerate(){ + Long id = null ; + long now = current() ; + if(now != last){ + //涓婃鐢熸垚ID 涓庢湰娆$敓鎴怚D 涓嶅湪鍚屼竴绉掑唴 + last = now ; + add = 0 ; + id = last * chengShu + add ++; + }else{ + //涓婃鐢熸垚ID 涓庢湰娆$敓鎴怚D 鍦ㄥ悓涓�绉掑唴 + if(add == maxAdd){ + //闄勫姞閲忓凡缁忕敤灏� + waitNextSecond(last) ;//绛夊埌涓嬩竴绉� + id = last * chengShu + add ++ ;//杩斿洖涓婁竴绉掔敓鎴愮殑ID + add = 0 ;//闄勫姞閲忓綊闆讹紝涓轰笅涓�绉掑噯澶� + }else{ + //闄勫姞閲忔湭鐢ㄥ敖 + id = last * chengShu + add ++ ; + } + } + return id + suffix ; + } + /** + * 绛夊緟涓嬩竴绉掑埌鏉� + * @param last + */ + private void waitNextSecond(Long last){ + try { + Thread.sleep(10); + } catch (InterruptedException e) { + }finally{ + long now = current() ; + if(now == last){ + waitNextSecond(last) ; + } + } + } + + + + /** + * 鏍煎紡涓� 150516010203 + * @return + */ + private static long current(){ + Calendar cal = Calendar.getInstance(); + long d = (cal.get(Calendar.YEAR) % 100) * 10000000000L + + (cal.get(Calendar.MONTH) + 1) * 100000000L + + cal.get(Calendar.DAY_OF_MONTH) * 1000000L + + cal.get(Calendar.HOUR_OF_DAY) * 10000L + + cal.get(Calendar.MINUTE) * 100L + + cal.get(Calendar.SECOND) ; + + return d ; + } + + public static void main(String args[]){ + FileNameIdUtil o = new FileNameIdUtil() ; + int total = 800 ; + long start = System.currentTimeMillis() ; + for(int i = 0 ; i < total ; i++){ + System.out.println((String)(o.generate())) ; + } + long end = System.currentTimeMillis() ; + System.out.println("浜х敓" + total + "ID鐢ㄦ椂" + (end - start) + "姣"); + } + +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FileRestVo.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FileRestVo.java new file mode 100644 index 0000000..52bfeac --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FileRestVo.java @@ -0,0 +1,28 @@ +package com.dy.pipIrrWebFile.fm; + +import lombok.Data; + +@Data +public class FileRestVo { + + public String fileName ; //鐢熸垚鐨勬枃浠跺悕绉帮紝渚嬪20170818153254_100000007.jpg + public Integer fileNameHash ; //鏂囦欢鍚嶇О鐨勫搱甯屽�� + public String fileSysId; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢绯荤粺鐨刬d锛屽湪閰嶇疆鏂囦欢涓厤缃� + public String fileSysAbsolutePath; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢鏈�缁堝瓨鍌ㄧ粷瀵硅矾寰勪腑鐨勬牴鐩綍锛屽湪閰嶇疆鏂囦欢涓厤缃� + public String fileSysRelativePath; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢鏈�缁堝瓨鍌ㄧ浉瀵硅矾寰勭殑鐩綍锛屽湪閰嶇疆鏂囦欢涓厤缃� + public String fileSysRestUrl; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢绯荤粺鐨剅estful URL锛屽湪閰嶇疆鏂囦欢涓厤缃� + public String fileWebUrl; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢绯荤粺鐨勪笅杞芥枃浠剁殑web URL锛屽湪閰嶇疆鏂囦欢涓厤缃� + public String fileWebDownloadPath; //涓嬭浇鏂囨。鐨凜ontroller鐨勭浉瀵硅矾寰� + + public String toString(){ + return "fileName=" + fileName + "\n" + + "fileNameHash=" + fileNameHash + "\n" + + "sysId=" + fileSysId + "\n" + + "fileSysAbsolutePath=" + fileSysAbsolutePath + "\n" + + "fileSysRelativePath=" + fileSysRelativePath + "\n" + + "restUrl=" + fileSysRestUrl + "\n" + + "fileWebUrl=" + fileWebUrl + "\n" + + "fileWebDownloadPath=" + fileWebDownloadPath ; + } + +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FmCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FmCtrl.java new file mode 100644 index 0000000..68b27e5 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FmCtrl.java @@ -0,0 +1,133 @@ +package com.dy.pipIrrWebFile.fm; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.List; + +/** + * 鍗曠偣鐧诲綍锛� + */ +@Slf4j +@RestController +@RequestMapping(path="fm") +@SuppressWarnings("unchecked")//java鐗堟湰瓒婇珮锛屽娉涘瀷绾︽潫瓒婁弗锛屾墍浠ラ厤缃甋uppressWarnings("unchecked") +public class FmCtrl { + + /** + * 鐢熸垚鏂囦欢鍚嶏紝骞朵笖璁$畻鍑鸿鏂囦欢鍚嶅搴旂殑鏂囦欢鏈嶅姟鍣ㄥ睘鎬� + * 鏂囦欢鍚嶇О鏄笉甯﹁矾寰勭殑鍚嶇О锛屼緥濡傦細20170818153254_100000007.jpg锛屾枃浠跺悕涓笉鑳芥湁鈥�/鈥濇垨鈥淺鈥濆瓧绗� + * @param fileExtName 鏂囦欢鎵╁睍鍚� + * @return + */ + @PostMapping(path = "create") + public FileRestVo create(String fileExtName){ + FileRestVo rvo = new FileRestVo() ; + if(fileExtName != null && !fileExtName.trim().equals("")){ + try { + String id = new FileNameIdUtil().generate(); + if(id != null){ + rvo.fileName = FileName.createFileName(false, id, fileExtName) ; + rvo = new RestHashDeal().fileTransRest(rvo.fileName, rvo) ; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return rvo ; + } + + /** + * 瑙f瀽鏂囦欢鍚嶏紙甯︽垨涓嶅甫鐩稿璺緞锛夛紝璁$畻鍑鸿鏂囦欢鍚嶅搴旂殑鏂囦欢鏈嶅姟鍣ㄥ睘鎬� + * 鏂囦欢鍚嶇О鍙互鏄笉甯﹁矾寰勭殑鍚嶇О锛屼緥濡傦細20170818153254_100000007.jpg + * 鏂囦欢鍚嶇О鍙互鏄甫璺緞鐨勫悕绉帮紝渚嬪锛歸ebFile/photo/20170818153254_100000007.jpg + * @param filePath + * @return + */ + @PostMapping(path = "parsePath") + public FileRestVo parsePath(String filePath){ + FileRestVo rvo = new FileRestVo() ; + if(filePath != null && !filePath.trim().equals("")){ + try { + int index = filePath.lastIndexOf("\\") ; + if(index > 0){ + filePath = filePath.substring(index + 1); + } + index = filePath.lastIndexOf("/") ; + if(index > 0){ + filePath = filePath.substring(index + 1); + } + index = filePath.lastIndexOf("?") ; + if(index > 0){ + filePath = filePath.substring(0, index); + } + rvo.fileName = filePath ; + rvo = new RestHashDeal().fileTransRest(filePath, rvo) ; + } catch (Exception e) { + e.printStackTrace(); + } + } + return rvo ; + } + /** + * 瑙f瀽鏂囦欢鍚嶏紝骞朵笖璁$畻鍑鸿鏂囦欢鍚嶅搴旂殑鏂囦欢鏈嶅姟鍣ㄥ睘鎬� + * 鏂囦欢鍚嶇О鍙互鏄笉甯﹁矾寰勭殑鍚嶇О锛屼緥濡傦細20170818153254_100000007.jpg + * 鏂囦欢鍚嶇О鍙互鏄甫璺緞鐨勫悕绉帮紝渚嬪锛歸ebFile/photo/20170818153254_100000007.jpg + * @param filePaths + * @return + */ + @PostMapping(path = "parsePathList", consumes = MediaType.APPLICATION_JSON_VALUE)//鍓嶇鎻愪氦json鏁版嵁 + public FileRestVo[] parsePathList(List<String> filePaths){ + List<FileRestVo> rList = new ArrayList<FileRestVo>() ; + if(filePaths != null && filePaths.size() > 0){ + try { + for(String filePath : filePaths){ + FileRestVo rvo = new FileRestVo() ; + int index = filePath.lastIndexOf("\\") ; + if(index > 0){ + filePath = filePath.substring(index + 1); + } + index = filePath.lastIndexOf("/") ; + if(index > 0){ + filePath = filePath.substring(index + 1); + } + index = filePath.lastIndexOf("?") ; + if(index > 0){ + filePath = filePath.substring(0, index); + } + rvo.fileName = filePath ; + rvo = new RestHashDeal().fileTransRest(filePath, rvo) ; + rList.add(rvo) ; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return rList.toArray(new FileRestVo[0]) ; + } + + /** + * 瑙f瀽鍝堝笇鍊硷紝璁$畻鍑鸿鍝堝笇鍊煎搴旂殑鏂囦欢鏈嶅姟鍣ㄥ睘鎬� + * @param hashCode + * @return + */ + @PostMapping(path = "parseHashcode") + public FileRestVo parseHashcode(Integer hashCode){ + FileRestVo rvo = new FileRestVo() ; + if(hashCode != null){ + try { + rvo.fileName = null ; + rvo = new RestHashDeal().fileTransRest(hashCode, rvo) ; + } catch (Exception e) { + e.printStackTrace(); + } + } + return rvo ; + } + + +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/RestHashDeal.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/RestHashDeal.java new file mode 100644 index 0000000..e404408 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/RestHashDeal.java @@ -0,0 +1,95 @@ +package com.dy.pipIrrWebFile.fm; + +import com.dy.common.util.MurmurHash; + +public class RestHashDeal { + + + /** + * 鏂囦欢鍚嶇О璁$畻杞崲 + * @param fileName + * @param rvo + * @return + * @throws Exception + */ + public FileRestVo fileTransRest(String fileName, FileRestVo rvo) throws Exception{ + if(fileName != null + && !fileName.trim().equals("") + && rvo != null){ + if(DyFmListener.dyFileGroup == null + || DyFmListener.dyFileGroup.list == null + || DyFmListener.dyFileGroup.list.size() == 0){ + throw new Exception("涓ラ噸閿欒锛屾枃浠舵湇鍔″櫒restful鏈厤缃紒") ; + }else{ + DyFileSvConf.Vo confVo = null ; + Integer hash = null ; + if(DyFmListener.dyFileGroup.list.size() == 1){ + confVo = DyFmListener.dyFileGroup.list.get(0) ; + }else{ + hash = new MurmurHash().hash16_plus(fileName) ; + for(DyFileSvConf.Vo lvo : DyFmListener.dyFileGroup.list){ + if(hash >= lvo.hashStart.intValue() + && hash <= lvo.hashEnd.intValue()){ + confVo = lvo ; + break ; + } + } + } + if(confVo != null){ + rvo.fileSysId = confVo.id; + rvo.fileNameHash = hash; + rvo.fileSysAbsolutePath = confVo.fileSysAbsolutePath; + rvo.fileSysRelativePath = confVo.fileSysRelativePath; + rvo.fileSysRestUrl = confVo.restUrl; + rvo.fileWebUrl = confVo.webUrl ; + rvo.fileWebDownloadPath = confVo.webDownloadPath ; + } + } + } + return rvo ; + } + + + /** + * 鍝堝笇鍊艰绠楄浆鎹� + * @param hashcode + * @param rvo + * @return + * @throws Exception + */ + public FileRestVo fileTransRest(Integer hashcode, FileRestVo rvo) throws Exception{ + if(hashcode != null + && rvo != null){ + if(DyFmListener.dyFileGroup == null + || DyFmListener.dyFileGroup.list == null + || DyFmListener.dyFileGroup.list.size() == 0){ + throw new Exception("涓ラ噸閿欒锛屾枃浠舵湇鍔″櫒restful鏈厤缃紒") ; + }else{ + DyFileSvConf.Vo confVo = null ; + Integer hash = hashcode ; + if(DyFmListener.dyFileGroup.list.size() == 1){ + confVo = DyFmListener.dyFileGroup.list.get(0) ; + }else{ + for(DyFileSvConf.Vo lvo : DyFmListener.dyFileGroup.list){ + if(hash >= lvo.hashStart.intValue() + && hash <= lvo.hashEnd.intValue()){ + confVo = lvo ; + break ; + } + } + } + if(confVo != null){ + rvo.fileSysId = confVo.id; + rvo.fileNameHash = hash; + rvo.fileSysAbsolutePath = confVo.fileSysAbsolutePath; + rvo.fileSysRelativePath = confVo.fileSysRelativePath; + rvo.fileSysRestUrl = confVo.restUrl; + rvo.fileWebUrl = confVo.webUrl ; + rvo.fileWebDownloadPath = confVo.webDownloadPath ; + } + } + } + return rvo ; + } + +} diff --git "a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/\350\257\264\346\230\216.txt" "b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/\350\257\264\346\230\216.txt" new file mode 100644 index 0000000..54bd0e0 --- /dev/null +++ "b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/\350\257\264\346\230\216.txt" @@ -0,0 +1 @@ +web鍒嗗竷寮忔枃浠剁鐞嗗瓙绯荤粺 \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileConstant.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileConstant.java new file mode 100644 index 0000000..80e0b3f --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileConstant.java @@ -0,0 +1,13 @@ +package com.dy.pipIrrWebFile.util; + + +public class FileConstant { + public static final String YES = "1" ; + public static final String NO = "0" ; + + public static final String phoneFileBasePath = "/phone/" ;//褰曢煶鏂囦欢 + public static final String photoFileBasePath = "/photo/" ;//鐓х墖鏂囦欢 + public static final String videoFileBasePath = "/video/" ;//瑙嗛鏂囦欢 + public static final String iconFileBasePath = "/icon/" ;//澶村儚鏂囦欢 + public static final String documentFileBasePath = "/document/" ;//鏂囨。鏂囦欢 +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileDocumentUtil.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileDocumentUtil.java new file mode 100644 index 0000000..a491f08 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileDocumentUtil.java @@ -0,0 +1,46 @@ +package com.dy.pipIrrWebFile.util; + +import com.dy.common.util.DateTime; +import com.dy.pipIrrGlobal.dyFile.FileConstant; + +import java.io.File; + + +/** + * 鏂囨。绫� + * @author Administrator + * + */ +public class FileDocumentUtil extends FileUtil { + + /** + * 鐢熸垚鏂囦欢鐩稿璺緞鍚嶇О + * + * @param absolutePath + * @param relativePath + * @param regionNum + * @return + */ + public String newFileRelativityPath(String absolutePath, String relativePath, String regionNum) { + String relativityPath = relativePath ; + if(regionNum != null && !regionNum.trim().equals("") && !regionNum.trim().equals(FileConstant.NotRegionNum)){ + relativityPath += regionNum ; + }else{ + if(com.dy.pipIrrWebFile.util.FileConstant.documentFileBasePath.startsWith("/")){ + if(relativityPath.endsWith("/")){ + relativityPath = relativityPath.substring(0, relativityPath.length() - 1) ; + } + } + } + relativityPath += com.dy.pipIrrWebFile.util.FileConstant.documentFileBasePath + DateTime.yyyyMMdd() + "/"; + + String basePath = absolutePath + relativityPath; + File dir = new File(basePath); + if (!dir.exists()) { + dir.mkdirs(); + } + return relativityPath; + } + + +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileIconUtil.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileIconUtil.java new file mode 100644 index 0000000..3d48586 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileIconUtil.java @@ -0,0 +1,38 @@ +package com.dy.pipIrrWebFile.util; + +import com.dy.pipIrrGlobal.dyFile.FileConstant; + +import java.io.File; + +public class FileIconUtil extends FileUtil { + + /** + * 鐢熸垚鏂囦欢鐩稿璺緞鍚嶇О + * + * @param absolutePath + * @param relativePath + * @param regionNum + * @return + */ + public String newFileRelativityPath(String absolutePath, String relativePath, String regionNum) { + String relativityPath = relativePath ; + if(regionNum != null && !regionNum.trim().equals("") && !regionNum.trim().equals(FileConstant.NotRegionNum)){ + relativityPath += regionNum ; + }else{ + if(com.dy.pipIrrWebFile.util.FileConstant.iconFileBasePath.startsWith("/")){ + if(relativityPath.endsWith("/")){ + relativityPath = relativityPath.substring(0, relativityPath.length() - 1) ; + } + } + } + relativityPath += com.dy.pipIrrWebFile.util.FileConstant.iconFileBasePath; + + String basePath = absolutePath + relativityPath; + File dir = new File(basePath); + if (!dir.exists()) { + dir.mkdirs(); + } + return relativityPath; + } + +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FilePhoneUtil.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FilePhoneUtil.java new file mode 100644 index 0000000..4443cd7 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FilePhoneUtil.java @@ -0,0 +1,41 @@ +package com.dy.pipIrrWebFile.util; + +import com.dy.common.util.DateTime; +import com.dy.pipIrrGlobal.dyFile.FileConstant; + +import java.io.File; + +public class FilePhoneUtil extends FileUtil { + + /** + * 鐢熸垚鏂囦欢鐩稿璺緞鍚嶇О + * + * @param absolutePath + * @param relativePath + * @param regionNum + * @return + */ + public String newFileRelativityPath(String absolutePath, String relativePath, String regionNum) { + String relativityPath = relativePath ; + if(regionNum != null && !regionNum.trim().equals("") && !regionNum.trim().equals(FileConstant.NotRegionNum)){ + relativityPath += regionNum ; + }else{ + if(com.dy.pipIrrWebFile.util.FileConstant.phoneFileBasePath.startsWith("/")){ + if(relativityPath.endsWith("/")){ + relativityPath = relativityPath.substring(0, relativityPath.length() - 1) ; + } + } + } + relativityPath += com.dy.pipIrrWebFile.util.FileConstant.phoneFileBasePath + DateTime.yyyyMMdd() + "/"; + + String basePath = absolutePath + relativityPath; + File dir = new File(basePath); + if (!dir.exists()) { + dir.mkdirs(); + } + return relativityPath; + } + + + +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FilePhotoUtil.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FilePhotoUtil.java new file mode 100644 index 0000000..6c92c43 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FilePhotoUtil.java @@ -0,0 +1,39 @@ +package com.dy.pipIrrWebFile.util; + +import com.dy.common.util.DateTime; +import com.dy.pipIrrGlobal.dyFile.FileConstant; + +import java.io.File; + +public class FilePhotoUtil extends FileUtil { + + + /** + * 鐢熸垚鏂囦欢鐩稿璺緞鍚嶇О + * + * @param absolutePath + * @param relativePath + * @param regionNum + * @return + */ + public String newFileRelativityPath(String absolutePath, String relativePath, String regionNum) { + String relativityPath = relativePath ; + if(regionNum != null && !regionNum.trim().equals("") && !regionNum.trim().equals(FileConstant.NotRegionNum)){ + relativityPath += ("-" + regionNum) ; + }else{ + if(com.dy.pipIrrWebFile.util.FileConstant.photoFileBasePath.startsWith("/")){ + if(relativityPath.endsWith("/")){ + relativityPath = relativityPath.substring(0, relativityPath.length() - 1) ; + } + } + } + relativityPath += com.dy.pipIrrWebFile.util.FileConstant.photoFileBasePath + DateTime.yyyyMMdd() + "/"; + String filePath = absolutePath + relativityPath; + File dir = new File(filePath); + if (!dir.exists()) { + dir.mkdirs(); + } + return relativityPath; + } + +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileUtil.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileUtil.java new file mode 100644 index 0000000..5b3bd58 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileUtil.java @@ -0,0 +1,122 @@ +package com.dy.pipIrrWebFile.util; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.RandomAccessFile; +import java.nio.channels.FileChannel; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + + +public class FileUtil { + + protected static final Logger log = LogManager.getLogger(FileUtil.class.getName()) ; + /** + * 淇濆瓨鏂囦欢 + * @param fileAbsolutelyPath 鏂囦欢缁濆璺緞 + * @param input + * @return 淇濆瓨鏂囦欢鐨勬槸鍚︽垚鍔熺殑缁撴灉 + */ + public boolean saveFile(String fileAbsolutelyPath , InputStream input){ + boolean success = true ; + if(fileAbsolutelyPath == null || input == null){ + success = false ; + }else{ + OutputStream os = null; + try { + os = new FileOutputStream(fileAbsolutelyPath); + byte[] b = new byte[1024] ; + int len = input.read(b) ; + while(len > 0){ + os.write(b, 0, len); + len = input.read(b) ; + os.flush(); + } + } catch (Exception e) { + e.printStackTrace(); + success = false ; + } finally { + try { + if(os != null){ + os.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return success ; + } + /** + * 澶嶅埗鏂囦欢 + * @param fromFile + * @param realPath 缁濆璺緞 + * @param newFileRelativityPath 鐩稿璺緞 + * @return + */ + public boolean copyFile(File fromFile, String realPath, String newFileRelativityPath){ + boolean flag = true ; + FileChannel fromChannel = null ; + FileChannel toChannel = null ; + try { + fromChannel = new RandomAccessFile(fromFile, "r").getChannel(); + toChannel = new RandomAccessFile(new File(realPath + newFileRelativityPath), "rw").getChannel(); + fromChannel.transferTo(0, fromChannel.size(), toChannel); + } catch (FileNotFoundException e) { + flag = false ; + log.error("澶嶅埗鏂囦欢鍑洪敊:" + e.getMessage()) ; + } catch (IOException e) { + flag = false ; + log.error("澶嶅埗鏂囦欢鍑洪敊:" + e.getMessage()) ; + }finally{ + try{ + if(fromChannel != null){ + fromChannel.close() ; + } + if(toChannel != null){ + toChannel.close() ; + } + }catch(Exception e){}finally{} + } + return flag ; + } + + /** + * 鍒犻櫎鏂囦欢 + * @param f + */ + public boolean deleteFile(File f){ + boolean flag = false ; + try{ + if(f != null){ + flag = f.delete() ; + } + }catch(Exception e){ + }finally{} + return flag ; + } + + /** + * 鍒犻櫎鏂囦欢 + * @param path + */ + public boolean deleteFile(String path){ + boolean flag = false ; + try{ + if(path != null && !path.equals("")){ + File f = new File(path) ; + if(f != null && f.exists()){ + flag = f.delete() ; + } + } + }catch(Exception e){ + }finally{} + return flag ; + } + +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileVideoUtil.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileVideoUtil.java new file mode 100644 index 0000000..63c8d70 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/FileVideoUtil.java @@ -0,0 +1,39 @@ +package com.dy.pipIrrWebFile.util; + +import com.dy.common.util.DateTime; +import com.dy.pipIrrGlobal.dyFile.FileConstant; + +import java.io.File; + +public class FileVideoUtil extends FileUtil { + + /** + * 鐢熸垚鏂囦欢鐩稿璺緞鍚嶇О + * + * @param absolutePath + * @param relativePath + * @param regionNum + * @return + */ + public String newFileRelativityPath(String absolutePath, String relativePath, String regionNum) { + String relativityPath = relativePath ; + if(regionNum != null && !regionNum.trim().equals("") && !regionNum.trim().equals(FileConstant.NotRegionNum)){ + relativityPath += regionNum ; + }else{ + if(com.dy.pipIrrWebFile.util.FileConstant.videoFileBasePath.startsWith("/")){ + if(relativityPath.endsWith("/")){ + relativityPath = relativityPath.substring(0, relativityPath.length() - 1) ; + } + } + } + relativityPath += com.dy.pipIrrWebFile.util.FileConstant.videoFileBasePath + DateTime.yyyyMMdd() + "/"; + + String basePath = absolutePath + relativityPath; + File dir = new File(basePath); + if (!dir.exists()) { + dir.mkdirs(); + } + return relativityPath; + } + +} 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..180ca61 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/util/ZipImg.java @@ -0,0 +1,63 @@ +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 zipToPng(File file, int xSize, int ySize) throws Exception{ + return zip(file, "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 ; + } + + 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(); + } + } + +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/resources/application.yml b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/resources/application.yml new file mode 100644 index 0000000..047c937 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/resources/application.yml @@ -0,0 +1,16 @@ +spring: + profiles: + include: global, database, database-ym, database-pj, database-test + +#actutor鐨剋eb绔彛 +management: + server: + port: ${pipIrr.file1.actutorPort} +#web鏈嶅姟绔彛锛宼omcat榛樿鏄�8088 +server: + port: ${pipIrr.file1.webPort} + servlet: + context-path: /file #web璁块棶涓婁笅鏂囪矾寰� + context-parameters: + #GenerateIdSetSuffixListener涓簲鐢紝鍙栧�艰寖鍥存槸0-99 + idSuffix: ${pipIrr.file.idSuffix} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/resources/log4j2.yml b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/resources/log4j2.yml new file mode 100644 index 0000000..cd6cccc --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/resources/log4j2.yml @@ -0,0 +1,71 @@ +Configuration: + #status锛岃繖涓敤浜庤缃甽og4j2鑷韩鍐呴儴鐨勪俊鎭緭鍑猴紝鍙互涓嶈缃紝褰撹缃垚trace鏃讹紝浣犱細鐪嬪埌log4j2鍐呴儴鍚勭璇︾粏杈撳嚭锛涘彲浠ヨ缃垚Off(鍏抽棴)鎴朎rror(鍙緭鍑洪敊璇俊鎭�) + status: Error + + Properties: # 瀹氫箟鍏ㄥ眬鍙橀噺 + Property: + #鏃ュ織鏂囦欢瀛樺偍鐨勭洰褰� + - name: log.path + value: ./logs + #鏃ュ織鏂囦欢瀛樺偍鍚嶇О + - name: project.name + value: pipIrrFile + + #瀹氫箟杈撳嚭鍣紝鍙互杈撳嚭鍒版帶鍒跺彴鍜屾枃浠�. + Appenders: + #杈撳嚭鍒版帶鍒跺彴 + Console: + #Appender鍛藉悕 + name: CONSOLE + target: SYSTEM_OUT + ThresholdFilter: + level: debug #杈撳嚭鏃ュ織绾у埆锛岃緭鍑烘棩蹇楁椂锛岄鍏堢敱Loggers.Root.level鎴朙oggers.Logger.level鍒ゆ柇鏄惁杈撳嚭锛岀劧鍚庡啀鐢辨湰level鍒ゆ柇鏄惁杈撳嚭 + onMatch: ACCEPT #onMatch=ACCEPT 澶т簬绛変簬 "level" 閰嶇疆鐨勭瓑绾у湴鏃ュ織杈撳嚭 + onMismatch: DENY #onMismatch=DENY 灏忎簬 "level" 閰嶇疆鐨勭瓑绾у湴鏃ュ織涓嶈緭鍑� + #鏃ュ織鍐呭鏍峰紡 + PatternLayout: + #%n-鎹㈣ + #%m-鏃ュ織鍐呭锛岃緭鍑轰唬鐮佷腑鎸囧畾鐨勬棩蹇椾俊鎭� + #%p-杈撳嚭浼樺厛绾э紝鍗矰EBUG,INFO,WARN,ERROR,FATAL + #%r-绋嬪簭鍚姩鍒扮幇鍦ㄧ殑姣鏁� + #%%- 杈撳嚭涓�涓�"%" 瀛楃 + #%t-褰撳墠绾跨▼鍚� + #%d-鏃ユ湡鍜屾椂闂�, 甯哥敤鐨勬牸寮忔湁%d{DATE},%d{ABSOLUTE},%d{HH:mm:ss,SSS},%d{ddMMyyyyHH:mm:ss,SSS} + #%l-鍚�%F%L%C%M + #%F-java婧愭枃浠跺悕 + #%L-java婧愮爜琛屾暟 + #%C-java绫诲悕,%C{1}杈撳嚭鏈�鍚庝竴涓厓绱� + #%M-java鏂规硶鍚� + pattern: "%d{yyyy-MM-dd HH:mm:ss,SSS}:%4p %t (%C.%M:%L) - %m%n" + # 杈撳嚭鍒版枃浠讹紝瓒呰繃10MB褰掓。 + RollingFile: + - name: ROLLING_FILE + ignoreExceptions: false + fileName: ${log.path}/${project.name}.log + filePattern: "${log.path}/${project.name}-%d{yyyy-MM-dd}-%i.log.gz" + ThresholdFilter: + level: error #杈撳嚭鏃ュ織绾у埆锛岃緭鍑烘棩蹇楁椂锛岄鍏堢敱Loggers.Root.level鎴朙oggers.Logger.level鍒ゆ柇鏄惁杈撳嚭锛岀劧鍚庡啀鐢辨湰level鍒ゆ柇鏄惁杈撳嚭 + onMatch: ACCEPT #onMatch=ACCEPT 澶т簬绛変簬 "level" 閰嶇疆鐨勭瓑绾у湴鏃ュ織杈撳嚭 + onMismatch: DENY #onMismatch=DENY 灏忎簬 "level" 閰嶇疆鐨勭瓑绾у湴鏃ュ織涓嶈緭鍑� + #鏃ュ織鍐呭鏍峰紡 + PatternLayout: + pattern: "%d{yyyy-MM-dd HH:mm:ss,SSS}:%4p %t (%C.%M:%L) - %m%n" + Policies: + # 姣忓ぉ鏃ュ織鏂囦欢鎸夊ぇ灏忓垎瀛愭枃浠� + SizeBasedTriggeringPolicy: + size: "1 MB" + DefaultRolloverStrategy: + max: 10 #涓�澶╁唴鏃ュ織鏂囦欢鏈�澶т釜鏁� + Delete: + basePath: "${log.path}" + maxDepth: 2 #鍒犻櫎鏃ュ織鏂囦欢鐨勬渶澶ф繁搴� + IfFileName: + glob: "${project.name}-%d{yyyy-MM-dd}-%i.log.gz" + IfLastModified: + age: "30d" #鏃ュ織鏂囦欢淇濈暀鐨勬渶澶уぉ鏁� + Loggers: + Root: + level: info #鏃ュ織杈撳嚭绾у埆锛屽叡鏈�8涓骇鍒紝鎸夌収浠庝綆鍒伴珮涓猴細all < trace < debug < info < warn < error < fatal < off + AppenderRef: #Root鐨勫瓙鑺傜偣锛岀敤鏉ユ寚瀹氳鏃ュ織杈撳嚭鍒板摢涓狝ppender. + - ref: CONSOLE #杈撳嚭鏃ュ織鏃讹紝棣栧厛鐢辨湰level鍒ゆ柇鏄惁杈撳嚭锛岀劧鍚庡啀鐢变笂闈㈢殑Appenders.Console.ThresholdFilter.level鍒ゆ柇鏄惁杈撳嚭 + - ref: ROLLING_FILE #杈撳嚭鏃ュ織鏃讹紝棣栧厛鐢辨湰level鍒ゆ柇鏄惁杈撳嚭锛岀劧鍚庡啀鐢变笂闈㈢殑Appenders.RollingFile.ThresholdFilter.level鍒ゆ柇鏄惁杈撳嚭 diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/test/java/com/dy/pipIrrWebFile/PipIrrWebFileApplicationTests.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/test/java/com/dy/pipIrrWebFile/PipIrrWebFileApplicationTests.java new file mode 100644 index 0000000..1e4d764 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/test/java/com/dy/pipIrrWebFile/PipIrrWebFileApplicationTests.java @@ -0,0 +1,13 @@ +package com.dy.pipIrrWebFile; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class PipIrrWebFileApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/pipIrr-platform/pipIrr-web/pom.xml b/pipIrr-platform/pipIrr-web/pom.xml index 7d26034..9e59107 100644 --- a/pipIrr-platform/pipIrr-web/pom.xml +++ b/pipIrr-platform/pipIrr-web/pom.xml @@ -31,6 +31,7 @@ <module>pipIrr-web-wechat</module> <module>pipIrr-web-app</module> <module>pipIrr-web-operation</module> + <module>pipIrr-web-file</module> </modules> <dependencies> @@ -180,6 +181,13 @@ <artifactId>jdom2</artifactId> </dependency> + <!-- thumbnailator 鐢熸垚鍥剧墖缂╃暐鍥� --> + <dependency> + <groupId>net.coobird</groupId> + <artifactId>thumbnailator</artifactId> + <version>0.4.20</version> + </dependency> + <!-- bean鍜宮ap浜掕浆鎹� --> <dependency> <groupId>org.apache.dubbo</groupId> -- Gitblit v1.8.0