pal 小组应用源码补充
This commit is contained in:
parent
d3c519bf0c
commit
68e3f64c93
@ -0,0 +1,311 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.components.web.PALRepositoryTreeWeb;
|
||||
import com.actionsoft.apps.coe.pal.cooperation.web.CooperationWeb;
|
||||
import com.actionsoft.bpms.org.dao.User;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.server.bind.annotation.Controller;
|
||||
import com.actionsoft.bpms.server.bind.annotation.Mapping;
|
||||
|
||||
/**
|
||||
* @Created by sunlh
|
||||
* @Date 2020-12-01
|
||||
*/
|
||||
|
||||
@Controller
|
||||
public class CooperationController {
|
||||
|
||||
/**
|
||||
* 主页
|
||||
* @param uc
|
||||
* @param mainPage
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_main")
|
||||
public String mainPage(UserContext uc, String mainPage) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.mainPage(mainPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建、修改小组时查询必要数据
|
||||
* @param uc
|
||||
* @param teamId
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_team_create_or_update_data_query")
|
||||
public String queryTeamCreateOrUpdateData(UserContext uc, String teamId) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.queryTeamCreateOrUpdateData(teamId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询PAL用户树
|
||||
* @param uc
|
||||
* @param pid
|
||||
* @param parentType
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_pal_user_tree_subjson")
|
||||
public String queryPalUserTree(UserContext uc, String pid, String parentType) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.queryPalUserTree(pid, parentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建、修改的小组信息
|
||||
* @param uc
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_team_create_or_update_data_save")
|
||||
public String saveTeamCreateOrUpdateData(UserContext uc, String data) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.saveTeamCreateOrUpdateData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前用户拥有管理权限的小组
|
||||
* @param uc
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_manage_team_info_list")
|
||||
public String queryManageTeamInfoList(UserContext uc) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.queryManageTeamInfoList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前用户所在的所有小组
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_manage_joined_team_list_query")
|
||||
public String queryJoinedTeamList(UserContext uc) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.queryJoinedTeamList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对小组进行排序
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_manage_user_team_sort")
|
||||
public String sortTeam(UserContext uc, String teamIds) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.sortTeam(teamIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改小组的基本信息
|
||||
* @param uc
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_manage_team_baseinfo_update_save")
|
||||
public String updateTeamInfo(UserContext uc, String data) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.updateTeamInfo(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改小组状态,停用/启用
|
||||
* @param uc
|
||||
* @param teamId
|
||||
* @param status 0启用/1停用
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_manage_team_update_status")
|
||||
public String updateTeamStatus(UserContext uc, String teamId, int status) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.updateTeamStatus(teamId, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解散小组
|
||||
* @param uc
|
||||
* @param teamId
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_manage_team_remove")
|
||||
public String removeTeam(UserContext uc, String teamId) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.removeTeam(teamId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出小组
|
||||
* @param uc
|
||||
* @param teamId
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_manage_team_exit")
|
||||
public String exitTeam(UserContext uc, String teamId) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.exitTeam(teamId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小组的详细信息,成员信息
|
||||
* @param uc
|
||||
* @param teamId
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_manage_team_detail_query")
|
||||
public String queryTeamDetail(UserContext uc, String teamId) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.queryTeamDetail(teamId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小组角色列表
|
||||
* @param uc
|
||||
* @param teamId
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_role_data_query")
|
||||
public String queryRoleData(UserContext uc, String teamId, String userIds) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.queryRoleData(teamId, userIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户的角色保存
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_role_user_update_save")
|
||||
public String saveUserUpdateRole(UserContext uc, String data) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.saveUserUpdateRole(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除小组角色
|
||||
* @param uc
|
||||
* @param teamId
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_role_remove")
|
||||
public String removeCooperationRole(UserContext uc, String teamId, String roleId) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.removeCooperationRole(teamId, roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增、修改角色信息时查询相关角色信息
|
||||
* @param uc
|
||||
* @param teamId
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_role_create_or_update_data_query")
|
||||
public String queryRoleUpdateData(UserContext uc, String teamId, String roleId) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.queryRoleUpdateData(teamId, roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设置的小组权限范围内的流程树结构
|
||||
* @param uc
|
||||
* @param wsId
|
||||
* @param teamId
|
||||
* @param pid
|
||||
* @param categorys
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_repository_tree_component_subjson")
|
||||
public String queryCooperationTeamRepositoryTree(UserContext uc, String wsId, String teamId, String pid, String categorys) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.queryCooperationTeamRepositoryTree(wsId, teamId, pid, categorys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小组权限范围内流程树
|
||||
* @param uc
|
||||
* @param wsId
|
||||
* @param teamId
|
||||
* @param rootId
|
||||
* @param categorys
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_repository_tree_component_search")
|
||||
public String searchCooperationTeamRepositoryTreeData(UserContext uc, String wsId, String teamId, String rootId, String categorys, String name) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.searchCooperationTeamRepositoryTreeData(wsId, teamId, rootId, categorys, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小组权限范围内所有的子节点
|
||||
* @param uc
|
||||
* @param wsId
|
||||
* @param teamId
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_repository_all_childern_data_query")
|
||||
public String searchCooperationTeamRepositoryAllChildrenData(UserContext uc, String wsId, String teamId, String pid) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.searchCooperationTeamRepositoryAllChildrenData(wsId, teamId, pid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据版本号查询当前正在使用中的流程名称
|
||||
* @param uc
|
||||
* @param versionIds
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_repository_names_query")
|
||||
public String queryRepositoryNamesByVersionIds(UserContext uc, String versionIds) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.queryRepositoryNamesByVersionIds(versionIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增/修改角色保存
|
||||
* @param uc
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_role_create_or_update_data_save")
|
||||
public String saveRoleUpdateData(UserContext uc, String data) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.saveRoleUpdateData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加成员,查询未加入小组的PAL用户以及现有的角色列表
|
||||
* @param uc
|
||||
* @param teamId
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_member_add_data_query")
|
||||
public String queryCooperationAddMemberData(UserContext uc, String teamId) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.queryCooperationAddMemberData(teamId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加成员,保存
|
||||
* @param uc
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_member_add_data_save")
|
||||
public String saveCooperationAddMemberData(UserContext uc, String data) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.saveCooperationAddMemberData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除小组成员
|
||||
* @param uc
|
||||
* @param teamId
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.cooperation_manage_team_member_remove")
|
||||
public String removeCooperationMember(UserContext uc, String teamId, String userIds) {
|
||||
CooperationWeb web = new CooperationWeb(uc);
|
||||
return web.removeCooperationMember(teamId, userIds);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,226 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation;
|
||||
|
||||
|
||||
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
|
||||
import com.actionsoft.apps.coe.pal.cooperation.util.CooperationUtil;
|
||||
import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache;
|
||||
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.util.CoeProcessLevelUtil;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.i18n.I18nRes;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CooperationQueryAPIManager {
|
||||
|
||||
private CooperationQueryAPIManager(){
|
||||
|
||||
}
|
||||
|
||||
public static CooperationQueryAPIManager getInstance() {
|
||||
return CooperationQueryAPIManager.Inner.instance;
|
||||
}
|
||||
|
||||
private static class Inner {
|
||||
private final static CooperationQueryAPIManager instance = new CooperationQueryAPIManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小组权限范围内的使用中的流程树根节点
|
||||
*
|
||||
* @param wsId
|
||||
* @param categorys
|
||||
* @param teamId 小组Id
|
||||
* @return
|
||||
*/
|
||||
public JSONArray getPalRepositoryTreeRoot(String wsId, String categorys, String teamId) {
|
||||
JSONArray result = new JSONArray();
|
||||
List<String> palMethodList;
|
||||
String[] categoryArray;
|
||||
if (UtilString.isEmpty(categorys)) {// 不指定分类
|
||||
palMethodList = PALMethodCache.getPALMethodList(true);
|
||||
if (!UtilString.isEmpty(teamId)) {
|
||||
palMethodList = PALMethodCache.getPALMethodList(true);
|
||||
List<String> list = new ArrayList<>();
|
||||
List<PALRepositoryModel> list1 = CooperationUtil.getPermRepositoryList(wsId, teamId, null, null, true, false);
|
||||
for (String str: palMethodList) {
|
||||
for (PALRepositoryModel model : list1) {
|
||||
if (model.getMethodCategory().equals(str)) {
|
||||
list.add(new String(str));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
palMethodList = list;
|
||||
}
|
||||
categoryArray = new String[palMethodList.size()];
|
||||
palMethodList.toArray(categoryArray);
|
||||
} else {// 指定分类
|
||||
categoryArray = categorys.split(",");
|
||||
}
|
||||
for (String category : categoryArray) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("id", category);
|
||||
jsonObject.put("versionId", category);
|
||||
String name = I18nRes.findValue(CoEConstant.APP_ID, category);
|
||||
jsonObject.put("name", name);
|
||||
JSONObject icon = new JSONObject();
|
||||
icon.put("icon", "");
|
||||
icon.put("color", "red");
|
||||
jsonObject.put("icon", icon);
|
||||
jsonObject.put("plCategory", category);
|
||||
List<PALRepositoryModel> list = CooperationUtil.getPermRepositoryList(wsId, teamId, category, null, true, false);
|
||||
if (list != null && list.size() > 0) {
|
||||
jsonObject.put("leaf", false);
|
||||
} else {
|
||||
jsonObject.put("leaf", true);
|
||||
}
|
||||
result.add(jsonObject);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据pid获取符合条件的子流程数据(小组权限范围内)
|
||||
* @param wsId
|
||||
* @param teamId
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
public JSONArray getUsedPalRepositoryTreeDataByPidNew(String wsId, String teamId, String pid) {
|
||||
// 获取符合权限的子流程
|
||||
List<PALRepositoryModel> childrenList = getUsedPalRepositoryModelsByPidNew(wsId, teamId, pid);
|
||||
CooperationUtil.sortByLevelAndOrderIndex(childrenList);
|
||||
Map<String, Integer> grandChildrenCountMap = new HashMap<>();
|
||||
for (PALRepositoryModel chlidModel : childrenList) {
|
||||
List<PALRepositoryModel> grandChildrenList = getUsedPalRepositoryModelsByPidNew(wsId, teamId, chlidModel.getId());
|
||||
grandChildrenCountMap.put(chlidModel.getId(), grandChildrenList.size());
|
||||
}
|
||||
JSONArray result = list2JsonNew(childrenList, grandChildrenCountMap);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个流程的使用中的子流程(小组权限范围内)
|
||||
*
|
||||
* @param wsId
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
public List<PALRepositoryModel> getUsedPalRepositoryModelsByPidNew(String wsId, String teamId, String pid) {
|
||||
if (UtilString.isEmpty(teamId)) {
|
||||
return PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryModelsByPid(wsId, pid);
|
||||
} else {
|
||||
List<PALRepositoryModel> result = new ArrayList<>();
|
||||
// 获取权限versionIds
|
||||
Set<String> permVerIds = CooperationUtil.getPermRepositoryVersionIds(wsId, teamId, null, null);
|
||||
if (permVerIds.size() > 0) {
|
||||
getPermRepositoryByPid(wsId, pid, permVerIds, true, false, new HashSet<>(), result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父节点获取权限范围内的子流程(小组权限范围内)
|
||||
* @param wsId
|
||||
* @param pid
|
||||
* @param permVersionIds 权限versionIds
|
||||
* @param isUse
|
||||
* @param isPublish
|
||||
* @param verIds 给一个空的Set,防止数据造成的死循环
|
||||
* @param result 结果集
|
||||
*/
|
||||
private void getPermRepositoryByPid(String wsId, String pid, Set<String> permVersionIds, boolean isUse, boolean isPublish, Set<String> verIds, List<PALRepositoryModel> result) {
|
||||
List<PALRepositoryModel> childList = PALRepositoryCache.getAllSubModelsByPid(wsId, pid);
|
||||
if (childList != null && childList.size() > 0) {
|
||||
for (PALRepositoryModel model : childList) {
|
||||
if (verIds.contains(model.getVersionId())) {
|
||||
//防止无限循环
|
||||
continue;
|
||||
}
|
||||
if (isUse) {
|
||||
if (model.isUse()) {// 设计中的流程是连贯的,与发布不同
|
||||
verIds.add(model.getVersionId());
|
||||
if (permVersionIds.contains(model.getVersionId())) {
|
||||
result.add(model);
|
||||
} else {
|
||||
getPermRepositoryByPid(wsId, model.getId(), permVersionIds, isUse, isPublish, verIds, result);
|
||||
}
|
||||
}
|
||||
} else if (isPublish) {
|
||||
if (model.isPublish() && permVersionIds.contains(model.getVersionId())) {
|
||||
verIds.add(model.getVersionId());
|
||||
result.add(model);
|
||||
} else {
|
||||
getPermRepositoryByPid(wsId, model.getId(), permVersionIds, isUse, isPublish, verIds, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新的流程树list转换json方法
|
||||
* @param list
|
||||
* @param childrenCountMap list中的model是否具有子节点map记录
|
||||
* @return
|
||||
*/
|
||||
private JSONArray list2JsonNew(List<PALRepositoryModel> list, Map<String, Integer> childrenCountMap) {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (PALRepositoryModel model : list) {
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("id", model.getVersionId().trim());
|
||||
object.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(model.getId(), model.getWsId()).trim());
|
||||
object.put("name", I18nRes.findValue(CoEConstant.APP_ID, model.getName()).trim());
|
||||
object.put("wsId", model.getWsId());
|
||||
object.put("isSystemFile", model.isSystemFile());
|
||||
object.put("plMethodId", model.getMethodId().trim());
|
||||
JSONObject icon = new JSONObject();// vue
|
||||
if (!"default".equals(model.getMethodId())) {
|
||||
if (PALMethodCache.getPALMethodModelById(model.getMethodId()) == null) {
|
||||
object.put("iconFont", "");
|
||||
icon.put("icon", "");
|
||||
icon.put("color", "#ff9421");
|
||||
} else {
|
||||
object.put("iconFont", "");
|
||||
icon.put("icon", "");
|
||||
icon.put("color", "#909399");
|
||||
}
|
||||
} else {
|
||||
object.put("iconFont", "");
|
||||
icon.put("icon", "");
|
||||
icon.put("color", "#ff9421");
|
||||
}
|
||||
object.put("icon", icon);
|
||||
List<PALRepositoryModel> children = null;
|
||||
if (childrenCountMap.containsKey(model.getId()) && childrenCountMap.get(model.getId()) > 0) {
|
||||
object.put("leaf", false);// 非叶子节点
|
||||
} else {
|
||||
object.put("leaf", true);// 叶子节点
|
||||
}
|
||||
object.put("plLevel", model.getLevel());
|
||||
object.put("plOrdexIndex", model.getOrderIndex());
|
||||
object.put("plDiagramUrl", model.getDiagramUrl());
|
||||
object.put("isDrops", model.isSystemFile());
|
||||
object.put("isPublish", model.isPublish());
|
||||
object.put("isStop", model.isStop());
|
||||
object.put("isApproval", model.isApproval());
|
||||
object.put("ext1", model.getExt1());
|
||||
object.put("ext2", model.getExt2());
|
||||
object.put("ext3", model.getExt3());
|
||||
object.put("ext4", model.getExt4());
|
||||
object.put("isUse", model.isUse());
|
||||
object.put("plCategory", model.getMethodCategory());
|
||||
object.put("versionId", model.getVersionId());
|
||||
object.put("orderIndex", model.getOrderIndex());
|
||||
object.put("isBottomLevel", model.isBottomLevel());
|
||||
jsonArray.add(object);
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.aslp;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.cooperation.extend.CooperationAppManager;
|
||||
import com.actionsoft.apps.coe.pal.cooperation.extend.CooperationAppProfile;
|
||||
import com.actionsoft.apps.resource.interop.aslp.ASLP;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 列出PAL小组扩展的App
|
||||
*/
|
||||
public class ListApps implements ASLP {
|
||||
|
||||
@Override
|
||||
public ResponseObject call(Map<String, Object> params) {
|
||||
List<CooperationAppProfile> list = CooperationAppManager.getList();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (CooperationAppProfile profile : list) {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("appId", profile.getAppContext().getId());
|
||||
jo.put("id", profile.getId());
|
||||
jo.put("title", profile.getTitle());
|
||||
jo.put("desc", profile.getDesc());
|
||||
jsonArray.add(jo);
|
||||
}
|
||||
return ResponseObject.newOkResponse().put("apps", jsonArray);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.aslp;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.cooperation.extend.CooperationAppManager;
|
||||
import com.actionsoft.apps.resource.AppContext;
|
||||
import com.actionsoft.apps.resource.interop.aslp.ASLP;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 为流程团队扩展App,推荐注册位置放在该App的启动后事件
|
||||
*
|
||||
* @author jack
|
||||
*
|
||||
*/
|
||||
public class RegisterApp implements ASLP {
|
||||
|
||||
@Override
|
||||
public ResponseObject call(Map<String, Object> params) {
|
||||
if (params == null) {
|
||||
return ResponseObject.newErrResponse().err("不接受参数为空的调用!");
|
||||
}
|
||||
AppContext app = (AppContext) params.get("caller");
|
||||
String id = (String) params.get("id");
|
||||
String title = (String) params.get("title");
|
||||
String desc = (String) params.get("desc");
|
||||
String deletedClass = (String) params.get("deletedClass");
|
||||
CooperationAppManager.register(app, id, title, desc, deletedClass);
|
||||
return ResponseObject.newOkResponse();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.constant;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Created by sunlh
|
||||
* @Date 2020-12-01
|
||||
*/
|
||||
public class Constant {
|
||||
|
||||
public final static String APP_ID = "com.actionsoft.apps.coe.pal.cooperation";
|
||||
|
||||
public final static String SORT_KEY = "sort";
|
||||
|
||||
public final static String SORT_TEAM_NAME = "team";
|
||||
|
||||
public final static String TEAMWORK_UPGRADE_LOG = "teamworkUpgradeLog";// 流程团队自动升级日志
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.dc;
|
||||
|
||||
import com.actionsoft.bpms.server.fs.AbstFileProcessor;
|
||||
|
||||
public class FileProcessor extends AbstFileProcessor{
|
||||
|
||||
}
|
||||
@ -0,0 +1,107 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.dto;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description 小组信息,成员信息
|
||||
* @Created by sunlh
|
||||
* @Date 2020-12-15
|
||||
*/
|
||||
public class CooperationManageListTeamDetailDto {
|
||||
|
||||
private String userId;
|
||||
private String teamId;
|
||||
private String teamName;
|
||||
private JSONObject teamLogo;// {code:xx,color:xx}
|
||||
private String teamDesc;
|
||||
private Boolean run;// 小组状态
|
||||
private Boolean teamManager;// 是否小组管理员
|
||||
private String wsId;
|
||||
private String wsName;
|
||||
private List<CooperationManageListTeamMemberDto> members;
|
||||
|
||||
public CooperationManageListTeamDetailDto() {
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getTeamId() {
|
||||
return teamId;
|
||||
}
|
||||
|
||||
public void setTeamId(String teamId) {
|
||||
this.teamId = teamId;
|
||||
}
|
||||
|
||||
public String getTeamName() {
|
||||
return teamName;
|
||||
}
|
||||
|
||||
public void setTeamName(String teamName) {
|
||||
this.teamName = teamName;
|
||||
}
|
||||
|
||||
public String getTeamDesc() {
|
||||
return teamDesc;
|
||||
}
|
||||
|
||||
public void setTeamDesc(String teamDesc) {
|
||||
this.teamDesc = teamDesc;
|
||||
}
|
||||
|
||||
public JSONObject getTeamLogo() {
|
||||
return teamLogo;
|
||||
}
|
||||
|
||||
public void setTeamLogo(JSONObject teamLogo) {
|
||||
this.teamLogo = teamLogo;
|
||||
}
|
||||
|
||||
public Boolean getRun() {
|
||||
return run;
|
||||
}
|
||||
|
||||
public void setRun(Boolean run) {
|
||||
this.run = run;
|
||||
}
|
||||
|
||||
public Boolean getTeamManager() {
|
||||
return teamManager;
|
||||
}
|
||||
|
||||
public void setTeamManager(Boolean teamManager) {
|
||||
this.teamManager = teamManager;
|
||||
}
|
||||
|
||||
public String getWsId() {
|
||||
return wsId;
|
||||
}
|
||||
|
||||
public void setWsId(String wsId) {
|
||||
this.wsId = wsId;
|
||||
}
|
||||
|
||||
public String getWsName() {
|
||||
return wsName;
|
||||
}
|
||||
|
||||
public void setWsName(String wsName) {
|
||||
this.wsName = wsName;
|
||||
}
|
||||
|
||||
public List<CooperationManageListTeamMemberDto> getMembers() {
|
||||
return members;
|
||||
}
|
||||
|
||||
public void setMembers(List<CooperationManageListTeamMemberDto> members) {
|
||||
this.members = members;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,116 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.dto;
|
||||
|
||||
import org.apache.xpath.operations.Bool;
|
||||
|
||||
/**
|
||||
* @Description 小组成员
|
||||
* @Created by sunlh
|
||||
* @Date 2020-12-15
|
||||
*/
|
||||
public class CooperationManageListTeamMemberDto {
|
||||
|
||||
private String userId;
|
||||
private String userName;
|
||||
private String deptId;
|
||||
private String deptName;
|
||||
private String email;
|
||||
private Boolean close;
|
||||
|
||||
private String teamId;
|
||||
private String teamName;
|
||||
private String roleId;
|
||||
private String roleName;
|
||||
private int roleType;
|
||||
|
||||
public CooperationManageListTeamMemberDto() {
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(String deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public String getDeptName() {
|
||||
return deptName;
|
||||
}
|
||||
|
||||
public void setDeptName(String deptName) {
|
||||
this.deptName = deptName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getTeamId() {
|
||||
return teamId;
|
||||
}
|
||||
|
||||
public void setTeamId(String teamId) {
|
||||
this.teamId = teamId;
|
||||
}
|
||||
|
||||
public String getTeamName() {
|
||||
return teamName;
|
||||
}
|
||||
|
||||
public void setTeamName(String teamName) {
|
||||
this.teamName = teamName;
|
||||
}
|
||||
|
||||
public String getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(String roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public int getRoleType() {
|
||||
return roleType;
|
||||
}
|
||||
|
||||
public void setRoleType(int roleType) {
|
||||
this.roleType = roleType;
|
||||
}
|
||||
|
||||
public Boolean getClose() {
|
||||
return close;
|
||||
}
|
||||
|
||||
public void setClose(Boolean close) {
|
||||
this.close = close;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.dto;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* @Description 个人小组管理小组信息查询
|
||||
* @Created by sunlh
|
||||
* @Date 2020-12-14
|
||||
*/
|
||||
public class CooperationManageMainTeamDto {
|
||||
private String teamId;
|
||||
private String teamName;
|
||||
private JSONObject teamLogo;// {code:xx,color:xx}
|
||||
private Boolean run;// 小组状态
|
||||
private Boolean teamManage;// 是否小组管理员
|
||||
|
||||
public CooperationManageMainTeamDto() {
|
||||
}
|
||||
|
||||
public CooperationManageMainTeamDto(String teamId, String teamName, JSONObject teamLogo, Boolean run, Boolean teamManage) {
|
||||
this.teamId = teamId;
|
||||
this.teamName = teamName;
|
||||
this.teamLogo = teamLogo;
|
||||
this.run = run;
|
||||
this.teamManage = teamManage;
|
||||
}
|
||||
|
||||
public String getTeamId() {
|
||||
return teamId;
|
||||
}
|
||||
|
||||
public void setTeamId(String teamId) {
|
||||
this.teamId = teamId;
|
||||
}
|
||||
|
||||
public String getTeamName() {
|
||||
return teamName;
|
||||
}
|
||||
|
||||
public void setTeamName(String teamName) {
|
||||
this.teamName = teamName;
|
||||
}
|
||||
|
||||
public JSONObject getTeamLogo() {
|
||||
return teamLogo;
|
||||
}
|
||||
|
||||
public void setTeamLogo(JSONObject teamLogo) {
|
||||
this.teamLogo = teamLogo;
|
||||
}
|
||||
|
||||
public Boolean getRun() {
|
||||
return run;
|
||||
}
|
||||
|
||||
public void setRun(Boolean run) {
|
||||
this.run = run;
|
||||
}
|
||||
|
||||
public Boolean getTeamManage() {
|
||||
return teamManage;
|
||||
}
|
||||
|
||||
public void setTeamManage(Boolean teamManage) {
|
||||
this.teamManage = teamManage;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.dto;
|
||||
|
||||
/**
|
||||
* @Description 角色信息
|
||||
* @Created by sunlh
|
||||
* @Date 2020-12-15
|
||||
*/
|
||||
public class CooperationRoleDto {
|
||||
|
||||
private String roleId;
|
||||
private String roleName;
|
||||
private String roleDesc;
|
||||
private int roleType;
|
||||
private String icon;
|
||||
|
||||
public CooperationRoleDto() {
|
||||
}
|
||||
|
||||
public String getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(String roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public String getRoleDesc() {
|
||||
return roleDesc;
|
||||
}
|
||||
|
||||
public void setRoleDesc(String roleDesc) {
|
||||
this.roleDesc = roleDesc;
|
||||
}
|
||||
|
||||
public int getRoleType() {
|
||||
return roleType;
|
||||
}
|
||||
|
||||
public void setRoleType(int roleType) {
|
||||
this.roleType = roleType;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,141 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.extend;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.cooperation.constant.Constant;
|
||||
import com.actionsoft.apps.resource.AppContext;
|
||||
import com.actionsoft.bpms.util.ClassReflect;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 注册和管理小组扩展应用
|
||||
*/
|
||||
public final class CooperationAppManager {
|
||||
private static List<CooperationAppProfile> _list = new ArrayList<>();
|
||||
|
||||
private CooperationAppManager() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*
|
||||
* @param app 具体的App实现对象
|
||||
* @param id 小组扩展应用的id,应用扩展唯一标识,可以为null,若为null,则默认应用id
|
||||
* @param title 报表标题,可以为null
|
||||
* @param desc 应用简单描述(可选),例如鼠标移动时的应用提示
|
||||
* @param deletedClass 对方App提供的一个普通Java类路径名,提供一个约定execute(String
|
||||
* teamId)方法,当小组被删除时回调。开发者可以在这里删除垃圾、配置信息,但不建议删除业务数据信息
|
||||
*/
|
||||
public static void register(AppContext app, String id, String title, String desc, String deletedClass) {
|
||||
CooperationAppProfile profile = new CooperationAppProfile();
|
||||
profile.setDeletedClass(deletedClass);
|
||||
profile.setId(id);
|
||||
profile.setTitle(title);
|
||||
profile.setDesc(desc);
|
||||
profile.setAppContext(app);
|
||||
boolean isUpdate = false;
|
||||
for (CooperationAppProfile p : _list) {
|
||||
if (p.getId().equals(profile.getId())) {
|
||||
p = profile;
|
||||
isUpdate = true;
|
||||
SDK.getAppAPI().info(SDK.getAppAPI().getAppContext(Constant.APP_ID), "扩展App[" + profile.getTitle() + "]重新被注册");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isUpdate) {
|
||||
_list.add(profile);
|
||||
SDK.getAppAPI().info(SDK.getAppAPI().getAppContext(Constant.APP_ID), "扩展App[" + profile.getTitle() + "]注册成功");
|
||||
}
|
||||
|
||||
// try {
|
||||
// System.out.println(callMainClass(UserContext.fromUID("admin"),
|
||||
// profile.getId(), "小组Id"));
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id获得profile注册信息
|
||||
*
|
||||
* @param id 注册profile时的Id
|
||||
* @return 如果没有找到返回null
|
||||
*/
|
||||
public static CooperationAppProfile getProfile(String id) {
|
||||
for (CooperationAppProfile p : _list) {
|
||||
if (p.getId().equals(id)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 有效的扩展应用App
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<CooperationAppProfile> getList() {
|
||||
List<CooperationAppProfile> list = new ArrayList<>();
|
||||
for (CooperationAppProfile p : _list) {
|
||||
if (SDK.getAppAPI().isActive(p.getAppContext().getId())) {
|
||||
list.add(p);
|
||||
}
|
||||
}
|
||||
list.sort((c1, c2) -> {
|
||||
return c1.getTitle().compareTo(c2.getTitle());
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知某个小组已删除,异步执行扩展App的级联删除方法
|
||||
*
|
||||
* @param teamId 小组Id
|
||||
* @return 如果出现错误,返回错误页面
|
||||
*/
|
||||
public static void signalTeamDeleted(String teamId) {
|
||||
for (CooperationAppProfile p : _list) {
|
||||
if (!UtilString.isEmpty(p.getDeletedClass()) && SDK.getAppAPI().isActive(p.getAppContext().getId())) {
|
||||
SignalTeamDeleted signal = new SignalTeamDeleted(p, teamId);
|
||||
Thread signalThread = new Thread(signal);
|
||||
signalThread.setName("com.actionsoft.apps.coe.cooperation Thread(Signal Team Deleted)-" + p.getTitle());
|
||||
signalThread.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SignalTeamDeleted implements Runnable {
|
||||
private String teamId;
|
||||
private CooperationAppProfile profile;
|
||||
|
||||
public SignalTeamDeleted(CooperationAppProfile profile, String teamId) {
|
||||
this.profile = profile;
|
||||
this.teamId = teamId;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
Constructor<?> cons = null;
|
||||
try {
|
||||
cons = ClassReflect.getConstructor(profile.getDeletedClass(), null, profile.getAppContext());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
SDK.getAppAPI().err(profile.getAppContext(), profile.getDeletedClass() + "--" + e.toString());
|
||||
}
|
||||
// 获得该接口实现类实例
|
||||
try {
|
||||
Class deletedClass = profile.getAppContext().getBindClassLoader().loadClass(profile.getDeletedClass());
|
||||
Object obj = cons.newInstance();
|
||||
Method execute = deletedClass.getMethod("execute", new Class[] { String.class });
|
||||
execute.invoke(obj, new Object[] { teamId });
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
SDK.getAppAPI().err(profile.getAppContext(), profile.getDeletedClass() + "--" + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.extend;
|
||||
|
||||
import com.actionsoft.apps.resource.AppContext;
|
||||
import com.actionsoft.bpms.util.MD5;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
|
||||
/**
|
||||
* PAL小组应用扩展描述
|
||||
*/
|
||||
public final class CooperationAppProfile {
|
||||
private AppContext appContext;
|
||||
private String id;
|
||||
private String title;
|
||||
private String desc;
|
||||
private String deletedClass;
|
||||
|
||||
public CooperationAppProfile() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 该扩展App的Id,若未指定,则以相应的appId
|
||||
*
|
||||
* @return id
|
||||
*/
|
||||
public String getId() {
|
||||
if (UtilString.isEmpty(id)) {
|
||||
return getAppContext().getId();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用简单描述(可选),例如鼠标移动时的应用提示
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDesc() {
|
||||
if (desc == null) {
|
||||
desc = "";
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用对象,如果该应用被停用,该Profile不会出现在可用状态
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public AppContext getAppContext() {
|
||||
return appContext;
|
||||
}
|
||||
|
||||
public void setAppContext(AppContext appContext) {
|
||||
this.appContext = appContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用标题
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getTitle() {
|
||||
if (UtilString.isEmpty(title)) {
|
||||
return appContext.getName();
|
||||
} else {
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对方App提供的一个普通Java类路径名,提供一个约定execute(String
|
||||
* teamId)方法,当小组被删除时回调。开发者可以在这里删除垃圾、配置信息,但不建议删除业务数据信息
|
||||
*
|
||||
* @return 可选。一个类路径
|
||||
*/
|
||||
public String getDeletedClass() {
|
||||
if (deletedClass == null)
|
||||
deletedClass = "";
|
||||
deletedClass = deletedClass.trim();
|
||||
return deletedClass;
|
||||
}
|
||||
|
||||
public void setDeletedClass(String deletedClass) {
|
||||
this.deletedClass = deletedClass;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.plugins;
|
||||
|
||||
import com.actionsoft.apps.listener.AppListener;
|
||||
import com.actionsoft.apps.resource.AppContext;
|
||||
|
||||
/**
|
||||
* @Description 应用安装后事件
|
||||
* @Created by sunlh
|
||||
* @Date 2020-12-28
|
||||
*/
|
||||
public class InstallListener implements AppListener {
|
||||
|
||||
@Override
|
||||
public void after(AppContext appContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean before(AppContext appContext) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.plugins;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.cooperation.aslp.ListApps;
|
||||
import com.actionsoft.apps.coe.pal.cooperation.aslp.RegisterApp;
|
||||
import com.actionsoft.apps.coe.pal.cooperation.dc.FileProcessor;
|
||||
import com.actionsoft.apps.listener.PluginListener;
|
||||
import com.actionsoft.apps.resource.AppContext;
|
||||
import com.actionsoft.apps.resource.plugin.profile.ASLPPluginProfile;
|
||||
import com.actionsoft.apps.resource.plugin.profile.AWSPluginProfile;
|
||||
import com.actionsoft.apps.resource.plugin.profile.AppExtensionProfile;
|
||||
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Created by sunlh
|
||||
* @Date 2020-12-01
|
||||
*/
|
||||
public class Plugins implements PluginListener {
|
||||
@Override
|
||||
public List<AWSPluginProfile> register(AppContext app) {
|
||||
List<AWSPluginProfile> list = new ArrayList<>();
|
||||
list.add(new ASLPPluginProfile("registerApp", RegisterApp.class.getName(), "开发者注册流程团队扩展App", null));
|
||||
list.add(new ASLPPluginProfile("listApps", ListApps.class.getName(), "列出已注册的流程团队扩展App", null));
|
||||
list.add(new DCPluginProfile("teamworkUpgradeLog", FileProcessor.class.getName(), "[流程团队][小组/权限数据]自动更新到[PAL小组]", false, false));
|
||||
|
||||
Map<String, Object> params2 = new HashMap<String, Object>();
|
||||
params2.put("title", "回收站");
|
||||
params2.put("id", "recycle");// 回收站标识
|
||||
params2.put("desc", "浏览和编辑流程回收站内容");
|
||||
params2.put("deletedClass", "");
|
||||
list.add(new AppExtensionProfile("PAL小组->回收站", "aslp://com.actionsoft.apps.coe.pal.cooperation/registerApp", params2));
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,407 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.plugins;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.cooperation.constant.CoeCooperationConst;
|
||||
import com.actionsoft.apps.coe.pal.cooperation.constant.Constant;
|
||||
import com.actionsoft.apps.coe.pal.cooperation.model.*;
|
||||
import com.actionsoft.apps.coe.pal.cooperation.util.LogUtil;
|
||||
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.ws.dao.CoeWorkSpaceDaoFactory;
|
||||
import com.actionsoft.apps.coe.pal.pal.ws.model.CoeWorkSpaceModel;
|
||||
import com.actionsoft.apps.coe.pal.teamwork.TeamPermAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.teamwork.cache.TeamMemberPermCache;
|
||||
import com.actionsoft.apps.coe.pal.teamwork.cache.TeamPermCache;
|
||||
import com.actionsoft.apps.coe.pal.teamwork.dao.TeamPerm;
|
||||
import com.actionsoft.apps.coe.pal.teamwork.model.TeamMemberPermExtendModel;
|
||||
import com.actionsoft.apps.coe.pal.teamwork.model.TeamMemberPermModel;
|
||||
import com.actionsoft.apps.coe.pal.teamwork.model.TeamPermModel;
|
||||
import com.actionsoft.apps.lifecycle.api.AppsAPIManager;
|
||||
import com.actionsoft.apps.listener.AppListener;
|
||||
import com.actionsoft.apps.resource.AppContext;
|
||||
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
|
||||
import com.actionsoft.bpms.commons.login.constant.LoginConst;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.commons.session.SessionImpl;
|
||||
import com.actionsoft.bpms.org.model.UserModel;
|
||||
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.util.UUIDGener;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.AppAPI;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description 启动后事件
|
||||
* @Created by sunlh
|
||||
* @Date 2021-03-16
|
||||
*/
|
||||
public class StartListener implements AppListener {
|
||||
@Override
|
||||
public void after(AppContext appContext) {
|
||||
// 同事圈&流程团队数据自动转换
|
||||
new upgradeTeamworkData().autoUpgradeRun();
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程团队数据自动升级
|
||||
*/
|
||||
class upgradeTeamworkData {
|
||||
private String sid = new SessionImpl().registerSession(LoginConst.SYSTEM_COE, "admin", "0:0:0:0:0:0:0:1", "cn", "pc", true, null).getSessionId();
|
||||
private UserContext uc = UserContext.fromSessionId(sid);
|
||||
private Timestamp time = new Timestamp(System.currentTimeMillis());
|
||||
|
||||
/**
|
||||
* 同事圈&流程团队数据自动转换为PAL小组数据
|
||||
*/
|
||||
private void autoUpgradeRun() {
|
||||
boolean isActive = AppsAPIManager.getInstance().isActive("com.actionsoft.apps.network");
|
||||
if (!isActive) {
|
||||
return;
|
||||
}
|
||||
List<TeamPermModel> list = new TeamPerm().query().list();
|
||||
if (list == null || list.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
File logFile = createTeamworkUpgradeLogFile();// 创建日志文件
|
||||
LogUtil.appendLog("[开始]PAL流程团队 小组-成员-权限 数据自动更新至 PAL小组 " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), logFile);
|
||||
LogUtil.appendLog("-------------------------------------------------------------------------------", logFile);
|
||||
CoeCooperationAPIManager api = CoeCooperationAPIManager.getInstance();
|
||||
List<CoeWorkSpaceModel> wsList = CoeWorkSpaceDaoFactory.createCoeWorkSpace().getCoeWorkSpaceModelRecodesNoPage(); // 所有资产库条数
|
||||
// 查询所有工作网络
|
||||
Map<String, String> networkMap = queryAllNetwork();
|
||||
for (CoeWorkSpaceModel ws : wsList) {
|
||||
String wsId = ws.getUUId();
|
||||
// 获取设置了权限的小组
|
||||
List<TeamPermModel> teamPermModelList = TeamPermCache.getTeamListByWsId(wsId);
|
||||
if (teamPermModelList != null && teamPermModelList.size() > 0) {
|
||||
teamPermModelList.sort((t1, t2) -> {return t1.getTeamId().compareTo(t2.getTeamId());});
|
||||
List<String> teamIds = new ArrayList<>();
|
||||
for (TeamPermModel teamPerm : teamPermModelList) {
|
||||
if (!teamIds.contains(teamPerm.getTeamId())) {
|
||||
teamIds.add(teamPerm.getTeamId());
|
||||
}
|
||||
}
|
||||
for (String teamId : teamIds) {
|
||||
// 获取同事圈该小组
|
||||
JSONObject team = queryTeamById(teamId);
|
||||
String teamName = team.getString("teamName");
|
||||
if (teamName.length() > 36) {
|
||||
teamName = teamName.substring(0, 36);
|
||||
}
|
||||
String teamDesc = team.getString("teamDesc");
|
||||
if (teamDesc.length() > 255) {
|
||||
teamDesc = teamDesc.substring(0, 255);
|
||||
}
|
||||
// 创建小组
|
||||
CoeCooperationTeamModel newTeam = new CoeCooperationTeamModel(teamId, wsId, networkMap.get(team.getString("networkId")), teamName, null, teamDesc, CoeCooperationConst.TEAM_STATUS_RUN, uc.getUID(), time, uc.getUID(), time);
|
||||
api.createCooperationTeam(newTeam);// to db
|
||||
// 记录日志
|
||||
LogUtil.appendLog("[成功][创建小组][" + newTeam.getTeamName() + "]", logFile);
|
||||
// 获取小组数据权限
|
||||
Set<String> teamPermVerIds = new HashSet<>();// 小组数据权限
|
||||
List<String> palNames = new ArrayList<>();
|
||||
List<TeamPermModel> teamPermList = TeamPermCache.getPALListOfTeam(teamId);
|
||||
if (teamPermList != null && teamPermList.size() > 0) {
|
||||
for (TeamPermModel model : teamPermList) {
|
||||
List<PALRepositoryModel> palList = PALRepositoryCache.getByVersionId(model.getResourceId());
|
||||
// 筛选有效的PAL模型
|
||||
if (palList != null && palList.size() > 0) {
|
||||
teamPermVerIds.add(model.getResourceId());
|
||||
palNames.add(palList.get(0).getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 小组权限
|
||||
List<CoeCooperationTeamPermModel> newTeamPermList = new ArrayList<>();
|
||||
for (String verId : teamPermVerIds) {
|
||||
CoeCooperationTeamPermModel teamPerm = new CoeCooperationTeamPermModel(UUIDGener.getUUID(), teamId, verId);
|
||||
newTeamPermList.add(teamPerm);
|
||||
}
|
||||
if (newTeamPermList.size() > 0) {
|
||||
api.createCooperationTeamPerms(newTeamPermList);// to db
|
||||
LogUtil.appendLog("[成功][创建小组模型数据权限][" + StringUtils.join(palNames, ",") + "]", logFile);
|
||||
}
|
||||
// 小组角色
|
||||
// 创建默认角色
|
||||
api.createCooperationDefaultRole(teamId, uc.getUID());
|
||||
LogUtil.appendLog("[成功][创建小组默认角色列表][管理员、设计人员、浏览人员]", logFile);
|
||||
// 查询管理员角色
|
||||
CoeCooperationRoleModel manageRole = api.queryCooperationManageRole(teamId);
|
||||
if (manageRole == null) {
|
||||
continue;
|
||||
}
|
||||
String manageRoleId = manageRole.getId();
|
||||
// 每个小组成员创建一个角色(管理员除外)
|
||||
List<CoeCooperationRoleModel> newRoleList = new ArrayList<>();
|
||||
List<String> newRoleNameList = new ArrayList<>();
|
||||
List<CoeCooperationRolePermModel> newRolePermList = new ArrayList<>();
|
||||
Map<String, List<String>> newRolePermNameMap = new HashMap<>();
|
||||
List<CoeCooperationMemberModel> newMemberList = new ArrayList<>();
|
||||
List<String> newMemberNameList = new ArrayList<>();
|
||||
JSONArray members = queryTeamMember(teamId);// 获取小组成员
|
||||
for (int i = 0; i < members.size(); i++) {
|
||||
JSONObject member = members.getJSONObject(i);
|
||||
String userId = member.getString("userId");
|
||||
boolean isManage = member.getBooleanValue("isManage");
|
||||
if (isManage) {// 管理员直接使用管理员角色
|
||||
// 创建成员
|
||||
CoeCooperationMemberModel newMember = new CoeCooperationMemberModel(UUIDGener.getUUID(), teamId, userId, manageRoleId, uc.getUID(), time, uc.getUID(), time);
|
||||
newMemberList.add(newMember);
|
||||
newMemberNameList.add(userId);
|
||||
} else {
|
||||
// 查询权限
|
||||
TeamMemberPermModel permModel = TeamMemberPermCache.getByTeamAndUser(teamId, userId);
|
||||
if (permModel == null) {
|
||||
continue;
|
||||
}
|
||||
String actionType = permModel.getActionType();
|
||||
String appPerm = queryRoleAppPerm(actionType);
|
||||
String actionPerm = queryRoleActionPerm(actionType);
|
||||
// 创建角色
|
||||
String newRoleId = UUIDGener.getUUID();
|
||||
UserModel user = SDK.getORGAPI().getUser(userId);
|
||||
String roleName = (user == null ? userId : user.getUserName()) + "(角色)";
|
||||
String roleDesc = "系统根据[流程团队]小组成员权限自动创建的角色";
|
||||
CoeCooperationRoleModel newRoleModel = new CoeCooperationRoleModel(newRoleId, teamId, roleName, roleDesc, CoeCooperationConst.ROLE_TYPE_CUSTOM, appPerm, actionPerm, null, uc.getUID(), time, uc.getUID(), time);
|
||||
newRoleList.add(newRoleModel);
|
||||
newRoleNameList.add(newRoleModel.getRoleName());
|
||||
// 创建角色数据权限
|
||||
Set<String> rolePermVerIds = queryRoleDataPerm(teamPermVerIds, permModel.getTeamMemberPermExtendModel());
|
||||
newRolePermNameMap.put(roleName + "[" + userId + "]", new ArrayList<>());
|
||||
for (String verId : rolePermVerIds) {
|
||||
CoeCooperationRolePermModel rolePerm = new CoeCooperationRolePermModel(UUIDGener.getUUID(), teamId, newRoleId, verId);
|
||||
newRolePermList.add(rolePerm);
|
||||
newRolePermNameMap.get(roleName + "[" + userId + "]").add(PALRepositoryCache.getByVersionId(rolePerm.getPalVersionId()).get(0).getName());
|
||||
}
|
||||
CoeCooperationMemberModel newMember = new CoeCooperationMemberModel(UUIDGener.getUUID(), teamId, userId, newRoleId, uc.getUID(), time, uc.getUID(), time);
|
||||
newMemberList.add(newMember);
|
||||
newMemberNameList.add(userId);
|
||||
}
|
||||
}
|
||||
if (newRoleList.size() > 0) {
|
||||
api.createCooperationRoles(newRoleList);// to db
|
||||
LogUtil.appendLog("[成功][创建角色列表][" + StringUtils.join(newRoleNameList, ",") + "]", logFile);
|
||||
}
|
||||
if (newMemberList.size() > 0) {
|
||||
api.createCooperationMemebers(newMemberList);// to db
|
||||
LogUtil.appendLog("[成功][创建小组成员][" + StringUtils.join(newMemberNameList, ",") + "]", logFile);
|
||||
}
|
||||
if (newRolePermList.size() > 0) {
|
||||
api.createCooperationRolePerms(newRolePermList);// to db
|
||||
LogUtil.appendLog("[成功][创建角色模型数据权限][" + JSON.toJSON(newRolePermNameMap) + "]", logFile);
|
||||
}
|
||||
LogUtil.appendLog("-------------------------------------------------------------------------------", logFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
LogUtil.appendLog("[完成]PAL流程团队 小组-成员-权限 数据自动更新至 PAL小组 " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), logFile);
|
||||
// 清空现有流程团队相关数据(不包括同事圈)
|
||||
LogUtil.appendLog("[开始][删除]PAL流程团队 小组-成员-权限 相关数据(不包括同事圈所有内容)", logFile);
|
||||
TeamPermAPIManager.getInstance().removeAllPerms();
|
||||
LogUtil.appendLog("[完成][删除]PAL流程团队 小组-成员-权限 相关数据(不包括同事圈所有内容)", logFile);
|
||||
|
||||
LogUtil.appendLog("[结束]PAL流程团队数据自动处理完成", logFile);
|
||||
LogUtil.appendLog("---end---", logFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色应用权限
|
||||
* @param actionType
|
||||
* @return
|
||||
*/
|
||||
private String queryRoleAppPerm(String actionType) {
|
||||
List<String> appPerm = new ArrayList<>();
|
||||
// 流程发布
|
||||
if (actionType.contains("p")) {
|
||||
appPerm.add("com.actionsoft.apps.coe.pal.publisher");
|
||||
}
|
||||
// 报告生成器
|
||||
if (actionType.contains("报告生成器")) {
|
||||
appPerm.add("com.actionsoft.apps.coe.pal.output");
|
||||
}
|
||||
// 关联查询
|
||||
if (actionType.contains("关联查询")) {
|
||||
appPerm.add("com.actionsoft.apps.coe.pal.relationsearch");
|
||||
}
|
||||
// 回收站
|
||||
if (actionType.contains("回收站")) {
|
||||
appPerm.add("recycle");
|
||||
}
|
||||
// ProcessOn
|
||||
if (actionType.contains("ProcessOn")) {
|
||||
appPerm.add("com.actionsoft.apps.coe.pal.processon");
|
||||
}
|
||||
// VOC-CTQ
|
||||
if (actionType.contains("VOC-CTQ")) {
|
||||
appPerm.add("com.actionsoft.apps.coe.pal.voc.ctq");
|
||||
}
|
||||
return StringUtils.join(appPerm, ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色操作权限
|
||||
* @param actionType
|
||||
* @return
|
||||
*/
|
||||
private String queryRoleActionPerm(String actionType) {
|
||||
List<String> actionPerm = new ArrayList<>();
|
||||
// 新增、修改权限
|
||||
if (actionType.contains(CoeCooperationConst.ACTION_WRITE)) {
|
||||
actionPerm.add(CoeCooperationConst.ACTION_WRITE);
|
||||
}
|
||||
// 删除权限
|
||||
if (actionType.contains(CoeCooperationConst.ACTION_DELETE)) {
|
||||
actionPerm.add(CoeCooperationConst.ACTION_DELETE);
|
||||
}
|
||||
// 版本管理权限
|
||||
if (actionType.contains(CoeCooperationConst.ACTION_VERSION)) {
|
||||
actionPerm.add(CoeCooperationConst.ACTION_VERSION);
|
||||
}
|
||||
return StringUtils.join(actionPerm, ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色数据权限
|
||||
* @param teamPermVerIds
|
||||
* @param extendModelList
|
||||
* @return
|
||||
*/
|
||||
private Set<String> queryRoleDataPerm(Set<String> teamPermVerIds, List<TeamMemberPermExtendModel> extendModelList) {
|
||||
Set<String> rolePermVerIds = new HashSet<>();// 角色数据权限
|
||||
if (extendModelList != null && extendModelList.size() > 0) {
|
||||
for (TeamMemberPermExtendModel extend : extendModelList) {
|
||||
// 必须在小组权限内
|
||||
if (teamPermVerIds.contains(extend.getResourceId())) {
|
||||
rolePermVerIds.add(extend.getResourceId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return rolePermVerIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小组成员
|
||||
* @param teamId
|
||||
*/
|
||||
private JSONArray queryTeamMember(String teamId) {
|
||||
JSONArray result = new JSONArray();
|
||||
// 调用App
|
||||
String sourceAppId = CoeCooperationConst.COOPERATION_ID;
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.network/queryTeamMemberByTeamId";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
params.put("sid", sid);
|
||||
//小组ID,必填
|
||||
params.put("teamId", teamId);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//查询某个小组的成员列表
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
if (ro.isOk()) {
|
||||
Map map = (Map) ro.getData();
|
||||
JSONArray teamMembers = (JSONArray) map.get("teamMembers");
|
||||
for (int i = 0; i < teamMembers.size(); i++) {
|
||||
JSONObject member = teamMembers.getJSONObject(i);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("userId", member.getString("userId"));
|
||||
obj.put("createUser", member.getString("createUserId"));
|
||||
obj.put("createTime", member.getString("createTime"));
|
||||
obj.put("isManage", "1".equals(member.getString("memberType")));
|
||||
result.add(obj);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小组
|
||||
* @param teamId
|
||||
* @return
|
||||
*/
|
||||
private JSONObject queryTeamById(String teamId) {
|
||||
// 调用App
|
||||
String sourceAppId = CoeCooperationConst.COOPERATION_ID;
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.network/queryTeamById";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
//小组ID,必填
|
||||
params.put("teamId", teamId);
|
||||
params.put("sid", sid);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//查询小组信息
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
// 小组名称,小组简介,分类,logo
|
||||
if (ro.isOk()) {
|
||||
// 获取小组工作网络
|
||||
Map map = (Map) ro.getData();
|
||||
JSONObject team = (JSONObject) map.get("team");
|
||||
return team;
|
||||
}
|
||||
return new JSONObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有工作网络
|
||||
* @return
|
||||
*/
|
||||
private Map<String, String> queryAllNetwork() {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
// 调用App
|
||||
String sourceAppId = CoeCooperationConst.COOPERATION_ID;
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.network/queryAllNetwork";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
params.put("sid", sid);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//查询所有工作网络列表
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
if (ro.isOk()) {
|
||||
JSONArray arr = (JSONArray)((Map)ro.getData()).get("networks");
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject network = arr.getJSONObject(i);
|
||||
result.put(network.getString("id"), network.getString("networkName"));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建流程团队数据权限自动升级日志
|
||||
* @return
|
||||
*/
|
||||
private File createTeamworkUpgradeLogFile() {
|
||||
// 创建dc目录
|
||||
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(Constant.APP_ID, Constant.TEAMWORK_UPGRADE_LOG);
|
||||
DCContext dc = new DCContext(uc, dcProfile, Constant.APP_ID, "logs", "upgrade");
|
||||
String dirPath = dc.getPath();
|
||||
File dir = new File(dirPath);
|
||||
dir.mkdirs();
|
||||
File logFile = new File(dirPath, "upgrade.log");
|
||||
try {
|
||||
logFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return logFile;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean before(AppContext appContext) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.plugins;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager;
|
||||
import com.actionsoft.apps.listener.AppListener;
|
||||
import com.actionsoft.apps.resource.AppContext;
|
||||
|
||||
/**
|
||||
* @Description 卸载后事件
|
||||
* @Created by sunlh
|
||||
* @Date 2020-12-29
|
||||
*/
|
||||
public class UninstallListener implements AppListener {
|
||||
@Override
|
||||
public void after(AppContext appContext) {
|
||||
// 卸载时删除所有小组数据
|
||||
CoeCooperationAPIManager.getInstance().removeAllCooperation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean before(AppContext appContext) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,177 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.util;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
|
||||
import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.method.PALMethodManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.i18n.I18nRes;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CooperationUtil {
|
||||
/**
|
||||
* 统计个人权限下的模型文件的建模大类和建模方法分类
|
||||
* 不作为个人是否有某建模方法判断依据,仅根据已有数据进行统计
|
||||
* @param wsId
|
||||
* @param teamId
|
||||
*/
|
||||
public static List<JSONObject> getRepositoryCategoryAndMethods(String wsId, String teamId) {
|
||||
List<JSONObject> result = new ArrayList<>();
|
||||
List<String> palMethodCategoryList = PALMethodCache.getPALMethodList(true);// 获取建模标准大类
|
||||
Set<String> categorys = new HashSet<>();
|
||||
Set<String> methods = new HashSet<>();
|
||||
if (UtilString.isNotEmpty(teamId)) {
|
||||
Set<String> versionIds = getPermRepositoryVersionIds(wsId, teamId, null, null);
|
||||
for (String versionId : versionIds) {
|
||||
List<PALRepositoryModel> list = PALRepositoryCache.getByVersionId(versionId);
|
||||
if (list != null && list.size() > 0) {
|
||||
PALRepositoryModel model = list.get(0);
|
||||
categorys.add(model.getMethodCategory());
|
||||
methods.add(model.getMethodId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
methods.add("default");// 文件夹分类
|
||||
}
|
||||
for (String category : palMethodCategoryList) {
|
||||
if (UtilString.isNotEmpty(teamId) && !categorys.contains(category)) {
|
||||
continue;
|
||||
}
|
||||
JSONObject categoryObj = new JSONObject();
|
||||
String name = I18nRes.findValue(CoEConstant.APP_ID, category);
|
||||
categoryObj.put("category", category);
|
||||
categoryObj.put("id", category);
|
||||
categoryObj.put("name", name);
|
||||
categoryObj.put("method", new JSONArray());
|
||||
if ("process".equals(category) && methods.contains("default")) {// 文件夹特殊分类特殊处理
|
||||
JSONObject methodObj = new JSONObject();
|
||||
methodObj.put("app", CoEConstant.APP_ID);
|
||||
methodObj.put("category", category);
|
||||
methodObj.put("categoryName", I18nRes.findValue(CoEConstant.APP_ID, category));
|
||||
methodObj.put("method", "default");
|
||||
methodObj.put("id", "default");
|
||||
methodObj.put("name", "文件夹");
|
||||
JSONObject icon = PALMethodManager.getInstance().getPALMethodIconById("default");
|
||||
methodObj.put("icon", icon);
|
||||
categoryObj.getJSONArray("method").add(methodObj);
|
||||
}
|
||||
List<PALMethodModel> list = PALMethodCache.getPALMethodModelListByMethod(category);// 建模分类
|
||||
for (PALMethodModel model : list) {
|
||||
if (UtilString.isNotEmpty(teamId) && !methods.contains(model.getId())) {
|
||||
continue;
|
||||
}
|
||||
JSONObject methodObj = new JSONObject();
|
||||
methodObj.put("app", model.getApp().getId());
|
||||
methodObj.put("category", category);
|
||||
methodObj.put("categoryName", I18nRes.findValue(CoEConstant.APP_ID, category));
|
||||
methodObj.put("method", model.getId());
|
||||
methodObj.put("id", model.getId());
|
||||
methodObj.put("name", I18nRes.findValue(CoEConstant.APP_ID, model.getId()));
|
||||
JSONObject icon = PALMethodManager.getInstance().getPALMethodIconById(model.getId());
|
||||
methodObj.put("icon", icon);
|
||||
categoryObj.getJSONArray("method").add(methodObj);
|
||||
}
|
||||
result.add(categoryObj);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有有权限的模型文件的versionId
|
||||
* @param wsId 资产库Id
|
||||
* @param teamId 小组Id
|
||||
* @param category 建模方法大类,可为null
|
||||
* @param method 模型分类,可为null
|
||||
* @return
|
||||
*/
|
||||
public static Set<String> getPermRepositoryVersionIds(String wsId, String teamId, String category, String method) {
|
||||
Set<String> result = new HashSet<>();
|
||||
Iterator<PALRepositoryModel> iterator = PALRepositoryCache.getByWsId(wsId);
|
||||
while (iterator.hasNext()) {
|
||||
PALRepositoryModel model = iterator.next();
|
||||
if (!result.contains(model.getVersionId())) {
|
||||
if (UtilString.isNotEmpty(method)) {// 先判断建模分类(小)是否符合
|
||||
if (model.getMethodId().equals(method)) {
|
||||
result.add(model.getVersionId());
|
||||
}
|
||||
} else if (UtilString.isNotEmpty(category)){// 再判断建模分类(大)是否符合
|
||||
if (model.getMethodCategory().equals(category)) {
|
||||
result.add(model.getVersionId());
|
||||
}
|
||||
} else {
|
||||
result.add(model.getVersionId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 小组数据权限范围+该角色(当前用户所属角色)下的数据权限交集
|
||||
if (!UtilString.isEmpty(teamId)) {
|
||||
List<String> permVerList = CoeCooperationAPIManager.getInstance().queryCooperationTeamPermVerIds(teamId);
|
||||
Set<String> versionIds = new HashSet<>();
|
||||
if (result.size() > 0) {
|
||||
for (String verId : result) {
|
||||
if (permVerList.contains(verId)) {
|
||||
versionIds.add(verId);
|
||||
}
|
||||
}
|
||||
}
|
||||
result = versionIds;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有有权限的使用中的模型文件
|
||||
* @param wsId 资产库Id
|
||||
* @param teamId 小组Id
|
||||
* @param category 建模方法大类,可为null
|
||||
* @param method 模型分类,可为null
|
||||
* @return
|
||||
*/
|
||||
public static List<PALRepositoryModel> getPermRepositoryList(String wsId, String teamId, String category, String method, boolean isUse, boolean isPublish) {
|
||||
List<PALRepositoryModel> result = new ArrayList<>();
|
||||
Set<String> versionIds = getPermRepositoryVersionIds(wsId, teamId, category, method);
|
||||
for (String versionId : versionIds) {
|
||||
List<PALRepositoryModel> list = PALRepositoryCache.getByVersionId(versionId);
|
||||
if (list != null) {
|
||||
for (PALRepositoryModel model : list) {
|
||||
if ((isUse && model.isUse()) || (isPublish && model.isPublish())) {
|
||||
result.add(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序
|
||||
* @param list
|
||||
*/
|
||||
public static void sortByLevelAndOrderIndex(List<PALRepositoryModel> list) {
|
||||
Collections.sort(list, new Comparator1());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据级别排序
|
||||
*/
|
||||
private static class Comparator1 implements Comparator<PALRepositoryModel> {
|
||||
@Override
|
||||
public int compare(PALRepositoryModel model1, PALRepositoryModel model2) {
|
||||
Integer level1 = model1.getLevel();
|
||||
Integer level2 = model2.getLevel();
|
||||
int result = level1.compareTo(level2);
|
||||
if (result == 0) {
|
||||
Integer index1 = model1.getOrderIndex();
|
||||
Integer index2 = model2.getOrderIndex();
|
||||
result = index1.compareTo(index2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
package com.actionsoft.apps.coe.pal.cooperation.util;
|
||||
|
||||
import com.actionsoft.bpms.commons.log.auditing.constant.AuditConst;
|
||||
import com.actionsoft.bpms.commons.security.logging.model.Level;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class LogUtil {
|
||||
|
||||
/**
|
||||
* 追加日志内容
|
||||
* @param content 内容
|
||||
* @param file 文件
|
||||
*/
|
||||
public static void appendLog(String content, File file) {
|
||||
try {
|
||||
String logFilePath = file.getPath();
|
||||
// 构造函数中的第二个参数true表示以追加形式写文件
|
||||
FileOutputStream fos = new FileOutputStream(logFilePath, true);
|
||||
OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8");
|
||||
osw.write(content + "\n");
|
||||
osw.close();
|
||||
fos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("文件写入失败!" + e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void appendLog(String content, File ... files) {
|
||||
for (File file : files) {
|
||||
appendLog(content, file);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getStackTrace(Throwable t) {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
try {
|
||||
t.printStackTrace(pw);
|
||||
return sw.toString();
|
||||
} finally {
|
||||
pw.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getLogContent(File file) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
InputStreamReader reader = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
reader = new InputStreamReader(new FileInputStream(file), "UTF-8");
|
||||
br = new BufferedReader(reader);
|
||||
String s;
|
||||
while ((s = br.readLine()) != null) {
|
||||
builder.append(s).append("\n");
|
||||
}
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
if (br != null) {
|
||||
br.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录一条审计日志
|
||||
* @param me
|
||||
* @param op
|
||||
* @param obj
|
||||
* @param info
|
||||
* @param level
|
||||
*/
|
||||
public static void recordAuditLog(UserContext me, String op, String obj, String info, Level level) {
|
||||
SDK.getLogAPI().audit(AuditConst.CHANNEL_CLIENT, AuditConst.CATALOG_PROCESS, me.getUID(), op, obj, info, me.getClientIP(), level);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user