端到端功能后台应用功能入口部分提交

This commit is contained in:
ouyang 2023-05-10 18:38:23 +08:00
parent d0e3428cd5
commit 4aaa69a671
8 changed files with 380 additions and 7 deletions

View File

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<app xmlns="http://www.actionsoft.com.cn/app"> <app xmlns="http://www.actionsoft.com.cn/app">
<name>端到端(SubProcess)建模方法</name> <name>端到端(SubProcess)建模方法</name>
<version>1.0</version> <version>1.0</version>
<buildNo>29</buildNo> <buildNo>29</buildNo>
<developer id="776cca9a287c8b4d63b9cad216aa3859" tablePrefix="ACT" url="http://www.actionsoft.com.cn">北京炎黄盈动科技发展有限责任公司</developer> <developer id="776cca9a287c8b4d63b9cad216aa3859" tablePrefix="ACT" url="http://www.actionsoft.com.cn">北京炎黄盈动科技发展有限责任公司</developer>
<categoryVisible>false</categoryVisible> <categoryVisible>false</categoryVisible>
<releaseDate>2022-06-13</releaseDate> <releaseDate>2022-06-13</releaseDate>
<description><![CDATA[端到端建模方法]]></description> <description><![CDATA[端到端建模方法]]></description>
<details><![CDATA[]]></details> <details><![CDATA[]]></details>
<installDate>2022-06-08 21:10:35</installDate> <installDate>2022-06-08 21:10:35</installDate>
<upgradeDate>2022-06-13 09:36:32</upgradeDate> <upgradeDate>2022-06-13 09:36:32</upgradeDate>
<installListener/> <installListener/>
<pluginListener>com.actionsoft.apps.coe.method.process.subprocess.Plugins</pluginListener> <pluginListener>com.actionsoft.apps.coe.method.process.subprocess.plugin.Plugins</pluginListener>
<startListener/> <startListener/>
<stopListener/> <stopListener/>
<upgradeListener/> <upgradeListener/>
@ -23,5 +23,8 @@
<modelAdministrator/> <modelAdministrator/>
<icon code="&amp;#xe703;" color="#dc4f39"/> <icon code="&amp;#xe703;" color="#dc4f39"/>
<requires/> <requires/>
<palMethodIcon>{"process.epc":{"code": "&amp;#xe605;","color": "#4E7FF9"}}</palMethodIcon> <palMethodIcon>{"process.epc":{"code": "&amp;#xe605;","color": "#4E7FF9"}}</palMethodIcon>
<properties>
<property action="disabled" group="功能入口相关" name="SUB_PROCESS_MODEL_LOCATION" title="端到端模型存放目录" type="input" isSystem="false" desc="指定生成的端到端模型存放的根目录" ref="">process/3d2f5b3d-3e66-4777-808a-2c56e91dc8cc</property>
</properties>
</app> </app>

View File

