From 88051919bf45c966f95449efb2b97fdb0fd540c2 Mon Sep 17 00:00:00 2001 From: "446052889@qq.com" <446052889@qq.com> Date: Tue, 28 Jun 2022 11:11:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=8F=91=E5=B8=83app?= =?UTF-8?q?=E6=BA=90=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apps/coe/pal/publisher/Plugins.java | 151 + .../publisher/PublishClientController.java | 505 ++ .../pal/publisher/PublisherController.java | 641 +++ .../coe/pal/publisher/ReciveTeamDeleted.java | 15 + .../client/dao/PublisherClientDao.java | 340 ++ .../client/dto/ProcessPublishDTO.java | 106 + .../client/dto/ProcessPublishHistoryDTO.java | 140 + .../client/util/PublisherSkinsDao.java | 32 + .../client/web/ProcessPublishClientWeb.java | 4790 +++++++++++++++++ .../client/web/ProcessPublishWeb.java | 3020 +++++++++++ .../coe/pal/publisher/conf/PublisherConf.java | 235 + .../publisher/constant/PublisherConstant.java | 23 + .../publisher/event/AppInstallListener.java | 67 + .../pal/publisher/event/AppStartListener.java | 44 + .../publisher/event/AppUnInstallListener.java | 57 + .../event/PublishAppCustomAction.java | 120 + .../PublishExecuteListenerInterfaceImpl.java | 134 + ...ublishInstanceAfterReactivateLIstener.java | 244 + .../pal/publisher/event/SubFormAfterSave.java | 121 + .../event/SubFormGridFilterListener.java | 71 + 20 files changed, 10856 insertions(+) create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/Plugins.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/PublishClientController.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/PublisherController.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/ReciveTeamDeleted.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/dao/PublisherClientDao.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/dto/ProcessPublishDTO.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/dto/ProcessPublishHistoryDTO.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/PublisherSkinsDao.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishClientWeb.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishWeb.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/conf/PublisherConf.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/constant/PublisherConstant.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/AppInstallListener.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/AppStartListener.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/AppUnInstallListener.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishAppCustomAction.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishExecuteListenerInterfaceImpl.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishInstanceAfterReactivateLIstener.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/SubFormAfterSave.java create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/SubFormGridFilterListener.java diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/Plugins.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/Plugins.java new file mode 100644 index 00000000..be73e089 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/Plugins.java @@ -0,0 +1,151 @@ +package com.actionsoft.apps.coe.pal.publisher; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.actionsoft.apps.coe.pal.publisher.client.web.ProcessPublishClientWeb; +import com.actionsoft.apps.coe.pal.publisher.client.web.ProcessPublishWeb; +import com.actionsoft.apps.coe.pal.publisher.conf.PublisherConf; +import com.actionsoft.apps.coe.pal.publisher.event.PublishAppCustomAction; +import com.actionsoft.apps.listener.PluginListener; +import com.actionsoft.apps.resource.AppContext; +import com.actionsoft.apps.resource.plugin.profile.*; + +/** + * 插件需要的资源注册 + * + */ +public class Plugins implements PluginListener { + + public Plugins() { + } + + @Override + public List register(AppContext context) { + List list = new ArrayList(); + + // PAL应用扩展点 + Map params0 = new HashMap(); + params0.put("title", "流程发布"); + params0.put("icon", ""); + params0.put("desc", "流程发布"); + params0.put("mainClass", ProcessPublishWeb.class.getName()); + params0.put("deletedClass", ""); + list.add(new AppExtensionProfile("PAL流程资产库->流程发布", "aslp://com.actionsoft.apps.coe.pal/registerExtendsApp", params0)); + + // 注册应用扩展点 + Map params16 = new HashMap(); + params16.put("title", "流程发布"); + params16.put("desc", "发布流程到流程管理门户"); + params16.put("deletedClass", ReciveTeamDeleted.class.getName()); + list.add(new AppExtensionProfile("PAL小组->流程发布", "aslp://com.actionsoft.apps.coe.pal.cooperation/registerApp", params16)); + + list.add(new SkinsPluginProfile(ProcessPublishClientWeb.class.getName(), false)); + + + //自定义事件 + list.add(new AppCustomActionPluginProfile(PublishAppCustomAction.class.getName())); + + // 注册xpages + Map params2 = new HashMap(); + params2.put("systemName", "常用流程"); + params2.put("type", "2"); + params2.put("urlIdentifier", "com.actionsoft.apps.publisher_xpages_common_msg"); + params2.put("xpagesContent",PublisherConf.getXpagesContent("common") ); + list.add(new AppExtensionProfile("流程发布-常用流程", "aslp://com.actionsoft.apps.addons.xpages/registerApp", params2)); + + Map params3 = new HashMap(); + params3.put("systemName", "高频流程"); + params3.put("type", "2"); + params3.put("urlIdentifier", "com.actionsoft.apps.publisher_xpages_frequency_msg"); + params3.put("xpagesContent",PublisherConf.getXpagesContent("frequency") ); + list.add(new AppExtensionProfile("流程发布-高频流程", "aslp://com.actionsoft.apps.addons.xpages/registerApp", params3)); + + Map params4 = new HashMap(); + params4.put("systemName", "系统地图"); + params4.put("type", "2"); + params4.put("urlIdentifier", "com.actionsoft.apps.publisher_xpages_system_msg"); + params4.put("xpagesContent",PublisherConf.getXpagesContent("systemMap") ); + list.add(new AppExtensionProfile("流程发布-系统地图", "aslp://com.actionsoft.apps.addons.xpages/registerApp", params4)); + + Map params5 = new HashMap(); + params5.put("systemName", "流程地图"); + params5.put("type", "2"); + params5.put("urlIdentifier", "com.actionsoft.apps.publisher_xpages_processmap_msg"); + params5.put("xpagesContent",PublisherConf.getXpagesContent("processMap") ); + list.add(new AppExtensionProfile("流程发布-流程地图", "aslp://com.actionsoft.apps.addons.xpages/registerApp", params5)); + + Map params6 = new HashMap(); + params6.put("systemName", "发布动态"); + params6.put("type", "2"); + params6.put("urlIdentifier", "com.actionsoft.apps.publisher_xpages_notification_msg"); + params6.put("xpagesContent",PublisherConf.getXpagesContent("notification") ); + list.add(new AppExtensionProfile("流程发布-发布动态", "aslp://com.actionsoft.apps.addons.xpages/registerApp", params6)); + + Map params7 = new HashMap(); + params7.put("systemName", "数据地图"); + params7.put("type", "2"); + params7.put("urlIdentifier", "com.actionsoft.apps.publisher_xpages_data_msg"); + params7.put("xpagesContent",PublisherConf.getXpagesContent("dataMap") ); + list.add(new AppExtensionProfile("流程发布-数据地图", "aslp://com.actionsoft.apps.addons.xpages/registerApp", params7)); + + Map params8 = new HashMap(); + params8.put("systemName", "组织地图"); + params8.put("type", "2"); + params8.put("urlIdentifier", "com.actionsoft.apps.publisher_xpages_org_msg"); + params8.put("xpagesContent",PublisherConf.getXpagesContent("orgMap") ); + list.add(new AppExtensionProfile("流程发布-组织地图", "aslp://com.actionsoft.apps.addons.xpages/registerApp", params8)); + + Map params9 = new HashMap(); + params9.put("systemName", "控制地图"); + params9.put("type", "2"); + params9.put("urlIdentifier", "com.actionsoft.apps.publisher_xpages_control_msg"); + params9.put("xpagesContent",PublisherConf.getXpagesContent("controlMap") ); + list.add(new AppExtensionProfile("流程发布-控制地图", "aslp://com.actionsoft.apps.addons.xpages/registerApp", params9)); + + Map params10 = new HashMap(); + params10.put("systemName", "轮播图"); + params10.put("type", "1"); + params10.put("urlIdentifier", "com.actionsoft.apps.publisher_xpages_banner_msg"); + params10.put("xpagesContent", "./w?sid=@sid&cmd=com.actionsoft.apps.publisher_xpages_banner_msg" ); + list.add(new AppExtensionProfile("流程发布-轮播图", "aslp://com.actionsoft.apps.addons.xpages/registerApp", params10)); + + Map param11 = new HashMap<>(); + param11.put("systemName", "我参与的"); + param11.put("type", "2"); + param11.put("urlIdentifier", "com.actionsoft.apps.publisher_xpages_participant_msg"); + param11.put("xpagesContent",PublisherConf.getXpagesContent("participant") ); + // list.add(new AppExtensionProfile("流程发布-我参与的", "aslp://com.actionsoft.apps.addons.xpages/registerApp", param11)); + + Map param12 = new HashMap<>(); + param12.put("systemName", "我负责的"); + param12.put("type", "2"); + param12.put("urlIdentifier", "com.actionsoft.apps.publisher_xpages_responsible_msg"); + param12.put("xpagesContent",PublisherConf.getXpagesContent("responsible") ); + // list.add(new AppExtensionProfile("流程发布-我负责的", "aslp://com.actionsoft.apps.addons.xpages/registerApp", param12)); + + Map param13 = new HashMap<>(); + param13.put("systemName", "岗位职责"); + param13.put("type", "2"); + param13.put("urlIdentifier", "com.actionsoft.apps.publisher_xpages_postresponsibility_msg"); + param13.put("xpagesContent",PublisherConf.getXpagesContent("postresponsibility") ); + // list.add(new AppExtensionProfile("流程发布-岗位职责", "aslp://com.actionsoft.apps.addons.xpages/registerApp", param13)); + + Map param14 = new HashMap<>(); + param14.put("systemName", "RCAI矩阵"); + param14.put("type", "2"); + param14.put("urlIdentifier", "com.actionsoft.apps.publisher_xpages_rcaimatrix_msg"); + param14.put("xpagesContent",PublisherConf.getXpagesContent("rcaimatrix") ); + // list.add(new AppExtensionProfile("流程发布-RCAI矩阵", "aslp://com.actionsoft.apps.addons.xpages/registerApp", param14)); + + Map params15 = new HashMap(); + params15.put("systemName", "流程发布->催办通知"); + params15.put("icon", ""); + list.add(new AppExtensionProfile("流程发布->通知", "aslp://com.actionsoft.apps.notification/registerApp", params15)); + + return list; + } + +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/PublishClientController.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/PublishClientController.java new file mode 100644 index 00000000..d622c488 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/PublishClientController.java @@ -0,0 +1,505 @@ +package com.actionsoft.apps.coe.pal.publisher; + +import com.actionsoft.apps.coe.pal.publisher.client.web.ProcessPublishClientWeb; +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.bpms.util.UtilString; + +@Controller +public class PublishClientController { + //流程发布首页 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_home") + public String publishClientHome(UserContext me) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.getHomePage(me); + } + //按组织维护流程-首页 + @Mapping("com.actionsoft.apps.coe.pal.publisher_manage_home") + public String getManageHome(UserContext me, String wsId, String categorys) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + if (UtilString.isEmpty(categorys)) { + categorys = "process"; + } + return web.getManageHome(wsId, categorys); + } + + //流程查询-首页 + @Mapping("com.actionsoft.apps.coe.pal.publisher_manage_search_home") + public String getManageSearchHome(UserContext me, String wsId, String categorys) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + if (UtilString.isEmpty(categorys)) { + categorys = "process"; + } + + return web.getManageSearchHome(wsId, categorys); + } + + //流程查询-条件查询 + @Mapping("com.actionsoft.apps.coe.pal.publisher_manage_search_condition_home") + public String getManageSearchHomeCondition(UserContext me, String wsId, String categorys) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + if (UtilString.isEmpty(categorys)) { + categorys = "process"; + } + + return web.getManageSearchHomeCondition(wsId, categorys); + } + + /** + * 常用流程查询 + * @param me + * @param count + * @return + */ + @Mapping("com.actionsoft.apps.publisher_xpages_common_msg") + public String commonProcessQuery(UserContext me, String count) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.commonProcessQuery(me, count); + } + + /** + * 高频流程查询 + * @param me + * @param count + * @return + */ + @Mapping("com.actionsoft.apps.publisher_xpages_frequency_msg") + public String frequencyProcessQuery(UserContext me, String count) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.frequencyProcessQuery(me, count); + } + + + /** + * 系统地图查询 + * @param me + * @param count + * @return + */ + @Mapping("com.actionsoft.apps.publisher_xpages_system_msg") + public String systemDataQuery(UserContext me, String count) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryDataBycategory(me, count, "itsystem", "systemmap"); + } + + /** + * 组织地图查询 + * @param me + * @param count + * @return + */ + @Mapping("com.actionsoft.apps.publisher_xpages_org_msg") + public String orgDataQuery(UserContext me, String count) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryDataBycategory(me, count, "org", "orgmap"); + } + + /** + * 数据/表单地图查询 + * @param me + * @param count + * @return + */ + @Mapping("com.actionsoft.apps.publisher_xpages_data_msg") + public String dataDataQuery(UserContext me, String count) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryDataBycategory(me, count, "data", "systemmap"); + } + + /** + * 控制/风险地图查询 + * @param me + * @param count + * @return + */ + @Mapping("com.actionsoft.apps.publisher_xpages_control_msg") + public String controlDataQuery(UserContext me, String count) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryDataBycategory(me, count, "control", "controlmap"); + } + + /** + * 流程通知公告 + * @param me + * @param count + * @return + */ + @Mapping("com.actionsoft.apps.publisher_xpages_notification_msg") + public String notificationDataQuery(UserContext me, String count) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryNotificationData(me, "0", count); + } + + /** + * 查询启用中的资产库列表和aws组织列表 + * @param me + * @return + */ + @Mapping("com.actionsoft.apps.publisher_xpages_processmap_ws_org_query") + public String processmapWsAndOrgDataQuery(UserContext me) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.processmapWsAndOrgDataQuery(me); + } + + /** + * 流程地图 + * @param me + * @param wsId + * @param orgId + * @return + */ + @Mapping("com.actionsoft.apps.publisher_xpages_processmap_msg") + public String processmapDataQuery(UserContext me, String wsId, String orgId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryProcessmapData(me, wsId, orgId); + } + + /** + * 轮播图 + * @param me + * @return + */ + @Mapping("com.actionsoft.apps.publisher_xpages_banner_msg") + public String bannerDataQuery(UserContext me) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryBannerData(me); + } + + /** + * 打开流程 + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_page") + public String openPage(UserContext me, String uuid, String taskId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.openPage(me, uuid, taskId); + } + + /** + * 搜索功能 + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_search_page") + public String search(UserContext me, String text, String type, String templateId, String wsId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.search(me, text, type, templateId, wsId); + } + + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_search_data") + public String searchData(UserContext me, String searchText, String searchType, String searchWsId, int start, int pageLimit) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.searchData(me, searchText, searchType, searchWsId, start, pageLimit); + } + + /** + * 打开流程地图主页 + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_processmap_page") + public String openProcessMapPage(UserContext me, String wsId, String orgId, String type) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.openProcessMapPage(me, wsId, orgId, type); + } + + /** + * 业务架构 + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_ws_page") + public String openProcessMapWsPage(UserContext me, String wsId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.openProcessMapWsPage(me, wsId); + } + + /** + * 组织架构 + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_org_page") + public String openProcessMapOrgPage(UserContext me, String orgId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.openProcessMapOrgPage(me, orgId); + } + + /** + * 业务架构展开 + * @param me + * @param id + * @param wsId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_processmap_ws_expand") + public String expendProcessMapWsData(UserContext me, String id, String wsId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.expendProcessMapWsData(me, id, wsId); + } + + /** + * 校验是否可打开 + * @param me + * @param id + * @param wsId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_processmap_ws_check_open") + public String openProcessMapWsDataCheck(UserContext me, String id, String wsId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.openProcessMapWsDataCheck(me, id, wsId); + } + + /** + * 组织架构展开 + * @param me + * @param id + * @param orgId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_processmap_org_expand") + public String expendProcessMapOrgData(UserContext me, String id, String orgId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.expendProcessMapOrgData(me, id, orgId); + } + + /** + * 组织架构中查询部门下的流程 + * @param me + * @param deptId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_processmap_org_dept_dialog_page") + public String openProcessMapOrgDeptDialog(UserContext me, String deptId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.openProcessMapOrgDeptDialog(me, deptId); + } + + /********************永辉接口start*************************/ + + /** + * 导航条-搜索 + * 获取所有已发布的文件 + * @param me + * @param wsId + * @param type all:所有当前正在使用状态中的模型,包括发布和停用 publish:已发布模型 + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_search_data_json") + public String queryPublishRepositoryDataJson(UserContext me, String wsId, String type) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryPublishRepositoryDataJson(me, wsId, null, type); + } + + /** + * 获取所有有权限的资产库 + * @param me + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_ws_data_json") + public String queryPermWorkspaceDataJson(UserContext me) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryPermWorkspaceDataJson(me); + } + + /** + * 获取发布动态 + * @param me + * @param wsId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_dynamic_history_data_json") + public String queryDynamicHistoryDataJson(UserContext me, String wsId, String type) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryDynamicHistoryDataJson(me, wsId, type); + } + + /** + * 获取发布动态(更多) + * @param me + * @param wsId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_dynamic_history_more_data_json") + public String queryDynamicHistoryMoreDataJson(UserContext me, String wsId, String type) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryDynamicHistoryMoreDataJson(me, wsId, type); + } + + /** + * 根据类别获取权限下已发布的流程列表 + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_process_by_type_data_json") + public String queryPublishRepositoryDataJsonByType(UserContext me, String type, String wsId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryPublishRepositoryDataJsonByType(me, type, wsId); + } + + /** + * 获取所有有权限的部门列表,部门列表来源于所有具有权限的流程的责任部门 + * @param me + * @param wsId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_aws_department_data_json") + public String queryAwsDepartmentDataJson(UserContext me, String wsId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryAwsDepartmentDataJson(me, wsId); + } + + /** + * 获取当前部门的流程数据(责任部门)和当前部门下具有权限的子部门列表 + * @param me + * @param wsId + * @param departmentId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_process_by_department_data_json") + public String queryPublishedProcessAndSubDepartment(UserContext me, String wsId, String departmentId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryPublishedProcessAndSubDepartment(me, wsId, departmentId); + } + + /** + * 获取子流程列表 + * @param me + * @param uuid 流程ID + * @param type all:所有当前正在使用状态中的模型,包括发布和停用 publish:已发布模型 + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_process_by_parent_data_json") + public String queryPublishProcessByParent(UserContext me, String uuid, String type) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryPublishProcessByParent(me, uuid, type); + } + + /** + * 点击流程名称打开流程 + * 获取流程详情页面 + * @param me + * @param uuid + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_process_open") + public String openPublishRepository(UserContext me, String uuid, String type) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.openPublishRepository(me, uuid, type); + } + + /** + * 获取二级或三级流程 + * @param me + * @param wsId + * @param level 默认三级,可选值(2,3),参数值不正确也默认三级 + * @param type all:所有当前正在使用状态中的模型,包括发布和停用 publish:已发布模型 + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_second_level_data_json") + public String querySecendLevelRepositoryDataJson(UserContext me, String wsId, String level, String type) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + String rtnStr = ""; + if("2".equals(level)) { + rtnStr = web.querySecondLevelRepositoryDataJson(me, wsId, type); + } else { + rtnStr = web.queryThirdLevelRepositoryDataJson(me, wsId, type); + } + return rtnStr; + } + + /** + * 获取已加入的群组 + * @param me + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_user_joined_team_data_json") + public String queryJoinedTeamByUserId(UserContext me) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryJoinedTeamByUserId(me); + } + + /** + * 获取未加入群组(私密小组除外) + * @param me + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_user_not_join_team_data_json") + public String queryNotJoinTeamByUserId(UserContext me ) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.queryNotJoinTeamByUserId(me); + } + + /** + * 组织架构中查询部门下的流程(返回json) + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_processmap_org_dept_data") + public String openProcessMapOrgDeptData(UserContext me, String wsId, String deptId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.openProcessMapOrgDeptData(me, wsId, deptId); + } + + /** + * 依据流程库Id获取该流程库主题风格的轮播图资源 + * @param me + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_banner_carousel") + public String bannerCarouselData(UserContext me, String wsId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.bannerCarouselData(me); + } + /********************永辉接口end*************************/ + + /** + * 我参与的流程查询 + * @param me + * @param count + * @return + */ + @Mapping("com.actionsoft.apps.publisher_xpages_participant_msg") + public String participantDataQuery(UserContext me, String count) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.participantDataQuery(me, count); + } + + /** + * 我负责的流程查询 + * @param me + * @param count + * @return + */ + @Mapping("com.actionsoft.apps.publisher_xpages_responsible_msg") + public String responsibleDataQuery(UserContext me, String count) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.responsibleDataQuery(me, count); + } + + /** + * 岗位职责模块查询 + * @param me + * @param count + * @return + */ + @Mapping("com.actionsoft.apps.publisher_xpages_postresponsibility_msg") + public String postresponsibilityDataQuery(UserContext me, String count) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.postresponsibilityDataQuery(me, count); + } + + /** + * RCAI模块查询 + * @param me + * @param count + * @return + */ + @Mapping("com.actionsoft.apps.publisher_xpages_rcaimatrix_msg") + public String rcaimatrixDataQuery(UserContext me, String count) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.rcaimatrixDataQuery(me, count); + } + + + /** + * 流程地图默认资产库和默认组织设置 + * @return + */ + @Mapping("com.actionsoft.apps.publisher_workspace_and_org_msg") + public String getCoeWorkSpaceAndOrgInfo(UserContext me) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.getCoeWorkSpaceAndOrgInfo(); + } +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/PublisherController.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/PublisherController.java new file mode 100644 index 00000000..58784986 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/PublisherController.java @@ -0,0 +1,641 @@ +package com.actionsoft.apps.coe.pal.publisher; + +import java.util.HashMap; + +import com.actionsoft.apps.AppsConst; +import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; +import com.actionsoft.apps.coe.pal.publisher.client.web.ProcessPublishClientWeb; +import com.actionsoft.apps.coe.pal.publisher.client.web.ProcessPublishWeb; +import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate; +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.commons.session.constant.SessionConst; +import com.actionsoft.bpms.commons.session.model.SessionModel; +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.bpms.server.conf.server.AWSServerConf; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.PortalAPI; + +@Controller +public class PublisherController { + + //流程发布-首页 + @Mapping("com.actionsoft.apps.coe.pal.publisher_home") + public String publisherHome(UserContext me, String teamId, String wsid) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.processPublishNewPage(teamId, wsid); + } + + //流程发布-代办任务列表 + @Mapping("com.actionsoft.apps.coe.pal.publisher_tasklist") + public String getTaskInstanceList(UserContext me, String start, String size){ + ProcessPublishWeb web = new ProcessPublishWeb(me); + int startNum = 0; + if (start != null) { + startNum = Integer.parseInt(start); + } else { + return null; + } + int sizeNum = 0; + if (size != null) { + sizeNum = Integer.parseInt(size); + } else { + return null; + } + return web.getTaskInstanceList(startNum, sizeNum); + } + + /** + * 新版待办列表 + * + * @param me + * @param start + * @param size + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_new_taskList_handle") + public String getNewTaskInstanceList(UserContext me, int start, int size, String search) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getNewTaskInstanceList(start, size, search); + } + + /** + * 新版待阅列表 + * + * @param me + * @param start + * @param size + * @param search + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_new_taskList_read") + public String getNewTaskInstanceListForRead(UserContext me, int start, int size, String search) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getNewTaskInstanceListForRead(start, size, search); + } + + //流程发布-已办任务列表 + @Mapping("com.actionsoft.apps.coe.pal.publisher_historytasklist") + public String getHistoryTaskInstanceList(UserContext me, String start, String size){ + ProcessPublishWeb web = new ProcessPublishWeb(me); + int startNum = 0; + if (start != null) { + startNum = Integer.parseInt(start); + } else { + return null; + } + int sizeNum = 0; + if (size != null) { + sizeNum = Integer.parseInt(size); + } else { + return null; + } + + return web.getHistoryTaskInstanceList(startNum, sizeNum); + } + + /** + * 新版已办列表 + * + * @param me + * @param start + * @param size + * @param search + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_new_historyTaskList_handled") + public String getNewHistoryTaskInstanceList(UserContext me, int start, int size, String search) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getNewHistoryTaskInstanceList(start, size, search); + } + + /** + * 新版已阅列表 + * + * @param me + * @param start + * @param size + * @param search + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_new_historyTaskList_read") + public String getNewHistoryTaskInstanceListForRead(UserContext me, int start, int size, String search) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getNewHistoryTaskInstanceListForRead(start, size, search); + } + + //流程发布-历史任务列表 + @Mapping("com.actionsoft.apps.coe.pal.publisher_processlist") + public String getProcessInstanceList(UserContext me, String start, String size){ + ProcessPublishWeb web = new ProcessPublishWeb(me); + int pageNum = 0; + if (start != null) { + pageNum = Integer.parseInt(start); + } else { + return null; + } + int sizeNum = 0; + if (size != null) { + sizeNum = Integer.parseInt(size); + } else { + return null; + } + + return web.getProcessInstanceList(pageNum, sizeNum); + } + + //流程发布-得到新的历史任务列表页面 + @Mapping("com.actionsoft.apps.coe.pal.publisher_processlist_page") + public String getNewProcessInstanceListPage(UserContext me) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getNewProcessInstanceListPage(me); + } + + //流程发布-得到新的历史任务列表数据 + @Mapping("com.actionsoft.apps.coe.pal.publisher_processlist_new") + public String getNewProcessInstanceList(UserContext me, int start, int size, String search) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getNewProcessInstanceList(start, size, search); + } + + //流程发布-催办发送消息处理 + @Mapping("com.actionsoft.apps.coe.pal.publisher_urge") + public String sendMessageUrge(UserContext me, String processInstId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.sendMessageUrge(me, processInstId); + } + + //流程发布-新增流程实例 + @Mapping("com.actionsoft.apps.coe.pal.publisher_save") + public String savePublishInstance(UserContext me, String title, String teamId, String teamName, String wsId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.savePublishInstance(title, teamId, teamName, wsId); + } + + //流程发布-流程办理页面 + @Mapping("com.actionsoft.apps.coe.pal.publisher_handle") + public String toPublishInstanceHandle(UserContext me, String processInstId, String taskInstId, String openState){ + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.toPublishInstanceHandle(processInstId, taskInstId, openState); + } + + //流程发布-删除流程实例 + @Mapping("com.actionsoft.apps.coe.pal.publisher_remove") + public String removeProcessInstance(UserContext me, String processInstIds) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.removeProcessInstance(processInstIds); + } + + //流程发布-流程办理获取未发布流程 + @Mapping("com.actionsoft.apps.coe.pal.publisher_handle_notpublished") + public String getNotPublishedRepositorys(UserContext me, String teamId, String wsId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getNotPublishedRepositorys(teamId, wsId); + } + + //流程发布-流程办理获取已发布流程未发布版本 + @Mapping("com.actionsoft.apps.coe.pal.publisher_handle_notpublishedversion") + public String getNotPublishedVersionRepositorys(UserContext me, String teamId, String wsId, String resourceId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getNotPublishedVersionRepositorys(teamId, wsId, resourceId); + } + + //流程发布-流程办理获取已发布流程未发布版本 + @Mapping("com.actionsoft.apps.coe.pal.publisher_handle_published") + public String getPublishedRepositorys(UserContext me, String teamId, String wsId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getPublishedRepositorys(teamId, wsId); + } + + //流程发布客户端-首页(整合版) + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_home") + public String publishClientHome(UserContext me) { +// ProcessPublishWeb web = new ProcessPublishWeb(me); +// return web.getClientHome(); + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.getHomePage(me); + } + + //流程发布客户端-流程树数据 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_treedata") + public String getTreeData(UserContext me, String roleId, String wsId, String wsName) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getTreeData(roleId, wsId, wsName); + } + + //流程发布客户端-流程发布历史 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_history") + public String getPublishHistoryList(UserContext me, String wsId, String repositoryId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getPublishHistoryList(repositoryId, wsId); + } + + //流程发布客户端-主页面 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_main") + public String publishClientMain(UserContext me) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getClientMain(); + } + + //流程发布客户端-主页面-发布历史 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_main_more") + public String getMorePublishHistory(UserContext me, String time) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getMorePublishHistory(time); + } + + + //流程发布客户端-搜索已发布的流程文件 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_search") + public String searchPublishPALRepository(UserContext me, String name) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.searchPublishPALRepository(name); + } + + //流程发布客户端-更新浏览次数 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_update_viewcount") + public String updateViewCount(UserContext me, String repositoryId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.updateViewCount(repositoryId); + } + + //流程发布客户端-index页(集成版) + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso") + public String publishClientHomeSSO(UserContext me) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.getHomePage(me); + } + + //流程发布客户端-首页(集成版) + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_main") + public String publishClientMainSSO(UserContext me, String wsId) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.getClientMain(wsId); + } + + //流程发布客户端-首页-查询 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_search") + public String publishClientMainSSOSearch(UserContext me, String palIds, String filter, String order, String name) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.searchInClientMain(palIds, filter, order, name); + } + + //获取登录coe的session + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_coe") + public String getCoESesstionId(UserContext me) { + ResponseObject response = ResponseObject.newOkResponse(); + + String uid = me.getUID(); + SessionModel sessionModel = null; + if (SessionConst.SESSION_STATUS_OK == me.validateSession()) { + SessionImpl mySession = new SessionImpl(AWSServerConf.getMainServerSessionIdleTime()); + sessionModel = mySession.registerSession(LoginConst.SYSTEM_COE, uid, me.getClientIP(), me.getLanguage(), me.getDeviceType(), true, null); + } + response.put("sid", sessionModel.getSessionId()); + return response.toString(); + } + + //退出 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_logout") + public String logout(UserContext me) { + String sid = me.getSessionId(); + PortalAPI portalApi = SDK.getPortalAPI(); + portalApi.closeSession(sid); + return HtmlPageTemplate.merge(AppsConst.SYS_APP_PORTAL, "client.user.sys.logout.htm", new HashMap()); + } + + //修改密码 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_pwd") + public String modifyPassword(UserContext me, String oldPassword, String password) { + PortalAPI portalApi = SDK.getPortalAPI(); + // 返回由ResponseObject生成的JSON串,result=ok修改成功,否则检查msg(如不允许修改口令、口令不合法) + return portalApi.changePasswd(me, oldPassword, password); + } + + //参数设置 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_setting_data") + public String getSettingParams(UserContext me) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.getSettingData(); + } + + //参数设置 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_setting") + public String setting(UserContext me, String title, String fotter, String isComment, String isPrint, String isViewAttribute, String isViewHistory) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.setting(title, fotter, isComment, isPrint, isViewAttribute, isViewHistory); + } + + //发布历史 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_publish_list") + public String getPublishList(UserContext me, String start, String type) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.getPublishList(start, type); + } + + //获取所有组织模型的资产库数据 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_org_ws_treedata") + public String getOrgWsTreeData(UserContext me) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.getOrgWsTreeData(); + } + + //标准化体系页面 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_org_relation_page") + public String toOrgRelationPage(UserContext me) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.toOrgRelationPage(); + } + + //组织模型关联页面(标准化体系页面) + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_org_relation_main_page") + public String toOrgRelationMainPage(UserContext me) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.toOrgRelationModelPage(); + } + + //组织模型关联数据 + @Mapping("com.actionsoft.apps.coe.pal.publisher_client_sso_org_relation_data") + public String getOrgRelativeModel(UserContext me, String orgModelId, String modelIds) { + ProcessPublishClientWeb web = new ProcessPublishClientWeb(me); + return web.getOrgRelativeModel(orgModelId, modelIds); + } + //生成流程手册 + @Mapping("com.actionsoft.apps.coe.pal.publisher_openProcess") + public String openProcess(UserContext me,String wsId,String fileId,String teamId,String processInstId,String type) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.openProcess(me,wsId,fileId,teamId,processInstId,type); + } + //保存子表 + @Mapping("com.actionsoft.apps.coe.pal.publisher_savebefore") + public String savebefore(UserContext me,String ProFile_N,String ProFile_NId,String processInstId, String ProFile_c,String ProFile_CId,String ChangeDFileNameNew,String AfterChange_CId,String ProFile_s,String ProFile_SId,String PublishDesc,String StopDesc,String ChangeDesc,String N_taskId,String C_taskId,String S_taskId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.savebefore(ProFile_N, ProFile_NId,processInstId,ProFile_c,ProFile_CId,ChangeDFileNameNew,AfterChange_CId,ProFile_s,ProFile_SId,PublishDesc,StopDesc,ChangeDesc,N_taskId,C_taskId,S_taskId); + } + //查询 + @Mapping("com.actionsoft.apps.coe.pal.publisher_selectcns") + public String selectcns(UserContext me,String processInstId){ + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.selectcns(processInstId); + } + //预览流程手册 + @Mapping("com.actionsoft.apps.coe.pal.publisher_ReportPreview") + public String ReportPreview(UserContext me,String processInstId,String type) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.ReportPreview(me, processInstId,type); + } + //快速查询 + @Mapping("com.actionsoft.apps.coe.pal.publisher_tree_query") + public String treeQuery(UserContext me,String wsId,String scope,String queryType,String autoContent) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.treeQuery(me,wsId,scope,queryType,autoContent); + } + + /** + * 获取字表数据 + * @param me + * @param processInstId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_data_query") + public String getPublisherData (UserContext me, String processInstId, String wsId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getPublisherData(processInstId, wsId); + } + + /** + * 是否开启三员管理 + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_high_security_mode_query") + public String querySecutiryMode(){ + ResponseObject ro = ResponseObject.newOkResponse(); + boolean mode = PALRepositoryQueryAPIManager.getInstance().isSecurityMode(); + ro.put("isHighSecurity",mode); + return ro.toString(); + } + + /** + * 打开流程详情页面 + * @param me + * @param uuid + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_publish_file_open") + public String openPublishFilePage(UserContext me, String uuid, String taskId) { + return PALRepositoryQueryAPIManager.getInstance().getPublishPortalHtml(me, uuid, taskId, false); + } + + /** + * 预览流程手册 + * @param me + * @param taskId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_publish_output_file_open") + public String openPublishOutputFile(UserContext me, String taskId) { + String ro = PALRepositoryQueryAPIManager.getInstance().outputReportPreview(me, taskId); + return ro; + } + + /** + * 查询发布数据的树结构 + * @param me + * @param type new change stop 三种类型查询不同的树结构 + * @param wsId + * @param teamId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_publish_tree_data_query") + public String queryPublishTreeData(UserContext me, String type, String wsId, String teamId, boolean flag, String pid) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.queryPublishTreeData(type, wsId, teamId, flag, pid); + } + + /** + * 快速查询定位到需要的发布流程 + * + * @param me + * @param wsId + * @param teamId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_publish_tree_data_query_search") + public String queryPublishTreeSearchByName(UserContext me, String wsId, String teamId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getTreeDataForSearchByName(wsId, teamId); + } + + /** + * 创建流程手册 + * @param me + * @param uuid + * @param teamId + * @param wsId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_output_pr_report_create") + public String createOutputPrReport(UserContext me, String uuid, String teamId, String wsId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.createOutputPrReport(uuid, wsId, teamId); + } + + /** + * 查询流程的未发布版本 + * @param me + * @param uuid + * @param teamId + * @param wsId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_not_publish_version_query") + public String queryNotPublishVersion(UserContext me, String uuid, String teamId, String wsId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.queryNotPublishVersion(uuid, wsId, teamId); + } + + /** + * 查询流程的流程手册ID + * @param me + * @param uuid + * @param teamId + * @param wsId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_output_pr_report_query") + public String queryOutputReport(UserContext me, String uuid, String teamId, String wsId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.queryOutputReport(uuid, wsId, teamId); + } + + /** + * 表单保存/办理之前执行 + * @param me + * @param data + * @param teamId + * @param wsId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_save_before") + public String saveFormPublishSubData(UserContext me, String data, String teamId, String wsId, String processInstId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.saveFormPublishSubData(data, teamId, wsId, processInstId); + } + + /** + * 查询流程发布表数据(批量) + * @param me + * @param processInstId + * @param wsId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_batch_data_query") + public String getPublishBatchData(UserContext me, String processInstId, String wsId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.getPublisherBatchData(processInstId, wsId); + } + + /** + * 批量创建流程手册 + * @param me + * @param uuids + * @param teamId + * @param wsId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_output_pr_reports_create") + public String createOutputPrReports(UserContext me, String uuids, String teamId, String wsId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.createOutputPrReports(wsId, teamId, uuids); + } + + /** + * 查询流程的其他版本并默认查询结果的第一条创建流程手册 + * @param me + * @param data + * @param teamId + * @param wsId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_versions_query_output_pr_reports_create") + public String queryVersionsAndCreateOputputPrReports(UserContext me, String data, String teamId, String wsId, String createTime) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.queryVersionsAndCreateOputputPrReports(wsId, teamId, data, createTime); + } + + /** + * 批量查询流程的流程手册ID + * @param me + * @param uuids + * @param teamId + * @param wsId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_batch_output_pr_report_query") + public String queryBatchOutputReport(UserContext me, String uuids, String teamId, String wsId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.queryBatchOutputReport(uuids, wsId, teamId); + } + + /** + * 子表数据批量保存 + * @param me + * @param wsId + * @param teamId + * @param processInstId + * @param type + * @param data + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_batch_save") + public String saveBatchData(UserContext me, String wsId, String teamId, String processInstId, String type, String data) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.saveBatchData(wsId, teamId, processInstId, type, data); + } + + /** + * 表单保存/办理前执行(批量) + * @param me + * @param wsId + * @param teamId + * @param processInstId + * @param newData + * @param changeData + * @param stopData + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_batch_save_before") + public String saveFormBatchPubishData(UserContext me, String wsId, String teamId, String processInstId, String newData, String changeData, String stopData, boolean isTransact) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.saveFormBatchPubishData(wsId, teamId, processInstId, newData, changeData, stopData, isTransact); + } + + /** + * 校验文件类型是否可打开 + * @param me + * @param uuid + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_publish_repository_method_check") + public String checkPublishRepositoryMethod(UserContext me, String uuid) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.checkPublishRepositoryMethod(uuid); + } + + /** + * 查询流程实例bo表状态字段 + * @param me + * @param processInstId + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.publisher_save_status_query") + public String querySaveStatus(UserContext me, String processInstId) { + ProcessPublishWeb web = new ProcessPublishWeb(me); + return web.querySaveStatus(processInstId); + } + +} + diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/ReciveTeamDeleted.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/ReciveTeamDeleted.java new file mode 100644 index 00000000..e3063760 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/ReciveTeamDeleted.java @@ -0,0 +1,15 @@ +package com.actionsoft.apps.coe.pal.publisher; + +public class ReciveTeamDeleted { + + /** + * 接收小组被删除的通知(此时小组已被删除),补偿扩展App的操作,如删除垃圾配置 + * + * @param teamId 小组Id + */ + public void execute(String teamId) { + //System.out.println("黄河收到,工作网络的一个小组[" + teamId + "]被删除了!"); + // 删除该小组产生的发布申请记录及相关 + } + +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/dao/PublisherClientDao.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/dao/PublisherClientDao.java new file mode 100644 index 00000000..e3d902d3 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/dao/PublisherClientDao.java @@ -0,0 +1,340 @@ +package com.actionsoft.apps.coe.pal.publisher.client.dao; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl; +import com.actionsoft.apps.coe.pal.publisher.constant.PublisherConstant; +import com.actionsoft.apps.coe.pal.system.util.StringUtil; +import com.actionsoft.bpms.commons.database.RowMapper; +import com.actionsoft.bpms.server.conf.server.AWSServerConf; +import com.actionsoft.bpms.util.DBSql; +public class PublisherClientDao { + + /** + * 获取模型关联的模型Id + * + * @param id + * @return + * @author zhangming + */ + public List> getFileIdsByRelationFileId(String id) { + String sql = "SELECT DISTINCT(r.FILEID), pal.PLNAME, MODIFYDATE FROM APP_ACT_COE_PAL_SHAPE_RLAT r, APP_ACT_COE_PAL_REPOSITORY pal WHERE r.RELATIONFILEID in (" + id + ") AND r.FILEID = pal.ID AND pal.PLCATEGORY='process' ORDER BY MODIFYDATE DESC"; + List> list = DBSql.query(sql, new RowMapper>() { + @Override + public Map mapRow(ResultSet rs, int arg1) throws SQLException { + Map map = new HashMap(); + map.put("id", rs.getString(1)); + map.put("name", rs.getString(2)); + return map; + } + }); + return list; + } + + /** + * 获取模型关联的模型Id(只有文件属性关联) + * + * @param id + * @return + * @author zhangming + */ + public List> getFileIdsByRelationFileId1(String id) { + String sql = "SELECT DISTINCT(r.FILEID), pal.PLNAME, MODIFYDATE FROM APP_ACT_COE_PAL_SHAPE_RLAT r, APP_ACT_COE_PAL_REPOSITORY pal WHERE r.RELATIONFILEID in (" + id + ") AND r.FILEID = pal.ID AND r.SHAPEID='' AND pal.PLCATEGORY='process' ORDER BY MODIFYDATE DESC"; + List> list = DBSql.query(sql, new RowMapper>() { + @Override + public Map mapRow(ResultSet rs, int arg1) throws SQLException { + Map map = new HashMap(); + map.put("id", rs.getString(1)); + map.put("name", rs.getString(2)); + return map; + } + }); + return list; + } + + /** + * 获取管理标准、技术标准和工作标准的Id + * + * @return + * @author zhangming + */ + public Map getControlPolicyId(String wsId) { + Map resultMap = new HashMap(); + String sql = "SELECT ID, PLNAME FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME IN (?,?,?) AND WSID=? AND PLMETHODID='control.policy'"; + List> listMap = DBSql.query(sql, new RowMapper>() { + @Override + public Map mapRow(ResultSet rs, int arg1) throws SQLException { + Map map = new HashMap(); + map.put(rs.getString(2), rs.getString(1)); + return map; + } + }, new Object[]{PublisherConstant.ORG_RELATION_MANAGEMENT_STANDARD, PublisherConstant.ORG_RELATION_TECHNICAL_STANDARD, PublisherConstant.ORG_RELATION_WORK_STANDARD, wsId}); + for (Map map : listMap) { + Set set = map.keySet(); + for (String key : set) { + resultMap.put(key, map.get(key)); + } + } + return resultMap; + } + + + /** + * 获取某个范围内的关联模型Id + * + * @param relationFileIds + * @return + * @author zhangming + */ + public List> getFileIdsByRelation(String relationFileIds) { + if (relationFileIds == null || "".equals(relationFileIds)) { + return new ArrayList>(); + } + String sql = "SELECT pal.ID, pal.PLNAME, p.PUBLISHDATE FROM APP_ACT_COE_PAL_REPOSITORY pal, (" + + " SELECT r.FILEID, MAX(p.PUBLISHDATE) PUBLISHDATE" + + " FROM APP_ACT_COE_PAL_SHAPE_RLAT r, APP_ACT_COE_PAL_PUBLISH p, APP_ACT_COE_PAL_PUBLISH_LIST pl" + + " WHERE r.FILEID = pl.PALREPOSITORYID AND r.RELATIONFILEID IN (" + relationFileIds + ") AND p.ID=pl.PID AND pl.ACTIONTYPE='N'" + + " GROUP BY r.FILEID) p" + + " WHERE pal.ID = p.FILEID and pal.ISPUBLISH=1" + + " ORDER BY p.PUBLISHDATE DESC"; + List> list = DBSql.query(sql, new RowMapper>() { + @Override + public Map mapRow(ResultSet rs, int arg1) throws SQLException { + Map map = new HashMap(); + if (rs.getString(1) == null) { + return null; + } + map.put("id", rs.getString(1)); + map.put("name", rs.getString(2)); + Timestamp publishDate = rs.getTimestamp(3); + DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + map.put("publishDate", sdf.format(publishDate)); + return map; + } + }); + return list; + } + + /** + * 获取某个范围内的关联模型Id(只有文件属性关联) + * + * @param relationFileIds + * @return + * @author zhangming + */ + public List> getFileIdsByRelation1(String relationFileIds) { + if (relationFileIds == null || "".equals(relationFileIds)) { + return new ArrayList>(); + } + String sql = "SELECT pal.ID, pal.PLNAME, p.PUBLISHDATE FROM APP_ACT_COE_PAL_REPOSITORY pal, (" + + " SELECT r.FILEID, MAX(p.PUBLISHDATE) PUBLISHDATE" + + " FROM APP_ACT_COE_PAL_SHAPE_RLAT r, APP_ACT_COE_PAL_PUBLISH p, APP_ACT_COE_PAL_PUBLISH_LIST pl" + + " WHERE r.FILEID = pl.PALREPOSITORYID AND r.RELATIONFILEID IN (" + relationFileIds + ") AND r.SHAPEID='' AND p.ID=pl.PID AND pl.ACTIONTYPE='N'" + + " GROUP BY r.FILEID) p" + + " WHERE pal.ID = p.FILEID and pal.ISPUBLISH=1" + + " ORDER BY p.PUBLISHDATE DESC"; + List> list = DBSql.query(sql, new RowMapper>() { + @Override + public Map mapRow(ResultSet rs, int arg1) throws SQLException { + Map map = new HashMap(); + if (rs.getString(1) == null) { + return null; + } + map.put("id", rs.getString(1)); + map.put("name", rs.getString(2)); + Timestamp publishDate = rs.getTimestamp(3); + DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + map.put("publishDate", sdf.format(publishDate)); + return map; + } + }); + return list; + } + + /** + * 获取某个范围内的被关联模型Id + * + * @param fileIds + * @param relationFileIds + * @return + * @author zhangming + */ + public List> getRelationFileIds(String fileIds, String relationFileIds) { + if (fileIds == null || "".equals(fileIds) || relationFileIds == null || "".equals(relationFileIds)) { + return new ArrayList>(); + } + String sql = "SELECT pal.ID, pal.PLNAME, p.PUBLISHDATE from APP_ACT_COE_PAL_REPOSITORY pal, (" + + " SELECT r.RELATIONFILEID, MAX(p.PUBLISHDATE) PUBLISHDATE" + + " FROM APP_ACT_COE_PAL_SHAPE_RLAT r, APP_ACT_COE_PAL_PUBLISH p, APP_ACT_COE_PAL_PUBLISH_LIST pl" + + " WHERE r.RELATIONFILEID = pl.PALREPOSITORYID AND r.FILEID IN (" + fileIds + ") AND r.RELATIONFILEID IN (" + relationFileIds + ") AND p.ID=pl.PID AND pl.ACTIONTYPE='N'" + + " GROUP BY r.RELATIONFILEID) p" + + " WHERE pal.ID=p.RELATIONFILEID and pal.ISPUBLISH=1" + + " ORDER BY p.PUBLISHDATE DESC"; + List> list = DBSql.query(sql, new RowMapper>() { + @Override + public Map mapRow(ResultSet rs, int arg1) throws SQLException { + Map map = new HashMap(); + if (rs.getString(1) == null) { + return null; + } + map.put("id", rs.getString(1)); + map.put("name", rs.getString(2)); + Timestamp publishDate = rs.getTimestamp(3); + DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + map.put("publishDate", sdf.format(publishDate)); + return map; + } + }); + return list; + } + + /** + * 发布历史 + * + * @param ids + * @return + * @author zhangming + */ + public List> getPublishListData(String ids, String category, String wsId, String methodId) { + if (ids == null || "".equals(ids)) { + return new ArrayList>(); + } + String sql = "SELECT r.ID, r.PLNAME, p.PUBLISHDATE from APP_ACT_COE_PAL_REPOSITORY r, (" + + " SELECT pl.PALREPOSITORYID, MAX(p.PUBLISHDATE) publishdate " + + " FROM APP_ACT_COE_PAL_PUBLISH p, APP_ACT_COE_PAL_PUBLISH_LIST pl" + + " WHERE p.ID=pl.PID AND pl.PALREPOSITORYID IN (" + ids + ")" + + " GROUP BY pl.PALREPOSITORYID ) p" + + " WHERE r.ID = p.PALREPOSITORYID AND r.PLCATEGORY='" + category + "' AND r.PLMETHODID <> 'default' AND r.WSID='" + wsId + "'"; + if (methodId != null && !"".equals(methodId)) { + sql += " AND r.PLMETHODID='" + methodId + "'"; + } + sql += " ORDER BY p.PUBLISHDATE DESC"; + List> list = DBSql.query(sql, new RowMapper>() { + @Override + public Map mapRow(ResultSet rs, int arg1) throws SQLException { + Map map = new HashMap(); + if (rs.getString(1) == null) { + return null; + } + map.put("id", rs.getString(1)); + map.put("name", rs.getString(2)); + Timestamp publishDate = rs.getTimestamp(3); + DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + map.put("publishDate", sdf.format(publishDate)); + return map; + } + }); + return list; + } + /** + * 根据name获取未发布的流程文件 + * @param name + * @param wsId + * @param methodId + * @return + */ + public List getCoeProcessLevelByNamen(String name, String wsId, String methodId) { + String namelike = ""; + if (StringUtil.containSpecialChar(name)) { + namelike = "'%" + StringUtil.replaceSqlStr(name, AWSServerConf.isMySQL()) + "%'" + (AWSServerConf.isMySQL() ? "ESCAPE '\\\\'" : " ESCAPE '\\'"); + } else { + namelike = "'%" + name + "%'"; + } + StringBuilder sql = new StringBuilder("select * from " + PALRepositoryModelImpl.DATABASE_ENTITY + " where " + PALRepositoryModelImpl.FIELD_WS_ID + "='" + wsId + "' and " + PALRepositoryModelImpl.FIELD_PL_NAME + " like " + namelike + " and ISPUBLISH = '0'"); + if (methodId != null && !"".equals(methodId)) { + sql.append(" and PLMETHODID = '" + methodId + "' "); + } + sql.append(" ORDER BY " + PALRepositoryModelImpl.FIELD_PL_ORDERINDEX + " ASC"); + return DBSql.query(sql.toString(), new PALRespositoryModelMapper()); + } + /** + * 根据name获取有多个版本的流程文件 + * @param name + * @param wsId + * @param methodId + * @return + */ + public List getCoeProcessLevelByNamec(String name, String wsId, String methodId) { + String namelike = ""; + if (StringUtil.containSpecialChar(name)) { + namelike = "'%" + StringUtil.replaceSqlStr(name, AWSServerConf.isMySQL()) + "%'" + (AWSServerConf.isMySQL() ? "ESCAPE '\\\\'" : " ESCAPE '\\'"); + } else { + namelike = "'%" + name + "%'"; + } + StringBuilder sql = new StringBuilder("select * from " + PALRepositoryModelImpl.DATABASE_ENTITY + " where " + PALRepositoryModelImpl.FIELD_WS_ID + "='" + wsId + "' and " + PALRepositoryModelImpl.FIELD_PL_NAME + " like " + namelike + " and ISPUBLISH = '1'"); + String sqlcount = "select count(*) from " + PALRepositoryModelImpl.DATABASE_ENTITY + " where " + PALRepositoryModelImpl.FIELD_WS_ID + "='" + wsId + "' and " + PALRepositoryModelImpl.FIELD_PL_NAME + " like " + namelike + ""; + + if (methodId != null && !"".equals(methodId)) { + sql.append(" and PLMETHODID = '" + methodId + "' "); + } + sql.append(" ORDER BY " + PALRepositoryModelImpl.FIELD_PL_ORDERINDEX + " ASC"); + sqlcount+=" ORDER BY " + PALRepositoryModelImpl.FIELD_PL_ORDERINDEX + " ASC"; + String num = DBSql.getString(sqlcount); + int number = Integer.parseInt(num); + if(number <= 1) { + List data = null; + return data; + } + return DBSql.query(sql.toString(), new PALRespositoryModelMapper()); + } + /** + * 根据name获取停用的流程文件 + * @param name + * @param wsId + * @param category + * @return + */ + public List getCoeProcessLevelByNameAndCategorys(String name, String wsId, String category) { + + String namelike = ""; + + if (StringUtil.containSpecialChar(name)) { + namelike = "'%" + StringUtil.replaceSqlStr(name, AWSServerConf.isMySQL()) + "%'" + (AWSServerConf.isMySQL() ? "ESCAPE '\\\\'" : " ESCAPE '\\'"); + } else { + namelike = "'%" + name + "%'"; + } + StringBuilder sql = new StringBuilder("select * from " + PALRepositoryModelImpl.DATABASE_ENTITY + " where " + PALRepositoryModelImpl.FIELD_WS_ID + "='" + wsId + "' and " + PALRepositoryModelImpl.FIELD_PL_NAME + " like " + namelike + " and " + PALRepositoryModelImpl.FIELD_IS_USE + "='1' and ISPUBLISH = '1'"); + + if (category != null && !"".equals(category)) { + sql.append(" and PLCATEGORY = '" + category + "' "); + } + sql.append(" ORDER BY " + PALRepositoryModelImpl.FIELD_PL_ORDERINDEX + " ASC"); + return DBSql.query(sql.toString(), new PALRespositoryModelMapper()); + } + private class PALRespositoryModelMapper implements RowMapper { + PALRepository pal = new PALRepository(); + public PALRepositoryModel mapRow(ResultSet rs, int arg1) throws SQLException { + return (PALRepositoryModel) pal.record2Model(rs); + } + } + /** + * 根据userId获取资源Id列表 + * @param userId + * @return + */ + public List getTeamUserPerms(String userId) { + String sql = " select distinct perm.RESOURCEID from APP_ACT_NETWORK_TEAM_MEMBER tm , APP_ACT_COE_TEAM_PERM perm " + + "where tm.TEAMID=perm.TEAMID and tm.MEMBERSTATUS='1' and tm.USERID=? "; + List resourceIdList = DBSql.query(sql.toString(), new RowMapper() { + @Override + public String mapRow(ResultSet rs, int arg1) throws SQLException { + return rs.getString(1); + } + }, new Object[] { userId }); + if(resourceIdList == null) { + resourceIdList = new ArrayList(); + } + return resourceIdList; + } + +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/dto/ProcessPublishDTO.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/dto/ProcessPublishDTO.java new file mode 100644 index 00000000..d61210f6 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/dto/ProcessPublishDTO.java @@ -0,0 +1,106 @@ +package com.actionsoft.apps.coe.pal.publisher.client.dto; + +/** + * 流程发布代办已办传输类 + * + * @author 郝文豪(James) + * @date 2020/7/13 0013 上午 11:16 + */ +public class ProcessPublishDTO { + /** + * 流程实例id + */ + private String processInstId; + /** + * 序号 + */ + private int index; + /** + * 标题 + */ + private String title; + /** + * 来自谁+部门 + */ + private String fromUser; + /** + * 接收时间 + */ + private String date; + /** + * 是否是自己发起填写的流程 + */ + private boolean ownerProcess; + /** + * 任务实例id + */ + private String taskInstId; + /** + * 打开状态 + */ + private String openState; + + public String getProcessInstId() { + return processInstId; + } + + public void setProcessInstId(String processInstId) { + this.processInstId = processInstId; + } + + public int getIndex() { + return index; + } + + public void setIndex(int index) { + this.index = index; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getFromUser() { + return fromUser; + } + + public void setFromUser(String fromUser) { + this.fromUser = fromUser; + } + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + public boolean isOwnerProcess() { + return ownerProcess; + } + + public void setOwnerProcess(boolean ownerProcess) { + this.ownerProcess = ownerProcess; + } + + public String getTaskInstId() { + return taskInstId; + } + + public void setTaskInstId(String taskInstId) { + this.taskInstId = taskInstId; + } + + public String getOpenState() { + return openState; + } + + public void setOpenState(String openState) { + this.openState = openState; + } +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/dto/ProcessPublishHistoryDTO.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/dto/ProcessPublishHistoryDTO.java new file mode 100644 index 00000000..39f4c1e4 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/dto/ProcessPublishHistoryDTO.java @@ -0,0 +1,140 @@ +package com.actionsoft.apps.coe.pal.publisher.client.dto; + +import java.io.Serializable; + +/** + * 流程发布的数据传输对象类 + * + * @author 郝文豪(James) + * @date 2020/4/7 0007 下午 2:09 + */ +public class ProcessPublishHistoryDTO implements Serializable { + /** + * 流程实例id + */ + private String processInstId; + /** + * 标题 + */ + private String title; + + /** + * 申请人 + */ + private String createUser; + + /** + * 申请时间 + */ + private String createTime; + + /** + * 类型 + */ + private String type; + + /** + * 审批状态 + */ + private String approvalState; + + /** + * 审批人 + */ + private String approvalUser; + + /** + * 审批人id + */ + private String approvalUserId; + + /** + * 是否完成 + */ + private Boolean end; + + /** + * 任务实例id + */ + private String taskInstId; + + public String getTaskInstId() { + return taskInstId; + } + + public void setTaskInstId(String taskInstId) { + this.taskInstId = taskInstId; + } + + public String getProcessInstId() { + return processInstId; + } + + public void setProcessInstId(String processInstId) { + this.processInstId = processInstId; + } + + public Boolean getEnd() { + return end; + } + + public void setEnd(Boolean end) { + this.end = end; + } + + public String getApprovalUserId() { + return approvalUserId; + } + + public void setApprovalUserId(String approvalUserId) { + this.approvalUserId = approvalUserId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getCreateUser() { + return createUser; + } + + public void setCreateUser(String createUser) { + this.createUser = createUser; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getApprovalState() { + return approvalState; + } + + public void setApprovalState(String approvalState) { + this.approvalState = approvalState; + } + + public String getApprovalUser() { + return approvalUser; + } + + public void setApprovalUser(String approvalUser) { + this.approvalUser = approvalUser; + } +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/PublisherSkinsDao.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/PublisherSkinsDao.java new file mode 100644 index 00000000..cbb01e49 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/PublisherSkinsDao.java @@ -0,0 +1,32 @@ +package com.actionsoft.apps.coe.pal.publisher.client.util; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; + +import com.actionsoft.bpms.commons.database.RowMapper; +import com.actionsoft.bpms.commons.pagination.SQLPagination; +import com.actionsoft.bpms.util.DBSql; + +/** + * 导航处理类 + * + * @author ZZ + * + */ +public class PublisherSkinsDao { + + public long getPrevLoginTime(String userId) { + long prevLoginTime = 0; + String sql = " select * from SYS_SESSION s where s.userid = '" + userId + "' order by s.STARTTIME desc "; + List list = DBSql.query(SQLPagination.getPaginitionSQL(sql, 0, 2), new RowMapper() { + public Long mapRow(ResultSet rs, int paramInt) throws SQLException { + return rs.getLong("starttime"); + } + }); + if (list != null && list.size() > 0) { + prevLoginTime = list.get(list.size() - 1); + } + return prevLoginTime; + } +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishClientWeb.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishClientWeb.java new file mode 100644 index 00000000..6bb4e8f1 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishClientWeb.java @@ -0,0 +1,4790 @@ +package com.actionsoft.apps.coe.pal.publisher.client.web; + +import java.io.File; +import java.sql.Timestamp; +import java.text.Collator; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI; +import com.actionsoft.apps.coe.pal.log.CoEOpLogConst; +import com.actionsoft.apps.coe.pal.pal.manage.publish.constant.PublishConst; + +import com.actionsoft.apps.AppsConst; +import com.actionsoft.apps.coe.pal.publisher.client.dao.PublisherClientDao; +import com.actionsoft.apps.coe.pal.publisher.conf.PublisherConf; +import com.actionsoft.apps.coe.pal.publisher.constant.PublisherConstant; +import com.actionsoft.apps.coe.pal.team.user.web.UserWeb; +import com.actionsoft.apps.coe.pal.util.HighSecurityUtil; +import com.actionsoft.apps.lifecycle.api.AppsAPIManager; +import com.actionsoft.apps.resource.AppContext; +import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; +import com.actionsoft.bpms.bpmn.modeler.io.BPMNIO; +import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.commons.portal.pub.web.PublicPortalWeb; +import com.actionsoft.bpms.commons.portal.skins.AbstPortalSkins; +import com.actionsoft.bpms.commons.portal.skins.PortalSkinsInterface; +import com.actionsoft.bpms.org.cache.UserCache; +import com.actionsoft.bpms.org.cache.UserMapCache; +import com.actionsoft.bpms.org.model.CompanyModel; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.RoleModel; +import com.actionsoft.bpms.org.model.UserMapModel; +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.Base64; +import com.actionsoft.bpms.util.UtilDate; +import com.actionsoft.bpms.util.UtilFile; +import com.actionsoft.bpms.util.UtilString; +import com.actionsoft.apps.coe.pal.constant.CoEConstant; +import com.actionsoft.apps.coe.pal.pal.manage.publish.cache.PublishHistoryCache; +import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishCommonDao; +import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishFrequencyDao; +import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishListHistory; +import com.actionsoft.apps.coe.pal.pal.manage.publish.model.PublishFrequencyModel; +import com.actionsoft.apps.coe.pal.pal.manage.publish.model.PublishHistoryModel; +import com.actionsoft.apps.coe.pal.pal.manage.publish.model.PublishListHistoryModel; +import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache; +import com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil; +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.dao.PALRepository; +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.designer.util.CoeDesignerUtil; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.constant.CoeFileConstant; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.dao.UpFileDao; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; +import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil; +import com.actionsoft.apps.coe.pal.pal.ws.dao.CoeWorkSpace; +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.team.user.dao.CoeUser; +import com.actionsoft.apps.coe.pal.team.user.dao.CoeUserDaoFactory; +import com.actionsoft.exception.AWSException; +import com.actionsoft.i18n.I18nRes; +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.collections4.IteratorUtils; + +public class ProcessPublishClientWeb extends AbstPortalSkins implements PortalSkinsInterface { + private UserContext _uc; + + public ProcessPublishClientWeb() { + } + + public ProcessPublishClientWeb(UserContext userContext) { + _uc = userContext; + } + + @Override + public String getHomePage(UserContext uc) { + _uc = uc; + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + CoEOpLogAPI.auditOkOp(uc, CoEOpLogConst.MODULE_CATEGORY_APPCENTER, CoEOpLogConst.OP_ACCESS, CoEOpLogConst.INFO_APPCENTER_ACCESS_PREFIX + SDK.getAppAPI().getAppContext(PublisherConf.APPID).getName() + CoEOpLogConst.INFO_APPCENTER_ACCESS_SUFFIX); + } + if (PublisherConf.PUBLISH_PORTAL_VERSION.equals("v3")) { + Map macroLibraries = getHomePage2(uc); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.sso.home2.html", macroLibraries); + } else { + AppAPI appApi = SDK.getAppAPI(); + JSONArray wsTree = new JSONArray(); + String isIntegrationAWSUser = appApi.getProperty(PublisherConstant.PUBLISH, "isIntegrationAWSUser"); //是否整合AWS用户 + String roleId = ""; + if ("false".equals(isIntegrationAWSUser)) { + roleId = PublishConst.GUESTROLE; + } else { + roleId = uc.getRoleModel().getId(); + } + String emptyMessage = ""; + PALRepository dao = new PALRepository(); + List> allWsList = dao.getWorkSpaceListByPublishRole(roleId, false); + if (allWsList == null || allWsList.size() == 0) { + emptyMessage = "未分配资产库访问权限"; + } + List> wsList = dao.getWorkSpaceListByPublishRole(roleId, true); // 有访问权限的资产库 + StringBuilder wsIds = new StringBuilder(""); + StringBuilder modelIds = new StringBuilder(""); + JSONArray repositoryList = new JSONArray(); // 有访问权限的文件 + if (wsList != null && wsList.size() > 0) { + int i = 0; + List> removeList = new ArrayList>(); + for (Map ws : wsList) { + boolean isActive = PALRepositoryQueryAPIManager.getInstance().isActiveWorkSpace(ws.get("wsId")); + if (!isActive) { + removeList.add(ws); + } else { + JSONObject wsJson = new JSONObject(); + wsJson.put("id", ws.get("wsId")); + wsJson.put("name", ws.get("wsName")); + if (i == 0) { + wsJson.put("open", true); + } else { + wsJson.put("open", false); + } + wsJson.put("ws", true); + wsJson.put("wsName", ws.get("wsName")); + if (PublisherConf.PUBLISH_PORTAL_VERSION.equals("v1")) { + wsJson.put("icon", PublisherConf.PORTAL_TREE_ICON_FOLDER); + } else { + wsJson.put("icon", PublisherConf.PORTAL_TREE_ICON_FOLDER1); + } + wsTree.add(wsJson); + wsIds.append(ws.get("wsId")).append(","); + i++; + } + } + wsList.removeAll(removeList); + + if (wsList.size() > 0) { + ProcessPublishWeb web = new ProcessPublishWeb(uc); + for (Map ws : wsList) { + List repositoryModelList = dao.getRepositoryListByPublishRole(roleId, ws.get("wsId")); + repositoryList.addAll(web.getRepositoryTree(repositoryModelList, ws.get("wsId"), true, false, false, null, false)); + } + } else { + emptyMessage = "资产库被停用"; + } + } else { + emptyMessage = "可访问流程未发布"; + } + + if (repositoryList != null && repositoryList.size() > 0) { + wsTree.addAll(repositoryList); + for (int i = 0; i < repositoryList.size(); i++) { + String versionId = ""; + if (repositoryList.getJSONObject(i).containsKey("versionId")) { + versionId = repositoryList.getJSONObject(i).getString("versionId"); + } else { + versionId = repositoryList.getJSONObject(i).getString("id"); + } + modelIds.append(versionId).append(","); + } + } + + boolean isComment = PublisherConf.isComment(); //允许留言 + boolean isViewHistory = PublisherConf.isViewHistory(); //允许查看历史发布记录 + boolean isViewAttribute = PublisherConf.isViewAttribute(); //允许查看属性 + boolean isPrint = PublisherConf.isPrint(); //允许打印 + String fotter = PublisherConf.getFotter(); //页底信息 + fotter = fotter == null ? "" : fotter; + String title = PublisherConf.getTitle(); //门户标题 + JSONObject dockDisplay = new JSONObject(); + if (!isComment) { + dockDisplay.put("messageView", "display: none;"); + } + if (!isViewHistory) { + dockDisplay.put("publishView", "display: none;"); + } + if (!isViewAttribute) { + dockDisplay.put("attributeView", "display: none;"); + } + if (!isPrint) { + dockDisplay.put("printView", "display: none;"); + } + Map macroLibraries = new HashMap(); + boolean isCoEUser = CoeUserDaoFactory.createUser().validateIsAccessCOE(uc.getUID()); + //公共方法 判断密码修改周期 + PublicPortalWeb portalWeb = new PublicPortalWeb(uc); + JSONObject params = portalWeb.getLoginCheckSecurityInfo(); + macroLibraries.put("isSecurityPwdChange", params.getBoolean("isSecurityPwdChange")); + macroLibraries.put("forceChangePwd", params.getBoolean("forceChangePwd")); + macroLibraries.put("isSecurityPwdComplexity", params.getBoolean("isSecurityPwdComplexity")); + macroLibraries.put("securityMinPwdLength", params.getIntValue("securityMinPwdLength")); + macroLibraries.put("securityMaxPwdLength", params.getIntValue("securityMaxPwdLength")); + macroLibraries.put("sid", uc.getSessionId()); + macroLibraries.put("roleId", roleId); + macroLibraries.put("wsTree", wsTree); + macroLibraries.put("wsId", (wsList == null || wsList.size() == 0) ? "" : wsList.get(0).get("wsId")); + macroLibraries.put("wsName", (wsList == null || wsList.size() == 0) ? "" : wsList.get(0).get("wsName")); + macroLibraries.put("dockDisplay", dockDisplay.toString()); + macroLibraries.put("fotter", fotter.length() > 40 ? fotter.substring(0, 39) : fotter); + macroLibraries.put("title", title.length() > 20 ? title.substring(0, 19) : title); + macroLibraries.put("isComment", isComment); + macroLibraries.put("isViewHistory", isViewHistory); + macroLibraries.put("isViewAttribute", isViewAttribute); + macroLibraries.put("isPrint", isPrint); + macroLibraries.put("userName", uc.getUserName()); + macroLibraries.put("userPhoto", SDK.getPortalAPI().getUserPhoto(uc, uc.getUID())); + macroLibraries.put("emptyMessage", emptyMessage); + macroLibraries.put("entryCoEView", isCoEUser && HighSecurityUtil.allow3PLoginPal(uc.getUID()) ? "" : "display: none;"); + macroLibraries.put("settingView", uc.getUID().equals("admin") ? "" : "display: none;"); + macroLibraries.put("appId", PublisherConf.APPID); + String wsIdsStr = wsIds.toString(); + macroLibraries.put("wsIds", wsIdsStr.contains(",") ? wsIdsStr.substring(0, wsIdsStr.lastIndexOf(",")) : wsIdsStr); + String modelIdsStr = modelIds.toString(); + macroLibraries.put("modelIds", modelIdsStr.contains(",") ? modelIdsStr.substring(0, modelIdsStr.lastIndexOf(",")) : modelIdsStr); + //App-关联查询 + AppContext relationSearchAppContext = AppsAPIManager.getInstance().getAppContext(PublisherConf.RELATION_SEARCH_ID); + macroLibraries.put("relationSearchId", PublisherConf.RELATION_SEARCH_ID.replace(".", "_")); + macroLibraries.put("relationSearchTitle", PublisherConf.RELATION_SEARCH_NAME); + macroLibraries.put("relationSearchCmd", "_portal_home"); + if (relationSearchAppContext != null && SDK.getAppAPI().isActive(relationSearchAppContext.getId())) { + macroLibraries.put("relationSearchIcon", relationSearchAppContext.getIcon16Url(uc)); + macroLibraries.put("relationSearchName", relationSearchAppContext.getName()); + macroLibraries.put("showRelationSearch", ""); + } else { + macroLibraries.put("showRelationSearch", "display: none;"); + } + if (PublisherConf.PUBLISH_PORTAL_VERSION.equals("v1")) { + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.sso.home.html", macroLibraries); + } else if (PublisherConf.PUBLISH_PORTAL_VERSION.equals("v2")) { + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.sso.home1.html", macroLibraries); + } + return null; + } + } + + /** + * v3新版门户 + * @return + */ + public Map getHomePage2(UserContext uc) { + Map macroLibraries = new HashMap(); + AppAPI appApi = SDK.getAppAPI(); + JSONArray wsTree = new JSONArray(); + String isIntegrationAWSUser = appApi.getProperty(PublisherConstant.PUBLISH, "isIntegrationAWSUser"); //是否整合AWS用户 + String roleId = ""; + if ("false".equals(isIntegrationAWSUser)) { + roleId = PublishConst.GUESTROLE; + } else { + roleId = uc.getRoleModel().getId(); + } + boolean isCoEUser = CoeUserDaoFactory.createUser().validateIsAccessCOE(uc.getUID()); + //公共方法 判断密码修改周期 + PublicPortalWeb portalWeb = new PublicPortalWeb(uc); + JSONObject params = portalWeb.getLoginCheckSecurityInfo(); + macroLibraries.put("isSecurityPwdChange", params.getBoolean("isSecurityPwdChange")); + macroLibraries.put("forceChangePwd", params.getBoolean("forceChangePwd")); + macroLibraries.put("isSecurityPwdComplexity", params.getBoolean("isSecurityPwdComplexity")); + macroLibraries.put("securityMinPwdLength", params.getIntValue("securityMinPwdLength")); + macroLibraries.put("securityMaxPwdLength", params.getIntValue("securityMaxPwdLength")); + macroLibraries.put("sid", uc.getSessionId()); + macroLibraries.put("roleId", roleId); + macroLibraries.put("wsTree", wsTree); + macroLibraries.put("userName", uc.getUserName()); + macroLibraries.put("userPhoto", SDK.getPortalAPI().getUserPhoto(uc, uc.getUID())); + macroLibraries.put("entryCoEView", isCoEUser && HighSecurityUtil.allow3PLoginPal(uc.getUID()) ? "" : "display: none;"); + macroLibraries.put("settingView", uc.getUID().equals("admin") ? "" : "display: none;"); + macroLibraries.put("appId", PublisherConf.APPID); + List> wsList = getPalAndAwsPermRepositoryVersionIdByUser(uc, roleId, null); + JSONArray ws = new JSONArray(); + if (wsList != null && wsList.size() > 0) { + for (int i = 0; i < wsList.size(); i++) { + JSONObject object = new JSONObject(); + object.put("id", wsList.get(i).get("wsId")); + object.put("text", wsList.get(i).get("wsName")); + object.put("initDisplay", "0"); + ws.add(object); + } + } + macroLibraries.put("ws", ws); + macroLibraries.put("palAdmin", new CoeUser().isCoEManager(uc.getUID())); + // 获取logo图片路径 + JSONObject object = getLogoImgPath(uc); + macroLibraries.put("logoImgPath", object.getString("src")); + macroLibraries.put("logoImgName", object.getString("name")); + // 门户参数 + macroLibraries.put("xpagesId", PublisherConf.XPAGES_ID); + macroLibraries.put("portalTabs", PublisherConf.PORTAL_TABS); + return macroLibraries; + } + + /** + * 首页 + * + * @return + * @author zhangming + */ + public String getClientMain(String wsId) { + JSONArray result = search("", null, null, null); //所有文件 + + JSONArray plrdArray = new JSONArray(); + JSONArray plrpArray = new JSONArray(); + PALRepository dao = new PALRepository(); + List> plrds = dao.searchRepositoryPlrdByPublisherPortal(_uc.getRoleModel().getId()); + for (Map plrd : plrds) { + if (plrd != null && plrd.containsKey("id") && !plrd.get("id").equals("")) { + plrdArray.add(plrd); + } + } + List> plrps = dao.searchRepositoryPlrpByPublisherPortal(_uc.getRoleModel().getId()); + for (Map plrp : plrps) { + if (plrp != null && plrp.containsKey("id") && !plrp.get("id").equals("")) { + plrpArray.add(plrp); + } + } + + Map macroLibraries = new HashMap(); + macroLibraries.put("result", result); + macroLibraries.put("plrd", plrdArray); + macroLibraries.put("plrp", plrpArray); + macroLibraries.put("wsId", wsId); + macroLibraries.put("sid", _uc.getSessionId()); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.sso.main.html", macroLibraries); + } + + /** + * 查询 + * + * @param modelIds + * @param filter + * @param order + * @param name + * @return + * @author zhangming + */ + public String searchInClientMain(String modelIds, String filter, String order, String name) { + JSONArray result = search(modelIds, filter, order, name); + + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("result", result); + return ro.toString(); + } + + private JSONArray search(String modelIds, String filter, String order, String name) { + PALRepository dao = new PALRepository(); + List models = dao.searchRepositoryByPublisherPortal(modelIds, filter, order, name); + + List jsonList = new ArrayList<>(); + for (String id : models) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model == null) { + continue; + } + + boolean isActive = false; + if (model != null && !"default".equals(model.getMethodId())) { + if (PALMethodCache.getPALMethodModelById(model.getMethodId()) == null) { + isActive = false; + } else { + String methodId = PALMethodCache.getPALMethodModelById(model.getMethodId()).getApp().getId(); + isActive = SDK.getAppAPI().isActive(methodId); + } + } + + String processDefId = ""; + String appId = ""; + if (model != null) {// 获取流程版本id + appId = CoeProcessLevelUtil.getAppId(model.getId()); + processDefId = CoeProcessLevelUtil.getProcessDefIdByVer(appId, model.getId(), (int)model.getVersion()); + } + + String p = model.getFilePath(); + String imagePath = "../apps/"+ CoEConstant.APP_ID +"/img/method/default.png"; + if (!processDefId.equals("")) { + imagePath = "data:image/png;base64," + BPMNIO.getBPMNImageThumbnail(CoeProcessLevelUtil.getAppId(model.getId()), processDefId); + } else { + if (!"".equals(p)) { + UtilFile utilFile = new UtilFile(p + "/" + model.getId() + ".small.png"); + if (utilFile.exists()) { + byte[] base64Bytes = Base64.encode(utilFile.readBytes()); + imagePath = "data:image/png;base64," + new String(base64Bytes); + } + } + } + if ("default".equals(model.getMethodId())) { + imagePath = "../apps/com.actionsoft.apps.coe.pal.publisher/img/default_folder.png"; + } + + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("name", model.getName()); + object.put("imgPath", imagePath); + object.put("processDefId", processDefId); + object.put("methodId", model.getMethodId()); + String relationType = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_RELATION_TYPE); + object.put("plrd", ""); + object.put("plrp", ""); + if ("address".equals(relationType)) { + String dutyDept = model.getDutyDept(); + if (!UtilString.isEmpty(dutyDept)) { + if (SDK.getORGAPI().getDepartmentById(dutyDept) != null) { + dutyDept = SDK.getORGAPI().getDepartmentById(dutyDept).getName(); + object.put("plrd", dutyDept); + } + } + String dutyPerson = model.getDutyUser(); + if (!UtilString.isEmpty(dutyPerson)) { + object.put("plrp", SDK.getORGAPI().getUserAliasNames(dutyPerson)); + } + } else { + String plrdId = model.getOwnerDept(); + if (plrdId != null && !"".equals(plrdId)) { + List list = DesignerShapeRelationCache.getListByAttrId(id, "", "plRD"); + if (list != null && list.size() > 0) { + object.put("plrd", list.get(0).getRelationShapeText()); + } else { + object.put("plrd", ""); + } + } + String plrpId = model.getOwnerUser(); + if (plrpId != null && !"".equals(plrpId)) { + List list = DesignerShapeRelationCache.getListByAttrId(id, "", "plRP"); + if (list != null && list.size() > 0) { + object.put("plrp", list.get(0).getRelationShapeText()); + } else { + object.put("plrp", ""); + } + } + } + object.put("version", model.getVersion()); + object.put("isActive", isActive); + + if (model.isPublish()) { + PublishListHistory historyDao = new PublishListHistory(); + String lastPublishDate = historyDao.getLastPublishDateByModelId(model.getId()); + if (lastPublishDate != null && !"".equals(lastPublishDate)) { + lastPublishDate = lastPublishDate.substring(0, 10); + } + object.put("publishDate", lastPublishDate == null ? "" : lastPublishDate); + } else { + object.put("publishDate", ""); + } + + jsonList.add(object); + } + + if (order != null && order.contains("plrd")) { + Collections.sort(jsonList, new ComparatorPlrdChinese()); + } + if (order != null && order.contains("plrp")) { + Collections.sort(jsonList, new ComparatorPlrpChinese()); + } + return JSONArray.parseArray(JSON.toJSONString(jsonList)); + } + + private class ComparatorPlrdChinese implements Comparator { + @Override + public int compare(JSONObject model1, JSONObject model2) { + String plrd1 = model1.getString("plrd"); + String plrd2 = model2.getString("plrd"); + return Collator.getInstance(Locale.CHINESE).compare(plrd1, plrd2); + } + } + + private class ComparatorPlrpChinese implements Comparator { + @Override + public int compare(JSONObject model1, JSONObject model2) { + String plrp1 = model1.getString("plrp"); + String plrp2 = model2.getString("plrp"); + return Collator.getInstance(Locale.CHINESE).compare(plrp1, plrp2); + } + } + + /** + * 查询发布历史 + * + * @param start + * @param type N/C/S,如果查询全部该字段为空 + * @return + * @author zhangming + */ + public String getPublishList(String start, String type) { + ProcessPublishWeb web = new ProcessPublishWeb(_uc); + JSONArray list = web.getMorePublishHistory(start, "50", type); + + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("results", list); + return ro.toString(); + } + + public String getSettingData() { + boolean isComment = PublisherConf.isComment(); //允许留言 + boolean isViewHistory = PublisherConf.isViewHistory(); //允许查看历史发布记录 + boolean isViewAttribute = PublisherConf.isViewAttribute(); //允许查看属性 + boolean isPrint = PublisherConf.isPrint(); //允许打印 + String fotter = PublisherConf.getFotter(); //页底信息 + fotter = fotter == null ? "" : fotter; + String title = PublisherConf.getTitle(); //门户标题 + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("isComment", isComment + ""); + ro.put("isViewHistory", isViewHistory + ""); + ro.put("isViewAttribute", isViewAttribute + ""); + ro.put("isPrint", isPrint + ""); + ro.put("fotter", fotter); + ro.put("title", title); + return ro.toString(); + } + + /** + * 参数设置 + * + * @param title + * @param fotter + * @param isComment + * @param isPrint + * @param isViewAttribute + * @param isViewHistory + * @return + * @author zhangming + */ + public String setting(String title, String fotter, String isComment, String isPrint, String isViewAttribute, String isViewHistory) { + PublisherConf.setTitle(title); + PublisherConf.setFotter(fotter); + PublisherConf.setComment(isComment); + PublisherConf.setPrint(isPrint); + PublisherConf.setViewAttribute(isViewAttribute); + PublisherConf.setViewHistory(isViewHistory); + ResponseObject ro = ResponseObject.newOkResponse(); + return ro.toString(); + } + + /** + * 获取资产库列表 + * + * @return + * @author zhangming + */ + public String getOrgWsTreeData() { + ResponseObject ro = ResponseObject.newOkResponse(); + + List wsList = CoeWorkSpaceDaoFactory.createCoeWorkSpace().getInstanceAll(); + JSONArray wsTree = new JSONArray(); + if (wsList != null && wsList.size() > 0) { + int i = 0; + for (CoeWorkSpaceModel ws : wsList) { + boolean isActive = PALRepositoryQueryAPIManager.getInstance().isActiveWorkSpace(ws.getUUId()); + if (isActive) { + JSONObject wsJson = new JSONObject(); + String wsId = ws.getUUId(); + wsJson.put("id", wsId); + wsJson.put("name", ws.getWsName()); + if (i == 0) { + wsJson.put("open", true); + } else { + wsJson.put("open", false); + } + wsJson.put("ws", true); + wsJson.put("wsId", wsId); + wsJson.put("wsName", ws.getWsName()); + if (PublisherConf.PUBLISH_PORTAL_VERSION.equals("v1")) { + wsJson.put("icon", PublisherConf.PORTAL_TREE_ICON_FOLDER); + } else { + wsJson.put("icon", PublisherConf.PORTAL_TREE_ICON_FOLDER1); + } + wsTree.add(wsJson); + i++; + + JSONArray jsonArray = PALRepositoryQueryAPIManager.getInstance().getPalRepositoryTreeData(_uc, wsId, "org", "isUsed"); + for (int j = 0; j < jsonArray.size(); j++) { + JSONObject object = jsonArray.getJSONObject(j); + if (object.getString("id").equals("org")) { + object.put("id", wsId + "_org"); + object.put("pid", wsId); + object.put("icon", PublisherConf.PORTAL_TREE_ICON_FOLDER1); + } else { + if (object.getString("pid").equals("org")) { + object.put("pid", wsId + "_org"); + } + if (object.getString("isParent") == "true") { + object.put("icon", PublisherConf.PORTAL_TREE_ICON_FOLDER1); + } else { + object.put("icon", ""); + } + } + + wsTree.add(object); + } + } + } + } + ro.put("wsTreeData", wsTree); + return ro.toString(); + } + + /** + * 标准化体系页面 + * + * @return + * @author zhangming + */ + public String toOrgRelationPage() { + Map macroLibraries = new HashMap(); + macroLibraries.put("sid", _uc.getSessionId()); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.sso.org.html", macroLibraries); + } + + /** + * 组织模型相关的模型页面 + * + * @return + * @author zhangming + */ + public String toOrgRelationModelPage() { + Map macroLibraries = new HashMap(); + macroLibraries.put("sid", _uc.getSessionId()); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.sso.org.main.html", macroLibraries); + } + + public String getOrgRelativeModel(String orgModelId, String modelIds) { + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("data", getOrgRelationModelList(orgModelId, modelIds)); + return ro.toString(); + } + + private JSONObject getOrgRelationModelList(String orgModelId, String modelIds) { + JSONObject data = new JSONObject(); + + //如果orgModelId为空,则查询发布历史 + if (orgModelId == null || "".equals(orgModelId)) { + PublisherClientDao publisherDao = new PublisherClientDao(); + String[] modelIdArray = modelIds.split(","); + StringBuilder sb = new StringBuilder(); + if (modelIdArray.length > 0) { + for (String modelId : modelIdArray) { + if (!"".equals(modelId)) { + sb.append("'" + modelId + "',"); + } + } + } + if (sb.length() > 0) { + String wsId = ""; + if (modelIdArray[0].length() > 36) { + wsId = modelIdArray[0].substring(modelIdArray[0].indexOf("_") + 1); + } else if (modelIdArray[0].length() == 36) { + if (PALRepositoryCache.getCache().get(modelIdArray[0]) != null) { + wsId = PALRepositoryCache.getCache().get(modelIdArray[0]).getWsId(); + } + } else { + return data; + } + + String sqlIds = sb.substring(0, sb.lastIndexOf(",")); + List> processList = publisherDao.getPublishListData(sqlIds, "process", wsId, null); + data.put("processList", processList); + Map controlPolicyIds = publisherDao.getControlPolicyId(wsId); + //管理标准 + if (controlPolicyIds.containsKey(PublisherConstant.ORG_RELATION_MANAGEMENT_STANDARD)) { + List> managementRoleList = new ArrayList>(); + List> technicalRoleList = new ArrayList>(); + List> workRoleList = new ArrayList>(); + String publishedManagementStandardIds = ""; + String publishedTechnicalStandardIds = ""; + String publishedWorkStandardIds = ""; + if (controlPolicyIds.containsKey(PublisherConstant.ORG_RELATION_MANAGEMENT_STANDARD)) { + String managementStandardId = controlPolicyIds.get(PublisherConstant.ORG_RELATION_MANAGEMENT_STANDARD); + publishedManagementStandardIds = getRelationPublishedControlIds(wsId, managementStandardId, "control.policy"); + } + if (controlPolicyIds.containsKey(PublisherConstant.ORG_RELATION_TECHNICAL_STANDARD)) { + String technicalStandardId = controlPolicyIds.get(PublisherConstant.ORG_RELATION_TECHNICAL_STANDARD); + publishedTechnicalStandardIds = getRelationPublishedControlIds(wsId, technicalStandardId, "control.policy"); + } + if (controlPolicyIds.containsKey(PublisherConstant.ORG_RELATION_WORK_STANDARD)) { + String workStandardId = controlPolicyIds.get(PublisherConstant.ORG_RELATION_WORK_STANDARD); + publishedWorkStandardIds = getRelationPublishedControlIds(wsId, workStandardId, "control.policy"); + } + + List> list = publisherDao.getPublishListData(sqlIds, "control", wsId, "control.policy"); + if (list != null && list.size() > 0) { + for (Map map : list) { + String id = map.get("id").toString(); + if (publishedManagementStandardIds.contains(id)) { + managementRoleList.add(map); + } else if (publishedTechnicalStandardIds.contains(id)) { + technicalRoleList.add(map); + } else if (publishedWorkStandardIds.contains(id)) { + workRoleList.add(map); + } + + } + } + data.put("managementList", managementRoleList); + data.put("technicalList", technicalRoleList); + data.put("workList", workRoleList); + } else { + data.put("managementList", new ArrayList()); + data.put("technicalList", new ArrayList()); + data.put("workList", new ArrayList()); + } + } + + return data; + } + + PALRepositoryModel orgModel = PALRepositoryCache.getCache().get(orgModelId); + String wsId = orgModel.getWsId(); + if (orgModel != null) { + List orgList = new ArrayList(); + PALRepositoryQueryAPIManager.getInstance().getAllUsedPalRepositoryModelsByPid(wsId, orgModelId, orgList); //组织模型的所有子流程 + StringBuilder sbOrgIds = new StringBuilder("'" + orgModelId + "'"); + if (orgList != null && orgList.size() > 0) { + for (PALRepositoryModel model : orgList) { + sbOrgIds.append(",'").append(model.getId()).append("'"); + } + } + //流程模型 + PublisherClientDao publisherDao = new PublisherClientDao(); + List> processIdList = publisherDao.getFileIdsByRelationFileId1(sbOrgIds.toString()); //org模型关联的流程模型Id + List> processList = publisherDao.getFileIdsByRelation1(sbOrgIds.toString()); + String processIds = ""; //processIds保存org模型关联的所有process模型Id,包括已发布和未发布的 + if (processIdList != null && processIdList.size() > 0) { + StringBuilder sbProcessIds = new StringBuilder(); + for (Map processMap : processIdList) { + String processId = processMap.get("id").toString(); + sbProcessIds.append("'").append(processId).append("',"); + } + processIds = sbProcessIds.substring(0, sbProcessIds.lastIndexOf(",")); + } + data.put("processIds", processIds); + List> processOrgList = new ArrayList>(); + if (processList != null) { + for (Map map : processList) { + if (modelIds.contains(map.get("id").toString())) { + processOrgList.add(map); + } + } + } + data.put("processList", processOrgList); + + //根据流程模型,获取关联的制度模型 + Map controlPolicyIds = publisherDao.getControlPolicyId(wsId); + //管理标准 + if (controlPolicyIds.containsKey(PublisherConstant.ORG_RELATION_MANAGEMENT_STANDARD)) { + String managementStandardId = controlPolicyIds.get(PublisherConstant.ORG_RELATION_MANAGEMENT_STANDARD); + String publishedManagementStandardIds = getRelationPublishedControlIds(wsId, managementStandardId, "control.policy"); + List> managementList = publisherDao.getRelationFileIds(processIds, publishedManagementStandardIds); + List> managementRoleList = new ArrayList>(); + if (managementList != null && managementList.size() > 0) { + for (Map managementMap : managementList) { + String id = managementMap.get("id").toString(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (modelIds.contains(model.getVersionId())) { + managementRoleList.add(managementMap); + } + } + } + data.put("managementList", managementRoleList); + } else { + data.put("managementList", new ArrayList()); + } + //技术标准 + if (controlPolicyIds.containsKey(PublisherConstant.ORG_RELATION_TECHNICAL_STANDARD)) { + String technicalStandardId = controlPolicyIds.get(PublisherConstant.ORG_RELATION_TECHNICAL_STANDARD); + String publishedTechnicalStandardIds = getRelationPublishedControlIds(wsId, technicalStandardId, "control.policy"); + List> technicalList = publisherDao.getRelationFileIds(processIds, publishedTechnicalStandardIds); + List> technicalRoleList = new ArrayList>(); + if (technicalList != null && technicalList.size() > 0) { + for (Map managementMap : technicalList) { + String id = managementMap.get("id").toString(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (modelIds.contains(model.getVersionId())) { + technicalRoleList.add(managementMap); + } + } + } + data.put("technicalList", technicalRoleList); + } else { + data.put("technicalList", new ArrayList()); + } + //工作标准 + if (controlPolicyIds.containsKey(PublisherConstant.ORG_RELATION_WORK_STANDARD)) { + String workStandardId = controlPolicyIds.get(PublisherConstant.ORG_RELATION_WORK_STANDARD); + String publishedWorkStandardIds = getRelationPublishedControlIds(wsId, workStandardId, "control.policy"); + List> workList = publisherDao.getRelationFileIds(processIds, publishedWorkStandardIds); + List> workRoleList = new ArrayList>(); + if (workList != null && workList.size() > 0) { + for (Map managementMap : workList) { + String id = managementMap.get("id").toString(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (modelIds.contains(model.getVersionId())) { + workRoleList.add(managementMap); + } + } + } + data.put("workList", workRoleList); + } else { + data.put("workList", new ArrayList()); + } + } + return data; + } + + private String getRelationPublishedControlIds(String wsId, String pid, String methodId) { + List standardList = new ArrayList(); + PALRepositoryQueryAPIManager.getInstance().getAllPublishedPalRepositoryModelsByPid(wsId, pid, standardList); + String ids = ""; //已经发布的管理标准 + StringBuilder sbStandardIds = new StringBuilder("'" + pid + "'"); + if (standardList != null && standardList.size() > 0) { + for (PALRepositoryModel model : standardList) { + if (methodId == null || "".equals(methodId) || methodId.equals(model.getMethodId())) { + sbStandardIds.append(",'").append(model.getId()).append("'"); + } + } + } + ids = sbStandardIds.toString(); + return ids; + } + + /** + * 按组织维护流程 + * + * @param wsId + * @return + */ + public String getManageHome(String wsId, String categorys) { + Map result = new HashMap(); + result.put("sid", _uc.getSessionId()); + JSONArray treeData = new JSONArray(); + if (UtilString.isEmpty(wsId)) { + wsId = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_DEFAULT_WSID); + } + result.put("wsId", wsId); + //根节点 + String[] categoryArray = categorys.split(","); + for (String category : categoryArray) { + category = category.trim(); + JSONObject categoryRoot = new JSONObject(); + categoryRoot.put("id", category); + categoryRoot.put("name", I18nRes.findValue(CoEConstant.APP_ID, category)); + categoryRoot.put("open", false); + categoryRoot.put("nocheck", true); + treeData.add(categoryRoot); + + //查询部门下的流程根节点 + List list = PALRepositoryQueryAPIManager.getInstance().getRootPALRepositoryModelsByDeptId(_uc.getUID(), wsId, null, category, true, false); + List newList = new ArrayList(); + for (PALRepositoryModel process : list) { + PALRepositoryModelImpl newProcess = (PALRepositoryModelImpl) process; + newProcess.setNewParentId(category); + newList.add((PALRepositoryModel) newProcess); + } + treeData.addAll(PALRepositoryQueryAPIManager.getInstance().list2Json(_uc, newList, true, false)); + } + result.put("treeData", treeData); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.sso.manage.home.html", result); + } + + /** + * 已发布流程查询 + * + * @param wsId + * @param categorys + * @return + */ + public String getManageSearchHome(String wsId, String categorys) { + Map result = new HashMap(); + result.put("sid", _uc.getSessionId()); + if (UtilString.isEmpty(wsId)) { + wsId = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_DEFAULT_WSID); + } + + JSONArray treeData = new JSONArray(); + PALRepositoryQueryAPIManager manager = PALRepositoryQueryAPIManager.getInstance(); + PALRepository dao = new PALRepository(); + String[] categoryList = categorys.split(","); + StringBuilder filePerms = new StringBuilder(""); + for (String category : categoryList) { + category = category.trim(); + + JSONObject root = new JSONObject(); + root.put("id", category); + root.put("name", I18nRes.findValue(CoEConstant.APP_ID, category)); + root.put("open", false); + treeData.add(root); + + List repositoryModelList = dao.searchRepositoryList(wsId, null, null, "", -1, null, null, null, null, null, null, -1, null, category, null, false, true, "", "", -1, null, "PLNO"); + for (PALRepositoryModel model : repositoryModelList) { + filePerms.append(model.getId()).append(","); + } + List newList = manager.setNewPid(repositoryModelList); + treeData.addAll(manager.list2Json(_uc, newList, false, true)); + } + + result.put("treeData", treeData); + result.put("filePerms", filePerms); + + result.put("wsId", wsId); + result.put("processRootId", SDK.getAppAPI().getProperty(PublisherConstant.PUBLISH, "processRootId")); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.sso.search.home.html", result); + } + + /** + * 已发布流程查询 + * + * @param wsId + * @param categorys + * @return + */ + public String getManageSearchHomeCondition(String wsId, String categorys) { + Map result = new HashMap(); + result.put("sid", _uc.getSessionId()); + if (UtilString.isEmpty(wsId)) { + wsId = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_DEFAULT_WSID); + } + + JSONArray treeData = new JSONArray(); + PALRepositoryQueryAPIManager manager = PALRepositoryQueryAPIManager.getInstance(); + PALRepository dao = new PALRepository(); + String[] categoryList = categorys.split(","); + StringBuilder filePerms = new StringBuilder(""); + for (String category : categoryList) { + category = category.trim(); + + JSONObject root = new JSONObject(); + root.put("id", category); + root.put("name", I18nRes.findValue(CoEConstant.APP_ID, category)); + root.put("open", false); + treeData.add(root); + + JSONArray params = new JSONArray(); + JSONObject param1 = new JSONObject(); + param1.put("key", "securityclass"); + param1.put("value", "='内部'"); + params.add(param1); + List repositoryModelList = dao.searchRepositoryList(wsId, null, null, "", -1, null, null, null, null, null, null, -1, null, category, null, false, true, "", "", -1, params, "PLNO"); + params = new JSONArray(); + JSONObject param2 = new JSONObject(); + param2.put("key", "securityclass"); + param2.put("value", "='外部公开'"); + params.add(param2); + repositoryModelList.addAll(dao.searchRepositoryList(wsId, null, null, "", -1, null, null, null, null, null, null, -1, null, category, null, false, true, "", "", -1, params, "PLNO")); + for (PALRepositoryModel model : repositoryModelList) { + filePerms.append(model.getId()).append(","); + } + List newList = manager.setNewPid(repositoryModelList); + treeData.addAll(manager.list2Json(_uc, newList, false, true)); + } + + result.put("treeData", treeData); + result.put("filePerms", filePerms); + + result.put("wsId", wsId); + result.put("processRootId", SDK.getAppAPI().getProperty(PublisherConstant.PUBLISH, "processRootId")); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.sso.search.home.html", result); + } + + private boolean isEmpty(List list) { + return list == null || list.size() == 0; + } + + /** + * 获取当前人权限下的模型id + * 条件: + * 1.模型中有节点关联的是AWS平台的人员且人员与当前人相同 + * 2.模型中有关联节点是角色,且角色是当前人员的所属角色(包括兼职角色) + * 3.模型的文件属性中的责任人是当前人 + * 4.获取的流程文件的当前版本必须是已发布 + * @param uc + * @return + */ + private Set getAwsOrgPermRepositoryByUser(UserContext uc, String category, boolean isPublish) { + Set result = new HashSet<>(); + // 获取当前人的所有角色 + String userId = uc.getUID(); + Set roleIds = new HashSet<>(); + RoleModel roleModel = uc.getRoleModel(); + roleIds.add(roleModel.getId()); + // 兼职角色 + List userMapModels = UserMapCache.getMapListOfUser(userId); + if (!isEmpty(userMapModels)) { + for (UserMapModel role : userMapModels) { + roleIds.add(role.getRoleId()); + } + } + // 条件1,2,4 + List list = DesignerShapeRelationCache.getListByRelationShapeId("00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000"); + if (!isEmpty(list)) { + for (DesignerShapeRelationModel model : list) { + JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); + if ("user".equalsIgnoreCase(object.getString("type")) && uc.getUID().equals(object.getString("id"))) { + PALRepositoryModel p = PALRepositoryCache.getCache().get(model.getFileId()); + if (p != null) { + if (isPublish) { + if (p.isPublish()) { + if (UtilString.isEmpty(category)) { + result.add(p.getId()); + } else { + if (p.getMethodCategory().equals(category)) { + result.add(p.getId()); + } + } + } + } else { + if (UtilString.isEmpty(category)) { + result.add(p.getId()); + } else { + if (p.getMethodCategory().equals(category)) { + result.add(p.getId()); + } + } + } + } + } + if ("role".equalsIgnoreCase(object.getString("type")) && roleIds.contains(object.getString("id"))) { + PALRepositoryModel p = PALRepositoryCache.getCache().get(model.getFileId()); + if (p != null) { + if (isPublish) { + if (p.isPublish()) { + if (UtilString.isEmpty(category)) { + result.add(p.getId()); + } else { + if (p.getMethodCategory().equals(category)) { + result.add(p.getId()); + } + } + } + } else { + if (UtilString.isEmpty(category)) { + result.add(p.getId()); + } else { + if (p.getMethodCategory().equals(category)) { + result.add(p.getId()); + } + } + } + } + } + } + } + // 条件3,4 + CoeWorkSpace workSpace = new CoeWorkSpace(); + List wsList = workSpace.getNormalCoeWorkSpaceModelRecodes(); + if (!isEmpty(wsList)) { + for (CoeWorkSpaceModel model : wsList) { + Iterator iterator = PALRepositoryCache.getByWsId(model.getUUId()); + while (iterator.hasNext()) { + PALRepositoryModel pModel = iterator.next(); + if (pModel != null && pModel.getMethodCategory().equals(category) && userId.equals(pModel.getDutyUser())) { + if (isPublish) { + if (pModel.isPublish()) { + result.add(pModel.getId()); + } + } else { + result.add(pModel.getId()); + } + } + } + } + } + return result; + } + + /** + * 获取当前人权限下的模型id + * 条件: + * 1.模型中有节点关联的是AWS平台的人员且人员与当前人相同 + * 2.模型中有关联节点是角色,且角色是当前人员的所属角色(包括兼职角色) + * 3.获取的流程文件的当前版本必须是已发布 + * @param uc + * @return + */ + private Set getAwsOrgPermRealtionRepositoryByUser(UserContext uc, String category, boolean isPublish) { + Set result = new HashSet<>(); + // 获取当前人的所有角色 + String userId = uc.getUID(); + Set roleIds = new HashSet<>(); + RoleModel roleModel = uc.getRoleModel(); + roleIds.add(roleModel.getId()); + // 兼职角色 + List userMapModels = UserMapCache.getMapListOfUser(userId); + if (!isEmpty(userMapModels)) { + for (UserMapModel role : userMapModels) { + roleIds.add(role.getRoleId()); + } + } + // 条件1,2,3 + List list = DesignerShapeRelationCache.getListByRelationShapeId("00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000"); + if (!isEmpty(list)) { + for (DesignerShapeRelationModel model : list) { + JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); + if ("user".equalsIgnoreCase(object.getString("type")) && uc.getUID().equals(object.getString("id"))) { + PALRepositoryModel p = PALRepositoryCache.getCache().get(model.getFileId()); + if (p != null) { + if (isPublish) { + if (p.isPublish()) { + if (UtilString.isEmpty(category)) { + result.add(p.getId()); + } else { + if (p.getMethodCategory().equals(category)) { + result.add(p.getId()); + } + } + } + } else { + if (UtilString.isEmpty(category)) { + result.add(p.getId()); + } else { + if (p.getMethodCategory().equals(category)) { + result.add(p.getId()); + } + } + } + } + } + if ("role".equalsIgnoreCase(object.getString("type")) && roleIds.contains(object.getString("id"))) { + PALRepositoryModel p = PALRepositoryCache.getCache().get(model.getFileId()); + if (p != null) { + if (isPublish) { + if (p.isPublish()) { + if (UtilString.isEmpty(category)) { + result.add(p.getId()); + } else { + if (p.getMethodCategory().equals(category)) { + result.add(p.getId()); + } + } + } + } else { + if (UtilString.isEmpty(category)) { + result.add(p.getId()); + } else { + if (p.getMethodCategory().equals(category)) { + result.add(p.getId()); + } + } + } + } + } + } + } + return result; + } + + /** + * 获取责任人是当前人的模型id + * 条件: + * 1.模型的文件属性中的责任人是当前人 + * @param uc + * @return + */ + private Set getPermRepositoryByDutyPerson(UserContext uc, String category, boolean isPublish) { + Set result = new HashSet<>(); + // 获取当前人的所有角色 + String userId = uc.getUID(); + // 条件3,4 + CoeWorkSpace workSpace = new CoeWorkSpace(); + List wsList = workSpace.getNormalCoeWorkSpaceModelRecodes(); + if (!isEmpty(wsList)) { + for (CoeWorkSpaceModel model : wsList) { + Iterator iterator = PALRepositoryCache.getByWsId(model.getUUId()); + while (iterator.hasNext()) { + PALRepositoryModel pModel = iterator.next(); + if (pModel != null && pModel.getMethodCategory().equals(category) && userId.equals(pModel.getDutyUser())) { + if (isPublish) { + if (pModel.isPublish()) { + result.add(pModel.getId()); + } + } else { + result.add(pModel.getId()); + } + } + } + } + } + return result; + } + + /** + * 获取当前人给定部门时权限下的模型id + * 模型中有关联节点是部门,且角色是当前人员的所属角色(包括兼职角色) + * @param uc + * @param category + * @param deptId + * @return + */ + private Set getAwsOrgPermRepositoryByDept(UserContext uc, String category, String deptId, boolean isPublish) { + Set result = new HashSet<>(); + List list = DesignerShapeRelationCache.getListByRelationShapeId("00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000"); + if (!isEmpty(list)) { + for (DesignerShapeRelationModel model : list) { + JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); + if ("department".equalsIgnoreCase(object.getString("type")) && deptId.equals(object.getString("id"))) { + PALRepositoryModel p = PALRepositoryCache.getCache().get(model.getFileId()); + if (p != null && p.isPublish()) { + if (isPublish) { + if (p.isPublish()) {// 已发布 + if (UtilString.isEmpty(category)) { + result.add(p.getId()); + } else { + if (p.getMethodCategory().equals(category)) { + result.add(p.getId()); + } + } + } + } else { + if (UtilString.isEmpty(category)) { + result.add(p.getId()); + } else { + if (p.getMethodCategory().equals(category)) { + result.add(p.getId()); + } + } + } + } + } + } + } + return result; + } + + /** + * 获取当前人权限下的资产库id集合 + * @param uc + * @return + */ + private Set getAwsOrgPermWsByUser(UserContext uc, String category) { + Set wsIds = new HashSet<>(); + Set repositoryIds = getAwsOrgPermRepositoryByUser(uc, category, true); + for (String repositoryId : repositoryIds) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(repositoryId); + if (model != null && PALRepositoryQueryAPIManager.getInstance().isActiveWorkSpace(model.getWsId())) + wsIds.add(model.getWsId()); + } + return wsIds; + } + + /** + * 根据userId获取具有权限的已发布资产库 + * @return + */ + private List> getPermRepositoryVersionIdByUser(UserContext uc, String roleId) { + // 获取资产库流程Id + PALRepository dao = new PALRepository(); + List> wsList = dao.getWorkSpaceListByPublishRole(roleId, true, true); // 有访问权限的资产库 + if (wsList != null && wsList.size() > 0) { + List> removeList = new ArrayList>(); + for (Map ws : wsList) { + boolean isActive = PALRepositoryQueryAPIManager.getInstance().isActiveWorkSpace(ws.get("wsId")); + if (!isActive) { + removeList.add(ws); + } + } + wsList.removeAll(removeList); + } + return wsList; + } + + /** + * 根据userId获取具有权限的已发布资产库 + * pal自身权限+关联AWS平台权限 + * @return + */ + private List> getPalAndAwsPermRepositoryVersionIdByUser(UserContext uc, String roleId, String category) { + // 获取资产库流程Id + PALRepository dao = new PALRepository(); + //List> wsList = dao.getWorkSpaceListByPublishRole(roleId, true, true); // 有访问权限的资产库 + List> wsList = dao.getWorkSpaceListByPublishRole(roleId, false, true); // 有访问权限的资产库(发布+未发布) + if (wsList != null && wsList.size() > 0) { + List> removeList = new ArrayList>(); + for (Map ws : wsList) { + boolean isActive = PALRepositoryQueryAPIManager.getInstance().isActiveWorkSpace(ws.get("wsId")); + if (!isActive) { + removeList.add(ws); + } + } + wsList.removeAll(removeList); + } + // 关联AWS组织的资产库权限整合 + if (wsList == null) { + wsList = new ArrayList<>(); + } + Set wsIds = getAwsOrgPermWsByUser(uc, category); + if (wsIds.size() > 0) { + Set temp = new HashSet<>(); + for (Map ws : wsList) { + temp.add(ws.get("wsId")); + } + CoeWorkSpace wsDao = new CoeWorkSpace(); + for (String wsId : wsIds) { + if (!temp.contains(wsId)) { + CoeWorkSpaceModel model = wsDao.getInstance(wsId); + if (model != null) { + Map result = new HashMap<>(); + result.put("wsId", model.getUUId()); + result.put("wsName", model.getWsName()); + wsList.add(result); + } + } + } + } + return wsList; + } + + /** + * 获取基本参数 + * @param uc + * @param count + * @return + */ + private JSONObject getXPagesBasicParam(UserContext uc, String count) { + String isIntegrationAWSUser = SDK.getAppAPI().getProperty(PublisherConstant.PUBLISH, "isIntegrationAWSUser"); //是否整合AWS用户 + String roleId = ""; + if ("false".equals(isIntegrationAWSUser)) { + roleId = PublishConst.GUESTROLE; + } else { + roleId = uc.getRoleModel().getId(); + } + + boolean limit = true;// 是否限制条数,count为空则不限制 + int c = 0; + if(!UtilString.isEmpty(count)){ + c = Integer.parseInt(count); + } else { + limit = false; + } + JSONObject object = new JSONObject(); + object.put("roleId", roleId); + object.put("c", c); + object.put("limit", limit); + return object; + } + + /** + * 常用流程查询 + * xpages小页面 + * @param count + * @return + */ + public String commonProcessQuery(UserContext uc, String count) { + String category = "process"; + Map result = new HashMap(); + result.put("sid", uc.getSessionId()); + result.put("uid", uc.getUID()); + JSONObject param = getXPagesBasicParam(uc, count); + String roleId = param.getString("roleId"); + boolean limit = param.getBooleanValue("limit"); + int c = param.getIntValue("c"); + PublishListHistory pHistory = new PublishListHistory(); + JSONArray array = new JSONArray(); + // 获取常用流程数据 + List> wsList = getPalAndAwsPermRepositoryVersionIdByUser(uc, roleId, category); + if (wsList != null && wsList.size() > 0) { + PublishCommonDao commonDao = new PublishCommonDao(); + + StringBuffer wsIds = new StringBuffer(); + String sqlParam = ""; + for (Map map : wsList) { + wsIds.append("'").append(map.get("wsId")).append("'").append(","); + } + if (wsIds.length() > 0) { + sqlParam = wsIds.substring(0, wsIds.length() - 1); + } + // 获取降序排列的数据 + Object [] commons = commonDao.getCommonDataByWsIds(sqlParam, category); + @SuppressWarnings("unchecked") + List list = (ArrayList) commons[0];// 按照设定顺序升序排序的id集合 + JSONObject datas = (JSONObject) commons[1]; + if (list != null && list.size() > 0) { + PALRepository repositoryDao = new PALRepository(); + Set versionIds = repositoryDao.getRepositoryVersionIdListByPublishRole(roleId, sqlParam, category); + Set repositoryIds = getAwsOrgPermRepositoryByUser(uc, category, true);// aws平台下的资产库流程文件 + for (String str : repositoryIds) { + versionIds.add(PALRepositoryCache.getCache().get(str).getVersionId()); + } + int index = 0; + List list1 = new ArrayList<>(); + for (String id : list) { + if (limit && index >= c) break; + JSONObject data = datas.getJSONObject(id); + int sort = data.getIntValue("sort"); + //将sort为0的数据单独提出来 + if (sort == 0) { + list1.add(data); + continue; + } + List temps = PALRepositoryCache.getByVersionId(data.getString("wsId"), data.getString("plversionId")); + if (temps == null || temps.size() == 0) continue; + for (PALRepositoryModel model : temps) { + if (model.isPublish() && versionIds.contains(model.getVersionId())) { + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("name", model.getName()); + object.put("versionId", model.getVersionId()); + object.put("method", model.getMethodId()); + object.put("date", model.getPublishDate() == null ? "" : model.getPublishDate()); + String taskId = pHistory.getLastPublishTaskIdByModelId(model.getId()); + object.put("taskId", taskId == null ? "" : taskId); + array.add(object); + index++; + break; + } + } + } + //将sort为0的数据放在数组的末尾 + for (JSONObject data:list1) { + if (limit && index >= c) break; + List temps = PALRepositoryCache.getByVersionId(data.getString("wsId"), data.getString("plversionId")); + if (temps == null || temps.size() == 0) continue; + for (PALRepositoryModel model : temps) { + if (model.isPublish() && versionIds.contains(model.getVersionId())) { + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("name", model.getName()); + object.put("versionId", model.getVersionId()); + object.put("method", model.getMethodId()); + object.put("date", model.getPublishDate() == null ? "" : model.getPublishDate()); + String taskId = pHistory.getLastPublishTaskIdByModelId(model.getId()); + object.put("taskId", taskId == null ? "" : taskId); + array.add(object); + index++; + break; + } + } + } + } + } + result.put("data", array); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.xpages.common.html", result); + } + + /** + * 高频流程查询 + * @param uc + * @param count + * @return + */ + public String frequencyProcessQuery(UserContext uc, String count) { + String category = "process"; + Map result = new HashMap(); + result.put("sid", uc.getSessionId()); + result.put("uid", uc.getUID()); + JSONObject param = getXPagesBasicParam(uc, count); + String roleId = param.getString("roleId"); + boolean limit = param.getBooleanValue("limit"); + int c = param.getIntValue("c"); + + JSONArray array = new JSONArray(); + // 获取高频流程记录数据 + List> wsList = getPalAndAwsPermRepositoryVersionIdByUser(uc, roleId, category); + if (wsList != null && wsList.size() > 0) { + PublishFrequencyDao frequencyDao = new PublishFrequencyDao(); + StringBuffer wsIds = new StringBuffer(); + String sqlParam = ""; + for (Map map : wsList) { + wsIds.append("'").append(map.get("wsId")).append("'").append(","); + } + if (wsIds.length() > 0) { + sqlParam = wsIds.substring(0, wsIds.length() - 1); + } + Object [] frequencyModels = frequencyDao.getDatasOrderByCount(sqlParam, category); + @SuppressWarnings("unchecked") + List list = (ArrayList) frequencyModels[0];// 按照访问量降序排序的id集合 + JSONObject datas = (JSONObject) frequencyModels[1]; + PublishListHistory pHistory = new PublishListHistory(); + // 获取所有节点 + if (list != null && list.size() > 0) { + PALRepository repositoryDao = new PALRepository(); + Set versionIds = repositoryDao.getRepositoryVersionIdListByPublishRole(roleId, sqlParam, category); + Set repositoryIds = getAwsOrgPermRepositoryByUser(uc, category, true);// aws平台下的资产库流程文件 + for (String str : repositoryIds) { + versionIds.add(PALRepositoryCache.getCache().get(str).getVersionId()); + } + int index = 0; + for (String id : list) { + if (limit && index >= c) break; + JSONObject data = datas.getJSONObject(id); + List temps = PALRepositoryCache.getByVersionId(data.getString("wsId"), data.getString("plversionId")); + if (temps == null || temps.size() == 0) continue; + for (PALRepositoryModel model : temps) { + if (model.isPublish() && versionIds.contains(model.getVersionId())) { + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("name", model.getName()); + object.put("versionId", model.getVersionId()); + object.put("count", data.getString("count")); + object.put("method", model.getMethodId()); + object.put("date", model.getPublishDate() == null ? "" : model.getPublishDate()); + String taskId = pHistory.getLastPublishTaskIdByModelId(model.getId()); + object.put("taskId", taskId == null ? "" : taskId); + array.add(object); + index++; + break; + } + } + } + } + } + result.put("data", array); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.xpages.frequency.html", result); + } + + /** + * 系统、数据、组织、控制模型查询 + * @param count + * @return + */ + public String queryDataBycategory(UserContext uc, String count, String category, String page) { + Map result = new HashMap(); + result.put("sid", uc.getSessionId()); + result.put("uid", uc.getUID()); + JSONObject param = getXPagesBasicParam(uc, count); + String roleId = param.getString("roleId"); + boolean limit = param.getBooleanValue("limit"); + int c = param.getIntValue("c"); + JSONArray array = new JSONArray(); + // 获取系统模型数据 + List> wsList = getPalAndAwsPermRepositoryVersionIdByUser(uc, roleId, category); + if (wsList != null && wsList.size() > 0) { + + StringBuffer wsIds = new StringBuffer(); + String sqlParam = ""; + for (Map map : wsList) { + wsIds.append("'").append(map.get("wsId")).append("'").append(","); + } + if (wsIds.length() > 0) { + sqlParam = wsIds.substring(0, wsIds.length() - 1); + } + int index = 0; + PALRepository dao = new PALRepository(); + List plList = dao.getRepositoryListByPublishRoleAndCategory(roleId, sqlParam, category); + Set repositoryIds = getAwsOrgPermRepositoryByUser(uc, category, true);// aws平台下的资产库流程文件 + // 整合PAL自身权限文件和关联AWS的权限文件 + if (repositoryIds != null && repositoryIds.size() > 0) { + // 整合完成之后重新排序,按照发布时间,层级,顺序排序 + if (plList == null) { + plList = new ArrayList<>(); + } + Set idSet = new HashSet<>(); + for (PALRepositoryModel plModel : plList) { + idSet.add(plModel.getId()); + } + for (String id : repositoryIds) { + if (!idSet.contains(id)) { + plList.add(PALRepositoryCache.getCache().get(id)); + } + } + // 排序 + Collections.sort(plList, new Comparator() { + @Override + public int compare(PALRepositoryModel o1, PALRepositoryModel o2) { + Timestamp p1 = o1.getPublishDate(); + Timestamp p2 = o2.getPublishDate(); + if (!p1.equals(p2)) { + return p2.compareTo(p1); + } + int level1 = o1.getLevel(); + int level2 = o2.getLevel(); + if (level1 != level2) { + return level1 - level2; + } + int order1 = o1.getOrderIndex(); + int order2 = o2.getOrderIndex(); + return order1 - order2; + } + }); + } + if (plList != null && plList.size() > 0) { + for (PALRepositoryModel plModel : plList) { + JSONObject object = new JSONObject(); + object.put("id", plModel.getId()); + object.put("name", plModel.getName()); + object.put("versionId", plModel.getVersionId()); + object.put("date", plModel.getPublishDate() == null ? "" : plModel.getPublishDate()); + object.put("method", plModel.getMethodId()); + object.put("taskId", ""); + array.add(object); + index++; + if (limit && index >= c) { + break; + } + } + } + } + result.put("data", array); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.xpages." + page + ".html", result); + } + + + + /** + * 发布动态 + * @param count + * @return + */ + public String queryNotificationData(UserContext uc, String start, String count) { + Map result = new HashMap(); + result.put("sid", uc.getSessionId()); + result.put("uid", uc.getUID()); + JSONObject param = getXPagesBasicParam(uc, count); + String roleId = param.getString("roleId"); + int startNum = -1; + if (!UtilString.isEmpty(start)) { + startNum = Integer.parseInt(start); + } + int limitNum = 10; + if (!UtilString.isEmpty(count)) { + limitNum = Integer.parseInt(count); + } + JSONArray array = new JSONArray(); + PublishListHistory dao = new PublishListHistory(); + // 获取所有的发布历史 + List modelList = dao.getPublishListHistory(); + if (!isEmpty(modelList)) { + // 获取PAL权限版本ID + PALRepository repository = new PALRepository(); + Set palVersionIds = repository.getPalVersionIdByroleId(roleId); + Set palProcessIds = new HashSet<>(); + for (String versionId : palVersionIds) { + List list = PALRepositoryCache.getByVersionId(versionId); + if (!isEmpty(list)) { + for (PALRepositoryModel model : list) { + palProcessIds.add(model.getId()); + } + } + } + // 获取关联AWS组织的版本ID且当前为已发布 + Set awsProcessIds = getAwsOrgPermRepositoryByUser(uc, null, true); + // 整合所有权限 + for (String id : awsProcessIds) { + String tempVer = PALRepositoryCache.getCache().get(id).getVersionId(); + if (!palProcessIds.contains(tempVer)) { + palProcessIds.add(tempVer); + } + } + int index = 0; + for (PublishListHistoryModel model : modelList) { + if (index >= limitNum) { + break; + } + if (!palProcessIds.contains(model.getPalRepositoryId())) + continue; + PALRepositoryModel repositoryModel = PALRepositoryCache.getCache().get(model.getPalRepositoryId()); + if (repositoryModel == null) { + continue; + } + JSONObject object = new JSONObject(); + String actionType = model.getActionType(); + object.put("type", actionType); + object.put("date", model.getPublishDate()); + String intro = ""; + if ("N".equals(actionType)) { + intro = "新发布"; + } else if ("C".equals(actionType)) { + intro = "变更"; + } else if ("S".equals(actionType)) { + intro = "停用"; + } + object.put("intro", intro); + object.put("method", repositoryModel.getMethodId()); + object.put("desc", model.getPublishDesc()); + object.put("pid", model.getpId()); + PublishHistoryModel pModel = PublishHistoryCache.getModel(model.getpId()); + object.put("pDesc", pModel.getPublishDesc()); + object.put("id", model.getPalRepositoryId()); + object.put("name", repositoryModel.getName()); + object.put("version", repositoryModel.getVersion() + ".0"); + object.put("isPublish", repositoryModel.isPublish() ? "1" : "0"); + String taskId = model.getTaskId(); + object.put("taskId", taskId == null ? "" : taskId); + array.add(object); + index ++; + } + } + result.put("data", array); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.xpages.notification.html", result); + } + + /** + * xpages配置流程地图时查询资产库列表和平台单位列表 + * @param uc + * @return + */ + public String processmapWsAndOrgDataQuery(UserContext uc) { + ResponseObject ro = ResponseObject.newOkResponse(); + // 获取启用中的资产库 + List wsList = CoeWorkSpaceDaoFactory.createCoeWorkSpace().getCoeWorkSpaceModelRecodesNoPage(); + JSONArray wsArray = new JSONArray(); + if (!isEmpty(wsList)) { + for (CoeWorkSpaceModel ws : wsList) { + if (ws.getWsState() == 0) { + JSONObject object = new JSONObject(); + object.put("text", ws.getWsName()); + object.put("id", ws.getUUId()); + wsArray.add(object); + } + } + } + // 获取未注销的平台单位 + List cList = SDK.getORGAPI().getCompanys(); + JSONArray orgArray = new JSONArray(); + if (!isEmpty(cList)) { + for (CompanyModel company: cList) { + JSONObject object = new JSONObject(); + object.put("text", company.getName()); + object.put("id", company.getId()); + orgArray.add(object); + } + } + ro.put("wsData", wsArray); + ro.put("orgData", orgArray); + return ro.toString(); + } + + /** + * 流程地图 + * @param orgId + * @param wsId + * @return + */ + public String queryProcessmapData(UserContext uc, String wsId, String orgId) { + Map result = new HashMap(); + result.put("sid", uc.getSessionId()); + result.put("uid", uc.getUID()); + JSONObject param = getXPagesBasicParam(uc, null); + String roleId = param.getString("roleId"); + // 获取资产库一级流程 + List> wsList = getPalAndAwsPermRepositoryVersionIdByUser(uc, roleId, "process"); + // wsId在wsList内则取wsId,不在则取wsList中第一个元素 + if (wsList != null && wsList.size() > 0) { + Set wsIds = new HashSet<>(); + for (Map map : wsList) { + wsIds.add(map.get("wsId")); + } + if (UtilString.isEmpty(wsId) || !wsIds.contains(wsId)) { + wsId = wsList.get(0).get("wsId"); + } + } + // 获取三个一级流程 + JSONArray processData = getUsedModelsByPid(roleId, wsId, "process"); + result.put("processData", processData); + + // 获取组织架构 + List orgList = SDK.getORGAPI().getCompanys(); + if (orgList != null && orgList.size() > 0) { + Set orgIds = new HashSet<>(); + for (int i = 0; i < orgList.size(); i++) { + if (orgList.get(i).isClosed()) { + continue; + } + orgIds.add(orgList.get(i).getId()); + } + if (UtilString.isEmpty(orgId) || !orgIds.contains(orgId)) { + orgId = orgList.get(0).getId(); + } + } + // 获取三个部门 + JSONArray deptData = getDeptsByCompany(orgId); + result.put("deptData", deptData); + result.put("wsId", wsId); + result.put("orgId", orgId); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.xpages.processmap.html", result); + } + + /** + * 获取3个一级部门 + * @param orgId + * @return + */ + private JSONArray getDeptsByCompany(String orgId) { + JSONArray result = new JSONArray(); + List list = SDK.getORGAPI().getDepartmentsByCompanyId(1, orgId); + int index = 0; + for (DepartmentModel model : list) { + if (model.isClosed()) { + continue; + } + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("name", model.getName()); + result.add(object); + index++; + if (index >= 3) { + break; + } + } + return result ; + } + + // 当同一个version流程存在已发布和使用中的,过滤掉使用中的 + private List filterPublisherData(List list) { + if (list != null && list.size() > 0) { + List tempList = new ArrayList<>(); + Set idSet = new HashSet<>(); + for (PALRepositoryModel model : list) { + if (model.isPublish()) { + idSet.add(model.getVersionId()); + tempList.add(model); + } + } + for (PALRepositoryModel model : list) { + if (model.isUse() && !idSet.contains(model.getVersionId())) { + tempList.add(model); + } + } + list = tempList; + } + return list; + } + + /** + * 获取3个一级流程 + * @param wsId + * @param parentId + * @return + */ + private JSONArray getUsedModelsByPid(String roleId, String wsId, String parentId) { + JSONArray result = new JSONArray(); + if (!UtilString.isEmpty(wsId)) { + @SuppressWarnings("unchecked") + List list = IteratorUtils.toList(PALRepositoryCache.getByPid(wsId, "process")); + list = filterPublisherData(list); + if (list != null && list.size() > 0) { + // 排列 + Collections.sort(list, new Comparator() { + @Override + public int compare(PALRepositoryModel o1, PALRepositoryModel o2) { + return o1.getOrderIndex() > o2.getOrderIndex() ? 1 : o1.getOrderIndex() < o2.getOrderIndex() ? -1 : 0; + } + }); + PALRepository dao = new PALRepository(); + Set idSet = dao.getRepositoryVersionIdListByPublishRole(roleId, "'" + wsId + "'", "process"); + Set relationAwsIdSet = getAwsOrgPermRepositoryByUser(_uc, "process", true); + if (relationAwsIdSet != null && relationAwsIdSet.size() > 0) { + for (String awsId : relationAwsIdSet) { + idSet.add(awsId); + } + } + int index = 0; + for (PALRepositoryModel model : list) { + boolean flag = false; + if (model.isPublish() && idSet.contains(model.getVersionId())) { + flag = true; + } else { + Set ids = new HashSet<>(); + List subList = new ArrayList<>(); + PALRepositoryCache.getAllChildrenModelsByPid(wsId, model.getId(), subList, ids); + if (subList != null && subList.size() > 0) { + for (PALRepositoryModel subModel : subList) { + if (subModel.isPublish() && idSet.contains(subModel.getVersionId())) { + flag = true; + break; + } + } + } + } + if (flag) { + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("name", model.getName()); + result.add(object); + index++; + } + if (index >= 3) { + break; + } + } + } + } + return result; + } + + /** + * 搜索 + * @param uc + * @param text 搜索文本 + * @param type 类型 + * @param templateId xpagesId + * @param wsId 默认展示的流程资产库id + * @return + */ + public String search(UserContext uc, String text, String type, String templateId, String wsId) { + Map result = new HashMap(); + result.put("sid", uc.getSessionId()); + result.put("uid", uc.getUID()); + result.put("text", text); + result.put("type", type); + result.put("templateId", templateId); + JSONObject param = getXPagesBasicParam(uc, null); + String roleId = param.getString("roleId"); + // List> wsList = getPermRepositoryVersionIdByUser(uc, roleId); + List> wsList = getPalAndAwsPermRepositoryVersionIdByUser(uc, roleId, null); + JSONArray ws = new JSONArray(); + if (wsList != null && wsList.size() > 0) { + for (int i = 0; i < wsList.size(); i++) { + JSONObject object = new JSONObject(); + object.put("id", wsList.get(i).get("wsId")); + object.put("text", wsList.get(i).get("wsName")); + if(wsId!=null && wsId.equals(wsList.get(i).get("wsId"))) { + object.put("initDisplay", "1"); //默认使用的流程资产库 + } else { + object.put("initDisplay", "0"); + } + ws.add(object); + } + } + result.put("ws", ws); + + JSONArray scope = new JSONArray(); + JSONObject object = new JSONObject(); + object.put("name", "已发布文件"); + object.put("type", "all"); + scope.add(object); + + // alsp获取xpages数据 + // 调用App + String sourceAppId = PublisherConf.APPID; + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.addons.xpages/queryCwListByTemplateId"; + // 参数定义列表 + Map params = new HashMap(); + //模板id,必填 + params.put("templateId", templateId); + params.put("sid", uc.getSessionId()); + AppAPI appAPI = SDK.getAppAPI(); + //查询模板信息 + ResponseObject xpagesList = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + JSONObject data = JSONObject.parseObject(xpagesList.toDataString()); + JSONArray cwList = data.getJSONArray("cwList"); + for (int i = 0; i < cwList.size(); i++) { + JSONObject obj = cwList.getJSONObject(i).getJSONArray("subList").getJSONObject(0); + JSONObject obj2 = new JSONObject(); + if (obj.getString("cwUrl").contains("com.actionsoft.apps.publisher_xpages_banner_msg")) { + continue; + } + obj2.put("name", obj.getString("cwName")); + String url = obj.getString("cwUrl"); + if (!url.contains("com.actionsoft.apps.publisher_xpages_")) {// 识别PAL流程发布默认的xpages + continue; + } + String type2 = url.substring(url.indexOf("xpages_") + 7, url.indexOf("_msg")); + obj2.put("type", type2); + scope.add(obj2); + } + result.put("scope", scope); + JSONObject logoObject = getLogoImgPath(uc); + result.put("logoImgPath", logoObject.getString("src")); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.search.html", result); + } + + /** + * 查询数据 + * @param searchText + * @param searchType + * @param searchWsId + * @param start + * @param pageLimit + * @return + */ + public String searchData(UserContext uc, String searchText, String searchType, String searchWsId, int start, int pageLimit) { + JSONObject param = getXPagesBasicParam(uc, null); + String roleId = param.getString("roleId"); + String wsIdsql = ""; + if (UtilString.isEmpty(searchWsId)) { + // List> wsList = getPermRepositoryVersionIdByUser(uc, roleId); + List> wsList = getPalAndAwsPermRepositoryVersionIdByUser(uc, roleId, null); + if (wsList != null && wsList.size() > 0) { + StringBuffer wsIds = new StringBuffer(); + for (Map map : wsList) { + wsIds.append("'").append(map.get("wsId")).append("'").append(","); + } + if (wsIds.length() > 0) { + wsIdsql = wsIds.substring(0, wsIds.length() - 1); + } + } + } else { + wsIdsql = "'" + searchWsId + "'"; + } + switch (searchType) { + case "all":// 已发布文件 + return getAllPublishedData(searchText, wsIdsql, roleId, start, pageLimit, null); + case "common":// 常用流程 + return getPublishedCommonData(searchText, wsIdsql, roleId, start, pageLimit, "process"); + case "frequency":// 高频流程 + return getPublishedFrequencyData(searchText, wsIdsql, roleId, start, pageLimit, "process"); + case "system":// 系统地图 + return getAllPublishedData(searchText, wsIdsql, roleId, start, pageLimit, "itsystem"); + case "data":// 数据地图 + return getAllPublishedData(searchText, wsIdsql, roleId, start, pageLimit, "data"); + case "control":// 控制地图 + return getAllPublishedData(searchText, wsIdsql, roleId, start, pageLimit, "control"); + case "org":// 组织地图 + return getAllPublishedData(searchText, wsIdsql, roleId, start, pageLimit, "org"); + case "processmap":// 流程地图 + return getAllPublishedData(searchText, wsIdsql, roleId, start, pageLimit, "process"); + default:// 通知公告 + return getPublishNotificationData(searchText, wsIdsql, roleId, start, pageLimit, null); + } + } + + private String getPublishNotificationData(String searchText, String wsIdsql, String roleId, int start, int pageLimit, String category) { + ResponseObject ro = ResponseObject.newOkResponse(); + PublishListHistory dao = new PublishListHistory(); + List modelList = dao.getPublishListHistoryByRole(roleId, null, wsIdsql, searchText); + + // 获取PAL权限版本ID + PALRepository repository = new PALRepository(); + Set palVersionIds = repository.getPalVersionIdByroleId(roleId); + Set palProcessIds = new HashSet<>(); + for (String versionId : palVersionIds) { + List list = PALRepositoryCache.getByVersionId(versionId); + if (!isEmpty(list)) { + for (PALRepositoryModel model : list) { + palProcessIds.add(model.getId()); + } + } + } + // 获取关联AWS组织的版本ID且当前为已发布 + Set awsProcessIds = getAwsOrgPermRepositoryByUser(_uc, null, true); + // 整合所有权限 + for (String id : awsProcessIds) { + String tempVer = PALRepositoryCache.getCache().get(id).getVersionId(); + if (!palProcessIds.contains(tempVer)) { + palProcessIds.add(tempVer); + } + } + + // 过滤最终结果 + List list = new ArrayList<>(); + for (JSONObject object : modelList) { + String repositoryId = object.getString("repositoryId"); + if (palProcessIds.contains(repositoryId)) { + list.add(object); + } + } + List subList = null; + int end = start + pageLimit; + if (start > list.size() - 1) { + subList = new ArrayList<>(); + } else if (list.size() >= end) { + subList = list.subList(start, end); + } else { + subList = list.subList(start, list.size()); + } + JSONArray result = new JSONArray(); + for (JSONObject object : subList) { + JSONObject object2 = new JSONObject(); + String repositoryId = object.getString("repositoryId"); + PALRepositoryModel palModel = PALRepositoryCache.getCache().get(repositoryId); + object2.put("id", palModel.getId()); + object2.put("version", palModel.getVersion()); + String userName = ""; + if (UserCache.getModel(object.getString("userId")) != null) { + userName = UserCache.getModel(object.getString("userId")).getUserName(); + } + + String actionType = object.getString("actionType"); + String intro = ""; + switch (actionType) { + case "N": + intro = "新发布"; + break; + case "C": + intro = "变更"; + break; + default:// S + intro = "停用"; + break; + } + object2.put("name", palModel.getName() + "[" + intro + "]"); + object2.put("user", userName); + object2.put("dept", getDeptPath(object.getString("userId"))); + object2.put("date", object.getTimestamp("publishDate")); + object2.put("desc", object.getString("publishDesc")); + object2.put("isPublish", palModel.isPublish() ? "1" : "0"); + object2.put("taskId", object.containsKey("taskId") ? object.getString("taskId") : ""); + // 获取路径 + StringBuilder sBuilder = new StringBuilder();// 名称组合 + Set idSets = new HashSet<>();// id记录,校验防止递归死循环 + sBuilder.append(palModel.getName()); + idSets.add(palModel.getId()); + getFilePath(palModel, sBuilder,idSets);// 递归获取当前文件名称路径 + object2.put("path", sBuilder.toString()); + result.add(object2); + } + ro.put("data", result); + ro.put("count", result.size()); + return ro.toString(); + } + + /** + * 获取部门路径 + * @param userId + * @return + */ + private String getDeptPath(String userId) { + StringBuilder sBuilder = new StringBuilder();// 名称组合 + Set idSets = new HashSet<>();// id记录,校验防止递归死循环 + if (!UtilString.isEmpty(userId)) { + DepartmentModel model = SDK.getORGAPI().getDepartmentByUser(userId); + sBuilder.append(model.getName()); + idSets.add(model.getId()); + getDeptPath(model, sBuilder, idSets); + } + return sBuilder.toString(); + } + + private void getDeptPath(DepartmentModel model, StringBuilder sBuilder, Set idSets) { + if (!"0".equals(model.getId())) { + if (!idSets.contains(model.getParentDepartmentId())) { + String parentId = model.getParentDepartmentId(); + DepartmentModel parentModel = SDK.getORGAPI().getDepartmentById(parentId); + if (parentModel != null) { + sBuilder.insert(0, parentModel.getName() + ">"); + idSets.add(parentModel.getId()); + getDeptPath(parentModel, sBuilder, idSets); + } + } + } else { + sBuilder.insert(0, model.getName() + ">"); + } + } + + // 获取高频流程列表 + private String getPublishedFrequencyData(String searchText, String wsIdsql, String roleId, int start, int pageLimit, String category) { + ResponseObject ro = ResponseObject.newOkResponse(); + PALRepository dao = new PALRepository(); + List list = dao.getRepositoryFrequencyListByPublishRole(wsIdsql, roleId, searchText, category); + if (list == null) { + list = new ArrayList<>(); + } + Set idSet = new HashSet<>(); + for (PALRepositoryModel model : list) { + idSet.add(model.getId()); + } + // 添加关联aws组织的流程进行合并 + boolean flag = false; + Set awsProcessIds = getAwsOrgPermRepositoryByUser(_uc, category, true); + if (awsProcessIds != null && awsProcessIds.size() > 0) { + for (String processId : awsProcessIds) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(processId); + if (model != null && wsIdsql.indexOf(model.getWsId()) > -1 && !idSet.contains(model.getId()) && model.getName().indexOf(searchText) > -1) { + list.add(model); + idSet.add(model.getId()); + flag = true; + } + } + } + if (flag) {// 合并过数据则需要重新排序 + // 排序 + Collections.sort(list, new MyComparator()); + } + List subList = null; + int end = start + pageLimit; + if (start > list.size() - 1) { + subList = new ArrayList<>(); + } else if (list.size() >= end) { + subList = list.subList(start, end); + } else { + subList = list.subList(start, list.size()); + } + JSONArray result = assembleData(subList); + ro.put("data", result); + ro.put("count", result.size()); + return ro.toString(); + } + + // 获取常用流程列表 + private String getPublishedCommonData(String searchText, String wsIdsql, String roleId, int start, int pageLimit, String category) { + ResponseObject ro = ResponseObject.newOkResponse(); + PALRepository dao = new PALRepository(); + // List list = dao.getRepositoryCommonListByPublishRolePagination(wsIdsql, roleId, searchText, start, pageLimit, category); + List list = dao.getRepositoryCommonListByPublishRole(wsIdsql, roleId, searchText, category); + if (list == null) { + list = new ArrayList<>(); + } + Set idSet = new HashSet<>(); + for (PALRepositoryModel model : list) { + idSet.add(model.getId()); + } + // 添加关联aws组织的流程进行合并 + boolean flag = false; + Set awsProcessIds = getAwsOrgPermRepositoryByUser(_uc, category, true); + if (awsProcessIds != null && awsProcessIds.size() > 0) { + for (String processId : awsProcessIds) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(processId); + if (model != null && wsIdsql.indexOf(model.getWsId()) > -1 && !idSet.contains(model.getId()) && model.getName().indexOf(searchText) > -1) { + list.add(model); + idSet.add(model.getId()); + flag = true; + } + } + } + if (flag) {// 合并过数据则需要重新排序 + // 排序 + Collections.sort(list, new MyComparator()); + } + List subList = null; + int end = start + pageLimit; + if (start > list.size() - 1) { + subList = new ArrayList<>(); + } else if (list.size() >= end) { + subList = list.subList(start, end); + } else { + subList = list.subList(start, list.size()); + } + JSONArray result = assembleData(subList); + ro.put("data", result); + ro.put("count", result.size()); + return ro.toString(); + } + + // 获取已发布文件列表 + private String getAllPublishedData(String searchText, String wsIdsql, String roleId, int start, int pageLimit, String category) { + ResponseObject ro = ResponseObject.newOkResponse(); + PALRepository dao = new PALRepository(); + List list = dao.getRepositoryListByPublishRole(wsIdsql, roleId, searchText, category); + if (list == null) { + list = new ArrayList<>(); + } + Set idSet = new HashSet<>(); + for (PALRepositoryModel model : list) { + idSet.add(model.getId()); + } + // 添加关联aws组织的流程进行合并 + boolean flag = false; + Set awsProcessIds = getAwsOrgPermRepositoryByUser(_uc, category, true); + if (awsProcessIds != null && awsProcessIds.size() > 0) { + for (String processId : awsProcessIds) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(processId); + if (model != null && wsIdsql.indexOf(model.getWsId()) > -1 && !idSet.contains(model.getId()) && model.getName().indexOf(searchText) > -1) { + list.add(model); + idSet.add(model.getId()); + flag = true; + } + } + } + if (flag) {// 合并过数据则需要重新排序 + // 排序 + Collections.sort(list, new MyComparator()); + } + List subList = null; + int end = start + pageLimit; + if (start > list.size() - 1) { + subList = new ArrayList<>(); + } else if (list.size() >= end) { + subList = list.subList(start, end); + } else { + subList = list.subList(start, list.size()); + } + JSONArray result = assembleData(subList); + ro.put("data", result); + ro.put("count", result.size()); + return ro.toString(); + } + + private class MyComparator implements Comparator { + @Override + public int compare(PALRepositoryModel o1, PALRepositoryModel o2) { + Timestamp p1 = o1.getPublishDate(); + Timestamp p2 = o2.getPublishDate(); + if (p1 != null && p2 != null) { + if (!p1.equals(p2)) { + return p2.compareTo(p1); + } + } + int level1 = o1.getLevel(); + int level2 = o2.getLevel(); + if (level1 != level2) { + return level1 - level2; + } + int order1 = o1.getOrderIndex(); + int order2 = o2.getOrderIndex(); + return order1 - order2; + } + } + + // 查询发布信息,拼接结果json + private JSONArray assembleData(List list) { + PublishListHistory pHistory = new PublishListHistory(); + JSONArray result = new JSONArray(); + // 获取已发布分页数据 + for (int i = 0; i < list.size(); i++) { + PALRepositoryModel model = list.get(i); + JSONObject object = pHistory.getLastPublishByModelId(model.getId()); + JSONObject object2 = new JSONObject(); + if (object != null) { + String userId = object.getString("userId"); + String userName = ""; + if (UserCache.getModel(userId) != null) { + userName = UserCache.getModel(userId).getUserName(); + } + object2.put("user", userName); + object2.put("dept", getDeptPath(userId)); + object2.put("date", object.getTimestamp("date")); + object2.put("desc", UtilString.isEmpty(object.getString("desc")) ? "" : object.getString("desc")); + object2.put("taskId", object.containsKey("taskId") ? object.getString("taskId") : ""); + } else { + object2.put("user", ""); + object2.put("dept", ""); + object2.put("date", ""); + object2.put("desc", ""); + object2.put("taskId", ""); + } + object2.put("id", model.getId()); + object2.put("name", model.getName()); + object2.put("version", model.getVersion()); + + // 获取路径 + StringBuilder sBuilder = new StringBuilder();// 名称组合 + Set idSets = new HashSet<>();// id记录,校验防止递归死循环 + sBuilder.append(model.getName()); + idSets.add(model.getId()); + getFilePath(model, sBuilder,idSets);// 递归获取当前文件名称路径 + object2.put("path", sBuilder.toString()); + result.add(object2); + } + return result; + } + + /** + * 获取文件名称全路径 + * @param model + * @return + */ + private void getFilePath(PALRepositoryModel model, StringBuilder sBuilder, Set idSets) { + if (model.getParentId().length() == 36) { + if (!idSets.contains(model.getParentId())) { + String parentId = model.getParentId(); + PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(parentId); + if (parentModel != null) { + sBuilder.insert(0, parentModel.getName() + ">"); + idSets.add(parentModel.getId()); + getFilePath(parentModel, sBuilder, idSets); + } + } + } else { + sBuilder.insert(0, I18nRes.findValue(CoEConstant.APP_ID, model.getParentId()) + ">"); + } + } + + /** + * 打开流程地图 + * @param wsId + * @param orgId + * @param type + * @return + */ + public String openProcessMapPage(UserContext uc, String wsId, String orgId, String type) { + Map macroLibraries = getHomePage2(uc); + macroLibraries.put("wsId", wsId); + // 获取权限资产库列表 + JSONObject param = getXPagesBasicParam(uc, null); + String roleId = param.getString("roleId"); + List> wsList = getPalAndAwsPermRepositoryVersionIdByUser(uc, roleId, "process"); + // List> wsList = getPermRepositoryVersionIdByUser(uc, roleId); + JSONArray ws = new JSONArray(); + if (wsList != null && wsList.size() > 0) { + for (int i = 0; i < wsList.size(); i++) { + JSONObject object = new JSONObject(); + object.put("id", wsList.get(i).get("wsId")); + object.put("text", wsList.get(i).get("wsName")); + ws.add(object); + } + } + macroLibraries.put("ws", ws); + // 在里面则返回名称,不在里面返回空 + macroLibraries.put("orgId", orgId); + // 获取单位列表 + JSONArray org = new JSONArray(); + List orgList = SDK.getORGAPI().getCompanys(); + if (orgList != null && orgList.size() > 0) { + for (int i = 0; i < orgList.size(); i++) { + if (orgList.get(i).isClosed()) { + continue; + } + JSONObject object = new JSONObject(); + object.put("id", orgList.get(i).getId()); + object.put("text", orgList.get(i).getName()); + org.add(object); + } + } + macroLibraries.put("org", org); + macroLibraries.put("type", type); + JSONObject object = getLogoImgPath(uc); + macroLibraries.put("logoImgPath", object.getString("src")); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.sso.processmap.html", macroLibraries); + } + + /** + * 业务架构页面 + * @param me + * @param wsId + * @return + */ + public String openProcessMapWsPage(UserContext me, String wsId) { + JSONObject param = getXPagesBasicParam(me, null); + String roleId = param.getString("roleId"); + Map macroLibraries = new HashMap<>(); + macroLibraries.put("sid", me.getSessionId()); + macroLibraries.put("uid", me.getUID()); + macroLibraries.put("wsId", wsId); + JSONArray firstLevel = new JSONArray(); + JSONObject secendLevel = new JSONObject(); + if (!UtilString.isEmpty(wsId)) { + @SuppressWarnings("unchecked") + List list = IteratorUtils.toList(PALRepositoryCache.getByPid(wsId, "process")); + list = filterPublisherData(list); + if (list != null && list.size() > 0) { + Collections.sort(list, new Comparator() { + @Override + public int compare(PALRepositoryModel o1, PALRepositoryModel o2) { + return o1.getOrderIndex() > o2.getOrderIndex() ? 1 : o1.getOrderIndex() < o2.getOrderIndex() ? -1 : 0; + } + }); + PALRepository dao = new PALRepository(); + Set idSet = dao.getRepositoryVersionIdListByPublishRole(roleId, "'" + wsId + "'", "process"); + Set relationAwsIdSet = getAwsOrgPermRepositoryByUser(_uc, "process", true); + if (relationAwsIdSet != null && relationAwsIdSet.size() > 0) { + for (String awsId : relationAwsIdSet) { + idSet.add(awsId); + } + } + for (PALRepositoryModel model : list) { + boolean flag = false; + if (model.isPublish() && idSet.contains(model.getVersionId())) { + flag = true; + } else { + Set ids = new HashSet<>(); + List subList = new ArrayList<>(); + PALRepositoryCache.getAllChildrenModelsByPid(wsId, model.getId(), subList, ids); + if (subList != null && subList.size() > 0) { + for (PALRepositoryModel subModel : subList) { + if (subModel.isPublish() && idSet.contains(subModel.getVersionId())) { + flag = true; + break; + } + } + } + } + if (flag) { + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("versionId", model.getVersionId()); + object.put("name", model.getName()); + object.put("canOpen", idSet.contains(model.getVersionId())); + object.put("isPublish", model.isPublish()); + object.put("method", model.getMethodId()); + firstLevel.add(object); + } + } + + for (int i = 0; i < firstLevel.size(); i++) { + JSONObject firstObject = firstLevel.getJSONObject(i); + getPublishAndRoleChildModel(wsId, idSet, firstObject.getString("versionId"), secendLevel); + } + } + } + macroLibraries.put("firstLevelData", firstLevel); + macroLibraries.put("secendLevelData", secendLevel); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.sso.processmap.ws.html", macroLibraries); + } + + /** + * 获取子级节点 + * @param wsId + * @param filterSet + * @param version + * @param result + */ + private void getPublishAndRoleChildModel(String wsId, Set filterSet, String version, JSONObject result) { + List secendList = PALRepositoryCache.getAllSubModelsByPid(wsId, version); + secendList.sort((o1, o2)-> {return o1.getOrderIndex() > o2.getOrderIndex() ? 1 : o1.getOrderIndex() < o2.getOrderIndex() ? -1 : 0;}); + Set useVersionIds = new HashSet<>(); + List publishVersionIds = new ArrayList<>(); + JSONArray secendArr = new JSONArray(); + for (PALRepositoryModel model : secendList) { + if (model.isUse()) { + useVersionIds.add(model.getVersionId()); + } + if (model.isPublish()) { + publishVersionIds.add(model.getVersionId()); + } + } + for (String str : useVersionIds) { + if (!publishVersionIds.contains(str)) { + publishVersionIds.add(str); + } + } + for (String versionId : publishVersionIds) { + boolean flag = false; + PALRepositoryModel model = null;// = PALRepositoryCache.getCache().get(versionId); + List models = PALRepositoryCache.getByVersionId(wsId, versionId); + if (models != null && models.size() > 0) { + PALRepositoryModel temp = null; + for (PALRepositoryModel obj : models) { + if (obj.isPublish()) { + temp = obj; + break; + } + } + if (temp == null) { + for (PALRepositoryModel obj : models) { + if (obj.isUse()) { + temp = obj; + } + } + } + model = temp; + } + + if (model != null) { + flag = checkCanShow(wsId, filterSet, flag, model); + } + if (flag) { + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("versionId", model.getVersionId()); + object.put("name", model.getName()); + object.put("canOpen", filterSet.contains(model.getVersionId())); + object.put("child", checkChild(wsId, filterSet, false, model)); + object.put("isPublish", model.isPublish()); + secendArr.add(object); + } + } + result.put(version, secendArr); + } + + /** + * 判断是否有子流程并且有其权限 + * @param wsId + * @param filterSet + * @param flag + * @param model + * @return + */ + private boolean checkChild(String wsId, Set filterSet, boolean flag, PALRepositoryModel model) { + Set ids = new HashSet<>(); + List subList = new ArrayList<>(); + PALRepositoryCache.getAllChildrenModelsByPid(wsId, model.getId(), subList, ids); + if (subList != null && subList.size() > 0) { + for (PALRepositoryModel subModel : subList) { + if (subModel.isPublish() && filterSet.contains(subModel.getVersionId())) { + flag = true; + break; + } + } + } + return flag; + } + + /** + * 查看当前流程是否能显示 + * 判断条件:1.当前流程已发布且有权限;2.当前流程的所有子流程存在发布且其有权限查看 + * @param wsId + * @param filterSet + * @param flag + * @return + */ + private boolean checkCanShow(String wsId, Set filterSet, boolean flag, PALRepositoryModel model) { + if (model.isPublish() && filterSet.contains(model.getVersionId())) { + flag = true; + } else { + flag = checkChild(wsId, filterSet, flag, model); + } + return flag; + } + + /** + * 组织架构页面 + * @param me + * @param orgId + * @return + */ + public String openProcessMapOrgPage(UserContext me, String orgId) { + Map macroLibraries = new HashMap<>(); + macroLibraries.put("sid", me.getSessionId()); + macroLibraries.put("uid", me.getUID()); + macroLibraries.put("orgId", orgId); + JSONArray firstLevel = new JSONArray(); + JSONObject secendLevel = new JSONObject(); + if (!UtilString.isEmpty(orgId)) { + List list = SDK.getORGAPI().getDepartmentsByCompanyId(1, orgId); + if (list != null && list.size() > 0) { + // 获取单位下一级部门 + for (DepartmentModel model : list) { + if (model.isClosed()) { + continue; + } + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("name", model.getName()); + boolean isExistSub = SDK.getORGAPI().isExistSubDepartment(model.getId()); + object.put("child", isExistSub); + firstLevel.add(object); + // 获取一级部门下的二级部门 + if (isExistSub) { + List subList = SDK.getORGAPI().getSubDepartments(model.getId()); + JSONArray subArray = new JSONArray(); + if (subList != null && subList.size() > 0) { + for (DepartmentModel subModel : subList) { + if (subModel.isClosed()) { + continue; + } + JSONObject object2 = new JSONObject(); + object2.put("id", subModel.getId()); + object2.put("name", subModel.getName()); + boolean isExistSub2 = SDK.getORGAPI().isExistSubDepartment(subModel.getId()); + object2.put("child", isExistSub2); + subArray.add(object2); + } + } + secendLevel.put(model.getId(), subArray); + } + } + + } + } + macroLibraries.put("firstLevelData", firstLevel); + macroLibraries.put("secendLevelData", secendLevel); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.sso.processmap.org.html", macroLibraries); + } + + /** + * 业务架构展开 + * @param me + * @param id + * @param wsId + * @return + */ + public String expendProcessMapWsData(UserContext me, String id, String wsId) { + ResponseObject ro = ResponseObject.newOkResponse(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model == null) { + throw new AWSException("该流程不存在,请刷新重试"); + } + JSONObject param = getXPagesBasicParam(me, null); + String roleId = param.getString("roleId"); + PALRepository dao = new PALRepository(); + Set idSet = dao.getRepositoryVersionIdListByPublishRole(roleId, "'" + wsId + "'", "process"); + Set relationAwsIdSet = getAwsOrgPermRepositoryByUser(_uc, "process", true); + if (relationAwsIdSet != null && relationAwsIdSet.size() > 0) { + for (String awsId : relationAwsIdSet) { + idSet.add(awsId); + } + } + JSONObject nextLevel = new JSONObject(); + getPublishAndRoleChildModel(wsId, idSet, model.getVersionId(), nextLevel); + ro.put("data", nextLevel.get(model.getVersionId())); + return ro.toString(); + } + + /** + * 打开文件时的权限和类型校验 + * @param me + * @param id + * @param wsId + * @return + */ + public String openProcessMapWsDataCheck(UserContext me, String id, String wsId) { + ResponseObject ro = ResponseObject.newOkResponse(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model == null) { + throw new AWSException("该流程不存在,请刷新重试"); + } + if (UtilString.isEmpty(wsId)) { + wsId = model.getWsId(); + } + String status = "ok"; + if ("default".equals(model.getMethodId())) { + status = "typeError"; + } + if (!model.isPublish()) { + status = "notPublish"; + } + if (!"ok".equals(status)) {// 避免后续查询 + ro.put("status", status); + return ro.toString(); + } + JSONObject param = getXPagesBasicParam(me, null); + String roleId = param.getString("roleId"); + PALRepository dao = new PALRepository(); + Set idSet = dao.getRepositoryVersionIdListByPublishRole(roleId, "'" + wsId + "'", "process"); + Set relationAwsIdSet = getAwsOrgPermRepositoryByUser(_uc, "process", true); + if (relationAwsIdSet != null && relationAwsIdSet.size() > 0) { + for (String awsId : relationAwsIdSet) { + idSet.add(awsId); + } + } + if (!idSet.contains(model.getVersionId())) { + status = "noPerm"; + } + ro.put("status", status); + return ro.toString(); + } + + /** + * 组织架构展开 + * @param me + * @param id 部门id + * @param orgId 单位id + * @return + */ + + public String expendProcessMapOrgData(UserContext me, String id, String orgId) { + ResponseObject ro = ResponseObject.newOkResponse(); + DepartmentModel model = SDK.getORGAPI().getDepartmentById(id); + if (model == null) { + throw new AWSException("该部门不存在,请刷新重试"); + } + JSONArray data = new JSONArray(); + List list = SDK.getORGAPI().getSubDepartments(id); + if (list != null && list.size() > 0) { + for (DepartmentModel subModel : list) { + if (subModel.isClosed()) { + continue; + } + JSONObject object = new JSONObject(); + object.put("id", subModel.getId()); + object.put("name", subModel.getName()); + boolean isExistSub = SDK.getORGAPI().isExistSubDepartment(subModel.getId()); + object.put("child", isExistSub); + data.add(object); + } + } + ro.put("data", data); + return ro.toString(); + } + + /** + * 查询组织架构中部门流程 + * @param me + * @param deptId + * @return + */ + public String openProcessMapOrgDeptDialog(UserContext me, String deptId) { + Map macroLibraries = new HashMap<>(); + macroLibraries.put("sid", me.getSessionId()); + macroLibraries.put("uid", me.getUID()); + macroLibraries.put("deptId", deptId); + DepartmentModel model = SDK.getORGAPI().getDepartmentById(deptId); + JSONArray data = new JSONArray(); + String deptName = ""; + if(model != null) { + deptName = model.getName(); + JSONObject param = getXPagesBasicParam(me, null); + String roleId = param.getString("roleId"); + PALRepository dao = new PALRepository(); + // List list = dao.getRepositoryListByPublishRole(roleId, null, "process", deptId, "default"); + List list = dao.getRepositoryListByPublishRole(roleId, null, "process", null, "default"); + // 查询关联了当前部门的已发布流程 + Set relationDeptIds = getAwsOrgPermRepositoryByDept(_uc, "process", deptId, true); + if (!isEmpty(list)) { + for (PALRepositoryModel pModel : list) { + if (deptId.equals(pModel.getDutyDept()) || relationDeptIds.contains(pModel.getId())) { + JSONObject object = new JSONObject(); + object.put("id", pModel.getId()); + object.put("name", pModel.getName()); + object.put("method", pModel.getMethodId()); + data.add(object); + } + } + } + } + macroLibraries.put("deptName", deptName); + macroLibraries.put("data", data); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.sso.processmap.org.dialog.html", macroLibraries); + } + + // 获取logo图片路径 + private JSONObject getLogoImgPath(UserContext uc) { + JSONObject logo = new JSONObject(); + DCContext logoDcContext = null; + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, "portalTheme"); + if (dcProfile != null) { + logoDcContext = new DCContext(uc, dcProfile, "portal", "logo"); + } + boolean flag1 = false; + if (logoDcContext != null) { + File file = new File(logoDcContext.getPath()); + if (file.exists()) { + File [] files = file.listFiles(); + if (files != null) { + if (files.length > 0) { + for (File file2 : files) { + String src = new DCContext(uc, dcProfile, CoEConstant.APP_ID, "portal", "logo", file2.getName()).getDownloadURL(); + logo.put("src", src); + logo.put("name", file2.getName()); + flag1 = true; + break; + } + } + } + } + } + if (!flag1) { + // 默认PALlogo + logo.put("src", "../apps/"+ CoEConstant.APP_ID +"/img/logo/portal_logo.png"); + logo.put("name", "portal_logo.png"); + } + return logo; + } + + /** + * 轮播图 + * @param uc + * @return + */ + public String queryBannerData(UserContext uc) { + Map result = new HashMap(); + result.put("sid", uc.getSessionId()); + result.put("uid", uc.getUID()); + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, "portalTheme"); + DCContext bannerDcContext = null; + if (dcProfile != null) { + bannerDcContext = new DCContext(_uc, dcProfile, "portal", "banner"); + } + // 轮播图设置 + JSONArray pictures = new JSONArray(); + if (bannerDcContext != null) { + File file = new File(bannerDcContext.getPath()); + if (file.exists()) { + File [] files = file.listFiles(); + if (files != null) { + // 按照名称排序 + List fileList = Arrays.asList(files); + Collections.sort(fileList, new Comparator() { + @Override + public int compare(File o1, File o2) { + if (o1.isDirectory() && o2.isFile()) + return -1; + if (o1.isFile() && o2.isDirectory()) + return 1; + return o1.getName().compareTo(o2.getName()); + } + }); + for (int i = 0; i < fileList.size(); i++) { + File file2 = files[i]; + String src = new DCContext(_uc, dcProfile, CoEConstant.APP_ID, "portal", "banner", file2.getName()).getDownloadURL(); + JSONObject object = new JSONObject(); + object.put("src", src); + object.put("name", file2.getName()); + pictures.add(object); + } + } + } + } + if (pictures.isEmpty()) { + JSONObject object = new JSONObject(); + object.put("src", "../apps/"+ CoEConstant.APP_ID +"/img/portal_banner.jpg"); + object.put("name", "portal_banner"); + pictures.add(object); + } + result.put("bannerImgs", pictures); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.xpages.banner.html", result); + } + + /*********************永辉接口start***************************/ + + // 查询发布信息,拼接结果json + private JSONArray assembleData2(List list) { + PublishListHistory pHistory = new PublishListHistory(); + JSONArray result = new JSONArray(); + for (int i = 0; i < list.size(); i++) { + PALRepositoryModel model = list.get(i); + JSONObject object = pHistory.getLastPublishByModelId(model.getId()); + JSONObject object2 = new JSONObject(); + if (object != null) { + String userId = object.getString("userId"); + String userName = ""; + if (UserCache.getModel(userId) != null) { + userName = UserCache.getModel(userId).getUserName(); + } + object2.put("user", userName); + object2.put("departmentPath", getDeptPath(userId)); + object2.put("publishDate", UtilDate.datetimeFormat(object.getTimestamp("date"))); + object2.put("publishDesc", object.getString("desc")); + } else { + object2.put("user", ""); + object2.put("departmentPath", ""); + object2.put("publishDate", ""); + object2.put("publishDesc", ""); + } + object2.put("id", model.getId()); + object2.put("name", model.getName()); + object2.put("version", "V" + model.getVersion() + ".0"); + object2.put("method", model.getMethodId()); + object2.put("category", model.getMethodCategory()); + + // 获取路径 + StringBuilder sBuilder = new StringBuilder();// 名称组合 + Set idSets = new HashSet<>();// id记录,校验防止递归死循环 + sBuilder.append(model.getName()); + idSets.add(model.getId()); + getFilePath(model, sBuilder,idSets);// 递归获取当前文件名称路径 + object2.put("path", sBuilder.toString()); + result.add(object2); + } + return result; + } + + /** + * 获取所有文件 + * @param uc + * @param wsId + * @param category + * @param type 已发布或者全部 + * @return + */ + public String queryPublishRepositoryDataJson(UserContext uc, String wsId, String category, String type) { + JSONObject param = getXPagesBasicParam(uc, null); + String roleId = param.getString("roleId"); + String wsIdsql = "'" + wsId + "'"; + ResponseObject ro = ResponseObject.newOkResponse(); + PALRepository dao = new PALRepository(); + List list = null; + if (type == null || "publish".equals(type)) { + list = dao.getRepositoryListByPublishRole(wsIdsql, roleId, null, category, true, false); + } else { + list = dao.getRepositoryListByPublishRole(wsIdsql, roleId, null, category, false, true); + } + if (list == null) { + list = new ArrayList<>(); + } + JSONArray result = assembleData2(list); + ro.setData(result); + return ro.toString(); + } + + /** + * 获取所有已发布的文件 + * @param wsId + * @return + */ + public String queryPublishRepositoryDataJson(UserContext uc, String wsId, String category) { + JSONObject param = getXPagesBasicParam(uc, null); + String roleId = param.getString("roleId"); + String wsIdsql = "'" + wsId + "'"; + ResponseObject ro = ResponseObject.newOkResponse(); + PALRepository dao = new PALRepository(); + List list = dao.getRepositoryListByPublishRole(wsIdsql, roleId, null, category); + if (list == null) { + list = new ArrayList<>(); + } + Set idSet = new HashSet<>(); + for (PALRepositoryModel model : list) { + idSet.add(model.getId()); + } + // 添加关联aws组织的流程进行合并 + boolean flag = false; + Set awsProcessIds = getAwsOrgPermRepositoryByUser(_uc, category, true); + if (awsProcessIds != null && awsProcessIds.size() > 0) { + for (String processId : awsProcessIds) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(processId); + if (model != null && wsIdsql.indexOf(model.getWsId()) > -1 && !idSet.contains(model.getId())) { + list.add(model); + idSet.add(model.getId()); + flag = true; + } + } + } + if (flag) {// 合并过数据则需要重新排序 + // 排序 + Collections.sort(list, new MyComparator()); + } + JSONArray result = assembleData2(list); + ro.setData(result); + return ro.toString(); + } + + /** + * 获取所有有权限的资产库 + * @return + */ + public String queryPermWorkspaceDataJson(UserContext uc) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONObject param = getXPagesBasicParam(uc, null); + String roleId = param.getString("roleId"); + List> wsList = getPalAndAwsPermRepositoryVersionIdByUser(uc, roleId, null); + JSONArray ws = new JSONArray(); + if (wsList != null && wsList.size() > 0) { + for (int i = 0; i < wsList.size(); i++) { + JSONObject object = new JSONObject(); + object.put("wsId", wsList.get(i).get("wsId")); + object.put("wsName", wsList.get(i).get("wsName")); + ws.add(object); + } + } + ro.setData(ws); + return ro.toString(); + } + + /** + * 按照创建时间倒序排序 + * + */ + private class CreateDateComparator implements Comparator { + + @Override + public int compare(PALRepositoryModel o1, PALRepositoryModel o2) { + Timestamp p1 = o1.getCreateDate(); + Timestamp p2 = o2.getCreateDate(); + if (p1 != null && p2 != null) { + if (!p1.equals(p2)) { + return p2.compareTo(p1); + } + } + int level1 = o1.getLevel(); + int level2 = o2.getLevel(); + if (level1 != level2) { + return level1 - level2; + } + int order1 = o1.getOrderIndex(); + int order2 = o2.getOrderIndex(); + return order1 - order2; + } + + } + + /** + * 获取发布动态 + * @param wsId + * @return + */ + public String queryDynamicHistoryDataJson(UserContext uc, String wsId, String type) { + JSONObject param = getXPagesBasicParam(uc, null); + String roleId = param.getString("roleId"); + String wsIdsql = "'" + wsId + "'"; + ResponseObject ro = ResponseObject.newOkResponse(); + + if (type == null || "publish".equals(type)) {// 获取已发布流程 + + } else {// 按照创建时间倒序获取所有流程 + JSONArray result = new JSONArray(); + List list = new ArrayList<>(); + PALRepository repository = new PALRepository(); + Set palVersionIds = repository.getPalVersionIdByroleId(roleId); + Iterator iterator = PALRepositoryCache.getByWsId(wsId); + while (iterator.hasNext()) { + PALRepositoryModel model = iterator.next(); + if (palVersionIds.contains(model.getVersionId())) { + list.add(model); + } + } + // 按照时间倒序,名称升序排序 + Collections.sort(list, new CreateDateComparator()); + for (PALRepositoryModel palModel : list) { + JSONObject object2 = new JSONObject(); + String userName = ""; + String userId = palModel.getCreateUser(); + if (!UtilString.isEmpty(userId) && UserCache.getModel(userId) != null) { + userName = UserCache.getModel(userId).getUserName(); + } + object2.put("id", palModel.getId()); + object2.put("version", "V" + palModel.getVersion() + ".0"); + object2.put("user", userName); + object2.put("name", palModel.getName()); + object2.put("createDate", UtilDate.datetimeFormat(palModel.getCreateDate())); + object2.put("isPublish", palModel.isPublish() ? "1" : "0"); + object2.put("method", palModel.getMethodId()); + object2.put("category", palModel.getMethodCategory()); + // 获取发布类型名称 + String categoryName = ""; + if (palModel.getLevel() <= 2) { + categoryName = palModel.getName(); + } else { + PALRepositoryModel model = palModel; + while (true) { + String pid = model.getParentId(); + PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(pid); + if (parentModel == null) { + break; + } else { + if (parentModel.getLevel() <= 2) { + categoryName = parentModel.getName(); + break; + } + } + model = parentModel; + } + } + object2.put("categoryName", categoryName); + result.add(object2); + } + ro.setData(result); + return ro.toString(); + } + + PublishListHistory dao = new PublishListHistory(); + List modelList = dao.getPublishListHistoryByRole(roleId, null, wsIdsql, null); + // 获取PAL权限版本ID + PALRepository repository = new PALRepository(); + Set palVersionIds = repository.getPalVersionIdByroleId(roleId); + Set palProcessIds = new HashSet<>(); + for (String versionId : palVersionIds) { + List list = PALRepositoryCache.getByVersionId(versionId); + if (!isEmpty(list)) { + for (PALRepositoryModel model : list) { + palProcessIds.add(model.getId()); + } + } + } + + // 过滤最终结果 + List list = new ArrayList<>(); + for (JSONObject object : modelList) { + String repositoryId = object.getString("repositoryId"); + if (palProcessIds.contains(repositoryId)) { + list.add(object); + } + } + + JSONArray result = new JSONArray(); + for (JSONObject object : list) { + JSONObject object2 = new JSONObject(); + String repositoryId = object.getString("repositoryId"); + PALRepositoryModel palModel = PALRepositoryCache.getCache().get(repositoryId); + object2.put("id", palModel.getId()); + object2.put("version", "V" + palModel.getVersion() + ".0"); + String userName = ""; + if (UserCache.getModel(object.getString("userId")) != null) { + userName = UserCache.getModel(object.getString("userId")).getUserName(); + } + + String actionType = object.getString("actionType"); + String intro = ""; + switch (actionType) { + case "N": + intro = "新发布"; + break; + case "C": + intro = "变更"; + break; + default:// S + intro = "停用"; + break; + } + object2.put("name", palModel.getName() + "[" + intro + "]"); + object2.put("user", userName); + object2.put("publishDate", UtilDate.datetimeFormat(object.getTimestamp("publishDate"))); + object2.put("publishDesc", object.getString("publishDesc")); + object2.put("isPublish", palModel.isPublish() ? "1" : "0"); + object2.put("method", palModel.getMethodId()); + object2.put("category", palModel.getMethodCategory()); + // 获取发布类型名称 + String categoryName = ""; + if (palModel.getLevel() <= 2) { + categoryName = palModel.getName(); + } else { + PALRepositoryModel model = palModel; + while (true) { + String pid = model.getParentId(); + PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(pid); + if (parentModel == null) { + break; + } else { + if (parentModel.getLevel() <= 2) { + categoryName = parentModel.getName(); + break; + } + } + model = parentModel; + } + } + object2.put("categoryName", categoryName); + result.add(object2); + } + ro.setData(result); + return ro.toString(); + } + + /** + * 获取发布动态(更多) + * @param wsId + * @return + */ + public String queryDynamicHistoryMoreDataJson(UserContext uc, String wsId, String type) { + JSONObject param = getXPagesBasicParam(uc, null); + String roleId = param.getString("roleId"); + String wsIdsql = "'" + wsId + "'"; + + ResponseObject ro = ResponseObject.newOkResponse(); + + if (type == null || "publish".equals(type)) {// 获取已发布流程 + + } else {// 按照创建时间倒序获取所有流程 + JSONArray result = new JSONArray(); + List list = new ArrayList<>(); + // 获取PAL权限版本ID + PALRepository repository = new PALRepository(); + Set palVersionIds = repository.getPalVersionIdByroleId(roleId); + Iterator iterator = PALRepositoryCache.getByWsId(wsId); + while (iterator.hasNext()) { + PALRepositoryModel model = iterator.next(); + if (palVersionIds.contains(model.getVersionId())) { + list.add(model); + } + } + // 按照时间倒序,名称升序排序 + Collections.sort(list, new CreateDateComparator()); + for (PALRepositoryModel palModel : list) { + JSONObject object2 = new JSONObject(); + object2.put("id", palModel.getId()); + object2.put("version", "V" + palModel.getVersion() + ".0"); + String userName = ""; + String userId = palModel.getCreateUser(); + if (!UtilString.isEmpty(userId) && UserCache.getModel(userId) != null) { + userName = UserCache.getModel(userId).getUserName(); + } + object2.put("name", palModel.getName()); + object2.put("user", userName); + object2.put("departmentPath", getDeptPath(palModel.getCreateUser())); + object2.put("createDate", UtilDate.datetimeFormat(palModel.getCreateDate())); + object2.put("isPublish", palModel.isPublish() ? "1" : "0"); + object2.put("method", palModel.getMethodId()); + object2.put("category", palModel.getMethodCategory()); + + // 获取路径 + StringBuilder sBuilder = new StringBuilder();// 名称组合 + Set idSets = new HashSet<>();// id记录,校验防止递归死循环 + sBuilder.append(palModel.getName()); + idSets.add(palModel.getId()); + getFilePath(palModel, sBuilder,idSets);// 递归获取当前文件名称路径 + object2.put("path", sBuilder.toString()); + result.add(object2); + } + ro.setData(result); + return ro.toString(); + } + + PublishListHistory dao = new PublishListHistory(); + List modelList = dao.getPublishListHistoryByRole(roleId, null, wsIdsql, null); + // 获取PAL权限版本ID + PALRepository repository = new PALRepository(); + Set palVersionIds = repository.getPalVersionIdByroleId(roleId); + Set palProcessIds = new HashSet<>(); + for (String versionId : palVersionIds) { + List list = PALRepositoryCache.getByVersionId(versionId); + if (!isEmpty(list)) { + for (PALRepositoryModel model : list) { + palProcessIds.add(model.getId()); + } + } + } + + // 过滤最终结果 + List list = new ArrayList<>(); + for (JSONObject object : modelList) { + String repositoryId = object.getString("repositoryId"); + if (palProcessIds.contains(repositoryId)) { + list.add(object); + } + } + + JSONArray result = new JSONArray(); + for (JSONObject object : list) { + JSONObject object2 = new JSONObject(); + String repositoryId = object.getString("repositoryId"); + PALRepositoryModel palModel = PALRepositoryCache.getCache().get(repositoryId); + object2.put("id", palModel.getId()); + object2.put("version", "V" + palModel.getVersion() + ".0"); + String userName = ""; + if (UserCache.getModel(object.getString("userId")) != null) { + userName = UserCache.getModel(object.getString("userId")).getUserName(); + } + + String actionType = object.getString("actionType"); + String intro = ""; + switch (actionType) { + case "N": + intro = "新发布"; + break; + case "C": + intro = "变更"; + break; + default:// S + intro = "停用"; + break; + } + object2.put("name", palModel.getName() + "[" + intro + "]"); + object2.put("user", userName); + object2.put("departmentPath", getDeptPath(object.getString("userId"))); + object2.put("publishDate", UtilDate.datetimeFormat(object.getTimestamp("publishDate"))); + object2.put("publishDesc", object.getString("publishDesc")); + object2.put("isPublish", palModel.isPublish() ? "1" : "0"); + object2.put("method", palModel.getMethodId()); + object2.put("category", palModel.getMethodCategory()); + + // 获取路径 + StringBuilder sBuilder = new StringBuilder();// 名称组合 + Set idSets = new HashSet<>();// id记录,校验防止递归死循环 + sBuilder.append(palModel.getName()); + idSets.add(palModel.getId()); + getFilePath(palModel, sBuilder,idSets);// 递归获取当前文件名称路径 + object2.put("path", sBuilder.toString()); + result.add(object2); + } + ro.setData(result); + return ro.toString(); + } + + /** + * 根据类别获取权限下的发布流程 + * @param me + * @param type publish:获取当前状态为已发布且有权限的文件 stop: 获取曾经发布过但是当前是未发布状态(使用中)的文件 recentView:按照流程点击量倒序获取当前状态为已发布的文件(类似高频流程) + * @param wsId + * @return + */ + public String queryPublishRepositoryDataJsonByType(UserContext me, String type, String wsId) { + switch (type) { + case "publish": + // 获取已发布流程 + return queryPublishRepositoryDataJson(me, wsId, "process"); + case "stop": + JSONObject param = getXPagesBasicParam(me, null); + String roleId = param.getString("roleId"); + PublishListHistory history = new PublishListHistory(); + Set publishHistorySet = history.getPublishDataByActiontype("S", wsId); + // 获取权限下的模型id + // 获取PAL权限版本ID + PALRepository repository = new PALRepository(); + Set palVersionIds = repository.getPalVersionIdByroleId(roleId); + Set palProcessIds = new HashSet<>(); + for (String versionId : palVersionIds) { + List list = PALRepositoryCache.getByVersionId(versionId); + if (!isEmpty(list)) { + for (PALRepositoryModel model : list) { + palProcessIds.add(model.getId()); + } + } + } + // 获取关联AWS组织的版本ID且当前为未发布 + Set awsProcessIds = getAwsOrgPermRepositoryByUser(_uc, null, false); + // 整合所有权限 + palProcessIds.addAll(awsProcessIds); + List list = new ArrayList<>(); + Iterator iterator = PALRepositoryCache.getByWsId(wsId); + while (iterator.hasNext()) { + PALRepositoryModel model = iterator.next(); + if (!model.isPublish() && "process".equals(model.getMethodCategory()) && publishHistorySet.contains(model.getId()) && palProcessIds.contains(model.getId())) {// 未发布&&已停用&&有权限 + list.add(model); + } + } + // 排序 + Collections.sort(list, new MyComparator()); + JSONArray data = assembleData2(list); + ResponseObject r2 = ResponseObject.newOkResponse(); + r2.setData(data); + return r2.toString(); + default:// recentView + List tempList = new ArrayList<>(); + PublishFrequencyDao frequencyDao = new PublishFrequencyDao(); + List frequencyModels = frequencyDao.getDataOrderByCount(wsId); + if (frequencyModels == null || frequencyModels.size() == 0) { + ResponseObject r = ResponseObject.newOkResponse(); + r.setData(tempList); + return r.toString(); + } + Map map = new HashMap<>(); + for (PublishFrequencyModel model : frequencyModels) { + map.put(model.getPlversionId(), model.getCount()); + } + String result = queryPublishRepositoryDataJson(me, wsId, "process"); + JSONObject ro = JSONObject.parseObject(result); + JSONArray array = ro.getJSONArray("data"); + for (int i = 0; i < array.size(); i++) { + JSONObject object = array.getJSONObject(i); + String id = object.getString("id"); + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model!= null) { + String versionId = model.getVersionId(); + if (map.containsKey(versionId)) { + object.put("viewCount", map.get(versionId)); + tempList.add(object); + } + } + } + // 按照访问量降序排序 + Collections.sort(tempList, new CountComparator()); + ResponseObject r = ResponseObject.newOkResponse(); + r.setData(tempList); + return r.toString(); + } + } + + private class CountComparator implements Comparator { + @Override + public int compare(JSONObject o1, JSONObject o2) { + Integer count1 = o1.getInteger("viewCount"); + Integer count2 = o2.getInteger("viewCount"); + return count2 - count1; + } + } + + /** + * 获取所有有权限的部门列表,部门列表来源于所有具有权限的流程的责任部门 + * 已发布 + * @param me + * @param wsId + * @return + */ + public String queryAwsDepartmentDataJson(UserContext me, String wsId) { + String category = "process"; + JSONObject param = getXPagesBasicParam(me, null); + String roleId = param.getString("roleId"); + // 获取PAL权限版本ID + PALRepository repository = new PALRepository(); + Set palVersionIds = repository.getPalVersionIdByroleId(roleId); + Set palProcessIds = new HashSet<>(); + for (String versionId : palVersionIds) { + List list = PALRepositoryCache.getByVersionId(versionId); + if (!isEmpty(list)) { + for (PALRepositoryModel model : list) { + if (model.isPublish() && model.getMethodCategory().equals(category)) { + palProcessIds.add(model.getId()); + } + } + } + } + // 获取关联AWS组织的版本ID且当前为已发布 + Set awsProcessIds = getAwsOrgPermRepositoryByUser(_uc, category, true); + // 整合所有权限 + palProcessIds.addAll(awsProcessIds); + + // 获取所有部门ID + Set deptIds = new HashSet<>(); + for (String id : palProcessIds) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model != null && model.getWsId().equals(wsId)) { + // 责任部门 + String deptId = model.getDutyDept(); + if (!UtilString.isEmpty(deptId)) { + deptIds.add(deptId); + } + } + } + List list = new ArrayList<>(); + for (String deptId : deptIds) { + JSONObject object = new JSONObject(); + DepartmentModel dModel = SDK.getORGAPI().getDepartmentById(deptId); + if (dModel != null) { + // 获取单位 + CompanyModel cModel = SDK.getORGAPI().getCompanyById(dModel.getCompanyId()); + if (cModel != null) { + object.put("id", dModel.getId()); + object.put("departmentId", dModel.getId()); + object.put("departmentName", dModel.getName()); + object.put("departmentLayer", dModel.getLayer()); + object.put("departmentOrderIndex", dModel.getOrderIndex()); + object.put("departmentClosed", dModel.isClosed()); + object.put("companyId", dModel.getCompanyId()); + object.put("companyName", cModel.getName()); + object.put("companyOrderIndex", cModel.getOrderIndex()); + object.put("companyClosed", cModel.isClosed()); + list.add(object); + } + } + } + // 排序,按照单位部门层级和顺序排序 + Collections.sort(list, new DepartmentComparator()); + ResponseObject ro = ResponseObject.newOkResponse(); + ro.setData(list); + return ro.toString(); + } + + // 部门排序 + private class DepartmentComparator implements Comparator{ + @Override + public int compare(JSONObject o1, JSONObject o2) { + int cOrder1 = o1.getIntValue("companyOrderIndex"); + int cOrder2 = o2.getIntValue("companyOrderIndex"); + if (cOrder1 != cOrder2) { + return cOrder1 - cOrder2; + } + int dLayer1 = o1.getIntValue("departmentLayer"); + int dLayer2 = o2.getIntValue("departmentLayer"); + if (dLayer1 != dLayer2) { + return dLayer1 - dLayer2; + } + int dOrder1 = o1.getIntValue("departmentOrderIndex"); + int dOrder2 = o2.getIntValue("departmentOrderIndex"); + return dOrder1 - dOrder2; + } + + } + + /** + * 获取当前部门的流程数据(责任部门)和当前部门下具有权限的子部门列表 + * @param me + * @param wsId + * @param departmentId + * @return + */ + public String queryPublishedProcessAndSubDepartment(UserContext me, String wsId, String departmentId) { + JSONObject result = new JSONObject(); + // 获取有权限的已发布流程 + String category = "process"; + JSONObject param = getXPagesBasicParam(me, null); + String roleId = param.getString("roleId"); + // 过滤当前责任部门的流程 + // 获取PAL权限版本ID + PALRepository repository = new PALRepository(); + Set palVersionIds = repository.getPalVersionIdByroleId(roleId); + Set palProcessIds = new HashSet<>(); + for (String versionId : palVersionIds) { + List list = PALRepositoryCache.getByVersionId(versionId); + if (!isEmpty(list)) { + for (PALRepositoryModel model : list) { + if (model.isPublish() && model.getMethodCategory().equals(category)) { + palProcessIds.add(model.getId()); + } + } + } + } + // 获取关联AWS组织的版本ID且当前为已发布 + Set awsProcessIds = getAwsOrgPermRepositoryByUser(_uc, category, true); + // 整合所有权限id + palProcessIds.addAll(awsProcessIds); + List list = new ArrayList<>(); + Set deptIds = new HashSet<>(); + for (String id : palProcessIds) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model != null && model.getWsId().equals(wsId)) { + // 责任部门 + String deptId = model.getDutyDept(); + if (!UtilString.isEmpty(deptId)) { + deptIds.add(deptId); + if (deptId.equals(departmentId)) { + list.add(model); + } + } + } + } + Collections.sort(list, new MyComparator()); + JSONArray repositoryArr = new JSONArray(); + for (PALRepositoryModel model : list) { + // "子部门列表(部门id,部门名称); + // 所有选择了该部门作为责任部门的流程文件列表(流程id,流程名称,是否有附件、附件Id,附件名称、附件链接、流程地图图片)" + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("name", model.getName()); + object.put("version", "V" + model.getVersion() + ".0"); + object.put("hasFile", false); + object.put("method", model.getMethodId()); + object.put("category", model.getMethodCategory()); + // 附件 + JSONArray file = new JSONArray(); + StringBuffer sqlWhere = new StringBuffer(); + sqlWhere.append(" and PALREPOSITORYID ='").append(model.getId()).append("' and FILETYPE='f'"); + UpFileDao upFileDao = new UpFileDao(); + List search = upFileDao.search(sqlWhere.toString()); + if (search != null && search.size() > 0) { + object.put("hasFile", true); + for (UpfileModel upfileModel : search) { + JSONObject fileObject = new JSONObject(); + fileObject.put("id", upfileModel.getUuid()); + fileObject.put("name", upfileModel.getFileName()); + String downloadUrl = ""; + DCContext dcContext = null; + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); + if (dcProfile != null) { + dcContext = new DCContext(me, dcProfile, CoEConstant.APP_ID, "file",upfileModel.getPl_uuid(), upfileModel.getFileName()); + } + if (dcContext != null) { + downloadUrl = dcContext.getDownloadURL() + "&isInline=false"; + } + fileObject.put("url", downloadUrl); + file.add(fileObject); + } + } + object.put("file", file); + // 流程图片 + String imgSrc = ""; + String path = model.getFilePath(); + if (!UtilString.isEmpty(path)) { + UtilFile utilFile = new UtilFile(path + "/" + model.getId() + ".small.png"); + if (utilFile.exists()) { + byte[] base64Bytes = Base64.encode(utilFile.readBytes()); + imgSrc = "data:image/png;base64," + new String(base64Bytes); + } + } + object.put("imgSrc", imgSrc); + repositoryArr.add(object); + } + result.put("process", repositoryArr); + // 获取子部门列表 + List deptList = new ArrayList<>(); + getPermDepartment(deptList, deptIds, departmentId);// 获取子部门列表 + // 部门排序 + JSONArray deptArr = new JSONArray(); + for (DepartmentModel dept : deptList) { + JSONObject deptObj = new JSONObject(); + deptObj.put("id", dept.getId()); + deptObj.put("departmentName", dept.getName()); + deptArr.add(deptObj); + } + result.put("department", deptArr); + ResponseObject ro = ResponseObject.newOkResponse(); + ro.setData(result); + return ro.toString(); + } + + // 获取所有符合条件的子部门 + private void getPermDepartment(List list, Set deptIds, String parentId) { + // 获取子部门列表 + List subDeptList = SDK.getORGAPI().getSubDepartments(parentId); + if (!isEmpty(subDeptList)) { + for (DepartmentModel model : subDeptList) { + if (deptIds.contains(model.getId())) { + list.add(model); + } else { + getPermDepartment(list, deptIds, model.getId()); + } + } + } + } + + // 获取子流程列表 + public String queryPublishProcessByParent(UserContext me, String id, String type) { + // 获取有权限的已发布流程 + String category = "process"; + JSONObject param = getXPagesBasicParam(me, null); + String roleId = param.getString("roleId"); + // 过滤当前责任部门的流程 + // 获取PAL权限版本ID + PALRepository repository = new PALRepository(); + Set palVersionIds = repository.getPalVersionIdByroleId(roleId); + Set palProcessIds = new HashSet<>(); + for (String versionId : palVersionIds) { + List list = PALRepositoryCache.getByVersionId(versionId); + if (!isEmpty(list)) { + for (PALRepositoryModel model : list) { + if (type == null || "publish".equals(type)) {// 获取已发布流程 + if(model.isPublish() && model.getMethodCategory().equals(category)) { + palProcessIds.add(model.getId()); + } + } else {// 获取当前使用中流程,不区分状态 + if(model.isUse() && model.getMethodCategory().equals(category)) { + palProcessIds.add(model.getId()); + } + } + } + } + } + + // 获取当前流程信息和子流程 + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model == null) { + throw new AWSException("查找失败 uuid: " + id ); + } + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("name", model.getName()); + object.put("version", "V" + model.getVersion() + ".0"); + object.put("hasChild", false); + object.put("childData", new JSONArray()); + object.put("method", model.getMethodId()); + object.put("category", model.getMethodCategory()); + object.put("level", model.getLevel()); + object.put("isPublish", model.isPublish()); + + // 获取子流程列表 + List subList = new ArrayList<>(); + getPermSubPalRepository(subList, palProcessIds, model.getId()); + if (!isEmpty(subList)) { + object.put("hasChild", true); + // 获取附件列表,获取流程图片 + JSONArray subArr = new JSONArray(); + for (PALRepositoryModel subModel : subList) { + JSONObject subObj = new JSONObject(); + subObj.put("id", subModel.getId()); + subObj.put("name", subModel.getName()); + subObj.put("version", "V" + subModel.getVersion() + ".0"); + subObj.put("hasFile", false); + subObj.put("method", subModel.getMethodId()); + subObj.put("category", subModel.getMethodCategory()); + subObj.put("level", subModel.getLevel()); + subObj.put("isPublish", subModel.isPublish()); + // 附件 + JSONArray file = new JSONArray(); + StringBuffer sqlWhere = new StringBuffer(); + sqlWhere.append(" and PALREPOSITORYID ='").append(subModel.getId()).append("' and FILETYPE='f'"); + UpFileDao upFileDao = new UpFileDao(); + List search = upFileDao.search(sqlWhere.toString()); + if (search != null && search.size() > 0) { + subObj.put("hasFile", true); + for (UpfileModel upfileModel : search) { + JSONObject fileObject = new JSONObject(); + fileObject.put("id", upfileModel.getUuid()); + fileObject.put("name", upfileModel.getFileName()); + String downloadUrl = ""; + DCContext dcContext = null; + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); + if (dcProfile != null) { + dcContext = new DCContext(me, dcProfile, CoEConstant.APP_ID, "file",upfileModel.getPl_uuid(), upfileModel.getFileName()); + } + if (dcContext != null) { + downloadUrl = dcContext.getDownloadURL() + "&isInline=false"; + } + fileObject.put("url", downloadUrl); + file.add(fileObject); + } + } + subObj.put("file", file); + // 流程图片 + String imgSrc = ""; + String path = subModel.getFilePath(); + if (!UtilString.isEmpty(path)) { + UtilFile utilFile = new UtilFile(path + "/" + subModel.getId() + ".small.png"); + if (utilFile.exists()) { + byte[] base64Bytes = Base64.encode(utilFile.readBytes()); + imgSrc = "data:image/png;base64," + new String(base64Bytes); + } + } + subObj.put("imgSrc", imgSrc); + subArr.add(subObj); + } + object.put("childData", subArr); + } + ResponseObject ro = ResponseObject.newOkResponse(); + ro.setData(object); + return ro.toString(); + } + + private void getPermSubPalRepository(List list, Set palProcessIds, String pid) { + // 获取子流程 + PALRepositoryModel model = PALRepositoryCache.getCache().get(pid); + if (model != null) { + List subList = PALRepositoryCache.getAllSubModelsByPid(model.getWsId(), model.getId()); + if (!isEmpty(subList)) { + // 排序 + Collections.sort(subList, new Comparator() { + @Override + public int compare(PALRepositoryModel o1, PALRepositoryModel o2) { + int level1 = o1.getLevel(); + int level2 = o2.getLevel(); + if (level1 != level2) { + return level1 - level2; + } + int orderIndex1 = o1.getOrderIndex(); + int orderIndex2 = o2.getOrderIndex(); + return orderIndex1 - orderIndex2; + } + }); + for (PALRepositoryModel subModel : subList) { + if (palProcessIds.contains(subModel.getId())) { + list.add(subModel); + } else { + getPermSubPalRepository(list, palProcessIds, subModel.getId()); + } + } + } + } + } + + /** + * 打开流程 + * @param me + * @param uuid + * @return + */ + public String openPublishRepository(UserContext me, String uuid, String type) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + if (model != null) { + if ("default".equals(model.getMethodId())) { + throw new AWSException("当前文件类型不支持打开"); + } + } + if (type == null || "publish".equals(type)) {// 获取已发布流程 + return PALRepositoryQueryAPIManager.getInstance().getPublishPortalHtml(me, uuid, null); + } else {// 不再校验是否已发布 + return PALRepositoryQueryAPIManager.getInstance().getPublishPortalHtml(me, uuid, null, false); + } + } + + /** + * 查找二级流程 + * @param me + * @param wsId + * @param type all:所有当前正在使用状态中的模型,包括发布和停用 publish:已发布模型 + * @return + */ + public String querySecondLevelRepositoryDataJson(UserContext me, String wsId, String type) { + JSONArray result = new JSONArray(); + // 暂时不处理权限,取所有二级流程类文件 + List firstLevelModels = PALRepositoryCache.getAllSubModelsByPid(wsId, "process"); + if (!isEmpty(firstLevelModels)) { + Set versionIds = new HashSet<>(); + for (PALRepositoryModel model : firstLevelModels) { + if (!versionIds.contains(model.getVersionId())) { + // 获取第二级流程 + List secendLevelModels = PALRepositoryCache.getAllSubModelsByPid(wsId, model.getId()); + if (!isEmpty(secendLevelModels)) { + if (type == null || "publish".equals(type)) {// 获取已发布流程 + for (PALRepositoryModel sModel : secendLevelModels) { + if (sModel.isPublish()) { + JSONObject object = new JSONObject(); + object.put("id", sModel.getId()); + object.put("name", sModel.getName()); + object.put("level", sModel.getLevel()); + object.put("parentId", sModel.getParentId()); + object.put("method", sModel.getMethodId()); + object.put("category", sModel.getMethodCategory()); + object.put("parentName", model.getName()); + object.put("isPublish", model.isPublish()); + result.add(object); + } + } + } else {// 获取当前使用中流程,不区分状态 + for (PALRepositoryModel sModel : secendLevelModels) { + if (sModel.isUse()) { + JSONObject object = new JSONObject(); + object.put("id", sModel.getId()); + object.put("name", sModel.getName()); + object.put("level", sModel.getLevel()); + object.put("parentId", sModel.getParentId()); + object.put("method", sModel.getMethodId()); + object.put("category", sModel.getMethodCategory()); + object.put("parentName", model.getName()); + object.put("isPublish", model.isPublish()); + result.add(object); + } + } + } + } + versionIds.add(model.getVersionId()); + } + } + } + ResponseObject ro = ResponseObject.newOkResponse(); + ro.setData(result); + return ro.toString(); + } + + /** + * 查找三级流程(已发布和未发布) + * @param me + * @param wsId + * @param type all:所有当前正在使用状态中的模型,包括发布和停用 publish:已发布模型 + * @return + */ + public String queryThirdLevelRepositoryDataJson(UserContext me, String wsId, String type) { + JSONArray result = new JSONArray(); + ResponseObject ro = ResponseObject.newOkResponse(); + ro.setData(result); + Set versionIds = new HashSet<>(); + // 一级流程 + List firstLevelModels = PALRepositoryCache.getAllSubModelsByPid(wsId, "process"); + if(isEmpty(firstLevelModels)) { + return ro.toString(); + } + //非管理员在测试库下(type:all)权限 + CoeUser coeUserDao = CoeUserDaoFactory.createUser(); + boolean isCoEManager = coeUserDao.isCoEManager(me.getUID()); //是否管理员权限 + + PublisherClientDao publisherDao = new PublisherClientDao(); + List resourceIds = publisherDao.getTeamUserPerms(me.getUID()); //拥有的资源权限 + // + for (PALRepositoryModel model : firstLevelModels) { + if(versionIds.contains(model.getVersionId())) { + continue; + } + // 获取第二级流程 + List secendLevelModels = PALRepositoryCache.getAllSubModelsByPid(wsId, model.getId()); + if(isEmpty(secendLevelModels)) { + continue; + } + for (PALRepositoryModel sModel : secendLevelModels) { + // 获取第三级流程 + List thirdLevelModels = PALRepositoryCache.getAllSubModelsByPid(wsId, sModel.getId()); + if(isEmpty(thirdLevelModels)) { + continue; + } + for(PALRepositoryModel tModel : thirdLevelModels) { + if (type == null || "publish".equals(type) ) {// 获取已发布流程 + if (tModel.isPublish() || "default".equals(tModel.getMethodId())) { + //第四级流程及以下流程 + List possessionList = new ArrayList(); + this.getAllPalRepositoryModelsByPid(wsId, tModel.getId(), possessionList); //递归得到流程信息 + //过滤统计流程的数量 + long possessionCount = 0; + for(int m = 0; m < possessionList.size(); m++) { + PALRepositoryModel mo = possessionList.get(m); + if("process.bpmn2".equals(mo.getMethodId()) && mo.isPublish()) { //只统计process.bpmn2类 + possessionCount ++; + } + } + JSONObject object = new JSONObject(); + object.put("id", tModel.getId()); + object.put("name", tModel.getName()); + object.put("level", tModel.getLevel()); + object.put("parentId", tModel.getParentId()); + object.put("method", tModel.getMethodId()); + object.put("category", tModel.getMethodCategory()); + object.put("parentName", sModel.getName()); + object.put("isPublish", tModel.isPublish()); + object.put("possessionCount", possessionCount); //目录下包含的所有流程数量,只包含bpmn当前版本的 + object.put("privilege", 1); //已发布的正式库永远有权限 + result.add(object); + } + } else {// 获取当前使用中的流程,不区分状态 + if (tModel.isUse()) { + //第四级流程及以下流程 + List possessionList = new ArrayList(); + this.getAllPalRepositoryModelsByPid(wsId, tModel.getId(), possessionList); //递归得到流程信息 + //privalige:0-没有第三级菜单下的流程权限;1-有第三级菜单下的流程权限 + int privalige = 1; + if(!isCoEManager) { + privalige = 0; + for(int i = 0; i < possessionList.size(); i++) { + PALRepositoryModel mo = possessionList.get(i); + if("process.bpmn2".equals(mo.getMethodId()) && mo.isUse() && resourceIds.contains(mo.getId())) { + privalige = 1; + break; + } + } + } + //过滤统计流程的数量 + long possessionCount = 0; + for(int m = 0; m < possessionList.size(); m++) { + PALRepositoryModel mo = possessionList.get(m); + if("process.bpmn2".equals(mo.getMethodId()) && mo.isUse()) { //只统计process.bpmn2类 + possessionCount ++; + } + } + JSONObject object = new JSONObject(); + object.put("id", tModel.getId()); + object.put("name", tModel.getName()); + object.put("level", tModel.getLevel()); + object.put("parentId", tModel.getParentId()); + object.put("method", tModel.getMethodId()); + object.put("category", tModel.getMethodCategory()); + object.put("parentName", sModel.getName()); + object.put("isPublish", tModel.isPublish()); + object.put("possessionCount", possessionCount); //目录下包含的所有流程数量,只包含bpmn当前版本的 + // 非管理人员测试库下 + if(isCoEManager) { + object.put("privilege", 1); //管理员拥有所有权限 + } else { + object.put("privilege", privalige); //非管理员 + } + result.add(object); + } + } + } //end of third level + } + versionIds.add(model.getVersionId()); + } + return ro.toString(); + } + + /** + * 获取某个流程的所有子流程 + * + * @param wsId + * @param pid + * @param list + */ + private void getAllPalRepositoryModelsByPid(String wsId, String pid, List list) { + List children = PALRepositoryCache.getAllSubModelsByPid(wsId, pid); + if (children != null && children.size() > 0) { + list.addAll(children); + for (PALRepositoryModel model : children) { + getAllPalRepositoryModelsByPid(wsId, model.getId(), list); + } + } + } + + /** + * 获取已加入群组 + * @param me + * @return + */ + public String queryJoinedTeamByUserId(UserContext me) { + JSONArray result = new JSONArray(); + // 获取所有工作网络列表 + JSONArray networks = getAllNetworks(); + + // 查询小组列表 + for (Object object : networks) { + JSONObject network = (JSONObject)object; + String networkId = network.getString("id"); + + Map teamMap = new LinkedHashMap(); + //获取工作网络中所有小组 + AppAPI appAPI = SDK.getAppAPI(); + Map params = new HashMap(); + String aslp = "aslp://com.actionsoft.apps.network/queryTeamsByNetwork"; + params.put("networkId", networkId); + params.put("sid", _uc.getSessionId()); + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(PublisherConf.APPID), aslp, params); + if (ro.toJsonObject().get("data") != null ) { + JSONArray teams = (JSONObject.parseObject(ro.toJsonObject().toString()).getJSONObject("data")).getJSONArray("teams"); + if (teams != null && teams.size() > 0) { + for (int i = 0; i < teams.size(); i++) { + JSONObject team = teams.getJSONObject(i); + if ("1".equals(team.getString("teamStatus"))) + teamMap.put(team.getString("id"), team);// 筛选启用中的小组 + } + } + for (Map.Entry entry : teamMap.entrySet()) { + JSONObject team = entry.getValue(); + String id = team.getString("id"); + // 查询小组成员 + Map numberMap = new HashMap<>(); + //小组ID,必填 + numberMap.put("teamId", id); + numberMap.put("sid", _uc.getSessionId()); + //查询某个小组的成员列表 + ResponseObject teamNumberRo = appAPI.callASLP(appAPI.getAppContext(PublisherConf.APPID), "aslp://com.actionsoft.apps.network/queryTeamMemberByTeamId", numberMap); + if (teamNumberRo.toJsonObject().get("data") != null ) { + JSONArray teamNumbers = (JSONObject.parseObject(teamNumberRo.toJsonObject().toString()).getJSONObject("data")).getJSONArray("teamMembers"); + boolean flag = false; + for (Object o : teamNumbers) { + JSONObject teamNumber = (JSONObject)o; + // 查询是否在当前小组中 + if (teamNumber.getString("userId").equals(_uc.getUID())) { + flag = true; + break; + } + } + if (flag) { + String teamName = team.getString("teamName"); + String teamType = team.getString("teamType"); + String teamTypeIcon = "../apps/com.actionsoft.apps.network/img/team/type_" + teamType + ".png"; + String teamTypeName = ""; + if ("1".equals(teamType)) { + teamTypeName = "公共"; + } else if ("2".equals(teamType)) { + teamTypeName = "私有"; + } else if ("3".equals(teamType)) { + teamTypeName = "私密"; + } + String teamLogo = team.getString("teamLogo"); + String teamLogoSrc = "".equals(teamLogo) ? "../apps/com.actionsoft.apps.network/img/team/logo_2.png" : teamLogo; + int teamMembersNum = team.getInteger("memberAmount") == null ? 0 : team.getInteger("memberAmount"); + // 小组成员 + List numbers = new ArrayList<>(); + for (Object o : teamNumbers) { + JSONObject teamNumber = (JSONObject)o; + numbers.add(teamNumber.getString("userName")); + } + Collections.sort(numbers); + JSONObject teamData = new JSONObject(); + + teamData.put("id", id); + teamData.put("name", teamName); + teamData.put("teamType", teamType); + teamData.put("teamTypeIcon", teamTypeIcon); + teamData.put("teamTypeName", teamTypeName); + teamData.put("teamLogoSrc", teamLogoSrc); + teamData.put("teamMembersNum", teamMembersNum); + teamData.put("numbers", String.join(",", numbers)); + result.add(teamData); + } + } + } + } + } + ResponseObject ro = ResponseObject.newOkResponse(); + ro.setData(result); + return ro.toString(); + } + + /** + * 获取未加入群组 + * @param me + * @return + */ + public String queryNotJoinTeamByUserId(UserContext me) { + JSONArray result = new JSONArray(); + // 获取所有工作网络列表 + JSONArray networks = getAllNetworks(); + + // 查询小组列表 + for (Object object : networks) { + JSONObject network = (JSONObject)object; + String networkId = network.getString("id"); + + Map teamMap = new LinkedHashMap(); + //获取工作网络中所有小组 + AppAPI appAPI = SDK.getAppAPI(); + Map params = new HashMap(); + String aslp = "aslp://com.actionsoft.apps.network/queryTeamsByNetwork"; + params.put("networkId", networkId); + params.put("sid", _uc.getSessionId()); + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(PublisherConf.APPID), aslp, params); + if (ro.toJsonObject().get("data") != null ) { + JSONArray teams = (JSONObject.parseObject(ro.toJsonObject().toString()).getJSONObject("data")).getJSONArray("teams"); + if (teams != null && teams.size() > 0) { + for (int i = 0; i < teams.size(); i++) { + JSONObject team = teams.getJSONObject(i); + if ("1".equals(team.getString("teamStatus"))) + teamMap.put(team.getString("id"), team);// 筛选启用中的小组 + } + } + for (Map.Entry entry : teamMap.entrySet()) { + JSONObject team = entry.getValue(); + String id = team.getString("id"); + String teamType = team.getString("teamType"); + if ("3".equals(teamType)) {// 未加入的私密小组不显示 + continue; + } + // 查询小组成员 + Map numberMap = new HashMap<>(); + //小组ID,必填 + numberMap.put("teamId", id); + numberMap.put("sid", _uc.getSessionId()); + //查询某个小组的成员列表 + ResponseObject teamNumberRo = appAPI.callASLP(appAPI.getAppContext(PublisherConf.APPID), "aslp://com.actionsoft.apps.network/queryTeamMemberByTeamId", numberMap); + if (teamNumberRo.toJsonObject().get("data") != null ) { + JSONArray teamNumbers = (JSONObject.parseObject(teamNumberRo.toJsonObject().toString()).getJSONObject("data")).getJSONArray("teamMembers"); + boolean flag = false; + for (Object o : teamNumbers) { + JSONObject teamNumber = (JSONObject)o; + // 查询是否在当前小组中 + if (teamNumber.getString("userId").equals(_uc.getUID())) { + flag = true; + break; + } + } + if (!flag) { + String teamName = team.getString("teamName"); + String teamTypeIcon = "../apps/com.actionsoft.apps.network/img/team/type_" + teamType + ".png"; + String teamTypeName = ""; + if ("1".equals(teamType)) { + teamTypeName = "公共"; + } else if ("2".equals(teamType)) { + teamTypeName = "私有"; + } else if ("3".equals(teamType)) { + teamTypeName = "私密"; + } + String teamLogo = team.getString("teamLogo"); + String teamLogoSrc = "".equals(teamLogo) ? "../apps/com.actionsoft.apps.network/img/team/logo_2.png" : teamLogo; + int teamMembersNum = team.getInteger("memberAmount") == null ? 0 : team.getInteger("memberAmount"); + + JSONObject teamData = new JSONObject(); + + teamData.put("id", id); + teamData.put("name", teamName); + teamData.put("teamType", teamType); + teamData.put("teamTypeIcon", teamTypeIcon); + teamData.put("teamTypeName", teamTypeName); + teamData.put("teamLogoSrc", teamLogoSrc); + teamData.put("teamMembersNum", teamMembersNum); + result.add(teamData); + } + } + } + } + } + ResponseObject ro = ResponseObject.newOkResponse(); + ro.setData(result); + return ro.toString(); + } + + /** + * 获取工作网络集合 + */ + private JSONArray getAllNetworks() { + JSONArray result = new JSONArray(); + // 调用App + String sourceAppId = PublisherConf.APPID; + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.network/queryAllNetwork"; + // 参数定义列表 + Map params = new HashMap<>(); + params.put("sid", _uc.getSessionId()); + AppAPI appAPI = SDK.getAppAPI(); + //查询工作网络列表 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + if (ro.toJsonObject().get("data") != null) { + JSONArray networks = (JSONObject.parseObject(ro.toJsonObject().toString()).getJSONObject("data")).getJSONArray("networks"); + for (Object object : networks) { + JSONObject obj = (JSONObject) object; + JSONObject temp = new JSONObject(); + temp.put("networkName", obj.getString("networkName")); + temp.put("id", obj.getString("id")); + result.add(temp); + } + } + return result; + } + + // 获取所有子部门 + private void getSubDepartments(List list, String parentId) { + // 获取子部门列表 + List subDeptList = SDK.getORGAPI().getSubDepartments(parentId); + if (!isEmpty(subDeptList)) { + for (DepartmentModel model : subDeptList) { + list.add(model); + getSubDepartments(list, model.getId()); + } + } + /*// 获取子部门列表 + List subDeptList = SDK.getORGAPI().getSubDepartments(parentId); + if (!isEmpty(subDeptList)) { + for (DepartmentModel model : subDeptList) { + if (deptIds.contains(model.getId())) { + list.add(model); + } else { + getPermDepartment(list, deptIds, model.getId()); + } + } + }*/ + } + /** + * 查询组织架构中部门流程 + * @param me + * @param wsId + * @return json + */ + public String openProcessMapOrgDeptData(UserContext me, String wsId, String departmentId) { + JSONObject result = new JSONObject(); + //FIXME 由于时间紧急,此方法功能正常,但待优化的地方很多 + // 获取有权限的已发布流程 + String category = "process"; + JSONObject param = getXPagesBasicParam(me, null); + String roleId = param.getString("roleId"); + // 过滤当前责任部门的流程 + // 获取PAL权限版本ID + PALRepository repository = new PALRepository(); + Set palVersionIds = repository.getPalVersionIdByroleId(roleId); + Set palProcessIds = new HashSet<>(); + for (String versionId : palVersionIds) { + List list = PALRepositoryCache.getByVersionId(versionId); + if (!isEmpty(list)) { + for (PALRepositoryModel model : list) { + if (model.isPublish() && model.getMethodCategory().equals(category)) { + palProcessIds.add(model.getId()); + } + } + } + } + // 获取关联AWS组织的版本ID且当前为已发布 + Set awsProcessIds = getAwsOrgPermRepositoryByUser(_uc, category, true); + // 整合所有权限id + palProcessIds.addAll(awsProcessIds); + Set deptIds = new HashSet<>(); + for (String id : palProcessIds) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model != null && model.getWsId().equals(wsId)) { + // 责任部门 + String deptId = model.getDutyDept(); + if (!UtilString.isEmpty(deptId)) { + deptIds.add(deptId); + } + } + } + ///// + // 获取子部门列表 + List deptList = new ArrayList<>(); + //getSubDepartments(deptList, departmentId);// 获取子部门列表 + getPermDepartment(deptList, deptIds, departmentId);// 获取子部门列表 + // 部门排序 + JSONArray deptArr = new JSONArray(); + //加入本部门信息 + JSONObject selfDeptObj = new JSONObject(); + SDK.getORGAPI().getDepartmentById(departmentId); + selfDeptObj.put("id", departmentId); + selfDeptObj.put("departmentName", SDK.getORGAPI().getDepartmentById(departmentId).getName()); + deptArr.add(selfDeptObj); + //加入所有下级部门信息 + for (DepartmentModel dept : deptList) { + JSONObject deptObj = new JSONObject(); + deptObj.put("id", dept.getId()); + deptObj.put("departmentName", dept.getName()); + deptArr.add(deptObj); + } + result.put("department", deptArr); + //循环每一个部门得到流程信息 + JSONArray repositoryArr = new JSONArray(); //保存所有的流程 + Set repositoryModel_Ids = new HashSet(); //暂存流程id,保证流程不重复 + if(deptArr!=null && deptArr.size()>0) { + for(Object obj : deptArr) { + JSONObject deptObj = (JSONObject)obj; + //流程的列表 + JSONArray processArray = this.openProcessMapOrgDeptDataBySelfSubDept(me, wsId, deptObj.getString("id"), repositoryModel_Ids); + for(Object processObj : processArray) { + repositoryArr.add(processObj); + } + } + } + result.put("process", repositoryArr); + ResponseObject ro = ResponseObject.newOkResponse(); + ro.setData(result); + return ro.toString(); + } + /** 返回部门下流程 */ + private JSONArray openProcessMapOrgDeptDataBySelfSubDept(UserContext me, String wsId, String departmentId, Set repositoryModel_Ids) { + // 获取有权限的已发布流程 + String category = "process"; + JSONObject param = getXPagesBasicParam(me, null); + String roleId = param.getString("roleId"); + // 过滤当前责任部门的流程 + // 获取PAL权限版本ID + PALRepository repository = new PALRepository(); + Set palVersionIds = repository.getPalVersionIdByroleId(roleId); + Set palProcessIds = new HashSet<>(); + for (String versionId : palVersionIds) { + List list = PALRepositoryCache.getByVersionId(versionId); + if (!isEmpty(list)) { + for (PALRepositoryModel model : list) { + if (model.isPublish() && model.getMethodCategory().equals(category)) { + palProcessIds.add(model.getId()); + } + } + } + } + // 获取关联AWS组织的版本ID且当前为已发布 + Set awsProcessIds = getAwsOrgPermRepositoryByUser(_uc, category, true); + // 整合所有权限id + palProcessIds.addAll(awsProcessIds); + List list = new ArrayList<>(); + for (String id : palProcessIds) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model != null && model.getWsId().equals(wsId)) { + // 责任部门 + String deptId = model.getDutyDept(); + if (!UtilString.isEmpty(deptId)) { + if (deptId.equals(departmentId)) { + list.add(model); + } + } + } + } + Collections.sort(list, new MyComparator()); + JSONArray repositoryArr = new JSONArray(); + for (PALRepositoryModel model : list) { + if(repositoryModel_Ids.contains(model.getId())) { + //repositoryModel_Ids已经存在该model则略过 + continue; + } + repositoryModel_Ids.add(model.getId());//该modelId加入repositoryModel_Ids,使得下次不重复加入 + + // "子部门列表(部门id,部门名称); + // 所有选择了该部门作为责任部门的流程文件列表(流程id,流程名称,是否有附件、附件Id,附件名称、附件链接、流程地图图片)" + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("name", model.getName()); + object.put("version", "V" + model.getVersion() + ".0"); + object.put("hasFile", false); + object.put("method", model.getMethodId()); + object.put("category", model.getMethodCategory()); + // 附件 + JSONArray file = new JSONArray(); + StringBuffer sqlWhere = new StringBuffer(); + sqlWhere.append(" and PALREPOSITORYID ='").append(model.getId()).append("' and FILETYPE='f'"); + UpFileDao upFileDao = new UpFileDao(); + List search = upFileDao.search(sqlWhere.toString()); + if (search != null && search.size() > 0) { + object.put("hasFile", true); + for (UpfileModel upfileModel : search) { + JSONObject fileObject = new JSONObject(); + fileObject.put("id", upfileModel.getUuid()); + fileObject.put("name", upfileModel.getFileName()); + String downloadUrl = ""; + DCContext dcContext = null; + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); + if (dcProfile != null) { + dcContext = new DCContext(me, dcProfile, CoEConstant.APP_ID, "file",upfileModel.getPl_uuid(), upfileModel.getFileName()); + } + if (dcContext != null) { + downloadUrl = dcContext.getDownloadURL() + "&isInline=false"; + } + fileObject.put("url", downloadUrl); + file.add(fileObject); + } + } + object.put("file", file); + // 流程图片 + String imgSrc = ""; + String path = model.getFilePath(); + if (!UtilString.isEmpty(path)) { + UtilFile utilFile = new UtilFile(path + "/" + model.getId() + ".small.png"); + if (utilFile.exists()) { + byte[] base64Bytes = Base64.encode(utilFile.readBytes()); + imgSrc = "data:image/png;base64," + new String(base64Bytes); + } + } + object.put("imgSrc", imgSrc); + repositoryArr.add(object); + } + return repositoryArr; + } + /** + * 依据流程库Id获取该流程库主题风格的轮播图资源 + * @param me + * @return + */ + public String bannerCarouselData(UserContext me ) { + ResponseObject ro = ResponseObject.newOkResponse(); + // dc中文件目录 + DCContext bannerDcContext = null; + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, "portalTheme"); + if (dcProfile != null) { + bannerDcContext = new DCContext(_uc, dcProfile, "portal", "banner"); + } + // 轮播图文件 + JSONArray pictures = new JSONArray(); + int total = 0; + if (bannerDcContext != null) { + File file = new File(bannerDcContext.getPath()); + if (file.exists()) { + File [] files = file.listFiles(); + if (files != null) { + // 按照名称排序 + List fileList = Arrays.asList(files); + total = fileList.size(); + Collections.sort(fileList, new Comparator() { + @Override + public int compare(File o1, File o2) { + if (o1.isDirectory() && o2.isFile()) + return -1; + if (o1.isFile() && o2.isDirectory()) + return 1; + return o1.getName().compareTo(o2.getName()); + } + }); + for (int i = 0; i < fileList.size(); i++) { + File file2 = files[i]; + String src = new DCContext(_uc, dcProfile, CoEConstant.APP_ID, "portal", "banner", file2.getName()).getDownloadURL(); + JSONObject object = new JSONObject(); + object.put("index", i); + object.put("src", src); + object.put("name", file2.getName()); + pictures.add(object); + } + } + } + } + // + JSONObject data = new JSONObject(); + data.put("pictures", pictures);//图片资源 + data.put("sid", me.getSessionId()); + data.put("total", total); //图片总数 + ro.put("data", data); + return ro.toString(); + } + + /*********************永辉接口end***************************/ + + /** + * 查询“我参与的”流程 + * @param me + * @param count + * @return + */ + public String participantDataQuery(UserContext me, String count) { + int c = Integer.parseInt(count); + if (c < 0) { + throw new AWSException("xpages配置参数错误count=" + count); + } + Map result = new HashMap(); + result.put("sid", me.getSessionId()); + result.put("uid", me.getUID()); + JSONArray array = new JSONArray(); + // 获取当前人权限下的已发布流程ID集合 + Set ids = getAwsOrgPermRealtionRepositoryByUser(me, "process", true); + // 发布时间倒序 + List list = new ArrayList<>(); + for (String id : ids) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model != null) { + list.add(model); + } + } + Collections.sort(list, new MyComparator());// 排序 + PublishListHistory pHistory = new PublishListHistory(); + for (int i = 0; i < list.size() && i < c; i++) { + PALRepositoryModel model = list.get(i); + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("name", model.getName()); + object.put("versionId", model.getVersionId()); + object.put("method", model.getMethodId()); + object.put("date", model.getPublishDate() == null ? "" : model.getPublishDate()); + String taskId = pHistory.getLastPublishTaskIdByModelId(model.getId()); + object.put("taskId", taskId == null ? "" : taskId); + array.add(object); + } + result.put("data", array); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.xpages.participant.html", result); + } + + /** + * 查询“我负责的“流程 + * @param me + * @param count + * @return + */ + public String responsibleDataQuery(UserContext me, String count) { + int c = Integer.parseInt(count); + if (c < 0) { + throw new AWSException("xpages配置参数错误count=" + count); + } + Map result = new HashMap(); + result.put("sid", me.getSessionId()); + result.put("uid", me.getUID()); + JSONArray array = new JSONArray(); + // 获取责任人是当前人的已发布流程ID集合 + Set ids = getPermRepositoryByDutyPerson(me, "process", true); + List list = new ArrayList<>(); + for (String id : ids) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model != null) { + list.add(model); + } + } + Collections.sort(list, new MyComparator());// 排序 + PublishListHistory pHistory = new PublishListHistory(); + for (int i = 0; i < list.size() && i < c; i++) { + PALRepositoryModel model = list.get(i); + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("name", model.getName()); + object.put("versionId", model.getVersionId()); + object.put("method", model.getMethodId()); + object.put("date", model.getPublishDate() == null ? "" : model.getPublishDate()); + String taskId = pHistory.getLastPublishTaskIdByModelId(model.getId()); + object.put("taskId", taskId == null ? "" : taskId); + array.add(object); + } + result.put("data", array); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.xpages.responsible.html", result); + } + + /** + * 岗位职责模块查询 + * @param me + * @param count + * @return + */ + public String postresponsibilityDataQuery(UserContext me, String count) { + int c = Integer.parseInt(count); + if (c < 0) { + throw new AWSException("xpages配置参数错误count=" + count); + } + Map result = new HashMap(); + result.put("sid", me.getSessionId()); + result.put("uid", me.getUID()); + + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.xpages.postresponsibility.html", result); + } + + /** + * RCAI模块查询 + * @param me + * @param count + * @return + */ + public String rcaimatrixDataQuery(UserContext me, String count) { + int c = Integer.parseInt(count); + if (c < 0) { + throw new AWSException("xpages配置参数错误count=" + count); + } + Map result = new HashMap(); + result.put("sid", me.getSessionId()); + result.put("uid", me.getUID()); + // 获取当前人的所有角色 + String userId = me.getUID(); + Set roleIds = new HashSet<>(); + RoleModel role = me.getRoleModel(); + roleIds.add(role.getId()); + // 兼职角色 + List userMapModels = UserMapCache.getMapListOfUser(userId); + if (!isEmpty(userMapModels)) { + for (UserMapModel usermap : userMapModels) { + roleIds.add(usermap.getRoleId()); + } + } + // 获取当前人权限下的已发布流程ID集合 + Set ids = getAwsOrgPermRealtionRepositoryByUser(me, "process", true); + List list = new ArrayList<>(); + for (String id : ids) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model != null) { + list.add(model); + } + } + // 按照发布时间/名称排序 + Collections.sort(list, new Comparator() { + @Override + public int compare(PALRepositoryModel o1, PALRepositoryModel o2) { + Timestamp time1 = o1.getPublishDate(); + Timestamp time2 = o2.getPublishDate(); + if (time1 != null && time2 != null) { + if (!time1.equals(time2)) { + return time2.compareTo(time1); + } + } + return o1.getName().compareTo(o2.getName()); + } + }); + JSONArray data = new JSONArray(); + int index = 0; + // 获取流程的任务 + for (PALRepositoryModel model : list) { + if (index >= c) { + break; + } + String repositoryId = model.getId(); + String dutyUser = model.getDutyUser(); + String dutyUserName = ""; + if (!UtilString.isEmpty(dutyUser)) { + UserModel userModel = SDK.getORGAPI().getUser(dutyUser); + if (userModel != null) { + dutyUserName = userModel.getUserName(); + } + } + String name = model.getName(); + // 节点集合 + List> shapeList = CoeDesignerUtil.getShapeMessageJson2(repositoryId); + // 排序 + OutputWordUtil.orderByNumber(shapeList); + for (Map shape : shapeList) { + JSONObject trObj = new JSONObject();// 每一行数据 + trObj.put("duty_r", ""); + trObj.put("counselor_c", ""); + trObj.put("approval_a", ""); + trObj.put("notify_i", ""); + Set relation = new HashSet<>(); + JSONObject dataAttributes = (JSONObject)shape.get("attributes"); + if (dataAttributes != null) { + JSONArray dataAttributesJsonArray = dataAttributes.getJSONArray("attributesJsonArray"); + Map shapeModelMap = OutputWordUtil.getShapeRelationMap(repositoryId, (String) shape.get("id")); + boolean flag = false; + for (int i = 0; i < dataAttributesJsonArray.size(); i++) { + String values = ""; + JSONObject dataAttribute = dataAttributesJsonArray.getJSONObject(i); + // 获取awsorg类型等属性 + if (dataAttribute != null && dataAttribute.containsKey("type") && "awsorg".equals(dataAttribute.getString("type"))) { + String key = dataAttribute.getString("key"); + String attributeValue = dataAttribute.getString("value"); + StringBuilder keyValue = new StringBuilder(); + if (key != null) { + if (attributeValue != null && attributeValue.length() != 0) { + attributeValue = attributeValue.replace("[", "").replace("]", "").replace("\"", ""); + String[] keyValues = OutputWordUtil.removeRepeat(attributeValue, ",").split(","); + for (String keyId : keyValues) { + if (!"".equals(keyId) && shapeModelMap.containsKey(keyId)) { + String text = shapeModelMap.get(keyId); + JSONObject object = JSONObject.parseObject(text); + String type = object.getString("type"); + if ("department".equals(type)) {// 部门 + DepartmentModel deptModel = SDK.getORGAPI().getDepartmentById(keyId); + if (deptModel != null) { + keyValue.append(OutputWordUtil.specialCharTransfer(deptModel.getName())).append(","); + } + } + if ("user".equals(type)) {// 人员 + UserModel userModel = SDK.getORGAPI().getUser(keyId); + if (userModel != null) { + if (userModel.getUID().equals(me.getUID())) { + relation.add(dataAttribute.getString("key")); + } + keyValue.append(OutputWordUtil.specialCharTransfer(userModel.getUserName())).append(","); + } + } + if ("role".equals(type)) {// 角色 + RoleModel roleModel = SDK.getORGAPI().getRoleById(keyId); + if (roleModel != null) { + if (roleIds.contains(roleModel.getId())) { + relation.add(dataAttribute.getString("key")); + } + keyValue.append(OutputWordUtil.specialCharTransfer(roleModel.getName())).append(","); + } + } + } + } + } + } + if (keyValue.length() > 0) { + values = keyValue.toString().substring(0, keyValue.length() - 1); + if ("duty_r".equals(dataAttribute.getString("key"))) {// R 责任者 + flag = true; + trObj.put("duty_r", values); + } else if ("counselor_c".equals(dataAttribute.getString("key"))) {// C 咨询者 + flag = true; + trObj.put("counselor_c", values); + } else if ("approval_a".equals(dataAttribute.getString("key"))) {// A 审批者 + flag = true; + trObj.put("approval_a", values); + } else if ("notify_i".equals(dataAttribute.getString("key"))) {// I 知会者 + flag = true; + trObj.put("notify_i", values); + } + } + } + } + if (!flag) { + continue; + } + trObj.put("id", repositoryId);// 流程ID + trObj.put("name", name);// 流程名称 + trObj.put("shapeId", (String) shape.get("id"));// 节点ID + trObj.put("shapeName", shape.get("text").toString());// 任务 + trObj.put("shapeDesc", (OutputWordUtil.specialCharTransfer((String)dataAttributes.get("shapeDesc"))));// 任务描述 + trObj.put("dutyUser", dutyUserName);// 责任人 + trObj.put("relation", ""); + StringBuilder sb = new StringBuilder(); + if (relation.contains("duty_r")) { + sb.append("duty_r").append(","); + } + if (relation.contains("counselor_c")) { + sb.append("counselor_c").append(","); + } + if (relation.contains("approval_a")) { + sb.append("approval_a").append(","); + } + if (relation.contains("notify_i")) { + sb.append("notify_i").append(","); + } + trObj.put("relation", sb.toString()); + data.add(trObj); + index++; + if (index >= c) { + break; + } + } + } + } + result.put("data", data); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.xpages.rcaimatrix.html", result); + } + + + /** + * 得到流程资产库的数据和组织单元的数据 + * + * @return + */ + public String getCoeWorkSpaceAndOrgInfo() { + ResponseObject ro = ResponseObject.newOkResponse(); + //workspaces:资产库信息;//units:组织单元信息 + JSONObject data = new JSONObject(); + //可用的资产库信息 + List workspaceList = CoeWorkSpaceDaoFactory.createCoeWorkSpace().getCoeWorkSpaceModelRecodesNoPage(); + JSONArray workspaces = new JSONArray(); + if(workspaceList!=null && workspaceList.size()>0) { + for(CoeWorkSpaceModel workspace : workspaceList) { + JSONObject obj = new JSONObject(); + obj.put("id", workspace.getUUId()); + obj.put("name", workspace.getWsName()); + workspaces.add(obj); + } + } + data.put("workspaces", workspaces); + //组织单元信息 + List companyList = SDK.getORGAPI().getCompanys(); + JSONArray companys = new JSONArray(); + if(companyList!=null && companyList.size()>0) { + for(CompanyModel company : companyList) { + JSONObject obj = new JSONObject(); + obj.put("id", company.getId()); + obj.put("name", company.getNameI18N()); + companys.add(obj); + } + } + data.put("companys", companys); + ro.put("data",data); + return ro.toString(); + } + + public String openPage(UserContext me, String uuid, String taskId) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + if (model != null && "process".equals(model.getMethodCategory()) && UtilString.isEmpty(taskId)) { + taskId = new PublishListHistory().getLastPublishTaskIdByModelId(uuid); + } + return PALRepositoryQueryAPIManager.getInstance().getPublishPortalHtml(me, uuid, taskId); + } +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishWeb.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishWeb.java new file mode 100644 index 00000000..ea7d24bb --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/web/ProcessPublishWeb.java @@ -0,0 +1,3020 @@ +package com.actionsoft.apps.coe.pal.publisher.client.web; + +import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.*; +import java.util.stream.Collectors; + +import com.actionsoft.apps.coe.pal.constant.CoEConstant; +import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager; +import com.actionsoft.apps.coe.pal.cooperation.model.CoeCooperationTeamModel; +import com.actionsoft.apps.coe.pal.pal.manage.publish.PublishAPIManager; +import com.actionsoft.apps.coe.pal.pal.manage.publish.cache.PublishHistoryCache; +import com.actionsoft.apps.coe.pal.pal.manage.publish.constant.PublishConst; +import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishListHistory; +import com.actionsoft.apps.coe.pal.pal.manage.publish.model.PublishHistoryModel; +import com.actionsoft.apps.coe.pal.pal.manage.publish.model.PublishListHistoryModel; +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.repository.PALRepositoryQueryAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository; +import com.actionsoft.apps.coe.pal.pal.repository.model.CoeProcessLevelAutoBean; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl; +import com.actionsoft.apps.coe.pal.pal.repository.util.RepositoryTreeUtil; +import com.actionsoft.apps.coe.pal.pal.ws.web.VersionUtil; +import com.actionsoft.apps.coe.pal.publisher.client.dao.PublisherClientDao; +import com.actionsoft.apps.coe.pal.publisher.client.dto.ProcessPublishDTO; +import com.actionsoft.apps.coe.pal.publisher.client.dto.ProcessPublishHistoryDTO; +import com.actionsoft.apps.coe.pal.publisher.conf.PublisherConf; +import com.actionsoft.apps.coe.pal.publisher.constant.PublisherConstant; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.constant.TaskRuntimeConst; +import com.actionsoft.bpms.bpmn.constant.UserTaskRuntimeConst; +import com.actionsoft.bpms.bpmn.engine.cache.ProcessDefCache; +import com.actionsoft.bpms.bpmn.engine.cache.util.UserTaskDefUtil; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionTrack; +import com.actionsoft.bpms.bpmn.engine.model.def.ProcessDefinition; +import com.actionsoft.bpms.bpmn.engine.model.def.UserTaskModel; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.HistoryTaskInstance; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance; +import com.actionsoft.bpms.commons.htmlframework.AlertWindow; +import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate; +import com.actionsoft.bpms.commons.mvc.view.ActionWeb; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.form.engine.FormEngineHelper; +import com.actionsoft.bpms.org.cache.UserCache; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.server.Quota; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.util.*; +import com.actionsoft.exception.AWSException; +import com.actionsoft.i18n.I18nRes; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.AppAPI; +import com.actionsoft.sdk.local.api.ProcessExecuteQuery; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import org.apache.commons.lang.StringUtils; + +/** + * 流程发布App + * + */ +public class ProcessPublishWeb extends ActionWeb { + private UserContext _uc; + + public ProcessPublishWeb() { + } + + public ProcessPublishWeb(UserContext userContext) { + super(userContext); + _uc = userContext; + } + + public String mainPage(UserContext context, String wsId, String teamId) { + _uc = context; + //新页面 + return processPublishNewPage(teamId, wsId); + } + + /** + * 流程发布重构后新页面 + * + * @param teamId + * @param wsId + * @return + */ + public String processPublishNewPage(String teamId, String wsId) { + String teamName = ""; + boolean isActive = PALRepositoryQueryAPIManager.getInstance().isActiveWorkSpace(wsId); + if (!isActive) { + return AlertWindow.getAuthorityMessagePage("资产库被停用", "资产库被停用,该小组无法访问流程发布功能,请联系系统管理员"); + } + if (UtilString.isNotEmpty(teamId)) { + CoeCooperationTeamModel team = CoeCooperationAPIManager.getInstance().queryCooperationTeamById(teamId, true); + if (team == null) { + return AlertWindow.getAuthorityMessagePage("小组查询失败", "小组不存在或已停用,该小组无法访问流程发布功能,请联系系统管理员"); + } + if (!team.getWsId().equals(wsId)) { + return AlertWindow.getAuthorityMessagePage("小组信息错误", "小组与对应的资产库信息不匹配,参数错误,请联系系统管理员"); + } + teamName = team.getTeamName(); + } + ProcessDefinition processDef = ProcessDefCache.getInstance().getModel(PublisherConstant.PROCESSID); + String title = processDef.getDefaultInstanceTitle(); + Map macroLibraries = new HashMap(); + macroLibraries.put("teamId", teamId == null ? "" : teamId); + macroLibraries.put("teamName", teamName); + macroLibraries.put("wsId", wsId); + if (title == null || "".equals(title)) { + title = Quota.getMaxCoEPALUser() <= 0 ? "PAL流程发布" : "流程发布"; + } + macroLibraries.put("title", title); + macroLibraries.put("sessionId", _uc.getSessionId()); + macroLibraries.put("settingParam", JSON.toJSON(macroLibraries)); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.home.newPage.html", macroLibraries); + } + + /** + * 待办任务列表 + * + * @return + */ + public String getTaskInstanceList(int start, int size) { + String uid = _uc.getUID(); + List list = SDK.getTaskQueryAPI().processGroupId(PublisherConstant.PROCESSGROUPID).target(uid) + .listPage(start * size + 1, size);// 待办 + List totalList = SDK.getTaskQueryAPI().processGroupId(PublisherConstant.PROCESSGROUPID) + .target(uid).list(); // 所有待办 + StringBuilder html = new StringBuilder(); + int i = 1; + if (list != null && list.size() > 0) { + i = 1; + for (TaskInstance taskInstance : list) { + int num = start * size + i; + String owner = taskInstance.getOwner(); + if (UserCache.getModel(owner) != null) { + owner = UserCache.getModel(owner).getUserName(); + } + boolean hasRead = taskInstance.getReadTime() == null ? false : true; + String className = ""; + if (!hasRead) { + className = "task_no_read"; + } + String checkBox = ""; + // 任务发起人可以删除任务 + if ("00000000-0000-0000-0000-000000000000".equals(taskInstance.getParentTaskInstId())) { + checkBox = ""; + } + String openState = ""; + if (taskInstance.getState() == UserTaskRuntimeConst.STATE_TYPE_SYSTEM_NOTIFY) { + openState = "2"; + } + html.append("" + + " " + num + "" + " " + checkBox + + "" + "
" + taskInstance.getTitle() + "
" + + "
" + owner + "
" + " " + + UtilDate.datetimeFormat(taskInstance.getBeginTime()) + "" + ""); + i++; + } + } + + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("totalSize", totalList == null ? 0 : totalList.size()); + ro.put("html", html.toString()); + return ro.toString(); + } + + /** + * 新版待办列表 + * + * @param start + * @param size + * @return + */ + public String getNewTaskInstanceList(int start, int size, String search) { + ResponseObject res = ResponseObject.newOkResponse(); + String uid = _uc.getUID(); + List list = SDK.getTaskQueryAPI().processGroupId(PublisherConstant.PROCESSGROUPID).target(uid).list();// 待办 + List processPublishDTOS = Lists.newArrayList(); + if (list != null && list.size() > 0) { + list = list.stream().filter(taskInstance -> taskInstance.getState() != UserTaskRuntimeConst.STATE_TYPE_SYSTEM_NOTIFY).collect(Collectors.toList()); + handleNewTaskInstanceList(list, processPublishDTOS, search, ""); + } + if (processPublishDTOS.size() > (start * size + size)) { + res.put("data", processPublishDTOS.subList(0, start * size + size)); + } else { + res.put("data", processPublishDTOS); + } + res.put("count", processPublishDTOS.size()); + return res.toString(); + } + + /** + * 新版待阅列表 + * + * @param start + * @param size + * @param search + * @return + */ + public String getNewTaskInstanceListForRead(int start, int size, String search) { + ResponseObject res = ResponseObject.newOkResponse(); + String uid = _uc.getUID(); + List list = SDK.getTaskQueryAPI().processGroupId(PublisherConstant.PROCESSGROUPID).target(uid).list();// 待办 + List processPublishDTOS = Lists.newArrayList(); + if (list != null && list.size() > 0) { + list = list.stream().filter(taskInstance -> taskInstance.getState() == UserTaskRuntimeConst.STATE_TYPE_SYSTEM_NOTIFY).collect(Collectors.toList()); + handleNewTaskInstanceList(list, processPublishDTOS, search, "2"); + } + if (processPublishDTOS.size() > (start * size + size)) { + res.put("data", processPublishDTOS.subList(0, start * size + size)); + } else { + res.put("data", processPublishDTOS); + } + res.put("count", processPublishDTOS.size()); + return res.toString(); + } + + /** + * 处理待办待阅数据 + * + * @param list + * @param processPublishDTOS + * @param search + * @param openState + */ + private void handleNewTaskInstanceList(List list, List processPublishDTOS, String search, String openState) { + for (TaskInstance taskInstance : list) { + ProcessPublishDTO dto = new ProcessPublishDTO(); + dto.setProcessInstId(taskInstance.getProcessInstId()); + dto.setTitle(taskInstance.getTitle()); + UserModel userModel = UserCache.getModel(taskInstance.getOwner()); + String owner = userModel.getUserName(); + String deptName = SDK.getORGAPI().getDepartmentById(userModel.getDepartmentId()).getName(); + String fromUser = owner + "/" + deptName; + dto.setFromUser(fromUser); + dto.setDate(UtilDate.datetimeFormat(taskInstance.getBeginTime())); + dto.setOpenState(openState); + dto.setOwnerProcess("00000000-0000-0000-0000-000000000000".equals(taskInstance.getParentTaskInstId())); + dto.setTaskInstId(taskInstance.getId()); + if (StringUtils.isNotBlank(search)) { + if (fromUser.toLowerCase().contains(search.toLowerCase())) { + processPublishDTOS.add(dto); + } + } else { + processPublishDTOS.add(dto); + } + } + int index = 1; + for (ProcessPublishDTO dto : processPublishDTOS) { + dto.setIndex(index); + index++; + } + } + + /** + * 已办任务列表 + * + * @return + */ + public String getHistoryTaskInstanceList(int start, int size) { + String uid = _uc.getUID(); + List list = SDK.getHistoryTaskQueryAPI().processGroupId(PublisherConstant.PROCESSGROUPID) + .target(uid).listPage(start * size + 1, size);// 已办 + List totalList = SDK.getHistoryTaskQueryAPI() + .processGroupId(PublisherConstant.PROCESSGROUPID).target(uid).list();// 已办 + StringBuilder html = new StringBuilder(); + int i = 1; + if (list != null && list.size() > 0) { + i = 1; + for (HistoryTaskInstance historyTaskInstance : list) { + int num = start * size + i; + String owner = historyTaskInstance.getOwner(); + if (UserCache.getModel(owner) != null) { + owner = UserCache.getModel(owner).getUserName(); + } + boolean hasRead = historyTaskInstance.getReadTime() == null ? false : true; + String className = ""; + if (!hasRead) { + className = "task_no_read"; + } + html.append("" + + " " + num + "" + + "
" + historyTaskInstance.getTitle() + "
" + + "
" + owner + "
" + " " + + UtilDate.datetimeFormat(historyTaskInstance.getBeginTime()) + "" + ""); + i++; + } + } + + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("totalSize", totalList == null ? 0 : totalList.size()); + ro.put("html", html.toString()); + return ro.toString(); + } + + /** + * 新版已办列表 + * + * @param start + * @param size + * @param search + * @return + */ + public String getNewHistoryTaskInstanceList(int start, int size, String search) { + ResponseObject res = ResponseObject.newOkResponse(); + String uid = _uc.getUID(); + List list = SDK.getHistoryTaskQueryAPI().processGroupId(PublisherConstant.PROCESSGROUPID).target(uid).list();// 已办 + List processPublishDTOS = Lists.newArrayList(); + if (list != null && list.size() > 0) { + list = list.stream().filter(historyTaskInstance -> historyTaskInstance.getState() != UserTaskRuntimeConst.STATE_TYPE_SYSTEM_NOTIFY).collect(Collectors.toList()); + handleNewHistoryTaskInstanceList(list, processPublishDTOS, search); + } + if (processPublishDTOS.size() > (start * size + size)) { + res.put("data", processPublishDTOS.subList(0, start * size + size)); + } else { + res.put("data", processPublishDTOS); + } + res.put("count", processPublishDTOS.size()); + return res.toString(); + } + + /** + * 新版已阅列表 + * + * @param start + * @param size + * @param search + * @return + */ + public String getNewHistoryTaskInstanceListForRead(int start, int size, String search) { + ResponseObject res = ResponseObject.newOkResponse(); + String uid = _uc.getUID(); + List list = SDK.getHistoryTaskQueryAPI().processGroupId(PublisherConstant.PROCESSGROUPID).target(uid).list();// 已办 + List processPublishDTOS = Lists.newArrayList(); + if (list != null && list.size() > 0) { + list = list.stream().filter(historyTaskInstance -> historyTaskInstance.getState() == UserTaskRuntimeConst.STATE_TYPE_SYSTEM_NOTIFY).collect(Collectors.toList()); + handleNewHistoryTaskInstanceList(list, processPublishDTOS, search); + } + if (processPublishDTOS.size() > (start * size + size)) { + res.put("data", processPublishDTOS.subList(0, start * size + size)); + } else { + res.put("data", processPublishDTOS); + } + res.put("count", processPublishDTOS.size()); + return res.toString(); + } + + /** + * 处理已办已阅数据 + * + * @param list + * @param processPublishDTOS + * @param search + */ + private void handleNewHistoryTaskInstanceList(List list, List processPublishDTOS, String search) { + for (HistoryTaskInstance historyTaskInstance : list) { + ProcessPublishDTO dto = new ProcessPublishDTO(); + dto.setProcessInstId(historyTaskInstance.getProcessInstId()); + dto.setTitle(historyTaskInstance.getTitle()); + UserModel userModel = UserCache.getModel(historyTaskInstance.getOwner()); + String owner = userModel.getUserName(); + String deptName = SDK.getORGAPI().getDepartmentById(userModel.getDepartmentId()).getName(); + String fromUser = owner + "/" + deptName; + dto.setFromUser(fromUser); + dto.setDate(UtilDate.datetimeFormat(historyTaskInstance.getBeginTime())); + dto.setOwnerProcess(false); + dto.setOpenState("2"); + dto.setTaskInstId(historyTaskInstance.getId()); + if (StringUtils.isNotBlank(search)) { + if (fromUser.toLowerCase().contains(search.toLowerCase())) { + processPublishDTOS.add(dto); + } + } else { + processPublishDTOS.add(dto); + } + } + int index = 1; + for (ProcessPublishDTO dto : processPublishDTOS) { + dto.setIndex(index); + index++; + } + } + + /** + * 历史任务列表 + * + * @return + */ + public String getProcessInstanceList(int pageNum, int size) { + List list = SDK.getProcessQueryAPI().processGroupId(PublisherConstant.PROCESSGROUPID) + .finished().listPage(pageNum * size + 1, size);// 历史 + List totalList = SDK.getProcessQueryAPI().processGroupId(PublisherConstant.PROCESSGROUPID) + .finished().list();// 历史 + StringBuilder html = new StringBuilder(); + int i = 1; + if (list != null && list.size() > 0) { + i = 1; + for (ProcessInstance processInstance : list) { + int num = pageNum * size + i; + String creater = processInstance.getCreateUser(); + if (UserCache.getModel(creater) != null) { + creater = UserCache.getModel(creater).getUserName(); + } + html.append("" + " " + num + + "" + "
" + processInstance.getTitle() + "
" + + "
" + creater + "
" + " " + + UtilDate.datetimeFormat(processInstance.getCreateTime()) + "" + " "); + i++; + } + } + + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("totalSize", totalList == null ? 0 : totalList.size()); + ro.put("html", html.toString()); + return ro.toString(); + } + + /** + * 打开流程发布-历史记录-新页面 + * + * @param me + * @return + */ + public String getNewProcessInstanceListPage(UserContext me) { + Map macroLibraries = Maps.newHashMap(); + macroLibraries.put("sid", me.getSessionId()); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.home.history.html", macroLibraries); + } + + /** + * 分页查询流程发布历史记录 + * + * @param start + * @param size + * @return + */ + public String getNewProcessInstanceList(int start, int size, String search) { + ResponseObject res = ResponseObject.newOkResponse(); + //声明数据集合 + List processPublishHistoryDTOList = Lists.newArrayList(); + //获取所有流程数据 + List totalList = SDK.getProcessQueryAPI().processGroupId(PublisherConstant.PROCESSGROUPID).list(); + boolean flag = false; + String searchValue = ""; + if (StringUtils.isNotBlank(search)) { + flag = true; + searchValue = search.toLowerCase(); + } + for (ProcessInstance processInstance : totalList) { + ProcessPublishHistoryDTO dto = new ProcessPublishHistoryDTO(); + dto.setTitle(processInstance.getTitle()); + String creater = processInstance.getCreateUser(); + if (UserCache.getModel(creater) != null) { + creater = UserCache.getModel(creater).getUserName(); + } + dto.setCreateUser(creater); + dto.setCreateTime(UtilDate.datetimeFormat(processInstance.getCreateTime())); + List taskList = SDK.getTaskQueryAPI().processInstId(processInstance.getId()).activeTask().list(); + String transactor; + String transactorId; + StringBuilder transactorIdSb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); + String approvalState; + for (TaskInstance taskInstance : taskList) { + String title = taskInstance.getTitle(); + if (title.contains("流程通知")) { + continue; + } + transactor = taskInstance.getTarget(); + UserModel userModel = SDK.getORGAPI().getUser(transactor); + if (userModel != null) { + // 多人审核追加 + transactorIdSb.append(transactor).append(","); + sb.append(userModel.getUserName() + "/").append(SDK.getORGAPI().getDepartmentById(userModel.getDepartmentId()).getName()).append(","); + } + } + + if (sb.length() > 0) { + transactor = sb.substring(0, sb.length() - 1); + transactorId = transactorIdSb.substring(0, transactorIdSb.length() - 1); + } else { + transactor = sb.toString(); + transactorId = transactorIdSb.toString(); + } + // 查询流程实例是否结束 + boolean isEnd = processInstance.isEnd(); + if (isEnd) { + transactor = "无"; + approvalState = "已完成"; + } else { + approvalState = "审批中"; + } + dto.setApprovalUser(transactor); + dto.setApprovalState(approvalState); + dto.setApprovalUserId(transactorId); + dto.setProcessInstId(processInstance.getId()); + dto.setEnd(isEnd); + dto.setTaskInstId(processInstance.getStartTaskInstId()); + + //类型的获取 + List type = Lists.newArrayList(); + BO publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").detailByBindId(processInstance.getId()); + if (publish == null) { + dto.setType(""); + } else { + String bindId = publish.getBindId(); + List n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").addQuery("BINDID=", bindId).list(); + if (n != null && n.size() > 0) { + type.add("发布" + n.size()); + } + List c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").addQuery("BINDID=", bindId).list(); + if (c != null && c.size() > 0) { + type.add("更新" + c.size()); + } + List s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S").addQuery("BINDID=", bindId).list(); + if (s != null && s.size() > 0) { + type.add("废止" + s.size()); + } + dto.setType(Joiner.on(",").join(type)); + } + + //处理返回数据根据搜索条件 + if (flag) { + if (dto.getTitle().toLowerCase().contains(searchValue) || dto.getCreateUser().contains(searchValue) + || dto.getType().toLowerCase().contains(searchValue) || dto.getApprovalState().toLowerCase().contains(searchValue)) { + processPublishHistoryDTOList.add(dto); + } + } else { + processPublishHistoryDTOList.add(dto); + } + } + if (processPublishHistoryDTOList.size() > (start * size + size)) { + res.put("data", processPublishHistoryDTOList.subList(0, start * size + size)); + } else { + res.put("data", processPublishHistoryDTOList); + } + res.put("count", processPublishHistoryDTOList.size()); + return res.toString(); + } + + /** + * 发送催办通知(暂时没有用) + * + * @param me + * @param processInstId + * @return + */ + public String sendMessageUrge(UserContext me, String processInstId) { + BO publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").detailByBindId(processInstId); + if (publish == null) { + return ResponseObject.newErrResponse("not found processInstance").toString(); + } + ProcessDefinition processDef = ProcessDefCache.getInstance().getModel(publish.getProcessDefId()); + String reminderConfig = processDef.getNotifyConfig(); + JSONObject object = JSON.parseObject(reminderConfig); + JSONArray taskReminder = object.getJSONArray("taskReminder"); + if (taskReminder.size() > 0) { + //发送催办 + try{ + SDK.getProcessAPI().remindMailById(me.getUID(), processInstId); + } catch (AWSException e) { + return ResponseObject.newErrResponse(e.getMessage()).toString(); + } + return ResponseObject.newOkResponse().toString(); + } else { + return ResponseObject.newErrResponse("流程催办未开启,请先开启").toString(); + } + } + + /** + * 保存流程实例,并打开流程页面 + * + * @param title 流程标题 + * @return + */ + public String savePublishInstance(String title, String teamId, String teamName, String wsId) { + AppAPI appApi = SDK.getAppAPI(); + String processDefId = ""; + String selectionmode = appApi.getProperty(PublisherConstant.PUBLISH, "selectionmode"); + if ("radio".equals(selectionmode)) { + processDefId = appApi.getProperty("com.actionsoft.apps.coe.pal.publisher", "newPublishProcessId"); + } else if ("check".equals(selectionmode) || "checkInherit".equals(selectionmode)) { + processDefId = appApi.getProperty(PublisherConstant.PUBLISH, "publishProcessId"); + } + ProcessDefinition processDef = (ProcessDefinition) ProcessDefCache.getInstance().getModel(processDefId); + // 先建立bo再运行任务 + // 创建流程实例 + ProcessInstance processInstModel = null; + try { + processInstModel = SDK.getProcessAPI().createProcessInstance(processDefId, _uc.getUID(), title); + } catch (Exception e) { + e.printStackTrace(); + return ResponseObject.newErrResponse(e.getMessage()).toString(); + } + BO bo = new BO(); + bo.set("TEAMID", teamId); + bo.set("TEAMNAME", teamName); + bo.set("WSID", wsId); + bo.set("PUBLISHID", UUIDGener.getUUID()); + bo.set("APPLYUSERID", _uc.getUID()); + bo.set("APPLYUSERNAME", _uc.getUserName()); + String deptId = _uc.getUserModel().getDepartmentId(); + bo.set("APPLYDEPTID", deptId); + bo.set("APPLYDEPTNAME", SDK.getORGAPI().getDepartmentById(deptId).getName()); + bo.set("APPLYDATE", new Date()); + bo.set("SAVESTATUS", 1);//流程实例状态 + SDK.getBOAPI().create(PublisherConstant.BOTABLENAME, bo, processInstModel, _uc); + + ProcessExecuteQuery execquery = SDK.getProcessAPI().start(processInstModel); + List tracks = execquery.fetch(); + TaskInstance userTaskInst = null; + String targetUserInfo = ""; + for (ProcessExecutionTrack track : tracks) { + if (track.getObjectList() != null) { + List taskList = track.getObjectList(); + for (Object o : taskList) { + if (o instanceof TaskInstance) { + TaskInstance taskInst = (TaskInstance) o; + if (taskInst.getActivityType().equals(TaskRuntimeConst.ACTIVITY_TYPE_USERTASK)) { + if (taskInst.getTarget().equals(getContext().getUID())) { + userTaskInst = taskInst; + break;// 如果是多例的人工任务,只拿第1个给当前人打开表单 + } else { + targetUserInfo += " " + SDK.getORGAPI().getUserAliasNames(taskInst.getTarget()); + } + } + } + } + } + } + + ResponseObject ro = ResponseObject.newOkResponse(); + JSONObject object = new JSONObject(); + object.put("processInstId", processInstModel.getId()); + object.put("taskInstId", userTaskInst.getId()); + ro.put("data", object); + return ro.toString(); + } + + /** + * 跳转到流程实例办理页面 + * + * @param processInstId + * @param taskInstId + * @param openState 2:只读 + * @return + */ + public String toPublishInstanceHandle(String processInstId, String taskInstId, String openState) { + int openType = 2; + if (openState != null && !"".equals(openState)) { + openType = Integer.parseInt(openState); + } else { + return SDK.getFormAPI().getFormPage(_uc, processInstId, taskInstId, 1, 1, null, null); + } + + return SDK.getFormAPI().getFormPage(_uc, processInstId, taskInstId, openType, 1, null, null); + } + + /** + * 删除流程实例 + * + * @param processInstIds + * @return + */ + public String removeProcessInstance(String processInstIds) { + String[] processInstIdArray = processInstIds.split(","); + StringBuilder errorTask = new StringBuilder(); + int successNum = 0; // 删除成功的条数(分页需要) + int errNum = 0; + for (String processInstId : processInstIdArray) { + if (processInstId.equals("")) { + continue; + } + boolean result = SDK.getProcessAPI().deleteById(processInstId, _uc.getUID()); + if (!result) { + ProcessInstance processInstModel = SDK.getProcessAPI().getInstanceById(processInstId); + if (processInstModel != null) { + errorTask.append(processInstModel.getTitle()).append(","); + errNum++; + } + } else { + successNum++; + } + } + if (errorTask.length() == 0) { + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("successNum", successNum); + return ro.toString(); + } else { + ResponseObject ro = ResponseObject.newErrResponse(errorTask.toString()); + ro.put("successNum", successNum); + ro.put("errNum", errNum); + return ro.toString(); + } + } + + /** + * 流程实例办理页面-新增发布申请-未发布流程 + * + * @param teamId + * @param wsId + * @return + */ + public String getNotPublishedRepositorys(String teamId, String wsId) { + String Type = SDK.getAppAPI().getProperty(PublisherConf.APPID, "selectionmode"); + boolean checkbox = false; + boolean checkInherit = false; + if ("radio".equals(Type)) { + checkbox = false; + checkInherit = false; + } + if ("check".equals(Type)) { + checkbox = true; + checkInherit = false; + } + if ("checkInherit".equals(Type)) { + checkbox = true; + checkInherit = true; + } + PALRepository dao = new PALRepository(); + if (UtilString.isNotEmpty(teamId)) { + // 小组Id不为空,则需要查询小组授权后的流程库 + CoeCooperationTeamModel team = CoeCooperationAPIManager.getInstance().queryCooperationTeamById(teamId, true); + if (team != null) { + wsId = team.getWsId(); + } + } + + List usedList = new ArrayList(); + List methodList = PALMethodManager.getInstance().list(); + for (String method : methodList) { + PALRepositoryQueryAPIManager.getInstance().getAllUsedPalRepositoryModelsByPid(wsId, method, usedList); + } + + List list = dao.getNotPublishedRepositoryList(wsId); + List removeList = new ArrayList(); + List removeUsedList = new ArrayList(); + if (UtilString.isNotEmpty(teamId)) { + List versionIds = CoeCooperationAPIManager.getInstance().queryCooperationRoleDataPermByTeamUser(teamId, _uc.getUID()); + // 小组Id不为空,删除不具有小组权限的流程 + if (list != null) { + for (PALRepositoryModel model : list) { + if (!versionIds.contains(model.getVersionId())) { + removeList.add(model); + } + } + list.removeAll(removeList); + } + if (usedList != null) { + for (PALRepositoryModel model : usedList) { + if (!versionIds.contains(model.getVersionId())) { + removeUsedList.add(model); + } + } + usedList.removeAll(removeUsedList); + } + } + StringBuilder checkboxIds = new StringBuilder(); + for (PALRepositoryModel model : list) { + checkboxIds.append(model.getId()).append(","); + } + JSONArray treeData = getRepositoryTree(usedList, wsId, false, true, checkboxIds.toString(), false); + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("treeData", treeData); + ro.put("checkbox", checkbox); + ro.put("checkInherit", checkInherit); + return ro.toString(); + } + + /** + * 流程实例办理页面-修改发布-已发布流程未发布版本 + * + * @param teamId + * @param wsId + * @param resourceId + * @return + */ + public String getNotPublishedVersionRepositorys(String teamId, String wsId, String resourceId) { + JSONArray ja = new JSONArray(); + PALRepository dao = new PALRepository(); + List list = dao.getPublishedRepositoryVersionListByRid(resourceId); + if (list != null) { + for (PALRepositoryModel model : list) { + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("name", model.getName()); + object.put("version", model.getVersion()); + ja.add(object); + } + } + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("treeData", ja); + return ro.toString(); + } + + /** + * 流程实例办理页面-停用发布-已发布流程 + * + * @param teamId + * @param wsId + * @return + */ + public String getPublishedRepositorys(String teamId, String wsId) { + + String Type = SDK.getAppAPI().getProperty(PublisherConf.APPID, "selectionmode"); + boolean checkbox = false; + boolean checkInherit = false; + if ("radio".equals(Type)) { + checkbox = false; + checkInherit = false; + } + if ("check".equals(Type)) { + checkbox = true; + checkInherit = false; + } + if ("checkInherit".equals(Type)) { + checkbox = true; + checkInherit = true; + } + + PALRepository dao = new PALRepository(); + if (UtilString.isNotEmpty(teamId)) { + // 小组Id不为空,则需要查询小组授权后的流程库 + CoeCooperationTeamModel team = CoeCooperationAPIManager.getInstance().queryCooperationTeamById(teamId, true); + if (team != null) { + wsId = team.getWsId(); + } + } + List list = dao.getPublishedRepositoryList(wsId); + List versionIds = CoeCooperationAPIManager.getInstance().queryCooperationRoleDataPermByTeamUser(teamId, _uc.getUID()); + if (UtilString.isNotEmpty(teamId)) { + if (list != null) { + List removeList = new ArrayList(); + for (PALRepositoryModel model : list) { + if (!versionIds.contains(model.getVersionId())) { + removeList.add(model); + } + } + list.removeAll(removeList); + } + } + + JSONArray treeData = getRepositoryTree(list, wsId, false, true, "-", false); + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("treeData", treeData); + ro.put("checkbox", checkbox); + ro.put("checkInherit", checkInherit); + return ro.toString(); + } + + /** + * 流程发布客户首页(普通用户) + * + * @return + */ + public String getClientHome() { + AppAPI appApi = SDK.getAppAPI(); + JSONArray wsTree = new JSONArray(); + String isIntegrationAWSUser = appApi.getProperty(PublisherConstant.PUBLISH, "isIntegrationAWSUser"); // 是否整合AWS用户 + String roleId = ""; + if ("false".equals(isIntegrationAWSUser)) { + roleId = PublishConst.GUESTROLE; + } else { + roleId = _uc.getRoleModel().getId(); + } + PALRepository dao = new PALRepository(); + List> allWsList = dao.getWorkSpaceListByPublishRole(roleId, false); + if (allWsList == null || allWsList.size() == 0) { + return AlertWindow.getAuthorityMessagePage("没有可访问的资产库文件", "未分配资产库访问权限,请联系系统管理员"); + } + List> wsList = dao.getWorkSpaceListByPublishRole(roleId, true); // 有访问权限的资产库 + JSONArray repositoryList = new JSONArray(); // 有访问权限的文件 + if (wsList != null && wsList.size() > 0) { + int i = 0; + List> removeList = new ArrayList>(); + for (Map ws : wsList) { + boolean isActive = PALRepositoryQueryAPIManager.getInstance().isActiveWorkSpace(ws.get("wsId")); + if (!isActive) { + removeList.add(ws); + } else { + JSONObject wsJson = new JSONObject(); + wsJson.put("id", ws.get("wsId")); + wsJson.put("name", ws.get("wsName")); + if (i == 0) { + wsJson.put("open", true); + } else { + wsJson.put("open", false); + } + wsJson.put("ws", true); + wsJson.put("wsName", ws.get("wsName")); + wsTree.add(wsJson); + i++; + } + } + wsList.removeAll(removeList); + + if (wsList.size() > 0) { + List repositoryModelList = dao.getRepositoryListByPublishRole(roleId, + wsList.get(0).get("wsId")); + repositoryList = getRepositoryTree(repositoryModelList, wsList.get(0).get("wsId"), true, false, null, false); + } else { + return AlertWindow.getWarningMessagePage("没有可访问的资产库文件", "资产库被停用,请联系系统管理员"); + } + } else { + return AlertWindow.getWarningMessagePage("没有可访问的资产库文件", "可访问流程未发布,请联系系统管理员"); + } + + if (repositoryList != null && repositoryList.size() > 0) { + wsTree.addAll(repositoryList); + } + + boolean isComment = PublisherConf.isComment(); // 允许留言 + boolean isViewHistory = PublisherConf.isViewHistory(); // 允许查看历史发布记录 + boolean isViewAttribute = PublisherConf.isViewAttribute(); // 允许查看属性 + boolean isPrint = PublisherConf.isPrint(); // 允许打印 + String fotter = PublisherConf.getFotter(); // 页底信息 + JSONObject dockDisplay = new JSONObject(); + if (!isComment) { + dockDisplay.put("messageView", "display: none;"); + } + if (!isViewHistory) { + dockDisplay.put("publishView", "display: none;"); + } + if (!isViewAttribute) { + dockDisplay.put("attributeView", "display: none;"); + } + if (!isPrint) { + dockDisplay.put("printView", "display: none;"); + } + + Map macroLibraries = new HashMap(); + macroLibraries.put("sid", this.getContext().getSessionId()); + macroLibraries.put("roleId", roleId); + macroLibraries.put("wsTree", wsTree); + macroLibraries.put("wsName", wsList.get(0).get("wsName")); + macroLibraries.put("dockDisplay", dockDisplay.toString()); + macroLibraries.put("fotter", fotter == null ? "" : fotter); + macroLibraries.put("appId", PublisherConf.APPID); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.home.html", macroLibraries); + } + + /** + * 获取有权限的流程树 + * + * @param roleId + * @param wsId + * @return + */ + public String getTreeData(String roleId, String wsId, String wsName) { + PALRepository dao = new PALRepository(); + List repositoryList = dao.getRepositoryListByPublishRole(roleId, wsId); + JSONArray data = getRepositoryTree(repositoryList, wsId, true, false, null, false); + + ResponseObject ro = ResponseObject.newOkResponse(data.toString()); + return ro.toString(); + } + + /** + * 获取有权限的流程树(多个资产库) + * + * @param wsId + * @param multiWs + * @return + */ + public JSONArray getRepositoryTree(List repositoryList, String wsId, boolean multiWs, boolean checkbox, String checkboxIds, boolean flag) { + return getRepositoryTree(repositoryList, wsId, multiWs, true, checkbox, checkboxIds, flag); + } + + public JSONArray getRepositoryTree(List repositoryList, String wsId, boolean multiWs, boolean profitionIcon, boolean checkbox, String checkboxIds, boolean flag) { + JSONArray jsonArray = new JSONArray(); + // method排序 + List methodList = PALMethodCache.getPALMethodList(true); + for (String method : methodList) { + JSONArray array = getPublishRepositoryJSONArray(repositoryList, method, wsId, profitionIcon, checkbox, checkboxIds); + if (array.size() > 0) { + JSONObject object = new JSONObject(); + if (flag) { + object.put("id", method); + } else { + object.put("id", method + "_" + wsId); + } + object.put("name", I18nRes.findValue(CoEConstant.APP_ID, method)); + if (multiWs) { + object.put("pid", wsId); + } + object.put("open", false); + if (profitionIcon) { + object.put("icon", "../apps/"+ CoEConstant.APP_ID +"/img/method/" + method + ".png"); + } else { + if (PublisherConf.PUBLISH_PORTAL_VERSION.equals("v1")) { + object.put("icon", PublisherConf.PORTAL_TREE_ICON_FOLDER); + } else { + object.put("icon", PublisherConf.PORTAL_TREE_ICON_FOLDER1); + } + } + object.put("nocheck", true); + jsonArray.add(object); + jsonArray.addAll(array); + } + } + return jsonArray; + } + + private com.alibaba.fastjson.JSONArray getPublishRepositoryJSONArray(List repositoryList, String method, String wsId) { + return RepositoryTreeUtil.list2tree(repositoryList, wsId, method); + } + + private com.alibaba.fastjson.JSONArray getPublishRepositoryJSONArray(List repositoryList, String method, String wsId, boolean profitionIcon, boolean checkbox, String checkboxIds) { + return RepositoryTreeUtil.list2tree(repositoryList, wsId, method, profitionIcon, checkbox, checkboxIds); + } + + /** + * 获取资产库文件发布历史 + * + * @param repositoryId + * @param wsId + * @return + */ + public String getPublishHistoryList(String repositoryId, String wsId) { + PublishListHistory dao = new PublishListHistory(); + List list = dao.getRepositoryListByResourceId(repositoryId, wsId); + JSONArray jsonArray = new JSONArray(); + + if (list != null && list.size() > 0) { + for (PublishListHistoryModel publishModel : list) { + JSONObject object = new JSONObject(); + Timestamp publishDate = publishModel.getPublishDate(); + DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + object.put("publishDate", df.format(publishDate)); + object.put("publishType", publishModel.getActionType()); + object.put("publishDesc", publishModel.getPublishDesc()); + jsonArray.add(object); + } + } + + ResponseObject ro = ResponseObject.newOkResponse(jsonArray.toString()); + return ro.toString(); + } + + /** + * 流程发布客户首页(普通用户) + * + * @return + */ + public String getClientMain() { + JSONArray list = getMorePublishHistory("0", "10", null); + StringBuilder html = new StringBuilder(); + String year = ""; + String pid = ""; + + if (list != null) { + for (int i = 0; i < list.size(); i++) { + JSONObject object = list.getJSONObject(i); + String objectYear = object.getString("year"); + if (!year.equals(objectYear)) { + if (!"".equals(year)) { + html.append(" " + "" + ""); + } + html.append("
" + "

" + objectYear + "年

" + + "
" + "
    "); + year = objectYear; + } + String type = object.getString("type"); + String style = ""; + if ("N".equals(type)) { + style = "green"; + } else if ("C".equals(type)) { + style = "yellow"; + } else if ("S".equals(type)) { + style = "red"; + } + html.append("
  • "); + if (!pid.equals(object.getString("pid"))) { + html.append("

    " + object.getString("date") + "

    "); + pid = object.getString("pid"); + } else { + html.append("

     

    "); + } + + String onClick = ""; + String clickStyle = ""; + String isPublish = object.getString("isPublish"); + if ("1".equals(isPublish)) { + onClick = "onclick=\"clickImage('" + object.getString("repositoryId") + "')\""; + clickStyle = "cursor: pointer;"; + } + + html.append("

    " + object.getString("intro") + "

    " + + "

     

    " + "
    " + + "
    " + + " " + + "
    " + + "
    " + + "

    " + object.getString("desc") + "

    " + "
    " + "
    " + "
  • "); + } + if (!"".equals(year)) { + html.append("
" + "
" + "
"); + } + } + + Map macroLibraries = new HashMap(); + macroLibraries.put("sid", this.getContext().getSessionId()); + macroLibraries.put("html", html.toString()); + macroLibraries.put("year", year); + macroLibraries.put("pid", pid); + + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.main.html", macroLibraries); + } + + /** + * 根据名称查询发布文件列表 + * + * @param name + * @return + */ + public String searchPublishPALRepository(String name) { + String roleId = _uc.getRoleModel().getId(); + PALRepository dao = new PALRepository(); + List modelList = dao.getRepositoryListByPublishRole(roleId, null, name); + + StringBuilder html = new StringBuilder(); + for (int i = 0, size = modelList.size(); i < size; i++) { + PALRepositoryModel palModel = modelList.get(i); + ArrayList models = new ArrayList(); + models.add(palModel); + String ruuid = palModel.getParentId(); + PALRepositoryModel model; + while (true) { + model = PALRepositoryCache.getCache().get(ruuid); + if (model != null) { + if (PublishAPIManager.getInstance().havingReadPALRepositoryPermissionByRoleId(roleId, + model.getId())) { + models.add(model); + } + ruuid = model.getParentId(); + } else { + if (ruuid.length() < 36) { + PALRepositoryModelImpl cplm = new PALRepositoryModelImpl(); + cplm.setId(ruuid); + cplm.setName(ruuid); + models.add(cplm); + } + break; + } + } + + StringBuffer sb = new StringBuffer(); + for (int ii = models.size() - 1; ii >= 0; ii--) { + PALRepositoryModel plModel = models.get(ii); + sb.append(I18nRes.findValue(CoEConstant.APP_ID, plModel.getName())); + + if (ii != 0) { + sb.append(">"); + } + } + html.append( + "
" + + " " + + "
" + sb.toString() + + "
" + "
" + "
"); + if (i > 15) { + break; + } + } + + ResponseObject ro = ResponseObject.newOkResponse(html.toString()); + return ro.toString(); + } + + /** + * 获取更多发布历史 + * + * @param start + * @return + */ + public String getMorePublishHistory(String start) { + JSONArray list = getMorePublishHistory(start, null, null); + + ResponseObject ro = ResponseObject.newOkResponse(list.toString()); + return ro.toString(); + } + + public JSONArray getMorePublishHistory(String start, String size, String type) { + PublishListHistory dao = new PublishListHistory(); + + AppAPI appApi = SDK.getAppAPI(); + String isIntegrationAWSUser = appApi.getProperty(PublisherConstant.PUBLISH, "isIntegrationAWSUser"); // 是否整合AWS用户 + String roleId = ""; + if ("false".equals(isIntegrationAWSUser)) { + roleId = PublishConst.GUESTROLE; + } else { + roleId = _uc.getRoleModel().getId(); + } + + int startNum = -1; + if (start != null && !"".equals(start)) { + startNum = Integer.parseInt(start); + } + int sizeNum = 10; + if (size != null && !"".equals(size)) { + sizeNum = Integer.parseInt(size); + } + List modelList = dao.getPublishListHistoryByRole(roleId, startNum, sizeNum, type); + + JSONArray list = new JSONArray(); + if (modelList != null) { + for (PublishListHistoryModel model : modelList) { + PALRepositoryModel repositoryModel = PALRepositoryCache.getCache().get(model.getPalRepositoryId()); + JSONObject object = new JSONObject(); + String actionType = model.getActionType(); + object.put("type", actionType); + Timestamp date = model.getPublishDate(); + DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + object.put("date", sdf.format(date)); + DateFormat sdfy = new SimpleDateFormat("yyyy"); + object.put("year", sdfy.format(date)); + String intro = ""; + if ("N".equals(actionType)) { + intro = "新发布"; + } else if ("C".equals(actionType)) { + intro = "变更"; + } else if ("S".equals(actionType)) { + intro = "停用"; + } + object.put("intro", intro + " " + repositoryModel.getName()); + String p = repositoryModel.getFilePath(); + String image = "../apps/"+ CoEConstant.APP_ID +"/img/method/default.png"; + if (!"".equals(p)) { + UtilFile utilFile = new UtilFile(p + repositoryModel.getId() + ".small.png"); + if (utilFile.exists()) { + byte[] base64Bytes = Base64.encode(utilFile.readBytes()); + image = "data:image/png;base64," + new String(base64Bytes); + } + } + + object.put("method", repositoryModel.getMethodId()); + object.put("image", image); + object.put("desc", model.getPublishDesc()); + object.put("pid", model.getpId()); + PublishHistoryModel pModel = PublishHistoryCache.getModel(model.getpId()); + object.put("pDesc", pModel.getPublishDesc()); + object.put("repositoryId", model.getPalRepositoryId()); + object.put("repositoryName", repositoryModel.getName()); + object.put("repositoryVersion", repositoryModel.getVersion() + ".0"); + object.put("isPublish", repositoryModel.isPublish() ? "1" : "0"); + list.add(object); + } + } + + return list; + } + + /** + * 更新文件浏览次数 + * + * @param palRepositoryId + * @author zhangming + */ + public String updateViewCount(String palRepositoryId) { + PALRepository dao = new PALRepository(); + int r = dao.updateViewCount(palRepositoryId); + if (r == 1) { + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("repositoryId", palRepositoryId); + return ro.toString(); + } else { + ResponseObject ro = ResponseObject.newErrResponse(); + ro.put("repositoryId", palRepositoryId); + return ro.toString(); + } + } + + /** + * 流程发布门户(整合版) + * + * @return + * @author zhangming + */ + public String getClientSSOHome() { + AppAPI appApi = SDK.getAppAPI(); + JSONArray wsTree = new JSONArray(); + String isIntegrationAWSUser = appApi.getProperty(PublisherConstant.PUBLISH, "isIntegrationAWSUser"); // 是否整合AWS用户 + String roleId = ""; + if ("false".equals(isIntegrationAWSUser)) { + roleId = PublishConst.GUESTROLE; + } else { + roleId = _uc.getRoleModel().getId(); + } + PALRepository dao = new PALRepository(); + List> allWsList = dao.getWorkSpaceListByPublishRole(roleId, false); + if (allWsList == null || allWsList.size() == 0) { + return AlertWindow.getAuthorityMessagePage("没有可访问的资产库文件", "未分配资产库访问权限,请联系系统管理员"); + } + List> wsList = dao.getWorkSpaceListByPublishRole(roleId, true); // 有访问权限的资产库 + JSONArray repositoryList = new JSONArray(); // 有访问权限的文件 + if (wsList != null && wsList.size() > 0) { + int i = 0; + List> removeList = new ArrayList>(); + for (Map ws : wsList) { + boolean isActive = PALRepositoryQueryAPIManager.getInstance().isActiveWorkSpace(ws.get("wsId")); + if (!isActive) { + removeList.add(ws); + } else { + JSONObject wsJson = new JSONObject(); + wsJson.put("id", ws.get("wsId")); + wsJson.put("name", ws.get("wsName")); + if (i == 0) { + wsJson.put("open", true); + } else { + wsJson.put("open", false); + } + wsJson.put("ws", true); + wsJson.put("wsName", ws.get("wsName")); + wsTree.add(wsJson); + i++; + } + } + wsList.removeAll(removeList); + + if (wsList.size() > 0) { + List repositoryModelList = dao.getRepositoryListByPublishRole(roleId, + wsList.get(0).get("wsId")); + repositoryList = getRepositoryTree(repositoryModelList, wsList.get(0).get("wsId"), true, false, null, false); + } else { + return AlertWindow.getWarningMessagePage("没有可访问的资产库文件", "资产库被停用,请联系系统管理员"); + } + } else { + return AlertWindow.getWarningMessagePage("没有可访问的资产库文件", "可访问流程未发布,请联系系统管理员"); + } + + if (repositoryList != null && repositoryList.size() > 0) { + wsTree.addAll(repositoryList); + } + + String isComment = appApi.getProperty(PublisherConstant.PUBLISH, "isComment"); // 允许留言 + String isViewHistory = appApi.getProperty(PublisherConstant.PUBLISH, "isViewHistory"); // 允许查看历史发布记录 + String isViewAttribute = appApi.getProperty(PublisherConstant.PUBLISH, "isViewAttribute"); // 允许查看属性 + String isPrint = appApi.getProperty(PublisherConstant.PUBLISH, "isPrint"); // 允许打印 + String fotter = appApi.getProperty(PublisherConstant.PUBLISH, "fotter"); // 页底信息 + JSONObject dockDisplay = new JSONObject(); + if ("false".equals(isComment)) { + dockDisplay.put("messageView", "display: none;"); + } + if ("false".equals(isViewHistory)) { + dockDisplay.put("publishView", "display: none;"); + } + if ("false".equals(isViewAttribute)) { + dockDisplay.put("attributeView", "display: none;"); + } + if ("false".equals(isPrint)) { + dockDisplay.put("printView", "display: none;"); + } + + Map macroLibraries = new HashMap(); + macroLibraries.put("sid", this.getContext().getSessionId()); + macroLibraries.put("roleId", roleId); + macroLibraries.put("wsTree", wsTree); + macroLibraries.put("wsName", wsList.get(0).get("wsName")); + macroLibraries.put("dockDisplay", dockDisplay.toString()); + macroLibraries.put("fotter", fotter == null ? "" : fotter); + return HtmlPageTemplate.merge(PublisherConf.APPID, "publish.client.sso.home.html", macroLibraries); + } + + public String savebefore(String ProFile_N, String ProFile_NId, String processInstId, String ProFile_c, + String ProFile_CId, String ChangeDFileNameNew, String AfterChange_CId, String ProFile_s, String ProFile_SId, + String PublishDesc, String StopDesc, String ChangeDesc, String N_taskId, String C_taskId, String S_taskId) { + BO bo = new BO(); + BO publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").detailByBindId(processInstId); + int i = 0; + if (!ProFile_NId.isEmpty()) { + if (publish != null) { + String bindId = publish.getBindId(); + BO N = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").detailByBindId(bindId); + if (null == N) { + bo.set("PUBLISHFILEID", ProFile_NId); + bo.set("PUBLISHFILENAME", ProFile_N); + bo.set("PUBLISHDESC", PublishDesc); + bo.set("PROCESSDEFID", processInstId); + bo.set("TASKID", N_taskId); + i = SDK.getBOAPI().create("BO_ACT_COE_PUBLISH_N", bo, bindId, _uc.getUID()); + } else { + BO n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").detailByBindId(bindId); + String id = n.getString("ID"); + bo.set("PUBLISHFILEID", ProFile_NId); + bo.set("PUBLISHFILENAME", ProFile_N); + bo.set("PROCESSDEFID", processInstId); + bo.set("PUBLISHDESC", PublishDesc); + bo.set("BINDID", bindId); + bo.set("ID", id); + bo.set("TASKID", N_taskId); + i = SDK.getBOAPI().update("BO_ACT_COE_PUBLISH_N", bo); + } + } + } + if (!ChangeDFileNameNew.isEmpty()) { + if (publish != null) { + String bindId = publish.getBindId(); + BO C = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").detailByBindId(bindId); + if (null == C) { + bo.set("CHANGEFILENAME", ProFile_c); + bo.set("CHANGEDFILENAMENEW", ChangeDFileNameNew); + bo.set("CHANGEFILEID", ProFile_CId); + bo.set("CHANGEDFILEIDNEW", AfterChange_CId); + bo.set("PROCESSDEFID", processInstId); + bo.set("CHANGEDDESC", ChangeDesc); + bo.set("TASKID", C_taskId); + i = SDK.getBOAPI().create("BO_ACT_COE_PUBLISH_C", bo, bindId, _uc.getUID()); + } else { + BO c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").detailByBindId(bindId); + String id = c.getString("ID"); + bo.set("CHANGEFILENAME", ProFile_c); + bo.set("CHANGEDFILENAMENEW", ChangeDFileNameNew); + bo.set("CHANGEFILEID", ProFile_CId); + bo.set("CHANGEDFILEIDNEW", AfterChange_CId); + bo.set("ID", id); + bo.set("BINDID", bindId); + bo.set("CHANGEDDESC", ChangeDesc); + bo.set("PROCESSDEFID", processInstId); + bo.set("TASKID", C_taskId); + i = SDK.getBOAPI().update("BO_ACT_COE_PUBLISH_C", bo); + } + + } + } + if (!ProFile_s.isEmpty()) { + if (publish != null) { + String bindId = publish.getBindId(); + BO S = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S").detailByBindId(bindId); + if (null == S) { + bo.set("STOPFILENAME", ProFile_s); + bo.set("STOPFILEID", ProFile_SId); + bo.set("PROCESSDEFID", processInstId); + bo.set("STOPDESC", StopDesc); + bo.set("TASKID", S_taskId); + i = SDK.getBOAPI().create("BO_ACT_COE_PUBLISH_S", bo, bindId, _uc.getUID()); + + } else { + BO s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S").detailByBindId(bindId); + String id = s.getString("ID"); + bo.set("STOPFILENAME", ProFile_s); + bo.set("STOPFILEID", ProFile_SId); + bo.set("ID", id); + bo.set("BINDID", bindId); + bo.set("STOPDESC", StopDesc); + bo.set("PROCESSDEFID", processInstId); + bo.set("TASKID", S_taskId); + i = SDK.getBOAPI().update("BO_ACT_COE_PUBLISH_S", bo); + } + } + } + + return i + ""; + } + + public String selectcns(String processInstId) { + JSONArray jsonArray = new JSONArray(); + JSONObject object = new JSONObject(); + ResponseObject ro = ResponseObject.newOkResponse(); + boolean proNumber = false; + List list = SDK.getTaskQueryAPI().processInstId(processInstId).list(); + + if (!list.isEmpty()) { + for (TaskInstance taskIn : list) { + String parentTaskInstId = taskIn.getParentTaskInstId(); + if ("00000000-0000-0000-0000-000000000000".equals(parentTaskInstId)) { + proNumber = true; + + } + } + object.put("PRONUMBER", proNumber); + } + + BO publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").detailByBindId(processInstId); + if (publish != null) { + boolean isend = publish.isEnd(); + object.put("ISEND", isend); + String bindId = publish.getBindId(); + BO N = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").detailByBindId(bindId); + if (N != null) { + object.put("PUBLISHDESC", N.getString("PUBLISHDESC")); + object.put("PUBLISHFILENAME", N.getString("PUBLISHFILENAME")); + object.put("PUBLISHFILEID", N.getString("PUBLISHFILEID")); + object.put("TASKID", N.getString("TASKID")); + } + BO C = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").detailByBindId(bindId); + if (C != null) { + object.put("CHANGEFILENAME", C.getString("CHANGEFILENAME")); + object.put("CHANGEDFILENAMENEW", C.getString("CHANGEDFILENAMENEW")); + object.put("CHANGEFILEID", C.getString("CHANGEFILEID")); + object.put("CHANGEDDESC", C.getString("CHANGEDDESC")); + object.put("CHANGEDFILEIDNEW", C.getString("CHANGEDFILEIDNEW")); + object.put("TASKID", C.getString("TASKID")); + } + BO S = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S").detailByBindId(bindId); + if (S != null) { + object.put("STOPFILENAME", S.getString("STOPFILENAME")); + object.put("STOPFILEID", S.getString("STOPFILEID")); + object.put("STOPDESC", S.getString("STOPDESC")); + object.put("TASKID", S.getString("TASKID")); + } + + } + jsonArray.add(object); + ro.put("ncsData", jsonArray); + return ro.toString(); + } + + public String openProcess(UserContext me, String wsId, String fileId, String teamId, String processInstId, + String type) { + String userId = me.getUID(); + String taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportPr(wsId, userId, teamId, fileId); + return taskId; + } + + public String ReportPreview(UserContext me, String processInstId, String type) { + String bindid = null; + String taskid = null; + List list = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").addQuery("BINDID=", processInstId).list(); + if (!list.isEmpty()) { + for (BO bo : list) { + bindid = bo.getString("BINDID"); + if (type.equals("n")) { + List n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").addQuery("BINDID=", bindid).list(); + if (!n.isEmpty()) { + for (BO bn : n) { + taskid = bn.getString("TASKID"); + } + } + } + if (type.equals("c")) { + List c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").addQuery("BINDID=", bindid).list(); + if (!c.isEmpty()) { + for (BO bc : c) { + taskid = bc.getString("TASKID"); + } + } + + } + if (type.equals("s")) { + List s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S").addQuery("BINDID=", bindid).list(); + if (!s.isEmpty()) { + for (BO bs : s) { + taskid = bs.getString("TASKID"); + } + } + } + } + } + String url = ""; + url = PALRepositoryQueryAPIManager.getInstance().outputReportPreview(me, taskid); + return url; + } + + public String treeQuery(UserContext me, String wsId, String scope, String queryType, String autoContent) { + + PublisherClientDao publisherClientDao = new PublisherClientDao(); + List list = new ArrayList(); + + List modelList = null; + if ("N".equals(queryType)) { + modelList = publisherClientDao.getCoeProcessLevelByNamen(autoContent, wsId, null); + } else if ("C".equals(queryType)) { + modelList = publisherClientDao.getCoeProcessLevelByNamec(autoContent, wsId, null); + } else if ("S".equals(queryType)) { + modelList = publisherClientDao.getCoeProcessLevelByNameAndCategorys(autoContent, wsId, null); + } + for (int i = 0, size = modelList.size(); i < size; i++) { + PALRepositoryModel coeProcessLevelModel = modelList.get(i); + CoeProcessLevelAutoBean bean = new CoeProcessLevelAutoBean(); + ArrayList models = new ArrayList(); + models.add(coeProcessLevelModel); + String ruuid = coeProcessLevelModel.getParentId(); + PALRepositoryModel model; + boolean isError = false; + while (true) { + model = PALRepositoryCache.getCache().get(ruuid); + // model = (PALRepositoryModel) + // CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(ruuid); + if (model != null) { + models.add(model); + ruuid = model.getParentId(); + } else { + if (ruuid.length() < 36) { + PALRepositoryModelImpl cplm = new PALRepositoryModelImpl(); + cplm.setId(ruuid); + cplm.setName(ruuid); + models.add(cplm); + } else { + isError = true; + } + break; + } + } + if (isError) { + // continue; + } + StringBuffer sb = new StringBuffer(); + for (int ii = models.size() - 1; ii >= 0; ii--) { + PALRepositoryModel plModel = models.get(ii); + sb.append(I18nRes.findValue(CoEConstant.APP_ID, plModel.getName())); + + if (ii != 0) { + sb.append(">"); + } + } + bean.setUi( + "
" + sb.toString() + "
"); + bean.setValue(coeProcessLevelModel.getId()); + bean.setName(coeProcessLevelModel.getName()); + bean.setType(coeProcessLevelModel.getMethodId()); + list.add(bean); + if (list.size() > 15) { + break; + } + } + return JSON.toJSONString(list); + } + + /** + * 获取字表数据 + * @param processInstId + * @return + */ + public String getPublisherData(String processInstId, String wsId) { + ResponseObject ro = ResponseObject.newOkResponse(); + boolean closeFormPage = SDK.getAppAPI().getPropertyBooleanValue(PublisherConf.APPID, "closeFormPage", false); + ro.put("closeFormPage", closeFormPage); + JSONObject newObj = new JSONObject(); + JSONObject changeObj = new JSONObject(); + JSONObject stopObj = new JSONObject(); + boolean proNumber = false; + List list = SDK.getTaskQueryAPI().processInstId(processInstId).list(); + + if (!list.isEmpty()) { + for (TaskInstance taskIn : list) { + if("obj_87371cad5d54457e8c325c805028a56f".equals(taskIn.getActivityDefId())) { + proNumber = true; + } + } + } + ro.put("proNumber", proNumber); + BO publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").detailByBindId(processInstId); + if (publish != null) { + boolean isEnd = publish.isEnd(); + ro.put("isEnd", isEnd); + String bindId = publish.getBindId(); + BO newBo = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").detailByBindId(bindId); + if (newBo != null) { + newObj.put("publishDesc", newBo.getString("PUBLISHDESC")); + newObj.put("publishFileName", newBo.getString("PUBLISHFILENAME")); + newObj.put("publishFileId", newBo.getString("PUBLISHFILEID")); + PALRepositoryModel model = PALRepositoryCache.getCache().get(newBo.getString("PUBLISHFILEID")); + if (model != null) { + newObj.put("fileVersion", model.getVersion()); + newObj.put("methodId", model.getMethodId()); + newObj.put("category", model.getMethodCategory()); + } else { + newObj.put("fileVersion", 1); + newObj.put("methodId", "1"); + newObj.put("category", "1"); + } + newObj.put("taskId", newBo.getString("TASKID")); + } + BO changeBo = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").detailByBindId(bindId); + if (changeBo != null) { + changeObj.put("changeFileName", changeBo.getString("CHANGEFILENAME")); + changeObj.put("changedFileNameNew", changeBo.getString("CHANGEDFILENAMENEW")); + changeObj.put("changeFileId", changeBo.getString("CHANGEFILEID")); + changeObj.put("changedDesc", changeBo.getString("CHANGEDDESC")); + changeObj.put("changedFileIdNew", changeBo.getString("CHANGEDFILEIDNEW")); + changeObj.put("taskId", changeBo.getString("TASKID")); + JSONArray array = new JSONArray(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(changeBo.getString("CHANGEFILEID")); + if (model != null) { + changeObj.put("fileVersion", model.getVersion()); + changeObj.put("methodId", model.getMethodId()); + changeObj.put("category", model.getMethodCategory()); + List list2 = PALRepositoryCache.getByVersionId(wsId, model.getVersionId()); + if (list2 != null && list2.size() > 0) { + Collections.sort(list2,new Comparator(){ + @Override + public int compare(PALRepositoryModel o1, PALRepositoryModel o2) { + return VersionUtil.compareVersionNo(o1.getVersion(),o2.getVersion(),true); //升序 + } + }); + } + for (PALRepositoryModel model2 : list2) { + if (!model2.getId().equals(changeObj.getString("changeFileId")) && !model2.isPublish()) { + JSONObject object = new JSONObject(); + object.put("text", model2.getName()); + object.put("id", model2.getId()); + object.put("version", model2.getVersion()); + array.add(object); + } + } + } else { + changeObj.put("fileVersion", 1); + changeObj.put("methodId", "1"); + changeObj.put("category", "1"); + } + changeObj.put("targetFiles", array); + PALRepositoryModel targetModel = PALRepositoryCache.getCache().get(changeBo.getString("CHANGEDFILEIDNEW")); + if (targetModel != null) { + changeObj.put("targetFileVersion", targetModel.getVersion()); + changeObj.put("targetMethodId", targetModel.getMethodId()); + changeObj.put("targetCategory", targetModel.getMethodCategory()); + } else { + changeObj.put("targetFileVersion", 1); + changeObj.put("targetMethodId", "1"); + changeObj.put("targetCategory", "1"); + } + } + BO stopBo = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S").detailByBindId(bindId); + if (stopBo != null) { + stopObj.put("stopFileName", stopBo.getString("STOPFILENAME")); + stopObj.put("stopFileId", stopBo.getString("STOPFILEID")); + PALRepositoryModel model = PALRepositoryCache.getCache().get(stopBo.getString("STOPFILEID")); + if (model != null) { + stopObj.put("fileVersion", model.getVersion()); + stopObj.put("methodId", model.getMethodId()); + stopObj.put("category", model.getMethodCategory()); + } else { + stopObj.put("fileVersion", 1); + stopObj.put("methodId", "1"); + stopObj.put("category", "1"); + } + stopObj.put("stopDesc", stopBo.getString("STOPDESC")); + stopObj.put("taskId", stopBo.getString("TASKID")); + } + } + ro.put("newData", newObj); + ro.put("changeData", changeObj); + ro.put("stopData", stopObj); + return ro.toString(); + } + + /** + * 查询树结构 + * @param type + * @param wsId + * @param teamId + * @return + */ + public String queryPublishTreeData(String type, String wsId, String teamId, boolean flag, String pid) { + ResponseObject ro = ResponseObject.newOkResponse(); + String checkType = SDK.getAppAPI().getProperty(PublisherConf.APPID, "selectionmode"); + boolean checkbox = false; + boolean checkInherit = false; + if ("radio".equals(checkType)) { + checkbox = false; + checkInherit = false; + } + if ("check".equals(checkType)) { + checkbox = true; + checkInherit = false; + } + if ("checkInherit".equals(checkType)) { + checkbox = true; + checkInherit = true; + } + ro.put("checkbox", checkbox); + ro.put("checkInherit", checkInherit); + JSONArray array; + if ("new".equals(type)) {// new + array = getNotPublishedRepositoryTreeData(wsId, teamId, flag, pid); + } else if ("change".equals(type)) {// change + array = getPublishedRepositoryTreeData2(wsId, teamId); + } else {// stop + array = getPublishedRepositoryTreeData(wsId, teamId); + } + if (array == null || array.isEmpty()) { + array = new JSONArray(); + } + ro.put("data", array); + if (flag) { + return ro.toString(); + } else { + return array.toString(); + } + } + + /** + * 快速查询定位树节点 + * + * @param wsId + * @param teamId + * @return + */ + public String getTreeDataForSearchByName(String wsId, String teamId) { + if (UtilString.isNotEmpty(teamId)) { + // 小组Id不为空,则需要查询小组授权后的流程库 + CoeCooperationTeamModel team = CoeCooperationAPIManager.getInstance().queryCooperationTeamById(teamId, true); + if (team != null) { + wsId = team.getWsId(); + } + } + + List usedList = Lists.newArrayList(); + List methodList = PALMethodManager.getInstance().list(); + for (String method : methodList) { + PALRepositoryQueryAPIManager.getInstance().getAllUsedPalRepositoryModelsByPid(wsId, method, usedList); + } + List removeUsedList = new ArrayList(); + List versionIds = CoeCooperationAPIManager.getInstance().queryCooperationRoleDataPermByTeamUser(teamId, _uc.getUID()); + if (UtilString.isNotEmpty(teamId)) { + if (usedList != null) { + for (PALRepositoryModel model : usedList) { + if (!versionIds.contains(model.getVersionId())) { + removeUsedList.add(model); + } + } + usedList.removeAll(removeUsedList);// 筛选具有权限的所有使用中的流程 + } + } + JSONArray treeData = RepositoryTreeUtil.list2tree(usedList, wsId, true, true, "-"); + return treeData.toString(); + } + + + /** + * 单个文件发布查询未发布流程树结构 + * @param wsId + * @param teamId + * @return + */ + private JSONArray getNotPublishedRepositoryTreeData(String wsId, String teamId, boolean flag, String pid) { + if (UtilString.isNotEmpty(teamId)) { + // 小组Id不为空,则需要查询小组授权后的流程库 + CoeCooperationTeamModel team = CoeCooperationAPIManager.getInstance().queryCooperationTeamById(teamId, true); + if (team != null) { + wsId = team.getWsId(); + } + } + + if (flag) {// 根节点 + JSONArray rootArray = new JSONArray(); + List methodList = PALMethodCache.getPalMehtodList(teamId, _uc.getUID(), true); + for (String method : methodList) { + JSONObject object = new JSONObject(); + object.put("id", method); + object.put("name", I18nRes.findValue(CoEConstant.APP_ID, method)); + object.put("open", false); + object.put("icon", "../apps/"+ CoEConstant.APP_ID +"/img/method/" + method + ".png"); + object.put("nocheck", true); + rootArray.add(object); + } + return rootArray; + } else {// 根节点之下的子节点 + List subModels = PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryModelsByPidNew(_uc, wsId, teamId, pid); + StringBuilder checkboxIds = new StringBuilder(); + for (PALRepositoryModel model : subModels) { + List verList = PALRepositoryCache.getByVersionId(model.getVersionId()); + boolean checkbox = true; + for (PALRepositoryModel verModel : verList) { + if (verModel.isPublish()) { + checkbox = false; + } + } + if (checkbox) { + checkboxIds.append(model.getId()).append(","); + } + } + JSONArray array = RepositoryTreeUtil.list2tree(subModels, wsId, true, true, checkboxIds.toString()); + for (int i = 0; i < array.size(); i++) { + array.getJSONObject(i).put("pid", pid); + List childModels = PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryModelsByPidNew(_uc, wsId, teamId, array.getJSONObject(i).getString("id")); + if (childModels == null || childModels.size() == 0) { + array.getJSONObject(i).remove("open"); + array.getJSONObject(i).put("isParent", false); + } else { + array.getJSONObject(i).put("open", false); + array.getJSONObject(i).put("isParent", true); + } + } + return array; + } + } + + /** + * 单个文件发布查询当前已发布文件 + * @param wsId + * @param teamId + * @return + */ + private JSONArray getPublishedRepositoryTreeData(String wsId, String teamId) { + PALRepository dao = new PALRepository(); + if (UtilString.isNotEmpty(teamId)) { + // 小组Id不为空,则需要查询小组授权后的流程库 + CoeCooperationTeamModel team = CoeCooperationAPIManager.getInstance().queryCooperationTeamById(teamId, true); + if (team != null) { + wsId = team.getWsId(); + } + } + List list = dao.getPublishedRepositoryList(wsId); + List versionIds = CoeCooperationAPIManager.getInstance().queryCooperationRoleDataPermByTeamUser(teamId, _uc.getUID()); + if (UtilString.isNotEmpty(teamId)) { + if (list != null) { + List removeList = new ArrayList(); + for (PALRepositoryModel model : list) { + if (!versionIds.contains(model.getVersionId())) { + removeList.add(model); + } + } + list.removeAll(removeList); + } + } + JSONArray treeData = getRepositoryTree(list, wsId, false, true, "-", false); + return treeData; + } + + /** + * 单个文件发布查询当前已发布文件且所有已发布文件都有未发布的其它版本 + * @param wsId + * @param teamId + * @return + */ + private JSONArray getPublishedRepositoryTreeData2(String wsId, String teamId) { + PALRepository dao = new PALRepository(); + if (UtilString.isNotEmpty(teamId)) { + // 小组Id不为空,则需要查询小组授权后的流程库 + CoeCooperationTeamModel team = CoeCooperationAPIManager.getInstance().queryCooperationTeamById(teamId, true); + if (team != null) { + wsId = team.getWsId(); + } + } + List list = dao.getPublishedRepositoryList(wsId); + List versionIds = CoeCooperationAPIManager.getInstance().queryCooperationRoleDataPermByTeamUser(teamId, _uc.getUID()); + if (UtilString.isNotEmpty(teamId)) { + if (list != null) { + List removeList = new ArrayList(); + for (PALRepositoryModel model : list) { + if (!versionIds.contains(model.getVersionId())) { + removeList.add(model); + } + } + list.removeAll(removeList); + } + } + // 只获取有未发布版本的已发布流程文件 + List list2 = new ArrayList<>(); + for (PALRepositoryModel model : list) { + List temp = PALRepositoryCache.getByVersionId(model.getWsId(), model.getVersionId()); + if (temp != null && temp.size() > 1) { + list2.add(model); + } + } + JSONArray treeData= getRepositoryTree(list2, wsId, false, true, "-", false); + return treeData; + } + + /** + * 创建流程手册 + * @param uuid + * @param wsId + * @param teamId + * @return + */ + public String createOutputPrReport(String uuid, String wsId, String teamId) { + // 校验流程手册是否安装并启动 + if (!SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.output.pr")) { + return ResponseObject.newErrResponse("流程手册未安装或已暂停").toString(); + } + ResponseObject ro = ResponseObject.newOkResponse(); + // 校验 + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + if (model == null) { + throw new AWSException("没有找到文件:" + uuid); + } + String taskId = ""; + if ("process".equals(model.getMethodCategory()) && !"process.evc".equals(model.getMethodId()) && !"default".equals(model.getMethodId())) { + taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportPr(wsId, _uc.getUID(), teamId, uuid); + JSONObject object = JSONObject.parseObject(taskId); + if ("ok".equals(object.getString("result"))) { + taskId = object.getJSONObject("data").getString("taskId"); + } else { + throw new AWSException("创建流程手册失败:" + uuid); + } + } else { + throw new AWSException("文件不支持创建流程手册:" + uuid); + } + ro.put("taskId", taskId); + return ro.toString(); + } + + /** + * 查询流程的未发布版本 + * @param uuid + * @param wsId + * @param teamId + * @return + */ + public String queryNotPublishVersion(String uuid, String wsId, String teamId) { + ResponseObject ro = ResponseObject.newOkResponse(); + // 校验 + PALRepositoryModel m = PALRepositoryCache.getCache().get(uuid); + if (m == null) { + throw new AWSException("没有找到文件:" + uuid); + } + JSONArray array = new JSONArray(); + PALRepository dao = new PALRepository(); + List list = dao.getPublishedRepositoryVersionListByRid(uuid); + if (list != null) { + for (PALRepositoryModel model : list) { + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("text", model.getName()); + object.put("version", model.getVersion()); + array.add(object); + } + } + ro.put("data", array); + return ro.toString(); + } + + /** + * 查询流程的流程手册Id + * @param uuid + * @param wsId + * @param teamId + * @return + */ + public String queryOutputReport(String uuid, String wsId, String teamId) { + ResponseObject ro = ResponseObject.newOkResponse(); + PublishListHistory pHistory = new PublishListHistory(); + String taskId = pHistory.getLastPublishTaskIdByModelId(uuid); + if (taskId == null) { + taskId = ""; + } + ro.put("taskId", taskId); + return ro.toString(); + } + + /** + * 表单保存/办理之前执行子表保存 + * @param data + * @param teamId + * @param wsId + * @param processInstId + * @return + */ + public String saveFormPublishSubData(String data, String teamId, String wsId, String processInstId) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONObject saveData = JSONObject.parseObject(data); + JSONObject newObj = saveData.getJSONObject("newObj"); + JSONObject changeObj = saveData.getJSONObject("changeObj"); + JSONObject stopObj = saveData.getJSONObject("stopObj"); + String publishNewFileId = newObj.getString("uuid"); + String publishNewTaskId = newObj.getString("taskId"); + String publishNewDesc = newObj.getString("desc"); + String publishChangeFileId = changeObj.getString("uuid"); + String publishChangetargetId = changeObj.getString("targetId"); + String publishChangeTaskId = changeObj.getString("taskId"); + String publishChangeDesc = changeObj.getString("desc"); + String publishStopFileId = stopObj.getString("uuid"); + String publishStopTaskId = stopObj.getString("taskId"); + String publishStopDesc = stopObj.getString("desc"); + // 校验是否存在 + validModelExist(publishNewFileId); + validModelExist(publishChangeFileId); + validModelExist(publishChangetargetId); + validModelExist(publishStopFileId); + + // 校验表单内容是否在其他未办理完成的表单中已存在 + JSONObject validObj = new JSONObject(); + validPublisData(publishNewFileId, publishChangeFileId, publishStopFileId, processInstId, wsId, validObj); + if (!validObj.isEmpty()) { + ro = ResponseObject.newErrResponse(); + ro.put("data", validObj); + return ro.toString(); + } + + BO publishBo = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").detailByBindId(processInstId); + if (publishBo == null) { + throw new AWSException("无法找到流程实例 processInstId:" + processInstId); + } + String bindId = publishBo.getBindId(); + // 变更主BO表状态 + SDK.getBOAPI().updateByBindId("BO_ACT_COE_PUBLISH", bindId, "SAVESTATUS", 2); + {// 发布 + String boName = "BO_ACT_COE_PUBLISH_N"; + BO bo = SDK.getBOAPI().query(boName).detailByBindId(bindId); + if (UtilString.isEmpty(publishNewFileId)) { + if (bo != null) { + SDK.getBOAPI().remove(boName, bo.getId());// 清空 + } + } else { + BO newBo = new BO(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(publishNewFileId); + if (bo == null) {// 新建 + newBo.set("PUBLISHFILEID", model.getId()); + newBo.set("PUBLISHFILENAME", model.getName()); + newBo.set("PUBLISHDESC", publishNewDesc); + newBo.set("PROCESSDEFID", processInstId); + newBo.set("TASKID", publishNewTaskId); + SDK.getBOAPI().create(boName, newBo, bindId, _uc.getUID()); + } else {// 更新 + String id = bo.getString("ID"); + newBo.set("PUBLISHFILEID", model.getId()); + newBo.set("PUBLISHFILENAME", model.getName()); + newBo.set("PROCESSDEFID", processInstId); + newBo.set("PUBLISHDESC", publishNewDesc); + newBo.set("BINDID", bindId); + newBo.set("ID", id); + newBo.set("TASKID", publishNewTaskId); + SDK.getBOAPI().update(boName, newBo); + } + } + } + {// 变更 + String boName = "BO_ACT_COE_PUBLISH_C"; + BO bo = SDK.getBOAPI().query(boName).detailByBindId(bindId); + if (UtilString.isEmpty(publishChangetargetId)) { + if (bo != null) { + SDK.getBOAPI().remove(boName, bo.getId());// 清空 + } + } else { + BO changeBo = new BO(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(publishChangeFileId); + PALRepositoryModel newModel = PALRepositoryCache.getCache().get(publishChangetargetId); + if (bo == null) {// 新建 + changeBo.set("CHANGEFILENAME", model.getName()); + changeBo.set("CHANGEDFILENAMENEW", newModel.getName()); + changeBo.set("CHANGEFILEID", model.getId()); + changeBo.set("CHANGEDFILEIDNEW", newModel.getId()); + changeBo.set("PROCESSDEFID", processInstId); + changeBo.set("CHANGEDDESC", publishChangeDesc); + changeBo.set("TASKID", publishChangeTaskId); + SDK.getBOAPI().create(boName, changeBo, bindId, _uc.getUID()); + } else {// 更新 + String id = bo.getString("ID"); + changeBo.set("CHANGEFILENAME", model.getName()); + changeBo.set("CHANGEDFILENAMENEW", newModel.getName()); + changeBo.set("CHANGEFILEID", model.getId()); + changeBo.set("CHANGEDFILEIDNEW", newModel.getId()); + changeBo.set("ID", id); + changeBo.set("BINDID", bindId); + changeBo.set("CHANGEDDESC", publishChangeDesc); + changeBo.set("PROCESSDEFID", processInstId); + changeBo.set("TASKID", publishChangeTaskId); + SDK.getBOAPI().update(boName, changeBo); + } + } + } + {// 停用 + String boName = "BO_ACT_COE_PUBLISH_S"; + BO bo = SDK.getBOAPI().query(boName).detailByBindId(bindId); + if (UtilString.isEmpty(publishStopFileId)) { + if (bo != null) { + SDK.getBOAPI().remove(boName, bo.getId());// 清空 + } + } else { + BO stopBo = new BO(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(publishStopFileId); + if (bo == null) {// 新建 + stopBo.set("STOPFILENAME", model.getName()); + stopBo.set("STOPFILEID", model.getId()); + stopBo.set("PROCESSDEFID", processInstId); + stopBo.set("STOPDESC", publishStopDesc); + stopBo.set("TASKID", publishStopTaskId); + SDK.getBOAPI().create(boName, stopBo, bindId, _uc.getUID()); + } else {// 更新 + String id = bo.getString("ID"); + stopBo.set("STOPFILENAME", model.getName()); + stopBo.set("STOPFILEID", model.getId()); + stopBo.set("ID", id); + stopBo.set("BINDID", bindId); + stopBo.set("STOPDESC", publishStopDesc); + stopBo.set("PROCESSDEFID", processInstId); + stopBo.set("TASKID", publishStopTaskId); + SDK.getBOAPI().update(boName, stopBo); + } + } + } + return ro.toString(); + } + + /** + * 校验发布相关数据是否在其它未办理完成的表单中存在 + * 只要有相同versionId的流程存在未办理情况,即校验不通过 + */ + private void validPublisData(String publishNewFileId, String publishChangeFileId, String publishStopFileId, String processInstId, String wsId, JSONObject obj) { + Set set = new HashSet<>(); + if (!UtilString.isEmpty(publishNewFileId)) set.add(publishNewFileId); + if (!UtilString.isEmpty(publishChangeFileId)) set.add(publishChangeFileId); + if (!UtilString.isEmpty(publishStopFileId)) set.add(publishStopFileId); + if (set.isEmpty()) return; + List list = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").addQuery("ISEND =", 0).list(); + if (list != null && list.size() > 0) { + String type = null; + PALRepositoryModel m = null; + end: + for (BO bo : list) { + if (bo.getBindId().equals(processInstId)) continue; + // 获取三个子表 + {// 发布表 + BO newBo = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").detailByBindId(bo.getBindId()); + if (newBo != null) { + PALRepositoryModel temp1 = PALRepositoryCache.getCache().get(newBo.getString("PUBLISHFILEID")); + if (temp1 != null) { + List list1 = PALRepositoryCache.getByVersionId(wsId, temp1.getVersionId()); + for (PALRepositoryModel model : list1) { + if (set.contains(model.getId())) { + // 存在未办理完成的表单 + type = "new"; + m = model; + break end; + } + } + } + } + } + {// 变更表 + BO changeBo = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").detailByBindId(bo.getBindId()); + if (changeBo != null) { + PALRepositoryModel temp2 = PALRepositoryCache.getCache().get(changeBo.getString("CHANGEFILEID")); + if (temp2 != null) { + List list1 = PALRepositoryCache.getByVersionId(wsId, temp2.getVersionId()); + for (PALRepositoryModel model : list1) { + if (set.contains(model.getId())) { + // 存在未办理完成的表单 + type = "change"; + m = model; + break end; + } + } + } + } + } + {// 停用表 + BO stopBo = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S").detailByBindId(bo.getBindId()); + if (stopBo != null) { + PALRepositoryModel temp3 = PALRepositoryCache.getCache().get(stopBo.getString("STOPFILEID")); + if (temp3 != null) { + List list1 = PALRepositoryCache.getByVersionId(wsId, temp3.getVersionId()); + for (PALRepositoryModel model : list1) { + if (set.contains(model.getId())) { + // 存在未办理完成的表单 + type = "stop"; + m = model; + break end; + } + } + } + } + } + } + if (type != null) { + obj.put("type", type); + obj.put("id", m.getId()); + obj.put("name", m.getName()); + obj.put("version", m.getVersion()); + } + } + } + + /** + * 校验是否存在 + * @param uuid + */ + private void validModelExist(String uuid) { + if (!UtilString.isEmpty(uuid) && PALRepositoryCache.getCache().get(uuid) == null) { + throw new AWSException("文件不存在,请联系管理员 uuid:" + uuid); + } + } + + /************批量流程发布*****************/ + + /** + * 查询流程发布子表数据 + * @param processInstId + * @param wsId + * @return + */ + public String getPublisherBatchData(String processInstId, String wsId) { + ResponseObject ro = ResponseObject.newOkResponse(); + boolean closeFormPage = SDK.getAppAPI().getPropertyBooleanValue(PublisherConf.APPID, "closeFormPage", false); + ro.put("closeFormPage", closeFormPage); + JSONArray newArr = new JSONArray(); + JSONArray changeArr = new JSONArray(); + JSONArray stopArr = new JSONArray(); + boolean proNumber = false; + List list = SDK.getTaskQueryAPI().processInstId(processInstId).list(); + if (!list.isEmpty()) { + for (TaskInstance taskIn : list) { + // 根据节点表单应用-操作权限-主子表是否可修改控制是否只读 + UserTaskModel userTaskModel = UserTaskDefUtil.getModel(taskIn.getProcessDefId(), taskIn.getActivityDefId()); + boolean isModify = FormEngineHelper.getInstance().isFormDataModify(userTaskModel, _uc); + proNumber = isModify; +// if("obj_c643c74dc6800001bd741d7e1e40e4b0".equals(taskIn.getActivityDefId())) { +// proNumber = true; +// } + } + } + ro.put("proNumber", proNumber); + BO publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").detailByBindId(processInstId); + if (publish != null) { + boolean isEnd = publish.isEnd(); + ro.put("isEnd", isEnd); + String bindId = publish.getBindId(); + List newList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").addQuery("BINDID=", bindId).list(); + if (!isEmpty(newList)) { + for (int i = 0; i < newList.size(); i++) { + JSONObject obj = new JSONObject(); + BO newBo = newList.get(i); + if (newBo != null) { + obj.put("publishDesc", newBo.getString("PUBLISHDESC")); + obj.put("publishFileName", newBo.getString("PUBLISHFILENAME")); + obj.put("publishFileId", newBo.getString("PUBLISHFILEID")); + PALRepositoryModel model = PALRepositoryCache.getCache().get(newBo.getString("PUBLISHFILEID")); + if (model != null) { + obj.put("fileVersion", model.getVersion()); + obj.put("methodId", model.getMethodId()); + obj.put("category", model.getMethodCategory()); + } else { + obj.put("fileVersion", 1); + obj.put("methodId", "1"); + obj.put("category", "1"); + } + obj.put("taskId", newBo.getString("TASKID")); + newArr.add(obj); + } + } + } + List changeList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").addQuery("BINDID=", bindId).list(); + if (!isEmpty(changeList)) { + for (int j = 0; j < changeList.size(); j++) { + JSONObject obj = new JSONObject(); + BO changeBo = changeList.get(j); + if (changeBo != null) { + obj.put("changeFileName", changeBo.getString("CHANGEFILENAME")); + obj.put("changedFileNameNew", changeBo.getString("CHANGEDFILENAMENEW")); + obj.put("changeFileId", changeBo.getString("CHANGEFILEID")); + obj.put("changedDesc", changeBo.getString("CHANGEDDESC")); + obj.put("changedFileIdNew", changeBo.getString("CHANGEDFILEIDNEW")); + obj.put("taskId", changeBo.getString("TASKID")); + JSONArray array = new JSONArray(); + PALRepositoryModel model = PALRepositoryCache.getCache().get(changeBo.getString("CHANGEFILEID")); + if (model != null) { + obj.put("fileVersion", model.getVersion()); + obj.put("methodId", model.getMethodId()); + obj.put("category", model.getMethodCategory()); + List list2 = PALRepositoryCache.getByVersionId(wsId, model.getVersionId()); + if (list2 != null && list2.size() > 0) { + Collections.sort(list2,new Comparator(){ + @Override + public int compare(PALRepositoryModel o1, PALRepositoryModel o2) { + return VersionUtil.compareVersionNo(o1.getVersion(), o2.getVersion(),true); //升序 + } + }); + } + for (PALRepositoryModel model2 : list2) { + if (!model2.getId().equals(obj.getString("changeFileId")) && !model2.isPublish()) { + JSONObject object = new JSONObject(); + object.put("text", model2.getName()); + object.put("id", model2.getId()); + object.put("version", model2.getVersion()); + array.add(object); + } + } + } else { + obj.put("fileVersion", 1); + obj.put("methodId", "1"); + obj.put("category", "1"); + } + obj.put("targetFiles", array); + PALRepositoryModel targetModel = PALRepositoryCache.getCache().get(changeBo.getString("CHANGEDFILEIDNEW")); + if (targetModel != null) { + obj.put("targetFileVersion", targetModel.getVersion()); + obj.put("targetMethodId", targetModel.getMethodId()); + obj.put("targetCategory", targetModel.getMethodCategory()); + } else { + obj.put("targetFileVersion", 1); + obj.put("targetMethodId", "1"); + obj.put("targetCategory", "1"); + } + changeArr.add(obj); + } + } + } + List stopList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S").addQuery("BINDID=", bindId).list(); + if (!isEmpty(stopList)) { + for (int i = 0; i < stopList.size(); i++) { + JSONObject obj = new JSONObject(); + BO stopBo = stopList.get(i); + if (stopBo != null) { + obj.put("stopFileName", stopBo.getString("STOPFILENAME")); + obj.put("stopFileId", stopBo.getString("STOPFILEID")); + PALRepositoryModel model = PALRepositoryCache.getCache().get(stopBo.getString("STOPFILEID")); + if (model != null) { + obj.put("fileVersion", model.getVersion()); + obj.put("methodId", model.getMethodId()); + obj.put("category", model.getMethodCategory()); + } else { + obj.put("fileVersion", 1); + obj.put("methodId", "1"); + obj.put("category", "1"); + } + obj.put("stopDesc", stopBo.getString("STOPDESC")); + obj.put("taskId", stopBo.getString("TASKID")); + stopArr.add(obj); + } + } + } + } + ro.put("newData", newArr); + ro.put("changeData", changeArr); + ro.put("stopData", stopArr); + return ro.toString(); + } + + private boolean isEmpty(List list) { + return (list == null || list.size() == 0) ? true : false; + } + + /** + * 批量创建流程手册 + * @param wsId + * @param teamId + * @param uuids + * @return + */ + public String createOutputPrReports(String wsId, String teamId, String uuids) { + if (!SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.output.pr")) { + return ResponseObject.newErrResponse("流程手册未安装或已暂停").toString(); + } + ResponseObject ro = ResponseObject.newOkResponse(); + JSONObject result = new JSONObject(); + JSONArray array = JSONArray.parseArray(uuids); + for (int i = 0; i < array.size(); i++) { + String uuid = array.getString(i); + // 校验 + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + if (model == null) { + throw new AWSException("没有找到文件:" + uuid); + } + String taskId = ""; + if ("process".equals(model.getMethodCategory()) && !"process.evc".equals(model.getMethodId()) && !"default".equals(model.getMethodId())) { + taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportPr(wsId, _uc.getUID(), teamId, uuid); + JSONObject object = JSONObject.parseObject(taskId); + if ("ok".equals(object.getString("result"))) { + taskId = object.getJSONObject("data").getString("taskId"); + } else { + throw new AWSException("创建流程手册失败:" + uuid); + } + } else { + throw new AWSException("文件不支持创建流程手册:" + uuid); + } + result.put(uuid, UtilString.isEmpty(taskId) ? "" : taskId); + } + ro.put("data", result); + return ro.toString(); + } + + /** + * 查询流程的其他版本并默认查询结果的第一条创建流程手册 + * @param wsId + * @param teamId + * @param data + * @return + */ + public String queryVersionsAndCreateOputputPrReports(String wsId, String teamId, String data, String createTime) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONArray result = new JSONArray(); + JSONArray array = JSONArray.parseArray(data); + for (int i = 0; i < array.size(); i++) { + JSONObject object = array.getJSONObject(i); + // 若有未发布版本 + // 判断是否可以生成流程手册 + // 生成流程手册 + PALRepositoryModel model = PALRepositoryCache.getCache().get(object.getString("changeFileId")); + if (model == null) throw new AWSException("没有找到文件:" + object.getString("changeFileId")); + // 更新category,method等 + object.put("category", model.getMethodCategory()); + object.put("methodId", model.getMethodId()); + object.put("changeFileName", model.getName()); + object.put("fileVersion", model.getVersion()); + // 查询未发布版本 + List models = PALRepositoryCache.getByVersionId(wsId, model.getVersionId()); + if (models.size() > 0) { + for (PALRepositoryModel model2 : models) { + if (!model2.isPublish() && !model2.getId().equals(model.getId())) { + String id = model2.getId(); + double version = model2.getVersion(); + String text = model2.getName(); + JSONObject obj = new JSONObject(); + obj.put("id", id); + obj.put("text", text); + obj.put("version", version); + object.getJSONArray("targetFiles").add(obj); + } + } + } + // 生成流程手册 + if (object.getJSONArray("targetFiles").size() > 0) { + if ("process".equals(model.getMethodCategory()) && !"process.evc".equals(model.getMethodId()) && !"default".equals(model.getMethodId())) { + String id = object.getJSONArray("targetFiles").getJSONObject(0).getString("id"); + PALRepositoryModel model2 = PALRepositoryCache.getCache().get(id); + object.put("changedFileIdNew", model2.getId()); + object.put("changedFileNameNew", model2.getName()); + object.put("targetFileVersion", model2.getVersion()); + object.put("targetMethodId", model2.getMethodId()); + object.put("targetCategory", model2.getMethodCategory()); + String taskId = ""; + if ("submit_create".equals(createTime)) { + taskId = "submit_create"; + } else { + taskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportPr(wsId, _uc.getUID(), teamId, model2.getId()); + JSONObject object2 = JSONObject.parseObject(taskId); + if ("ok".equals(object2.getString("result"))) { + taskId = object2.getJSONObject("data").getString("taskId"); + } else { + throw new AWSException("创建流程手册失败:" + model2.getId()); + } + } + object.put("taskId", taskId); + } + result.add(object); + } else { + result.add(object); + } + } + ro.put("data", result); + return ro.toString(); + } + + /** + * 批量查询最后一次发布的手册 + * @param uuids + * @param wsId + * @param teamId + * @return + */ + public String queryBatchOutputReport(String uuids, String wsId, String teamId) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONArray array = JSONArray.parseArray(uuids); + PublishListHistory pHistory = new PublishListHistory(); + JSONObject object = new JSONObject(); + for (int i = 0; i < array.size(); i++) { + String uuid = array.getString(i); + String taskId = pHistory.getLastPublishTaskIdByModelId(uuid); + if (taskId == null) { + taskId = ""; + } + object.put(uuid, taskId); + } + ro.put("data", object); + return ro.toString(); + } + + /** + * 子表批量保存 + * @param wsId + * @param teamId + * @param processInstId + * @param type new change stop + * @param data + * @return + */ + public String saveBatchData(String wsId, String teamId, String processInstId, String type, String data) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONArray array = JSONArray.parseArray(data); + BO publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").detailByBindId(processInstId); + if (publish != null) { + String bindId = publish.getBindId(); + // 变更主BO表状态 + SDK.getBOAPI().updateByBindId("BO_ACT_COE_PUBLISH", bindId, "SAVESTATUS", 2); + if ("new".equals(type)) { + // 校验->清空->存储 + if (!array.isEmpty()) {// 校验 + HashSet ids = new HashSet<>(); + for (int i = 0; i < array.size(); i++) { + JSONObject object = array.getJSONObject(i); + validModelExist(object.getString("publishFileId"));// 校验 + ids.add(object.getString("publishFileId")); + } + JSONArray result = new JSONArray(); + validPublisData(ids, processInstId, wsId, result);// 校验 + if (result.size() > 0) { + ro = ResponseObject.newErrResponse(); + ro.put("data", result); + return ro.toString(); + } + } + String boName = "BO_ACT_COE_PUBLISH_N"; + SDK.getBOAPI().removeByBindId(boName, bindId);// 清空 + if (!array.isEmpty()) { + // 存储 + List list = new ArrayList<>(); + for (int i = 0; i < array.size(); i++) { + JSONObject object = array.getJSONObject(i); + PALRepositoryModel model = PALRepositoryCache.getCache().get(object.getString("publishFileId")); + BO newBo = new BO(); + newBo.set("PUBLISHFILEID", model.getId()); + newBo.set("PUBLISHFILENAME", model.getName()); + newBo.set("PUBLISHDESC", object.getString("publishDesc")); + newBo.set("PROCESSDEFID", processInstId); + newBo.set("TASKID", object.getString("taskId")); + list.add(newBo); + } + SDK.getBOAPI().create(boName, list, bindId, _uc.getUID()); + } + } + if ("change".equals(type)) { + // 校验->清空->保存 + if (!array.isEmpty()) {// 校验 + HashSet ids = new HashSet<>(); + for (int i = 0; i < array.size(); i++) { + JSONObject object = array.getJSONObject(i); + validModelExist(object.getString("changeFileId"));// 校验 + String newId = object.getString("changedFileIdNew"); + if (!UtilString.isEmpty(newId)) { + validModelExist(newId);// 校验 + } + ids.add(object.getString("changeFileId")); + } + JSONArray result = new JSONArray(); + validPublisData(ids, processInstId, wsId, result);// 校验 + if (result.size() > 0) { + ro = ResponseObject.newErrResponse(); + ro.put("data", result); + return ro.toString(); + } + } + String boName = "BO_ACT_COE_PUBLISH_C"; + SDK.getBOAPI().removeByBindId(boName, bindId);// 清空 + if (!array.isEmpty()) { + // 存储 + List list = new ArrayList<>(); + for (int i = 0; i < array.size(); i++) { + JSONObject object = array.getJSONObject(i); + PALRepositoryModel model = PALRepositoryCache.getCache().get(object.getString("changeFileId")); + PALRepositoryModel newModel = null; + String newId = object.getString("changedFileIdNew"); + if (!UtilString.isEmpty(newId)) { + newModel = PALRepositoryCache.getCache().get(newId); + } + BO changeBo = new BO(); + changeBo.set("CHANGEFILENAME", model.getName()); + changeBo.set("CHANGEDFILENAMENEW", newModel == null ? "" : newModel.getName()); + changeBo.set("CHANGEFILEID", model.getId()); + changeBo.set("CHANGEDFILEIDNEW", newModel == null ? "" : newModel.getId()); + changeBo.set("PROCESSDEFID", processInstId); + changeBo.set("CHANGEDDESC", object.getString("changedDesc")); + changeBo.set("TASKID", object.getString("taskId")); + list.add(changeBo); + } + SDK.getBOAPI().create(boName, list, bindId, _uc.getUID()); + } + } + if ("stop".equals(type)) { + // 校验->清空->保存 + if (!array.isEmpty()) {// 校验 + HashSet ids = new HashSet<>(); + for (int i = 0; i < array.size(); i++) { + JSONObject object = array.getJSONObject(i); + validModelExist(object.getString("stopFileId"));// 校验 + ids.add(object.getString("stopFileId")); + } + JSONArray result = new JSONArray(); + validPublisData(ids, processInstId, wsId, result);// 校验 + if (result.size() > 0) { + ro = ResponseObject.newErrResponse(); + ro.put("data", result); + return ro.toString(); + } + } + String boName = "BO_ACT_COE_PUBLISH_S"; + SDK.getBOAPI().removeByBindId(boName, bindId);// 清空 + if (!array.isEmpty()) { + // 存储 + List list = new ArrayList<>(); + for (int i = 0; i < array.size(); i++) { + JSONObject object = array.getJSONObject(i); + PALRepositoryModel model = PALRepositoryCache.getCache().get(object.getString("stopFileId")); + BO stopBo = new BO(); + stopBo.set("STOPFILENAME", model.getName()); + stopBo.set("STOPFILEID", model.getId()); + stopBo.set("PROCESSDEFID", processInstId); + stopBo.set("STOPDESC", object.getString("stopDesc")); + stopBo.set("TASKID", object.getString("taskId")); + list.add(stopBo); + } + SDK.getBOAPI().create(boName, list, bindId, _uc.getUID()); + } + } + + } + return ro.toString(); + } + + /** + * 校验发布相关数据是否在其它未办理完成的表单中存在 + * 只要有相同versionId的流程存在未办理情况,即校验不通过 + */ + private void validPublisData(HashSet set, String processInstId, String wsId, JSONArray array) { + if (set.isEmpty()) return; + Set filter = new HashSet<>(); + List list = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").addQuery("ISEND =", 0).list(); + if (list != null && list.size() > 0) { + for (BO bo : list) { + if (bo.getBindId().equals(processInstId)) continue; + // 获取三个子表 + {// 发布表 + BO newBo = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").detailByBindId(bo.getBindId()); + if (newBo != null) { + PALRepositoryModel temp1 = PALRepositoryCache.getCache().get(newBo.getString("PUBLISHFILEID")); + if (temp1 != null) { + List list1 = PALRepositoryCache.getByVersionId(wsId, temp1.getVersionId()); + for (PALRepositoryModel model : list1) { + if (set.contains(model.getId()) && !filter.contains(model.getId())) { + // 存在未办理完成的表单 + JSONObject obj = new JSONObject(); + obj.put("type", "new"); + obj.put("id", model.getId()); + obj.put("name", model.getName()); + obj.put("version", model.getVersion()); + array.add(obj); + } + } + } + } + } + {// 变更表 + BO changeBo = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").detailByBindId(bo.getBindId()); + if (changeBo != null) { + PALRepositoryModel temp2 = PALRepositoryCache.getCache().get(changeBo.getString("CHANGEFILEID")); + if (temp2 != null) { + List list1 = PALRepositoryCache.getByVersionId(wsId, temp2.getVersionId()); + for (PALRepositoryModel model : list1) { + if (set.contains(model.getId()) && !filter.contains(model.getId())) { + // 存在未办理完成的表单 + JSONObject obj = new JSONObject(); + obj.put("type", "change"); + obj.put("id", model.getId()); + obj.put("name", model.getName()); + obj.put("version", model.getVersion()); + array.add(obj); + } + } + } + } + } + {// 停用表 + BO stopBo = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S").detailByBindId(bo.getBindId()); + if (stopBo != null) { + PALRepositoryModel temp3 = PALRepositoryCache.getCache().get(stopBo.getString("STOPFILEID")); + if (temp3 != null) { + List list1 = PALRepositoryCache.getByVersionId(wsId, temp3.getVersionId()); + for (PALRepositoryModel model : list1) { + if (set.contains(model.getId()) && !filter.contains(model.getId())) { + // 存在未办理完成的表单 + JSONObject obj = new JSONObject(); + obj.put("type", "stop"); + obj.put("id", model.getId()); + obj.put("name", model.getName()); + obj.put("version", model.getVersion()); + array.add(obj); + } + } + } + } + } + } + } + } + + /** + * 表单保存/办理前执行(批量) + * @param wsId + * @param teamId + * @param processInstId + * @param newData + * @param changeData + * @param stopData + * @return + */ + public String saveFormBatchPubishData(String wsId, String teamId, String processInstId, String newData, String changeData, String stopData, boolean isTransact) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONArray newArray = JSONArray.parseArray(newData); + JSONArray changeArray = JSONArray.parseArray(changeData); + JSONArray stopArray = JSONArray.parseArray(stopData); + BO publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").detailByBindId(processInstId); + if (publish == null) throw new AWSException("表单不存在 " + processInstId); + // 校验所有数据 + HashSet ids = new HashSet<>(); + JSONArray result = new JSONArray(); + if (!newArray.isEmpty()) {// 校验 + for (int i = 0; i < newArray.size(); i++) { + JSONObject object = newArray.getJSONObject(i); + validModelExist(object.getString("publishFileId"));// 校验 + ids.add(object.getString("publishFileId")); + } + } + if (!changeArray.isEmpty()) {// 校验 + for (int i = 0; i < changeArray.size(); i++) { + JSONObject object = changeArray.getJSONObject(i); + validModelExist(object.getString("changeFileId"));// 校验 + String newId = object.getString("changedFileIdNew"); + if (!UtilString.isEmpty(newId)) { + validModelExist(newId);// 校验 + } + ids.add(object.getString("changeFileId")); + } + } + if (!stopArray.isEmpty()) {// 校验 + for (int i = 0; i < stopArray.size(); i++) { + JSONObject object = stopArray.getJSONObject(i); + validModelExist(object.getString("stopFileId"));// 校验 + ids.add(object.getString("stopFileId")); + } + } + validPublisData(ids, processInstId, wsId, result);// 校验 + if (result.size() > 0) { + + ro = ResponseObject.newErrResponse(); + ro.put("data", result); + return ro.toString(); + } + // 存储 + String bindId = publish.getBindId(); + // 变更主BO表状态 + SDK.getBOAPI().updateByBindId("BO_ACT_COE_PUBLISH", bindId, "SAVESTATUS", 2); + String newBoName = "BO_ACT_COE_PUBLISH_N"; + SDK.getBOAPI().removeByBindId(newBoName, bindId);// 清空 + if (!newArray.isEmpty()) { + // 存储 + List list = new ArrayList<>(); + for (int i = 0; i < newArray.size(); i++) { + JSONObject object = newArray.getJSONObject(i); + PALRepositoryModel model = PALRepositoryCache.getCache().get(object.getString("publishFileId")); + BO newBo = new BO(); + newBo.set("PUBLISHFILEID", model.getId()); + newBo.set("PUBLISHFILENAME", model.getName()); + newBo.set("PUBLISHDESC", object.getString("publishDesc")); + newBo.set("PROCESSDEFID", processInstId); + newBo.set("TASKID", object.getString("taskId")); + list.add(newBo); + } + SDK.getBOAPI().create(newBoName, list, bindId, _uc.getUID()); + } + + String changeBoName = "BO_ACT_COE_PUBLISH_C"; + SDK.getBOAPI().removeByBindId(changeBoName, bindId);// 清空 + if (!changeArray.isEmpty()) { + // 存储 + List list = new ArrayList<>(); + for (int i = 0; i < changeArray.size(); i++) { + JSONObject object = changeArray.getJSONObject(i); + PALRepositoryModel model = PALRepositoryCache.getCache().get(object.getString("changeFileId")); + PALRepositoryModel newModel = null; + String newId = object.getString("changedFileIdNew"); + if (!UtilString.isEmpty(newId)) { + newModel = PALRepositoryCache.getCache().get(newId); + } + BO changeBo = new BO(); + changeBo.set("CHANGEFILENAME", model.getName()); + changeBo.set("CHANGEDFILENAMENEW", newModel == null ? "" : newModel.getName()); + changeBo.set("CHANGEFILEID", model.getId()); + changeBo.set("CHANGEDFILEIDNEW", newModel == null ? "" : newModel.getId()); + changeBo.set("PROCESSDEFID", processInstId); + changeBo.set("CHANGEDDESC", object.getString("changedDesc")); + changeBo.set("TASKID", object.getString("taskId")); + list.add(changeBo); + } + SDK.getBOAPI().create(changeBoName, list, bindId, _uc.getUID()); + } + + String stopBoName = "BO_ACT_COE_PUBLISH_S"; + SDK.getBOAPI().removeByBindId(stopBoName, bindId);// 清空 + if (!stopArray.isEmpty()) { + // 存储 + List list = new ArrayList<>(); + for (int i = 0; i < stopArray.size(); i++) { + JSONObject object = stopArray.getJSONObject(i); + PALRepositoryModel model = PALRepositoryCache.getCache().get(object.getString("stopFileId")); + BO stopBo = new BO(); + stopBo.set("STOPFILENAME", model.getName()); + stopBo.set("STOPFILEID", model.getId()); + stopBo.set("PROCESSDEFID", processInstId); + stopBo.set("STOPDESC", object.getString("stopDesc")); + stopBo.set("TASKID", object.getString("taskId")); + list.add(stopBo); + } + SDK.getBOAPI().create(stopBoName, list, bindId, _uc.getUID()); + } + // 提交时通过线程处理流程手册的创建 + if (isTransact) { + batchCreateReportByThread(wsId, processInstId); + } + return ro.toString(); + } + + /** + * 对未创建手册的流程进行创建流程手册 + */ + private void batchCreateReportByThread(String wsId, String processInstId) { + BO publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").addQuery("BINDID=", processInstId).detail(); + if (publish != null) { + //ExecutorService service = Executors.newFixedThreadPool(4); + //使用下面的方式来替换 + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("Thread-call-runner-%d").build(); + ExecutorService service = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingDeque<>(), namedThreadFactory); + List n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").addQuery("BINDID=", processInstId).list(); + if (!n.isEmpty()) { + for (BO bn : n) { + String taskId = bn.getString("TASKID"); + if ("submit_create".equals(taskId)) { + service.execute(() -> { + // 创建流程手册 + String publishFileId = bn.getString("PUBLISHFILEID"); + String newTaskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportPr(wsId, _uc.getUID(), "", publishFileId); + JSONObject object = JSONObject.parseObject(newTaskId); + if ("ok".equals(object.getString("result"))) { + newTaskId = object.getJSONObject("data").getString("taskId"); + SDK.getLogAPI().consoleInfo("流程发布表单[发布]提交时创建流程手册成功,processInstId=" + processInstId + ",publishFileId=" + publishFileId); + int count = DBSql.update("UPDATE BO_ACT_COE_PUBLISH_N SET TASKID='" + newTaskId + "' WHERE ID ='" + bn.getId() + "'"); + SDK.getLogAPI().consoleInfo("流程发布表单[发布]提交时创建流程手册保存数据库成功,processInstId" + processInstId + ",publishFileId=" + publishFileId + ",执行SQL条数[" + count + "]"); + } else { + SDK.getLogAPI().consoleErr("流程发布表单[发布]提交时创建流程手册失败,processInstId=" + processInstId + ",publishFileId=" + publishFileId); + } + }); + } + } + } + List c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").addQuery("BINDID=", processInstId).list(); + if (!c.isEmpty()) { + for (BO bc : c) { + String taskId = bc.getString("TASKID"); + if ("submit_create".equals(taskId)) { + + // 创建流程手册 + service.execute(() -> { + // 创建流程手册 + String changedFileIdNew = bc.getString("CHANGEDFILEIDNEW"); + String newTaskId = PALRepositoryQueryAPIManager.getInstance().createOutputReportPr(wsId, _uc.getUID(), "", changedFileIdNew); + JSONObject object = JSONObject.parseObject(newTaskId); + if ("ok".equals(object.getString("result"))) { + newTaskId = object.getJSONObject("data").getString("taskId"); + SDK.getLogAPI().consoleInfo("流程发布表单[变更]提交时创建流程手册成功,processInstId=" + processInstId + ",changedFileIdNew=" + changedFileIdNew); + int count = DBSql.update("UPDATE BO_ACT_COE_PUBLISH_C SET TASKID='" + newTaskId + "' WHERE ID ='" + bc.getId() + "'"); + SDK.getLogAPI().consoleInfo("流程发布表单[变更]提交时创建流程手册保存数据库成功,processInstId=" + processInstId + ",changedFileIdNew=" + changedFileIdNew + ",执行SQL条数[" + count + "]"); + } else { + SDK.getLogAPI().consoleErr("流程发布表单[变更]提交时创建流程手册失败,processInstId=" + processInstId + ",changedFileIdNew=" + changedFileIdNew); + } + }); + } + } + } + // 关闭线程池 + service.shutdown(); + } + } + + /** + * 校验文件类型 + * @param uuid + * @return + */ + public String checkPublishRepositoryMethod(String uuid) { + if (!UtilString.isEmpty(uuid)) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + if (model != null) { + if ("default".equals(model.getMethodId())) { + return ResponseObject.newErrResponse("文件夹类型不允许打开").toString(); + } else { + return ResponseObject.newOkResponse().toString(); + } + } else { + return ResponseObject.newErrResponse("打开文件错误").toString(); + } + } else { + return ResponseObject.newErrResponse("打开文件错误").toString(); + } + } + + /** + * 查询流程实例bo表状态字段 + * @param processInstId + * @return + */ + public String querySaveStatus(String processInstId) { + BO publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").detailByBindId(processInstId); + if (publish == null) throw new AWSException("表单不存在 " + processInstId); + String saveStatus = publish.getString("SAVESTATUS"); + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("saveStatus", saveStatus); + return ro.toString(); + } + +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/conf/PublisherConf.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/conf/PublisherConf.java new file mode 100644 index 00000000..7eb765a6 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/conf/PublisherConf.java @@ -0,0 +1,235 @@ +package com.actionsoft.apps.coe.pal.publisher.conf; + +import com.actionsoft.bpms.util.UtilString; +import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSONArray; + +public final class PublisherConf { + public static final String APPID = "com.actionsoft.apps.coe.pal.publisher"; + + public static final String RELATION_SEARCH_ID = "com.actionsoft.apps.coe.pal.relationsearch"; + public static final String RELATION_SEARCH_NAME = "关联查询"; + + public static final String PORTAL_TREE_ICON_FOLDER = "../apps/com.actionsoft.apps.coe.pal.publisher/img/tree-folder.png"; + public static final String PORTAL_TREE_ICON_FOLDER1 = "../apps/com.actionsoft.apps.coe.pal.publisher/img/tree-folder1.png"; + + public static String PUBLISH_PORTAL_VERSION = "v1"; + + public static String XPAGES_ID = ""; + + public static JSONArray PORTAL_TABS = null; + + /** + * 页底信息,如客户流程管理部联系信息 + * + * @return + */ + public static String getFotter() { + String value = SDK.getAppAPI().getProperty(APPID, "fotter"); + if (UtilString.isEmpty(value)) { + value = "炎黄盈动"; + } + return value; + } + + public static void setFotter(String fotter) { + fotter = fotter == null ? "" : fotter; + SDK.getAppAPI().setProperty(APPID, "fotter", fotter); + } + + /** + * 门户标题 + * + * @return + */ + public static String getTitle() { + String value = SDK.getAppAPI().getProperty(APPID, "title"); + if (UtilString.isEmpty(value)) { + value = "CoE Process Portal"; + } + return value; + } + + public static void setTitle(String title) { + title = title == null ? "" : title; + SDK.getAppAPI().setProperty(APPID, "title", title); + } + + /** + * 流程发布流程版本Id + * + * @return + */ + public static String getPublishProcessId() { + String value = SDK.getAppAPI().getProperty(APPID, "publishProcessId"); + return value; + } + + /** + * 发布门户的浏览者是否整合AWS用户 + * + * @return 整合返回true + */ + public static boolean isIntegrationAWSUser() { + String value = SDK.getAppAPI().getProperty(APPID, "isIntegrationAWSUser"); + return (value != null && value.trim().equalsIgnoreCase("true")) ? true : false; + } + + /** + * 如果门户未整合AWS用户,此处配置来自外部系统访问门户的统一访客账户。该账户是AWS平台合法的账户 + * + * @return + */ + public static String getGuest() { + String value = SDK.getAppAPI().getProperty(APPID, "guest"); + return value; + } + + /** + * 发布门户的内容允许复制 + * + * @return 允许返回true + */ + public static boolean isCopy() { + String value = SDK.getAppAPI().getProperty(APPID, "isCopy"); + return (value != null && value.trim().equalsIgnoreCase("true")) ? true : false; + } + + public static void setCopy(String isCopy) { + if (isCopy != null && isCopy.trim().equalsIgnoreCase("true")) { + isCopy = "true"; + } else { + isCopy = "false"; + } + SDK.getAppAPI().setProperty(APPID, "isCopy", isCopy); + } + + /** + * 发布门户的内容允许打印 + * + * @return 允许返回true + */ + public static boolean isPrint() { + String value = SDK.getAppAPI().getProperty(APPID, "isPrint"); + return (value != null && value.trim().equalsIgnoreCase("true")) ? true : false; + } + + public static void setPrint(String isPrint) { + if (isPrint != null && isPrint.trim().equalsIgnoreCase("true")) { + isPrint = "true"; + } else { + isPrint = "false"; + } + SDK.getAppAPI().setProperty(APPID, "isPrint", isPrint); + } + + /** + * 发布门户的内容允许留言 + * + * @return 允许返回true + */ + public static boolean isComment() { + String value = SDK.getAppAPI().getProperty(APPID, "isComment"); + return (value != null && value.trim().equalsIgnoreCase("true")) ? true : false; + } + + public static void setComment(String isComment) { + if (isComment != null && isComment.trim().equalsIgnoreCase("true")) { + isComment = "true"; + } else { + isComment = "false"; + } + SDK.getAppAPI().setProperty(APPID, "isComment", isComment); + } + + /** + * 发布门户的内容允许查看属性 + * + * @return 允许返回true + */ + public static boolean isViewAttribute() { + String value = SDK.getAppAPI().getProperty(APPID, "isViewAttribute"); + return (value != null && value.trim().equalsIgnoreCase("true")) ? true : false; + } + + public static void setViewAttribute(String isViewAttribute) { + if (isViewAttribute != null && isViewAttribute.trim().equalsIgnoreCase("true")) { + isViewAttribute = "true"; + } else { + isViewAttribute = "false"; + } + SDK.getAppAPI().setProperty(APPID, "isViewAttribute", isViewAttribute); + } + + /** + * 发布门户的内容允许查看历史发布记录 + * + * @return 允许返回true + */ + public static boolean isViewHistory() { + String value = SDK.getAppAPI().getProperty(APPID, "isViewHistory"); + return (value != null && value.trim().equalsIgnoreCase("true")) ? true : false; + } + + public static void setViewHistory(String isViewHistory) { + if (isViewHistory != null && isViewHistory.trim().equalsIgnoreCase("true")) { + isViewHistory = "true"; + } else { + isViewHistory = "false"; + } + SDK.getAppAPI().setProperty(APPID, "isViewHistory", isViewHistory); + } + + /** + * 流程管理门户xpage + * @param type common:常用流程;frequency:高频流程;systemMap:系统地图;processMap:流程地图;notification:发布动态 + * @return + */ + public static String getXpagesContent(String type) { + StringBuffer content = new StringBuffer(); + switch (type) { + case "common": + content.append(""); + break; + case "frequency": + content.append(""); + break; + case "systemMap": + content.append(""); + break; + case "dataMap": + content.append(""); + break; + case "controlMap": + content.append(""); + break; + case "orgMap": + content.append(""); + break; + case "processMap": + content.append(""); + break; + case "notification": + content.append(""); + break; + case "banner":// 横幅轮播图 + content.append(""); + break; + case "participant":// 我参与的 + content.append(""); + break; + case "responsible":// 我负责的 + content.append(""); + break; + case "postresponsibility":// 岗位职责 + content.append(""); + break; + case "rcaimatrix":// rcai矩阵 + content.append(""); + break; + default: + break; + } + return content.toString(); + } +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/constant/PublisherConstant.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/constant/PublisherConstant.java new file mode 100644 index 00000000..9300186e --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/constant/PublisherConstant.java @@ -0,0 +1,23 @@ +package com.actionsoft.apps.coe.pal.publisher.constant; + +/** +* @Description 流程发布Constant +* @author zhangming +* @date 2014年9月19日 +* +*/ +public interface PublisherConstant { + public static final String PUBLISH = "com.actionsoft.apps.coe.pal.publisher"; //流程发布AppId + + public static final String PROCESSGROUPID = "obj_f2903c7c6a2d405a981a87e115d4261e"; //发布流程流程组Id + public static final String PROCESSID = "obj_d2b56ab6bd96477b9b14fc355f3c5ee9"; + + public static final String BOTABLENAME = "BO_ACT_COE_PUBLISH"; //发布流程BO表主表表名 + public static final String BOSUBTABLE_N = "BO_ACT_COE_PUBLISH_N"; //发布流程BO子表-新增 + public static final String BOSUBTABLE_C = "BO_ACT_COE_PUBLISH_C"; //发布流程BO子表-更新 + public static final String BOSUBTABLE_S = "BO_ACT_COE_PUBLISH_S"; //发布流程BO子表-停止 + + public static final String ORG_RELATION_MANAGEMENT_STANDARD = "管理标准"; //管理标准 + public static final String ORG_RELATION_TECHNICAL_STANDARD = "技术标准"; //技术标准 + public static final String ORG_RELATION_WORK_STANDARD = "工作标准"; //工作标准 +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/AppInstallListener.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/AppInstallListener.java new file mode 100644 index 00000000..e7ea1cb9 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/AppInstallListener.java @@ -0,0 +1,67 @@ +package com.actionsoft.apps.coe.pal.publisher.event; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import com.actionsoft.apps.AppsConst; +import com.actionsoft.apps.listener.AppListener; +import com.actionsoft.apps.resource.AppContext; +import com.actionsoft.bpms.util.Base64; +import com.actionsoft.exception.AWSException; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.AppAPI; + +public class AppInstallListener implements AppListener { + + @SuppressWarnings("resource") + @Override + public void after(AppContext app) { + // 流程管理门户xpages文件同步到xpages应用中 + try { + String path = AppsConst.APPS_ROOT + AppsConst.FOLDER_INSTALL + File.separator + app.getId() + File.separator + "xpages" + File.separator; + File fileDir = new File(path); + if (fileDir.exists()) { + File [] files = fileDir.listFiles(); + for (File file : files) { + InputStream input = null; + ByteArrayOutputStream arrayOutputStream = null; + input = new FileInputStream(file); + arrayOutputStream = new ByteArrayOutputStream(); + byte [] buf = new byte[1024]; + int len = 0; + while ((len = input.read(buf)) != -1) { + arrayOutputStream.write(buf, 0, len); + } + byte [] bytedata = arrayOutputStream.toByteArray(); + String content = new String(Base64.encode(bytedata)); + // 调用App + String sourceAppId = app.getId(); + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.addons.xpages/createTemplateByContent"; + // 参数定义列表 + Map params = new HashMap<>(); + //内容,必填 + params.put("content", content); + //0,覆盖 1不覆盖,非必填 + params.put("overWriteFlag", "0"); + AppAPI appAPI = SDK.getAppAPI(); + //根据一个xpages文件的内容创建一个xpages模板记录 + appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + } + } + } catch (Exception e) { + e.printStackTrace(); + throw new AWSException("流程管理门户xpages文件解析错误"); + } + } + + @Override + public boolean before(AppContext arg0) { + return true; + } + +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/AppStartListener.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/AppStartListener.java new file mode 100644 index 00000000..3cd15cf0 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/AppStartListener.java @@ -0,0 +1,44 @@ +package com.actionsoft.apps.coe.pal.publisher.event; + +import com.actionsoft.apps.coe.pal.publisher.conf.PublisherConf; +import com.actionsoft.apps.listener.AppListener; +import com.actionsoft.apps.resource.AppContext; +import com.actionsoft.exception.AWSException; +import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; + +public class AppStartListener implements AppListener{ + + @Override + public void after(AppContext arg0) { + // 初始化门户版本 + String value = SDK.getAppAPI().getProperty(PublisherConf.APPID, "portalVersion"); + PublisherConf.PUBLISH_PORTAL_VERSION = value; + if (value.equals("v3")) { + // 初始化门户配置 + String xpagesId = SDK.getAppAPI().getProperty(PublisherConf.APPID, "portalTemplateId_xpages"); + if ("".equals(xpagesId.trim())) { + throw new AWSException("PAL门户默认xpages模版配置参数不允许为空"); + } + PublisherConf.XPAGES_ID = xpagesId; + String portalTabs = SDK.getAppAPI().getProperty(PublisherConf.APPID, "portalTabs"); + if (!"".equals(portalTabs.trim())) { + try { + JSONArray array = JSON.parseArray(portalTabs.trim()); + PublisherConf.PORTAL_TABS = array; + } catch (Exception e) { + throw new AWSException("PAL门户Tab标签配置参数解析出错,请检查参数格式是否正确"); + } + } else { + PublisherConf.PORTAL_TABS = new JSONArray(); + } + } + } + + @Override + public boolean before(AppContext arg0) { + return true; + } + +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/AppUnInstallListener.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/AppUnInstallListener.java new file mode 100644 index 00000000..1fa890ed --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/AppUnInstallListener.java @@ -0,0 +1,57 @@ +package com.actionsoft.apps.coe.pal.publisher.event; + +import com.actionsoft.apps.AppsConst; +import com.actionsoft.apps.lifecycle.log.AppsLogger; +import com.actionsoft.apps.listener.AppListener; +import com.actionsoft.apps.resource.AppContext; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.util.ConsolePrinter; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.AppAPI; +import com.alibaba.fastjson.JSONObject; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + + +public class AppUnInstallListener implements AppListener { + + @Override + public void after(AppContext app) { +// TODO Auto-generated method stub + ConsolePrinter.info("publish app custom uninstall"); + System.out.print("publish app custom uninstall"); + ResponseObject ro = ResponseObject.newOkResponse(); + AppAPI appAPI = SDK.getAppAPI(); + String sourceAppId = app.getId(); + String xpagesid = "com.actionsoft.apps.addons.xpages"; + AppContext xpagesApp = appAPI.getAppContext(xpagesid); + AppContext publishApp = appAPI.getAppContext(sourceAppId); + if (xpagesApp != null && SDK.getAppAPI().isActive(xpagesApp.getId())) { + // 服务地址 + String aslp = "aslp://com.actionsoft.apps.addons.xpages/deleteTemplate"; + Map params = new HashMap(); + try { + // 参数定义列表 + String templateId = "30267ab3-aeb6-4371-88e0-ecc13cef94a6"; + params.put("templateId", templateId); + appAPI.callASLP(publishApp, aslp, params); + if (ro.isErr()) { + AppsLogger.err(publishApp, ro.getMsg()); + } + ConsolePrinter.info(ro.toString()); + } catch (Exception e) { + e.printStackTrace(); + ro.err(e.getMessage()); + } + } + + + } + + @Override + public boolean before(AppContext arg0) { + return true; + } +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishAppCustomAction.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishAppCustomAction.java new file mode 100644 index 00000000..fc355446 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishAppCustomAction.java @@ -0,0 +1,120 @@ +package com.actionsoft.apps.coe.pal.publisher.event; + +import com.actionsoft.apps.AppsConst; +import com.actionsoft.apps.lifecycle.dist.DistContext; +import com.actionsoft.apps.lifecycle.event.AppCustomActionInterface; +import com.actionsoft.apps.resource.AppContext; +import com.actionsoft.bpms.util.Base64; +import com.actionsoft.bpms.util.ConsolePrinter; +import com.actionsoft.exception.AWSException; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.AppAPI; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + + +public class PublishAppCustomAction implements AppCustomActionInterface { + + @Override + public void dist(AppContext app, DistContext distCtx) { + // TODO Auto-generated method stub + } + + @Override + public void install(AppContext app) { + ConsolePrinter.info("publish app custom install"); + System.out.print("publish app custom install"); + // 流程管理门户xpages文件同步到xpages应用中 + handleXPagesTemplate(app,"0"); + } + + public void uninstall(AppContext app) { + // TODO Auto-generated method stub + ConsolePrinter.info("publish app custom uninstall"); + System.out.print("publish app custom uninstall"); + //根据publish应用下的模板路径对应删除掉xpages模板 + String path = AppsConst.APPS_ROOT + AppsConst.FOLDER_INSTALL + File.separator + app.getId() + File.separator + "xpages" + File.separator; + ConsolePrinter.info(path); + File fileDir = new File(path); + if (fileDir.exists()) { + File [] files = fileDir.listFiles(); + for (File file : files) { + String sourceAppId = app.getId(); + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.addons.xpages/deleteTemplate"; + // 参数定义列表 + Map params = new HashMap<>(); + String fileName = file.getName(); + String templateId =""; + int dotindex = fileName.lastIndexOf("."); + if (dotindex != -1) { + templateId = fileName.substring(0, dotindex); + } + System.out.print(templateId); + ConsolePrinter.info(templateId); + params.put("templateId", templateId); + AppAPI appAPI = SDK.getAppAPI(); + appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + } + } + + } + + @Override + public void upgrade(AppContext app) { + // TODO Auto-generated method stub + handleXPagesTemplate(app,"0"); + + } + + /** + * 操作xpages模板 + * @param app + * @param overWriteFlag + */ + private void handleXPagesTemplate(AppContext app,String overWriteFlag){ + // 流程管理门户xpages文件同步到xpages应用中 + try { + String path = AppsConst.APPS_ROOT + AppsConst.FOLDER_INSTALL + File.separator + app.getId() + File.separator + "xpages" + File.separator; + ConsolePrinter.info(path); + File fileDir = new File(path); + if (fileDir.exists()) { + File [] files = fileDir.listFiles(); + for (File file : files) { + InputStream input = null; + ByteArrayOutputStream arrayOutputStream = null; + input = new FileInputStream(file); + arrayOutputStream = new ByteArrayOutputStream(); + byte [] buf = new byte[1024]; + int len = 0; + while ((len = input.read(buf)) != -1) { + arrayOutputStream.write(buf, 0, len); + } + byte [] bytedata = arrayOutputStream.toByteArray(); + String content = new String(Base64.encode(bytedata)); + // 调用App + String sourceAppId = app.getId(); + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.addons.xpages/createTemplateByContent"; + // 参数定义列表 + Map params = new HashMap<>(); + //内容,必填 + params.put("content", content); + //0,覆盖 1不覆盖,非必填 + params.put("overWriteFlag", overWriteFlag); + AppAPI appAPI = SDK.getAppAPI(); + //根据一个xpages文件的内容创建一个xpages模板记录 + appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + } + } + } catch (Exception e) { + e.printStackTrace(); + throw new AWSException("流程管理门户xpages文件解析错误"); + } + } +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishExecuteListenerInterfaceImpl.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishExecuteListenerInterfaceImpl.java new file mode 100644 index 00000000..42017965 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishExecuteListenerInterfaceImpl.java @@ -0,0 +1,134 @@ +package com.actionsoft.apps.coe.pal.publisher.event; + +import java.sql.Timestamp; +import java.util.List; + +import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishHistory; +import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishListHistory; +import com.actionsoft.apps.coe.pal.pal.manage.publish.model.PublishHistoryModel; +import com.actionsoft.apps.coe.pal.pal.manage.publish.model.PublishListHistoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository; +import com.actionsoft.apps.coe.pal.publisher.constant.PublisherConstant; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener; +import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListenerInterface; +import com.actionsoft.bpms.util.UUIDGener; +import com.actionsoft.sdk.local.SDK; + +public class PublishExecuteListenerInterfaceImpl extends ExecuteListener implements ExecuteListenerInterface { + + @Override + public String getDescription() { + return "将发布信息保存至CoE中。"; + } + + @Override + public String getProvider() { + return "aws-coe"; + } + + @Override + public String getVersion() { + return "V6.0"; + } + + @Override + public void execute(ProcessExecutionContext param) throws Exception { + //将发布信息保存至coe的发布表中 + PublishHistoryModel model = new PublishHistoryModel(); + String processInstId = param.getProcessInstance().getId(); + if ("terminate".equals(param.getProcessInstance().getControlState())) { + return; + } + BO bo = SDK.getBOAPI().query(PublisherConstant.BOTABLENAME).detailByBindId(processInstId); + model.setId(UUIDGener.getUUID()); + model.setProcessInstId(processInstId); + model.setWsId(bo.get("WSID").toString()); + model.setUserId(bo.get("APPLYUSERID").toString()); + String auditorId = ""; + if (bo.get("AUDITOR3") != null && !"".equals(bo.get("AUDITOR3").toString())) { + auditorId = bo.get("AUDITOR3").toString(); + } else if (bo.get("AUDITOR2") != null && !"".equals(bo.get("AUDITOR2").toString())) { + auditorId = bo.get("AUDITOR2").toString(); + } else { + auditorId = bo.get("AUDITOR1").toString(); + } + model.setAuditorId(auditorId); + model.setPublishDate(Timestamp.valueOf(bo.get("UPDATEDATE").toString())); + model.setPublishDesc(bo.get("PUBLISHDESC") == null ? "" : bo.get("PUBLISHDESC").toString()); + model.setTeamId(bo.get("TEAMID").toString()); + + List bolistN = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_N).bindId(processInstId).list(); + model.setPublishNew(bolistN == null ? 0 : bolistN.size()); + List bolistC = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_C).bindId(processInstId).list(); + model.setPublishChange(bolistC == null ? 0 : bolistC.size()); + List bolistS = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_S).bindId(processInstId).list(); + model.setPublishStop(bolistS == null ? 0 : bolistS.size()); + + PublishHistory dao = new PublishHistory(); + dao.insert(model); + + PublishListHistory listDao = new PublishListHistory(); + PALRepository repositoryDao = new PALRepository(); + //将发布信息保存至coe的发布子表中 + if (bolistN != null) { + for (BO boN : bolistN) { + PublishListHistoryModel publishListHistoryModelN = new PublishListHistoryModel(); + publishListHistoryModelN.setId(UUIDGener.getUUID()); + publishListHistoryModelN.setActionType("N"); + publishListHistoryModelN.setpId(model.getId()); + publishListHistoryModelN.setPublishDate(model.getPublishDate()); + publishListHistoryModelN.setPalRepositoryId(boN.get("PUBLISHFILEID").toString()); + publishListHistoryModelN.setPublishDesc(boN.get("PUBLISHDESC") == null ? "" : boN.get("PUBLISHDESC").toString()); + if (boN.get("TASKID") != null && !"".equals(boN.get("TASKID"))) { + publishListHistoryModelN.setTaskId(boN.get("TASKID").toString()); + } else { + publishListHistoryModelN.setTaskId(""); + } + listDao.insert(publishListHistoryModelN); + //修改流程文件的发布属性和发布时间 + repositoryDao.updatePublishStatusAndDate("N", boN.get("PUBLISHFILEID").toString(), null, model.getPublishDate()); + } + } + if (bolistC != null) { + for (BO boC : bolistC) { + PublishListHistoryModel publishListHistoryModelC = new PublishListHistoryModel(); + publishListHistoryModelC.setId(UUIDGener.getUUID()); + publishListHistoryModelC.setActionType("C"); + publishListHistoryModelC.setpId(model.getId()); + publishListHistoryModelC.setPublishDate(model.getPublishDate()); + publishListHistoryModelC.setPalRepositoryId(boC.get("CHANGEDFILEIDNEW").toString()); + publishListHistoryModelC.setPublishDesc(boC.get("CHANGEDDESC") == null ? "" : boC.get("CHANGEDDESC").toString()); + if (boC.get("TASKID") != null && !"".equals(boC.get("TASKID"))) { + publishListHistoryModelC.setTaskId(boC.get("TASKID").toString()); + } else { + publishListHistoryModelC.setTaskId(""); + } + listDao.insert(publishListHistoryModelC); + //修改流程文件的发布属性 + repositoryDao.updatePublishStatusAndDate("C", boC.get("CHANGEDFILEIDNEW").toString(), boC.get("CHANGEFILEID").toString(), model.getPublishDate()); + } + } + if (bolistS != null) { + for (BO boS : bolistS) { + PublishListHistoryModel publishListHistoryModelS = new PublishListHistoryModel(); + publishListHistoryModelS.setId(UUIDGener.getUUID()); + publishListHistoryModelS.setActionType("S"); + publishListHistoryModelS.setpId(model.getId()); + publishListHistoryModelS.setPublishDate(model.getPublishDate()); + publishListHistoryModelS.setPalRepositoryId(boS.get("STOPFILEID").toString()); + publishListHistoryModelS.setPublishDesc(boS.get("STOPDESC") == null ? "" : boS.get("STOPDESC").toString()); + if (boS.get("TASKID") != null && !"".equals(boS.get("TASKID"))) { + publishListHistoryModelS.setTaskId(boS.get("TASKID").toString()); + } else { + publishListHistoryModelS.setTaskId(""); + } + listDao.insert(publishListHistoryModelS); + //修改流程文件的发布属性 + repositoryDao.updatePublishStatusAndDate("S", boS.get("STOPFILEID").toString(), null, model.getPublishDate()); + } + } + } + +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishInstanceAfterReactivateLIstener.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishInstanceAfterReactivateLIstener.java new file mode 100644 index 00000000..fc3e34dc --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PublishInstanceAfterReactivateLIstener.java @@ -0,0 +1,244 @@ +package com.actionsoft.apps.coe.pal.publisher.event; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; + +import com.actionsoft.apps.coe.pal.pal.manage.publish.dao.PublishHistory; +import com.actionsoft.apps.coe.pal.pal.manage.publish.model.PublishHistoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl; +import com.actionsoft.apps.coe.pal.publisher.constant.PublisherConstant; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance; +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.sdk.local.SDK; + +public class PublishInstanceAfterReactivateLIstener extends ExecuteListener{ + + @Override + public String getDescription() { + return "流程复活后进行相关数据还原处理"; + } + + @Override + public String getProvider() { + return "aws-coe"; + } + + @Override + public String getVersion() { + return "V6.3"; + } + + @Override + public void execute(ProcessExecutionContext ctx) throws Exception { + String processInstId = ctx.getProcessInstance().getId(); + ProcessInstance processInstance = ctx.getProcessInstance(); + SDK.getLogAPI().consoleInfo("-----------执行流程复活后事件-------------"); + SDK.getLogAPI().consoleInfo("流程实例标题:" + processInstance.getTitle() + "[processInstId=" + processInstId + "]"); + // 获取相关的流程数据 + + List bolistN = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_N).bindId(processInstId).list(); + List bolistC = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_C).bindId(processInstId).list(); + List bolistS = SDK.getBOAPI().query(PublisherConstant.BOSUBTABLE_S).bindId(processInstId).list(); + List pList = new ArrayList<>(); + if (bolistN != null) { + for (BO boN : bolistN) { + String publishFileId = boN.get("PUBLISHFILEID").toString(); + PALRepositoryModel palModel = PALRepositoryCache.getCache().get(publishFileId); + if (palModel != null && palModel.isPublish()) {// 若当前为非已发布状态,则不进行处理 + // 若当前流程model.getPalRepositoryId()除此次发布以外存在发布过、变更过、废止过,则退回至停用状态,否则退回至设计状态 + // List allPublishData = listDao.query("PALREPOSITORYID = ?", publishFileId).list(); + List allPublishData = DBSql.getMaps("SELECT ID FROM SYS_COE_PAL_PUBLISH_LIST WHERE PALREPOSITORYID = ?", new Object[] {publishFileId}); + if (allPublishData != null) { + boolean isPublish = false; + boolean isStop = false; + boolean isApproval = false; + if (allPublishData.size() > 1) { + // 退回至停用状态 + isStop = true; + } else { + // 退回至设计状态 + } + createResultMap(palModel.getName(), palModel.getId(), isPublish, isStop, isApproval, pList); + } + } + + } + } + if (bolistC != null) { + for (BO boC : bolistC) { + String changefileId = boC.get("CHANGEFILEID").toString();// 变更文件id + String changedFileIdNew = boC.get("CHANGEDFILEIDNEW").toString();// 变更后文件id + PALRepositoryModel changeModel = PALRepositoryCache.getCache().get(changefileId); + PALRepositoryModel changeNewModel = PALRepositoryCache.getCache().get(changedFileIdNew); + // 符合该条件可进行复活,状态值不符合则暂时不处理 + if (changeModel != null && changeNewModel != null && changeModel.isStop() && changeNewModel.isPublish()) { + // changeModel退回至已发布状态 + boolean isPublish = true; + boolean isStop = false; + boolean isApproval = false; + createResultMap(changeModel.getName(), changefileId, isPublish, isStop, isApproval, pList); + // List allchangeData = listDao.query("PALREPOSITORYID = ?", changedFileIdNew).list(); + List allchangeData = DBSql.getMaps("SELECT ID FROM SYS_COE_PAL_PUBLISH_LIST WHERE PALREPOSITORYID = ?", new Object[] {changedFileIdNew}); + if (allchangeData != null) { + isPublish = false; + isStop = false; + isApproval = false; + if (allchangeData.size() > 1) { + // changeNewModel退回至停用状态 + isStop = true; + } else { + // changeNewModel退回至设计状态 + } + createResultMap(changeNewModel.getName(), changedFileIdNew, isPublish, isStop, isApproval, pList); + + } + } + } + } + + if (bolistS != null) { + for (BO boS : bolistS) { + String stopFileId = boS.get("STOPFILEID").toString(); + PALRepositoryModel stopModel = PALRepositoryCache.getCache().get(stopFileId); + // 已停用且该流程版本下所有流程没有在发布状态的进行退回,保证退回之后该流程所有版本中只有一条为已发布状态 + if (stopModel != null && stopModel.isStop()) { + List stopList = PALRepositoryCache.getByVersionId(stopModel.getVersionId()); + boolean flag = false; + for (PALRepositoryModel model : stopList) { + if (model.isPublish()) { + flag = true; + break; + } + } + if (!flag) { + // 退回至已发布状态 + boolean isPublish = true; + boolean isStop = false; + boolean isApproval = false; + createResultMap(stopModel.getName(), stopFileId, isPublish, isStop, isApproval, pList); + } + } + } + } + if (pList.size() > 0) { + restoreData(pList, processInstId); + + } + } + + /** + * 还原数据 + * @param pList + * @param processInstId + */ + private void restoreData(List pList, String processInstId) { + // 批量处理回退数据 + boolean flag = batchHandleRepositoryData(pList); + int r = 0; + if (flag) { + // 删除SYS_COE_PAL_PUBLISH和SYS_COE_PAL_PUBLISH_LIST表数据 + PublishHistory dao = new PublishHistory();// 发布结果主表 + PublishHistoryModel history = dao.queryBy("PROCESSINSTID = ?", processInstId); + if (history != null) { + r = dao.delete(history.getId()); + } + SDK.getLogAPI().consoleInfo("流程状态还原,变更数据[" + pList.size() + "]条"); + for (PALRepositoryModel model : pList) { + SDK.getLogAPI().consoleInfo("流程名称:" + model.getName() + "[id=" + model.getId() + ",isPublish=" + model.isPublish() + ",isStop=" + model.isStop() + "]"); + } + if (r > 0) { + SDK.getLogAPI().consoleInfo("删除发布结果数据成功[processInstId=" + processInstId + "]"); + } + } + } + + /** + * 流程数据库状态还原 + * @param pList + * @return + */ + private boolean batchHandleRepositoryData(List pList) { + boolean completeSuccess = false; + Connection conn = DBSql.open(); + PreparedStatement ps = null; + java.sql.ResultSet rset = null; + Timestamp nowTime = new Timestamp(System.currentTimeMillis()); + try { + conn.setAutoCommit(false); + String sql = "UPDATE " + PALRepositoryModelImpl.DATABASE_ENTITY + " SET " + + PALRepositoryModelImpl.FIELD_PL_ISPUBLISH + " =?, " + + PALRepositoryModelImpl.FIELD_PL_ISSTOP + "= ?," + + PALRepositoryModelImpl.FIELD_PL_MODIFYDATE + " = ? WHERE " + + PALRepositoryModelImpl.FIELD_UUID + "=?"; + ps = conn.prepareStatement(sql); + for (int i = 0; i < pList.size(); i++) { + String id = pList.get(i).getId(); + int isPublish = pList.get(i).isPublish() ? 1 : 0; + int isStop = pList.get(i).isStop() ? 1 : 0; + ps.setInt(1, isPublish); + ps.setInt(2, isStop); + ps.setTimestamp(3, nowTime); + ps.setString(4, id); + ps.addBatch(); + } + int[] results = ps.executeBatch(); + for (int i = 0; i < results.length; i++) { + if ((results[i] >= 0) || (results[i] == PreparedStatement.SUCCESS_NO_INFO)) { + completeSuccess = true; + } + } + if (completeSuccess) { + conn.commit(); + PALRepository dao = new PALRepository(); + for (PALRepositoryModel model : pList) { + PALRepositoryModel model2 = dao.getInstance(model.getId()); + if (model2 != null) { + PALRepositoryCache.getCache().put(model2.getId(), model2); + } + } + } else { + conn.rollback(); + PALRepositoryCache.getCache().reload(); + } + } catch (SQLException e) { + try { + conn.rollback(); + } catch (SQLException e1) { + e1.printStackTrace(); + } + e.printStackTrace(); + } finally { + DBSql.close(conn, ps, rset); + } + return completeSuccess; + } + + /** + * 结果集,用于批量处理数据源 + * @param id + * @param isPublish + * @param isStop + * @param isApproval + */ + private void createResultMap(String name, String id, boolean isPublish, boolean isStop, boolean isApproval, List pList) { + PALRepositoryModelImpl modelImpl = new PALRepositoryModelImpl(); + modelImpl.setId(id); + modelImpl.setName(name); + modelImpl.setPublish(isPublish); + modelImpl.setStop(isStop); + // modelImpl.setApproval(isApproval);// 不处理 + pList.add(modelImpl); + } + +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/SubFormAfterSave.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/SubFormAfterSave.java new file mode 100644 index 00000000..7da34867 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/SubFormAfterSave.java @@ -0,0 +1,121 @@ +package com.actionsoft.apps.coe.pal.publisher.event; + +import java.util.ArrayList; +import java.util.List; + +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener; +import com.actionsoft.bpms.bpmn.engine.listener.ListenerConst; +import com.actionsoft.bpms.util.UUIDGener; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.BOQueryAPI; + +public class SubFormAfterSave extends ExecuteListener { + + public String getDescription() { + return "子表单保存后,拆分成多条数据保存到数据库中"; + } + + public String getProvider() { + return "Actionsoft"; + } + + public String getVersion() { + return "1.0"; + } + + public void execute(ProcessExecutionContext param) throws Exception { + //记录ID + String boId = param.getParameterOfString(ListenerConst.FORM_EVENT_PARAM_BOID); + //表单ID + String formId = param.getParameterOfString(ListenerConst.FORM_EVENT_PARAM_FORMID); + //BO表名 + String boName = param.getParameterOfString(ListenerConst.FORM_EVENT_PARAM_BONAME); + BO formData = (BO) param.getParameter(ListenerConst.FORM_EVENT_PARAM_FORMDATA); + String bindId = formData.getBindId(); + String uid = formData.getCreateUser(); + if (boName.equals("BO_ACT_COE_PUBLISH_N")) { + // 保存前的表单数据,注意:该参数针对不同场景获取内容会有所不同 + // 主表场景获取主表数据;子表场景获取子表数据;获取不同的数据请使用BOQueryAPI获取 + String publishFileId = formData.getString("PUBLISHFILEID"); + String publishDesc = formData.getString("PUBLISHDESC"); + + BOQueryAPI boQueryAPI = SDK.getBOAPI().query(boName); + boQueryAPI = boQueryAPI.bindId(bindId); + List list = boQueryAPI.list(); + StringBuilder boFileIds = new StringBuilder(); + for (BO bo : list) { + if (!bo.getId().equals(formData.getId())) { + boFileIds.append(bo.get("PUBLISHFILEID")); + } + } + String existedBoFileIds = boFileIds.toString(); + if (publishFileId != null && publishFileId.length() > 0) { + String[] publishFileIds = publishFileId.split(","); + List boList = new ArrayList(); + for (String fileId : publishFileIds) { + if (!existedBoFileIds.contains(fileId)) { + PALRepositoryModel repositoryModel = PALRepositoryCache.getCache().get(fileId); + if (repositoryModel != null) { + BO newBO = new BO(); + newBO.setId(UUIDGener.getUUID()); + newBO.set("PUBLISTHTYPE", "N"); + newBO.set("PUBLISHFILEID", fileId); + newBO.set("PUBLISHFILENAME", repositoryModel.getName()); + newBO.set("PUBLISHDESC", publishDesc); + boList.add(newBO); + } + } + } + SDK.getBOAPI().create(boName, boList, bindId, uid); + // 该记录是否新建的状态,由于机制调整,BO对象中的ID是不为空的,不能通过ID判断记录是否处于新建状态还是修改状态 + boolean isCreate = param.getParameterOfBoolean(ListenerConst.FORM_EVENT_PARAM_ISCREATE); + if (isCreate) { + SDK.getBOAPI().remove(boName, boId); + } + } + } else if (boName.equals("BO_ACT_COE_PUBLISH_S")) { + BOQueryAPI boQueryAPI = SDK.getBOAPI().query(boName); + boQueryAPI = boQueryAPI.bindId(bindId); + List list = boQueryAPI.list(); + StringBuilder boFileIds = new StringBuilder(); + for (BO bo : list) { + if (!bo.getId().equals(formData.getId())) { + boFileIds.append(bo.get("STOPFILEID")); + } + } + String existedBoFileIds = boFileIds.toString(); + + String stopFileId = formData.getString("STOPFILEID"); + String stopDesc = formData.getString("STOPDESC"); + if (stopFileId != null && stopFileId.length() > 0) { + String[] publishFileIds = stopFileId.split(","); + List boList = new ArrayList(); + for (String fileId : publishFileIds) { + if (!existedBoFileIds.contains(fileId)) { + PALRepositoryModel repositoryModel = PALRepositoryCache.getCache().get(fileId); + if (repositoryModel != null) { + BO newBO = new BO(); + newBO.setId(UUIDGener.getUUID()); + newBO.set("STOPTYPE", "S"); + newBO.set("STOPFILEID", fileId); + newBO.set("STOPFILENAME", repositoryModel.getName()); + newBO.set("STOPDESC", stopDesc); + boList.add(newBO); + } + } + } + SDK.getBOAPI().create(boName, boList, bindId, uid); + // 该记录是否新建的状态,由于机制调整,BO对象中的ID是不为空的,不能通过ID判断记录是否处于新建状态还是修改状态 + boolean isCreate = param.getParameterOfBoolean(ListenerConst.FORM_EVENT_PARAM_ISCREATE); + if (isCreate) { + SDK.getBOAPI().remove(boName, boId); + } + } + } + } + +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/SubFormGridFilterListener.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/SubFormGridFilterListener.java new file mode 100644 index 00000000..024945b7 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/SubFormGridFilterListener.java @@ -0,0 +1,71 @@ +package com.actionsoft.apps.coe.pal.publisher.event; + +import java.util.List; + +import com.actionsoft.bpms.bo.design.model.BOItemModel; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +import com.actionsoft.bpms.bpmn.engine.listener.FormGridFilterListener; +import com.actionsoft.bpms.bpmn.engine.listener.FormGridRowLookAndFeel; +import com.actionsoft.bpms.bpmn.engine.listener.ListenerConst; +import com.actionsoft.bpms.form.design.model.FormItemModel; + +public class SubFormGridFilterListener extends FormGridFilterListener { + + @Override + public FormGridRowLookAndFeel acceptRowData(ProcessExecutionContext context, List boItemList, BO boData) { + String tableName = context.getParameterOfString(ListenerConst.FORM_EVENT_PARAM_BONAME); + if (tableName.equals("BO_ACT_COE_PUBLISH_N")) { + //创建一个对象 + FormGridRowLookAndFeel diyLookAndFeel = new FormGridRowLookAndFeel(); + String fileName = boData.getString("PUBLISHFILENAME"); + if (fileName != null) { + boData.set("PUBLISHFILENAME", "" + fileName + "");// 重新设定一个字段的值 + } + + boData.set("字段子表字段名", "|"); + + //处理好之后,将该对象返回 + return diyLookAndFeel; + } else if (tableName.equals("BO_ACT_COE_PUBLISH_C")) { + //创建一个对象 + FormGridRowLookAndFeel diyLookAndFeel = new FormGridRowLookAndFeel(); + String fileName1 = boData.getString("CHANGEFILENAME"); + if (fileName1 != null) { + boData.set("CHANGEFILENAME", "" + fileName1 + "");// 重新设定一个字段的值 + } + String fileName2 = boData.getString("CHANGEDFILENAMENEW"); + if (fileName2 != null) { + boData.set("CHANGEDFILENAMENEW", "" + fileName2 + "");// 重新设定一个字段的值 + } + + boData.set("字段子表字段名", "|"); + + //处理好之后,将该对象返回 + return diyLookAndFeel; + } else if (tableName.equals("BO_ACT_COE_PUBLISH_S")) { + //创建一个对象 + FormGridRowLookAndFeel diyLookAndFeel = new FormGridRowLookAndFeel(); + String fileName = boData.getString("STOPFILENAME"); + if (fileName != null) { + boData.set("STOPFILENAME", "" + fileName + "");// 重新设定一个字段的值 + } + boData.set("字段子表字段名", "|"); + + //处理好之后,将该对象返回 + return diyLookAndFeel; + } + return null; + } + + @Override + public String getCustomeTableHeaderHtml(ProcessExecutionContext arg0, FormItemModel arg1, List arg2) { + return null; + } + + @Override + public String orderByStatement(ProcessExecutionContext arg0) { + return null; + } + +}