();
+ }
}
diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/upfile/model/UpfileModel.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/upfile/model/UpfileModel.java
index 2a9a5d78..7923c1b0 100755
--- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/upfile/model/UpfileModel.java
+++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/upfile/model/UpfileModel.java
@@ -3,6 +3,7 @@
*/
package com.actionsoft.apps.coe.pal.pal.repository.upfile.model;
+import java.io.Serializable;
import java.sql.Timestamp;
/**
@@ -10,7 +11,7 @@ import java.sql.Timestamp;
* @version 创建时间:2014-4-8
*
*/
-public class UpfileModel {
+public class UpfileModel implements Serializable {
public static final String DATABASE_ENTITY = "APP_ACT_COE_PAL_UPFILE";
public static final String FIELD_UUID = "ID";
public static final String FIELD_PL_UUID = "PALREPOSITORYID";
@@ -22,6 +23,7 @@ public class UpfileModel {
public static final String FIELD_SECURITY_LEVEL = "SECURITYLEVEL";
public static final String FIELD_CREATEUSER = "CREATEUSER";
public static final String FIELD_CREATETIME = "CREATETIME";
+ public static final String FIELD_ATTRID = "ATTRID";
private String uuid;
/**
@@ -65,6 +67,10 @@ public class UpfileModel {
* 上传时间
*/
private Timestamp createTime;
+ /**
+ * 属性id
+ */
+ private String attrId;
/**
* 下载url,数据库无该字段,后期自行拼装
@@ -150,5 +156,12 @@ public class UpfileModel {
public void setCreateTime(Timestamp createTime) {
this.createTime = createTime;
}
+ public String getAttrId() {
+ return attrId;
+ }
+
+ public void setAttrId(String attrId) {
+ this.attrId = attrId;
+ }
}
diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/upfile/util/CoeUpFileUtil.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/upfile/util/CoeUpFileUtil.java
new file mode 100644
index 00000000..e591a743
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/upfile/util/CoeUpFileUtil.java
@@ -0,0 +1,304 @@
+package com.actionsoft.apps.coe.pal.pal.repository.upfile.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.actionsoft.apps.coe.pal.components.model.PALSecurityLevelModel;
+import com.actionsoft.apps.coe.pal.constant.CoEConstant;
+//import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodAttributeCache;
+import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel;
+import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.cache.DesignerShapeRelationCache;
+import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
+import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
+import com.actionsoft.apps.coe.pal.pal.repository.upfile.cache.PALUpfileCache;
+import com.actionsoft.apps.coe.pal.pal.repository.upfile.constant.CoeFileConstant;
+import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
+import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
+import com.actionsoft.apps.coe.pal.util.HighSecurityUtil;
+import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
+import com.actionsoft.bpms.server.UserContext;
+import com.actionsoft.bpms.server.fs.DCContext;
+import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
+import com.actionsoft.bpms.server.fs.dc.DCUtil;
+import com.actionsoft.bpms.util.UtilString;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+
+/**
+ * COE 附件上传工具类 处理设计器中 文件附件、形状附件
+ * 属性附件参考: {@link MethodAttrUpFileUtil}
+ */
+public class CoeUpFileUtil {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CoeUpFileUtil.class);
+
+ /**
+ * DCPluginProfile 对象 COE_Upfile
+ */
+ private static final DCPluginProfile DC_UPFILE_PROFILE = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE);
+
+ /**
+ * 获取 DCContext
+ *
+ * @param uc 用户上下文
+ * @param model 上传文件模型
+ */
+ public static DCContext getUpFileDCContext(UserContext uc, UpfileModel model) {
+ DCContext dcContext = null;
+ if (DC_UPFILE_PROFILE != null) {
+ if (CoeFileConstant.FILE_TYPE_F.equals(model.getType())) {
+ // 文件
+ dcContext = new DCContext(uc, DC_UPFILE_PROFILE, CoEConstant.APP_ID, "file", model.getPl_uuid(), model.getFileName());
+ } else if (CoeFileConstant.FILE_TYPE_S.equals(model.getType())) {
+ // 图形
+ dcContext = new DCContext(uc, DC_UPFILE_PROFILE, CoEConstant.APP_ID, model.getPl_uuid(), model.getShape_uuid(), model.getFileName());
+ } else {
+ // 属性
+ dcContext = MethodAttrUpFileUtil.getDCContext(model, uc);
+ }
+ }
+ return dcContext;
+ }
+
+ /**
+ * 获取 上传文件的 DCContext
+ */
+ public static DCContext getUpFileDCContext(UserContext uc, String groupValue, String fileValue, String fileName) {
+ DCContext dcContext = null;
+ if (DC_UPFILE_PROFILE != null) {
+ dcContext = new DCContext(uc, DC_UPFILE_PROFILE, CoEConstant.APP_ID, groupValue, fileValue, fileName);
+ }
+ return dcContext;
+ }
+//
+// /**
+// * 获取tmp目录对应DCContext
+// *
+// * 文件附件:tmp/upfile/uuid/fileName
+// * 形状附件:tmp/upfile/uuid_shapeId/fileName
+// * 文件属性附件:tmp/attr_upfile/uuid_attrId/fileName
+// * 形状属性附件:tmp/attr_upfile/uuid_shapeId_attrId/fileName
+// *
+// *
+// * @param model 上传文件模型
+// */
+// public static DCContext getTmpUpFileDCContext(UpfileModel model) {
+// return getTmpUpFileDCContext(model.getType(), model.getPl_uuid(), model.getShape_uuid(), model.getAttrId(), model.getFileName());
+// }
+//
+// /**
+// * 获取tmp目录对应DCContext
+// *
+// * 文件附件:tmp/upfile/uuid/fileName
+// * 形状附件:tmp/upfile/uuid_shapeId/fileName
+// * 文件属性附件:tmp/attr_upfile/uuid_attrId/fileName
+// * 形状属性附件:tmp/attr_upfile/uuid_shapeId_attrId/fileName
+// *
+// */
+// public static DCContext getTmpUpFileDCContext(String type, String plId, String shapeId, String attrId, String fileName) {
+// DCContext dcContext = null;
+// if (CoeFileConstant.FILE_TYPE_F.equals(type)) {
+// // 文件
+// dcContext = DCUtil.createTempFileContext(CoEConstant.APP_ID, "upfile", plId, null);
+// } else if (CoeFileConstant.FILE_TYPE_S.equals(type)) {
+// // 图形
+// dcContext = DCUtil.createTempFileContext(CoEConstant.APP_ID, "upfile", plId + "_" + shapeId, null);
+// } else if (CoeFileConstant.FILE_TYPE_A.equals(type)) {
+// // 属性
+// dcContext = MethodAttrUpFileUtil.getTmpUpFileDCContext(plId, shapeId, attrId, fileName);
+// }
+// // 设置文件名称
+// if (dcContext != null) {
+// dcContext.setFileName(fileName);
+// }
+// return dcContext;
+// }
+//
+// /**
+// * 将tmp目录中文件移动到COE目录下,移动后删除tmp目录文件
+// */
+// public static void moveTmpFileToCOE(UpfileModel model) {
+// DCContext tmpContext = CoeUpFileUtil.getTmpUpFileDCContext(model);
+// DCContext coeContext = CoeUpFileUtil.getUpFileDCContext(null, model);
+// if (tmpContext != null && coeContext != null) {
+// String fName = model.getFileName();
+// tmpContext.setFileName(fName);
+// coeContext.setFileName(fName);
+// if (tmpContext.existFile()) {
+// DCUtil.copyDCFile(tmpContext, coeContext);
+// tmpContext.delete();
+// }
+// }
+// }
+//
+// /**
+// * 删除DC目录及文件
+// *
+// * @param dcContext 文件上传 DC对象
+// * @throws Exception 异常抛出
+// */
+// public static void removeUpFileDc(DCContext dcContext) throws Exception {
+// if (dcContext != null) {
+// dcContext.delete();
+// String fName = dcContext.getFileName();
+// if (!fName.contains(".")) {
+// return;
+// }
+// String dirName = fName.substring(0, fName.lastIndexOf("."));
+// dcContext.setFileName(dirName);
+// if (dcContext.existFile()) {
+// dcContext.delete();
+// }
+// // pdf 删除
+// if (!fName.endsWith(".pdf")) {
+// dcContext.setFileName(dirName + ".pdf");
+// if (dcContext.existFile()) {
+// dcContext.delete();
+// }
+// }
+// }
+// }
+//
+// /**
+// * 组装附件列表信息
+// *
+// * @param wsId 资产库ID
+// * @param methodId 建模方法ID
+// * @param plId 模型ID
+// * @param fileAttachmentList 文件附件列表
+// * @param shapeAttachmentMap 形状附件map数据 key:shapeId,value JSONArray
+// * @param relationAttachmentList 文件关联附件列表
+// * @param relationShapeAttachmentMap 关联形状附件map数据 key:shapeId,value JSONArray
+// */
+// public static void wrapperAttachmentList(UserContext uc, String wsId, String methodId, String plId, JSONArray fileAttachmentList, Map shapeAttachmentMap, JSONArray relationAttachmentList, Map relationShapeAttachmentMap) {
+// List upfileModels = PALUpfileCache.getByPlUuid(plId);
+// for (UpfileModel model : upfileModels) {
+// String shapeUuid = model.getShape_uuid();
+// JSONObject object = wrapperAttachmentObj(uc, model);
+// if ("f".equals(model.getType())) {
+// fileAttachmentList.add(object);
+// } else if ("s".equals(model.getType()) && UtilString.isNotEmpty(shapeUuid)) {
+// shapeAttachmentMap.computeIfAbsent(shapeUuid, k -> new JSONArray()).add(object);
+// }
+// }
+// List relationModels = DesignerShapeRelationCache.getListByFileId(plId);
+// Map> relationModelsMap = relationModels.stream().collect(Collectors.groupingBy(item -> UtilString.isEmpty(item.getShapeId())));
+// // 关联附件列表
+// List fileRelationModels = relationModelsMap.getOrDefault(true, Collections.emptyList());
+// List shapeRelationModels = relationModelsMap.getOrDefault(false, Collections.emptyList());
+//
+// // 文件关联附件组装
+// List relFileUpfileModels = getRelationAttachmentList(wsId, methodId, fileRelationModels);
+// relFileUpfileModels.forEach(model -> relationAttachmentList.add(wrapperAttachmentObj(uc, model)));
+// // 形状关联附件组装
+// Map> shapeRelationModelsMap = shapeRelationModels.stream().filter(item -> UtilString.isNotEmpty(item.getShapeId())).collect(Collectors.groupingBy(DesignerShapeRelationModel::getShapeId));
+// for (Map.Entry> entry : shapeRelationModelsMap.entrySet()) {
+// String shapeId = entry.getKey();
+// List models = entry.getValue();
+// List relShapeUpfileModels = getRelationAttachmentList(wsId, methodId, models);
+// relShapeUpfileModels.forEach(model -> {
+// // 组装附件信息
+// JSONObject object = wrapperAttachmentObj(uc, model);
+// relationShapeAttachmentMap.computeIfAbsent(shapeId, k -> new JSONArray()).add(object);
+// });
+// }
+// }
+//
+// /**
+// * 组装附件信息
+// */
+// public static JSONObject wrapperAttachmentObj(UserContext uc, UpfileModel model) {
+// return wrapperAttachmentObj(uc, model, null);
+// }
+//
+// /**
+// * 组装附件信息
+// */
+// public static JSONObject wrapperAttachmentObj(UserContext uc, UpfileModel model, JSONObject refObj) {
+// JSONObject object = new JSONObject();
+// object.put("fileName", model.getFileName());
+// object.put("fileId", model.getUuid());
+// object.put("uuid", model.getUuid());
+// object.put("attrId", model.getAttrId());
+// object.put("shapeId", model.getShape_uuid());
+// object.put("download", model.getDownload());
+// object.put("securityLevel", model.getSecurityLevel());
+// object.put("hasSecurity", true);
+// if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) {
+// int userSecurityLevel = uc.getUserModel().getSecurityLevel();
+// PALSecurityLevelModel upFileSecurityLevelInfo = HighSecurityUtil.getUpFileSecurityLevelInfo(model.getUuid());
+// int upfileSecurityLevel = Integer.parseInt(upFileSecurityLevelInfo.getCode());
+// if (userSecurityLevel < upfileSecurityLevel) {
+// object.put("hasSecurity", false);
+// }
+// object.put("securityInfo", upFileSecurityLevelInfo);
+// }
+// boolean isDownload = true;
+// // 判断ref是否存在
+// if (refObj != null) {
+// isDownload = refObj.getBooleanValue("isDownload");
+// boolean isPreview = refObj.getBooleanValue("isPreview");
+// object.put("isDownload", isDownload);
+// object.put("isPreview", isPreview);
+// }
+// String downloadURL = "";
+// if (isDownload) {
+// DCContext dcContext = CoeUpFileUtil.getUpFileDCContext(uc, model);
+// if (dcContext != null) {
+// downloadURL = dcContext.getDownloadURL() + "&isInline=false";
+// }
+// }
+// object.put("url", downloadURL);
+// return object;
+// }
+//
+// /**
+// * 获取当前模型关联的其他模型的附件集合
+// */
+// public static List getRelationAttachmentList(String wsId, String methodId, List relationModels) {
+// List relUpfileModels = new ArrayList<>();
+// // attrKey , relationType[ref中的type]
+// Map relationTypeMap = new HashMap<>();
+// // 获取属性列表
+// List attributeList = PALMethodAttributeCache.getListByMethodIdAndWsId(methodId, wsId);
+// for (PALMethodAttributeModel model : attributeList) {
+// String relationType = "shape";
+// if ("relation".equals(model.getType())) {
+// JSONObject refObj = JSONObject.parseObject(model.getRef());
+// relationType = refObj.containsKey("type") ? refObj.getString("type") : "shape";
+// }
+// relationTypeMap.put(model.getKey(), relationType);
+// }
+// for (DesignerShapeRelationModel relationModel : relationModels) {
+// String attrId = relationModel.getAttrId();
+// if (!relationTypeMap.containsKey(attrId)) {
+// continue;
+// }
+// String type = relationTypeMap.get(attrId);
+// if ("file".equals(type)) {
+// String relationFileId = relationModel.getRelationFileId();
+// PALRepositoryModel uesRelPlModel = CoeProcessLevelUtil.getUseRepositoryByVersionId(relationFileId);
+// if (uesRelPlModel != null) {
+// List useRelUpFileList = PALUpfileCache.getByPlUuid(uesRelPlModel.getId());
+// if (!useRelUpFileList.isEmpty()) {
+// relUpfileModels.addAll(useRelUpFileList);
+// }
+// }
+// } else {
+// List useRelUpFileList = PALUpfileCache.getByPlUuidAndShapeId(relationModel.getRelationFileId(), relationModel.getRelationShapeId());
+// if (!useRelUpFileList.isEmpty()) {
+// relUpfileModels.addAll(useRelUpFileList);
+// }
+// }
+// }
+// return relUpfileModels;
+// }
+
+}
diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/upfile/util/MethodAttrUpFileUtil.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/upfile/util/MethodAttrUpFileUtil.java
new file mode 100644
index 00000000..d6e989b3
--- /dev/null
+++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/upfile/util/MethodAttrUpFileUtil.java
@@ -0,0 +1,125 @@
+package com.actionsoft.apps.coe.pal.pal.repository.upfile.util;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import com.actionsoft.apps.coe.pal.constant.CoEConstant;
+import com.actionsoft.apps.coe.pal.pal.method.constant.PALMethodConst;
+import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
+import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
+import com.actionsoft.bpms.server.UserContext;
+import com.actionsoft.bpms.server.fs.DCContext;
+import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
+import com.actionsoft.bpms.server.fs.dc.DCUtil;
+import com.actionsoft.bpms.util.UtilString;
+
+/**
+ * @author oYang
+ * @Description 建模属性附件工具类
+ * @createTime 2024年03月26日 17:06:00
+ */
+public class MethodAttrUpFileUtil {
+
+ private static final Set