| 
					
				 | 
			
			
				@@ -27,6 +27,7 @@ import kd.imc.rim.common.message.exception.MsgException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import kd.imc.rim.common.utils.FileUploadUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import kd.imc.rim.common.utils.FileUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import kd.imc.rim.common.utils.MD5; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import nckd.base.helper.CommonHelperUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import nckd.jimin.jyyy.fi.common.XmlUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import nckd.jimin.jyyy.fi.plugin.operate.SRMHelperUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -119,7 +120,8 @@ public class SRMSynAttacmentApiPlugin implements Serializable { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 fileUrl = fileUrl.replace("&", "&"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 String downloadUrl = fileUrl + "&access_token=" + token; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                logger.info("SRMSynAttacmentApiPlugin:downloadUrl " + downloadUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                logger.info("SRMSynAttacmentApiPlugin:开始处理文件,downloadUrl " + downloadUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                logger.info("SRMSynAttacmentApiPlugin:文件名 " + fileName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 URL url = new URL(downloadUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //这里没有使用 封装后的ResponseEntity 就是也是因为这里不适合一次性的拿到结果,放不下content,会造成内存溢出 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -130,15 +132,21 @@ public class SRMSynAttacmentApiPlugin implements Serializable { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //使用bufferedInputStream 缓存流的方式来获取下载文件,不然大文件会出现内存溢出的情况 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 InputStream inputStream = new BufferedInputStream(connection.getInputStream()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                logger.info("SRMSynAttacmentApiPlugin:开始读取文件流 " + CommonHelperUtils.getDateStringFormat(new Date(), "yyyy-MM-dd HH:mm:ss")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 byte[] fileData = InputStreamToBytes(inputStream); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                logger.info("SRMSynAttacmentApiPlugin:开始读取文件流 " + CommonHelperUtils.getDateStringFormat(new Date(), "yyyy-MM-dd HH:mm:ss")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 TempFileCache cache = CacheFactory.getCommonCacheFactory().getTempFileCache(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 String tempUrl = cache.saveAsFullUrl(fileName, fileData,3600); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                logger.info("SRMSynAttacmentApiPlugin:缓存结束 " + CommonHelperUtils.getDateStringFormat(new Date(), "yyyy-MM-dd HH:mm:ss")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 StringBuffer uid = new StringBuffer(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 uid.append("rc-upload-").append(new Date().getTime()).append("-"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 Map<String,Object> attachmentInfo = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                attachmentInfo.put("entityNumber", "entityNumber"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                attachmentInfo.put("entityNumber", entityName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 attachmentInfo.put("name", fileName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 attachmentInfo.put("url", tempUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 attachmentInfo.put("size", fileSize); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -170,8 +178,13 @@ public class SRMSynAttacmentApiPlugin implements Serializable { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 return returnResult("1000", "附件上传后,保存单据失败:" + err.toString(), null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (IOException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            logger.info("synAttacmenthForSRM:IOException " + (e.getMessage() == null ? "" : e.getMessage())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return returnResult("1000", "附件保存异常" + e.getMessage(), null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch(Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            logger.info("synAttacmenthForSRM:" + (e.getMessage() == null ? "" : e.getMessage())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            logger.info("synAttacmenthForSRM:Exception " + (e.getMessage() == null ? "" : e.getMessage())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return returnResult("1000", "附件保存异常" + e.getMessage(), null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -277,8 +290,8 @@ public class SRMSynAttacmentApiPlugin implements Serializable { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private byte[] InputStreamToBytes(InputStream inputStream){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        byte[] buffer = new byte[1024]; // 创建一个缓冲区,大小可以根据需要调整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        byte[] buffer = new byte[1024 * 1024 * 5];// 5MB 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        byte[] buffer = new byte[1024]; // 创建一个缓冲区,大小可以根据需要调整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        byte[] buffer = new byte[1024 * 1024 * 5];// 5MB 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         int bytesRead; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 读取数据到缓冲区,直到没有更多数据可读 
			 |