云苍穹附件携带

1.通过AttachmentServiceHelper.getAttachments()获取源附件:

List<Map<String,Object>> attachments = AttachmentServiceHelper.getAttachments("cas_claimbill",claimbillPK,"attachmentpanel"); //bos_attachment 附件面板实体中读取

2.附件地址和最近修改时间不能直接使用:

if(attachment.get("lastModified") instanceof Date){
  Date date = (Date)attachment.get("lastModified");
  attachment.put("lastModified",date.getTime());
}
if(attachment.containsKey("attPkId")){
  DynamicObject dbAttachment = BusinessDataServiceHelper.londSingle(attachment.get("attkId")," bos_attachment","ffileid");  //ffileid是bos_svc_attachment 附件管理中心的编码,上传的附件都在这里面

  //下载地址:String downUrl= getDomainContextUrl() + "/attachment/download.do?path=/" +ffileid

  attachment.put("url",dbAttachment.getstring("ffileid"));
}

3.上传附件到目标单:

AttachmentServiceHelper.upload("cas_recbill", recbillPK,"attachmentpanel", attachments);

4.其他:

 TempFileCache cache = CacheFactory.getCommonCacheFactory().getTempFileCache();
 String tempUrl = cache.saveAsFullUrl((String) attachItem.get("name"), inputStream, 600);
String ffileid= AttachmentServiceHelper.saveTempToFileService(tempUrl,appId,entity, pk, (String)attachItem.get("name")); ///对应 ffileid是bos_svc_attachment 附件管理中心的编码,上传的附件都在这里面
FileService service = FileServiceFactory.getAttachmentFileService();
String pathParam = FileNameUtils.getAttachmentFileName(requestContext.getTenantId(),
                    requestContext.getAccountId(), uuid, fileName);
FileItem fileItem = new FileItem(fileName, pathParam, in);
String downUrl =service.upload(fileItem);//不知道返回的是什么
posted @ 2021-04-19 10:33  LJ9197  阅读(262)  评论(0)    收藏  举报