|
@@ -105,8 +105,6 @@ public class SRMSynAttacmentApiPlugin implements Serializable {
|
|
|
return returnResult("1000", "失败,单据号(" + billNO + ")在星瀚中未匹配到单据", null);
|
|
|
}
|
|
|
|
|
|
- JSONObject returnData = new JSONObject();
|
|
|
-
|
|
|
Map<String, Object> attachmentInfos = new HashMap<>();
|
|
|
List<Map<String, Object>> attachments = new ArrayList<>();
|
|
|
|
|
@@ -132,31 +130,46 @@ 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"));
|
|
|
+// logger.info("SRMSynAttacmentApiPlugin:开始读取文件流 " + CommonHelperUtils.getDateStringFormat(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
|
- byte[] fileData = InputStreamToBytes(inputStream);
|
|
|
+// byte[] fileData = InputStreamToBytes(inputStream);
|
|
|
|
|
|
- logger.info("SRMSynAttacmentApiPlugin:开始读取文件流 " + CommonHelperUtils.getDateStringFormat(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+// 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);
|
|
|
+ try {
|
|
|
+ TempFileCache cache = CacheFactory.getCommonCacheFactory().getTempFileCache();
|
|
|
|
|
|
- logger.info("SRMSynAttacmentApiPlugin:缓存结束 " + CommonHelperUtils.getDateStringFormat(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ 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", entityName);
|
|
|
- attachmentInfo.put("name", fileName);
|
|
|
- attachmentInfo.put("url", tempUrl);
|
|
|
- attachmentInfo.put("size", fileSize);
|
|
|
-// attachmentInfo.put("status", map.get("status"));
|
|
|
- attachmentInfo.put("uid", uid.toString() + i);
|
|
|
+ String tempUrl = cache.saveAsFullUrl(fileName, inputStream, 3600);
|
|
|
|
|
|
- attachments.add(attachmentInfo);
|
|
|
+ logger.info("SRMSynAttacmentApiPlugin:缓存文件-结束 " + CommonHelperUtils.getDateStringFormat(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
|
- connection.disconnect();
|
|
|
- inputStream.close();
|
|
|
+ StringBuffer uid = new StringBuffer();
|
|
|
+ uid.append("rc-upload-").append(new Date().getTime()).append("-");
|
|
|
+ Map<String, Object> attachmentInfo = new HashMap<>();
|
|
|
+ attachmentInfo.put("entityNumber", entityName);
|
|
|
+ attachmentInfo.put("name", fileName);
|
|
|
+ attachmentInfo.put("url", tempUrl);
|
|
|
+ attachmentInfo.put("size", fileSize);
|
|
|
+// attachmentInfo.put("status", map.get("status"));
|
|
|
+ attachmentInfo.put("uid", uid.toString() + i);
|
|
|
+
|
|
|
+ attachments.add(attachmentInfo);
|
|
|
+ } catch (Exception e){
|
|
|
+ logger.info("synAttacmenthForSRM:缓存文件失败," + (e.getMessage() == null ? "" : e.getMessage()));
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if(inputStream!=null){
|
|
|
+ inputStream.close();
|
|
|
+ }
|
|
|
+ if(connection !=null){
|
|
|
+ connection.disconnect();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.info("附件上传失败,堆栈信息01:",e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
attachmentInfos.put("attachmentpanel",attachments);
|