| | |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | Cd_83_Up obj = new Cd_83_Up() ; |
| | | String hex = "683C68B08485353448830200000000001000282353FE739444000001000313000101211615000101210000000000000000000200019000011518000101210A7B16"; |
| | | //ä¸é¢ä¸¤æ¡ä¸æ¥æ°æ®ï¼ICå¡ç¼ç 齿¯éBCDç¼ç èå¼å¸¸ |
| | | //String hex = "683C68B08485353448830200000000001000282353FE739444000001000313000101211615000101210000000000000000000200019000011518000101210A7B16"; |
| | | String hex = "683C68B05301154CEA8306001000000004343638483BBBB9E0001000001603000101215907000101210000000000000000000500019000015308000101210AF716"; |
| | | byte[] bs = ByteUtil.hex2Bytes(hex) ; |
| | | |
| | | Data data = new Data() ; |
New file |
| | |
| | | package com.dy.common.util; |
| | | |
| | | /** |
| | | * MurmurHashç®æ³ï¼é«è¿ç®æ§è½ï¼ä½ç¢°æçï¼ç±Austin Applebyå建äº2008å¹´ï¼ |
| | | * ç°å·²åºç¨å°Hadoopãlibstdc++ãnginxãlibmemcachedç弿ºç³»ç»ã2011å¹´ |
| | | * Appleby被Googleéä½£ï¼éåGoogleæ¨åºå
¶åç§çCityHashç®æ³ã |
| | | * |
| | | * 宿¹ç½ç«ï¼https://sites.google.com/site/murmurhash/ |
| | | * |
| | | * MurmurHashç®æ³ï¼èªç§°è¶
级快çhashç®æ³ï¼æ¯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 |
| | | * |
| | | * ä½ä¹ææç« 声称ï¼åªæå½keyçé¿åº¦å¤§äº10åèçæ¶åï¼MurmurHashçè¿ç®é |
| | | * 度æå¿«äºDJBãä»è®¡ç®éåº¦ä¸æ¥çï¼MurmurHashåªéç¨äºå·²ç¥é¿åº¦çãé¿åº¦æ¯ |
| | | * è¾é¿çå符ã |
| | | * |
| | | * åå¸å¼åå¸é常ååï¼å³ä½ç¢°æç |
| | | * æ¯Crc16æ´ä¸ºåå |
| | | */ |
| | | 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("================="); |
| | | } |
| | | } |
New file |
| | |
| | | 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); |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.dyFile; |
| | | |
| | | public class FileConstant { |
| | | public static final String NotRegionNum = "-1"; //å¨webæä»¶ç³»ç»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" ;//åæ°åç§° |
| | | } |
New file |
| | |
| | | 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; |
| | | // åéPOSTè¯·æ± |
| | | 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) ; |
| | | |
| | | // åéPOSTè¯·æ± |
| | | return restTemplate.postForObject(fileRestUrl, requestEntity, Object.class).toString(); |
| | | } |
| | | |
| | | /** |
| | | * è§£ææä»¶åç§° |
| | | * @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; |
| | | // åéPOSTè¯·æ± |
| | | FileRestVo rvo = restTemplate.postForObject(webUrl, requestEntity, FileRestVo.class); |
| | | |
| | | return rvo ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * è§£ææä»¶åç§° |
| | | * @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; |
| | | // åéPOSTè¯·æ± |
| | | FileRestVo[] rvos = restTemplate.postForObject(webUrl, requestEntity, FileRestVo[].class); |
| | | rList = Arrays.asList(rvos) ; |
| | | } |
| | | return rList ; |
| | | } |
| | | |
| | | /** |
| | | * è§£ææä»¶åå¸å¼ |
| | | * @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; |
| | | // åéPOSTè¯·æ± |
| | | FileRestVo rvo = restTemplate.postForObject(webUrl, requestEntity, FileRestVo.class); |
| | | |
| | | return rvo ; |
| | | } |
| | | |
| | | /** |
| | | * è§£ææä»¶æä»¶è·¯å¾ä¸çåå¸å¼å¹¶è¿åå¾ç宿´è·¯å¾ |
| | | * @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 ; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.dyFile; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class FileRestVo { |
| | | |
| | | |
| | | public String fileName ; //çæçæä»¶åç§°ï¼ä¾å¦20170818153254_100000007.jpg |
| | | public Integer fileNameHash ; //æä»¶åç§°çåå¸å¼ |
| | | public String fileSysId; //æä»¶åç§°çåå¸å¼å¯¹åºçæä»¶ç³»ç»çidï¼å¨é
ç½®æä»¶ä¸é
ç½® |
| | | public String fileSysAbsolutePath; //æä»¶åç§°çåå¸å¼å¯¹åºçæä»¶æç»åå¨ç»å¯¹è·¯å¾ä¸çæ ¹ç®å½ï¼å¨é
ç½®æä»¶ä¸é
ç½® |
| | | public String fileSysRelativePath; //æä»¶åç§°çåå¸å¼å¯¹åºçæä»¶æç»åå¨ç¸å¯¹è·¯å¾çç®å½ï¼å¨é
ç½®æä»¶ä¸é
ç½® |
| | | public String fileSysRestUrl; //æä»¶åç§°çåå¸å¼å¯¹åºçæä»¶ç³»ç»çrestful URLï¼å¨é
ç½®æä»¶ä¸é
ç½® |
| | | public String fileWebPath; //æä»¶åç§°çåå¸å¼å¯¹åºçæä»¶ç³»ç»çæ¾ç¤ºåä¸è½½æä»¶çweb pathï¼å¨æçæ |
| | | public String fileWebUrl; //æä»¶åç§°çåå¸å¼å¯¹åºçæä»¶ç³»ç»çæ¾ç¤ºæä»¶çweb URLï¼å¨é
ç½®æä»¶ä¸é
ç½® |
| | | public String fileWebDownloadPath; //ä¸è½½ææ¡£çControllerçç¸å¯¹è·¯å¾ |
| | | |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * æ¤æ¹æ³ä¸ç¨äºï¼å 为æä»¶åç§°åé¢å ä¸ ï¼hashcodeåï¼ä¸è½½æä»¶ç±»ä¸å°æ¾å°ä¸æä»¶ |
| | | * éæ°å建fileSysWebUrl |
| | | * @param relativeFilePath |
| | | * @param hashcode |
| | | public void createFilePath(String relativeFilePath, Integer hashcode){ |
| | | if(relativeFilePath != null){ |
| | | if(relativeFilePath.indexOf("?") < 0){ |
| | | this.fileWebPath = relativeFilePath + "?" + hashcode; |
| | | } |
| | | } |
| | | } |
| | | */ |
| | | } |
New file |
| | |
| | | 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 ;//æä»¶åhash |
| | | 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 ; |
| | | } |
| | | } |
New file |
| | |
| | | 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; |
| | | } |
| | | } |
New file |
| | |
| | | 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ç±»åï¼MPå°èªå¨ä¸ºå
¶èµå¼ï¼éªè±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; |
| | | |
| | | } |
New file |
| | |
| | | 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 ; |
| | | |
| | | /** |
| | | * ä¸ä¼ ç
§çå¾çæä»¶ ï¼å½ååªå¯¹png 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("请ä¸ä¼ Word,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) ; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | 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 ; |
| | | } |
| | | } |
New file |
| | |
| | | 项ç®çº§å
¨å±Controllerï¼ææä¾èµpipIrr-globalçæ¨¡å齿è¿äºå
¨å±çController |
| | |
| | | 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çwebä¸ä¸æ URL |
| | | supportedFileTypes: docx,xlsx,doc,xls,pdf #æ¯æçææ¡£ï¼éç
§çãå½é³ãå½åï¼æä»¶ç±»å |
| | | 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ææ¬å°IP |
| | | webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ #nginxæå¡è·¯å¾,å®è£
é¨ç½²æ¶IPæ¹æå¤ç½IPæåå |
| | | webDownloadPath: http://127.0.0.1:${pipIrr.file1.webPort}/file/download/down?id= #å®è£
é¨ç½²æ¶IPæ¹æå¤ç½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 |
| | |
| | | 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çwebä¸ä¸æ URL |
| | | supportedFileTypes: docx,xlsx,doc,xls,pdf #æ¯æçææ¡£ï¼éç
§çãå½é³ãå½åï¼æä»¶ç±»å |
| | | 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ææ¬å°IP |
| | | webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ #nginxæå¡è·¯å¾,å®è£
é¨ç½²æ¶IPæ¹æå¤ç½IPæåå |
| | | webDownloadPath: http://127.0.0.1:${pipIrr.file1.webPort}/file/download/down?id= #å®è£
é¨ç½²æ¶IPæ¹æå¤ç½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 |
| | |
| | | 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çwebä¸ä¸æ URL |
| | | supportedFileTypes: docx,xlsx,doc,xls,pdf #æ¯æçææ¡£ï¼éç
§çãå½é³ãå½åï¼æä»¶ç±»å |
| | | 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ææ¬å°IP |
| | | webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ #nginxæå¡è·¯å¾,å®è£
é¨ç½²æ¶IPæ¹æå¤ç½IPæåå |
| | | webDownloadPath: http://127.0.0.1:${pipIrr.file1.webPort}/file/download/down?id= #å®è£
é¨ç½²æ¶IPæ¹æå¤ç½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 |
| | |
| | | global: |
| | | dev: false #æ¯å¦å¼åé¶æ®µï¼trueæfalse |
| | | dsName: ym #å¼åé¶æ®µï¼è®¾ç½®ä¸´æ¶çæ°æ®åºåç§° |
| | | nginx: |
| | | webPort: 54321 |
| | | mw: |
| | | webPort: 8070 |
| | | actutorPort: 9070 |
| | |
| | | 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çwebä¸ä¸æ URL |
| | | supportedFileTypes: docx,xlsx,doc,xls,pdf #æ¯æçææ¡£ï¼éåªä½æä»¶ï¼å¦ç
§çãå½é³ãå½åï¼æä»¶ç±»å |
| | | 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ææ¬å°IP |
| | | webUrl: http://127.0.0.1:${pipIrr.nginx.webPort}/webfiles/ #nginxæå¡è·¯å¾,å®è£
é¨ç½²æ¶IPæ¹æå¤ç½IPæåå |
| | | webDownloadPath: http://127.0.0.1:${pipIrr.file1.webPort}/file/download/down?id= #å®è£
é¨ç½²æ¶IPæ¹æå¤ç½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 |
New file |
| | |
| | | <?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> |
New file |
| | |
| | | /mvnw text eol=lf |
| | | *.cmd text eol=crlf |
New file |
| | |
| | | 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/ |
New file |
| | |
| | | # 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 |
New file |
| | |
| | | #!/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 "$@" |
New file |
| | |
| | | <# : 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" |
New file |
| | |
| | | <?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> |
| | | <!-- çæä¸å
å«ä¾èµjarç坿§è¡jarå
|
| | | <plugin> |
| | | !- spring bootæä¾çmavenæå
æä»¶ - |
| | | <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> |
| | | --> |
| | | <!-- æ·è´ä¾èµçjarå
å°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}æ¯mavenåéï¼å
ç½®çï¼è¡¨ç¤ºtargetç®å½,妿ä¸åï¼å°å¨æ ¹ç®å½ä¸å建/lib --> |
| | | <outputDirectory>${project.build.directory}/lib</outputDirectory> |
| | | <!-- excludeTransitive:æ¯å¦ä¸å
å«é´æ¥ä¾èµå
ï¼æ¯å¦æä»¬ä¾èµAï¼ä½æ¯Aåä¾èµäºBï¼æä»¬æ¯å¦ä¹è¦æBæè¿å» é»è®¤ä¸æ--> |
| | | <excludeTransitive>false</excludeTransitive> |
| | | <!-- å¤å¶çjaræä»¶å»æçæ¬ä¿¡æ¯ --> |
| | | <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ï¼ ç®æ å¹³å°ç¼è¯çæ¬ï¼encodingï¼ å符éç¼ç ã --> |
| | | <configuration> |
| | | <source>${java.version}</source> |
| | | <target>${java.version}</target> |
| | | <encoding>${encoding}</encoding> |
| | | </configuration> |
| | | </plugin> |
| | | <plugin> |
| | | <!-- è§£å³èµæºæä»¶çç¼ç é®é¢ --> |
| | | <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> |
| | | <!-- ä¸é¢è§£å³ï¼å½è¿è¡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> |
New file |
| | |
| | | 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); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | 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çæ¬è¶é«ï¼å¯¹æ³å约æè¶ä¸¥ï¼æä»¥é
ç½®SuppressWarnings("unchecked") |
| | | public class DownloadFileCtrl { |
| | | |
| | | @Autowired |
| | | private DownloadFileSv sv ; |
| | | |
| | | @Autowired |
| | | private FileOperate fileOp ; |
| | | |
| | | @Value("${dy.webFile.fmUrl}") |
| | | private String fmUrl ; |
| | | |
| | | |
| | | /** |
| | | * éè¿webæä»¶æ°æ®åºå®ä½idä¸è½½è¯¥æä»¶ |
| | | * @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); |
| | | } |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * ç¨IDæ¥è¯¢ |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public WebFile selectById(String id){ |
| | | if(NumUtil.isPlusIntNumber(id)){ |
| | | return dao.selectByPrimaryKey(Long.parseLong(id)) ; |
| | | }else{ |
| | | return null ; |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | 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çæ¬è¶é«ï¼å¯¹æ³å约æè¶ä¸¥ï¼æä»¥é
ç½®SuppressWarnings("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åå¸å¼æä»¶ç³»ç»ä¿åææ¡£æä»¶ |
| | | * @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 ; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | 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 ;//ä¸è½½ææ¡£çwebè·¯å¾ |
| | | public String webDownloadPath ;//ä¸è½½ææ¡£çControllerçç¸å¯¹è·¯å¾ |
| | | 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("åºéï¼id为空äºï¼") ; |
| | | }else{ |
| | | this.id = this.id.trim() ; |
| | | } |
| | | if(this.fileSysAbsolutePath == null || this.fileSysAbsolutePath.trim().equals("")){ |
| | | throw new Exception("åºéï¼fileSysAbsolutePath为空äºï¼") ; |
| | | }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("åºéï¼fileSysBasePath为空äºï¼") ; |
| | | }else{ |
| | | this.fileSysRelativePath = this.fileSysRelativePath.trim() ; |
| | | } |
| | | if(this.webUrl == null || this.webUrl.trim().equals("")){ |
| | | throw new Exception("åºéï¼webUrl为空äºï¼") ; |
| | | }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("åºéï¼webDownloadPathï¼") ; |
| | | } |
| | | |
| | | if(this.hashStart == null){ |
| | | throw new Exception("åºéï¼hashStart为空äºï¼") ; |
| | | }else if(this.hashStart.intValue() < 0){ |
| | | throw new Exception("åºéï¼hashStartå°äº0äºï¼") ; |
| | | }else if(this.hashStart.intValue() > 65535){ |
| | | throw new Exception("åºéï¼hashStart大äº65535äºï¼") ; |
| | | } |
| | | if(this.hashEnd == null){ |
| | | throw new Exception("åºéï¼hashEnd为空äºï¼") ; |
| | | }else if(this.hashEnd.intValue() < 0){ |
| | | throw new Exception("åºéï¼hashEndå°äº0äºï¼") ; |
| | | }else if(this.hashEnd.intValue() > 65535){ |
| | | throw new Exception("åºéï¼hashEnd大äº65535äºï¼") ; |
| | | } |
| | | if(this.hashEnd < this.hashStart){ |
| | | throw new Exception("åºéï¼hashEndå°äº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("åºéï¼idæéå¤ï¼") ; |
| | | } |
| | | if(this.hashStart.intValue() == vo.hashStart.intValue()){ |
| | | throw new Exception("åºéï¼hashStartæéå¤ï¼") ; |
| | | } |
| | | if(this.hashEnd.intValue() == vo.hashEnd.intValue()){ |
| | | throw new Exception("åºéï¼hashEndæéå¤ï¼") ; |
| | | } |
| | | if(this.hashStart.intValue() == vo.hashEnd.intValue()){ |
| | | throw new Exception("åºéï¼hashStartä¸hashEndæéå¤ï¼") ; |
| | | } |
| | | if(this.hashEnd.intValue() == vo.hashStart.intValue()){ |
| | | throw new Exception("åºéï¼hashEndä¸hashStartæéå¤ï¼") ; |
| | | } |
| | | return true ; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | 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(); |
| | | } |
| | | } |
New file |
| | |
| | | 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 ; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | 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 ; |
| | | |
| | | //åç¼ |
| | | //å¨åå¸å¼ç³»ç»ä¸ï¼ä¾å¦å¤ä¸ªä¸å¡ä¸é´ä»¶dataMwï¼å¤ä¸ªç³»ç»é½ä¼åæ°æ®åºä¸æå
¥æ°æ®ï¼ç¨ç齿¯æ¤IDçæå¨ï¼ |
| | | //æ¤IDçæå¨å¨å个åç³»ç»ä¸é¾å
为åä¸ç±»æ°æ®çæç¸åçIDï¼é ææ°æ®åºæå
¥å 主é®ç¸åèæ¥é, |
| | | //æä»¥è®¾è®¡æ¤åç¼ï¼æ¯ä¸ªåç³»ç»åç¼ä¸å |
| | | private static String suffix = "0" ; |
| | | |
| | | static { |
| | | last = current() ; |
| | | } |
| | | |
| | | /** |
| | | * 为èªå®ç°ç¨åºæä¾çIDçæå¨ |
| | | * 15é¿åº¦IDï¼å¹´åº¦å两ä½ï¼å¦ææ¯17ä½é¿åº¦IDï¼å¹´åº¦ååä½ï¼é£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 䏿¬æ¬¡çæID ä¸å¨åä¸ç§å
|
| | | last = now ; |
| | | add = 0 ; |
| | | id = last * chengShu + add ++; |
| | | }else{ |
| | | //䏿¬¡çæID 䏿¬æ¬¡çæID å¨åä¸ç§å
|
| | | 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) + "毫ç§"); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrWebFile.fm; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class FileRestVo { |
| | | |
| | | public String fileName ; //çæçæä»¶åç§°ï¼ä¾å¦20170818153254_100000007.jpg |
| | | public Integer fileNameHash ; //æä»¶åç§°çåå¸å¼ |
| | | public String fileSysId; //æä»¶åç§°çåå¸å¼å¯¹åºçæä»¶ç³»ç»çidï¼å¨é
ç½®æä»¶ä¸é
ç½® |
| | | public String fileSysAbsolutePath; //æä»¶åç§°çåå¸å¼å¯¹åºçæä»¶æç»åå¨ç»å¯¹è·¯å¾ä¸çæ ¹ç®å½ï¼å¨é
ç½®æä»¶ä¸é
ç½® |
| | | public String fileSysRelativePath; //æä»¶åç§°çåå¸å¼å¯¹åºçæä»¶æç»åå¨ç¸å¯¹è·¯å¾çç®å½ï¼å¨é
ç½®æä»¶ä¸é
ç½® |
| | | public String fileSysRestUrl; //æä»¶åç§°çåå¸å¼å¯¹åºçæä»¶ç³»ç»çrestful URLï¼å¨é
ç½®æä»¶ä¸é
ç½® |
| | | public String fileWebUrl; //æä»¶åç§°çåå¸å¼å¯¹åºçæä»¶ç³»ç»çä¸è½½æä»¶çweb URLï¼å¨é
ç½®æä»¶ä¸é
ç½® |
| | | public String fileWebDownloadPath; //ä¸è½½ææ¡£çControllerçç¸å¯¹è·¯å¾ |
| | | |
| | | 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 ; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | 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çæ¬è¶é«ï¼å¯¹æ³å约æè¶ä¸¥ï¼æä»¥é
ç½®SuppressWarnings("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 ; |
| | | } |
| | | |
| | | /** |
| | | * è§£ææä»¶åï¼å¸¦æä¸å¸¦ç¸å¯¹è·¯å¾ï¼ï¼è®¡ç®åºè¯¥æä»¶å对åºçæä»¶æå¡å¨å±æ§ |
| | | * æä»¶åç§°å¯ä»¥æ¯ä¸å¸¦è·¯å¾çåç§°ï¼ä¾å¦ï¼20170818153254_100000007.jpg |
| | | * æä»¶åç§°å¯ä»¥æ¯å¸¦è·¯å¾çåç§°ï¼ä¾å¦ï¼webFile/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 ; |
| | | } |
| | | /** |
| | | * è§£ææä»¶åï¼å¹¶ä¸è®¡ç®åºè¯¥æä»¶å对åºçæä»¶æå¡å¨å±æ§ |
| | | * æä»¶åç§°å¯ä»¥æ¯ä¸å¸¦è·¯å¾çåç§°ï¼ä¾å¦ï¼20170818153254_100000007.jpg |
| | | * æä»¶åç§°å¯ä»¥æ¯å¸¦è·¯å¾çåç§°ï¼ä¾å¦ï¼webFile/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]) ; |
| | | } |
| | | |
| | | /** |
| | | * è§£æåå¸å¼ï¼è®¡ç®åºè¯¥åå¸å¼å¯¹åºçæä»¶æå¡å¨å±æ§ |
| | | * @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 ; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | 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 ; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | webåå¸å¼æä»¶ç®¡çåç³»ç» |
New file |
| | |
| | | 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/" ;//ææ¡£æä»¶ |
| | | } |
New file |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | 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 ; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | spring: |
| | | profiles: |
| | | include: global, database, database-ym, database-pj, database-test |
| | | |
| | | #actutorçwebç«¯å£ |
| | | management: |
| | | server: |
| | | port: ${pipIrr.file1.actutorPort} |
| | | #webæå¡ç«¯å£ï¼tomcaté»è®¤æ¯8088 |
| | | server: |
| | | port: ${pipIrr.file1.webPort} |
| | | servlet: |
| | | context-path: /file #web访é®ä¸ä¸æè·¯å¾ |
| | | context-parameters: |
| | | #GenerateIdSetSuffixListenerä¸åºç¨ï¼åå¼èå´æ¯0-99 |
| | | idSuffix: ${pipIrr.file.idSuffix} |
New file |
| | |
| | | Configuration: |
| | | #statusï¼è¿ä¸ªç¨äºè®¾ç½®log4j2èªèº«å
é¨çä¿¡æ¯è¾åºï¼å¯ä»¥ä¸è®¾ç½®ï¼å½è®¾ç½®ætraceæ¶ï¼ä½ ä¼çå°log4j2å
é¨åç§è¯¦ç»è¾åºï¼å¯ä»¥è®¾ç½®æOff(å
³é)æError(åªè¾åºé误信æ¯) |
| | | 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æLoggers.Logger.level夿æ¯å¦è¾åºï¼ç¶ååç±æ¬level夿æ¯å¦è¾åº |
| | | onMatch: ACCEPT #onMatch=ACCEPT 大äºçäº "level" é
ç½®çççº§å°æ¥å¿è¾åº |
| | | onMismatch: DENY #onMismatch=DENY å°äº "level" é
ç½®çççº§å°æ¥å¿ä¸è¾åº |
| | | #æ¥å¿å
å®¹æ ·å¼ |
| | | PatternLayout: |
| | | #%n-æ¢è¡ |
| | | #%m-æ¥å¿å
容ï¼è¾åºä»£ç 䏿å®çæ¥å¿ä¿¡æ¯ |
| | | #%p-è¾åºä¼å
级ï¼å³DEBUG,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æLoggers.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çåèç¹ï¼ç¨æ¥æå®è¯¥æ¥å¿è¾åºå°åªä¸ªAppender. |
| | | - ref: CONSOLE #è¾åºæ¥å¿æ¶ï¼é¦å
ç±æ¬level夿æ¯å¦è¾åºï¼ç¶ååç±ä¸é¢çAppenders.Console.ThresholdFilter.level夿æ¯å¦è¾åº |
| | | - ref: ROLLING_FILE #è¾åºæ¥å¿æ¶ï¼é¦å
ç±æ¬level夿æ¯å¦è¾åºï¼ç¶ååç±ä¸é¢çAppenders.RollingFile.ThresholdFilter.level夿æ¯å¦è¾åº |
New file |
| | |
| | | package com.dy.pipIrrWebFile; |
| | | |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | @SpringBootTest |
| | | class PipIrrWebFileApplicationTests { |
| | | |
| | | @Test |
| | | void contextLoads() { |
| | | } |
| | | |
| | | } |
| | |
| | | <module>pipIrr-web-wechat</module> |
| | | <module>pipIrr-web-app</module> |
| | | <module>pipIrr-web-operation</module> |
| | | <module>pipIrr-web-file</module> |
| | | </modules> |
| | | |
| | | <dependencies> |
| | |
| | | <artifactId>jdom2</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- thumbnailator çæå¾ç缩ç¥å¾ --> |
| | | <dependency> |
| | | <groupId>net.coobird</groupId> |
| | | <artifactId>thumbnailator</artifactId> |
| | | <version>0.4.20</version> |
| | | </dependency> |
| | | |
| | | <!-- beanåmapäºè½¬æ¢ --> |
| | | <dependency> |
| | | <groupId>org.apache.dubbo</groupId> |