@ -0,0 +1,95 @@
package com.actionsoft.apps.coe.method.process.subprocess;
import com.actionsoft.apps.coe.method.process.subprocess.web.SubProcessWeb;
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.server.bind.annotation.Controller;
import com.actionsoft.bpms.server.bind.annotation.Mapping;
import com.actionsoft.exception.AWSException;
import com.alibaba.fastjson.JSONArray;
/**
* @author oYang
* @create 2023-05-09 15:37
*/
@Controller
public class SubProcessController {
/**
* 功能入口->获取部分初始数据
* @param uc
* @return
*/
@Mapping("com.actionsoft.apps.coe.method.process.subprocess.init_data")
public String initData(UserContext uc){
try {
SubProcessWeb processWeb = new SubProcessWeb(uc);
return processWeb.initData();
} catch (AWSException e) {
return ResponseObject.newErrResponse(e.getMessage()).toString();
}
}
/**
* 功能入口->子流程树加载接口
* 端到端功能入口处 加载流程文件树 调用资产库主界面左侧树方法API
* 在此基础上保留 EPC与泳道图 其它建模类型的模型过滤掉
* @param uc
* @param wsId
* @param teamId
* @param pid
* @param createUsers
* @param orgIds
* @param methodIds
* @return
*/
@Mapping("com.actionsoft.apps.coe.method.process.subprocess.find_tree_node")
public String findSubProcessModelTreeNode(UserContext uc, String wsId, String teamId, String pid, String createUsers, String orgIds, String methodIds){
SubProcessWeb processWeb = new SubProcessWeb(uc);
return processWeb.findSubProcessTreeNode(wsId, teamId, pid, createUsers, orgIds, methodIds);
}
/**
* 功能入口->子流程选择接口
* 根据选择的树节点 返回节点下所有子级节点不限于一级子节点
* @param uc
* @param nodeKeyJsonArr
* @return
*/
@Mapping("com.actionsoft.apps.coe.method.process.subprocess.find_tree_child_node_all")
public String findModeTreeChildNodeAll(UserContext uc, String nodeKeyJsonArr){
try {
SubProcessWeb processWeb = new SubProcessWeb(uc);
JSONArray childNodeAll = processWeb.findModeTreeChildNodeAll(nodeKeyJsonArr);
ResponseObject ro = ResponseObject.newOkResponse("查询成功");
ro.setData(childNodeAll);
return ro.toString();
} catch (AWSException e) {
return ResponseObject.newErrResponse(e.getMessage()).toString();
}
}
/**
* 功能入口->加载位置树
* @param uc
* @param wsId
* @param teamId
* @param pid
* @return
*/
@Mapping("com.actionsoft.apps.coe.method.process.subprocess.construct_position_tree")
public String constructPositionTree(UserContext uc, String wsId, String teamId, String pid){
try {
SubProcessWeb processWeb = new SubProcessWeb(uc);
JSONArray data = processWeb.constructPositionTree(wsId, teamId, pid);
ResponseObject ro = ResponseObject.newOkResponse("查询成功");
ro.setData(data);
return ro.toString();
} catch (AWSException e) {
return ResponseObject.newErrResponse(e.getMessage()).toString();
}
}
}

View File

@ -0,0 +1,14 @@
package com.actionsoft.apps.coe.method.process.subprocess.constant;
/**
* @author oYang
* @create 2023-05-10 15:35
*/
public interface SubProcessConst {
// 应用ID
String APP_ID = "com.actionsoft.apps.coe.method.process.subprocess";
// 端到端流程存放父节点 参数名
String SUB_PROCESS_MODEL_LOCATION = "SUB_PROCESS_MODEL_LOCATION";
}

View File

