批量修改文件功能流程版本获取最新运行版本
This commit is contained in:
parent
e9ef26783f
commit
9d28c5a65d
@ -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<String, JSONObject> queryRepositoryAttributeById = new RepositoryAttribute().queryRepositoryAttributeById(id);
|
||||
Map<String, JSONObject> 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<String, JSONObject> queryRepositoryAttributeById(String uuid) {
|
||||
Map<String, JSONObject> result = new HashMap<>();
|
||||
PALRepositoryModel plModel = PALRepositoryCache.getCache().get(uuid);
|
||||
// 获取所有文件属性
|
||||
List<PALMethodAttributeModel> methodAttrModels = PALRepositoryAPIManager.getInstance().getValidAndUseAttributeModels(plModel.getWsId(), plModel.getMethodId());
|
||||
if (methodAttrModels != null && methodAttrModels.size() > 0) {
|
||||
Map<String, PALMethodAttributeModel> attributeModelMap = new HashMap<>();
|
||||
Map<String, Integer> sortAttrMap = new HashMap<>();
|
||||
if (methodAttrModels != null) {
|
||||
int sort = 0;
|
||||
for (PALMethodAttributeModel attr : methodAttrModels) {
|
||||
attributeModelMap.put(attr.getKey(), attr);
|
||||
sortAttrMap.put(attr.getKey(), ++sort);
|
||||
}
|
||||
}
|
||||
List<PALRepositoryPropertyModel> 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<String> inputValueList = new ArrayList<>();
|
||||
List<DesignerShapeRelationModel> list = DesignerShapeRelationCache.getListByAttrId(plModel.getId(), "", attributeModel.getKey());
|
||||
if (list != null && list.size() > 0) {
|
||||
// 判断是否有重复数据,进行重复过滤
|
||||
Set<String> tempStrs = new HashSet<>();
|
||||
List<DesignerShapeRelationModel> 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<PALRepositoryModel> 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<DesignerShapeRelationModel> list = DesignerShapeRelationCache.getListByAttrId(plModel.getId(), "", attributeModel.getKey());
|
||||
List<String> deptValList = new ArrayList<>();
|
||||
List<String> positionValList = new ArrayList<>();
|
||||
List<String> roleValList = new ArrayList<>();
|
||||
List<String> userValList = new ArrayList<>();
|
||||
if (list != null && list.size() > 0) {
|
||||
Set<String> filter = new HashSet<String>();// 去重记录
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user