From 9d28c5a65de947a0e11fc6b5612c155199a509df Mon Sep 17 00:00:00 2001 From: yujh Date: Fri, 21 Mar 2025 09:33:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E4=BF=AE=E6=94=B9=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8A=9F=E8=83=BD=E6=B5=81=E7=A8=8B=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=9C=80=E6=96=B0=E8=BF=90=E8=A1=8C=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UpateFileStateController.java | 179 +++++++++++++++++- 1 file changed, 177 insertions(+), 2 deletions(-) diff --git a/com.awspaas.user.bpa/src/com/awspaas/user/bpa/controller/UpateFileStateController.java b/com.awspaas.user.bpa/src/com/awspaas/user/bpa/controller/UpateFileStateController.java index 79227618..8d4f3066 100644 --- a/com.awspaas.user.bpa/src/com/awspaas/user/bpa/controller/UpateFileStateController.java +++ b/com.awspaas.user.bpa/src/com/awspaas/user/bpa/controller/UpateFileStateController.java @@ -1,10 +1,16 @@ package com.awspaas.user.bpa.controller; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst; import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager; import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile; import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; +import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache; import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory; +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.PALRepositoryPropertyModel; import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb; import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; @@ -12,6 +18,9 @@ import com.actionsoft.bpms.bo.engine.BO; import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance; import com.actionsoft.bpms.commons.database.RowMap; import com.actionsoft.bpms.commons.login.constant.LoginConst; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.RoleModel; +import com.actionsoft.bpms.org.model.UserModel; import com.actionsoft.bpms.server.SSOUtil; import com.actionsoft.bpms.server.UserContext; import com.actionsoft.bpms.server.fs.DCContext; @@ -252,7 +261,7 @@ public class UpateFileStateController { int count = 0; int count2 = 0; try { - Map queryRepositoryAttributeById = new RepositoryAttribute().queryRepositoryAttributeById(id); + Map queryRepositoryAttributeById = queryRepositoryAttributeById(id); if (null != queryRepositoryAttributeById && !queryRepositoryAttributeById.isEmpty()) { // 发布部门 String dempId = ""; @@ -346,7 +355,9 @@ public class UpateFileStateController { publishN.set("PUBLISTHTYPE","N"); publishN.set("PUBLISHFILENAME",model.getName()); publishN.set("PUBLISHFILEID",plId); - ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance("obj_a228b4816a7b4f58a862b9612299948c", "admin", ""); + //获取发布流程组中运行中的流程 + String processDefId = SDK.getRepositoryAPI().getProcessDefIdOfRelease("obj_fb1c7a54b98b412187388c8bab407362"); + ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance(processDefId, "admin", ""); SDK.getBOAPI().create("BO_ACT_COE_PUBLISH_N",publishN,processInstance,me); @@ -718,5 +729,169 @@ public class UpateFileStateController { } + /** + * 根据模型ID查询所有文件扩展属性 + * @param uuid + * @return + */ + public Map queryRepositoryAttributeById(String uuid) { + Map result = new HashMap<>(); + PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid); + // 获取所有文件属性 + List methodAttrModels = PALRepositoryAPIManager.getInstance().getValidAndUseAttributeModels(plModel.getWsId(), plModel.getMethodId()); + if (methodAttrModels != null && methodAttrModels.size() > 0) { + Map attributeModelMap = new HashMap<>(); + Map sortAttrMap = new HashMap<>(); + if (methodAttrModels != null) { + int sort = 0; + for (PALMethodAttributeModel attr : methodAttrModels) { + attributeModelMap.put(attr.getKey(), attr); + sortAttrMap.put(attr.getKey(), ++sort); + } + } + List propertys = PALRepositoryPropertyCache.getPropertyByPlId(plModel.getId()); + // 排序 + // propertys.sort((p1, p2) -> (sortAttrMap.containsKey(p1.getPropertyId()) ? sortAttrMap.get(p1.getPropertyId()) : 0) - (sortAttrMap.containsKey(p2.getPropertyId()) ? sortAttrMap.get(p2.getPropertyId()) : 0)); + + for (PALRepositoryPropertyModel property : propertys) { + String id = property.getPropertyId(); + if (!attributeModelMap.containsKey(id) || !attributeModelMap.get(id).getUse()) { + continue; + } + PALMethodAttributeModel attributeModel = attributeModelMap.get(id); + // 记录结果集 + JSONObject attrObj = new JSONObject(); + attrObj.put("ref", attributeModel.getRef());// ref + attrObj.put("type", attributeModel.getType());// 类型 relation string ... + attrObj.put("attrId", attributeModel.getKey());// 属性key + attrObj.put("attrTitle", attributeModel.getNewTitle());// 属性标题 + attrObj.put("text", "");// 属性内容单行文本 + attrObj.put("value", new JSONArray());// 属性内容集,relation或awsorg类型时存储对应的json数据 + String inputValue = property.getPropertyValue(); + if ("relation".equals(attributeModel.getType())) { + List inputValueList = new ArrayList<>(); + List list = DesignerShapeRelationCache.getListByAttrId(plModel.getId(), "", attributeModel.getKey()); + if (list != null && list.size() > 0) { + // 判断是否有重复数据,进行重复过滤 + Set tempStrs = new HashSet<>(); + List tempList = new ArrayList<>(); + for (int i = 0; i < list.size(); i++) { + DesignerShapeRelationModel model = list.get(i); + String str = model.getFileId() + model.getShapeId() + model.getAttrId() + model.getRelationFileId() + model.getRelationShapeId(); + if (!tempStrs.contains(str)) { + tempList.add(model); + tempStrs.add(str); + } + } + list = tempList; + for (int i = 0; i < list.size(); i++) { + DesignerShapeRelationModel model = list.get(i); + JSONObject refObj = JSONObject.parseObject(attributeModel.getRef()); + String relationTyp = refObj.containsKey("type") ? refObj.getString("type") : "shape"; + if ("file".equals(relationTyp)) {// 关联的模型文件 + if (model.getRelationFileId().length() < 36) { + continue; + } + List list2 = PALRepositoryCache.getByVersionId(plModel.getWsId(), model.getRelationFileId()); + for (PALRepositoryModel model2 : list2) { + if (model2.isUse()) { + inputValueList.add(model2.getName()); + JSONObject tmp = new JSONObject(); + tmp.put("fileId", model2.getId()); + tmp.put("name", model2.getName()); + tmp.put("isFile", true); + attrObj.getJSONArray("value").add(tmp); + break; + } + } + } else { + inputValueList.add(model.getRelationShapeText()); + JSONObject tmp = new JSONObject(); + tmp.put("fileId", model.getRelationFileId()); + tmp.put("shapeId", model.getRelationShapeId()); + tmp.put("name", model.getRelationShapeText()); + tmp.put("isFile", false); + attrObj.getJSONArray("value").add(tmp); + } + } + } + inputValue = org.apache.tools.ant.util.StringUtils.join(inputValueList, ","); + } + // 关联bpm组织架构 + if ("awsorg".equals(attributeModel.getType())) { + List list = DesignerShapeRelationCache.getListByAttrId(plModel.getId(), "", attributeModel.getKey()); + List deptValList = new ArrayList<>(); + List positionValList = new ArrayList<>(); + List roleValList = new ArrayList<>(); + List userValList = new ArrayList<>(); + if (list != null && list.size() > 0) { + Set filter = new HashSet();// 去重记录 + list.sort((m1, m2) -> { + return m1.getId().compareTo(m2.getId()); + }); + for (DesignerShapeRelationModel model : list) { + if ("00000000-0000-0000-0000-000000000000".equals(model.getRelationFileId()) && "00000000-0000-0000-0000-000000000000".equals(model.getRelationShapeId())) { + JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); + boolean flag = false; + // 查询最新名称 + if ("department".equals(object.getString("type"))) { + DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); + if (dept != null && !filter.contains(dept.getId())) { + deptValList.add(dept.getName()); + filter.add(dept.getId()); + flag = true; + } + } + if ("position".equals(object.getString("type"))) {// 岗位,先用角色代替 + RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); + if (role != null && !filter.contains(role.getId())) { + positionValList.add(role.getName()); + filter.add(role.getId()); + flag = true; + } + } + if ("user".equals(object.getString("type"))) { + UserModel user = SDK.getORGAPI().getUser(object.getString("id")); + if (user != null && !filter.contains(user.getUID())) { + userValList.add(user.getUserName()); + filter.add(user.getUID()); + flag = true; + } + } + if ("role".equals(object.getString("type"))) { + RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); + if (role != null && !filter.contains(role.getId())) { + roleValList.add(role.getName()); + filter.add(role.getId()); + flag = true; + } + } + if (flag) { + attrObj.getJSONArray("value").add(object); + } + } + } + } + // 数据组合 + deptValList.addAll(positionValList); + deptValList.addAll(roleValList); + deptValList.addAll(userValList); + inputValue = org.apache.tools.ant.util.StringUtils.join(deptValList, ","); + + } + if (UtilString.isNotEmpty(inputValue)){ + inputValue = inputValue.replaceAll("'", "'"); + inputValue = inputValue.replaceAll("\"", """); + attrObj.put("text", inputValue); + result.put(attributeModel.getKey(), attrObj); + }else { + attrObj.put("text", inputValue); + result.put(attributeModel.getKey(), attrObj); + } + } + } + return result; + } + }