@ -0,0 +1,40 @@
package com.actionsoft.apps.coe.method.process.subprocess.model.vo;
/**
* @author oYang
* @create 2023-05-10 11:06
*/
public class SubProcessTagVo {
private String label;
private String value;
public SubProcessTagVo(String label, String value) {
this.label = label;
this.value = value;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String toString() {
return "SubProcessTagVo{" +
"label='" + label + '\'' +
", value='" + value + '\'' +
'}';
}
}

View File

@ -1,4 +1,4 @@
package com.actionsoft.apps.coe.method.process.subprocess; package com.actionsoft.apps.coe.method.process.subprocess.plugin;
import com.actionsoft.apps.listener.PluginListener; import com.actionsoft.apps.listener.PluginListener;
import com.actionsoft.apps.resource.AppContext; import com.actionsoft.apps.resource.AppContext;

View File

@ -0,0 +1,201 @@
package com.actionsoft.apps.coe.method.process.subprocess.web;
import com.actionsoft.apps.coe.method.process.subprocess.constant.SubProcessConst;
import com.actionsoft.apps.coe.method.process.subprocess.model.vo.SubProcessTagVo;
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.apps.coe.pal.pal.repository.web.CoeProcessLevelWeb;
import com.actionsoft.bpms.commons.mvc.view.ActionWeb;
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.util.UtilString;
import com.actionsoft.exception.AWSException;
import com.actionsoft.i18n.I18nRes;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections4.IteratorUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author oYang
* @create 2023-05-09 15:49
*/
public class SubProcessWeb extends ActionWeb {
private UserContext uc;
public SubProcessWeb(UserContext uc) {
super(uc);
this.uc = uc;
}
public String initData() throws AWSException{
// 获取端到端文件存储的根目录
String property = SDK.getAppAPI().getProperty(SubProcessConst.APP_ID, SubProcessConst.SUB_PROCESS_MODEL_LOCATION);
if (UtilString.isEmpty(property))
throw new AWSException("应用参数【" + SubProcessConst.SUB_PROCESS_MODEL_LOCATION + "】异常");
String[] locationIds = property.split("/");
StringBuffer dirName = new StringBuffer(I18nRes.findValue(CoEConstant.APP_ID, locationIds[0]) + "/");
for (int i = 1; i < locationIds.length; i++) {
PALRepositoryModel model = PALRepositoryCache.getCache().get(locationIds[i]);
dirName.append(model.getName()).append("/");
}
ResponseObject ro = ResponseObject.newOkResponse();
ro.put("dirRootName", dirName.toString());
ro.put("dirRootPath", property);
return ro.toString();
}
/**
* 资产库主界面左侧树适配
* @param wsId
* @param teamId
* @param pid
* @param createUsers
* @param orgIds
* @param methodIds
* @return
* @throws AWSException
*/
public String findSubProcessTreeNode(String wsId, String teamId, String pid, String createUsers, String orgIds, String methodIds) throws AWSException{
// 调用资产库主界面左侧树的API
CoeProcessLevelWeb processLevelWeb = new CoeProcessLevelWeb(uc);
String result = processLevelWeb.getPalProcesslevelTreeData(wsId, teamId, pid, createUsers, orgIds, methodIds);
// 解析API返回结果
ResponseObject ro = ResponseObject.parse(result);
JSONArray data = ro.getData(JSONArray.class);
if (UtilString.isEmpty(pid)){
data = data.stream()
.filter(item -> "process".equals(((JSONObject)item).getString("plCategory")))
.collect(Collectors.toCollection(JSONArray::new));
}else {
// 保留EPC 泳道图 其它过滤掉
data = data.stream()
.filter(item -> {
JSONObject model = (JSONObject) item;
boolean flag = false;
if ("process.framework".equals(model.getString("plMethodId")) || "default".equals(model.getString("plMethodId"))){
// 递归判断该架构或者该文件夹是否保留
flag = this.isContainEpcOrFlowChart(model.getString("wsId"),model.getString("versionId"));
}else if ("process.epc".equals(model.getString("plMethodId")) || "process.flowchart".equals(model.getString("plMethodId"))){
flag = true;
}
return flag;
})
.collect(Collectors.toCollection(JSONArray::new));
}
ro.setData(data);
return ro.toString();
}
/**
* 递归判断当前架构或者文件夹是否包含 EPC或者泳道图
* @param wsId
* @param pid
* @return
*/
private boolean isContainEpcOrFlowChart(String wsId, String pid){
boolean flag = false;
Iterator<PALRepositoryModel> iterator = PALRepositoryCache.getByPid(wsId, pid);
if (!iterator.hasNext()) return flag;
while (iterator.hasNext()){
PALRepositoryModel currentModel = iterator.next();
if ("process.framework".equals(currentModel.getMethodId()) || "default".equals(currentModel.getMethodId())){
flag = this.isContainEpcOrFlowChart(wsId, currentModel.getVersionId());
}else if ("process.epc".equals(currentModel.getMethodId()) || "process.flowchart".equals(currentModel.getMethodId())){
flag = true;
}
if (flag) break;
}
return flag;
}
/**
* 查询当前节点下的所有子级节点
* @param nodeKeyJsonArr nodeKey的JSONArray字符串
* @return JSONArray
* @throws AWSException
*/
public JSONArray findModeTreeChildNodeAll(String nodeKeyJsonArr) throws AWSException{
if (UtilString.isEmpty(nodeKeyJsonArr)) {
throw new AWSException("参数异常");
}
List<SubProcessTagVo> tagVoList = new ArrayList<>();
Set<String> filterKeySet = new HashSet<>();
List<String> nodeKeys = JSONArray.parseArray(nodeKeyJsonArr, String.class);
List<PALRepositoryModel> modelList = new ArrayList<>();
for (String nodeKey : nodeKeys) {
PALRepositoryModel repositoryModel = PALRepositoryCache.getCache().get(nodeKey);
modelList.add(repositoryModel);
}
this.handleModelTreeChildNode(modelList, tagVoList, filterKeySet);
return (JSONArray) JSONArray.toJSON(tagVoList);
}
private void handleModelTreeChildNode(List<PALRepositoryModel> modelList, List<SubProcessTagVo> tagVoList, Set<String> filterKeySet){
for (PALRepositoryModel model : modelList) {
if (!("process.framework".equals(model.getMethodId())
|| "default".equals(model.getMethodId()))){
// 当前模型不是架构或者文件夹 则直接放入返回列表中
if (!filterKeySet.contains(model.getId())){
SubProcessTagVo tagVo = new SubProcessTagVo(model.getName(), model.getId());
tagVoList.add(tagVo);
filterKeySet.add(model.getId());
}
continue;
}
// 获取当前模型的一级子节点
Iterator<PALRepositoryModel> iterator = PALRepositoryCache.getByPid(model.getWsId(), model.getId());
List<PALRepositoryModel> list = IteratorUtils.toList(iterator);
handleModelTreeChildNode(list, tagVoList, filterKeySet);
}
}
/**
* 调用资产库主界面左侧树 API
* 在此基础上保留文件夹与架构
* 其它模型文件过滤掉
* @param wsId
* @param teamId
* @param pid
* @return
* @throws AWSException
*/
public JSONArray constructPositionTree(String wsId, String teamId, String pid) throws AWSException {
String property = SDK.getAppAPI().getProperty(SubProcessConst.APP_ID, SubProcessConst.SUB_PROCESS_MODEL_LOCATION);
if (UtilString.isEmpty(property))
throw new AWSException("应用参数【" + SubProcessConst.SUB_PROCESS_MODEL_LOCATION + "】异常");
String[] locationIds = property.split("/");
if (UtilString.isEmpty(pid)){
JSONArray result = PALRepositoryQueryAPIManager.getInstance().getPalRepositoryTreeRoot(uc, wsId, null, teamId);
result = result.stream()
.filter(item -> {
JSONObject model = (JSONObject) item;
return locationIds[0].equals(model.getString("id"));
}).collect(Collectors.toCollection(JSONArray :: new));
return result;
}
JSONArray result = PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryTreeDataByPidNew(uc, wsId, teamId, pid);
if (locationIds[0].equals(pid)){
result = result.stream()
.filter(item -> locationIds[1].equals(((JSONObject)item).getString("id")))
.collect(Collectors.toCollection(JSONArray :: new));
return result;
}
result = result.stream()
.filter(item -> {
boolean flag = false;
JSONObject model = (JSONObject) item;
return flag = "default".equals(model.getString("plMethodId")) || "".equals(model.getString("plMethodId"));
}).collect(Collectors.toCollection(JSONArray :: new));
return result;
}
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<aws-actions>
<cmd-bean name="com.actionsoft.apps.coe.method.process.subprocess.init_data"/>
<cmd-bean name="com.actionsoft.apps.coe.method.process.subprocess.find_tree_node">
<param name="wsId"/>
<param name="teamId"/>
<param name="pid"/>
<param name="createUsers"/>
<param name="orgIds"/>
<param name="methodIds"/>
</cmd-bean>
<cmd-bean name="com.actionsoft.apps.coe.method.process.subprocess.find_tree_child_node_all">
<param name="nodeKeyJsonArr"/>
</cmd-bean>
<cmd-bean name="com.actionsoft.apps.coe.method.process.subprocess.construct_position_tree">
<param name="wsId"/>
<param name="teamId"/>
<param name="pid"/>
</cmd-bean>
</aws-actions>