|
@@ -156,9 +156,10 @@ public class AttachmentFileUtil {
|
|
System.out.println("downUrl:"+downUrl);
|
|
System.out.println("downUrl:"+downUrl);
|
|
|
|
|
|
attachItem.put("url", actUrl);
|
|
attachItem.put("url", actUrl);
|
|
|
|
+ result.put("url", actUrl);
|
|
attachments.add(attachItem);
|
|
attachments.add(attachItem);
|
|
//绑定单据
|
|
//绑定单据
|
|
- AttachmentServiceHelper.upload(entity, pk, attachKey, attachments);
|
|
|
|
|
|
+ //AttachmentServiceHelper.upload(entity, pk, attachKey, attachments);
|
|
|
|
|
|
}catch(Exception e1){
|
|
}catch(Exception e1){
|
|
logger.info("FTP 附件上传失败,堆栈信息e1:",e1.getMessage());
|
|
logger.info("FTP 附件上传失败,堆栈信息e1:",e1.getMessage());
|
|
@@ -202,6 +203,7 @@ public class AttachmentFileUtil {
|
|
attachItem.put("url", actUrl);
|
|
attachItem.put("url", actUrl);
|
|
|
|
|
|
attachments.add(attachItem);
|
|
attachments.add(attachItem);
|
|
|
|
+ attToAttachmentFile(attachItem);
|
|
// 绑定单据
|
|
// 绑定单据
|
|
AttachmentServiceHelper.upload(entity, pk, attachKey, attachments);
|
|
AttachmentServiceHelper.upload(entity, pk, attachKey, attachments);
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
@@ -211,6 +213,44 @@ public class AttachmentFileUtil {
|
|
return "ss";
|
|
return "ss";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 将给定的附件属性映射转换为附件实体对象
|
|
|
|
+ * 此方法主要用于将包含附件信息的映射转换为系统中的附件文件对象,包括设置基本属性、唯一标识、状态以及关联的元数据
|
|
|
|
+ *
|
|
|
|
+ * @param attachment 包含附件信息的映射,如名称、大小、类型等
|
|
|
|
+ * @return DynamicObject 表示附件文件的对象,包含完整的附件属性
|
|
|
|
+ */
|
|
|
|
+ public static DynamicObject attToAttachmentFile(Map<String, Object> attachment) {
|
|
|
|
+
|
|
|
|
+ //创建一条基础资料数据-附件字段
|
|
|
|
+ DynamicObject attObj = BusinessDataServiceHelper.newDynamicObject("bd_attachment");
|
|
|
|
+ attObj.set("name", attachment.get("name"));
|
|
|
|
+ attObj.set("size", 0);
|
|
|
|
+ attObj.set("uid", attachment.get("uid"));
|
|
|
|
+ attObj.set("url", attachment.get("uid"));
|
|
|
|
+ String fileType = attachment.get("name").toString();
|
|
|
|
+ if (fileType.contains(".")) {
|
|
|
|
+ fileType = fileType.substring(fileType.lastIndexOf(".") + 1);
|
|
|
|
+ }
|
|
|
|
+ attObj.set("type", fileType);
|
|
|
|
+ //tempfile=1表示持久化附件对象
|
|
|
|
+ attObj.set("tempfile", 1);
|
|
|
|
+ ORM orm = ORM.create();
|
|
|
|
+ long id = orm.genLongId("bd_attachment");
|
|
|
|
+ attObj.set("id", id);
|
|
|
|
+ attObj.set("pageid", "");
|
|
|
|
+ attObj.set("number", UUID.randomUUID().toString());
|
|
|
|
+ attObj.set("status", "B");
|
|
|
|
+ Date now = new Date();
|
|
|
|
+ attObj.set("modifytime", now.getTime());
|
|
|
|
+ attObj.set("createtime", now.getTime());
|
|
|
|
+ attObj.set("creator", UserServiceHelper.getCurrentUserId());
|
|
|
|
+ SaveServiceHelper.save(new DynamicObject[]{attObj});
|
|
|
|
+
|
|
|
|
+ return attObj;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 根据地址获得数据的字节流并转换成大小
|
|
* 根据地址获得数据的字节流并转换成大小
|
|
* @param strUrl 网络连接地址
|
|
* @param strUrl 网络连接地址
|