diff --git a/com.awspaas.user.apps.yili.integration/.settings/org.eclipse.jdt.core.prefs b/com.awspaas.user.apps.yili.integration/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..ec1937b3 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/XmlDatasUtil.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/XmlDatasUtil.java new file mode 100644 index 00000000..d688686e --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/XmlDatasUtil.java @@ -0,0 +1,240 @@ +package com.awspaas.user.apps.integration; + +/** + * @author wangchengye + * @description + * @createtime 2022-07-09 15:54 + * @updateAndOther + */ +public class XmlDatasUtil { + // 外部系统ID + private String External_system_ID; + // 其他系统待办ID + private String Other_system_to_do_ID; + // 流程标题 + private String Process_title; + //// pc端的url地址 + private String pcurl; + // s手机端的url地址 + private String mobileurl; + // 待办人的登录账号 + private String To_do_login_account; +//待办创建时间 + private String To_do_creation_time; + //// 待办办结时间 + private String To_do_completion_time; + // 待办状态 + private String To_do_status; +//公文类型的待办 + private String To_do_official_type; + // 已读类型 + private String viewtype; + // 创建日期 + private String createdate; + // 待办办结日期 + private String donedate; + // 待办接收日期 + private String receivedate; + // 待办接收时间 + private String receivetime; + // 当前节点是否已经归档 + private String currentnodetype; + // 流程编号 + private String requestcode; + // 当前节点 + private String currentnodename; + // 未操作者 + private String nooperator; + // 待办人员工作工号 + private String workcode; + // 工作流程编号 + private String workflowname; + // 流程创建人员登录账号 + private String createrhrcode; + // 流程创建人员工号 + private String createrworkcode; + + public String getExternal_system_ID() { + return External_system_ID; + } + + public void setExternal_system_ID(String external_system_ID) { + External_system_ID = external_system_ID; + } + + public String getOther_system_to_do_ID() { + return Other_system_to_do_ID; + } + + public void setOther_system_to_do_ID(String other_system_to_do_ID) { + Other_system_to_do_ID = other_system_to_do_ID; + } + + public String getProcess_title() { + return Process_title; + } + + public void setProcess_title(String process_title) { + Process_title = process_title; + } + + public String getPcurl() { + return pcurl; + } + + public void setPcurl(String pcurl) { + this.pcurl = pcurl; + } + + public String getMobileurl() { + return mobileurl; + } + + public void setMobileurl(String mobileurl) { + this.mobileurl = mobileurl; + } + + public String getTo_do_login_account() { + return To_do_login_account; + } + + public void setTo_do_login_account(String to_do_login_account) { + To_do_login_account = to_do_login_account; + } + + public String getTo_do_creation_time() { + return To_do_creation_time; + } + + public void setTo_do_creation_time(String to_do_creation_time) { + To_do_creation_time = to_do_creation_time; + } + + public String getTo_do_completion_time() { + return To_do_completion_time; + } + + public void setTo_do_completion_time(String to_do_completion_time) { + To_do_completion_time = to_do_completion_time; + } + + public String getTo_do_status() { + return To_do_status; + } + + public void setTo_do_status(String to_do_status) { + To_do_status = to_do_status; + } + + public String getTo_do_official_type() { + return To_do_official_type; + } + + public void setTo_do_official_type(String to_do_official_type) { + To_do_official_type = to_do_official_type; + } + + public String getViewtype() { + return viewtype; + } + + public void setViewtype(String viewtype) { + this.viewtype = viewtype; + } + + public String getCreatedate() { + return createdate; + } + + public void setCreatedate(String createdate) { + this.createdate = createdate; + } + + public String getDonedate() { + return donedate; + } + + public void setDonedate(String donedate) { + this.donedate = donedate; + } + + public String getReceivedate() { + return receivedate; + } + + public void setReceivedate(String receivedate) { + this.receivedate = receivedate; + } + + public String getReceivetime() { + return receivetime; + } + + public void setReceivetime(String receivetime) { + this.receivetime = receivetime; + } + + public String getCurrentnodetype() { + return currentnodetype; + } + + public void setCurrentnodetype(String currentnodetype) { + this.currentnodetype = currentnodetype; + } + + public String getRequestcode() { + return requestcode; + } + + public void setRequestcode(String requestcode) { + this.requestcode = requestcode; + } + + public String getCurrentnodename() { + return currentnodename; + } + + public void setCurrentnodename(String currentnodename) { + this.currentnodename = currentnodename; + } + + public String getNooperator() { + return nooperator; + } + + public void setNooperator(String nooperator) { + this.nooperator = nooperator; + } + + public String getWorkcode() { + return workcode; + } + + public void setWorkcode(String workcode) { + this.workcode = workcode; + } + + public String getWorkflowname() { + return workflowname; + } + + public void setWorkflowname(String workflowname) { + this.workflowname = workflowname; + } + + public String getCreaterhrcode() { + return createrhrcode; + } + + public void setCreaterhrcode(String createrhrcode) { + this.createrhrcode = createrhrcode; + } + + public String getCreaterworkcode() { + return createrworkcode; + } + + public void setCreaterworkcode(String createrworkcode) { + this.createrworkcode = createrworkcode; + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/CreateFileContorller.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/CreateFileContorller.java new file mode 100644 index 00000000..64b8a879 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/CreateFileContorller.java @@ -0,0 +1,102 @@ +package com.awspaas.user.apps.integration.controller; + +import com.actionsoft.apps.coe.pal.constant.CoEConstant; +import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI; +import com.actionsoft.apps.coe.pal.log.CoEOpLogConst; +import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager; +import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; +import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.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.resource.plugin.profile.DCPluginProfile; +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.server.bind.annotation.Controller; +import com.actionsoft.bpms.server.bind.annotation.Mapping; +import com.actionsoft.bpms.server.conf.server.AWSServerConf; +import com.actionsoft.bpms.server.fs.DCContext; +import com.actionsoft.bpms.server.fs.dc.DCProfileManager; +import com.actionsoft.bpms.server.fs.dc.DCUtil; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.bpms.util.UUIDGener; +import com.actionsoft.bpms.util.UtilFile; +import com.actionsoft.bpms.util.UtilString; +import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSONObject; +import com.awspaas.user.apps.integration.event.OutputDCFileProcessor; +import com.awspaas.user.apps.integration.web.UpfileWeb; + +import java.io.File; +import java.util.LinkedHashMap; +import java.util.List; + +/* + * 文件阅览界面下载时创建手册 + */ +@Controller +public class CreateFileContorller { + /* @Mapping("com.awspaas.user.apps.integrates.createFileController") + public JSONObject createFile(String sid,String taskId,String title) throws Exception { + System.out.println("taskid》》》》》》》》》》"+taskId); + System.out.println("fileName》》》》》》》》》》"+title); + String reportDownloadURL = ""; + UserContext me = UserContext.fromSessionId(sid); + OutputTaskModel model = new OutputTask().getTaskReportById(taskId); + JSONObject result = new JSONObject(); + if (model != null) { + //三员管理,步骤横表下载重新生成手册 + + String taskName = model.getTaskName(); + if ("步骤横表".equals(taskName)){ + // 重新设置生成id,与用户id + String uuid = UUIDGener.getUUID(); + model.setUserId(me.getUID()); + + // 重新生成手册文件 + OutputAPIManager.getInstance().reGennerReport(me,model,uuid); + + // 重新构建手册下载URL + taskId = uuid; + } + + try { + result.put("result","ok"); + reportDownloadURL = OutputDCFileProcessor.getReportDownloadURL(model.getWsId(), taskId, model.getProfileId(), me, title+model.getTaskName()); + result.put("url",reportDownloadURL); + } catch (Exception e) { + + e.printStackTrace(); + } + } + return result; + }*/ + + @Mapping("com.awspaas.user.apps.integrates.createFileController") + public String DownLoad(String sid,String taskId,String title,String id) throws Exception { + UserContext me = UserContext.fromSessionId(sid); + UpfileWeb upfileWeb = new UpfileWeb(me); + String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+id+"' "; + RowMap map = DBSql.getMap(sql); + String method = ""; + if (map!=null){ + method = map.getString("PLMETHODID"); + } + + String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"+id+"'" + + ") and FILENAME not like '%.xml'"; + List maps = DBSql.getMaps(sql_upfile); + String upfile_ids = ""; + if (maps.size()>0){ + for (RowMap rowMap: + maps) { + upfile_ids+=rowMap.getString("ID")+","; + } + } + String zip_url = upfileWeb.readZipFileDownLoad(upfile_ids, title, taskId, method); + return zip_url; + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/GetSomeIndexController.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/GetSomeIndexController.java new file mode 100644 index 00000000..4cc4b802 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/GetSomeIndexController.java @@ -0,0 +1,80 @@ +package com.awspaas.user.apps.integration.controller; + +import java.util.Date; +import java.util.LinkedHashMap; + +import com.actionsoft.bpms.bo.engine.BO; +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.database.RowMap; +import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate; +import com.actionsoft.bpms.server.RequestParams; +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.DBSql; +import com.actionsoft.bpms.util.UUIDGener; +import com.actionsoft.sdk.local.SDK; + +@Controller +public class GetSomeIndexController { + @Mapping(value = "com.awspaas.user.apps.integration.controller.GetSomeIndexController.toIndex") + public String toIndex() { + return HtmlPageTemplate.merge("com.awspaas.user.apps.yili.integration", "domainprocess.html", + new LinkedHashMap<>()); + } + + @Mapping(value = "com.awspaas.user.apps.integration.controller.GetSomeIndexController.getProcessCenter") + public String getProcessCenter(UserContext me, RequestParams params) { + ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance( + "obj_fb1c7a54b98b412187388c8bab407362", me.getUID(), me.getUserName() + "发起流程发布流程"); + // ProcessExecuteQuery start = SDK.getProcessAPI().start(processInstance); + // String startTaskInstId = processInstance.getStartTaskInstId(); + SDK.getProcessAPI().setVariable(processInstance, "createType", "oa"); + setData(me, processInstance); + TaskInstance taskInstance = (TaskInstance) SDK.getProcessAPI().start(processInstance).fetchActiveTasks().get(0); + String url = SDK.getPortalAPI().getPortalUrl() + "/r/w?sid=" + me.getSessionId() + + "&cmd=CLIENT_BPM_FORM_MAIN_PAGE_OPEN&processInstId=" + processInstance.getId() + "&taskInstId=" + + taskInstance.getId() + "&openState=1&reloadedFile=1"; + return SDK.getFormAPI().getFormPage(me, processInstance.getId(), taskInstance.getId(), taskInstance.getState(), + 1, "", "", "", true); + } + + public void setData(UserContext userContext, ProcessInstance processInstance) { + BO bo = new BO(); + bo.set("TEAMID", ""); + bo.set("TEAMNAME", ""); + bo.set("PUBLISHID", UUIDGener.getUUID()); + bo.set("APPLYUSERID", userContext.getUID()); + bo.set("APPLYUSERNAME", userContext.getUID()); + String deptId = userContext.getUserModel().getDepartmentId(); + bo.set("APPLYDEPTID", deptId); + bo.set("APPLYDEPTNAME", SDK.getORGAPI().getDepartmentById(deptId).getName()); + bo.set("APPLYDATE", new Date()); + bo.set("SAVESTATUS", 1);// 流程实例状态 + bo.set("CREATETYPE", 1);// 创建类型 + + // 根据部门名称 和单位 计算出 内部校对人 和流程经理 + String departmentId = userContext.getUserModel().getDepartmentId(); + String allpath = SDK.getORGAPI().getDepartmentById(departmentId).getPathNameOfCache(); + String[] patharr = allpath.split("/"); + StringBuffer sb = new StringBuffer(); + for (String str : patharr) { + sb.append("'").append(str).append("'").append(","); + } + String substring = sb.substring(0, sb.length() - 1); + // 可以为boData中的字段进行赋值 + RowMap data = DBSql.getMap("select DEAPRTMNUM,PROCESSMNUMBER from BO_ACT_PROCESSMANAGER where ORGDEPART in (" + substring + ")"); + if (null != data) { + //throw new AWSException("请联系管理员,配置流程经理和流程校对人!"); + bo.set("DEPARTMENT_PROOFREADER", data.getString("DEAPRTMNUM")); + bo.set("PROCESS_MANAGER", data.getString("PROCESSMNUMBER")); + } + bo.set("WSID", "7d3ca852-a0bd-42e6-80b1-3dcea6f55083"); + bo.set("RELEASE_INSTRUCTIONS", + "


关于发布《XXXXXXXXXXXX》的通知

 

各事业部、分(子)公司、总部各部(室):

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,现下发《xxxxxxxxxxxxxxx》,请各单位遵照执行。

特此通知。

(xxxxxxxxx)单位名称

2022年7月27日

");// 流程实例状态 + SDK.getBOAPI().create("BO_ACT_COE_PUBLISH", bo, processInstance, userContext); + + } + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/GetmeritsController.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/GetmeritsController.java new file mode 100644 index 00000000..9d8fd9a3 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/GetmeritsController.java @@ -0,0 +1,2185 @@ +package com.awspaas.user.apps.integration.controller; + +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate; +import com.actionsoft.bpms.server.bind.annotation.Controller; +import com.actionsoft.bpms.server.bind.annotation.Mapping; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang.StringUtils; + +import java.util.*; + +@Controller +public class GetmeritsController { + + + /** + * 获取页面的方法 + */ + @Mapping("com.awspaas.user.apps.integration.controller.GetmeritsController.getHtml") + public String getHtml(){ + + String html = "territory.html"; + + return HtmlPageTemplate.merge("com.awspaas.user.apps.yili.integration",html,new LinkedHashMap<>()); + } + + /** + * 这是第一个图的筛选方法 + * @param sid session + * @param departname 部门名称 + * @return + */ + @Mapping("com.awspaas.user.apps.integration.controller.GetmeritsController.getMetritsFirst") + public JSONObject getMetritsFirst(String sid,String departname){ + JSONObject result = new JSONObject(new LinkedHashMap<>()); + List list = new ArrayList(new LinkedList()); + list.add(0,""); + list.add(1,"L1流程架构"); + list.add(2,"绩效指标"); + result.put("headtop",list); + if (departname.equals("全部")){ + /** + * 战略流程 + */ + JSONArray jsonArray1 =new JSONArray(new LinkedList<>()); + JSONObject json_first = new JSONObject(new LinkedHashMap<>()); + json_first.put("leftname","战略流程"); + JSONArray secondcont = new JSONArray(); + JSONArray num1 = new JSONArray(); + List list1 = SDK.getBOAPI().query("BO_EU_LCJG", true).addQuery("JG_NAME=", "战略流程").orderByCreated().asc().list(); + for (BO bo:list1 + ) { + JSONObject jsonObject_se = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_name = new JSONObject(new LinkedHashMap<>()); + String name = bo.getString("LC_NAME").substring(bo.getString("LC_NAME").indexOf(" ")+1,bo.getString("LC_NAME").length()); + String num_name = bo.getString("LC_NAME").substring(0,bo.getString("LC_NAME").indexOf(" ")-1); + System.out.println("L1-L3下的名称前的数字是>>>>>>"+num_name); + jsonObject_se.put("name",bo.getString("LC_NAME")); + + String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLNAME = '"+bo.getString("LC_NAME")+"' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + RowMap maps = DBSql.getMap(sql); + jsonObject_se.put("id",maps.getString("ID")); + String string = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where SYNCHRONOUS_HOME like '" +num_name + "%'"); + jsonObject_name.put("name",string); + num1.add(jsonObject_name); + secondcont.add(jsonObject_se); + } + + json_first.put("secondcont",secondcont); + json_first.put("num1",num1); + + /** + * 运营流程 + */ + JSONObject json_second = new JSONObject(new LinkedHashMap<>()); + json_second.put("leftname","运营流程"); + JSONArray secondcont_second = new JSONArray(); + JSONArray num1_second = new JSONArray(); + List list1_second = SDK.getBOAPI().query("BO_EU_LCJG", true).addQuery("JG_NAME=", "运营流程").orderByCreated().asc().list(); + for (BO bo:list1_second + ) { + JSONObject jsonObject_se = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_name = new JSONObject(new LinkedHashMap<>()); + jsonObject_se.put("name",bo.getString("LC_NAME")); + String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLNAME = '"+bo.getString("LC_NAME")+"' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + RowMap maps = DBSql.getMap(sql); + jsonObject_se.put("id",maps.getString("ID")); + String name = bo.getString("LC_NAME").substring(bo.getString("LC_NAME").indexOf(" ")+1,bo.getString("LC_NAME").length()); + String num_name = bo.getString("LC_NAME").substring(0,bo.getString("LC_NAME").indexOf(" ")-1); + + String string = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where SYNCHRONOUS_HOME like '" +num_name + "%'"); + jsonObject_name.put("name",string); + num1_second.add(jsonObject_name); + secondcont_second.add(jsonObject_se); + } + + json_second.put("secondcont",secondcont_second); + json_second.put("num1",num1_second); + +/** + * 支持流程 + */ + +/** + * 运营流程 + */ + JSONObject json_thrid = new JSONObject(new LinkedHashMap<>()); + json_thrid.put("leftname","支持流程"); + JSONArray secondcont_thrid = new JSONArray(); + JSONArray num1_thrid = new JSONArray(); + List list1_thrid = SDK.getBOAPI().query("BO_EU_LCJG", true).addQuery("JG_NAME=", "支持流程").orderByCreated().asc().list(); + for (BO bo:list1_thrid + ) { + JSONObject jsonObject_se = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_name = new JSONObject(new LinkedHashMap<>()); + jsonObject_se.put("name",bo.getString("LC_NAME")); + String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLNAME = '"+bo.getString("LC_NAME")+"' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + RowMap maps = DBSql.getMap(sql); + jsonObject_se.put("id",maps.getString("ID")); + String name = bo.getString("LC_NAME").substring(bo.getString("LC_NAME").indexOf(" ")+1,bo.getString("LC_NAME").length()); + String num_name = bo.getString("LC_NAME").substring(0,bo.getString("LC_NAME").indexOf(" ")-1); + + String string = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where SYNCHRONOUS_HOME like '" +num_name+ "%'"); + jsonObject_name.put("name",string); + num1_thrid.add(jsonObject_name); + secondcont_thrid.add(jsonObject_se); + } + + json_thrid.put("secondcont",secondcont_thrid); + json_thrid.put("num1",num1_thrid); + jsonArray1.add(json_first); + jsonArray1.add(json_second); + jsonArray1.add(json_thrid); + result.put("content",jsonArray1); + return result; + }else{ + /** + * 战略流程 + */ + JSONArray jsonArray1 =new JSONArray(new LinkedList<>()); + JSONObject json_first = new JSONObject(new LinkedHashMap<>()); + json_first.put("leftname","战略流程"); + JSONArray secondcont = new JSONArray(); + JSONArray num1 = new JSONArray(); + List list1 = SDK.getBOAPI().query("BO_EU_LCJG", true).addQuery("JG_NAME=", "战略流程").orderByCreated().asc().list(); + for (BO bo:list1 + ) { + JSONObject jsonObject_se = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_name = new JSONObject(new LinkedHashMap<>()); + String name = bo.getString("LC_NAME").substring(bo.getString("LC_NAME").indexOf(" ")+1,bo.getString("LC_NAME").length()); + String num_name = bo.getString("LC_NAME").substring(0,bo.getString("LC_NAME").indexOf(" ")-1); + + jsonObject_se.put("name",bo.getString("LC_NAME")); + + String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLNAME = '"+bo.getString("LC_NAME")+"' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + RowMap maps = DBSql.getMap(sql); + jsonObject_se.put("id",maps.getString("ID")); + String string = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where SYNCHRONOUS_HOME like '" +num_name + "%' and NDICATOR_USER_DEFINED_LABEL = '"+departname+"'"); + jsonObject_name.put("name",string); + num1.add(jsonObject_name); + secondcont.add(jsonObject_se); + } + + json_first.put("secondcont",secondcont); + json_first.put("num1",num1); + + /** + * 运营流程 + */ + JSONObject json_second = new JSONObject(new LinkedHashMap<>()); + json_second.put("leftname","运营流程"); + JSONArray secondcont_second = new JSONArray(); + JSONArray num1_second = new JSONArray(); + List list1_second = SDK.getBOAPI().query("BO_EU_LCJG", true).addQuery("JG_NAME=", "运营流程").orderByCreated().asc().list(); + for (BO bo:list1_second + ) { + JSONObject jsonObject_se = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_name = new JSONObject(new LinkedHashMap<>()); + jsonObject_se.put("name",bo.getString("LC_NAME")); + String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLNAME = '"+bo.getString("LC_NAME")+"' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + RowMap maps = DBSql.getMap(sql); + jsonObject_se.put("id",maps.getString("ID")); + String name = bo.getString("LC_NAME").substring(bo.getString("LC_NAME").indexOf(" ")+1,bo.getString("LC_NAME").length()); + String num_name = bo.getString("LC_NAME").substring(0,bo.getString("LC_NAME").indexOf(" ")-1); + + String string = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where SYNCHRONOUS_HOME like '" +num_name + "%' and NDICATOR_USER_DEFINED_LABEL = '"+departname+"'"); + jsonObject_name.put("name",string); + num1_second.add(jsonObject_name); + secondcont_second.add(jsonObject_se); + } + + json_second.put("secondcont",secondcont_second); + json_second.put("num1",num1_second); + +/** + * 支持流程 + */ + +/** + * 运营流程 + */ + JSONObject json_thrid = new JSONObject(new LinkedHashMap<>()); + json_thrid.put("leftname","支持流程"); + JSONArray secondcont_thrid = new JSONArray(); + JSONArray num1_thrid = new JSONArray(); + List list1_thrid = SDK.getBOAPI().query("BO_EU_LCJG", true).addQuery("JG_NAME=", "支持流程").orderByCreated().asc().list(); + for (BO bo:list1_thrid + ) { + JSONObject jsonObject_se = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_name = new JSONObject(new LinkedHashMap<>()); + jsonObject_se.put("name",bo.getString("LC_NAME")); + String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLNAME = '"+bo.getString("LC_NAME")+"' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + RowMap maps = DBSql.getMap(sql); + jsonObject_se.put("id",maps.getString("ID")); + String name = bo.getString("LC_NAME").substring(bo.getString("LC_NAME").indexOf(" ")+1,bo.getString("LC_NAME").length()); + String num_name = bo.getString("LC_NAME").substring(0,bo.getString("LC_NAME").indexOf(" ")-1); + + String string = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where SYNCHRONOUS_HOME like '" +num_name + "%' and NDICATOR_USER_DEFINED_LABEL = '"+departname+"'"); + jsonObject_name.put("name",string); + num1_thrid.add(jsonObject_name); + secondcont_thrid.add(jsonObject_se); + } + + json_thrid.put("secondcont",secondcont_thrid); + json_thrid.put("num1",num1_thrid); + jsonArray1.add(json_first); + jsonArray1.add(json_second); + jsonArray1.add(json_thrid); + result.put("content",jsonArray1); + return result; + } + } + @Mapping("com.awspaas.user.apps.integration.controller.GetmeritsController.getDepartname") + public JSONObject getDepartname(String sid){ + JSONObject result = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + List bo_eu_depat_name = SDK.getBOAPI().query("BO_EU_DEPAT_NAME", true).list(); + int i=0; + for (BO bo:bo_eu_depat_name + ) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("termsKey",i); + jsonObject.put("termsVal",bo.getString("DEPART_NAME")); + jsonArray.add(jsonObject); + i++; + } + result.put("result","ok"); + result.put("fileTypes",jsonArray); + return result; + } + @Mapping("com.awspaas.user.apps.integration.controller.GetmeritsController.getFirst") + public JSONArray getFirst(String sid,String plid,String name,String departname){ + JSONArray jsonArray = new JSONArray(new LinkedList<>()); + if (StringUtils.isNotEmpty(departname)){ + String sql_parent = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = '"+plid+"' order by PLORDERINDEX asc"; + List maps1 = DBSql.getMaps(sql_parent); + for (RowMap rowMap: maps1) { + JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); + jsonObject.put("text",rowMap.getString("PLNAME")); + jsonObject.put("href","#"); + String PLname = rowMap.getString("PLNAME").substring(rowMap.getString("PLNAME").indexOf(" ")+1,rowMap.getString("PLNAME").length()); + String num_name = rowMap.getString("PLNAME").substring(0,rowMap.getString("PLNAME").indexOf(" ")); + + String names = name.substring(name.indexOf(" ")+1,name.length()); + String string = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where SYNCHRONOUS_HOME like '"+num_name+"%' AND NDICATOR_USER_DEFINED_LABEL = '" + departname + "'"); + jsonObject.put("num",string); + JSONArray jsonArray1 = new JSONArray(new LinkedList<>()); + String sql_parent11 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = '"+rowMap.getString("ID")+"' order by PLORDERINDEX asc"; + List maps111 = DBSql.getMaps(sql_parent11); + for (RowMap rowmap: maps111) { + JSONObject jsonObject1 = new JSONObject(new LinkedHashMap<>()); + jsonObject1.put("text",rowmap.getString("PLNAME")); + jsonObject1.put("href","#"); + String PLname1 = rowmap.getString("PLNAME").substring(rowmap.getString("PLNAME").indexOf(" ")+1,rowmap.getString("PLNAME").length()); + String names1 = rowMap.getString("PLNAME").substring(rowMap.getString("PLNAME").indexOf(" ")+1,rowMap.getString("PLNAME").length()); + String num_name1 = rowmap.getString("PLNAME").substring(0,rowmap.getString("PLNAME").indexOf(" ")); + + String strings = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where SYNCHRONOUS_HOME like '%"+num_name1+"%' AND NDICATOR_USER_DEFINED_LABEL = '" + departname + "'"); + jsonObject1.put("num",strings); + jsonArray1.add(jsonObject1); + String sql_parent111 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = '"+rowmap.getString("ID")+"' order by PLORDERINDEX asc"; + List maps1111 = DBSql.getMaps(sql_parent111); + JSONArray jsonArray2 = new JSONArray(new LinkedList<>()); + for (RowMap map:maps1111 + ) { + JSONObject jsonObject2 = new JSONObject(new LinkedHashMap<>()); + jsonObject2.put("text",map.getString("PLNAME")); + jsonObject2.put("href","#"); + String PLname2 = map.getString("PLNAME").substring(map.getString("PLNAME").indexOf(" ")+1,map.getString("PLNAME").length()); + String names2 = rowmap.getString("PLNAME").substring(rowmap.getString("PLNAME").indexOf(" ")+1,rowmap.getString("PLNAME").length()); + String num_name2 = map.getString("PLNAME").substring(0,map.getString("PLNAME").indexOf(" ")); + + String stringss = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where SYNCHRONOUS_HOME like '%"+num_name2+"' AND NDICATOR_USER_DEFINED_LABEL = '" + departname + "'"); + jsonObject2.put("num",stringss); + jsonArray2.add(jsonObject2); + } + //jsonObject1.put("nodes",jsonArray2); + } + jsonObject.put("nodes",jsonArray1); + jsonArray.add(jsonObject); + } + + + + return jsonArray; + }else { + + String sql_parent = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = '"+plid+"' order by PLORDERINDEX asc"; + List maps1 = DBSql.getMaps(sql_parent); + for (RowMap rowMap: maps1) { + JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); + jsonObject.put("text",rowMap.getString("PLNAME")); + jsonObject.put("href","#"); + String PLname = rowMap.getString("PLNAME").substring(rowMap.getString("PLNAME").indexOf(" ")+1,rowMap.getString("PLNAME").length()); + String num_name = rowMap.getString("PLNAME").substring(0,rowMap.getString("PLNAME").indexOf(" ")); + + String names = name.substring(name.indexOf(" ")+1,name.length()); + String string = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where SYNCHRONOUS_HOME like '"+num_name+"%'"); + jsonObject.put("num",string); + JSONArray jsonArray1 = new JSONArray(new LinkedList<>()); + String sql_parent11 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = '"+rowMap.getString("ID")+"' order by PLORDERINDEX asc"; + List maps111 = DBSql.getMaps(sql_parent11); + for (RowMap rowmap: maps111) { + JSONObject jsonObject1 = new JSONObject(new LinkedHashMap<>()); + jsonObject1.put("text",rowmap.getString("PLNAME")); + jsonObject1.put("href","#"); + String PLname1 = rowmap.getString("PLNAME").substring(rowmap.getString("PLNAME").indexOf(" ")+1,rowmap.getString("PLNAME").length()); + String names1 = rowMap.getString("PLNAME").substring(rowMap.getString("PLNAME").indexOf(" ")+1,rowMap.getString("PLNAME").length()); + String num_name1 = rowmap.getString("PLNAME").substring(0,rowmap.getString("PLNAME").indexOf(" ")); + + String strings = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where SYNCHRONOUS_HOME like '%"+num_name1+"%' "); + jsonObject1.put("num",strings); + jsonArray1.add(jsonObject1); + String sql_parent111 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = '"+rowmap.getString("ID")+"' order by PLORDERINDEX asc"; + List maps1111 = DBSql.getMaps(sql_parent111); + JSONArray jsonArray2 = new JSONArray(new LinkedList<>()); + for (RowMap map:maps1111 + ) { + JSONObject jsonObject2 = new JSONObject(new LinkedHashMap<>()); + jsonObject2.put("text",map.getString("PLNAME")); + jsonObject2.put("href","#"); + String PLname2 = map.getString("PLNAME").substring(map.getString("PLNAME").indexOf(" ")+1,map.getString("PLNAME").length()); + String names2 = rowmap.getString("PLNAME").substring(rowmap.getString("PLNAME").indexOf(" ")+1,rowmap.getString("PLNAME").length()); + String num_name2 = map.getString("PLNAME").substring(0,map.getString("PLNAME").indexOf(" ")); + + String stringss = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where SYNCHRONOUS_HOME like '%"+num_name2+"' "); + jsonObject2.put("num",stringss); + jsonArray2.add(jsonObject2); + } + //jsonObject1.put("nodes",jsonArray2); + } + jsonObject.put("nodes",jsonArray1); + jsonArray.add(jsonObject); + } + + + + return jsonArray; + } + } + + @Mapping("com.awspaas.user.apps.integration.controller.GetmeritsController.getsecondDepartname") + public JSONArray getsecondDepartname(String sid){ + JSONArray result = new JSONArray(); + List bo_eu_depat_name = SDK.getBOAPI().query("BO_EU_DEPAT_NAME", true).list(); + int i=0; + for (BO bo:bo_eu_depat_name + ) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("name",bo.getString("DEPART_NAME")); + result.add(jsonObject); + i++; + } + return result; + } + + @Mapping("com.awspaas.user.apps.integration.controller.GetmeritsController.getL1Process") + public JSONObject getL1Process(String sid){ + JSONObject result = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + List maps = DBSql.getMaps(sql); int i=0; + for (RowMap rowMap:maps + ) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("termsKey",rowMap.getString("ID")); + jsonObject.put("termsVal",rowMap.getString("PLNAME")); + jsonArray.add(jsonObject); + i++; + } + result.put("result","ok"); + result.put("fileTypes",jsonArray); + return result; + } + + @Mapping("com.awspaas.user.apps.integration.controller.GetmeritsController.getTable2Data") + public JSONObject getTable2Data(String sid,String plname,String departname) { + JSONObject result = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_content = new JSONArray(new LinkedList<>()); + + if (departname.equals("全部")){ + + + + + String id = DBSql.getString("select ID from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLNAME = '" + plname + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"); + + /** + * 这是L1的流程绩效数据汇总 + */ + JSONObject jsonObject1 = new JSONObject(new LinkedHashMap<>()); + String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND ID = '" + id + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + RowMap map = DBSql.getMap(sql); + jsonObject1.put("leftname", "L1流程绩效指标"); + JSONArray jsonArray1 = new JSONArray(); + JSONObject jsonObject_secondcont = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_name = new JSONArray(new LinkedList<>()); + JSONObject jsonObject_name = new JSONObject(new LinkedHashMap<>()); + jsonObject_name.put("title", map.getString("PLNAME")); + jsonObject_name.put("id", map.getString("ID")); + jsonObject_name.put("incident", true); + String name = map.getString("PLNAME").substring(map.getString("PLNAME").indexOf(" ")+1); + + String names = map.getString("PLNAME").substring(0,map.getString("PLNAME").indexOf(" ")); + + + List list = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("SYNCHRONOUS_HOME like '"+names+"%' ",null).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效").list(); + List list_child = new LinkedList(); + List linked_Waring = new LinkedList(); + int i = 0; + for (BO bo : list + ) { + list_child.add(i, bo.getString("PERFORMANCE_INDICATOR_NAME")); + linked_Waring.add(i, 10); + i++; + } + jsonObject_name.put("child", list_child); + jsonObject_name.put("Warning", linked_Waring); + jsonArray_name.add(jsonObject_name); + jsonObject_secondcont.put("name", jsonArray_name); + jsonObject_secondcont.put("list1", new LinkedList<>()); + jsonObject_secondcont.put("list2", new LinkedList<>()); + jsonObject_secondcont.put("list3", new LinkedList<>()); + jsonArray1.add(jsonObject_secondcont); + jsonObject1.put("secondcont", jsonArray1); + + /** + * L2流程数据汇总 + */ + String sqls = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = '" + id + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List maps = DBSql.getMaps(sqls); + + String ids = ""; + + JSONObject jsonObject2 = new JSONObject(new LinkedHashMap<>()); + + jsonObject2.put("leftname", "L2流程绩效指标"); + JSONArray jsonArray2 = new JSONArray(); + JSONObject jsonObject_secondcont2 = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_name2 = new JSONArray(new LinkedList<>()); + for (RowMap rowmap : maps + ) { + ids+=rowmap.getString("ID")+","; + + JSONObject jsonObject_name2 = new JSONObject(new LinkedHashMap<>()); + jsonObject_name2.put("title", rowmap.getString("PLNAME")); + jsonObject_name2.put("id", rowmap.getString("ID")); + jsonObject_name2.put("incident", true); + String name2 = rowmap.getString("PLNAME").substring(rowmap.getString("PLNAME").indexOf(" ")+1); + String names2 = rowmap.getString("PLNAME").substring(0,rowmap.getString("PLNAME").indexOf(" ")); + + List lists = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("SYNCHRONOUS_HOME like '"+names2+"%' ",null).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效").list(); + List list_childs = new LinkedList(); + int j = 0; + for (BO bo : lists + ) { + list_childs.add(j, bo.getString("PERFORMANCE_INDICATOR_NAME")); + j++; + } + jsonObject_name2.put("child", list_childs); + jsonArray_name2.add(jsonObject_name2); + + } + jsonObject_secondcont2.put("name", jsonArray_name2); + jsonObject_secondcont2.put("list1", new LinkedList<>()); + jsonObject_secondcont2.put("list2", new LinkedList<>()); + jsonObject_secondcont2.put("list3", new LinkedList<>()); + jsonArray2.add(jsonObject_secondcont2); + jsonObject2.put("secondcont",jsonArray2); + String dleass = ""; + String[] deptSplit = ids.split(","); + if(deptSplit.length==1){ + dleass = "'"+deptSplit[0]+"'"; + } + dleass ="'"+ StringUtils.join(deptSplit, "','")+"'"; + System.out.println( + "dleass》》》》》》》》》》"+dleass + ); + +/** + * 关联流程清单 + */ + JSONObject jsonObject4 = new JSONObject(new LinkedHashMap<>()); + jsonObject4.put("leftname", "关联流程清单"); + JSONArray jsonArray4_secondcont = new JSONArray(new LinkedList<>()); + JSONObject jsonObject4_secondcont = new JSONObject(new LinkedHashMap<>()); + jsonObject4_secondcont.put("name",new LinkedList<>()); + jsonObject4_secondcont.put("list1",new LinkedList<>()); + jsonObject4_secondcont.put("list2",new LinkedList<>()); + jsonObject4_secondcont.put("list3",new LinkedList<>()); + jsonArray4_secondcont.add(jsonObject4_secondcont); + jsonObject4.put("secondcont",jsonArray4_secondcont); + /** + * L3流程数据汇总 + */ + + + + + JSONObject jsonObject3 = new JSONObject(new LinkedHashMap<>()); + + jsonObject3.put("leftname", "L3流程绩效指标"); + JSONArray jsonArray3 = new JSONArray(); + + List list_num = new LinkedList(); + int q=0; + String[] plid = dleass.split(","); + for (String ikds:plid + ) { + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = "+ikds+" AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List mapss = DBSql.getMaps(sqls3); + for (RowMap rowmaps : mapss) { + String name2 = rowmaps.getString("PLNAME").substring(rowmaps.getString("PLNAME").indexOf(" ") + 1); + String name2s = rowmaps.getString("PLNAME").substring(0,rowmaps.getString("PLNAME").indexOf(" ")); + String string = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where PERFORMANCE_TYPE = 'L1L3流程绩效' and SYNCHRONOUS_HOME like '" + name2s + "%'"); + list_num.add(q, Integer.valueOf(string)); + q++; + } + } + + Integer max = Collections.max(list_num); + if (max==0){ + max=3; + } + + Map> map_list = new HashMap>(); + for(int h = 0;h()); + } + JSONObject jsonObject_secondcont3 = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_name3 = new JSONArray(new LinkedList<>()); + + for (String ikds:plid + ) { + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = "+ikds+" AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List mapss = DBSql.getMaps(sqls3); + + for (RowMap rowmaps : mapss + ) { + + + JSONObject jsonObject_name3 = new JSONObject(new LinkedHashMap<>()); + jsonObject_name3.put("title", rowmaps.getString("PLNAME")); + jsonObject_name3.put("id", rowmaps.getString("ID")); + jsonObject_name3.put("incident", true); + String name2 = rowmaps.getString("PLNAME").substring(rowmaps.getString("PLNAME").indexOf(" ")+1); + String name22s = rowmaps.getString("PLNAME").substring(0,rowmaps.getString("PLNAME").indexOf(" "));; + List lists = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效").addQuery("SYNCHRONOUS_HOME like '"+name22s+"%'", null).list(); + List list_childs = new LinkedList(); + jsonObject_name3.put("child", list_childs); + jsonArray_name3.add(jsonObject_name3); + + } + } + jsonObject_secondcont3.put("name", jsonArray_name3); + + int r=0; + + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID in (" + dleass + ") AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List mapss = DBSql.getMaps(sqls3); + for (RowMap rowmaps : mapss) { + String name2 = rowmaps.getString("PLNAME").substring(rowmaps.getString("PLNAME").indexOf(" ") + 1); + String names2 = rowmaps.getString("PLNAME").substring(0,rowmaps.getString("PLNAME").indexOf(" ")); + ; + List lists = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("PERFORMANCE_TYPE=", "L1L3流程绩效").addQuery("SYNCHRONOUS_HOME like '" + names2 + "%'", null).list(); + + for (int w = 0; w < lists.size(); w++) { + map_list.get(String.valueOf(w)).add(r, lists.get(w).getString("PERFORMANCE_INDICATOR_NAME")); + } + if (lists.size() < map_list.size()) { + for (int u = lists.size(); u < map_list.size(); u++) { + map_list.get(String.valueOf(u)).add(r, ""); + } + + } + r++; + + } + for (int t=0;t(); + lisr.add(1); + lisr.add(2); + lisr.add(4); + result.put("yunxing",lisr); + + return result; + }else { + + + + + + String id = DBSql.getString("select ID from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLNAME = '" + plname + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"); + + /** + * 这是L1的流程绩效数据汇总 + */ + JSONObject jsonObject1 = new JSONObject(new LinkedHashMap<>()); + String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND ID = '" + id + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + RowMap map = DBSql.getMap(sql); + jsonObject1.put("leftname", "L1流程绩效指标"); + JSONArray jsonArray1 = new JSONArray(); + JSONObject jsonObject_secondcont = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_name = new JSONArray(new LinkedList<>()); + JSONObject jsonObject_name = new JSONObject(new LinkedHashMap<>()); + jsonObject_name.put("title", map.getString("PLNAME")); + jsonObject_name.put("id", map.getString("ID")); + jsonObject_name.put("incident", true); + String name = map.getString("PLNAME").substring(map.getString("PLNAME").indexOf(" ")+1); + + String names = map.getString("PLNAME").substring(0,map.getString("PLNAME").indexOf(" ")); + + + List list = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("NDICATOR_USER_DEFINED_LABEL = ",departname).addQuery("SYNCHRONOUS_HOME like '"+names+"%' ",null).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效").list(); + List list_child = new LinkedList(); + List linked_Waring = new LinkedList(); + int i = 0; + for (BO bo : list + ) { + list_child.add(i, bo.getString("PERFORMANCE_INDICATOR_NAME")); + linked_Waring.add(i, 10); + i++; + } + jsonObject_name.put("child", list_child); + jsonObject_name.put("Warning", linked_Waring); + jsonArray_name.add(jsonObject_name); + jsonObject_secondcont.put("name", jsonArray_name); + jsonObject_secondcont.put("list1", new LinkedList<>()); + jsonObject_secondcont.put("list2", new LinkedList<>()); + jsonObject_secondcont.put("list3", new LinkedList<>()); + jsonArray1.add(jsonObject_secondcont); + jsonObject1.put("secondcont", jsonArray1); + + /** + * L2流程数据汇总 + */ + String sqls = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = '" + id + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List maps = DBSql.getMaps(sqls); + + String ids = ""; + + JSONObject jsonObject2 = new JSONObject(new LinkedHashMap<>()); + + jsonObject2.put("leftname", "L2流程绩效指标"); + JSONArray jsonArray2 = new JSONArray(); + JSONObject jsonObject_secondcont2 = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_name2 = new JSONArray(new LinkedList<>()); + for (RowMap rowmap : maps + ) { + ids+=rowmap.getString("ID")+","; + + JSONObject jsonObject_name2 = new JSONObject(new LinkedHashMap<>()); + jsonObject_name2.put("title", rowmap.getString("PLNAME")); + jsonObject_name2.put("id", rowmap.getString("ID")); + jsonObject_name2.put("incident", true); + String name2 = rowmap.getString("PLNAME").substring(rowmap.getString("PLNAME").indexOf(" ")+1); + String names2 = rowmap.getString("PLNAME").substring(0,rowmap.getString("PLNAME").indexOf(" ")); + + List lists = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("NDICATOR_USER_DEFINED_LABEL = ",departname).addQuery("SYNCHRONOUS_HOME like '"+names2+"%' ",null).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效").list(); + List list_childs = new LinkedList(); + int j = 0; + for (BO bo : lists + ) { + list_childs.add(j, bo.getString("PERFORMANCE_INDICATOR_NAME")); + j++; + } + jsonObject_name2.put("child", list_childs); + jsonArray_name2.add(jsonObject_name2); + + } + jsonObject_secondcont2.put("name", jsonArray_name2); + jsonObject_secondcont2.put("list1", new LinkedList<>()); + jsonObject_secondcont2.put("list2", new LinkedList<>()); + jsonObject_secondcont2.put("list3", new LinkedList<>()); + jsonArray2.add(jsonObject_secondcont2); + jsonObject2.put("secondcont",jsonArray2); + String dleass = ""; + String[] deptSplit = ids.split(","); + if(deptSplit.length==1){ + dleass = "'"+deptSplit[0]+"'"; + } + dleass ="'"+ StringUtils.join(deptSplit, "','")+"'"; + System.out.println( + "dleass》》》》》》》》》》"+dleass + ); + +/** + * 关联流程清单 + */ + JSONObject jsonObject4 = new JSONObject(new LinkedHashMap<>()); + jsonObject4.put("leftname", "关联流程清单"); + JSONArray jsonArray4_secondcont = new JSONArray(new LinkedList<>()); + JSONObject jsonObject4_secondcont = new JSONObject(new LinkedHashMap<>()); + jsonObject4_secondcont.put("name",new LinkedList<>()); + jsonObject4_secondcont.put("list1",new LinkedList<>()); + jsonObject4_secondcont.put("list2",new LinkedList<>()); + jsonObject4_secondcont.put("list3",new LinkedList<>()); + jsonArray4_secondcont.add(jsonObject4_secondcont); + jsonObject4.put("secondcont",jsonArray4_secondcont); + /** + * L3流程数据汇总 + */ + + + + + JSONObject jsonObject3 = new JSONObject(new LinkedHashMap<>()); + + jsonObject3.put("leftname", "L3流程绩效指标"); + JSONArray jsonArray3 = new JSONArray(); + + List list_num = new LinkedList(); + int q=0; + String[] plid = dleass.split(","); + for (String ikds:plid + ) { + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = "+ikds+" AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List mapss = DBSql.getMaps(sqls3); + for (RowMap rowmaps : mapss) { + String name2 = rowmaps.getString("PLNAME").substring(rowmaps.getString("PLNAME").indexOf(" ") + 1); + String name2s = rowmaps.getString("PLNAME").substring(0,rowmaps.getString("PLNAME").indexOf(" ")); + String string = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where NDICATOR_USER_DEFINED_LABEL = '"+departname+"' AND PERFORMANCE_TYPE = 'L1L3流程绩效' and SYNCHRONOUS_HOME like '" + name2s + "%'"); + list_num.add(q, Integer.valueOf(string)); + q++; + } + } + + Integer max = Collections.max(list_num); + if (max==0){ + max=3; + } + + Map> map_list = new HashMap>(); + for(int h = 0;h()); + } + JSONObject jsonObject_secondcont3 = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_name3 = new JSONArray(new LinkedList<>()); + + for (String ikds:plid + ) { + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = "+ikds+" AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List mapss = DBSql.getMaps(sqls3); + + for (RowMap rowmaps : mapss + ) { + + + JSONObject jsonObject_name3 = new JSONObject(new LinkedHashMap<>()); + jsonObject_name3.put("title", rowmaps.getString("PLNAME")); + jsonObject_name3.put("id", rowmaps.getString("ID")); + jsonObject_name3.put("incident", true); + String name2 = rowmaps.getString("PLNAME").substring(rowmaps.getString("PLNAME").indexOf(" ")+1); + String name22s = rowmaps.getString("PLNAME").substring(0,rowmaps.getString("PLNAME").indexOf(" "));; + List lists = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("NDICATOR_USER_DEFINED_LABEL = ",departname).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效").addQuery("SYNCHRONOUS_HOME like '"+name22s+"%'", null).list(); + List list_childs = new LinkedList(); + jsonObject_name3.put("child", list_childs); + jsonArray_name3.add(jsonObject_name3); + + } + } + jsonObject_secondcont3.put("name", jsonArray_name3); + + int r=0; + + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID in (" + dleass + ") AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List mapss = DBSql.getMaps(sqls3); + for (RowMap rowmaps : mapss) { + String name2 = rowmaps.getString("PLNAME").substring(rowmaps.getString("PLNAME").indexOf(" ") + 1); + String names2 = rowmaps.getString("PLNAME").substring(0,rowmaps.getString("PLNAME").indexOf(" ")); + ; + List lists = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("NDICATOR_USER_DEFINED_LABEL = ",departname).addQuery("PERFORMANCE_TYPE=", "L1L3流程绩效").addQuery("SYNCHRONOUS_HOME like '" + names2 + "%'", null).list(); + + for (int w = 0; w < lists.size(); w++) { + map_list.get(String.valueOf(w)).add(r, lists.get(w).getString("PERFORMANCE_INDICATOR_NAME")); + } + if (lists.size() < map_list.size()) { + for (int u = lists.size(); u < map_list.size(); u++) { + map_list.get(String.valueOf(u)).add(r, ""); + } + + } + r++; + + } + for (int t=0;t(); + lisr.add(1); + lisr.add(2); + lisr.add(4); + result.put("yunxing",lisr); + + return result; + } + } + + @Mapping("com.awspaas.user.apps.integration.controller.GetmeritsController.tabledrag") + public JSONObject tabledrag(String sid,String id,String departname){ + JSONObject result = new JSONObject(new LinkedHashMap<>()); + if (departname.equals("全部")){ + List list = new LinkedList(); + list.add("流程绩效指标"); + list.add("衡量单位"); + list.add("跟踪频率"); + list.add("计算公式"); + list.add("数据来源"); + result.put("headtop",list); + JSONArray jsonArray = new JSONArray(new LinkedList<>()); + JSONObject jsonObject_contant = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_secondcont = new JSONArray(new LinkedList<>()); + JSONArray jsonArray_num1 = new JSONArray(new LinkedList<>()); + JSONArray jsonArray_num2 = new JSONArray(new LinkedList<>()); + JSONArray jsonArray_num3 = new JSONArray(new LinkedList<>()); + JSONArray jsonArray_num4 = new JSONArray(new LinkedList<>()); + RowMap rowMap = DBSql.getMap("select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND id = '" + id + "'"); + + + if (rowMap.getString("PLPARENTID").equals("process")){ + String Planme = rowMap.getString("PLNAME").substring(rowMap.getString("PLNAME").indexOf(" ") + 1); + String Plname_num = rowMap.getString("PLNAME").substring(0,rowMap.getString("PLNAME").indexOf(" ") ); + List bo_eu_per_ind_lib = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("SYNCHRONOUS_HOME like '"+Plname_num+"%'",null).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效") .list(); + + for (BO bo: + bo_eu_per_ind_lib) { + String data = bo.getString("SYNCHRONOUS_HOME"); + String deoa= ""; + if (data.contains(",")){ + String[] ds = data.split(","); + if(ds.length==1){ + deoa= "'"+ds[0]+"'"; + } + deoa ="'"+ StringUtils.join(ds, "','")+"'"; + System.out.println( + "deoa》》》》》》》》》》"+deoa + ); + }else { + deoa = "'"+data+"'"; + } + if (deoa.indexOf("'"+Plname_num+"'")>=0){ + + JSONObject jsonObject_name = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num1 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num2 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num3 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num4 = new JSONObject(new LinkedHashMap<>()); + if (StringUtils.isNotEmpty(bo.getString("PERFORMANCE_INDICATOR_NAME"))){ + jsonObject_name.put("name",bo.getString("PERFORMANCE_INDICATOR_NAME")); + }else { + jsonObject_name.put("name","/"); + } + + if (StringUtils.isNotEmpty(bo.getString("UNIT_MEASUREMENT"))){ + jsonObject_num1.put("name",bo.getString("UNIT_MEASUREMENT")); + }else { + jsonObject_num1.put("name","/"); + } + + if (StringUtils.isNotEmpty(bo.getString("STATISTICAL_PERIOD"))){ + jsonObject_num2.put("name",bo.getString("STATISTICAL_PERIOD")); + }else { + jsonObject_num2.put("name","/"); + } + + if (StringUtils.isNotEmpty(bo.getString("COMPUTATIONAL_FORMULA"))){ + jsonObject_num3.put("name",bo.getString("COMPUTATIONAL_FORMULA")); + }else { + jsonObject_num3.put("name","/"); + } + if (StringUtils.isNotEmpty(bo.getString("DATA_SOURCES"))){ + jsonObject_num4.put("name",bo.getString("DATA_SOURCES")); + }else { + jsonObject_num4.put("name","/"); + } + jsonArray_secondcont.add(jsonObject_name); + jsonArray_num1.add(jsonObject_num1); + jsonArray_num2.add(jsonObject_num2); + jsonArray_num3.add(jsonObject_num3); + jsonArray_num4.add(jsonObject_num4); + } + } + jsonObject_contant.put("secondcont",jsonArray_secondcont); + jsonObject_contant.put("num1",jsonArray_num1); + jsonObject_contant.put("num2",jsonArray_num2); + jsonObject_contant.put("num3",jsonArray_num3); + jsonObject_contant.put("num4",jsonArray_num4); + jsonArray.add(jsonObject_contant); + + result.put("content",jsonArray); + }else { + RowMap rowMap1 = DBSql.getMap("select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND id = '" + rowMap.getString("ID") + "'"); + if (rowMap1.getString("PLPARENTID").equals("process")){ + String Planme = rowMap1.getString("PLNAME").substring(rowMap1.getString("PLNAME").indexOf(" ") + 1); + String Planme_num = rowMap1.getString("PLNAME").substring(0,rowMap1.getString("PLNAME").indexOf(" ")); + List bo_eu_per_ind_lib = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("SYNCHRONOUS_HOME like '" + Planme_num + "%'", null).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效").list(); + for (BO bo: + bo_eu_per_ind_lib) { + + String data = bo.getString("SYNCHRONOUS_HOME"); + String deoa = ""; + if (data.contains(",")) { + String[] ds = data.split(","); + if (ds.length == 1) { + deoa = "'" + ds[0] + "'"; + } + deoa = "'" + StringUtils.join(ds, "','") + "'"; + System.out.println( + "deoa》》》》》》》》》》" + deoa + ); + }else { + deoa = "'"+data+"'"; + } + if (deoa.indexOf("'" + Planme_num + "'") >= 0) { + JSONObject jsonObject_name = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num1 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num2 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num3 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num4 = new JSONObject(new LinkedHashMap<>()); + if (StringUtils.isNotEmpty(bo.getString("PERFORMANCE_INDICATOR_NAME"))) { + jsonObject_name.put("name", bo.getString("PERFORMANCE_INDICATOR_NAME")); + } else { + jsonObject_name.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("UNIT_MEASUREMENT"))) { + jsonObject_num1.put("name", bo.getString("UNIT_MEASUREMENT")); + } else { + jsonObject_num1.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("STATISTICAL_PERIOD"))) { + jsonObject_num2.put("name", bo.getString("STATISTICAL_PERIOD")); + } else { + jsonObject_num2.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("COMPUTATIONAL_FORMULA"))) { + jsonObject_num3.put("name", bo.getString("COMPUTATIONAL_FORMULA")); + } else { + jsonObject_num3.put("name", "/"); + } + if (StringUtils.isNotEmpty(bo.getString("DATA_SOURCES"))) { + jsonObject_num4.put("name", bo.getString("DATA_SOURCES")); + } else { + jsonObject_num4.put("name", "/"); + } + jsonArray_secondcont.add(jsonObject_name); + jsonArray_num1.add(jsonObject_num1); + jsonArray_num2.add(jsonObject_num2); + jsonArray_num3.add(jsonObject_num3); + jsonArray_num4.add(jsonObject_num4); + } + } + jsonObject_contant.put("secondcont", jsonArray_secondcont); + jsonObject_contant.put("num1", jsonArray_num1); + jsonObject_contant.put("num2", jsonArray_num2); + jsonObject_contant.put("num3", jsonArray_num3); + jsonObject_contant.put("num4", jsonArray_num4); + jsonArray.add(jsonObject_contant); + + result.put("content",jsonArray); + }else{ + String Planme = rowMap.getString("PLNAME").substring(rowMap.getString("PLNAME").indexOf(" ") + 1); + String Planme_num = rowMap.getString("PLNAME").substring(0,rowMap.getString("PLNAME").indexOf(" ")); + List bo_eu_per_ind_lib = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("SYNCHRONOUS_HOME like '" + Planme_num + "%'", null).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效").list(); + for (BO bo: + bo_eu_per_ind_lib) { + + String data = bo.getString("SYNCHRONOUS_HOME"); + String deoa = ""; + if (data.contains(",")) { + String[] ds = data.split(","); + if (ds.length == 1) { + deoa = "'" + ds[0] + "'"; + } + deoa = "'" + StringUtils.join(ds, "','") + "'"; + System.out.println( + "deoa》》》》》》》》》》" + deoa + ); + }else { + deoa = "'"+data+"'"; + } + if (deoa.indexOf("'" + Planme_num + "'") >= 0) { + JSONObject jsonObject_name = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num1 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num2 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num3 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num4 = new JSONObject(new LinkedHashMap<>()); + if (StringUtils.isNotEmpty(bo.getString("PERFORMANCE_INDICATOR_NAME"))) { + jsonObject_name.put("name", bo.getString("PERFORMANCE_INDICATOR_NAME")); + } else { + jsonObject_name.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("UNIT_MEASUREMENT"))) { + jsonObject_num1.put("name", bo.getString("UNIT_MEASUREMENT")); + } else { + jsonObject_num1.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("STATISTICAL_PERIOD"))) { + jsonObject_num2.put("name", bo.getString("STATISTICAL_PERIOD")); + } else { + jsonObject_num2.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("COMPUTATIONAL_FORMULA"))) { + jsonObject_num3.put("name", bo.getString("COMPUTATIONAL_FORMULA")); + } else { + jsonObject_num3.put("name", "/"); + } + if (StringUtils.isNotEmpty(bo.getString("DATA_SOURCES"))) { + jsonObject_num4.put("name", bo.getString("DATA_SOURCES")); + } else { + jsonObject_num4.put("name", "/"); + } + + jsonArray_secondcont.add(jsonObject_name); + jsonArray_num1.add(jsonObject_num1); + jsonArray_num2.add(jsonObject_num2); + jsonArray_num3.add(jsonObject_num3); + jsonArray_num4.add(jsonObject_num4); + } + } + jsonObject_contant.put("secondcont", jsonArray_secondcont); + jsonObject_contant.put("num1", jsonArray_num1); + jsonObject_contant.put("num2", jsonArray_num2); + jsonObject_contant.put("num3", jsonArray_num3); + jsonObject_contant.put("num4", jsonArray_num4); + jsonArray.add(jsonObject_contant); + + result.put("content",jsonArray); + } + } + result.put("content",jsonArray); + System.out.println("jsonArray》》》》》》》》》》》"+jsonArray); + return result; + }else { + + List list = new LinkedList(); + list.add("流程绩效指标"); + list.add("衡量单位"); + list.add("跟踪频率"); + list.add("计算公式"); + list.add("数据来源"); + result.put("headtop",list); + JSONArray jsonArray = new JSONArray(new LinkedList<>()); + JSONObject jsonObject_contant = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_secondcont = new JSONArray(new LinkedList<>()); + JSONArray jsonArray_num1 = new JSONArray(new LinkedList<>()); + JSONArray jsonArray_num2 = new JSONArray(new LinkedList<>()); + JSONArray jsonArray_num3 = new JSONArray(new LinkedList<>()); + JSONArray jsonArray_num4 = new JSONArray(new LinkedList<>()); + RowMap rowMap = DBSql.getMap("select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND id = '" + id + "'"); + + + if (rowMap.getString("PLPARENTID").equals("process")){ + String Planme = rowMap.getString("PLNAME").substring(rowMap.getString("PLNAME").indexOf(" ") + 1); + String Plname_num = rowMap.getString("PLNAME").substring(0,rowMap.getString("PLNAME").indexOf(" ") ); + List bo_eu_per_ind_lib = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("SYNCHRONOUS_HOME like '"+Plname_num+"%'",null).addQuery("NDICATOR_USER_DEFINED_LABEL=",departname).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效") .list(); + + for (BO bo: + bo_eu_per_ind_lib) { + + String data = bo.getString("SYNCHRONOUS_HOME"); + String deoa = ""; + if (data.contains(",")) { + String[] ds = data.split(","); + if (ds.length == 1) { + deoa = "'" + ds[0] + "'"; + } + deoa = "'" + StringUtils.join(ds, "','") + "'"; + System.out.println( + "deoa》》》》》》》》》》" + deoa + ); + }else { + deoa = "'"+data+"'"; + } + if (deoa.indexOf("'"+Plname_num+"'") >= 0) { + JSONObject jsonObject_name = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num1 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num2 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num3 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num4 = new JSONObject(new LinkedHashMap<>()); + if (StringUtils.isNotEmpty(bo.getString("PERFORMANCE_INDICATOR_NAME"))) { + jsonObject_name.put("name", bo.getString("PERFORMANCE_INDICATOR_NAME")); + } else { + jsonObject_name.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("UNIT_MEASUREMENT"))) { + jsonObject_num1.put("name", bo.getString("UNIT_MEASUREMENT")); + } else { + jsonObject_num1.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("STATISTICAL_PERIOD"))) { + jsonObject_num2.put("name", bo.getString("STATISTICAL_PERIOD")); + } else { + jsonObject_num2.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("COMPUTATIONAL_FORMULA"))) { + jsonObject_num3.put("name", bo.getString("COMPUTATIONAL_FORMULA")); + } else { + jsonObject_num3.put("name", "/"); + } + if (StringUtils.isNotEmpty(bo.getString("DATA_SOURCES"))) { + jsonObject_num4.put("name", bo.getString("DATA_SOURCES")); + } else { + jsonObject_num4.put("name", "/"); + } + jsonArray_secondcont.add(jsonObject_name); + jsonArray_num1.add(jsonObject_num1); + jsonArray_num2.add(jsonObject_num2); + jsonArray_num3.add(jsonObject_num3); + jsonArray_num4.add(jsonObject_num4); + } + } + jsonObject_contant.put("secondcont", jsonArray_secondcont); + jsonObject_contant.put("num1", jsonArray_num1); + jsonObject_contant.put("num2", jsonArray_num2); + jsonObject_contant.put("num3", jsonArray_num3); + jsonObject_contant.put("num4", jsonArray_num4); + jsonArray.add(jsonObject_contant); + + result.put("content",jsonArray); + }else { + RowMap rowMap1 = DBSql.getMap("select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND id = '" + rowMap.getString("ID") + "'"); + if (rowMap1.getString("PLPARENTID").equals("process")){ + String Planme = rowMap1.getString("PLNAME").substring(rowMap1.getString("PLNAME").indexOf(" ") + 1); + String Planme_num = rowMap1.getString("PLNAME").substring(0,rowMap1.getString("PLNAME").indexOf(" ")); + List bo_eu_per_ind_lib = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("NDICATOR_USER_DEFINED_LABEL=",departname).addQuery("SYNCHRONOUS_HOME like '%" + Planme_num + "%'", null).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效").list(); + for (BO bo: + bo_eu_per_ind_lib) { + + String data = bo.getString("SYNCHRONOUS_HOME"); + String deoa = ""; + if (data.contains(",")) { + String[] ds = data.split(","); + if (ds.length == 1) { + deoa = "'" + ds[0] + "'"; + } + deoa = "'" + StringUtils.join(ds, "','") + "'"; + System.out.println( + "deoa》》》》》》》》》》" + deoa + ); + }else { + deoa = "'"+data+"'"; + } + if (deoa.indexOf("'" + Planme_num + "'") >= 0) { + + JSONObject jsonObject_name = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num1 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num2 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num3 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num4 = new JSONObject(new LinkedHashMap<>()); + if (StringUtils.isNotEmpty(bo.getString("PERFORMANCE_INDICATOR_NAME"))) { + jsonObject_name.put("name", bo.getString("PERFORMANCE_INDICATOR_NAME")); + } else { + jsonObject_name.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("UNIT_MEASUREMENT"))) { + jsonObject_num1.put("name", bo.getString("UNIT_MEASUREMENT")); + } else { + jsonObject_num1.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("STATISTICAL_PERIOD"))) { + jsonObject_num2.put("name", bo.getString("STATISTICAL_PERIOD")); + } else { + jsonObject_num2.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("COMPUTATIONAL_FORMULA"))) { + jsonObject_num3.put("name", bo.getString("COMPUTATIONAL_FORMULA")); + } else { + jsonObject_num3.put("name", "/"); + } + if (StringUtils.isNotEmpty(bo.getString("DATA_SOURCES"))) { + jsonObject_num4.put("name", bo.getString("DATA_SOURCES")); + } else { + jsonObject_num4.put("name", "/"); + } + jsonArray_secondcont.add(jsonObject_name); + jsonArray_num1.add(jsonObject_num1); + jsonArray_num2.add(jsonObject_num2); + jsonArray_num3.add(jsonObject_num3); + jsonArray_num4.add(jsonObject_num4); + } + } + jsonObject_contant.put("secondcont", jsonArray_secondcont); + jsonObject_contant.put("num1", jsonArray_num1); + jsonObject_contant.put("num2", jsonArray_num2); + jsonObject_contant.put("num3", jsonArray_num3); + jsonObject_contant.put("num4", jsonArray_num4); + jsonArray.add(jsonObject_contant); + + result.put("content",jsonArray); + }else{ + String Planme = rowMap.getString("PLNAME").substring(rowMap.getString("PLNAME").indexOf(" ") + 1); + String Planme_num = rowMap.getString("PLNAME").substring(0,rowMap.getString("PLNAME").indexOf(" ")); + List bo_eu_per_ind_lib = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("NDICATOR_USER_DEFINED_LABEL=",departname).addQuery("SYNCHRONOUS_HOME like '%" + Planme_num + "%'", null).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效").list(); + for (BO bo: + bo_eu_per_ind_lib) { + + String data = bo.getString("SYNCHRONOUS_HOME"); + String deoa = ""; + if (data.contains(",")) { + String[] ds = data.split(","); + if (ds.length == 1) { + deoa = "'" + ds[0] + "'"; + } + deoa = "'" + StringUtils.join(ds, "','") + "'"; + System.out.println( + "deoa》》》》》》》》》》" + deoa + ); + }else { + deoa = "'"+data+"'"; + } + if (deoa.indexOf("'" + Planme_num + "'") >= 0) { + JSONObject jsonObject_name = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num1 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num2 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num3 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_num4 = new JSONObject(new LinkedHashMap<>()); + if (StringUtils.isNotEmpty(bo.getString("PERFORMANCE_INDICATOR_NAME"))) { + jsonObject_name.put("name", bo.getString("PERFORMANCE_INDICATOR_NAME")); + } else { + jsonObject_name.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("UNIT_MEASUREMENT"))) { + jsonObject_num1.put("name", bo.getString("UNIT_MEASUREMENT")); + } else { + jsonObject_num1.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("STATISTICAL_PERIOD"))) { + jsonObject_num2.put("name", bo.getString("STATISTICAL_PERIOD")); + } else { + jsonObject_num2.put("name", "/"); + } + + if (StringUtils.isNotEmpty(bo.getString("COMPUTATIONAL_FORMULA"))) { + jsonObject_num3.put("name", bo.getString("COMPUTATIONAL_FORMULA")); + } else { + jsonObject_num3.put("name", "/"); + } + if (StringUtils.isNotEmpty(bo.getString("DATA_SOURCES"))) { + jsonObject_num4.put("name", bo.getString("DATA_SOURCES")); + } else { + jsonObject_num4.put("name", "/"); + } + + jsonArray_secondcont.add(jsonObject_name); + jsonArray_num1.add(jsonObject_num1); + jsonArray_num2.add(jsonObject_num2); + jsonArray_num3.add(jsonObject_num3); + jsonArray_num4.add(jsonObject_num4); + } + } + jsonObject_contant.put("secondcont", jsonArray_secondcont); + jsonObject_contant.put("num1", jsonArray_num1); + jsonObject_contant.put("num2", jsonArray_num2); + jsonObject_contant.put("num3", jsonArray_num3); + jsonObject_contant.put("num4", jsonArray_num4); + jsonArray.add(jsonObject_contant); + + result.put("content",jsonArray); + } + } + result.put("content",jsonArray); + System.out.println("jsonArray》》》》》》》》》》》"+jsonArray); + return result; + } + } + + @Mapping("com.awspaas.user.apps.integration.controller.GetmeritsController.getnewTable") + public JSONArray getnewTable(String sid, String plname, String departname){ + JSONArray result = new JSONArray(new LinkedList<>()); + if (departname.equals("全部")){ + + /** + * 这个是L1流程绩效指标数据汇总 + */ + String id = DBSql.getString("select ID from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLNAME = '" + plname + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"); + String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND ID = '" + id + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + RowMap map = DBSql.getMap(sql); + JSONObject jsonObject_L1 = new JSONObject(new LinkedHashMap<>()); + jsonObject_L1.put("levels_name","L1流程绩效指标"); + JSONArray jsonArray_levels_1 = new JSONArray(new LinkedList<>()); + JSONObject jsonObject_levels_1 = new JSONObject(new LinkedHashMap<>()); + jsonObject_levels_1.put("name",map.getString("PLNAME")); + jsonObject_levels_1.put("id",map.getString("ID")); + JSONArray jsonArray_child_1 = new JSONArray(new LinkedList<>()); + String names = map.getString("PLNAME").substring(0,map.getString("PLNAME").indexOf(" ")); + List list = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("SYNCHRONOUS_HOME like '"+names+"%' ",null).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效").list(); + for (BO bo:list + ) { + JSONObject jsonObject_child_1 = new JSONObject(new LinkedHashMap<>()); + jsonObject_child_1.put("content",bo.getString("PERFORMANCE_INDICATOR_NAME")); + jsonObject_child_1.put("num","1"); + jsonArray_child_1.add(jsonObject_child_1); + } + + jsonObject_levels_1.put("child",jsonArray_child_1); + jsonArray_levels_1.add(jsonObject_levels_1); + jsonObject_L1.put("levels_1",jsonArray_levels_1); + + /** + * 这是L2流程绩效指标汇总 + */ + + String sqls = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = '" + id + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List maps = DBSql.getMaps(sqls); + + String ids = ""; + JSONObject jsonObject_L2 = new JSONObject(new LinkedHashMap<>()); + jsonObject_L2.put("levels_name","L2流程绩效指标"); + JSONArray jsonArray_levels_2 = new JSONArray(new LinkedList<>()); + + JSONArray jsonArray_child_2 = new JSONArray(new LinkedList<>()); + List list_num_2 = new LinkedList(); + List> list_pq_2 = new LinkedList(); + int t=0; + for (RowMap rowMap: + maps) { + ids+=rowMap.getString("ID")+","; + JSONObject jsonObject_child_2 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_child_2_content = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_child_2_content = new JSONArray(new LinkedList<>()); + jsonObject_child_2.put("name",rowMap.getString("PLNAME")); + jsonObject_child_2.put("id",rowMap.getString("ID")); + jsonArray_child_2_content.add(jsonObject_child_2); + jsonObject_child_2_content.put("content",jsonArray_child_2_content); + jsonArray_child_2.add(jsonObject_child_2_content); + + String names2 = rowMap.getString("PLNAME").substring(0,rowMap.getString("PLNAME").indexOf(" ")); + String string = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where PERFORMANCE_TYPE = 'L1L3流程绩效' and SYNCHRONOUS_HOME like '%" + names2 + "%'"); + int counts = Integer.valueOf(string); + List maps1 = DBSql.getMaps("select * from BO_EU_PER_IND_LIB where PERFORMANCE_TYPE = 'L1L3流程绩效' and SYNCHRONOUS_HOME like '%" + names2 + "%'"); + for (RowMap rw: + maps1) { + String synchronous_home = rw.getString("SYNCHRONOUS_HOME"); + String deoa = ""; + if (synchronous_home.contains(",")){ + String[] ds = synchronous_home.split(","); + if(ds.length==1){ + deoa= "'"+ds[0]+"'"; + } + deoa ="'"+ StringUtils.join(ds, "','")+"'"; + System.out.println( + "deoa》》》》》》》》》》"+deoa + ); + }else { + deoa = "'" +synchronous_home+"'"; + } + String names_num = "'"+names2+"'"; + if (deoa.indexOf(names_num) == -1){ + counts-=1; + } + } + + list_num_2.add(t, counts); + t++; + + } + Integer maxs = Collections.max(list_num_2); + if (maxs==0){ + maxs=1; + } + + String dleass = ""; + String[] deptSplit = ids.split(","); + if(deptSplit.length==1){ + dleass = "'"+deptSplit[0]+"'"; + } + dleass ="'"+ StringUtils.join(deptSplit, "','")+"'"; + System.out.println( + "dleass》》》》》》》》》》"+dleass + ); + + String[] plid = dleass.split(","); + + int y=0; + for (String ikds:plid + ) { + String sqls3_1 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = '" + id + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + List mapsss = DBSql.getMaps(sqls3_1); + for (RowMap rowmaps : mapsss) { + String name2s = rowmaps.getString("PLNAME").substring(0, rowmaps.getString("PLNAME").indexOf(" ")); + List bo_list = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("PERFORMANCE_TYPE=", "L1L3流程绩效").addQuery("SYNCHRONOUS_HOME like '%" + name2s + "%'", null).list(); + Map map_name = new LinkedHashMap<>(); + int p = 0; + List bo_lists = new LinkedList<>(); + for (BO bo : + bo_list) { + String data = bo.getString("SYNCHRONOUS_HOME"); + String deoa = ""; + if (data.contains(",")) { + String[] ds = data.split(","); + if (ds.length == 1) { + deoa = "'" + ds[0] + "'"; + } + deoa = "'" + StringUtils.join(ds, "','") + "'"; + System.out.println( + "deoa》》》》》》》》》》" + deoa + ); + } else { + deoa = "'" + data + "'"; + } + if (deoa.indexOf("'" + name2s + "'") >= 0) { + String indicatorName = bo.getString("PERFORMANCE_INDICATOR_NAME"); + map_name.put(Integer.valueOf(p), indicatorName); + bo_lists.add(bo); + p++; + } + } + if (Integer.valueOf(bo_lists.size()) < maxs) { + for (int i = bo_lists.size(); i < maxs; i++) { + map_name.put(Integer.valueOf(p), ""); + p++; + } + + } + System.out.println("mmap>>>>>>>>>>>>>>>>>>>"+map_name); + list_pq_2.add(y, map_name); + y++; + } + } + JSONObject jsonObject_child_2_father = new JSONObject(new LinkedHashMap<>()); + + jsonObject_child_2_father.put("child",jsonArray_child_2); + // jsonObject_child_2_1_father.put("child",jsonArray_child_2_1); + jsonArray_levels_2.add(jsonObject_child_2_father); + System.out.println("maxs.>>>>>>>>>>>+"+maxs); + for (int i=0;i()); + + JSONArray jsonArray_child_3_last = new JSONArray(new LinkedList<>()); + int h = 0; + for (String ikds:plid + ) { + JSONObject jsonObject_child_content_3_last = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_child_content_3_last = new JSONArray(new LinkedList<>()); + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND ID = '" + id + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List mapss = DBSql.getMaps(sqls3); + for (RowMap rowmaps : mapss) { + /** + * 这是L3流程绩效名称中的流程架构 + */ + JSONObject jsonObject_child_content_3_name_last = new JSONObject(new LinkedHashMap<>()); + System.out.println("h>>>>>>>>>>>>>>>" + h); + jsonObject_child_content_3_name_last.put("name", list_pq_2.get(h).get(i)); + if(StringUtils.isNotEmpty(list_pq_2.get(h).get(i))){ + + jsonObject_child_content_3_name_last.put("num", "1"); + }else { + jsonObject_child_content_3_name_last.put("num", "0"); + } + jsonArray_child_content_3_last.add(jsonObject_child_content_3_name_last); + h++; + } + + + jsonObject_child_content_3_last.put("content",jsonArray_child_content_3_last); + System.out.println("jsonObject_child_content_3_last>>>>>>>>>>>>>>"+jsonObject_child_content_3_last); + jsonArray_child_3_last.add(jsonObject_child_content_3_last); + jsonObject_child_3_last.put("child",jsonArray_child_3_last); + + } + + if (StringUtils.isNotEmpty(jsonObject_child_3_last.get("child").toString())){ + int child = countStr(jsonObject_child_3_last.get("child").toString(), "{\"name\":\"\","); + if (plid.length==child){ + continue; + } + } + jsonArray_levels_2.add(jsonObject_child_3_last); + } + + //jsonArray_levels_2.add(jsonObject_child_2_1_father); + jsonObject_L2.put("levels_2",jsonArray_levels_2); + + /** + * 这是L3流程绩效指标 + */ + + JSONObject jsonObject_L3 = new JSONObject(new LinkedHashMap<>()); + jsonObject_L3.put("levels_name","L3流程绩效指标"); + JSONArray jsonArray_levels_3 = new JSONArray(new LinkedList<>()); + JSONObject jsonObject_child_3 = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_child_3 = new JSONArray(new LinkedList<>()); + + + + List list_num = new LinkedList(); + List> list_pq = new LinkedList(); + int q=0; + JSONArray jsonArray_L3_name = new JSONArray(new LinkedList<>()); + for (String ikds:plid + ) { + JSONObject jsonObject_L3_name = new JSONObject(new LinkedHashMap<>()); + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = "+ikds+" AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List mapss = DBSql.getMaps(sqls3); + JSONArray jsonArray_content_1 = new JSONArray(new LinkedList<>()); + for (RowMap rowmaps : mapss) { + JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); + String name2s = rowmaps.getString("PLNAME").substring(0,rowmaps.getString("PLNAME").indexOf(" ")); + String name_PLNAme = rowmaps.getString("PLNAME"); + jsonObject.put("name",name_PLNAme); + jsonObject.put("id",rowmaps.getString("ID")); + jsonArray_content_1.add(jsonObject); + String string = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where PERFORMANCE_TYPE = 'L1L3流程绩效' and SYNCHRONOUS_HOME like '" + name2s + "%'"); + list_num.add(q, Integer.valueOf(string)); + q++; + } + if (mapss.size()==0){ + JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); + jsonObject.put("name",""); + jsonObject.put("id",""); + jsonArray_content_1.add(jsonObject); + } + jsonObject_L3_name.put("content",jsonArray_content_1); + jsonArray_L3_name.add(jsonObject_L3_name); + } + jsonObject_child_3.put("child",jsonArray_L3_name); + jsonArray_levels_3.add(jsonObject_child_3); + Integer max = Collections.max(list_num); + if (max==0){ + max=3; + } + int r=0; + for (String ikds:plid + ) { + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = "+ikds+" AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + List mapss = DBSql.getMaps(sqls3); + for (RowMap rowmaps : mapss) { + String name2s = rowmaps.getString("PLNAME").substring(0,rowmaps.getString("PLNAME").indexOf(" ")); + List bo_list = SDK.getBOAPI().query("BO_EU_PER_IND_LIB",true).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效").addQuery("SYNCHRONOUS_HOME like '%"+name2s+"%'",null).list(); + Map map_name = new LinkedHashMap<>(); + int p = 0; + for (BO bo: + bo_list) { + String indicatorName = bo.getString("PERFORMANCE_INDICATOR_NAME"); + map_name.put(Integer.valueOf(p),indicatorName); + p++; + } + /* if (bo_list.size()==0){ + map_name.put(Integer.valueOf(p),""); + p++; + }*/ + if (Integer.valueOf(bo_list.size()) map_name = new LinkedHashMap<>(); + int p = 0; + if (Integer.valueOf(mapss.size()) map_list = new HashMap(); + for(int h = 0;h())); + } + String l3_ids = ""; + JSONObject jsonObject_child_content_3 = new JSONObject(new LinkedHashMap<>()); + List linkedList = new LinkedList(); + int u= 0; + for (String ikds:plid + ) { + + JSONArray jsonArray_child_content_3 = new JSONArray(new LinkedList<>()); + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = "+ikds+" AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List mapss = DBSql.getMaps(sqls3); + linkedList.add(mapss.size()); + u++; + for (RowMap rowmaps : mapss + ) { + /** + * 这是L3流程绩效名称中的流程架构 + */ + l3_ids+=rowmaps.getString("PLNAME").substring(0,rowmaps.getString("PLNAME").indexOf(" "))+","; + JSONObject jsonObject_child_content_3_name = new JSONObject(new LinkedHashMap<>()); + jsonObject_child_content_3_name.put("name",rowmaps.getString("PLNAME")); + jsonObject_child_content_3_name.put("id",rowmaps.getString("ID")); + jsonArray_child_content_3.add(jsonObject_child_content_3_name); + } + if (mapss.size()==0){ + JSONObject jsonObject_child_content_3_name = new JSONObject(new LinkedHashMap<>()); + jsonObject_child_content_3_name.put("name",""); + jsonObject_child_content_3_name.put("id",""); + jsonArray_child_content_3.add(jsonObject_child_content_3_name); + } + + + jsonObject_child_content_3.put("content",jsonArray_child_content_3); + jsonArray_child_3.add(jsonObject_child_content_3); + } + String dpliea = ""; + + String[] deptSplits = l3_ids.split(","); + if(deptSplits.length==1){ + dpliea = "'"+deptSplits[0]+"'"; + } + dpliea ="'"+ StringUtils.join(deptSplits, "','")+"'"; + System.out.println( + "dpliea》》》》》》》》》》"+dpliea + ); + + String[] plids = dpliea.split(","); + + + + + + + for (int i=0;i()); + + JSONArray jsonArray_child_3_last = new JSONArray(new LinkedList<>()); + int h = 0; + for (String ikds:plid + ) { + JSONObject jsonObject_child_content_3_last = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_child_content_3_last = new JSONArray(new LinkedList<>()); + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = "+ikds+" AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List mapss = DBSql.getMaps(sqls3); + for (RowMap rowmaps : mapss) { + /** + * 这是L3流程绩效名称中的流程架构 + */ + JSONObject jsonObject_child_content_3_name_last = new JSONObject(new LinkedHashMap<>()); + System.out.println("h>>>>>>>>>>>>>>>"+h); + jsonObject_child_content_3_name_last.put("name",list_pq.get(h).get(i)); + if (StringUtils.isNotEmpty(list_pq.get(h).get(i))){ + + jsonObject_child_content_3_name_last.put("num","1"); + }else { + jsonObject_child_content_3_name_last.put("num","0"); + } + jsonArray_child_content_3_last.add(jsonObject_child_content_3_name_last); + h++; + } + + if(mapss.size()==0){ + JSONObject jsonObject_child_content_3_name_last = new JSONObject(new LinkedHashMap<>()); + jsonObject_child_content_3_name_last.put("name",list_pq.get(h).get(i)); + System.out.println("h>>>>>>>>>>>>>>>"+h); + if (StringUtils.isNotEmpty(list_pq.get(h).get(i))){ + + jsonObject_child_content_3_name_last.put("num","1"); + }else { + jsonObject_child_content_3_name_last.put("num","0"); + } + jsonArray_child_content_3_last.add(jsonObject_child_content_3_name_last); + h++; + } + jsonObject_child_content_3_last.put("content",jsonArray_child_content_3_last); + System.out.println("jsonObject_child_content_3_last>>>>>>>>>>>>>>"+jsonObject_child_content_3_last); + jsonArray_child_3_last.add(jsonObject_child_content_3_last); + } + jsonObject_child_3_last.put("child",jsonArray_child_3_last); + jsonArray_levels_3.add(jsonObject_child_3_last); + } + jsonObject_L3.put("levels_3",jsonArray_levels_3); + System.out.println("jsonArray>>>>>>>>>>"+jsonArray_levels_3); + JSONObject jsonObject_4 = new JSONObject(new LinkedHashMap<>()); + jsonObject_4.put("levels_name","关键流程清单"); + jsonObject_4.put("levels_4",new JSONArray(new LinkedList<>())); + + result.add(jsonObject_L1); + result.add(jsonObject_L2); + result.add(jsonObject_L3); + result.add(jsonObject_4); + + return result; + }else { + /** + * 这个是L1流程绩效指标数据汇总 + */ + String id = DBSql.getString("select ID from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLNAME = '" + plname + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"); + String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND ID = '" + id + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + RowMap map = DBSql.getMap(sql); + JSONObject jsonObject_L1 = new JSONObject(new LinkedHashMap<>()); + jsonObject_L1.put("levels_name","L1流程绩效指标"); + JSONArray jsonArray_levels_1 = new JSONArray(new LinkedList<>()); + JSONObject jsonObject_levels_1 = new JSONObject(new LinkedHashMap<>()); + jsonObject_levels_1.put("name",map.getString("PLNAME")); + jsonObject_levels_1.put("id",map.getString("ID")); + JSONArray jsonArray_child_1 = new JSONArray(new LinkedList<>()); + String names = map.getString("PLNAME").substring(0,map.getString("PLNAME").indexOf(" ")); + List list = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("NDICATOR_USER_DEFINED_LABEL = ",departname).addQuery("SYNCHRONOUS_HOME like '"+names+"%' ",null).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效").list(); + for (BO bo:list + ) { + JSONObject jsonObject_child_1 = new JSONObject(new LinkedHashMap<>()); + jsonObject_child_1.put("content",bo.getString("PERFORMANCE_INDICATOR_NAME")); + jsonObject_child_1.put("num","1"); + jsonArray_child_1.add(jsonObject_child_1); + } + + jsonObject_levels_1.put("child",jsonArray_child_1); + jsonArray_levels_1.add(jsonObject_levels_1); + jsonObject_L1.put("levels_1",jsonArray_levels_1); + + /** + * 这是L2流程绩效指标汇总 + */ + + String sqls = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = '" + id + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List maps = DBSql.getMaps(sqls); + + String ids = ""; + JSONObject jsonObject_L2 = new JSONObject(new LinkedHashMap<>()); + jsonObject_L2.put("levels_name","L2流程绩效指标"); + JSONArray jsonArray_levels_2 = new JSONArray(new LinkedList<>()); + + JSONArray jsonArray_child_2 = new JSONArray(new LinkedList<>()); + List list_num_2 = new LinkedList(); + List> list_pq_2 = new LinkedList(); + int t=0; + for (RowMap rowMap: + maps) { + ids+=rowMap.getString("ID")+","; + JSONObject jsonObject_child_2 = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_child_2_content = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_child_2_content = new JSONArray(new LinkedList<>()); + jsonObject_child_2.put("name",rowMap.getString("PLNAME")); + jsonObject_child_2.put("id",rowMap.getString("ID")); + jsonArray_child_2_content.add(jsonObject_child_2); + jsonObject_child_2_content.put("content",jsonArray_child_2_content); + jsonArray_child_2.add(jsonObject_child_2_content); + + String names2 = rowMap.getString("PLNAME").substring(0,rowMap.getString("PLNAME").indexOf(" ")); + String string = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where PERFORMANCE_TYPE = 'L1L3流程绩效' and NDICATOR_USER_DEFINED_LABEL ='"+departname+"' and SYNCHRONOUS_HOME like '%" + names2 + "%'"); + int counts = Integer.valueOf(string); + List maps1 = DBSql.getMaps("select * from BO_EU_PER_IND_LIB where PERFORMANCE_TYPE = 'L1L3流程绩效' and NDICATOR_USER_DEFINED_LABEL ='"+departname+"' and SYNCHRONOUS_HOME like '%" + names2 + "%'"); + for (RowMap rw: + maps1) { + String synchronous_home = rw.getString("SYNCHRONOUS_HOME"); + String deoa = ""; + if (synchronous_home.contains(",")){ + String[] ds = synchronous_home.split(","); + if(ds.length==1){ + deoa= "'"+ds[0]+"'"; + } + deoa ="'"+ StringUtils.join(ds, "','")+"'"; + System.out.println( + "deoa》》》》》》》》》》"+deoa + ); + }else { + deoa = "'" +synchronous_home+"'"; + } + String names_num = "'"+names2+"'"; + if (deoa.indexOf(names_num) == -1){ + counts-=1; + } + } + + list_num_2.add(t, counts); + t++; + + } + Integer maxs = Collections.max(list_num_2); + if (maxs==0){ + maxs=1; + } + + String dleass = ""; + String[] deptSplit = ids.split(","); + if(deptSplit.length==1){ + dleass = "'"+deptSplit[0]+"'"; + } + dleass ="'"+ StringUtils.join(deptSplit, "','")+"'"; + System.out.println( + "dleass》》》》》》》》》》"+dleass + ); + + String[] plid = dleass.split(","); + + int y=0; + + String sqls3_1 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = '" + id + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + List mapsss = DBSql.getMaps(sqls3_1); + for (RowMap rowmaps : mapsss) { + String name2s = rowmaps.getString("PLNAME").substring(0, rowmaps.getString("PLNAME").indexOf(" ")); + List bo_list = SDK.getBOAPI().query("BO_EU_PER_IND_LIB", true).addQuery("NDICATOR_USER_DEFINED_LABEL=",departname).addQuery("PERFORMANCE_TYPE=", "L1L3流程绩效").addQuery("SYNCHRONOUS_HOME like '%" + name2s + "%'", null).list(); + Map map_name = new LinkedHashMap<>(); + int p = 0; + List bo_lists = new LinkedList<>(); + for (BO bo : + bo_list) { + String data = bo.getString("SYNCHRONOUS_HOME"); + String deoa = ""; + if (data.contains(",")){ + String[] ds = data.split(","); + if(ds.length==1){ + deoa= "'"+ds[0]+"'"; + } + deoa ="'"+ StringUtils.join(ds, "','")+"'"; + System.out.println( + "deoa》》》》》》》》》》"+deoa + ); + }else { + deoa = "'"+data+"'"; + } + if (deoa.indexOf("'"+name2s+"'")>= 0){ + String indicatorName = bo.getString("PERFORMANCE_INDICATOR_NAME"); + map_name.put(Integer.valueOf(p), indicatorName); + bo_lists.add(bo); + p++; + } + } + if (Integer.valueOf(bo_lists.size()) < maxs) { + for (int i = bo_lists.size(); i < maxs; i++) { + map_name.put(Integer.valueOf(p), ""); + p++; + } + + } + list_pq_2.add(y, map_name); + y++; + } + + JSONObject jsonObject_child_2_father = new JSONObject(new LinkedHashMap<>()); + + jsonObject_child_2_father.put("child",jsonArray_child_2); + // jsonObject_child_2_1_father.put("child",jsonArray_child_2_1); + jsonArray_levels_2.add(jsonObject_child_2_father); + System.out.println("maxs.>>>>>>>>>>>+"+maxs); + for (int i=0;i()); + + JSONArray jsonArray_child_3_last = new JSONArray(new LinkedList<>()); + int h = 0; + for (String ikds:plid + ) { + JSONObject jsonObject_child_content_3_last = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_child_content_3_last = new JSONArray(new LinkedList<>()); + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND ID = '" + id + "' AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List mapss = DBSql.getMaps(sqls3); + for (RowMap rowmaps : mapss) { + /** + * 这是L3流程绩效名称中的流程架构 + */ + JSONObject jsonObject_child_content_3_name_last = new JSONObject(new LinkedHashMap<>()); + System.out.println("h>>>>>>>>>>>>>>>" + h); + jsonObject_child_content_3_name_last.put("name", list_pq_2.get(h).get(i)); + if (StringUtils.isNotEmpty(list_pq_2.get(h).get(i))){ + jsonObject_child_content_3_name_last.put("num", "1"); + }else { + jsonObject_child_content_3_name_last.put("num", "0"); + } + + jsonArray_child_content_3_last.add(jsonObject_child_content_3_name_last); + h++; + } + + + jsonObject_child_content_3_last.put("content",jsonArray_child_content_3_last); + System.out.println("jsonObject_child_content_3_last>>>>>>>>>>>>>>"+jsonObject_child_content_3_last); + jsonArray_child_3_last.add(jsonObject_child_content_3_last); + jsonObject_child_3_last.put("child",jsonArray_child_3_last); + + } + + if (StringUtils.isNotEmpty(jsonObject_child_3_last.get("child").toString())){ + int child = countStr(jsonObject_child_3_last.get("child").toString(), "{\"name\":\"\","); + if (plid.length==child){ + continue; + } + } + jsonArray_levels_2.add(jsonObject_child_3_last); + } + + + //jsonArray_levels_2.add(jsonObject_child_2_1_father); + jsonObject_L2.put("levels_2",jsonArray_levels_2); + + + /** + * 这是L3流程绩效指标 + */ + + JSONObject jsonObject_L3 = new JSONObject(new LinkedHashMap<>()); + jsonObject_L3.put("levels_name","L3流程绩效指标"); + JSONArray jsonArray_levels_3 = new JSONArray(new LinkedList<>()); + JSONObject jsonObject_child_3 = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_child_3 = new JSONArray(new LinkedList<>()); + + List list_num = new LinkedList(); + List> list_pq = new LinkedList(); + int q=0; + JSONArray jsonArray_L3_name = new JSONArray(new LinkedList<>()); + for (String ikds:plid + ) { + JSONObject jsonObject_L3_name = new JSONObject(new LinkedHashMap<>()); + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = "+ikds+" AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List mapss = DBSql.getMaps(sqls3); + JSONArray jsonArray_content_1 = new JSONArray(new LinkedList<>()); + if (mapss.size()==0){ + JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); + jsonObject.put("name",""); + jsonObject.put("id",""); + jsonArray_content_1.add(jsonObject); + } + for (RowMap rowmaps : mapss) { + JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); + String name2s = rowmaps.getString("PLNAME").substring(0,rowmaps.getString("PLNAME").indexOf(" ")); + String name_PLNAme = rowmaps.getString("PLNAME"); + jsonObject.put("name",name_PLNAme); + jsonObject.put("id",rowmaps.getString("ID")); + jsonArray_content_1.add(jsonObject); + String string = DBSql.getString("select count(*) from BO_EU_PER_IND_LIB where NDICATOR_USER_DEFINED_LABEL = '"+departname+"' AND PERFORMANCE_TYPE = 'L1L3流程绩效' and SYNCHRONOUS_HOME like '" + name2s + "%'"); + list_num.add(q, Integer.valueOf(string)); + q++; + } + + jsonObject_L3_name.put("content",jsonArray_content_1); + jsonArray_L3_name.add(jsonObject_L3_name); + } + jsonObject_child_3.put("child",jsonArray_L3_name); + jsonArray_levels_3.add(jsonObject_child_3); + Integer max = Collections.max(list_num); + if (max==0){ + max=3; + } + int r=0; + for (String ikds:plid + ) { + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = "+ikds+" AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + List mapss = DBSql.getMaps(sqls3); + for (RowMap rowmaps : mapss) { + String name2s = rowmaps.getString("PLNAME").substring(0,rowmaps.getString("PLNAME").indexOf(" ")); + List bo_list = SDK.getBOAPI().query("BO_EU_PER_IND_LIB",true).addQuery("NDICATOR_USER_DEFINED_LABEL = ",departname).addQuery("PERFORMANCE_TYPE=","L1L3流程绩效").addQuery("SYNCHRONOUS_HOME like '"+name2s+"%'",null).list(); + Map map_name = new LinkedHashMap<>(); + int p = 0; + for (BO bo: + bo_list) { + String indicatorName = bo.getString("PERFORMANCE_INDICATOR_NAME"); + map_name.put(Integer.valueOf(p),indicatorName); + p++; + } + if (Integer.valueOf(bo_list.size()) map_name = new LinkedHashMap<>(); + int p = 0; + if (Integer.valueOf(mapss.size()) map_list = new HashMap(); + for(int h = 0;h())); + } + String l3_ids = ""; + JSONObject jsonObject_child_content_3 = new JSONObject(new LinkedHashMap<>()); + List linkedList = new LinkedList(); + int u= 0; + for (String ikds:plid + ) { + + JSONArray jsonArray_child_content_3 = new JSONArray(new LinkedList<>()); + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = "+ikds+" AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List mapss = DBSql.getMaps(sqls3); + linkedList.add(mapss.size()); + u++; + for (RowMap rowmaps : mapss + ) { + /** + * 这是L3流程绩效名称中的流程架构 + */ + l3_ids+=rowmaps.getString("PLNAME").substring(0,rowmaps.getString("PLNAME").indexOf(" "))+","; + JSONObject jsonObject_child_content_3_name = new JSONObject(new LinkedHashMap<>()); + jsonObject_child_content_3_name.put("name",rowmaps.getString("PLNAME")); + jsonArray_child_content_3.add(jsonObject_child_content_3_name); + } + + + jsonObject_child_content_3.put("content",jsonArray_child_content_3); + jsonArray_child_3.add(jsonObject_child_content_3); + } + String dpliea = ""; + + String[] deptSplits = l3_ids.split(","); + if(deptSplits.length==1){ + dpliea = "'"+deptSplits[0]+"'"; + } + dpliea ="'"+ StringUtils.join(deptSplits, "','")+"'"; + System.out.println( + "dpliea》》》》》》》》》》"+dpliea + ); + + String[] plids = dpliea.split(","); + + + + + + + for (int i=0;i()); + + JSONArray jsonArray_child_3_last = new JSONArray(new LinkedList<>()); + int h = 0; + for (String ikds:plid + ) { + JSONObject jsonObject_child_content_3_last = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray_child_content_3_last = new JSONArray(new LinkedList<>()); + String sqls3 = "select * from APP_ACT_COE_PAL_REPOSITORY where CREATEUSER = 'admin' AND PLPARENTID = "+ikds+" AND PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + + List mapss = DBSql.getMaps(sqls3); + for (RowMap rowmaps : mapss) { + /** + * 这是L3流程绩效名称中的流程架构 + */ + JSONObject jsonObject_child_content_3_name_last = new JSONObject(new LinkedHashMap<>()); + System.out.println("h>>>>>>>>>>>>>>>"+h); + jsonObject_child_content_3_name_last.put("name",list_pq.get(h).get(i)); + if (StringUtils.isNotEmpty(list_pq.get(h).get(i))) { + jsonObject_child_content_3_name_last.put("num","1"); + }else { + jsonObject_child_content_3_name_last.put("num","0"); + } + jsonArray_child_content_3_last.add(jsonObject_child_content_3_name_last); + h++; + } + if (mapss.size()==0){ + JSONObject jsonObject_child_content_3_name_last = new JSONObject(new LinkedHashMap<>()); + System.out.println("h>>>>>>>>>>>>>>>"+h); + jsonObject_child_content_3_name_last.put("name",list_pq.get(h).get(i)); + if (StringUtils.isNotEmpty(list_pq.get(h).get(i))) { + jsonObject_child_content_3_name_last.put("num","1"); + }else { + jsonObject_child_content_3_name_last.put("num","0"); + } + jsonArray_child_content_3_last.add(jsonObject_child_content_3_name_last); + h++; + } + + + jsonObject_child_content_3_last.put("content",jsonArray_child_content_3_last); + System.out.println("jsonObject_child_content_3_last>>>>>>>>>>>>>>"+jsonObject_child_content_3_last); + jsonArray_child_3_last.add(jsonObject_child_content_3_last); + } + jsonObject_child_3_last.put("child",jsonArray_child_3_last); + jsonArray_levels_3.add(jsonObject_child_3_last); + } + jsonObject_L3.put("levels_3",jsonArray_levels_3); + System.out.println("jsonArray>>>>>>>>>>"+jsonArray_levels_3); + JSONObject jsonObject_4 = new JSONObject(new LinkedHashMap<>()); + jsonObject_4.put("levels_name","关键流程清单"); + jsonObject_4.put("levels_4",new JSONArray(new LinkedList<>())); + + result.add(jsonObject_L1); + result.add(jsonObject_L2); + result.add(jsonObject_L3); + result.add(jsonObject_4); + + return result; + } + } + + public static int countStr(String one, String two){ + int counter=0; + if (one.indexOf(two) == -1) { + return 0; + } + while(one.indexOf(two)!=-1){ + counter++; + one=one.substring(one.indexOf(two)+two.length()); + } + return counter; + } + + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/SendOAProcessController.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/SendOAProcessController.java new file mode 100644 index 00000000..f800e381 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/SendOAProcessController.java @@ -0,0 +1,191 @@ +package com.awspaas.user.apps.integration.controller; + +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +import com.actionsoft.bpms.bpmn.engine.model.def.ProcessDefinition; +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.mvc.view.ResponseObject; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.server.bind.annotation.Controller; +import com.actionsoft.bpms.server.bind.annotation.Mapping; +import com.actionsoft.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 com.awspaas.user.apps.integration.XmlDatasUtil; +import com.awspaas.user.apps.integration.util.HttpClientUtils; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.*; + +@Controller +public class SendOAProcessController { + @Mapping("com.awspaas.user.apps.integration.controller.SendOAProcessController.SendProcessByOA") + public JSONObject SendProcessByOA(String sid,String taskInstId,String processInstId,String isSave) throws IOException, DocumentException { + JSONObject result = new JSONObject(new LinkedHashMap<>()); + ProcessInstance instanceById = SDK.getProcessAPI().getInstanceById(processInstId); + TaskInstance instanceById1 = SDK.getTaskAPI().getInstanceById(taskInstId); + XmlDatasUtil xmlDatasUtil = new XmlDatasUtil(); + xmlDatasUtil.setExternal_system_ID("LCZD"); + xmlDatasUtil.setOther_system_to_do_ID(instanceById1.getId()); + ProcessDefinition processDefinition = SDK.getRepositoryAPI().getProcessDefinition(instanceById.getProcessDefId()); + String processName = processDefinition.getName(); + xmlDatasUtil.setProcess_title(" 您有一条草稿流程保存成功【"+processName+"】"); + + + + + //http://localhost:8089/portal/r/or?cmd=com.yili_form_page_open&processInstId=3505e654-9217-41cd-a31d-4971846b3219&taskInstId=8a71d75e-3ee0-43a2-a226-ecb01419319c&oauthName=oauthLogin&token=admin + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + if (portalUrl.equals("http://10.114.11.135:8088/portal")){ + portalUrl = "https://bpm.yili.com:8088/portal/"; + } + xmlDatasUtil.setPcurl(portalUrl+"/r/or?cmd=com.yili_form_page_open&oauthName=oauthLogin&processInstId="+instanceById.getId()+"&taskInstId="+instanceById1.getId()); + xmlDatasUtil.setMobileurl(portalUrl+"/r/or?cmd=com.yili_form_page_open&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&casaccount="+instanceById1.getTarget()+"&processInstId="+instanceById.getId()+"&taskInstId="+instanceById1.getId()); + String target = instanceById1.getTarget(); + + System.out.println("当前账户======》》》》"+target); + BO bo_eu_oa_reson = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("WORKCODE=" , target).detail(); + System.out.println("bo>>>>>>>>>>"+bo_eu_oa_reson); + if (bo_eu_oa_reson!=null){ + xmlDatasUtil.setTo_do_login_account(bo_eu_oa_reson.getString("LOGINID")); + } + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义格式,不显示毫秒 + String str = df.format(instanceById1.getBeginTime()); + String substring = str.substring(str.indexOf(" "), str.length()); + xmlDatasUtil.setTo_do_creation_time(substring); + xmlDatasUtil.setTo_do_completion_time(substring); + + //if (taskInstance.getState()==1){ + xmlDatasUtil.setTo_do_status("0"); + //} + xmlDatasUtil.setTo_do_official_type("0"); +// if (taskInstance.getReadState()==0){ +// xmlDatasUtil.setViewtype("0"); +// }else if (taskInstance.getReadState()==1){ + xmlDatasUtil.setViewtype("0"); +// + + xmlDatasUtil.setCreatedate(str.substring(0, str.indexOf(" "))); + xmlDatasUtil.setDonedate(str.substring(0, str.indexOf(" "))); + /*String der =""; + if (taskInstance.getReadTime()!=null){ + der = df.format(taskInstance.getReadTime()); + xmlDatasUtil.setReceivedate(der.substring(0, der.indexOf(" "))); + xmlDatasUtil.setReceivetime(der.substring(der.indexOf(" "),der.length())); + }else { + der = df.format(taskInstance.getBeginTime()); + xmlDatasUtil.setReceivedate(der.substring(0, der.indexOf(" "))); + xmlDatasUtil.setReceivetime(der.substring(der.indexOf(" "),der.length())); + }*/ + xmlDatasUtil.setReceivedate(str.substring(0, str.indexOf(" "))); + xmlDatasUtil.setReceivetime(substring); + + xmlDatasUtil.setCurrentnodetype("0"); + xmlDatasUtil.setRequestcode(instanceById.getId()); + xmlDatasUtil.setCurrentnodename(SDK.getRepositoryAPI().getProcessNode(instanceById.getProcessDefId(),instanceById1.getActivityDefId()).getName()); + + // 调用App + String sourceAppId = instanceById.getAppId(); + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.processtrends/processNodeInfoASLP"; + // 参数定义列表 + Map params = new HashMap(); + //流程实例id,必填 + params.put("processInstId", instanceById.getId()); + //,必填 + params.put("sid", sid); + AppAPI appAPI = SDK.getAppAPI(); + //流程节点数据 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + String username = ""; + String userid = ""; + /*if (ro.isOk()){ + List list = new ArrayList(); + Object processBudgetModelList = ro.get("processBudgetModelList"); + JSONArray array = JSON.parseArray(String.valueOf(processBudgetModelList)); + + if (!array.isEmpty()){ + for(int i=0;i>>>>>>>>>"+sdf.format(new Date())); + String sql = "select * from APP_ACT_COE_PAL_REPOSITORY " + + "where PLCATEGORY = 'process'and PLMETHODID !='process.framework' " + + "and ISPUBLISH = '1' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + ",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + "'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + "'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + "'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + "'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + "'42c09260-c1d3-44b7-ac3d-f8280e04c294')"; + + List rowMapList = DBSql.getMaps(sql); + for (RowMap rowmap:rowMapList + ) { + String card_sql = "SELECT * FROM APP_ACT_KMS_CARD WHERE CARDNAME like '"+rowmap.getString("PLNAME")+"%'"; + RowMap map = DBSql.getMap(card_sql); + if (map!=null){ + String sql_pal = "SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT4 = '"+map.getString("ID")+"'"; + RowMap rowMap = DBSql.getMap(sql_pal); + if (rowMap!=null){ + System.out.println("该知识已经存在于PAL资产库中的EXT4中,并且已经在知识中"); + }else{ + String level = ""; + if (rowMap!=null){ + + + if (rowmap.getString("PLVER").contains(".00")){ + String[] plvers = rowmap.getString("PLVER").split("\\."); + plvers[1] = plvers[1].replaceAll("0",""); + level = plvers[0]+"."+plvers[1]; + }else { + level = rowmap.getString("PLVER")+".0"; + } + } + CreateKnow(rowmap.getString("PLMETHODID"),rowmap.getString("PLNAME")+"V"+level,rowmap.getString("PLNAME"),rowmap.getString("PLVER"),true,true,"2099-12-31","1",USERID,"",sid); + /*Map names = new LinkedHashMap<>(); + + String plname = rowmap.getString("PLNAME"); + for (int i=0;i<4;i++) { + String sql_de = sql+" and PLNAME = '"+plname+"'"; + RowMap map1 = DBSql.getMap(sql_de); + if (map1!=null){ + names.put(i,map1.getString("PLNAME")); + plname = map1.getString("PLNAME"); + }else { + break; + } + } + for (int i=names.size() - 1; i >= 0; i--) { + String sql_de = sql+" and PLNAME = '"+names.get(i)+"'"; + RowMap map1 = DBSql.getMap(sql_de); + String sql_decre = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+names.get(i)+"'"; + RowMap map2 = DBSql.getMap(sql_decre); + if (map2==null){ + + createDimension(map1.getString("ID"),false,true,"1","","",names.get(i).toString(),sid); + } + }*/ + } + }else { + String level = ""; + if (rowmap!=null){ + if (rowmap.getString("PLVER").contains(".00")){ + System.out.println("PLver>>>>>>>>>>"+rowmap.getString("PLVER")); + String levels = rowmap.getString("PLVER"); + String[] plvers = levels.split("\\."); + System.out.println("pleces>>>>>>>>>>>>>>>>>"+plvers[0]); + plvers[1] = plvers[1].replaceAll("0",""); + level = plvers[0]+"."+plvers[1]; + }else { + level = rowmap.getString("PLVER")+".0"; + } + } + CreateKnow(rowmap.getString("PLMETHODID"),rowmap.getString("PLNAME")+"V"+level,rowmap.getString("PLNAME"),rowmap.getString("PLVER"),true,true,"2099-12-31","1",USERID,"",sid); + /*Map names = new LinkedHashMap<>(); + + + String plname = rowmap.getString("PLNAME"); + String plparentid = rowmap.getString("PLPARENTID"); + for (int i=0;i<4;i++) { + String slq = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+plparentid+"'"; + RowMap map3 = DBSql.getMap(slq); + if (map3!=null){ + names.put(i,map3.getString("PLNAME")); + plname = map3.getString("PLNAME"); + plparentid = map3.getString("PLPARENTID"); + }else if (plparentid.equals("process")){ + names.put(i,"流程制度"); + }else { + break; + } + } + for (int i=names.size() - 1; i >= 0; i--) { + if (names.get(i).equals("流程制度")){ + String sql_decre = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+names.get(i)+"'"; + RowMap map2 = DBSql.getMap(sql_decre); + if (map2==null){ + + createDimension("",false,true,"1","","",names.get(i).toString(),sid); + } + }else { + String sql_de = "select * from APP_ACT_COE_PAL_REPOSITORY " + + "where PLCATEGORY = 'process'and PLMETHODID ='process.framework' " + + "and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + ",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + "'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + "'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + "'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + "'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + "'42c09260-c1d3-44b7-ac3d-f8280e04c294')"+" and PLNAME = '"+names.get(i)+"'"; + RowMap map1 = DBSql.getMap(sql_de); + String sql_decre = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+names.get(i)+"'"; + RowMap map2 = DBSql.getMap(sql_decre); + if (map2==null){ + + createDimension(map1.getString("ID"),false,true,"1","","",names.get(i).toString(),sid); + } + } + + + + } + */ + } + } + System.out.println("知识库同步完成"); + } + + /** + * 创建知识 + * @param securityLevel + * @param knwlName + * @param plname + * @param PLVER + * @param isComment + * @param isRate + * @param validDate + * @param onlineLevel + * @param createUser + * @param cardContext + * @param sid + */ + public void CreateKnow(String securityLevel,String knwlName,String plname,String PLVER, boolean isComment,boolean isRate,String validDate,String onlineLevel,String createUser,String cardContext,String sid) { +// 调用App + UserContext userContext = UserContext.fromSessionId(sid); + String sourceAppId = APPID; +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/CreateKnwl"; +// 参数定义列表 + Map params = new HashMap(); +//保密级别, 0: 普通 1:秘密 2:机密,必填 + params.put("securityLevel", 0); +//知识名称,必填 + params.put("knwlName", knwlName); +//是否可以评论,必填 + params.put("isComment", isComment); +//是否可以评分,必填 + params.put("isRate", isRate); +//有效期:yyyy-MM-dd,非必填 + params.put("validDate", validDate); +//只读控制,1:在线阅读和下载 0:在线阅读,必填 + params.put("onlineLevel", 1); +//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填 + + params.put("createUser", createUser); +//知识内容,非必填 + params.put("cardContext", cardContext); +//sid,必填 + params.put("sid", sid); + AppAPI appAPI = SDK.getAppAPI(); +//创建知识 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + if (ro.isOk()){ + String cardId = ((LinkedHashMap) ro.getData()).get("cardId").toString(); + + String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '"+cardId+"' WHERE " + + " PLCATEGORY = 'process'and PLMETHODID !='process.framework' " + + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and ISPUBLISH = '1' and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + " '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + " '42c09260-c1d3-44b7-ac3d-f8280e04c294') and PLMETHODID = '"+securityLevel+"' and PLNAME = '"+plname+"' AND PLVER = '"+PLVER+"'"; + int update = DBSql.update(update_sql); + System.out.println("更新名称为:"+plname+"版本为:"+PLVER +"的知识对应的资产库的EXT4的影响行数为"+update); + creadteFile(userContext,cardId); + } + + } + + + /** + * 创建附件以及手册dc + * @param userContext + * @param cardId + */ + public void creadteFile(UserContext userContext, String cardId){ + /** + * 这个主要是负责对流程手册进行相关的文件的生成 + */ + String sourceAppId = APPID; +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/CreateFile"; + + if (StringUtils.isNotEmpty(cardId)){ + String sql_ext4 = "select * from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '"+cardId+"'"; + RowMap map = DBSql.getMap(sql_ext4); + RowMap rowMap = DBSql.getMap("select * from (select * from BO_ACT_COE_PUBLISH_N where PUBLISHFILEID = '"+map.getString("ID")+"' order by CREATEDATE desc) where rownum = 1"); + if (rowMap!=null){ + + if (StringUtils.isNotEmpty(rowMap.getString("TASKID"))) { + + OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID")); + if (model != null) { + System.out.println(",pdel============" + model); + System.out.println("123313123123123==========" + model.getProfileId()); + OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId()); + System.out.println("dajadfas======" + appProfile); + if (appProfile == null) { + throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId()); + } + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + String sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + rowMap.getString("PUBLISHFILEID") + "'"; + System.out.println("手册的版本号>>>>>>>>>>>>"+sql_lever); + String lever = DBSql.getString( sql_lever); + //lever = lever.substring(0,3); + if(lever.length()==5&&lever.substring(4).equals("0")){ + lever.substring(0,3); + }else if (lever.length()==1){ + lever=lever+".0"; + } + System.out.println("手册截取之后的版本号>>>>>>>>>>"+lever); + DCContext dcContext = new DCContext(userContext, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), rowMap.getString("TASKID"), rowMap.getString("PUBLISHFILENAME") + "_" + lever + ".doc"); + //UtilFile file = new UtilFile(dcContext.getPath()); + + + Map params = new HashMap(); +//知识ID,必填 + params.put("cardId", cardId); +//sid,必填 + params.put("sid", userContext.getSessionId()); + + params.put("dc", dcContext); + AppAPI appAPI = SDK.getAppAPI(); +//创建文件 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("流程手册的存入=================" + ro); + } + } + + } + String sql_A = "SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where ID = '"+map.getString("ID")+"' AND PLMETHODID != 'process.framework' AND PLMETHODID IN (select distinct PLMETHODID from APP_ACT_COE_PAL_REPOSITORY)"; + List rows = DBSql.getMaps(sql_A); + + for (RowMap bo:rows + ) { + + /** + * 这个是模型中的附件获取的并插入的数据信息,需要做修改 + */ + // 调用App + +// 参数定义列表 + Map paramss = new HashMap(); +//知识ID,必填 + paramss.put("cardId", cardId); +//sid,必填 + paramss.put("sid", userContext.getSessionId()); + + UpfileWeb upfileWeb = new UpfileWeb(userContext); + + + + String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID != 'process.framework' AND ID= '"+map.getString("ID")+"'" + + ")"; + List maps = DBSql.getMaps(sql_upfile); + for (RowMap row : maps) { + System.out.println("附件的名称>>>>>>>>>>"+row.getString("FILENAME")); + if (!row.getString("FILENAME").contains(".xml")){ + try { + + + UpfileModel upfileModel = new UpfileModel(); + upfileModel.setType(row.getString("FILETYPE")); + upfileModel.setFileName(row.getString("FILENAME")); + upfileModel.setPl_uuid(row.getString("PALREPOSITORYID")); + upfileModel.setShape_uuid(row.getString("SHAPEID")); + DCContext dcContexts = upfileWeb.getDCContext(upfileModel); + paramss.put("dc", dcContexts); + AppAPI appAPIs = SDK.getAppAPI(); + ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, paramss); + System.out.println("流程模型附件的生成============="+ros); + }catch (Exception e){ + System.out.println("附件无法上传>>>>>>>>"+row.getString("FILENAME")); + } + } + + } + +//DCContext对象,必填 + +//创建文件 + } + PublishKnow(userContext,cardId); + } + } + + + /** + * 发布知识 + * @param userContext + * @param id + */ + public void PublishKnow(UserContext userContext,String id){ + + String sql = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id in (select PLPARENTID from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '"+id +"')"; + List maps = DBSql.getMaps(sql); + String ids = ""; + for (RowMap rowmap:maps + ) { + ids+=rowmap.getString("EXT4")+","; + } + String[] deptSplit_id = ids.split(","); + + JSONArray jsonArray = new JSONArray(); + for (String id_names:deptSplit_id + ) { + jsonArray.add(id_names); + } + //jsonObject.put(deptSplit_id); + id+=","; + String[] deptSplit_das = id.split(","); + JSONArray jsonArray_das = new JSONArray(); + for (String das:deptSplit_das + ) { + jsonArray_das.add(das); + } + //jsonObject.put(deptSplit_id); + + + // 调用App + String sourceAppId = APPID; +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl"; +// 参数定义列表 + Map params = new HashMap(); +//要发布到的维度ID的JSON数组字符串,必填 + params.put("dimensionIDArray", jsonArray.toString()); +//要发布的知识ID的JSON数组字符串,必填 + params.put("knwlIDArray", jsonArray_das.toString()); +//标签的JSON数组字符串,非必填 + +//sid,必填 + params.put("sid", userContext.getSessionId()); + AppAPI appAPI = SDK.getAppAPI(); +//发布知识 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + + System.out.println("知识发布============"+ro); + + String sql_ext4 = "select PERMTYPE,ORGPERM from BO_ACT_PUBLISH_PERM_SCOPE where PALVERSIONID = (select PLVERSIONID from ( select PLVERSIONID from APP_ACT_COE_PAL_REPOSITORY a where ISPUBLISH = '1' AND EXT4 = '"+id.substring(0,id.length()-1)+"' order by a.createdate desc ) where rownum=1)";//id.substring(0,id.length()-1) + RowMap rowMap = DBSql.getMap(sql_ext4); + System.out.println("rowMap>>>>>>>>"+rowMap); + System.out.println("sqls>>>>>>>>"+sql_ext4); + JSONArray jsonArray1 = new JSONArray(new LinkedList<>()); + if (rowMap==null){ + List select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT"); + for (RowMap depaid: + select_id_from_orgdepartment) { + String id_depart = depaid.getString("ID"); + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType","department"); + jsonObjecta.put("assignmentId",id_depart); + jsonArray1.add(jsonObjecta); + } + }else { + String permtype = rowMap.getString("PERMTYPE"); + if (permtype.equals("1")) { + List select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT"); + for (RowMap depaid : + select_id_from_orgdepartment) { + String depaid_id = depaid.getString("ID"); + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", depaid_id); + jsonArray1.add(jsonObjecta); + } + } else { + String org_depart = rowMap.getString("ORGPERM"); + String deoa = ""; + if (org_depart.contains(",")) { + String[] ds = org_depart.split(","); + for (String depaid : + ds) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", depaid); + jsonArray1.add(jsonObjecta); + } + } else { + deoa = org_depart; + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", deoa); + jsonArray1.add(jsonObjecta); + } + } + } + AddKnwlAC(jsonArray1,userContext.getSessionId(),id.substring(0,id.length()-1)); + + } + + + /** + * 授权知识 + * @param jsonArray + * @param sid + * @param knwlId + * @return + */ + public boolean AddKnwlAC(JSONArray jsonArray, String sid, String knwlId) { +// 调用App + String sourceAppId = APPID; +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC"; +// 参数定义列表 + Map params = new HashMap(); +//[{"assignmentType":"department","assignmentId":"62196ff9-a26d-4be5-9480-3ef680886f63"},{"assignmentType":"user","assignmentId":"user1"}],必填 + params.put("acList", jsonArray); +//sid,如果为空,则需要传createUser参数,非必填 + params.put("sid", sid); +//知识ID,必填 + params.put("knwlId", knwlId); + AppAPI appAPI = SDK.getAppAPI(); +//给知识授权 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("授权>>>>>>>>>>>>"+ro); + return ro.isOk(); + } + + + + + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/OutputDCFileProcessor.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/OutputDCFileProcessor.java new file mode 100644 index 00000000..dce81728 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/OutputDCFileProcessor.java @@ -0,0 +1,145 @@ +package com.awspaas.user.apps.integration.event; + +import com.actionsoft.apps.coe.pal.constant.CoEConstant; +import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI; +import com.actionsoft.apps.coe.pal.log.CoEOpLogConst; +import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.server.fs.AbstFileProcessor; +import com.actionsoft.bpms.server.fs.DCContext; +import com.actionsoft.bpms.server.fs.FileProcessorListener; +import com.actionsoft.bpms.server.fs.dc.DCProfileManager; +import com.actionsoft.bpms.server.fs.dc.DCUtil; +import com.actionsoft.bpms.util.UtilFile; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.AppAPI; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +/** + * 这块主要是将手册以及相关的附件的代码 + */ +public class OutputDCFileProcessor extends AbstFileProcessor implements FileProcessorListener { + public OutputDCFileProcessor() { + } + + /** + * 得到报告文件 + * + * @param wsId 资产库id + * @param id 任务Id + * @param profileId 报告生成器扩展App的配置Id + * @throws Exception + */ + public static String getReportDownloadURL(String wsId, String id, String profileId, UserContext _uc, String taskName) throws Exception { + UtilFile file = OutputAPIManager.getInstance().getFilePath(wsId, id, profileId); + if (file.exists()) { + //String josnStr = OutputAPIManager.getInstance().getWizardJsonData(wsId, id, profileId); + // JSONObject jsonObj = JSONObject.fromObject(josnStr); + DCContext dcContext = null; + DCUtil.getInstance(); + if (taskName.contains("流程")){ + dcContext = DCUtil.createTempFileContext("com.actionsoft.apps.coe.pal.output.pr", "output", id, "zip"); + }else if (taskName.contains("表单")){ + dcContext = DCUtil.createTempFileContext("com.awspaas.user.apps.coe.pal.output.bd", "output", id, "zip"); + }else if (taskName.contains("制度")){ + dcContext = DCUtil.createTempFileContext("com.awspaas.user.apps.coe.pal.output.zd", "output", id, "zip"); + } + dcContext.setFileName(taskName+ ".zip"); + File ff = new File(dcContext.getFilePath()); + // UtilFile.zipCompress(file.getPath(), ff, "doc"); +// UtilFile.zipCompressExcludeName(file.getPath(), ff, "txt,**/*.log"); + UtilFile.zipCompressExcludeName(file.getPath(), ff, "log,**/config.txt"); + dcContext.setSession(_uc); + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_APPCENTER, CoEOpLogConst.OP_DOWNLOAD, CoEOpLogConst.INFO_OUTPUT_DOWNLOAD); + } + return dcContext.getDownloadURL(); + } + return ""; + } + + public static String doPreviewReport(String wsId, String id, String profileId, UserContext _uc) throws Exception { + UtilFile file = OutputAPIManager.getInstance().getFilePath(wsId, id, profileId); + ResponseObject result = ResponseObject.newOkResponse(); + if (file.exists()) { + File[] fileList = file.listFiles(); + if (fileList.length > 0) { + File docFile = null; + File[] var8 = fileList; + int var9 = fileList.length; + + for(int var10 = 0; var10 < var9; ++var10) { + File file2 = var8[var10]; + if (file2.isFile() && "doc".equals(file2.getName().substring(file2.getName().lastIndexOf(".") + 1))) { + docFile = file2; + break; + } + } + + if (docFile == null) { + return ResponseObject.newErrResponse("没有找到文件").toString(); + } + + if (SDK.getAppAPI().isActive("com.actionsoft.apps.addons.onlinedoc")) { + String sourceAppId = "com.actionsoft.apps.coe.pal.output.pr"; + String filename = docFile.getName(); + DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, wsId, id, filename); + Map aslpParams = new HashMap(); + aslpParams.put("sid", _uc.getSessionId()); + aslpParams.put("fileNameOriginal", filename); + aslpParams.put("sourceDc", sourceDc); + aslpParams.put("isShowDefaultToolbar", "false"); + aslpParams.put("isEncrypt", true); + aslpParams.put("isCopy", "true"); + aslpParams.put("isPrint", "false"); + aslpParams.put("isDownload", "false"); + AppAPI appAPI = SDK.getAppAPI(); + ResponseObject responseObject = appAPI.callASLP(appAPI.getAppContext(sourceAppId), "aslp://com.actionsoft.apps.addons.onlinedoc/filePreview", aslpParams); + if (responseObject != null) { + if (responseObject.isOk()) { + String url = responseObject.get("url").toString(); + result.put("url", url); + result.put("filename", filename); + if (SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IS_RECORD_OP_LOG", false)) { + CoEOpLogAPI.auditOkOp(_uc, "PAL应用中心", "access", "访问报告手册文档"); + } + } else { + result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员"); + } + } + } else { + result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员"); + } + } + } else { + result = ResponseObject.newErrResponse("没有可预览文件"); + } + + return result.toString(); + } + + public static String getReportLogDownloadURL(String wsId, String id, String profileId, UserContext _uc, String taskName) throws Exception { + UtilFile file = OutputAPIManager.getInstance().getFilePath(wsId, id, profileId); + if (file.exists()) { + DCContext dcContext = null; + DCUtil.getInstance(); + dcContext = DCUtil.createTempFileContext("com.actionsoft.apps.coe.pal.output.pr", "output", id, "zip"); + dcContext.setFileName("log.zip"); + File ff = new File(dcContext.getFilePath()); + UtilFile.zipCompress(file.getPath(), ff, "log"); + dcContext.setSession(_uc); + if (SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IS_RECORD_OP_LOG", false)) { + CoEOpLogAPI.auditOkOp(_uc, "PAL应用中心", "download", "下载报告手册文档日志"); + } + + return dcContext.getDownloadURL(); + } else { + return ""; + } + } +} \ No newline at end of file diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/ProcessAfterData.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/ProcessAfterData.java new file mode 100644 index 00000000..d4d7e405 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/ProcessAfterData.java @@ -0,0 +1,235 @@ +package com.awspaas.user.apps.integration.event; + +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.bpmn.engine.listener.InterruptListener; +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.login.constant.LoginConst; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.org.cache.UserCache; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.server.SSOUtil; +import com.actionsoft.bpms.server.UserContext; +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 com.awspaas.user.apps.integration.XmlDatasUtil; +import com.awspaas.user.apps.integration.oa.OaPendComponent; +import com.awspaas.user.apps.integration.util.HttpClientUtils; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 这个是发送OA待办以及更新OA待办的接口 + */ +public class ProcessAfterData extends ExecuteListener implements ExecuteListenerInterface { + + @Override + public String getVersion() { + return "0.0.1"; + } + + @Override + public String getProvider() { + return "ActionSoft"; + } + + @Override + public String getDescription() { + return "OA审批数据失败之后需要做的操作"; + } + + @Override + public void execute(ProcessExecutionContext processExecutionContext) throws Exception { + OaPendComponent component = new OaPendComponent(); + + BO bo_eu_faid_data = SDK.getBOAPI().query("BO_EU_FAID_DATA", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).detail(); + if (bo_eu_faid_data!=null){ + String changed = bo_eu_faid_data.getString("CHANGED"); + if (changed.equals("1")){ + ProcessInstance processed = SDK.getProcessAPI().getInstanceById(bo_eu_faid_data.getString("PROCESS_ID")); + TaskInstance taskInstance = SDK.getTaskAPI().getInstanceById(bo_eu_faid_data.getString("TASK_ID")); + if (processed!=null&&taskInstance!=null){ + System.out.println("这是发送待办调用发送待办数据发送问题"); + boolean b = sendOAPRocess(bo_eu_faid_data, processExecutionContext, taskInstance, processed); + } + }else if (changed.equals("2")){ + ProcessInstance processed = SDK.getProcessAPI().getInstanceById(bo_eu_faid_data.getString("PROCESS_ID")); + TaskInstance taskInstance = SDK.getTaskAPI().getInstanceById(bo_eu_faid_data.getString("TASK_ID")); + if (processed!=null&&taskInstance!=null){ + System.out.println("这是更新调用发送待办数据发送问题"); + component.readOa(taskInstance.getId()); + } + }else if (changed.equals("3")){ + ProcessInstance processed = SDK.getProcessAPI().getInstanceById(bo_eu_faid_data.getString("PROCESS_ID")); + TaskInstance instanceById = SDK.getTaskAPI().getInstanceById(processed.getStartTaskInstId()); + if (processed!=null&&instanceById!=null){ + System.out.println("这是删除调用发送待办数据发送问题"); + component.readOa(instanceById.getId()); + } + }else if (changed.equals("4")){ + ProcessInstance processed = SDK.getProcessAPI().getInstanceById(bo_eu_faid_data.getString("PROCESS_ID")); + TaskInstance taskInstance = SDK.getTaskAPI().getInstanceById(bo_eu_faid_data.getString("TASK_ID")); + System.out.println("这是结束调用发送待办数据发送问题"); + component.readOa(taskInstance.getId()); + } + } + } + + + public boolean sendOAPRocess(BO bo ,ProcessExecutionContext processExecutionContext,TaskInstance taskInstance, ProcessInstance processInstance) throws IOException, DocumentException { + boolean flag = false; + XmlDatasUtil xmlDatasUtil = new XmlDatasUtil(); + xmlDatasUtil.setExternal_system_ID("LCZD"); + xmlDatasUtil.setOther_system_to_do_ID(taskInstance.getId()); + BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstance.getId()).detail(); + if (bo_act_coe_publish!=null){ + xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+bo_act_coe_publish.getString("PROCESS_TITLE")+"】,点击进行处理"); + }else { + BO bo_eu_1664184390101 = SDK.getBOAPI().query("BO_EU_1664184390101", true).addQuery("BINDID=", processInstance.getId()).detail(); + if (bo_eu_1664184390101!=null){ + xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+bo_eu_1664184390101.getString("F_LMDOOGTE")+"】,点击进行处理"); + }else { + xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+processInstance.getTitle()+"】,点击进行处理"); + } + } + + //http://localhost:8089/portal/r/or?cmd=com.yili_form_page_open&processInstId=3505e654-9217-41cd-a31d-4971846b3219&taskInstId=8a71d75e-3ee0-43a2-a226-ecb01419319c&oauthName=oauthLogin&token=admin + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + if (portalUrl.equals("http://10.114.11.135:8088/portal")){ + portalUrl = "https://bpm.yili.com:8088/portal/"; + } + xmlDatasUtil.setPcurl(portalUrl+"/r/or?cmd=com.yili_form_page_open&oauthName=oauthLogin&processInstId="+processInstance.getId()+"&taskInstId="+taskInstance.getId()+"&openState="+taskInstance.getState()); + xmlDatasUtil.setMobileurl(portalUrl+"/r/or?cmd=com.yili_form_page_open&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&casaccount="+taskInstance.getTarget()+"&processInstId="+processInstance.getId()+"&taskInstId="+taskInstance.getId()+"&openState="+taskInstance.getState()); + String target = taskInstance.getTarget(); + System.out.println("当前账户======》》》》"+target); + BO bo_eu_oa_reson = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("WORKCODE=" , target).detail(); + System.out.println("bo>>>>>>>>>>"+bo_eu_oa_reson); + if (bo_eu_oa_reson!=null){ + + xmlDatasUtil.setTo_do_login_account(bo_eu_oa_reson.getString("LOGINID")); + } + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义格式,不显示毫秒 + String str = df.format(taskInstance.getBeginTime()); + String substring = str.substring(str.indexOf(" "), str.length()); + xmlDatasUtil.setTo_do_creation_time(substring); + xmlDatasUtil.setTo_do_completion_time(substring); + //if (taskInstance.getState()==1){ + xmlDatasUtil.setTo_do_status("0"); + //} + xmlDatasUtil.setTo_do_official_type("0"); +// if (taskInstance.getReadState()==0){ +// xmlDatasUtil.setViewtype("0"); +// }else if (taskInstance.getReadState()==1){ + xmlDatasUtil.setViewtype("0"); +// } + xmlDatasUtil.setCreatedate(str.substring(0, str.indexOf(" "))); + xmlDatasUtil.setDonedate(str.substring(0, str.indexOf(" "))); + /*String der =""; + if (taskInstance.getReadTime()!=null){ + der = df.format(taskInstance.getReadTime()); + xmlDatasUtil.setReceivedate(der.substring(0, der.indexOf(" "))); + xmlDatasUtil.setReceivetime(der.substring(der.indexOf(" "),der.length())); + }else { + der = df.format(taskInstance.getBeginTime()); + xmlDatasUtil.setReceivedate(der.substring(0, der.indexOf(" "))); + xmlDatasUtil.setReceivetime(der.substring(der.indexOf(" "),der.length())); + }*/ + xmlDatasUtil.setReceivedate(str.substring(0, str.indexOf(" "))); + xmlDatasUtil.setReceivetime(substring); + + xmlDatasUtil.setCurrentnodetype("0"); + xmlDatasUtil.setRequestcode(processInstance.getId()); + xmlDatasUtil.setCurrentnodename(SDK.getRepositoryAPI().getProcessNode(processInstance.getProcessDefId(),taskInstance.getActivityDefId()).getName()); + + // 调用App + String sourceAppId = processInstance.getAppId(); + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.processtrends/processNodeInfoASLP"; + // 参数定义列表 + Map params = new HashMap(); + //流程实例id,必填 + params.put("processInstId", processInstance.getId()); + //,必填 + params.put("sid", UserContext.fromUID(processInstance.getCreateUser()).getSessionId()); + AppAPI appAPI = SDK.getAppAPI(); + //流程节点数据 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + String username = ""; + String userid = ""; + if (ro.isOk()){ + List list = new ArrayList(); + Object processBudgetModelList = ro.get("processBudgetModelList"); + JSONArray array = JSON.parseArray(String.valueOf(processBudgetModelList)); + + if (!array.isEmpty()){ + for(int i=0;i>>>>>"+rootElement); + /*Element result = rootElement.element("Body").element("InsertTodoCominfoResponse ").element("out"); + String resultString = result.getData().toString(); + JSONObject jsonObject1 = JSON.parseObject(resultString); + String datas = jsonObject1.getString("result"); + String status = jsonObject1.getString("message"); + + if (datas.equals("success")){ + System.out.println("发送待办任务完成,请去OA系统上查看是否传输完成"); + flag = true; + }else { + System.out.println("发送待办任务失败,请联系管理员查看是否出现错误"); + System.out.println("错误提示>>>>>>>>>>>>"+status); + flag = false; + }*/ + bo.set("OA_RESULT",rootElement); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + bo.set("OA_DATE",simpleDateFormat.format(new Date())); + SDK.getBOAPI().update("BO_EU_FAID_DATA",bo); + return flag; + } + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/TaskCreatedAfterEvent.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/TaskCreatedAfterEvent.java new file mode 100644 index 00000000..50699f49 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/TaskCreatedAfterEvent.java @@ -0,0 +1,31 @@ +package com.awspaas.user.apps.integration.event; + +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.bpmn.engine.model.run.delegate.TaskInstance; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.ProcessExecuteQuery; + +/** + * 这块是自动审批的代码 + */ +public class TaskCreatedAfterEvent extends ExecuteListener implements ExecuteListenerInterface { + public TaskCreatedAfterEvent() { + super.setDescription("自动审批"); + super.setProvider("actionsoft"); + super.setVersion("1.0"); + } + + @Override + public void execute(ProcessExecutionContext processExecutionContext) throws Exception { + TaskInstance taskInstance = processExecutionContext.getTaskInstance(); + if (taskInstance.getState() != 2) { + String taskInstanceId = processExecutionContext.getTaskInstance().getId(); + SDK.getTaskAPI().setComment(taskInstanceId, "同意", "同意"); + String target = SDK.getTaskAPI().getTaskInstance(taskInstanceId).getTarget(); +// String target = processExecutionContext.getTaskInstance().getTarget(); + ProcessExecuteQuery processExecuteQuery = SDK.getTaskAPI().completeTask(taskInstanceId, null, target); + } + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/TestEvent.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/TestEvent.java new file mode 100644 index 00000000..8db4942b --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/TestEvent.java @@ -0,0 +1,376 @@ +package com.awspaas.user.apps.integration.event; + +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.commons.database.RowMap; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.sdk.local.SDK; +import org.apache.commons.lang.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +/** + * @PackageName: com.awspaas.user.apps.yili.event + * @ClassName: TestEvent + * @author: yujh + * @date: 2022/5/30 20:20 + */ +public class TestEvent extends ExecuteListener implements ExecuteListenerInterface { + + + + @Override + public String getVersion() { + return "0.0.1"; + } + + @Override + public String getProvider() { + return "ActionSoft"; + } + + @Override + public String getDescription() { + return "这个主要是做部门/岗位/职级进行并集,交集测试"; + } + + @Override + public void execute(ProcessExecutionContext processExecutionContext) throws Exception { + BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_EU_WCY_TEST", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).detail(); + String uid = ""; + String new_uid = ""; + if(bo_act_coe_publish1!=null) { + String da = bo_act_coe_publish1.getString("SEND_SCOP"); + + if (da.equals("1")) { + List select_userid_from_orguser = DBSql.getMaps("select USERID from ORGUSER WHERE CLOSED = '0'and userno is not null"); + for (RowMap row : select_userid_from_orguser + ) { + DepartmentModel departmentModel = SDK.getORGAPI().getDepartmentByUser(row.getString("USERID")); + if(departmentModel.getId().equals("e79281b1-2f81-4895-b30e-9f96e9ad0e2c")||departmentModel.getId().equals("5bc3a2dc-3bd2-4376-bcc3-5612e28e55fe")||departmentModel.getId().equals("a93a7f77-8b11-4261-8770-20b0cdfab315")||departmentModel.getId().equals("a93a7f77-8b11-4261-8770-20b0cdfab315")){ + + }else { + uid += row.getString("USERID") + ","; + } + } + } else { + List posts_list = new ArrayList(); + List org_list = new ArrayList(); + if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_ORG"))){ + String strs[] = bo_act_coe_publish1.getString("SEND_SCOPE_ORG").split(","); + org_list= Arrays.asList(strs); + } + + if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_POST"))) { + String posts[] = bo_act_coe_publish1.getString("SEND_SCOPE_POST").split(","); + posts_list = Arrays.asList(posts); + } + List ranks_list = new ArrayList(); + if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL"))) { + String ranks[] = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL").split(","); + ranks_list = Arrays.asList(ranks); + } + + System.out.println("部门id》》》》》》》》》》》》》"+org_list ); + System.out.println("posts_list》》》》》》》》》》》》》"+posts_list); + System.out.println("ranks_list》》》》》》》》》》》》》"+ranks_list); + System.out.println("部门数量》》》》》》》》》》》》》"+org_list.size() ); + System.out.println("岗位数量》》》》》》》》》》》》》"+posts_list.size()); + System.out.println("职级数量》》》》》》》》》》》》》"+ranks_list.size()); + if (org_list.size()!=0 && org_list!=null) { + for (String depaartid : org_list + ) { + System.out.println("departid>>>>>>>>>>>>>" + depaartid); + DepartmentModel departmentModel = SDK.getORGAPI().getDepartmentById(depaartid); + boolean existSubModelOfCache = departmentModel.isExistSubModelOfCache(); + System.out.println("是否含有下级?????????????" + existSubModelOfCache); + //判断选中的是否有下级部门 + if (existSubModelOfCache) { + List maps = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + depaartid + "'"); + for (RowMap row : maps + ) { + String id = row.getString("ID"); + DepartmentModel model = SDK.getORGAPI().getDepartmentById(id); + + if (model.isExistSubModelOfCache()) { + //有下级部门的选中有下级部门 + List rowMapList = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + id + "'"); + for (RowMap wo : + rowMapList) { + String ids = wo.getString("ID"); + DepartmentModel model1 = SDK.getORGAPI().getDepartmentById(ids); + if (model1.isExistSubModelOfCache()) { + List rowMapLists = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + ids + "'"); + for (RowMap wsa : + rowMapLists) { + String wsaString = wsa.getString("ID"); + DepartmentModel model2 = SDK.getORGAPI().getDepartmentById(wsaString); + if (model2.isExistSubModelOfCache()) { + List rowMapList1 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + wsaString + "'"); + for (RowMap rows : + rowMapList1) { + String rowsString = rows.getString("ID"); + DepartmentModel model3 = SDK.getORGAPI().getDepartmentById(rowsString); + if (model3.isExistSubModelOfCache()) { + List rowMapList2 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + rowsString + "'"); + for (RowMap ormap : + rowMapList2) { + String rowsString1 = ormap.getString("ID"); + DepartmentModel model4 = SDK.getORGAPI().getDepartmentById(rowsString1); + if (model4.isExistSubModelOfCache()) { + List rowMaps = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + rowsString1 + "'"); + for (RowMap owmapr : + rowMaps) { + String row_id = owmapr.getString("ID"); + DepartmentModel model5 = SDK.getORGAPI().getDepartmentById(row_id); + if (model5.isExistSubModelOfCache()) { + List rowMapList3 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + row_id + "'"); + for (RowMap owzmap : + rowMapList3) { + String idsa = owzmap.getString("ID"); + DepartmentModel model6 = SDK.getORGAPI().getDepartmentById(idsa); + if (model6.isExistSubModelOfCache()) { + + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(idsa); + for (UserModel user : allUsersByDepartments + ) { + if (!user.isClosed()){ + System.out.println("userclose>>>>>>>>>>"+user.isClosed()); + + if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(row_id); + for (UserModel user : allUsersByDepartments + ) { + if (!user.isClosed()) { + System.out.println("userclose>>>>>>>>>>"+user.isClosed()); + + if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(rowsString1); + for (UserModel user : allUsersByDepartments + ) { + if (!user.isClosed()){ + System.out.println("userclose>>>>>>>>>>"+user.isClosed()); + + if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(rowsString); + for (UserModel user : allUsersByDepartments + ) { + if (!user.isClosed()) { + System.out.println("userclose>>>>>>>>>>"+user.isClosed()); + + if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(wsaString); + for (UserModel user : allUsersByDepartments + ) { + if (!user.isClosed()) { + System.out.println("userclose>>>>>>>>>>"+user.isClosed()); + if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(ids); + for (UserModel user : allUsersByDepartments + ) { + if (!user.isClosed()) { + System.out.println("userclose>>>>>>>>>>"+user.isClosed()); + + if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(id); + for (UserModel user : allUsersByDepartments + ) { + if (!user.isClosed()) { + System.out.println("userclose>>>>>>>>>>"+user.isClosed()); + + if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } + } else { + //选中的没有下级部门 + List allUsersByDepartment = SDK.getORGAPI().getAllUsersByDepartment(depaartid); + for (UserModel user : allUsersByDepartment + ) { + if (!user.isClosed()) { + System.out.println("userclose>>>>>>>>>>"+user.isClosed()); + + System.out.println("user.getExt2())???????????" + user.getExt2()); + System.out.println("posts_list》》》》》》》》》das" + (posts_list.size() != 0)); + System.out.println("123123》》》》》》》》》》" + (ranks_list.size() != 0)); + if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } + String posts=""; + if (posts_list.size() !=0 &&ranks_list.size()==0) { + String[] post = bo_act_coe_publish1.getString("SEND_SCOPE_POST").split(","); + if (post.length==1){ + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + posts = "'"+post[0]+"'"; + }else { + posts = "'"+ StringUtils.join(post, "','")+"'"; + } + List maps = DBSql.getMaps("select USERID from ORGUSER where POSITION_NO in(" + posts + ") and userno is not null"); + for (RowMap map:maps + ) { + uid+=map.getString("USERID")+","; + } + } + } + if (org_list.size()==0||org_list==null){ + String posts=""; + String levels = ""; + if (posts_list.size() !=0 &&ranks_list.size()==0) { + String[] post = bo_act_coe_publish1.getString("SEND_SCOPE_POST").split(","); + if (post.length==1){ + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + posts = "'"+post[0]+"'"; + }else { + posts = "'"+ StringUtils.join(post, "','")+"'"; + } + List maps = DBSql.getMaps("select USERID from ORGUSER where CLOSED = '0' and userno is not null and POSITION_NO in(" + posts + ")"); + for (RowMap map:maps + ) { + uid+=map.getString("USERID")+","; + } + }else if (posts_list.size() ==0 &&ranks_list.size()!=0){ + String[] level = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL").split(","); + + if (level.length==1){ + levels = "'"+level[0]+"'"; + }else { + levels = "'"+ StringUtils.join(level, "','")+"'"; + } + List maps = DBSql.getMaps("select USERID from ORGUSER where CLOSED = '0' and userno is not null and EXT2 in (" + levels + ")"); + for (RowMap map:maps + ) { + uid+=map.getString("USERID")+","; + } + } + + } + } + System.out.println("userid》》》》》》》》》》》》》》》》》》》"+uid); + if (StringUtils.isNotEmpty(uid + )) { + uid = uid.substring(0, uid.length() - 1); + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + for (String userid:list + ) { + new_uid+=userid+","; + // System.out.println("当前账户======》》》》"+userid); + // BO boEuOaReson = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("WORKCODE=", userid).detail(); + // if (boEuOaReson!=null){ + BO bo = new BO(); + bo.set("USER_CODE",userid); + bo.set("USER_NAME",SDK.getORGAPI().getUser(userid).getUserName()); + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().createDataBO("BO_EU_YEUWS",bo,userContext); + // } + + } + } + + System.out.println("账户人员信息>>>>>>>>>>>>>"+new_uid); + } + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/UpdateDimensionJob.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/UpdateDimensionJob.java new file mode 100644 index 00000000..dd576d87 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/UpdateDimensionJob.java @@ -0,0 +1,84 @@ +package com.awspaas.user.apps.integration.event; + +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.schedule.IJob; +import com.actionsoft.bpms.server.SSOUtil; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.AppAPI; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 更新流程架构中同步到知识维度的数据 + */ +public class UpdateDimensionJob implements IJob { + + + + private static String APPID = "com.awspaas.user.apps.yili.integration"; + + + private static String USERID = "admin"; + + + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + + SSOUtil ssoUtil = new SSOUtil(); + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + String sid = ssoUtil.registerClientSessionNoPassword(USERID, "cn", portalUrl, "pc"); + UserContext userContext = UserContext.fromSessionId(sid); + String sql = "select * from APP_ACT_KMS_DIMENSION where ID not in ('obj_e055a421f23547579a75130d27ab3b34','obj_5020f54928c842b58107c3354e450070')"; + List maps = DBSql.getMaps(sql); + for (RowMap row : + maps) { + String sql_Pal = "select * from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '"+row.getString("ID")+"'"; + RowMap map = DBSql.getMap(sql_Pal); + if (map!=null){ + if (row.getString("DIMENSIONNAME").equals(map.getString("PLNAME"))){ + + }else{ + String parent_ext4 = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id = '"+map.getString("PLPARENTID")+"'"; + String ext4 = DBSql.getString("EXT4"); + updateDimension(row.getString("ID"),map.getString("PLNAME"),ext4,sid); + } + } + } + + } + + public void updateDimension(String dimensionId,String dimensionName,String parentId,String sid) { +// 调用App + String sourceAppId = APPID; +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/updateDimension"; +// 参数定义列表 + Map params = new HashMap(); +//发布是否需要审批,默认false,非必填 + params.put("isExamine", false); +//维度ID,必填 + params.put("dimensionId", dimensionId); +//是否启用,默认启用,非必填 + params.put("isEnabled", true); +//维度类型,1:允许发布知识 2:不允许发布知识,非必填 + params.put("showType", 1); +//维度描述,非必填 + params.put("memo", ""); +//维度名称,非必填 + params.put("dimensionName", dimensionName); +//父维度Id:""表示根维度,非必填 + params.put("parentId", parentId); +//sid,必填 + params.put("sid", sid); + AppAPI appAPI = SDK.getAppAPI(); +//修改维度 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/createDimensionJob.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/createDimensionJob.java new file mode 100644 index 00000000..35879308 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/event/createDimensionJob.java @@ -0,0 +1,177 @@ +package com.awspaas.user.apps.integration.event; + +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.schedule.IJob; +import com.actionsoft.bpms.server.SSOUtil; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.AppAPI; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * 创建维度 + */ +public class createDimensionJob implements IJob { + + + private static String APPID = "com.awspaas.user.apps.yili.integration"; + private static String USERID = "admin"; + + + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + + SSOUtil ssoUtil = new SSOUtil(); + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + String sid = ssoUtil.registerClientSessionNoPassword(USERID, "cn", portalUrl, "pc"); + UserContext userContext = UserContext.fromSessionId(sid); + String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc"; + List maps = DBSql.getMaps(sql); + for (RowMap rowmap: maps + ) { + + String sql_decre = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+rowmap.getString("PLNAME")+"'"; + RowMap map2 = DBSql.getMap(sql_decre); + if (map2==null){ + + createDimension(rowmap.getString("PLPARENTID"),false,true,"1","","",rowmap.getString("PLNAME").toString(),sid); + } + + String sql_parent = "select * from APP_ACT_COE_PAL_REPOSITORY where PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = '"+rowmap.getString("ID")+"' order by PLORDERINDEX asc"; + List maps1 = DBSql.getMaps(sql_parent); + for (RowMap rowMap: + maps1) { + + String cime = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+rowMap.getString("PLNAME")+"'"; + RowMap map = DBSql.getMap(cime); + if (map==null){ + + createDimension(rowMap.getString("PLPARENTID"),false,true,"1","","",rowMap.getString("PLNAME").toString(),sid); + } + + String sql_parent1 = "select * from APP_ACT_COE_PAL_REPOSITORY where PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = '"+rowMap.getString("ID")+"' order by PLORDERINDEX asc"; + List maps11 = DBSql.getMaps(sql_parent1); + for (RowMap rowMap1: + maps11) { + + String cle = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+rowMap1.getString("PLNAME")+"'"; + RowMap mapss = DBSql.getMap(cle); + if (mapss==null){ + + createDimension(rowMap1.getString("PLPARENTID"),false,true,"1","","",rowMap1.getString("PLNAME").toString(),sid); + } + + String sql_parent11 = "select * from APP_ACT_COE_PAL_REPOSITORY where PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = '"+rowMap1.getString("ID")+"' order by PLORDERINDEX asc"; + List maps111 = DBSql.getMaps(sql_parent11); + for (RowMap rowMap2: + maps111) { + + String cles = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+rowMap2.getString("PLNAME")+"'"; + RowMap mapkjs = DBSql.getMap(cles); + if (mapkjs==null){ + + createDimension(rowMap2.getString("PLPARENTID"),false,true,"1","","",rowMap2.getString("PLNAME").toString(),sid); + } + + String sql_parent111 = "select * from APP_ACT_COE_PAL_REPOSITORY where PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = '"+rowMap2.getString("ID")+"' order by PLORDERINDEX asc"; + List maps1111 = DBSql.getMaps(sql_parent111); + + for (RowMap rowMap3: + maps1111) { + String oqka = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+rowMap3.getString("PLNAME")+"'"; + RowMap ssaq = DBSql.getMap(oqka); + if (ssaq==null){ + + createDimension(rowMap3.getString("PLPARENTID"),false,true,"1","","",rowMap3.getString("PLNAME").toString(),sid); + } + } + } + } + } + + + } + + + + } + + /** + * 创建知识库维度 + * @param id + * @param isExamine + * @param isEnabled + * @param showType + * @param memo + * @param createUser + * @param dimensionName + * @param sid + */ + public void createDimension(String id,boolean isExamine,boolean isEnabled,String showType,String memo,String createUser,String dimensionName,String sid) { +// 调用App + String sourceAppId = APPID; +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/createDimension"; +// 参数定义列表 + Map params = new HashMap(); +//发布是否需要审批,默认false,必填 + params.put("isExamine", isExamine); +//是否启用,默认启用,必填 + params.put("isEnabled", isEnabled); +//维度类型,1:允许发布知识 2:不允许发布知识,必填 + params.put("showType", showType); +//维度描述,非必填 + params.put("memo", memo); +//维度名称,必填 + params.put("dimensionName", dimensionName); +//父维度Id:""表示根维度,必填 + + String sql = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id ='"+id+"'"; + String string = DBSql.getString(sql); + if (id.equals("process")){ + + if (SDK.getPortalAPI().getPortalUrl().equals("https://bpm.yili.com:8088/portal")){ + string = "obj_b0121317eb9b414586885bcc8527ab8f"; + }else if (SDK.getPortalAPI().getPortalUrl().equals("http://10.60.143.183:8088/portal")){ + string = "obj_e055a421f23547579a75130d27ab3b34"; + }else{ + string = "obj_6dcfbc5d374645d5b97c8ec51ea3a234"; + } + } + params.put("parentId", string); +//sid,必填 + params.put("sid", sid); + AppAPI appAPI = SDK.getAppAPI(); +//创建维度 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + + if (!dimensionName.equals("流程制度")){ + if (ro.isOk()){ + + + String cardId = ((LinkedHashMap) ro.getData()).get("dimensionId").toString(); + String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '"+cardId+"' WHERE " + + " PLCATEGORY = 'process'and PLMETHODID ='process.framework' " + + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + " '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + " '42c09260-c1d3-44b7-ac3d-f8280e04c294') and PLNAME = '"+dimensionName+"'"; + int update = DBSql.update(update_sql); + System.out.println("更新名称为:"+dimensionName+"的维度对应的资产库的EXT4的影响行数为"+update); + } + } + } + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/AddKnowACJob.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/AddKnowACJob.java new file mode 100644 index 00000000..ac211fe5 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/AddKnowACJob.java @@ -0,0 +1,428 @@ +package com.awspaas.user.apps.integration.job; + +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.schedule.IJob; +import com.actionsoft.bpms.server.SSOUtil; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.AppAPI; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang.StringUtils; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.util.*; + +public class AddKnowACJob implements IJob { + + private static String APPID = "com.awspaas.user.apps.yili.integration"; + + + private static String USERID = "admin"; + + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + + + String jobParameter = SDK.getJobAPI().getJobParameter(jobExecutionContext); + + SSOUtil ssoUtil = new SSOUtil(); + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + String sid = ssoUtil.registerClientSessionNoPassword(USERID, "cn", portalUrl, "pc"); + UserContext userContext = UserContext.fromSessionId(sid); + + List bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).list(); + for (BO bo : bo_act_coe_publish + ) { + String uid = ""; + String new_uid = ""; + if (bo != null) { + String da = bo.getString("SEND_SCOP"); + + if (da.equals("1")) { + List select_userid_from_orguser = DBSql.getMaps("select USERID from ORGUSER"); + for (RowMap row : select_userid_from_orguser + ) { + uid += row.getString("USERID") + ","; + } + } else { + List posts_list = new ArrayList(); + String strs[] = bo.getString("SEND_SCOPE_ORG").split(","); + if (StringUtils.isNotEmpty(bo.getString("SEND_SCOPE_POST"))) { + String posts[] = bo.getString("SEND_SCOPE_POST").split(","); + posts_list = Arrays.asList(posts); + } + List ranks_list = new ArrayList(); + if (StringUtils.isNotEmpty(bo.getString("SEND_SCOPE_LEVEL"))) { + String ranks[] = bo.getString("SEND_SCOPE_LEVEL").split(","); + ranks_list = Arrays.asList(ranks); + } + + for (String depaartid : strs + ) { + DepartmentModel departmentModel = SDK.getORGAPI().getDepartmentById(depaartid); + boolean existSubModelOfCache = departmentModel.isExistSubModelOfCache(); + //判断选中的是否有下级部门 + if (existSubModelOfCache) { + List maps = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + depaartid + "'"); + for (RowMap row : maps + ) { + String id = row.getString("ID"); + DepartmentModel model = SDK.getORGAPI().getDepartmentById(id); + + if (model.isExistSubModelOfCache()) { + //有下级部门的选中有下级部门 + List rowMapList = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + id + "'"); + for (RowMap wo : + rowMapList) { + String ids = wo.getString("ID"); + DepartmentModel model1 = SDK.getORGAPI().getDepartmentById(ids); + if (model1.isExistSubModelOfCache()) { + List rowMapLists = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + ids + "'"); + for (RowMap wsa : + rowMapLists) { + String wsaString = wsa.getString("ID"); + DepartmentModel model2 = SDK.getORGAPI().getDepartmentById(wsaString); + + if (model2.isExistSubModelOfCache()) { + List rowMapList1 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + wsaString + "'"); + for (RowMap rows : + rowMapList1) { + String rowsString = rows.getString("ID"); + DepartmentModel model3 = SDK.getORGAPI().getDepartmentById(rowsString); + if (model3.isExistSubModelOfCache()) { + List rowMapList2 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + rowsString + "'"); + for (RowMap ormap : + rowMapList2) { + String rowsString1 = ormap.getString("ID"); + DepartmentModel model4 = SDK.getORGAPI().getDepartmentById(rowsString1); + if (model4.isExistSubModelOfCache()) { + List rowMaps = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + rowsString1 + "'"); + for (RowMap owmapr : + rowMaps) { + String row_id = owmapr.getString("ID"); + DepartmentModel model5 = SDK.getORGAPI().getDepartmentById(row_id); + if (model5.isExistSubModelOfCache()) { + List rowMapList3 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + row_id + "'"); + for (RowMap owzmap : + rowMapList3) { + String idsa = owzmap.getString("ID"); + DepartmentModel model6 = SDK.getORGAPI().getDepartmentById(idsa); + if (model6.isExistSubModelOfCache()) { + + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(idsa); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list != null && ranks_list != null) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list != null && ranks_list == null) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list == null && ranks_list != null) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(row_id); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list != null && ranks_list != null) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list != null && ranks_list == null) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list == null && ranks_list != null) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(rowsString1); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list != null && ranks_list != null) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list != null && ranks_list == null) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list == null && ranks_list != null) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(rowsString); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list != null && ranks_list != null) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list != null && ranks_list == null) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list == null && ranks_list != null) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(wsaString); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list != null && ranks_list != null) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list != null && ranks_list == null) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list == null && ranks_list != null) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(ids); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list != null && ranks_list != null) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list != null && ranks_list == null) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list == null && ranks_list != null) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(id); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list != null && ranks_list != null) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list != null && ranks_list == null) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list == null && ranks_list != null) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + //选中的没有下级部门 + List allUsersByDepartment = SDK.getORGAPI().getAllUsersByDepartment(depaartid); + for (UserModel user : allUsersByDepartment + ) { + if (posts_list != null && ranks_list != null) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list != null && ranks_list == null) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list == null && ranks_list != null) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } + if (StringUtils.isNotEmpty(uid + )) { + uid = uid.substring(0, uid.length() - 1); + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + for (String userid : list + ) { + new_uid += userid + ","; + + } + } + } + + if (StringUtils.isNotEmpty(new_uid + )) { + new_uid = new_uid.substring(0, new_uid.length() - 1); + } + JSONArray jsonArray = new JSONArray(); + + if (bo.getString("SEND_SCOP").equals("0")) { + String departId = bo.getString("SEND_SCOPE_ORG"); + if (StringUtils.isNotEmpty(departId) && StringUtils.isEmpty(bo.getString("SEND_SCOPE_LEVEL")) && StringUtils.isEmpty(bo.getString("SEND_SCOPE_POST"))) { + String strs[] = departId.split(","); + for (String departmentid : strs + ) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", departmentid); + jsonArray.add(jsonObjecta); + } + } else { + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + + for (String user_id : list + ) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "user"); + jsonObjecta.put("assignmentId", user_id); + jsonArray.add(jsonObjecta); + } + } + + } + + List list = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID=", bo.getString("BINDID")).list(); + + for (BO bo_N: + list) { + String pr_id = bo_N.getString("PUBLISHFILEID"); + RowMap map = DBSql.getMap("SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + pr_id + "'"); + if (map!=null){ + String ext4 = map.getString("EXT4"); + if (StringUtils.isNotEmpty(ext4)){ + AddKnwlAC(jsonArray,userContext.getSessionId(),ext4); + } + } + + } + + List boList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).addQuery("BINDID=", bo.getString("BINDID")).list(); + + for (BO bo_N: + boList) { + String pr_id = bo_N.getString("CHANGEDFILEIDNEW"); + RowMap map = DBSql.getMap("SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + pr_id + "'"); + if (map!=null){ + String ext4 = map.getString("EXT4"); + if (StringUtils.isNotEmpty(ext4)){ + AddKnwlAC(jsonArray,userContext.getSessionId(),ext4); + } + } + + } + } + } + + public boolean AddKnwlAC(JSONArray jsonArray, String sid, String knwlId) { +// 调用App + String sourceAppId = APPID; +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC"; +// 参数定义列表 + Map params = new HashMap(); +//[{"assignmentType":"department","assignmentId":"62196ff9-a26d-4be5-9480-3ef680886f63"},{"assignmentType":"user","assignmentId":"user1"}],必填 + params.put("acList", jsonArray); +//sid,如果为空,则需要传createUser参数,非必填 + params.put("sid", sid); +//知识ID,必填 + params.put("knwlId", knwlId); + AppAPI appAPI = SDK.getAppAPI(); +//给知识授权 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + return ro.isOk(); + } + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/CreateWorkflowServiceJob.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/CreateWorkflowServiceJob.java new file mode 100644 index 00000000..e7fb93d6 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/CreateWorkflowServiceJob.java @@ -0,0 +1,590 @@ +package com.awspaas.user.apps.integration.job; + +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.schedule.IJob; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.awspaas.user.apps.integration.util.JDBCUtil; +import com.awspaas.user.apps.integration.util.UtilUrl; +import jodd.util.StringUtil; +import net.sourceforge.pinyin4j.PinyinHelper; +import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; +import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; +import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; +import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; +import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.commons.httpclient.methods.RequestEntity; +import org.apache.commons.httpclient.methods.StringRequestEntity; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + +/** + * 伊利OA系统与流程审批节点操作数据查询接口集成 + */ +public class CreateWorkflowServiceJob implements IJob { + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + System.out.println("portal======>>>>" + portalUrl); + /*if (portalUrl.equals("http://10.114.11.135:8088/portal")){ + portalUrl = "http://bpm.yili.com:8088/portal/"; + }*/ + JDBCUtil jdbcUtil = new JDBCUtil(); + Connection open = DBSql.open(); + List bos = SDK.getBOAPI().query("BO_EU_MODEL", true).list(); + for (BO bo : bos + ) { + + + try { + int tale = Integer.parseInt(bo.getString("WORKFLOWID")); + String workflowname = bo.getString("WORKFLOWNAME"); +//ProcessExecutionContext processExecutionContext,String fileCreateName,String fileName,String fileurl,String readingScope_org,String isFullCompany,String fileCreateDate,String relationProcessinstId,String readingScope_post,String readingScope_level,String fileid + + + JSONObject jsonObject = new JSONObject(new LinkedHashMap()); + jsonObject.put("workflowId", tale); + jsonObject.put("createDateStart", "2019-07-01 00:00:00");//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo() + jsonObject.put("createDateEnd", "2023-09-01 00:00:00");//processExecutionContext.getProcessInstance().getCreateUser() + jsonObject.put("pageIndex", 1); + jsonObject.put("pageSize", 10); + + + String xmlStr = "\n" + + " " + + " " + + " " + + " " + + "" + jsonObject + "" + + " " + + " " + + " " + + ""; + + + /* String xmls = "\n" + + " "; + */ + System.out.println("参数===============" + xmlStr); + //System.out.println("参数==============="+xmls); + //HttpClientUtil httpClientUtil = new HttpClientUtil(); + int timeout = 600000; + // HttpURLConnection 发送SOAP请求 + System.out.println("HttpURLConnection 发送SOAP请求"); + + String postSoap = UtilUrl.doPostSoap("http://10.105.1.59:80/services/WorkflowService", xmlStr, ""); + + /*// HttpClient发送SOAP请求 + System.out.println("HttpClient 发送SOAP请求"); + HttpClient client = new HttpClient(); + PostMethod postMethod = new PostMethod("http://10.119.22.207:80/services/WorkflowService"); + // 设置连接超时 + client.getHttpConnectionManager().getParams().setConnectionTimeout(timeout); + // 设置读取时间超时 + client.getHttpConnectionManager().getParams().setSoTimeout(timeout); + // 然后把Soap请求数据添加到PostMethod中 + RequestEntity requestEntity = new StringRequestEntity(xmlStr, "text/xml", "UTF-8"); + // 设置请求体 + postMethod.setRequestEntity(requestEntity); + int status = client.executeMethod(postMethod); + // 打印请求状态码 + System.out.println("status:" + status); + // 获取响应体输入流 + String responseBodyAsString = postMethod.getResponseBodyAsString(); + + + System.out.println("responseBodyAsString==========>>>>>>>"+responseBodyAsString); + + System.out.println("result=========>>>>>>>"+responseBodyAsString);*/ + + Document document = DocumentHelper.parseText(postSoap); + Element rootElement = document.getRootElement(); + System.out.println("rootElement>>>>>>" + rootElement); + Element result = rootElement.element("Body").element("getFormDataByWfIdResponse").element("out"); + String resultString = result.getData().toString(); + System.out.println("resultString=>>>>>>>>>>" + resultString); + JSONObject jsonObject1 = JSON.parseObject(resultString); + String datas = jsonObject1.getString("datas"); + JSONArray resultArray = JSONObject.parseArray(datas); + System.out.println("个数》》》》》》》》" + resultArray.size()); + StringBuffer allKey = getAllKey(resultArray.getJSONObject(0)); + System.out.println("所有的字段名称信息输出》》》》》》》》》》》》" + allKey + ); + String strs[] = allKey.toString().split(","); + String sql = "create table T" + tale + "("; + for (String name : strs + ) { + String field = getPYIndexStr(name,true); + + if (field.contains("(")){ + field =field.replaceAll("[(]","L"); + } + if (field.contains(")")){ + field =field.replaceAll("[)]","R"); + } + if (isStartWithNumber(field)){ + field = "A"+field; + } + + + System.out.println("flename=>>>>>>>"+name+">>>>fileid》》》》》"+field); + + sql += field + " " + "nvarchar2(2000),"; + } + sql = sql.substring(0, sql.length() - 1) + ")"; + System.out.println("sql>>>>>>>>>>>>>>" + sql); + RowMap map = DBSql.getMap("select * from user_tables t where table_name= upper('T" + tale + "')"); + System.out.println("rowMap>>>>>>>>" + map); + if (map == null) { + int update = DBSql.update(sql + ); + + for (String name : strs + ) { + String field = getPYIndexStr(name,true); + //sql += field + " " + "nvarchar2(2000),"; + if (field.contains("(")){ + field =field.replaceAll("[(]","L"); + } + if (field.contains(")")){ + field =field.replaceAll("[)]","R"); + } + if (isStartWithNumber(field)){ + field = "A"+field; + } + System.out.println("flename=>>>>>>>"+name+">>>>fileid》》》》》"+field); + jdbcUtil.comment("T"+tale,field,name); + } + + System.out.println("是否已经插入数据" + update); + } + + + // DBSql.update("create index AWS_IN_63A5A52E2FA2 on T"+tale+" (BINDID);"); + String substring = allKey.substring(0, allKey.length() - 1); + String insetr = "insert into T" + tale + "(" + substring + ") values("; + //for (int i =0;i 2000) { + DBSql.update("alter table T" + tale + " add " + field + "_temp clob"); + DBSql.update("update T" + tale + " set " + field + "_temp = " + field + ""); + DBSql.update("alter table T" + tale + " drop column " + field + ""); + DBSql.update("alter table T" + tale + " rename column " + field + "_temp to " + field + ""); + } + data += "'" + basic_data + "',"; + } else { + if (jsonObject2.get(field).toString().length() > 2000) { + DBSql.update("alter table T" + tale + " add " + field + "_temp clob"); + DBSql.update("update T" + tale + " set " + field + "_temp = " + field + ""); + DBSql.update("alter table T" + tale + " drop column " + field + ""); + DBSql.update("alter table T" + tale + " rename column " + field + "_temp to " + field + ""); + } + data += "'" + jsonObject2.get(field).toString() + "',"; + } + + } + System.out.println("最后数据=====》》》》》" + data); + data = data.substring(0, data.length() - 1); + String sqsl = insetr + data + ")"; + System.out.println("sqsl>>>>>>>>>>>>" + sqsl); + int update = DBSql.update(sqsl); + System.out.println("插入数据影响行数》》》》》》》》》》》" + update); + } + + + // } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + open.close(); + } catch (SQLException throwables) { + throwables.printStackTrace(); + } + } + System.out.println("同步插入OA表单数据同步完成"); + } + } + + public String getPYIndexStr(String strChinese, boolean bUpCase){ + + try{ + + StringBuffer buffer = new StringBuffer(); + String chinese = ""; + + byte b[] = strChinese.getBytes("GBK");//把中文转化成byte数组 + + for(int i = 0; i < b.length; i++){ + + if((b[i] & 255) > 128){ + + int char1 = b[i++] & 255; + + char1 <<= 8;//左移运算符用“<<”表示,是将运算符左边的对象,向左移动运算符右边指定的位数,并且在低位补零。其实,向左移n位,就相当于乘上2的n次方 + + int chart = char1 + (b[i] & 255); + + buffer.append(getPYIndexChar((char)chart, bUpCase)); + + continue; + + } + + char c = (char)b[i]; + + //确定指定字符是否是汉字、大写字母、数字 + if(!Character.isJavaIdentifierPart(c) || (c >= 'A' && c <= 'Z') || Character.isDigit(c)){ + + buffer.append(c); + + }if (c >= 'a' && c <= 'z'){ + + buffer.append((char) (c - 'a' + 'A')); + + } + + } + if (buffer.toString().contains("-")){ + chinese = buffer.toString().replaceAll("-","_"); + }else if (buffer.toString().contains(" ")){ + chinese = buffer.toString().replaceAll(" ","_"); + }else { + chinese = buffer.toString(); + } + + if (chinese.contains("\\(")){ + chinese = buffer.toString().replaceAll("\\(","L"); + } + + if (chinese.contains(")")){ + chinese = buffer.toString().replaceAll("[)]","R"); + } + + return chinese; + + }catch(Exception e){ + + e.printStackTrace(); + + } + + return null; + + } + + + private static char getPYIndexChar(char strChinese, boolean bUpCase){ + + int charGBK = strChinese; + + char result; + + if(charGBK >= 45217 && charGBK <= 45252){ + + result = 'A'; + + }else if(charGBK >= 45253 && charGBK <= 45760){ + + result = 'B'; + + }else if(charGBK >= 45761 && charGBK <= 46317){ + + result = 'C'; + + }else if(charGBK >= 46318 && charGBK <= 46825){ + + result = 'D'; + + } else if(charGBK >= 46826 && charGBK <= 47009){ + + result = 'E'; + + }else if(charGBK >= 47010 && charGBK <= 47296){ + + result = 'F'; + + }else if(charGBK >= 47297 && charGBK <= 47613){ + + result = 'G'; + + }else if(charGBK >= 47614 && charGBK <= 48118){ + + result = 'H'; + + }else if(charGBK >= 48119 && charGBK <= 49061){ + + result = 'J'; + + } else if(charGBK >= 49062 && charGBK <= 49323){ + + result = 'K'; + + }else if(charGBK >= 49324 && charGBK <= 49895){ + + result = 'L'; + + }else if(charGBK >= 49896 && charGBK <= 50370){ + + result = 'M'; + + }else if(charGBK >= 50371 && charGBK <= 50613){ + + result = 'N'; + + }else if(charGBK >= 50614 && charGBK <= 50621){ + + result = 'O'; + + }else if(charGBK >= 50622 && charGBK <= 50905){ + + result = 'P'; + + }else if(charGBK >= 50906 && charGBK <= 51386){ + + result = 'Q'; + + }else if(charGBK >= 51387 && charGBK <= 51445){ + + result = 'R'; + + }else if(charGBK >= 51446 && charGBK <= 52217){ + + result = 'S'; + + }else if(charGBK >= 52218 && charGBK <= 52697){ + + result = 'T'; + + }else if(charGBK >= 52698 && charGBK <= 52979){ + + result = 'W'; + + }else if(charGBK >= 52980 && charGBK <= 53688){ + + result = 'X'; + + }else if(charGBK >= 53689 && charGBK <= 54480){ + + result = 'Y'; + + }else if(charGBK >= 54481 && charGBK <= 55289){ + + result = 'Z'; + + }else{ + + result = (char)(65 + (new Random()).nextInt(25)); + + } + + if(!bUpCase){ + result = Character.toLowerCase(result); + } + + return result; + + } + + //根据JSONArray获取所有的key + public static StringBuffer getAllKey(JSONArray json1) { + StringBuffer stringBuffer = new StringBuffer(); + if (json1 != null ) { + Iterator i1 = json1.iterator(); + while (i1.hasNext()) { + Object key = i1.next(); + if (key instanceof JSONObject) { + JSONObject innerObject = (JSONObject) key; + stringBuffer.append(getAllKey(innerObject)); + } else if (key instanceof JSONArray) { + JSONArray innerObject = (JSONArray) key; + stringBuffer.append(getAllKey(innerObject)); + }else{ + } + } + } + return stringBuffer; + } + //根据jsonobject获取所有的key + public static StringBuffer getAllKey(JSONObject jsonObject) { + StringBuffer stringBuffer = new StringBuffer(); + Iterator keys = jsonObject.keySet().iterator();// jsonObject.keys(); + while (keys.hasNext()) { + String key = keys.next(); + stringBuffer.append(key.toString()).append(","); + if (jsonObject.get(key) instanceof JSONObject) { + JSONObject innerObject = (JSONObject) jsonObject.get(key); + stringBuffer.append(getAllKey(innerObject)); + } else if (jsonObject.get(key) instanceof JSONArray) { + JSONArray innerObject = (JSONArray) jsonObject.get(key); + stringBuffer.append(getAllKey(innerObject)); + } + } + return stringBuffer; + } + + //递归获取jsonObject的所有value + private StringBuffer mStringBuffer = new StringBuffer(); + public String getAllContentFromJson(Object cObject) { + + if(cObject instanceof JSONObject) { + JSONObject jsonObject = (JSONObject) cObject; + for (Map.Entry entry: jsonObject.entrySet()) { + Object o = entry.getValue(); + if(o instanceof Integer){ + mStringBuffer.append("'"+entry.getValue()+"',"); + }else if(o instanceof Double){ + mStringBuffer.append("'"+entry.getValue()+"',"); + }else if(o instanceof Float){ + mStringBuffer.append("'"+entry.getValue()+"',"); + }else if(o instanceof Byte){ + mStringBuffer.append("'"+entry.getValue()+"',"); + }else if(o instanceof Long){ + mStringBuffer.append("'"+entry.getValue()+"',"); + }else if(o instanceof String) { + Object object = null; + try{ + object=JSONObject.parseObject((String)o); + getAllContentFromJson(object); + }catch (Exception e){ + mStringBuffer.append("'"+entry.getValue()+"',"); + } + + + } + else { + getAllContentFromJson(o); + } + } + } + if(cObject instanceof JSONArray) { + JSONArray jsonArray = (JSONArray) cObject; + for(int i = 0; i < jsonArray.size(); i ++) { + getAllContentFromJson(jsonArray.get(i)); + } + } + return mStringBuffer.toString(); + } + + public static String replaceStr(String sourceStr) { + if (StringUtil.isBlank(sourceStr)) { + return ""; + } + String substring = sourceStr.substring(1, sourceStr.length() - 1); + if (substring.contains("'")) { + String replaceStr = substring.replace("'", "''"); + return "'" + replaceStr + "'"; + } + return sourceStr; + } + + + + + // 将汉字转换为全拼 + public static String getPingYin(String src) { + + char[] t1 = null; + t1 = src.toCharArray(); + String[] t2 = new String[t1.length]; + HanyuPinyinOutputFormat t3 = new HanyuPinyinOutputFormat(); + t3.setCaseType(HanyuPinyinCaseType.LOWERCASE); + t3.setToneType(HanyuPinyinToneType.WITHOUT_TONE); + t3.setVCharType(HanyuPinyinVCharType.WITH_V); + String t4 = ""; + int t0 = t1.length; + try { + for (int i = 0; i < t0; i++) { + // 判断是否为汉字字符 + if (java.lang.Character.toString(t1[i]).matches( + "[\\u4E00-\\u9FA5]+")) { + t2 = PinyinHelper.toHanyuPinyinStringArray(t1[i], t3); + t4 += t2[0]; + } else + t4 += java.lang.Character.toString(t1[i]); + } + // System.out.println(t4); + return t4; + } catch (BadHanyuPinyinOutputFormatCombination e1) { + e1.printStackTrace(); + } + return t4; + } + + + + // 返回中文的首字母 + public static String getPinYinHeadChar(String str) { + String temp = ""; + String demo = ""; + String convert = ""; + for (int j = 0; j < str.length(); j++) { + char word = str.charAt(j); + String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word); + if (pinyinArray != null) { + convert += pinyinArray[0].charAt(0); + } else { + convert += word; + } + } + for(int i=0;i='a' && convert.charAt(i)<='z'){ + temp=convert.substring(i,i+1).toUpperCase(); + demo += temp; + } + } + return demo; + } + + // 将字符串转移为ASCII码 + public static String getCnASCII(String cnStr) { + StringBuffer strBuf = new StringBuffer(); + byte[] bGBK = cnStr.getBytes(); + for (int i = 0; i < bGBK.length; i++) { + // System.out.println(Integer.toHexString(bGBK[i]&0xff)); + strBuf.append(Integer.toHexString(bGBK[i] & 0xff)); + } + return strBuf.toString(); + } + + + + //判断字符串是不是以数字开头 + public static boolean isStartWithNumber(String str) { + Pattern pattern = Pattern.compile("[0-9]*"); + Matcher isNum = pattern.matcher(str.charAt(0)+""); + if (!isNum.matches()) { + return false; + } + return true; + } + + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/CreategetFlowListALLByWfidJob.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/CreategetFlowListALLByWfidJob.java new file mode 100644 index 00000000..b0263956 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/CreategetFlowListALLByWfidJob.java @@ -0,0 +1,79 @@ +package com.awspaas.user.apps.integration.job; + +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.schedule.IJob; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.awspaas.user.apps.integration.util.UtilUrl; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.util.LinkedHashMap; + +/** + * 伊利oa审批数据获取 + */ +public class CreategetFlowListALLByWfidJob implements IJob { + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + try { + + DBSql.update("delete from BO_EU_OA_PROCESS"); + //jsonObject.put("createDateStart","2019-07-01 00:00:00");//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo() + //jsonObject.put("createDateEnd","2023-09-01 00:00:00");//processExecutionContext.getProcessInstance().getCreateUser() + String xmlStr = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + + System.out.println("参数==============="+xmlStr); + UserContext userContext = UserContext.fromUID("admin"); + //System.out.println("参数==============="+xmls); + //HttpClientUtil httpClientUtil = new HttpClientUtil(); + int timeout = 600000; + // HttpURLConnection 发送SOAP请求 + System.out.println("HttpURLConnection 发送SOAP请求"); + + String postSoap = UtilUrl.doPostSoap("http://10.105.1.59:80/services/WorkflowService", xmlStr, ""); + + + Document document = DocumentHelper.parseText(postSoap); + Element rootElement = document.getRootElement(); + System.out.println("rootElement>>>>>>"+rootElement); + Element result = rootElement.element("Body").element("getAllWfIdResponse").element("out"); + String resultString = result.getData().toString(); + System.out.println("resultString=>>>>>>>>>>"+resultString); + JSONArray jsonArray = JSON.parseArray(resultString); + + for (int i=0;i bo_eu_oa_process = SDK.getBOAPI().query("BO_EU_OA_PROCESS", true).list(); + // for (BO bo: + // bo_eu_oa_process) { + + + + + try{ + JSONObject jsonObject = new JSONObject(new LinkedHashMap()); + List bo_eu_oa_process = SDK.getBOAPI().query("BO_EU_MODEL", true).list(); + for (BO bos:bo_eu_oa_process + ) { + String length = SDK.getJobAPI().getJobParameter(jobExecutionContext); + int size = Integer.valueOf(length); + + for (int j=1;j\n" + + " " + + " " + + " " + + " " + + ""+jsonObject+""+ + " " + + " " + + " " + + ""; + + System.out.println("参数==============="+xmlStr); + //System.out.println("参数==============="+xmls); + //HttpClientUtil httpClientUtil = new HttpClientUtil(); + int timeout = 600000; + // HttpURLConnection 发送SOAP请求 + System.out.println("HttpURLConnection 发送SOAP请求"); + + String postSoap = UtilUrl.doPostSoap("http://10.119.22.207:80/services/WorkflowService", xmlStr, ""); + + + Document document = DocumentHelper.parseText(postSoap); + Element rootElement = document.getRootElement(); + System.out.println("rootElement>>>>>>"+rootElement); + Element result = rootElement.element("Body").element("getFlowListByWfIdResponse").element("out"); + String resultString = result.getData().toString(); + System.out.println("resultString=>>>>>>>>>>"+resultString); + //if (!StringUtils.isEmpty(resultString)){ + JSONObject jsonObject1 = JSON.parseObject(resultString); + String datas = jsonObject1.getString("datas"); + System.out.println(""); + JSONArray jsonArray = JSONArray.parseArray(datas); + System.out.println("jsonArrayData》》》》》》》》》》》》"+jsonArray); + if (jsonArray!=null&&jsonArray.size()!=0){ + UserContext userContext = UserContext.fromUID("admin"); + for (int i=0;i bo_eu_model = SDK.getBOAPI().query("BO_EU_MODEL", true).list(); + + for (BO bo: + bo_eu_model) { + BO bo_detail = new BO(); + bo_detail.set("CATEGORY",bo.getString("WORKFLOWNAME")); + bo_detail.set("DEFID",bo.getString("WORKFLOWID")); + bo_detail.set("NAME",bo.getString("WORKFLOWNAME")); + SDK.getBOAPI().create("BO_ACT_BPA_ACTI_PROCESS",bo_detail,jobParameter,"admin"); + } + System.out.println("插入流程清单数据成功,请查看采集器配置中是否已经完成增加"); + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/ReadSendCountJob.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/ReadSendCountJob.java new file mode 100644 index 00000000..8acaded4 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/ReadSendCountJob.java @@ -0,0 +1,89 @@ +package com.awspaas.user.apps.integration.job; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.schedule.IJob; +import com.actionsoft.bpms.util.UtilString; +import com.actionsoft.sdk.local.SDK; + +/** + * 统计部门下的人员数量 + * + * @author Administrator + * + */ +public class ReadSendCountJob implements IJob { + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + String depIds = SDK.getJobAPI().getJobParameter(jobExecutionContext); + StringBuffer depNames = new StringBuffer(); + + + if(UtilString.isNotEmpty(depIds)) { + ArrayList arr = new ArrayList(); + //全集团 + if("1".equals(depIds)) { + List departmentsByCompanyId = SDK.getORGAPI().getDepartmentsByCompanyId(1, "8911e732-b42a-4556-853f-ad32761bcbee"); + for (DepartmentModel departmentModel : departmentsByCompanyId) { + getUserList(arr, departmentModel.getId()); + depNames.append(SDK.getORGAPI().getDepartmentById(departmentModel.getId()).getName()); + } + }else { + //具体部门 + String[] split = depIds.split(","); + for (String depId : split) { + getUserList(arr, depId); + depNames.append(SDK.getORGAPI().getDepartmentById(depId).getName()); + } + } + + System.err.println(depNames+"总人数=====>"+arr.size()); + } + + } + + public void getUserList(ArrayList arr, String departmentId) { + // 获取当前部门下人员 + List userModelList = SDK.getORGAPI().getAllUsersByDepartment(departmentId); + for (UserModel userModel : userModelList) { + if(!userModel.isClosed()) { + arr.add(userModel.getUID()); + } + } + // 获取当前部门的子部门人员 + DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(departmentId); + if(departmentById.isExistSubModelOfCache()) { + getSubDepartments(arr, departmentById); + } + + + + } + //获取子部门人员 + public void getSubDepartments(ArrayList arr,DepartmentModel departmentById) { + if(!departmentById.isClosed()) { + List subDepartments = SDK.getORGAPI().getSubDepartments(departmentById.getId()); + for (DepartmentModel departmentModel : subDepartments) { + String id = departmentModel.getId(); + List userModelList = SDK.getORGAPI().getAllUsersByDepartment(id); + for (UserModel userModel : userModelList) { + if(!userModel.isClosed()) { + arr.add(userModel.getUID()); + } + } + //递归获取子部门下的子部门 + if (SDK.getORGAPI().isExistSubDepartment(id)) { + getSubDepartments(arr,SDK.getORGAPI().getDepartmentById(id)); + } + } + + } + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/SendOAReadByTaskBo.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/SendOAReadByTaskBo.java new file mode 100644 index 00000000..a39a885c --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/SendOAReadByTaskBo.java @@ -0,0 +1,35 @@ +package com.awspaas.user.apps.integration.job; + +import java.util.List; + +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.schedule.IJob; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.sdk.local.SDK; + +/** + * 这个是创建未发送待阅的人员合计 + */ +public class SendOAReadByTaskBo implements IJob { + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + /*String sql = "select * from wfh_task where OWNER !='admin'and TARGET != 'admin'and PROCESSDEFID = 'obj_fb1c7a54b98b412187388c8bab407362'and controlstate = 'complete'and tasktitle like '%(确认发布)%'\n" + + "and tasktitle not like '%测试%' and PROCESSINSTID in (select id from wfc_process where createuser !='admin'and PROCESSDEFID = 'obj_fb1c7a54b98b412187388c8bab407362'and CONTROLSTATE = 'end' and processtitle not like '%测试%')\n" + + "and PARENTTASKINSTID !='00000000-0000-0000-0000-000000000000'";*/ + + //String sql = "select id from wfc_process where createuser !='admin'and PROCESSDEFID = 'obj_fb1c7a54b98b412187388c8bab407362'and CONTROLSTATE = 'end' and processtitle not like '%测试%'"; + String sql = "select id from wfc_process where createuser !='admin'and PROCESSDEFID = 'obj_fb1c7a54b98b412187388c8bab407362'and CONTROLSTATE = 'end' and processtitle not like '%测试%' and id ='c8b2c66e-5fd7-43d7-b8a0-6f2e9bb5021e'"; + List maps = DBSql.getMaps(sql); + for (RowMap rowMap: + maps) { + String processinstid = rowMap.getString("ID"); + String taskid = SDK.getProcessAPI().getInstanceById(processinstid).getStartTaskInstId(); + sendReadByDataid2 sre = new sendReadByDataid2(); + sre.execute(processinstid,taskid); + } + System.out.println("定时器执行完毕,请重新查看数据是否执行成功"); + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/SendReadBycontract.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/SendReadBycontract.java new file mode 100644 index 00000000..7eeb7b63 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/SendReadBycontract.java @@ -0,0 +1,1331 @@ +package com.awspaas.user.apps.integration.job; + +import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst; +import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; +import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager; +import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile; +import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb; +import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +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.database.RowMap; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.schedule.IJob; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.server.fs.DCContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.bpms.util.UtilString; +import com.actionsoft.emm.util.AesUtil; +import com.actionsoft.exception.AWSException; +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 com.awspaas.user.apps.integration.util.HttpUtil; +import com.awspaas.user.apps.integration.util.UtilUrl; +import org.apache.commons.lang.StringUtils; +import org.docx4j.wml.P; +import org.docx4j.wml.U; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * 以单个流程形式发送OA待阅 + */ +public class SendReadBycontract implements IJob { + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + String jobParameter = SDK.getJobAPI().getJobParameter(jobExecutionContext); + String taskid = jobParameter.split(",")[1]; + String processid = jobParameter.split(",")[0]; + ProcessInstance instanceById = SDK.getProcessAPI().getInstanceById(processid); + TaskInstance taskInstance = SDK.getTaskAPI().getInstanceById(taskid); + String wsId = ""; + JSONArray filed = new JSONArray(new LinkedList<>()); + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + //System.out.println("portal======>>>>"+portalUrl); + /*if (portalUrl.equals("http://10.114.11.135:8088/portal")){ + portalUrl = "http://bpm.yili.com:8088/portal/"; + }*/ + try { + + + String url = portalUrl + "/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + String mobileurl = "https://bpm.yili.com:8088/portal" + "/r/or?cmd=com.yili_process_page_phone&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Timestamp endTime = instanceById.getStartTime(); + BO boActCoePublish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", instanceById.getId()).addQuery("OPTIONTYPE IS NOT NULL",null).detail(); + + +//ProcessExecutionContext processExecutionContext,String fileCreateName,String fileName,String fileurl,String readingScope_org,String isFullCompany,String fileCreateDate,String relationProcessinstId,String readingScope_post,String readingScope_level,String fileid + String not_url = "/w?cmd=com.yili_process_page&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + + + JSONObject jsonObject = new JSONObject(new LinkedHashMap()); + jsonObject.put("action", "read"); + jsonObject.put("title", " " + + "" + boActCoePublish.getString("PROCESS_TITLE") + ""); + //System.out.println("部门庄户》》》》》》》" + SDK.getORGAPI().getDepartmentByUser(taskInstance.getTarget()).getNo()); + jsonObject.put("dept", SDK.getORGAPI().getDepartmentByUser(taskInstance.getTarget()).getNo());//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo() + String target = taskInstance.getTarget(); + target = taskInstance.getTarget(); + + //System.out.println("当前账户======》》》》" + target); + + jsonObject.put("user", target); + + // jsonObject.put("user",);//processExecutionContext.getProcessInstance().getCreateUser() + jsonObject.put("date", sdf.format(endTime)); + jsonObject.put("remark", boActCoePublish.getString("PROCESS_TITLE")); + jsonObject.put("status", "0"); + jsonObject.put("dataid", instanceById.getId()); + jsonObject.put("pcurl", url); + jsonObject.put("mobileurl", mobileurl); + //list.add(1,"00352394"); + //list.add(2,"00352394"); + BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processid).addQuery("OPTIONTYPE IS NOT NULL",null).detail(); + String uid = ""; + String new_uid = ""; + /** + * 这块的判断主要是将组织,岗位,职级进行合并集进行相关的判断获取人员账户合集 + */ + + if(bo_act_coe_publish1!=null) { + String da = bo_act_coe_publish1.getString("SEND_SCOP"); + + ArrayList userList = new ArrayList<>(); + ArrayList userList2 = new ArrayList(); + + if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_ORG"))||"1".equals(da)) { + long startTime = System.currentTimeMillis(); + userList = getUser(bo_act_coe_publish1.getString("SEND_SCOPE_ORG"), bo_act_coe_publish1.getString("SEND_SCOP"), processid); + long endTimes = System.currentTimeMillis(); + System.out.println(instanceById.getTitle()+"_根据部门获取人员用时===>"+(endTimes-startTime)/1000); + } + + if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_POST"))) { + String posts[] = bo_act_coe_publish1.getString("SEND_SCOPE_POST").split(","); + //取并集 + String postss = ""; + if (posts.length == 1) { + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + postss = "'" + posts[0] + "'"; + } else { + postss = "'" + StringUtils.join(posts, "','") + "'"; + } + String sql = "select * from ORGUSER where POSITION_NO in (" + postss + ") and userno is not null"; + List maps1 = DBSql.getMaps(sql); + for (RowMap rowMap : maps1) { + String userId = rowMap.getString("USERID"); + if (!userList.contains(userId)) { + userList.add(userId); + } + + } + } + if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL"))) { + String ranks[] = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL").split(","); + String rankss = ""; + if (ranks.length == 1) { + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + rankss = "'" + ranks[0] + "'"; + } else { + rankss = "'" + StringUtils.join(ranks, "','") + "'"; + } + //取交集 + + + String sql2 = "select * from ORGUSER where EXT2 in (" + rankss + ") and userno is not null"; + List maps2 = DBSql.getMaps(sql2); + for (RowMap rowMap : maps2) { + String userId = rowMap.getString("USERID"); + if (userList.contains(userId)) { + userList2.add(userId); + } + + } + } + + if (StringUtils.isEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL"))) { + + for (String uids : userList + ) { + uid += uids + ","; + + BO bo = new BO();//BO_EU_PAL_SEND_LOG + bo.set("USREID",instanceById.getCreateUser()); + bo.set("TITLE",instanceById.getTitle()); + bo.set("SENDTIME",instanceById.getEndTime()); + bo.set("PROCESSID",instanceById.getId()); + bo.set("USERNAMES",uids); + bo.set("DEPID",UserContext.fromUID(uids).getDepartmentModel().getId() + ); + bo.set("POSTNAME",UserContext.fromUID(uids).getUserModel().getPositionName() + ); + bo.set("BUNAME",UserContext.fromUID(uids).getUserModel().getExt2() + ); + SDK.getBOAPI().createDataBO("BO_EU_PAL_SEND_LOG",bo,UserContext.fromUID("admin")); + } + + + } else { + for (String uids : userList2 + ) { + uid += uids + ","; + BO bo = new BO();//BO_EU_PAL_SEND_LOG + bo.set("USREID",instanceById.getCreateUser()); + bo.set("TITLE",instanceById.getTitle()); + bo.set("SENDTIME",instanceById.getEndTime()); + bo.set("PROCESSID",instanceById.getId()); + bo.set("USERNAMES",uids); + bo.set("DEPID",UserContext.fromUID(uids).getDepartmentModel().getId() + ); + bo.set("POSTNAME",UserContext.fromUID(uids).getUserModel().getPositionName() + ); + bo.set("BUNAME",UserContext.fromUID(uids).getUserModel().getExt2() + ); + SDK.getBOAPI().createDataBO("BO_EU_PAL_SEND_LOG",bo,UserContext.fromUID("admin")); + } + } + //System.out.println("部门id》》》》》》》》》》》》》"+org_list ); + //System.out.println("posts_list》》》》》》》》》》》》》"+posts_list); + //System.out.println("ranks_list》》》》》》》》》》》》》"+ranks_list); + //System.out.println("部门数量》》》》》》》》》》》》》"+org_list.size() ); + //System.out.println("岗位数量》》》》》》》》》》》》》"+posts_list.size()); + //System.out.println("职级数量》》》》》》》》》》》》》"+ranks_list.size()); + + } + + + + + // //System.out.println("userid》》》》》》》》》》》》》》》》》》》"+uid); + if (StringUtils.isNotEmpty(uid + )) { + + uid = uid.substring(0, uid.length() - 1); + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + for (String userid:list + ) { + new_uid+=userid+","; + // //System.out.println("当前账户======》》》》"+userid); + // BO boEuOaReson = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("WORKCODE=", userid).detail(); + // if (boEuOaReson!=null){ + /* BO bo = new BO(); + bo.set("USER_CODE",userid); + bo.set("USER_NAME",SDK.getORGAPI().getUser(userid).getUserName()); + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().createDataBO("BO_EU_YEUWS",bo,userContext);*/ + // } + + } + System.out.println("总推送人数>>>>>>>>>>>>"+list.size()); + } + + System.out.println("账户人员信息>>>>>>>>>>>>>"+new_uid); + + long startTime = System.currentTimeMillis(); +/** + * 对新的账户信息进行截取 + */ + if (StringUtils.isNotEmpty(new_uid + )) { + new_uid = new_uid.substring(0, new_uid.length() - 1); + } + /** + * 这块是对人员以300人为一个发送单位来实现进程的待阅发送 + */ + //System.out.println("new_userid ==========>>>>>>>>>"+new_uid); + String[] users = new_uid.split(","); + int length = 300; + int ys = users.length%length; + if (ys==0) { + int size = users.length/length; + int flag = 0; + + List list = new LinkedList(); + + for (int i=0;i list = new LinkedList(); + for (int i=0;i bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID=", instanceById.getId()).list(); + List bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).addQuery("BINDID=", instanceById.getId()).list(); + List bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).addQuery("BINDID=", instanceById.getId()).list(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + + JSONArray jsonArray = new JSONArray(); + + +/** + * 这里是去生成EHSQ相关数据 + */ + /* for (BO bo:bo_act_coe_publish_n + ) { + JSONArray jsonArray_EHSQ = new JSONArray(); + JSONObject jsonObject_ehsq = new JSONObject(new LinkedHashMap<>()); + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("PUBLISHFILEID"); + LinkedHashMap downloadurl = downloadUtil.outputReportDownload(UserContext.fromUID(processExecutionContext.getProcessInstance().getCreateUser()), bo.getString("TASKID"), publishfileid); + jsonObject_ehsq.put("fileid",bo.getString("TASKID")); + jsonObject_ehsq.put("filename",bo.getString("PUBLISHFILENAME")); + //jsonObject_ehsq.put("filecode",bo.getString("PUBLISH_NUMBER")); + jsonObject_ehsq.put("filecode","123456"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+publishfileid+"'"; + RowMap map = DBSql.getMap(sql_n); + jsonObject_ehsq.put("version",map.getString("PLVER")); + jsonObject_ehsq.put("releasedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("effectivedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("authorcode",processExecutionContext.getTaskInstance().getTarget()); + // jsonObject_ehsq.put("authorcode","00116465"); + jsonObject_ehsq.put("authorname",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); + //jsonObject_ehsq.put("authorname","毛鹏程"); + jsonObject_ehsq.put("companycode",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo()); + //jsonObject_ehsq.put("companycode","00000013"); + jsonObject_ehsq.put("authorcompany",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); + //jsonObject_ehsq.put("authorcompany","总部质量管理部"); + // jsonObject_ehsq.put("releasescope","总部质量管理部"); + BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true).addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); + if (bo1!=null){ + if (bo1.getString("PERMTYPE").equals("1")){ + }else { + + String departname = ""; + String orgperm = bo1.getString("ORGPERM"); + String dleass = ""; + String[] deptSplit = orgperm.split(","); + if(deptSplit.length==1){ + dleass = "'"+deptSplit[0]+"'"; + } + dleass ="'"+ StringUtils.join(deptSplit, "','")+"'"; + + List maps = DBSql.getMaps("select DEPARTMENTNAME from ORGDEPARTMENT where ID in (" + dleass + ")"); + for (RowMap rowmas:maps + ) { + departname+=rowmas.getString("DEPARTMENTNAME")+";"; + } + jsonObject_ehsq.put("releasescope","总部质量管理部"); + + } + } + + System.out.println("任务办理者>>>>>>>>>>>"+processExecutionContext.getTaskInstance().getTarget()); + String sessionId = new SSOUtil().registerClientSessionNoPassword(processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", LoginConst.DEVICE_PC); + + System.out.println("办理者的sessionid>>>>>>>>>>>"+sessionId); + String downurl = downloadUtil.getzipURL(sessionId,bo.getString("TASKID"),bo.getString("PUBLISHFILENAME")); + //jsonObject_ehsq.put("downloadurl","http://bpm.yili.com:8088/portal/r"+downurl.toString().substring(1)); + + String recordfiles = ""; + String recordurls = ""; + Set keys = downloadurl.keySet(); + for ( String key : keys ) { + recordfiles+=key+";"; + String cent_url = downloadurl.get(key).substring(downloadurl.get(key).indexOf("/df"),downloadurl.get(key).length()); + String fileDownurl = "http://bpm.yili.com:8088/portal/r"+cent_url; + recordurls+=fileDownurl+";"; + } + String new_name = ""; + String[] split = recordfiles.split(";"); + if (split.length>0){ + + for (int i =1;i0){ + String loadurl = urls[0].replaceAll("&sid=null","&sid="+sessionId); + System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<"+loadurl); + jsonObject_ehsq.put("downloadurl",loadurl); + for (int i =1;i()); + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("CHANGEDFILEIDNEW"); + LinkedHashMap downloadurl = downloadUtil.outputReportDownload(UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()), bo.getString("TASKID"), publishfileid); + jsonObject_ehsq.put("fileid",bo.getString("TASKID")); + jsonObject_ehsq.put("filename",bo.getString("CHANGEDFILENAMENEW")); + //jsonObject_ehsq.put("filecode",bo.getString("CHANGE_NUMBER")); + jsonObject_ehsq.put("filecode","123456"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+publishfileid+"'"; + RowMap map = DBSql.getMap(sql_n); + jsonObject_ehsq.put("verion",map.getString("PLVER")); + jsonObject_ehsq.put("releasedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("effectivedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("authorcode",processExecutionContext.getTaskInstance().getTarget()); + jsonObject_ehsq.put("authorname",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); + jsonObject_ehsq.put("companycode",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo()); + jsonObject_ehsq.put("authorcompany",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); + BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true).addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); + if (bo1!=null){ + if (bo1.getString("PERMTYPE").equals("1")){ + jsonObject_ehsq.put("releasescope","内蒙古伊利实业集团股份有限公司"); + }else { + + String departname = ""; + String orgperm = bo1.getString("ORGPERM"); + String dleass = ""; + String[] deptSplit = orgperm.split(","); + if(deptSplit.length==1){ + dleass = "'"+deptSplit[0]+"'"; + } + dleass ="'"+ StringUtils.join(deptSplit, "','")+"'"; + + List maps = DBSql.getMaps("select DEPARTMENTNAME from ORGDEPARTMENT where ID in (" + dleass + ")"); + for (RowMap rowmas:maps + ) { + departname+=rowmas.getString("DEPARTMENTNAME")+";"; + } + jsonObject_ehsq.put("releasescope",departname); + + } + } + + String sessionId = new SSOUtil().registerClientSessionNoPassword(processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", LoginConst.DEVICE_PC); + + String downurl = downloadUtil.getzipURL(sessionId,bo.getString("TASKID"),bo.getString("CHANGEDFILENAMENEW")); + String recordfiles = ""; + String recordurls = ""; + Set keys = downloadurl.keySet(); + for ( String key : keys ) { + recordfiles+=key+";"; + String cent_url = downloadurl.get(key).substring(downloadurl.get(key).indexOf("/df"),downloadurl.get(key).length()); + String fileDownurl = "http://bpm.yili.com:8088/portal/r"+cent_url; + recordurls+=fileDownurl+";"; + } + String new_name = ""; + String[] split = recordfiles.split(";"); + if (split.length>0){ + + for (int i =1;i0){ + String loadurl = urls[0].replaceAll("&sid=null","&sid="+sessionId); + System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<"+loadurl); + jsonObject_ehsq.put("downloadurl",loadurl); + for (int i =1;i>>>>>>"+map); + System.out.println("fileid==》》》》"+fileid); + System.out.println("id==》》》》"+map.getString("ID")); + RowMap rowMap = DBSql.getMap("SELECT * FROM " + bo_name + " where " + fileid + " '" + map.getString("ID") + "'"); + //BO bos = SDK.getBOAPI().query(bo_name,true).addQuery(fileid,"17e7d198-1656-4a2c-8912-a81850170be9").detail(); + if (rowMap!=null){ + + if (StringUtils.isNotEmpty(rowMap.getString("TASKID"))) { + + OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID")); + if (model != null) { + System.out.println(",pdel============" + model); + System.out.println("123313123123123==========" + model.getProfileId()); + OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId()); + System.out.println("dajadfas======" + appProfile); + if (appProfile == null) { + throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId()); + } + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + String sql_lever =""; + if (bo_name.equals("BO_ACT_COE_PUBLISH_N")){ + sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + rowMap.getString("PUBLISHFILEID") + "'"; + + }else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")){ + sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + rowMap.getString("CHANGEDFILEIDNEW") + "'"; + } + String lever = DBSql.getString( sql_lever); + System.out.println("版本号::::::::::::"+lever); + //lever = lever.substring(0,3); + if(lever.length()==5&&lever.substring(4).equals("0")){ + lever.substring(0,3); + }else if (lever.length()==1){ + lever=lever+".0"; + } + String filename = ""; + if (bo_name.equals("BO_ACT_COE_PUBLISH_N")){ + filename = rowMap.getString("PUBLISHFILENAME"); + }else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")){ + filename = rowMap.getString("CHANGEDFILENAMENEW"); + } + DCContext dcContext = new DCContext(userContext, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), rowMap.getString("TASKID"), filename+ "_" + lever+ ".doc"); + //UtilFile file = new UtilFile(dcContext.getPath()); + + + Map params = new HashMap(); +//知识ID,必填 + params.put("cardId", cardId); +//sid,必填 + params.put("sid", userContext.getSessionId()); + + params.put("dc", dcContext); + AppAPI appAPI = SDK.getAppAPI(); +//创建文件 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("流程手册的存入=================" + ro); + } + } + + } + String sql_A = "SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where ID = '"+map.getString("ID")+"' AND PLMETHODID != 'process.framework' AND PLMETHODID IN (select distinct PLMETHODID from APP_ACT_COE_PAL_REPOSITORY)"; + List rows = DBSql.getMaps(sql_A); + + for (RowMap bo:rows + ) { + + /** + * 这个是模型中的附件获取的并插入的数据信息,需要做修改 + */ + // 调用App + +// 参数定义列表 + Map paramss = new HashMap(); +//知识ID,必填 + paramss.put("cardId", cardId); +//sid,必填 + paramss.put("sid", userContext.getSessionId()); + + UpfileWeb upfileWeb = new UpfileWeb(userContext); + + + + String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID != 'process.framework' AND ID= '"+map.getString("ID")+"'" + + ")"; + List maps = DBSql.getMaps(sql_upfile); + for (RowMap row : maps) { + System.out.println("附件名称>>>>>>"+row.getString("FILENAME")); + if (!row.getString("FILENAME").contains(".xml")){ + UpfileModel upfileModel = new UpfileModel(); + upfileModel.setType(row.getString("FILETYPE")); + upfileModel.setFileName(row.getString("FILENAME")); + upfileModel.setPl_uuid(row.getString("PALREPOSITORYID")); + upfileModel.setShape_uuid(row.getString("SHAPEID")); + DCContext dcContexts = upfileWeb.getDCContext(upfileModel); + paramss.put("dc", dcContexts); + AppAPI appAPIs = SDK.getAppAPI(); + ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, paramss); + System.out.println("流程模型附件的生成============="+ros); + } + } + +//DCContext对象,必填 + +//创建文件 + } + try { + + PublishKnow(processInstance,userContext,cardId); + }catch (Exception e){ + e.printStackTrace(); + } + } + } + + + /** + * 发布知识 + * @param processInstance + * @param userContext + * @param id + */ + public void PublishKnow(ProcessInstance processInstance,UserContext userContext,String id){ + + String sql = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id in (select PLPARENTID from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '"+id +"')"; + List maps = DBSql.getMaps(sql); + String ids = ""; + for (RowMap rowmap:maps + ) { + ids+=rowmap.getString("EXT4")+","; + } + String[] deptSplit_id = ids.split(","); + + JSONArray jsonArray = new JSONArray(); + for (String id_names:deptSplit_id + ) { + jsonArray.add(id_names); + } + //jsonObject.put(deptSplit_id); + id+=","; + String[] deptSplit_das = id.split(","); + JSONArray jsonArray_das = new JSONArray(); + for (String das:deptSplit_das + ) { + jsonArray_das.add(das); + } + //jsonObject.put(deptSplit_id); + + if (!jsonArray_das.isEmpty()&&!jsonArray.isEmpty()){ + + // 调用App + String sourceAppId = processInstance + .getAppId(); +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl"; +// 参数定义列表 + Map params = new HashMap(); +//要发布到的维度ID的JSON数组字符串,必填 + params.put("dimensionIDArray", jsonArray.toString()); +//要发布的知识ID的JSON数组字符串,必填 + params.put("knwlIDArray", jsonArray_das.toString()); +//标签的JSON数组字符串,非必填 + +//sid,必填 + params.put("sid", userContext.getSessionId()); + AppAPI appAPI = SDK.getAppAPI(); +//发布知识 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + + System.out.println("知识发布============"+ro); + + } + + } + + /** + * 取消发布知识 + * @param processInstance + * @param sid + * @param knwlId + * @return + */ + public boolean CancelPublishKnwl(ProcessInstance processInstance,String sid,String knwlId) { +// 调用App + String sourceAppId = processInstance.getAppId(); +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/CancelPublishKnwl"; +// 参数定义列表 + Map params = new HashMap(); +//sid,如果为空,则需要传createUser参数,非必填 + params.put("sid", sid); +//知识ID,必填 + params.put("knwlId", knwlId); + AppAPI appAPI = SDK.getAppAPI(); +//取消发布知识(全部维度) + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("取消发布的ro=====>>>>"+ro); + return ro.isOk(); + } + + /** + * 创建XPage页面上的待阅 + * @param processExecutionContext + * @param fileCreateName + * @param fileName + * @param fileurl + * @param readingScope_org + * @param isFullCompany + * @param fileCreateDate + * @param relationProcessinstId + * @param readingScope_post + * @param readingScope_level + * @param fileid + * @return + */ + public boolean execute(ProcessExecutionContext processExecutionContext,String fileCreateName,String fileName,String fileurl,String readingScope_org,String isFullCompany,String fileCreateDate,String relationProcessinstId,String readingScope_post,String readingScope_level,String fileid) { +// 调用App + String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); +// aslp服务地址 + String aslp = "aslp://com.awspaas.user.apps.docview/PushFileToXpage"; +// 参数定义列表 + Map params = new HashMap(); +//发布人,不允许空值,必填 + params.put("fileCreateName", fileCreateName); +//待阅文件标题名称,不允许空值,必填 + params.put("fileName", fileName); +//阅读范围_组织,不允许空值,非必填 + params.put("readingScope_org", readingScope_org); +//是否全公司可见,不允许空值,必填 + params.put("isFullCompany", isFullCompany); +//待阅文件Url,不允许空值,必填 + params.put("fileurl", fileurl); +//发布日期,不允许空值,必填 + params.put("fileCreateDate", fileCreateDate); +//发布流程ID,不允许空值,必填 + params.put("relationProcessinstId", relationProcessinstId); +//阅读范围_岗位,不允许空值,非必填 + params.put("readingScope_post", readingScope_post); +//阅读范围_职级,不允许空值,非必填 + params.put("readingScope_level", readingScope_level); +//待阅文件ID,多个逗号隔开,不允许空值,必填 + params.put("fileid", fileid); + AppAPI appAPI = SDK.getAppAPI(); +//推送待阅文件到xpage门户 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("ros++++++++=====待阅》》》》》》》》》》"+ro); + return ro.isOk(); + } + + + /** + * 给知识授权 + * @param processInstance + * @param jsonArray + * @param sid + * @param knwlId + * @return + */ + public boolean AddKnwlAC(ProcessInstance processInstance,JSONArray jsonArray,String sid,String knwlId) { +// 调用App + String sourceAppId = processInstance.getAppId(); +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC"; +// 参数定义列表 + Map params = new HashMap(); +//[{"assignmentType":"department","assignmentId":"62196ff9-a26d-4be5-9480-3ef680886f63"},{"assignmentType":"user","assignmentId":"user1"}],必填 + params.put("acList", jsonArray); +//sid,如果为空,则需要传createUser参数,非必填 + params.put("sid", sid); +//知识ID,必填 + params.put("knwlId", knwlId); + AppAPI appAPI = SDK.getAppAPI(); +//给知识授权 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + return ro.isOk(); + } + + + /** + * 柱军代码,不知道做什么用的 + * @param processInstance + * @param wsId + * @param fileId + * @return + */ + public boolean AttrSynAslp(ProcessInstance processInstance, String wsId, JSONArray fileId){ + System.out.println(""); + // 调用App + String sourceAppId = processInstance.getAppId(); +// aslp服务地址 + String aslp = "aslp://com.awspaas.user.apps.yili.reportform/AttrSynAslp"; +// 参数定义列表 + Map params = new HashMap(); +//资产内容库id,必填 + params.put("wsId", wsId); +//文件id;json数组[id1,id2,id3],必填 + params.put("fileId", fileId); + AppAPI appAPI = SDK.getAppAPI(); +//增量同步数据 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("ro>>>>>>>>>>>>>"+ro); + return ro.isOk(); + } + + /** + * 发送OA待阅数据 + * @param jsonObject + * @param processInstance + * @param results + * @throws DocumentException + */ + public void SendOARead(JSONObject jsonObject,ProcessInstance processInstance,String[] results) throws DocumentException { + String userId = ""; + userId = StringUtils.join(results, ","); + jsonObject.put("userList",userId); + + + String xmlStr = "\n" + + " " + + " " + + " " + + " " + + ""+ + " " + + " " + + " " + + ""; + System.out.println("xmlStr>>>>>>>>"+xmlStr); + String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl"); + + String postSoap = UtilUrl.doPostSoap(readurl, xmlStr, ""); + Document document = DocumentHelper.parseText(postSoap); + Element rootElement = document.getRootElement(); + System.out.println("rootElement>>>>>>"+rootElement); + Element result = rootElement.element("Body").element("serviceResponse").element("out"); + String resultString = result.getData().toString(); + JSONObject jsonObject1 = JSON.parseObject(resultString); + String datas = jsonObject1.getString("data"); + String status = jsonObject1.getString("status"); + System.out.println("状态是什么》》》》》》》》》》》"+status); + JSONArray resultArray = JSONObject.parseArray(datas); + for (int j=0;j>>>>>>>>>>>"+s1); + String data = system+"##"+s1; + String encrypt = aesUtil.encrypt(data, AES); //获取加密之后的秘钥 + JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); + jsonObject.put("system",system); + jsonObject.put("token",encrypt); + jsonObject.put("infos",jsonArray); + HttpUtil httpUtil = new HttpUtil(); + System.out.println("jsonobject>>>>>>>>>>>>>>>>>>>"+jsonObject); + String s = httpUtil.sendPost(jsonObject, EHSQUrl); + System.out.println("发送到EHSQ是否是正确的>>>>>>>>>"+s); + + return s; + } + + /** + * 根据部门id获取当前部门以及下级部门的人员信息 + * @param processid + * @return + */ + public ArrayList getUser (String depIds,String isSend,String processid) { + ArrayList arr = new ArrayList(); + if(UtilString.isNotEmpty(depIds)) { + //全集团 + if("1".equals(isSend)) { + List departmentsByCompanyId = SDK.getORGAPI().getDepartmentsByCompanyId(1, "8911e732-b42a-4556-853f-ad32761bcbee"); + for (DepartmentModel departmentModel : departmentsByCompanyId) { + + getUserList(arr, departmentModel.getId(),processid); + } + }else { + //具体部门 + String[] split = depIds.split(","); + for (String depId : split) { + getUserList(arr, depId,processid); + } + } + + } + return arr; + } + + public void getUserList(ArrayList arr, String departmentId,String processid) { + // 获取当前部门下人员 + List userModelList = SDK.getORGAPI().getAllUsersByDepartment(departmentId); + for (UserModel userModel : userModelList) { + if(!userModel.isClosed()) { + if(!arr.contains(userModel.getUID())) { + BO boList = SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processid).addQuery("USER_ID=", userModel.getUID()).detail(); + if (boList==null) { + arr.add(userModel.getUID()); + } + } + } + } + // 获取当前部门的子部门人员 + DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(departmentId); + if(departmentById.isExistSubModelOfCache()) { + getSubDepartments(arr, departmentById,processid); + } + + } + //获取子部门人员 + public void getSubDepartments(ArrayList arr,DepartmentModel departmentById,String processid) { + if(!departmentById.isClosed()) { + List subDepartments = SDK.getORGAPI().getSubDepartments(departmentById.getId()); + for (DepartmentModel departmentModel : subDepartments) { + String id = departmentModel.getId(); + List userModelList = SDK.getORGAPI().getAllUsersByDepartment(id); + for (UserModel userModel : userModelList) { + if (!userModel.isClosed()) { + if (!arr.contains(userModel.getUID())) { + BO boList = SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processid).addQuery("USER_ID=", userModel.getUID()).detail(); + if (boList==null) { + arr.add(userModel.getUID()); + } + } + } + } + //递归获取子部门下的子部门 + } + } + } + + /** + * 创建更新的知识 + * @param bo + * @param wsId + * @param filed + * @param instanceById + * @param bo_act_coe_publish + * @param uid + */ + public void CreateKmsByUpdate(BO bo,String wsId,JSONArray filed,ProcessInstance instanceById,BO bo_act_coe_publish,String uid){ + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("CHANGEDFILEIDNEW"); + filed.add(publishfileid) + + + ; + DBSql.update("update APP_ACT_COE_PAL_REPOSITORY set EXT4 = '' where id = '"+publishfileid+"'"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+publishfileid+"'"; + RowMap map = DBSql.getMap(sql_n); + if (StringUtils.isEmpty(map.getString("EXT4"))){ + // aslp服务地址 + String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl"; +// 参数定义列表 + Map params_create = new HashMap(); +//保密级别, 0: 普通 1:秘密 2:机密,必填 + params_create.put("securityLevel", 0); +//知识名称,必填 + String level = ""; + if (map!=null){ + if (map.getString("PLVER").contains(".00")){ + String[] plvers = map.getString("PLVER").split("\\."); + plvers[1] = plvers[1].replaceAll("0",""); + level = plvers[0]+plvers[1]; + }else { + level = map.getString("PLVER"); + } + } + + + params_create.put("knwlName", map.getString("PLNAME")+"V"+level); +//是否可以评论,必填 + params_create.put("isComment", true); +//是否可以评分,必填 + params_create.put("isRate", true); +//有效期:yyyy-MM-dd,非必填 + params_create.put("validDate", "2099-12-31"); +//只读控制,1:在线阅读和下载 0:在线阅读,必填 + params_create.put("onlineLevel", 1); +//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填 + params_create.put("createUser", "admin"); +//知识内容,非必填 + params_create.put("cardContext", ""); +//sid,必填 + params_create.put("sid", UserContext.fromUID(instanceById.getCreateUser()).getSessionId()); + AppAPI appAPI_create = SDK.getAppAPI(); +//创建知识 + ResponseObject ro_create = appAPI_create.callASLP(appAPI_create.getAppContext(instanceById.getAppId()), aslps_create, params_create); + System.out.println("ro_create================"+ro_create); + String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); + JSONArray jsonArray1 = new JSONArray(); + if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")){ + String departId = bo_act_coe_publish.getString("SEND_SCOPE_ORG"); + if (StringUtils.isNotEmpty(departId)&&StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_LEVEL"))&&StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_POST"))){ + String strs[] = departId.split(","); + for (String departmentid:strs + ) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType","department"); + jsonObjecta.put("assignmentId",departmentid); + jsonArray1.add(jsonObjecta); + } + }else{ + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + + for (String user_id:list + ) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType","user"); + jsonObjecta.put("assignmentId",user_id); + jsonArray1.add(jsonObjecta); + } + } + + }else{ + List select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT"); + for (RowMap depaid: + select_id_from_orgdepartment) { + String id = depaid.getString("ID"); + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType","department"); + jsonObjecta.put("assignmentId",id); + jsonArray1.add(jsonObjecta); + } + } + AddKnwlAC(instanceById,jsonArray1,UserContext.fromUID(instanceById.getCreateUser()).getSessionId(),cardId); + + String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '"+cardId+"' WHERE " + + " PLCATEGORY = 'process'and PLMETHODID !='process.framework' " + + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + " '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + " '42c09260-c1d3-44b7-ac3d-f8280e04c294') and ID = '"+publishfileid+"'"; + int update = DBSql.update(update_sql); + System.out.println("更新id为:"+publishfileid+"版本为:的知识对应的资产库的EXT4的影响行数为"+update); + creadteFile(instanceById,"BO_ACT_COE_PUBLISH_C", UserContext.fromUID(instanceById.getCreateUser()),cardId," CHANGEDFILEIDNEW="); + } + //将旧的知识取消发布或者移动到废止发布中 + String publishfileid_old = bo.getString("CHANGEFILEID"); + String sql_c = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+publishfileid_old+"'"; + RowMap map1 = DBSql.getMap(sql_c); + if (StringUtils.isNotEmpty(map1.getString("EXT4"))){ + CancelPublishKnwl(instanceById,UserContext.fromUID(instanceById.getCreateUser()).getSessionId(),map1.getString("EXT4")); + DBSql.update( + "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '"+publishfileid_old+"'" + ); + } + } + + public void CreateKmsBynew(BO bo,String wsId,JSONArray filed,ProcessInstance instanceById,BO bo_act_coe_publish,String uid){ + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("PUBLISHFILEID"); + filed.add(publishfileid); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+publishfileid+"'"; + RowMap map = DBSql.getMap(sql_n); + if (StringUtils.isEmpty(map.getString("EXT4"))){ + // aslp服务地址 + String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl"; +// 参数定义列表 + Map params_create = new HashMap(); +//保密级别, 0: 普通 1:秘密 2:机密,必填 + params_create.put("securityLevel", 0); +//知识名称,必填 + + String level = ""; + + + if (map.getString("PLVER").contains(".00")){ + String[] plvers = map.getString("PLVER").split("\\."); + plvers[1] = plvers[1].replaceAll("0",""); + level = plvers[0]+plvers[1]; + }else { + level = map.getString("PLVER"); + } + + params_create.put("knwlName", map.getString("PLNAME")+"V"+level); +//是否可以评论,必填 + params_create.put("isComment", true); +//是否可以评分,必填 + params_create.put("isRate", true); +//有效期:yyyy-MM-dd,非必填 + params_create.put("validDate", "2099-12-31"); +//只读控制,1:在线阅读和下载 0:在线阅读,必填 + params_create.put("onlineLevel", 1); +//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填 + params_create.put("createUser", "admin"); +//知识内容,非必填 + params_create.put("cardContext", ""); +//sid,必填 + params_create.put("sid", UserContext.fromUID(instanceById.getCreateUser()).getSessionId()); + AppAPI appAPI_create = SDK.getAppAPI(); +//创建知识 + ResponseObject ro_create = appAPI_create.callASLP(appAPI_create.getAppContext(instanceById.getAppId()), aslps_create, params_create); + System.out.println("ro_create================"+ro_create); + String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); + JSONArray jsonArray1 = new JSONArray(); + if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")){ + String departId = bo_act_coe_publish.getString("SEND_SCOPE_ORG"); + if (StringUtils.isNotEmpty(departId)&&StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_LEVEL"))&&StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_POST"))) { + String strs[] = departId.split(","); + for (String departmentid : strs + ) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", departmentid); + jsonArray1.add(jsonObjecta); + } + }else{ + + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + + for (String user_id:list + ) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType","user"); + jsonObjecta.put("assignmentId",user_id); + jsonArray1.add(jsonObjecta); + } + } + }else{ + List select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT"); + for (RowMap depaid: + select_id_from_orgdepartment) { + String id = depaid.getString("ID"); + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType","department"); + jsonObjecta.put("assignmentId",id); + jsonArray1.add(jsonObjecta); + } + } + + + AddKnwlAC(instanceById,jsonArray1,UserContext.fromUID(instanceById.getCreateUser()).getSessionId(),cardId); + + String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '"+cardId+"' WHERE " + + " PLCATEGORY = 'process'and PLMETHODID !='process.framework' " + + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + " '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + " '42c09260-c1d3-44b7-ac3d-f8280e04c294') and ID = '"+publishfileid+"'"; + int update = DBSql.update(update_sql); + System.out.println("更新id为:"+publishfileid+"版本为:的知识对应的资产库的EXT4的影响行数为"+update); + creadteFile(instanceById,"BO_ACT_COE_PUBLISH_N", UserContext.fromUID(instanceById.getCreateUser()),cardId,"PUBLISHFILEID = "); + } + } + + /** + * 以线程进行发送待阅信息 + * @param list + * @param startTime + * @param jsonObject + * @param instanceById + */ + public void corse(List list,long startTime,JSONObject jsonObject,ProcessInstance instanceById ){ + // 创建线程来实现为每300人为一个的线程跑待阅 + ExecutorService service = Executors.newFixedThreadPool(4); + service.execute(new Runnable() { + @Override + public void run() { + int i=0; + for (String[] resrt:list + ) { + if ((list.size()-1)==i){ + long endTime = System.currentTimeMillis(); + + long time = endTime - startTime; + long itmes = time/1000/60/60; + BO bo_eu_pal_read_log = SDK.getBOAPI().query("BO_EU_PAL_READ_LOG", true).addQuery("PROCESSID = ", instanceById.getId()).detail(); + bo_eu_pal_read_log.set("ENDTIMES",endTime); + bo_eu_pal_read_log.set("TIMECOUNT",itmes); + SDK.getBOAPI().update("BO_EU_PAL_READ_LOG",bo_eu_pal_read_log); + } + try { + SendOARead(jsonObject,instanceById,resrt); + } catch (DocumentException e) { + e.printStackTrace(); + } + i++; + } + } + }); + } + + /** + * 创建待阅日志信息 + * @param instanceById + * @param jsonObject + * @param users + * @param startTime + */ + public void CreateReadLog(ProcessInstance instanceById,JSONObject jsonObject,String[] users,long startTime){ + BO bo_Read_log = new BO(); + bo_Read_log.set("USREID",instanceById.getCreateUser()); + bo_Read_log.set("DEPID",UserContext.fromUID(instanceById.getCreateUser()).getDepartmentModel().getId()); + bo_Read_log.set("BUNAME",UserContext.fromUID(instanceById.getCreateUser()).getUserModel().getExt4()); + bo_Read_log.set("TITLE",jsonObject.get("title")); + bo_Read_log.set("PROCESSID",instanceById.getId()); + bo_Read_log.set("SENDNUM",users.length); + BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", instanceById.getId()).addQuery("OPTIONTYPE IS NOT NULL",null).detail(); + String send_scop = bo_act_coe_publishs.getString("SEND_SCOP"); + bo_Read_log.set("SEND_SCOP",send_scop); + String SEND_SCOPE_ORG = bo_act_coe_publishs.getString("SEND_SCOPE_ORG"); + if (UtilString.isNotEmpty(SEND_SCOPE_ORG)){ + String[] resulr = SEND_SCOPE_ORG.split(","); + bo_Read_log.set("SEND_SCOPE_ORGNUM",resulr.length); + } + String SEND_SCOPE_POST = bo_act_coe_publishs.getString("SEND_SCOPE_POST"); + if (UtilString.isNotEmpty(SEND_SCOPE_POST)){ + String[] resulr = SEND_SCOPE_POST.split(","); + bo_Read_log.set("SEND_SCOPE_POST_NUM",resulr.length); + } + String SEND_SCOPE_LEVEL = bo_act_coe_publishs.getString("SEND_SCOPE_LEVEL"); + if (UtilString.isNotEmpty(SEND_SCOPE_LEVEL)){ + String[] resulr = SEND_SCOPE_LEVEL.split(","); + bo_Read_log.set("SEND_SCOPE_LEVEL_NUM",resulr.length); + } + + bo_Read_log.set("STARTTIMES",startTime); + SDK.getBOAPI().createDataBO("BO_EU_PAL_READ_LOG",bo_Read_log,UserContext.fromUID(instanceById.getCreateUser())); + + } +} \ No newline at end of file diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/TestSendOARead.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/TestSendOARead.java new file mode 100644 index 00000000..d73ee769 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/TestSendOARead.java @@ -0,0 +1,638 @@ +package com.awspaas.user.apps.integration.job; + +import com.actionsoft.bpms.bo.engine.BO; +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.database.RowMap; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.schedule.IJob; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.awspaas.user.apps.integration.util.UtilUrl; +import org.apache.commons.lang.StringUtils; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 测试发送待阅数据到10056870账户上,杨文军 + */ +public class TestSendOARead implements IJob { + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + String jobParameter = SDK.getJobAPI().getJobParameter(jobExecutionContext); + String taskid = jobParameter.split(",")[1]; + String processid = jobParameter.split(",")[0]; + ProcessInstance instanceById = SDK.getProcessAPI().getInstanceById(processid); + TaskInstance taskInstance = SDK.getTaskAPI().getInstanceById(taskid); + String wsId = ""; + JSONArray filed = new JSONArray(new LinkedList<>()); + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + System.out.println("portal======>>>>"+portalUrl); + /*if (portalUrl.equals("http://10.114.11.135:8088/portal")){ + portalUrl = "http://bpm.yili.com:8088/portal/"; + }*/ + try { + + + String url = portalUrl + "/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + String mobileurl = "https://bpm.yili.com:8088/portal" + "/r/or?cmd=com.yili_process_page_phone&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Timestamp endTime = instanceById.getStartTime(); + BO boActCoePublish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", instanceById.getId()).detail(); + + +//ProcessExecutionContext processExecutionContext,String fileCreateName,String fileName,String fileurl,String readingScope_org,String isFullCompany,String fileCreateDate,String relationProcessinstId,String readingScope_post,String readingScope_level,String fileid + String not_url = "/w?cmd=com.yili_process_page&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + + + JSONObject jsonObject = new JSONObject(new LinkedHashMap()); + jsonObject.put("action", "read"); + jsonObject.put("title", " " + + "" + boActCoePublish.getString("PROCESS_TITLE") + ""); + System.out.println("部门庄户》》》》》》》" + SDK.getORGAPI().getDepartmentByUser(taskInstance.getTarget()).getNo()); + jsonObject.put("dept", SDK.getORGAPI().getDepartmentByUser(taskInstance.getTarget()).getNo());//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo() + String target = taskInstance.getTarget(); + target = taskInstance.getTarget(); + + System.out.println("当前账户======》》》》" + target); + + jsonObject.put("user", target); + + // jsonObject.put("user",);//processExecutionContext.getProcessInstance().getCreateUser() + jsonObject.put("date", sdf.format(endTime)); + jsonObject.put("remark", boActCoePublish.getString("PROCESS_TITLE")); + jsonObject.put("status", "0"); + jsonObject.put("dataid", instanceById.getId()); + jsonObject.put("pcurl", url); + jsonObject.put("mobileurl", mobileurl); + //list.add(1,"00352394"); + //list.add(2,"00352394"); + /* BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", instanceById.getId()).detail(); + String uid = ""; + String new_uid = ""; + if (bo_act_coe_publish1 != null) { + String da = bo_act_coe_publish1.getString("SEND_SCOP"); + + if (da.equals("1")) { + List select_userid_from_orguser = DBSql.getMaps("select USERID from ORGUSER WHERE CLOSED = '0'"); + + for (RowMap row : select_userid_from_orguser + ) { + BO boList = SDK.getBOAPI().query("BO_ACT_DATAID",true).addQuery("PROCESSID=",processid).addQuery("USER_ID=",row.getString("USERID")).detail(); + if (boList==null){ + DepartmentModel departmentModel = SDK.getORGAPI().getDepartmentByUser(row.getString("USERID")); + if(departmentModel.getId().equals("e79281b1-2f81-4895-b30e-9f96e9ad0e2c")||departmentModel.getId().equals("5bc3a2dc-3bd2-4376-bcc3-5612e28e55fe")||departmentModel.getId().equals("a93a7f77-8b11-4261-8770-20b0cdfab315")||departmentModel.getId().equals("a93a7f77-8b11-4261-8770-20b0cdfab315")){ + + }else { + uid += row.getString("USERID") + ","; + } + } + } + } else { + List posts_list = new ArrayList(); + List org_list = new ArrayList(); + if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_ORG"))) { + String strs[] = bo_act_coe_publish1.getString("SEND_SCOPE_ORG").split(","); + org_list = Arrays.asList(strs); + } + + if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_POST"))) { + String posts[] = bo_act_coe_publish1.getString("SEND_SCOPE_POST").split(","); + posts_list = Arrays.asList(posts); + } + List ranks_list = new ArrayList(); + if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL"))) { + String ranks[] = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL").split(","); + ranks_list = Arrays.asList(ranks); + } + + System.out.println("部门id》》》》》》》》》》》》》" + org_list); + System.out.println("posts_list》》》》》》》》》》》》》" + posts_list); + System.out.println("ranks_list》》》》》》》》》》》》》" + ranks_list); + if (org_list.size() != 0 && org_list != null) { + for (String depaartid : org_list + ) { + System.out.println("departid>>>>>>>>>>>>>" + depaartid); + DepartmentModel departmentModel = SDK.getORGAPI().getDepartmentById(depaartid); + boolean existSubModelOfCache = departmentModel.isExistSubModelOfCache(); + System.out.println("是否含有下级?????????????" + existSubModelOfCache); + //判断选中的是否有下级部门 + if (existSubModelOfCache) { + List maps = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + depaartid + "'"); + for (RowMap row : maps + ) { + String id = row.getString("ID"); + DepartmentModel model = SDK.getORGAPI().getDepartmentById(id); + + if (model.isExistSubModelOfCache()) { + //有下级部门的选中有下级部门 + List rowMapList = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + id + "'"); + for (RowMap wo : + rowMapList) { + String ids = wo.getString("ID"); + DepartmentModel model1 = SDK.getORGAPI().getDepartmentById(ids); + if (model1.isExistSubModelOfCache()) { + List rowMapLists = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + ids + "'"); + for (RowMap wsa : + rowMapLists) { + String wsaString = wsa.getString("ID"); + DepartmentModel model2 = SDK.getORGAPI().getDepartmentById(wsaString); + if (model2.isExistSubModelOfCache()) { + List rowMapList1 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + wsaString + "'"); + for (RowMap rows : + rowMapList1) { + String rowsString = rows.getString("ID"); + DepartmentModel model3 = SDK.getORGAPI().getDepartmentById(rowsString); + if (model3.isExistSubModelOfCache()) { + List rowMapList2 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + rowsString + "'"); + for (RowMap ormap : + rowMapList2) { + String rowsString1 = ormap.getString("ID"); + DepartmentModel model4 = SDK.getORGAPI().getDepartmentById(rowsString1); + if (model4.isExistSubModelOfCache()) { + List rowMaps = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + rowsString1 + "'"); + for (RowMap owmapr : + rowMaps) { + String row_id = owmapr.getString("ID"); + DepartmentModel model5 = SDK.getORGAPI().getDepartmentById(row_id); + if (model5.isExistSubModelOfCache()) { + List rowMapList3 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + row_id + "'"); + for (RowMap owzmap : + rowMapList3) { + String idsa = owzmap.getString("ID"); + DepartmentModel model6 = SDK.getORGAPI().getDepartmentById(idsa); + if (model6.isExistSubModelOfCache()) { + + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(idsa); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(row_id); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(rowsString1); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(rowsString); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(wsaString); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(ids); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + List allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(id); + for (UserModel user : allUsersByDepartments + ) { + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + } + } else { + //选中的没有下级部门 + List allUsersByDepartment = SDK.getORGAPI().getAllUsersByDepartment(depaartid); + for (UserModel user : allUsersByDepartment + ) { + System.out.println("user.getExt2())???????????" + user.getExt2()); + System.out.println("posts_list》》》》》》》》》das" + (posts_list.size() != 0)); + System.out.println("123123》》》》》》》》》》" + (ranks_list.size() != 0)); + if (posts_list.size() != 0 && ranks_list.size() != 0) { + if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + if (posts_list.contains(user.getPositionNo())) { + + uid += user.getUID() + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + if (ranks_list.contains(user.getExt2())) { + + uid += user.getUID() + ","; + } + } else { + uid += user.getUID() + ","; + } + } + } + + } + } + if (org_list.size() == 0 || org_list == null) { + String posts = ""; + String levels = ""; + if (posts_list.size() != 0 && ranks_list.size() != 0) { + String[] post = bo_act_coe_publish1.getString("SEND_SCOPE_POST").split(","); + String[] level = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL").split(","); + if (post.length == 1) { + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + posts = "'" + post[0] + "'"; + } else { + posts = "'" + StringUtils.join(post, "','") + "'"; + } + if (level.length == 1) { + levels = "'" + level[0] + "'"; + } else { + levels = "'" + StringUtils.join(level, "','") + "'"; + } + List maps = DBSql.getMaps("select USERID from ORGUSER where POSITION_NO in(" + posts + ") and EXT2 in (" + levels + ")"); + for (RowMap map : maps + ) { + uid += map.getString("USERID") + ","; + } + } else if (posts_list.size() != 0 && ranks_list.size() == 0) { + String[] post = bo_act_coe_publish1.getString("SEND_SCOPE_POST").split(","); + if (post.length == 1) { + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + posts = "'" + post[0] + "'"; + } else { + posts = "'" + StringUtils.join(post, "','") + "'"; + } + List maps = DBSql.getMaps("select USERID from ORGUSER where POSITION_NO in(" + posts + ")"); + for (RowMap map : maps + ) { + uid += map.getString("USERID") + ","; + } + } else if (posts_list.size() == 0 && ranks_list.size() != 0) { + String[] level = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL").split(","); + + if (level.length == 1) { + levels = "'" + level[0] + "'"; + } else { + levels = "'" + StringUtils.join(level, "','") + "'"; + } + List maps = DBSql.getMaps("select USERID from ORGUSER where EXT2 in (" + levels + ")"); + for (RowMap map : maps + ) { + uid += map.getString("USERID") + ","; + } + } + + } + } + System.out.println("userid》》》》》》》》》》》》》》》》》》》" + uid); + if (StringUtils.isNotEmpty(uid + )) { + uid = uid.substring(0, uid.length() - 1); + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + for (String userid : list + ) { + + System.out.println("当前账户======》》》》" + userid); + // BO boEuOaReson = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("WORKCODE=", userid).detail(); + // if (boEuOaReson!=null){ + new_uid += userid + ","; + // } + + } + } + } + + if (StringUtils.isNotEmpty(new_uid + )) { + new_uid = new_uid.substring(0, new_uid.length() - 1); + }*/ + + /*System.out.println("new_userid ==========>>>>>>>>>"+new_uid); + String[] users = new_uid.split(","); + int length = 300; + int ys = users.length%length; + if (ys==0) { + int size = users.length/length; + int flag = 0; + for (int i=0;i\n" + + " " + + " " + + " " + + " " + + ""+ + " " + + " " + + " " + + ""; + System.out.println("xmlStr>>>>>>>>"+xmlStr); + String postSoap = UtilUrl.doPostSoap("http://10.105.1.59:80/services/service_lcglpt", xmlStr, ""); + Document document = DocumentHelper.parseText(postSoap); + Element rootElement = document.getRootElement(); + System.out.println("rootElement>>>>>>"+rootElement); + Element result = rootElement.element("Body").element("serviceResponse").element("out"); + String resultString = result.getData().toString(); + JSONObject jsonObject1 = JSON.parseObject(resultString); + String datas = jsonObject1.getString("data"); + String status = jsonObject1.getString("status"); + System.out.println("状态是什么》》》》》》》》》》》"+status); + JSONArray resultArray = JSONObject.parseArray(datas); + for (int j=0;j\n" + + " " + + " " + + " " + + " " + + ""+ + " " + + " " + + " " + + ""; + System.out.println("xmlStr>>>>>>>>"+xmlStr); + String postSoap = UtilUrl.doPostSoap("http://10.105.1.59:80/services/service_lcglpt", xmlStr, ""); + Document document = DocumentHelper.parseText(postSoap); + Element rootElement = document.getRootElement(); + System.out.println("rootElement>>>>>>"+rootElement); + Element result = rootElement.element("Body").element("serviceResponse").element("out"); + String resultString = result.getData().toString(); + JSONObject jsonObject1 = JSON.parseObject(resultString); + String datas = jsonObject1.getString("data"); + String status = jsonObject1.getString("status"); + System.out.println("状态是什么》》》》》》》》》》》"+status); + JSONArray resultArray = JSONObject.parseArray(datas); + for (int j=0;j\n" + + " " + + " " + + " " + + " " + + ""+ + " " + + " " + + " " + + ""; + System.out.println("xmlStr>>>>>>>>"+xmlStr); + String postSoap = UtilUrl.doPostSoap("http://10.105.1.59:80/services/service_lcglpt", xmlStr, ""); + Document document = DocumentHelper.parseText(postSoap); + Element rootElement = document.getRootElement(); + System.out.println("rootElement>>>>>>"+rootElement); + Element result = rootElement.element("Body").element("serviceResponse").element("out"); + String resultString = result.getData().toString(); + JSONObject jsonObject1 = JSON.parseObject(resultString); + String datas = jsonObject1.getString("data"); + String status = jsonObject1.getString("status"); + System.out.println("状态是什么》》》》》》》》》》》"+status); + JSONArray resultArray = JSONObject.parseArray(datas); + for (int j=0;j\n" + + " " + + " " + + " " + + " " + + ""+ + " " + + " " + + " " + + ""; + System.out.println("xmlStr>>>>>>>>"+xmlStr); + String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl"); + + String postSoap = UtilUrl.doPostSoap(readurl, xmlStr, ""); + Document document = DocumentHelper.parseText(postSoap); + Element rootElement = document.getRootElement(); + System.out.println("rootElement>>>>>>"+rootElement); + Element result = rootElement.element("Body").element("serviceResponse").element("out"); + String resultString = result.getData().toString(); + JSONObject jsonObject1 = JSON.parseObject(resultString); + String datas = jsonObject1.getString("data"); + String status = jsonObject1.getString("status"); + System.out.println("状态是什么》》》》》》》》》》》"+status); + JSONArray resultArray = JSONObject.parseArray(datas); + for (int j=0;j list = DBSql.getMaps(open, sql); + for (RowMap bo : list + ) { + String repository_sql = " select PLNAME from APP_ACT_COE_PAL_REPOSITORY " + + "where PLCATEGORY = 'process'and PLMETHODID ='process.framework' " + + "and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + ",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + "'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + "'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + "'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + "'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + "'42c09260-c1d3-44b7-ac3d-f8280e04c294')" + " and PLNAME ='" + bo.getString("PLNAME") + "'"; + String PLNAME = DBSql.getString(open, repository_sql); + System.out.println("repository_sql>>>>>>>>>>>>>>>>>>>" + repository_sql); + if (StringUtils.isEmpty(PLNAME)) { + PLNAME = bo.getString("EXT4"); + } + String add_name = PLNAME + ","; + + Map names = new LinkedHashMap<>(); + names.put(0, bo.getString("EXT4")); + names.put(1, PLNAME); + for (int i = 2; i < 5; i++) { + String repository_sqls = " select EXT4 from APP_ACT_COE_PAL_REPOSITORY " + + "where PLCATEGORY = 'process'and PLMETHODID ='process.framework' " + + "and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + ",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + "'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + "'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + "'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + "'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + "'42c09260-c1d3-44b7-ac3d-f8280e04c294')"+" and EXT4 ='" + PLNAME + "'";//and PLMETHODID !='process.framework' + String parent_name = DBSql.getString(open, repository_sqls); + if (names.containsValue(parent_name)) { + break; + } + String util_space = "select PLCATEGORY from APP_ACT_COE_PAL_REPOSITORY where PLPARENTID in ('process') and PLNAME = '" + PLNAME + "'"; + String fisrt_name = DBSql.getString(open, util_space); + if (names.containsValue(fisrt_name)) { + break; + } + if (fisrt_name.equals("process")) { + names.put(i, "obj_5020f54928c842b58107c3354e450070"); + } + if (StringUtils.isEmpty(parent_name)) { + break; + } + PLNAME = parent_name; + names.put(i, PLNAME); + add_name = PLNAME + ","; + } + add_name = names.get(0) + ","; + System.out.println("add_name==============" + + add_name); + String dimensionId = ""; + String de_name = ""; + System.out.println("names==========" + names); + for (int i = names.size() - 1; i >= 0; i--) { + System.out.println("name" + i + "=================?>>>>>>>>>>" + names.get(i)); + String dimensionId_sql = "SELECT ID FROM APP_ACT_KMS_DIMENSION where ID ='" + names.get(i) + "'"; + dimensionId = DBSql.getString(open, dimensionId_sql); + String sql_Frameworks = " select EXT4 from APP_ACT_COE_PAL_REPOSITORY " + + "where PLCATEGORY = 'process'and PLMETHODID ='process.framework' " + + "and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + ",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + "'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + "'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + "'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + "'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + "'42c09260-c1d3-44b7-ac3d-f8280e04c294')"+" and EXT4 = '" + names.get(i) + "'";// + String framework = DBSql.getString(open, sql_Frameworks);//&& StringUtils.isEmpty(framework) + + if (StringUtils.isNotEmpty(dimensionId) || StringUtils.isEmpty(framework)) { + + } else { + System.out.println("进入知识"); + String sql_Framework = " select EXT4 from APP_ACT_COE_PAL_REPOSITORY " + + "where PLCATEGORY = 'process'and PLMETHODID !='process.framework' " + + "and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + ",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + "'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + "'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + "'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + "'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + "'42c09260-c1d3-44b7-ac3d-f8280e04c294')"+"and EXT4 = '" + names.get(i) + "'";//PLMETHODID = 'process.framework' and + String frameworks = DBSql.getString(open, sql_Framework);//&& StringUtils.isEmpty(framework) + if (bo.getString("EXT4").equals(names.get(i))) { + String card_sql = "select ID from APP_ACT_KMS_CARD where ID ='" + names.get(i) + "'"; + String card = DBSql.getString(open, card_sql); + String card_sql_name = "select CARDNAME from APP_ACT_KMS_CARD where ID ='" + names.get(i) + "'"; + String card_name = DBSql.getString(open, card_sql_name); + if (StringUtils.isNotEmpty(card)) { + creadteFile(userContext, open, bo.getString("PLNAME"), add_name); + + } else { + + // aslp服务地址 + String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl"; +// 参数定义列表 + Map params_create = new HashMap(); +//保密级别, 0: 普通 1:秘密 2:机密,必填 + params_create.put("securityLevel", 0); +//知识名称,必填 + params_create.put("knwlName", card_name); +//是否可以评论,必填 + params_create.put("isComment", true); +//是否可以评分,必填 + params_create.put("isRate", true); +//有效期:yyyy-MM-dd,非必填 + params_create.put("validDate", "2099-12-31"); +//只读控制,1:在线阅读和下载 0:在线阅读,必填 + params_create.put("onlineLevel", 1); +//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填 + params_create.put("createUser", "admin"); +//知识内容,非必填 + params_create.put("cardContext", ""); +//sid,必填 + params_create.put("sid", userContext.getSessionId()); + AppAPI appAPI_create = SDK.getAppAPI(); +//创建知识 + ResponseObject ro_create = appAPI_create.callASLP(appAPI_create.getAppContext(APPID), aslps_create, params_create); + System.out.println("ro_create================" + ro_create); + creadteFile(userContext, open, names.get(i).toString(), add_name); + } + + + } else { + + if (StringUtils.isNotEmpty(dimensionId)) { + // 调用App + String sourceAppId = APPID; +// aslp服务地址 + String aslps_de = "aslp://com.actionsoft.apps.kms/createDimension"; +// 参数定义列表 + Map paramss = new HashMap(); +//发布是否需要审批,默认false,必填 + paramss.put("isExamine", false); +//是否启用,默认启用,必填 + paramss.put("isEnabled", true); +//维度类型,1:允许发布知识 2:不允许发布知识,必填 + paramss.put("showType", 1); +//维度描述,非必填 + paramss.put("memo", ""); +//创建人,非必填 + paramss.put("createUser", "admin"); + + String sql_fa = " select PLNAME from APP_ACT_COE_PAL_REPOSITORY " + + "where PLCATEGORY = 'process'and PLMETHODID ='process.framework' " + + "and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + ",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + "'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + "'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + "'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + "'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + "'42c09260-c1d3-44b7-ac3d-f8280e04c294')"+" and EXT4 = '" + names.get(i) + "'"; + String plname = DBSql.getString(open, sql_fa); +//维度名称,必填 + paramss.put("dimensionName", plname); + + String dimensionId_sql_i = "SELECT ID FROM APP_ACT_KMS_DIMENSION where ID ='" + names.get(i + 1) + "'"; + de_name = DBSql.getString(open, dimensionId_sql_i); +//父维度Id:""表示根维度,必填 + paramss.put("parentId", de_name); +//sid,必填 + paramss.put("sid", userContext.getSessionId()); + AppAPI appAPIs = SDK.getAppAPI(); +//创建维度 + ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslps_de, paramss); + + System.out.println("ros==================" + ros); + + } + } + + } + } + } + System.out.println("定时器执行完毕"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + open.close(); + } catch (SQLException throwables) { + throwables.printStackTrace(); + } + } + } + + public void creadteFile(UserContext userContext, Connection open, String name, String add_name) { + /** + * 这个主要是负责对流程手册进行相关的文件的生成 + */ + String sourceAppId = APPID; +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/CreateFile"; + + String sql = "SELECT CARDNAME FROM APP_ACT_KMS_CARD WHERE ID = '" + name + "'"; + String id = DBSql.getString(open, sql); + if (StringUtils.isNotEmpty(id)) { + BO bos = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("PUBLISHFILENAME = ", name).detail(); + if (bos != null) { + + + if (StringUtils.isNotEmpty(bos.getString("TASKID"))) { + + OutputTaskModel model = new OutputTask().getTaskReportById(bos.getString("TASKID")); + if (model != null) { + System.out.println(",pdel============" + model); + System.out.println("123313123123123==========" + model.getProfileId()); + OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId()); + System.out.println("dajadfas======" + appProfile); + if (appProfile == null) { + throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId()); + } + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + String sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME = '" + bos.getString("PUBLISHFILENAME") + "'"; + String lever = DBSql.getString(open, sql_lever); + //lever = lever.substring(0,3); + DCContext dcContext = new DCContext(userContext, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), bos.getString("TASKID"), bos.getString("PUBLISHFILENAME") + "_" + lever + ".doc"); + //UtilFile file = new UtilFile(dcContext.getPath()); + + + Map params = new HashMap(); +//知识ID,必填 + params.put("cardId", id); +//sid,必填 + params.put("sid", userContext.getSessionId()); + + params.put("dc", dcContext); + AppAPI appAPI = SDK.getAppAPI(); +//创建文件 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("流程手册的存入=================" + ro); + } + } + + } + String sql_A = "SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where PLNAME = '" + name + "' AND PLMETHODID != 'process.framework' AND PLMETHODID IN (select distinct PLMETHODID from APP_ACT_COE_PAL_REPOSITORY)"; + List rows = DBSql.getMaps(open, sql_A); + + for (RowMap bo : rows + ) { + + /** + * 这个是模型中的附件获取的并插入的数据信息,需要做修改 + */ + // 调用App + +// 参数定义列表 + Map paramss = new HashMap(); +//知识ID,必填 + paramss.put("cardId", id); +//sid,必填 + paramss.put("sid", userContext.getSessionId()); + + UpfileWeb upfileWeb = new UpfileWeb(userContext); + + + String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID != 'process.framework' AND PLNAME= '" + bo.getString("PLNAME") + "'" + + ")"; + List maps = DBSql.getMaps(open, sql_upfile); + for (RowMap row : maps) { + UpfileModel upfileModel = new UpfileModel(); + upfileModel.setType(row.getString("FILETYPE")); + upfileModel.setFileName(row.getString("FILENAME")); + upfileModel.setPl_uuid(row.getString("PALREPOSITORYID")); + upfileModel.setShape_uuid(row.getString("SHAPEID")); + DCContext dcContexts = upfileWeb.getDCContext(upfileModel); + paramss.put("dc", dcContexts); + AppAPI appAPIs = SDK.getAppAPI(); + ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, paramss); + System.out.println("流程模型附件的生成=============" + ros); + } + +//DCContext对象,必填 + +//创建文件 + } + PublishKnow(userContext, open, add_name, id); + } + } + + public void PublishKnow(UserContext userContext, Connection open, String add_name, String id) { + System.out.println("add_name=================" + add_name); + /*String result = add_name.substring(0, add_name.length() - 1); + String[] deptSplit = result.split(","); + + if (deptSplit.length == 1) { + result = "'" + deptSplit[0] + "'"; + } + result = "'" + StringUtils.join(deptSplit, "','") + "'"; + System.out.println(">>>>>NO =" + result); + + String sql = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME IN (" + result + ") "; + List maps = DBSql.getMaps(open, sql); + if (maps.size() == 0) { + String sql_DIMENSIONNAME = "SELECT PLPARENTID FROM APP_ACT_COE_PAL_REPOSITORY where PLCATEGORY = 'process' and PLNAME IN (" + result + ") "; + String maps_first = DBSql.getString(open, sql_DIMENSIONNAME); + + if (maps_first.equals("itsystem")) { + String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='IT系统' "; + maps = DBSql.getMaps(open, sql_id); + } else if (maps_first.equals("control")) { + String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='控制' "; + maps = DBSql.getMaps(open, sql_id); + } else if (maps_first.equals("process")) { + String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='流程制度' "; + maps = DBSql.getMaps(open, sql_id); + } else if (maps_first.equals("org")) { + String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='组织' "; + maps = DBSql.getMaps(open, sql_id); + } else if (maps_first.equals("data")) { + String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='数据' "; + maps = DBSql.getMaps(open, sql_id); + } else { + String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME =(SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where ID ='" + maps_first + "')"; + maps = DBSql.getMaps(open, sql_id); + } + } + String ids = ""; + if (maps.size() != 0) { + + for (RowMap rowmap : maps + ) { + ids += rowmap.getString("ID") + ","; + } + ids = ids.substring(0, ids.length() - 1); + + } else { + for (RowMap rowmap : maps + ) { + ids += rowmap.getString("ID") + ","; + } + ids = ids.substring(0, ids.length() - 1); + }*/ + + String[] deptSplit_id = add_name.split(","); + + JSONArray jsonArray = new JSONArray(); + for (String id_names : deptSplit_id + ) { + jsonArray.add(id_names); + } + //jsonObject.put(deptSplit_id); + id += ","; + String[] deptSplit_das = id.split(","); + JSONArray jsonArray_das = new JSONArray(); + for (String das : deptSplit_das + ) { + jsonArray_das.add(das); + } + //jsonObject.put(deptSplit_id); + + + // 调用App + String sourceAppId = APPID; +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl"; +// 参数定义列表 + Map params = new HashMap(); +//要发布到的维度ID的JSON数组字符串,必填 + params.put("dimensionIDArray", jsonArray.toString()); +//要发布的知识ID的JSON数组字符串,必填 + params.put("knwlIDArray", jsonArray_das.toString()); +//标签的JSON数组字符串,非必填 + +//sid,必填 + params.put("sid", userContext.getSessionId()); + AppAPI appAPI = SDK.getAppAPI(); +//发布知识 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + + System.out.println("知识发布============" + ro); + + + } +} + + diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/UpdateOADAIBANJob.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/UpdateOADAIBANJob.java new file mode 100644 index 00000000..1b9eba3c --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/UpdateOADAIBANJob.java @@ -0,0 +1,78 @@ +package com.awspaas.user.apps.integration.job; + +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.schedule.IJob; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.AppAPI; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.awspaas.user.apps.integration.XmlDatasUtil; +import com.awspaas.user.apps.integration.util.HttpClientUtils; +import org.dom4j.DocumentException; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class UpdateOADAIBANJob implements IJob { + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + List bo_eu_oa_mobileurl = SDK.getBOAPI().query("BO_EU_UPDATE_OA", true).list(); + for (BO bo:bo_eu_oa_mobileurl + ) { + XmlDatasUtil xmlDatasUtil = new XmlDatasUtil(); + xmlDatasUtil.setExternal_system_ID("LCZD"); + + xmlDatasUtil.setOther_system_to_do_ID(bo.getString("TODOID")); + xmlDatasUtil.setProcess_title(bo.getString("CONTENT")); + //http://localhost:8089/portal/r/or?cmd=com.yili_form_page_open&processInstId=3505e654-9217-41cd-a31d-4971846b3219&taskInstId=8a71d75e-3ee0-43a2-a226-ecb01419319c&oauthName=oauthLogin&token=admin + + xmlDatasUtil.setPcurl(bo.getString("PCURL").replaceAll("&","&")); + xmlDatasUtil.setMobileurl(bo.getString("MOBILEURL").replaceAll("&","&")); + + xmlDatasUtil.setTo_do_login_account(bo.getString("HRCODE")); + xmlDatasUtil.setTo_do_creation_time(bo.getString("NEWCREATETIME")); + xmlDatasUtil.setTo_do_completion_time(bo.getString("NEWDONETIME")); + + xmlDatasUtil.setTo_do_status("1"); + + xmlDatasUtil.setTo_do_official_type("0"); + + xmlDatasUtil.setViewtype("-2"); + + xmlDatasUtil.setCreatedate(bo.getString("CREATEDATES")); + xmlDatasUtil.setDonedate(bo.getString("DONEDATE")); + + xmlDatasUtil.setReceivedate(bo.getString("RECEIVEDATE")); + xmlDatasUtil.setReceivetime(bo.getString("RECEIVETIME")); + xmlDatasUtil.setCurrentnodetype("0"); + + xmlDatasUtil.setRequestcode(bo.getString("REQUESTCODE")); + xmlDatasUtil.setCurrentnodename(bo.getString("CURRENTNODENAME")); + + + xmlDatasUtil.setNooperator(bo.getString("NOOPERATOR")); + xmlDatasUtil.setWorkcode(""); + xmlDatasUtil.setWorkflowname(bo.getString("WORKFLOWNAME")); + + xmlDatasUtil.setCreaterhrcode(bo.getString("CREATERHRCODE")); + + xmlDatasUtil.setCreaterworkcode(""); + HttpClientUtils httpClientUtil = new HttpClientUtils(); + try { + String taskurl= SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "taskurl"); + + String s = httpClientUtil.SendPend(taskurl, xmlDatasUtil); + System.out.println("更新成功数据》》》》》》"+s); + } catch (Exception e) { + e.printStackTrace(); + } + } + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/deleteKnowJob.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/deleteKnowJob.java new file mode 100644 index 00000000..78e70890 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/deleteKnowJob.java @@ -0,0 +1,27 @@ +package com.awspaas.user.apps.integration.job; + +import com.actionsoft.bpms.schedule.IJob; +import com.actionsoft.bpms.util.DBSql; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +/** + * 清空表数据,知识发布的相关知识 + */ +public class deleteKnowJob implements IJob { + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + //APP_ACT_KMS_CARD + // APP_ACT_KMS_PUBLISH + //APP_ACT_KMS_DIMENSION + //APP_ACT_KMS_FILE + String sql_delete = "delete from APP_ACT_KMS_CARD"; + DBSql.update(sql_delete); + String sql_da = "delete from APP_ACT_KMS_PUBLISH"; + DBSql.update(sql_da); + String sql_das = "delete from APP_ACT_KMS_DIMENSION where DIMENSIONNAME !='流程制度' "; + DBSql.update(sql_das); + String sql_dass = "delete from APP_ACT_KMS_FILE"; + DBSql.update(sql_dass); + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/sendReadByDataid.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/sendReadByDataid.java new file mode 100644 index 00000000..6582e7b3 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/sendReadByDataid.java @@ -0,0 +1,1796 @@ +package com.awspaas.user.apps.integration.job; + +import java.sql.Connection; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import org.apache.commons.lang.StringUtils; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.quartz.JobExecutionException; + +import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst; +import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; +import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager; +import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile; +import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb; +import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +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.database.RowMap; +import com.actionsoft.bpms.commons.login.constant.LoginConst; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.server.SSOUtil; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.server.fs.DCContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.bpms.util.UtilString; +import com.actionsoft.emm.util.AesUtil; +import com.actionsoft.exception.AWSException; +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 com.awspaas.user.apps.integration.util.DownloadUtil; +import com.awspaas.user.apps.integration.util.HttpUtil; +import com.awspaas.user.apps.integration.util.UtilUrl; +@SuppressWarnings("all") +public class sendReadByDataid { + private String isSendEHSQ = "false"; + private String isSendOA = "true"; + private String isSendKMS = "true"; + public void execute(String processid, String taskid) throws JobExecutionException { + ProcessInstance instanceById = SDK.getProcessAPI().getInstanceById(processid); + TaskInstance taskInstance = SDK.getTaskAPI().getInstanceById(taskid); + String wsId = ""; + JSONArray filed = new JSONArray(new LinkedList<>()); + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + //System.out.println("portal======>>>>"+portalUrl); + /*if (portalUrl.equals("http://10.114.11.135:8088/portal")){ + portalUrl = "http://bpm.yili.com:8088/portal/"; + }*/ + try { + + String url = portalUrl + "/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + String mobileurl = "https://bpm.yili.com:8088/portal" + "/r/or?cmd=com.yili_process_page_phone&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Timestamp endTime = instanceById.getStartTime(); + BO boActCoePublish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", instanceById.getId()).addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + String not_url = "/w?cmd=com.yili_process_page&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + JSONObject jsonObject = new JSONObject(new LinkedHashMap()); + jsonObject.put("action", "read"); + jsonObject.put("title", " " + + "" + boActCoePublish.getString("PROCESS_TITLE") + ""); + //System.out.println("部门庄户》》》》》》》" + SDK.getORGAPI().getDepartmentByUser(taskInstance.getTarget()).getNo()); + jsonObject.put("dept", SDK.getORGAPI().getDepartmentByUser(taskInstance.getTarget()).getNo());//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo() + String target = taskInstance.getTarget(); + target = taskInstance.getTarget(); + + //System.out.println("当前账户======》》》》" + target); + + jsonObject.put("user", target); + + // jsonObject.put("user",);//processExecutionContext.getProcessInstance().getCreateUser() + jsonObject.put("date", sdf.format(endTime)); + jsonObject.put("remark", boActCoePublish.getString("PROCESS_TITLE")); + jsonObject.put("status", "0"); + jsonObject.put("dataid", instanceById.getId()); + jsonObject.put("pcurl", url); + jsonObject.put("mobileurl", mobileurl); + //list.add(1,"00352394"); + //list.add(2,"00352394"); + BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processid).addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + + /** + * 这块的判断主要是将组织,岗位,职级进行合并集进行相关的判断获取人员账户合集 + */ + + if(bo_act_coe_publish1!=null&&instanceById!=null) { + ArrayList sendList = getSendList(instanceById, bo_act_coe_publish1, jsonObject); + System.err.println(instanceById.getTitle()+"待发送人员列表====>"+sendList); + for (String uid : sendList) { + createLog(instanceById, uid); + long startTime = System.currentTimeMillis(); + SendOARead(jsonObject, instanceById, uid); + //CreateReadLog(instanceById, jsonObject, users, startTime); + } + + } + + + //BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", instanceById.getId()).addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + //流程发布的新增发布 + List bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID=", instanceById.getId()).list(); + List bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).addQuery("BINDID=", instanceById.getId()).list(); + List bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).addQuery("BINDID=", instanceById.getId()).list(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + + JSONArray jsonArray = new JSONArray(); + + +/** + * 这里是去生成EHSQ相关数据 + */ + /* for (BO bo:bo_act_coe_publish_n + ) { + JSONArray jsonArray_EHSQ = new JSONArray(); + JSONObject jsonObject_ehsq = new JSONObject(new LinkedHashMap<>()); + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("PUBLISHFILEID"); + LinkedHashMap downloadurl = downloadUtil.outputReportDownload(UserContext.fromUID(processExecutionContext.getProcessInstance().getCreateUser()), bo.getString("TASKID"), publishfileid); + jsonObject_ehsq.put("fileid",bo.getString("TASKID")); + jsonObject_ehsq.put("filename",bo.getString("PUBLISHFILENAME")); + //jsonObject_ehsq.put("filecode",bo.getString("PUBLISH_NUMBER")); + jsonObject_ehsq.put("filecode","123456"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+publishfileid+"'"; + RowMap map = DBSql.getMap(sql_n); + jsonObject_ehsq.put("version",map.getString("PLVER")); + jsonObject_ehsq.put("releasedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("effectivedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("authorcode",processExecutionContext.getTaskInstance().getTarget()); + // jsonObject_ehsq.put("authorcode","00116465"); + jsonObject_ehsq.put("authorname",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); + //jsonObject_ehsq.put("authorname","毛鹏程"); + jsonObject_ehsq.put("companycode",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo()); + //jsonObject_ehsq.put("companycode","00000013"); + jsonObject_ehsq.put("authorcompany",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); + //jsonObject_ehsq.put("authorcompany","总部质量管理部"); + // jsonObject_ehsq.put("releasescope","总部质量管理部"); + BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true).addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); + if (bo1!=null){ + if (bo1.getString("PERMTYPE").equals("1")){ + }else { + + String departname = ""; + String orgperm = bo1.getString("ORGPERM"); + String dleass = ""; + String[] deptSplit = orgperm.split(","); + if(deptSplit.length==1){ + dleass = "'"+deptSplit[0]+"'"; + } + dleass ="'"+ StringUtils.join(deptSplit, "','")+"'"; + + List maps = DBSql.getMaps("select DEPARTMENTNAME from ORGDEPARTMENT where ID in (" + dleass + ")"); + for (RowMap rowmas:maps + ) { + departname+=rowmas.getString("DEPARTMENTNAME")+";"; + } + jsonObject_ehsq.put("releasescope","总部质量管理部"); + + } + } + + System.out.println("任务办理者>>>>>>>>>>>"+processExecutionContext.getTaskInstance().getTarget()); + String sessionId = new SSOUtil().registerClientSessionNoPassword(processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", LoginConst.DEVICE_PC); + + System.out.println("办理者的sessionid>>>>>>>>>>>"+sessionId); + String downurl = downloadUtil.getzipURL(sessionId,bo.getString("TASKID"),bo.getString("PUBLISHFILENAME")); + //jsonObject_ehsq.put("downloadurl","http://bpm.yili.com:8088/portal/r"+downurl.toString().substring(1)); + + String recordfiles = ""; + String recordurls = ""; + Set keys = downloadurl.keySet(); + for ( String key : keys ) { + recordfiles+=key+";"; + String cent_url = downloadurl.get(key).substring(downloadurl.get(key).indexOf("/df"),downloadurl.get(key).length()); + String fileDownurl = "http://bpm.yili.com:8088/portal/r"+cent_url; + recordurls+=fileDownurl+";"; + } + String new_name = ""; + String[] split = recordfiles.split(";"); + if (split.length>0){ + + for (int i =1;i0){ + String loadurl = urls[0].replaceAll("&sid=null","&sid="+sessionId); + System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<"+loadurl); + jsonObject_ehsq.put("downloadurl",loadurl); + for (int i =1;i()); + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("CHANGEDFILEIDNEW"); + LinkedHashMap downloadurl = downloadUtil.outputReportDownload(UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()), bo.getString("TASKID"), publishfileid); + jsonObject_ehsq.put("fileid",bo.getString("TASKID")); + jsonObject_ehsq.put("filename",bo.getString("CHANGEDFILENAMENEW")); + //jsonObject_ehsq.put("filecode",bo.getString("CHANGE_NUMBER")); + jsonObject_ehsq.put("filecode","123456"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+publishfileid+"'"; + RowMap map = DBSql.getMap(sql_n); + jsonObject_ehsq.put("verion",map.getString("PLVER")); + jsonObject_ehsq.put("releasedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("effectivedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("authorcode",processExecutionContext.getTaskInstance().getTarget()); + jsonObject_ehsq.put("authorname",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); + jsonObject_ehsq.put("companycode",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo()); + jsonObject_ehsq.put("authorcompany",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); + BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true).addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); + if (bo1!=null){ + if (bo1.getString("PERMTYPE").equals("1")){ + jsonObject_ehsq.put("releasescope","内蒙古伊利实业集团股份有限公司"); + }else { + + String departname = ""; + String orgperm = bo1.getString("ORGPERM"); + String dleass = ""; + String[] deptSplit = orgperm.split(","); + if(deptSplit.length==1){ + dleass = "'"+deptSplit[0]+"'"; + } + dleass ="'"+ StringUtils.join(deptSplit, "','")+"'"; + + List maps = DBSql.getMaps("select DEPARTMENTNAME from ORGDEPARTMENT where ID in (" + dleass + ")"); + for (RowMap rowmas:maps + ) { + departname+=rowmas.getString("DEPARTMENTNAME")+";"; + } + jsonObject_ehsq.put("releasescope",departname); + + } + } + + String sessionId = new SSOUtil().registerClientSessionNoPassword(processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", LoginConst.DEVICE_PC); + + String downurl = downloadUtil.getzipURL(sessionId,bo.getString("TASKID"),bo.getString("CHANGEDFILENAMENEW")); + String recordfiles = ""; + String recordurls = ""; + Set keys = downloadurl.keySet(); + for ( String key : keys ) { + recordfiles+=key+";"; + String cent_url = downloadurl.get(key).substring(downloadurl.get(key).indexOf("/df"),downloadurl.get(key).length()); + String fileDownurl = "http://bpm.yili.com:8088/portal/r"+cent_url; + recordurls+=fileDownurl+";"; + } + String new_name = ""; + String[] split = recordfiles.split(";"); + if (split.length>0){ + + for (int i =1;i0){ + String loadurl = urls[0].replaceAll("&sid=null","&sid="+sessionId); + System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<"+loadurl); + jsonObject_ehsq.put("downloadurl",loadurl); + for (int i =1;i"); + Connection open = DBSql.open(); + // http://localhost:8089/portal/r/or?cmd=com.hy_client_bpm_form_main_page_open&oauthName=oauthLogin&processInstId=3505e654-9217-41cd-a31d-4971846b3219 + /** + * 当流程不等于终止的时候往下走 + */ + if (!"terminate".equals(processExecutionContext.getProcessInstance().getControlState())) { + DownloadUtil downloadUtil = new DownloadUtil(); + String wsId = ""; + JSONArray filed = new JSONArray(new LinkedList<>()); + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + System.out.println("portal======>>>>" + portalUrl); + /* + * if (portalUrl.equals("http://10.114.11.135:8088/portal")){ portalUrl = + * "http://bpm.yili.com:8088/portal/"; } + */ + try { + + String url = portalUrl + "/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=" + + processExecutionContext.getProcessInstance().getId() + "&taskInstId=" + + processExecutionContext.getTaskInstance().getId(); + String mobileurl = "https://bpm.yili.com:8088/portal" + + "/r/or?cmd=com.yili_process_page_phone&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId=" + + processExecutionContext.getProcessInstance().getId() + "&taskInstId=" + + processExecutionContext.getTaskInstance().getId(); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Timestamp endTime = processExecutionContext.getProcessInstance().getStartTime(); + BO boActCoePublish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true) + .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()) + .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + + // ProcessExecutionContext processExecutionContext,String fileCreateName,String + // fileName,String fileurl,String readingScope_org,String isFullCompany,String + // fileCreateDate,String relationProcessinstId,String readingScope_post,String + // readingScope_level,String fileid + String not_url = "/w?cmd=com.yili_process_page&processInstId=" + + processExecutionContext.getProcessInstance().getId() + "&taskInstId=" + + processExecutionContext.getTaskInstance().getId(); + execute(processExecutionContext, boActCoePublish.getString("APPLYUSERNAME"), + boActCoePublish.getString("PROCESS_TITLE"), not_url, + boActCoePublish.getString("SEND_SCOPE_ORG"), boActCoePublish.getString("SEND_SCOP"), + boActCoePublish.getString("APPLYDATE"), processExecutionContext.getProcessInstance().getId(), + boActCoePublish.getString("SEND_SCOPE_POST"), boActCoePublish.getString("SEND_SCOPE_LEVEL"), + "1"); + + JSONObject jsonObject = new JSONObject(new LinkedHashMap()); + jsonObject.put("action", "read"); + jsonObject.put("title", " " + "" + boActCoePublish.getString("PROCESS_TITLE") + ""); + jsonObject.put("dept", SDK.getORGAPI() + .getDepartmentByUser(processExecutionContext.getTaskInstance().getTarget()).getNo());// SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo() + String target = processExecutionContext.getTaskInstance().getTarget(); + target = processExecutionContext.getTaskInstance().getTarget(); + jsonObject.put("user", target); + // jsonObject.put("user",);//processExecutionContext.getProcessInstance().getCreateUser() + jsonObject.put("date", sdf.format(endTime)); + jsonObject.put("remark", boActCoePublish.getString("PROCESS_TITLE")); + jsonObject.put("status", "0"); + jsonObject.put("dataid", processExecutionContext.getProcessInstance().getId()); + jsonObject.put("pcurl", url); + jsonObject.put("mobileurl", mobileurl); + // list.add(1,"00352394"); + // list.add(2,"00352394"); + BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true) + .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()) + .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + String crateUserId = target; + String new_uid = ""; + + BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true) + .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()) + .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + // 流程发布的新增发布 + List bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true) + .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list(); + List bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true) + .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list(); + List bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true) + .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + + JSONArray jsonArray = new JSONArray(); + /** + * 推送到知识库 + */ + if("true".equals(isSendKMS)) { + try { + // 发布到知识库 + int m = 0; + for (BO bo : bo_act_coe_publish_n) { + createKmsByNew(bo, wsId, filed, processExecutionContext, bo_act_coe_publish, crateUserId); + } + // 更新知识库 + for (BO bo : bo_act_coe_publish_c) { + CreateKmsByupdate(bo, wsId, filed, processExecutionContext, bo_act_coe_publish, crateUserId); + } + + // 废止知识库文件 + for (BO bo : bo_act_coe_publish_s) { + // 将旧的知识取消发布或者移动到废止发布中 + String publishfileid_stop = bo.getString("STOPFILEID"); + filed.add(publishfileid_stop); + String sql_s = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid_stop + "'"; + RowMap map1 = DBSql.getMap(sql_s); + if (StringUtils.isNotEmpty(map1.getString("EXT4"))) { + CancelPublishKnwl(processExecutionContext, + processExecutionContext.getUserContext().getSessionId(), map1.getString("EXT4")); + + DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '" + publishfileid_stop + + "'"); + } + } + } catch (Exception e) { + // TODO: handle exception + } + } + + /** + * 更新数据看板底表 + */ + try { + AttrSynAslp(processExecutionContext, wsId, filed); + } catch (Exception e) { + // TODO: handle exception + } + + /** + * 推送待阅文件到OA + */ + if("true".equals(isSendOA)) { + ProcessInstance instanceById = processExecutionContext.getProcessInstance(); + if (bo_act_coe_publish1 != null && instanceById != null) { + System.err.println(instanceById.getTitle() + "推送OA待阅执行开始====>"); + long startTime = System.currentTimeMillis(); + ArrayList sendList = getSendList(instanceById, bo_act_coe_publish1, jsonObject); + System.err.println(instanceById.getTitle() + "待发送人员数量====>" + sendList.size()); + for (String uid : sendList) { + try { + ExecutorService service = Executors.newFixedThreadPool(5); + service.execute(new Runnable() { + @Override + public void run() { + try { + SendOARead(jsonObject, instanceById, uid); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + + } catch (Exception e) { + } + } + long endTimes = System.currentTimeMillis(); + //存入日志 + createReadLog(processExecutionContext, jsonObject, sendList, startTime,endTimes); + System.err.println(instanceById.getTitle() + "推送OA待阅执行完毕====>" + "用时:"+(endTimes-startTime)/1000/60+"分钟"); + } + + } + /** + * 推送到EHSQ + */ + if("true".equals(isSendEHSQ)) { + try { + //推送EHSQ + sendEHSQ(processExecutionContext, bo_act_coe_publish_n); + //更新EHSQ + updateEHSQ(processExecutionContext, bo_act_coe_publish_c); + } catch (Exception e) { + // TODO: handle exception + } + } + + + } catch (Exception e) { + e.printStackTrace(); + } finally { + + + open.close(); + } + } + } + + /** + * 创建附件及文件 + * + * @param processExecutionContext + * @param bo_name + * @param userContext + * @param cardId + * @param fileid + */ + public void creadteFile(ProcessExecutionContext processExecutionContext, String bo_name, UserContext userContext, + String cardId, String fileid) { + /** + * 这个主要是负责对流程手册进行相关的文件的生成 + */ + String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/CreateFile"; + + if (StringUtils.isNotEmpty(cardId)) { + String sql_ext4 = "select * from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '" + cardId + "'"; + RowMap map = DBSql.getMap(sql_ext4); + System.out.println("maps======>>>>>>>" + map); + System.out.println("fileid==》》》》" + fileid); + System.out.println("id==》》》》" + map.getString("ID")); + RowMap rowMap = DBSql + .getMap("SELECT * FROM " + bo_name + " where " + fileid + " '" + map.getString("ID") + "'"); + // BO bos = + // SDK.getBOAPI().query(bo_name,true).addQuery(fileid,"17e7d198-1656-4a2c-8912-a81850170be9").detail(); + if (rowMap != null) { + + if (StringUtils.isNotEmpty(rowMap.getString("TASKID"))) { + + OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID")); + if (model != null) { + System.out.println(",pdel============" + model); + System.out.println("123313123123123==========" + model.getProfileId()); + OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId()); + System.out.println("dajadfas======" + appProfile); + if (appProfile == null) { + throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId()); + } + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), + OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException( + "Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + String sql_lever = ""; + if (bo_name.equals("BO_ACT_COE_PUBLISH_N")) { + sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + + rowMap.getString("PUBLISHFILEID") + "'"; + + } else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")) { + sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + + rowMap.getString("CHANGEDFILEIDNEW") + "'"; + } + String lever = DBSql.getString(sql_lever); + System.out.println("版本号::::::::::::" + lever); + // lever = lever.substring(0,3); + if (lever.length() == 5 && lever.substring(4).equals("0")) { + lever.substring(0, 3); + } else if (lever.length() == 1) { + lever = lever + ".0"; + } + String filename = ""; + if (bo_name.equals("BO_ACT_COE_PUBLISH_N")) { + filename = rowMap.getString("PUBLISHFILENAME"); + } else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")) { + filename = rowMap.getString("CHANGEDFILENAMENEW"); + } + DCContext dcContext = new DCContext(userContext, dcProfile, appProfile.getAppContext().getId(), + model.getWsId(), rowMap.getString("TASKID"), filename + "_" + lever + ".doc"); + // UtilFile file = new UtilFile(dcContext.getPath()); + + Map params = new HashMap(); +//知识ID,必填 + params.put("cardId", cardId); +//sid,必填 + params.put("sid", userContext.getSessionId()); + + params.put("dc", dcContext); + AppAPI appAPI = SDK.getAppAPI(); +//创建文件 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("流程手册的存入=================" + ro); + } + } + + } + String sql_A = "SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where ID = '" + map.getString("ID") + + "' AND PLMETHODID != 'process.framework' AND PLMETHODID IN (select distinct PLMETHODID from APP_ACT_COE_PAL_REPOSITORY)"; + List rows = DBSql.getMaps(sql_A); + + for (RowMap bo : rows) { + + /** + * 这个是模型中的附件获取的并插入的数据信息,需要做修改 + */ + // 调用App + +// 参数定义列表 + Map paramss = new HashMap(); +//知识ID,必填 + paramss.put("cardId", cardId); +//sid,必填 + paramss.put("sid", userContext.getSessionId()); + + UpfileWeb upfileWeb = new UpfileWeb(userContext); + + String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID != 'process.framework' AND ID= '" + + map.getString("ID") + "'" + ")"; + List maps = DBSql.getMaps(sql_upfile); + for (RowMap row : maps) { + System.out.println("附件名称>>>>>>" + row.getString("FILENAME")); + if (!row.getString("FILENAME").contains(".xml")) { + UpfileModel upfileModel = new UpfileModel(); + upfileModel.setType(row.getString("FILETYPE")); + upfileModel.setFileName(row.getString("FILENAME")); + upfileModel.setPl_uuid(row.getString("PALREPOSITORYID")); + upfileModel.setShape_uuid(row.getString("SHAPEID")); + DCContext dcContexts = upfileWeb.getDCContext(upfileModel); + paramss.put("dc", dcContexts); + AppAPI appAPIs = SDK.getAppAPI(); + ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, paramss); + System.out.println("流程模型附件的生成=============" + ros); + } + } + +//DCContext对象,必填 + +//创建文件 + } + try { + + PublishKnow(processExecutionContext, userContext, cardId); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * 发布知识 + * + * @param processExecutionContext + * @param userContext + * @param id + */ + public void PublishKnow(ProcessExecutionContext processExecutionContext, UserContext userContext, String id) { + + String sql = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id in (select PLPARENTID from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '" + + id + "')"; + List maps = DBSql.getMaps(sql); + String ids = ""; + for (RowMap rowmap : maps) { + ids += rowmap.getString("EXT4") + ","; + } + String[] deptSplit_id = ids.split(","); + + JSONArray jsonArray = new JSONArray(); + for (String id_names : deptSplit_id) { + jsonArray.add(id_names); + } + // jsonObject.put(deptSplit_id); + id += ","; + String[] deptSplit_das = id.split(","); + JSONArray jsonArray_das = new JSONArray(); + for (String das : deptSplit_das) { + jsonArray_das.add(das); + } + // jsonObject.put(deptSplit_id); + + if (!jsonArray_das.isEmpty() && !jsonArray.isEmpty()) { + + // 调用App + String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl"; + // 参数定义列表 + Map params = new HashMap(); + //要发布到的维度ID的JSON数组字符串,必填 + params.put("dimensionIDArray", jsonArray.toString()); + //要发布的知识ID的JSON数组字符串,必填 + params.put("knwlIDArray", jsonArray_das.toString()); + //标签的JSON数组字符串,非必填 + + //sid,必填 + params.put("sid", userContext.getSessionId()); + AppAPI appAPI = SDK.getAppAPI(); + //发布知识 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + + System.out.println("知识发布============" + ro); + + } + + } + + /** + * 取消发布知识 + * + * @param processExecutionContext + * @param sid + * @param knwlId + * @return + */ + public boolean CancelPublishKnwl(ProcessExecutionContext processExecutionContext, String sid, String knwlId) { + // 调用App + String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/CancelPublishKnwl"; + // 参数定义列表 + Map params = new HashMap(); + //sid,如果为空,则需要传createUser参数,非必填 + params.put("sid", sid); + //知识ID,必填 + params.put("knwlId", knwlId); + AppAPI appAPI = SDK.getAppAPI(); + //取消发布知识(全部维度) + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("取消发布的ro=====>>>>" + ro); + return ro.isOk(); + } + + /** + * 创建XPage页面上的待阅文件 + * + * @param processExecutionContext + * @param fileCreateName + * @param fileName + * @param fileurl + * @param readingScope_org + * @param isFullCompany + * @param fileCreateDate + * @param relationProcessinstId + * @param readingScope_post + * @param readingScope_level + * @param fileid + * @return + */ + public boolean execute(ProcessExecutionContext processExecutionContext, String fileCreateName, String fileName, + String fileurl, String readingScope_org, String isFullCompany, String fileCreateDate, + String relationProcessinstId, String readingScope_post, String readingScope_level, String fileid) { + // 调用App + String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + // aslp服务地址 + String aslp = "aslp://com.awspaas.user.apps.docview/PushFileToXpage"; + // 参数定义列表 + Map params = new HashMap(); + //发布人,不允许空值,必填 + params.put("fileCreateName", fileCreateName); + //待阅文件标题名称,不允许空值,必填 + params.put("fileName", fileName); + //阅读范围_组织,不允许空值,非必填 + params.put("readingScope_org", readingScope_org); + //是否全公司可见,不允许空值,必填 + params.put("isFullCompany", isFullCompany); + //待阅文件Url,不允许空值,必填 + params.put("fileurl", fileurl); + //发布日期,不允许空值,必填 + params.put("fileCreateDate", fileCreateDate); + //发布流程ID,不允许空值,必填 + params.put("relationProcessinstId", relationProcessinstId); + //阅读范围_岗位,不允许空值,非必填 + params.put("readingScope_post", readingScope_post); + //阅读范围_职级,不允许空值,非必填 + params.put("readingScope_level", readingScope_level); + //待阅文件ID,多个逗号隔开,不允许空值,必填 + params.put("fileid", fileid); + AppAPI appAPI = SDK.getAppAPI(); + //推送待阅文件到xpage门户 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("ros++++++++=====待阅》》》》》》》》》》" + ro); + return ro.isOk(); + } + + /** + * 给知识授权 + * + * @param processExecutionContext + * @param jsonArray + * @param sid + * @param knwlId + * @return + */ + public boolean AddKnwlAC(ProcessExecutionContext processExecutionContext, JSONArray jsonArray, String sid, + String knwlId) { + // 调用App + String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC"; + // 参数定义列表 + Map params = new HashMap(); + //[{"assignmentType":"department","assignmentId":"62196ff9-a26d-4be5-9480-3ef680886f63"},{"assignmentType":"user","assignmentId":"user1"}],必填 + params.put("acList", jsonArray); + //sid,如果为空,则需要传createUser参数,非必填 + params.put("sid", sid); + //知识ID,必填 + params.put("knwlId", knwlId); + AppAPI appAPI = SDK.getAppAPI(); + //给知识授权 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + return ro.isOk(); + } + + /** + * 柱军的ASLP + * + * @param processExecutionContext + * @param wsId + * @param fileId + * @return + */ + public boolean AttrSynAslp(ProcessExecutionContext processExecutionContext, String wsId, JSONArray fileId) { + System.out.println(""); + // 调用App + String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); + // aslp服务地址 + String aslp = "aslp://com.awspaas.user.apps.yili.reportform/AttrSynAslp"; + // 参数定义列表 + Map params = new HashMap(); + //资产内容库id,必填 + params.put("wsId", wsId); + //文件id;json数组[id1,id2,id3],必填 + params.put("fileId", fileId); + AppAPI appAPI = SDK.getAppAPI(); + //增量同步数据 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("同步数据看板底表结果>>>>>>>>>>>>>" + ro); + return ro.isOk(); + } + + /** + * 发送OA待阅数据 + * + * @param jsonObject + * @param processInstance + * @param results + * @throws DocumentException + */ + public void SendOARead(JSONObject jsonObject, ProcessInstance processInstance, String userId) + throws DocumentException { + //System.err.println(processInstance.getTitle() + "开始发送:" + userId); + if ("".equals(userId) || UtilString.isEmpty(userId)) { + return; + } + jsonObject.put("userList", userId); + String xmlStr = "\n" + + " " + " " + " " + " " + + "" + " " + " " + + " " + ""; + //System.out.println("xmlStr>>>>>>>>" + xmlStr); + String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl"); + + String postSoap = UtilUrl.doPostSoap(readurl, xmlStr, ""); + Document document = DocumentHelper.parseText(postSoap); + Element rootElement = document.getRootElement(); + //System.out.println("rootElement>>>>>>" + rootElement); + Element result = rootElement.element("Body").element("serviceResponse").element("out"); + String resultString = result.getData().toString(); + JSONObject jsonObject1 = JSON.parseObject(resultString); + String datas = jsonObject1.getString("data"); + String status = jsonObject1.getString("status"); + //System.out.println("推送》》》》》》》》》》》" + status); + if ("false".equals(status)) { + System.out.println(processInstance.getTitle() + "待阅推送失败:" + userId); + try { + BO bo = new BO(); + bo.set("TITLE", processInstance.getTitle()); + bo.set("NAME", userId); + bo.set("DEPNAME", SDK.getORGAPI().getUser(userId).getDepartmentId()); + SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser()); + } catch (Exception e) { + // TODO: handle exception + } + } else { + System.out.println(processInstance.getTitle() + "待阅推送成功:" + userId); + JSONArray resultArray = JSONObject.parseArray(datas); + for (int j = 0; j < resultArray.size(); j++) { + JSONObject jsonObject2 = resultArray.getJSONObject(j); + String user = jsonObject2.get("user").toString(); + String dataid = jsonObject2.get("dataid").toString(); + BO bo = new BO(); + bo.set("TITLE", processInstance.getTitle()); + bo.set("PROCESSID", processInstance.getId()); + bo.set("USER_ID", user); + bo.set("DATAID", dataid); + bo.set("RESULT", status); + SDK.getBOAPI().create("BO_ACT_DATAID", bo, processInstance.getId(), processInstance.getCreateUser()); + } + } + } + + /** + * 发送EHSQ数据 + * + * @param jsonArray + * @return + * @throws Exception + */ + public String SendEHSQFile(JSONArray jsonArray) throws Exception { + System.out.println("===jsonArray===" + jsonArray); + /** + * 首先需要将传过来的参数进行加密操作,并设置 + */ + AesUtil aesUtil = new AesUtil(); + String system = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "system"); + String AES = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "AES"); + String EHSQUrl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "EHSQUrl"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String date = sdf.format(new Date()); + String s1 = date.replaceAll("-", "").replaceAll(" ", "").replaceAll(":", ""); + + System.out.println("时间>>>>>>>>>>>>" + s1); + String data = system + "##" + s1; + String encrypt = aesUtil.encrypt(data, AES); // 获取加密之后的秘钥 + JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); + jsonObject.put("system", system); + jsonObject.put("token", encrypt); + jsonObject.put("infos", jsonArray); + HttpUtil httpUtil = new HttpUtil(); + System.out.println("jsonobject>>>>>>>>>>>>>>>>>>>" + jsonObject); + String s = httpUtil.sendPost(jsonObject, EHSQUrl); + System.out.println("发送到EHSQ是否是正确的>>>>>>>>>" + s); + + return s; + } + + public ArrayList getSendList(ProcessInstance instanceById, BO bo_act_coe_publish1, JSONObject jsonObject) { + String sendType = bo_act_coe_publish1.getString("SEND_SCOP"); + String org = bo_act_coe_publish1.getString("SEND_SCOPE_ORG"); + String post = bo_act_coe_publish1.getString("SEND_SCOPE_POST"); + String level = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL"); + ArrayList userList = new ArrayList<>(); + if ("1".equals(sendType)) { + System.err.println("发送全集团=====>" + instanceById.getTitle()); + userList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, sendType); + + } else { + // 如果都不为空,组织/岗位取并集的结果同职级取交集 + if (UtilString.isNotEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isNotEmpty(level)) { + System.err.println("发送组织/岗位/职级=====>" + instanceById.getTitle()); + ArrayList sendOrgList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, + sendType); + ArrayList sendPostList = sendPost(post, sendOrgList, instanceById, bo_act_coe_publish1, + jsonObject); + userList = sendLevel(level, sendPostList, instanceById, bo_act_coe_publish1, jsonObject); + } + // 如果职级为空,组织/岗位取并集 + if (UtilString.isNotEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isEmpty(level)) { + System.err.println("发送组织/岗位=====>" + instanceById.getTitle()); + ArrayList sendOrgList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, + sendType); + userList = sendPost(post, sendOrgList, instanceById, bo_act_coe_publish1, jsonObject); + } + // 如果岗位为空,组织/职级取交集 + if (UtilString.isNotEmpty(org) && UtilString.isEmpty(post) && UtilString.isNotEmpty(level)) { + System.err.println("发送组织/职级=====>" + instanceById.getTitle()); + ArrayList sendOrgList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, + sendType); + userList = sendLevel(level, sendOrgList, instanceById, bo_act_coe_publish1, jsonObject); + } + + // 如果组织为空,岗位/职级取交集 + if (UtilString.isEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isNotEmpty(level)) { + System.err.println("发送岗位/职级=====>" + instanceById.getTitle()); + ArrayList sendPostList = sendPost(post, userList, instanceById, bo_act_coe_publish1, + jsonObject); + userList = sendLevel(level, sendPostList, instanceById, bo_act_coe_publish1, jsonObject); + } + // 如果只有组织不为空 + if (UtilString.isNotEmpty(org) && UtilString.isEmpty(post) && UtilString.isEmpty(level)) { + System.err.println("发送组织=====>" + instanceById.getTitle()); + userList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject,sendType); + } + // 如果只有岗位不为空 + if (UtilString.isEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isEmpty(level)) { + System.err.println("发送岗位=====>" + instanceById.getTitle()); + userList = sendPost(post, userList, instanceById, bo_act_coe_publish1,jsonObject); + } + // 如果只有职级不为空 + if (UtilString.isEmpty(org) && UtilString.isEmpty(post) && UtilString.isNotEmpty(level)) { + System.err.println("发送职级=====>" + instanceById.getTitle()); + userList = sendLevel2(level, userList, instanceById, bo_act_coe_publish1, jsonObject); + } + + + } + + return userList; + + } + + // 发送组织 + public ArrayList sendOrg(String org, ArrayList userList, ProcessInstance instanceById, + BO bo_act_coe_publish1, JSONObject jsonObject, String sendType) { + String processid = instanceById.getId(); + // 获取组织 + if (StringUtils.isNotEmpty(org) || "1".equals(sendType)) { + long startTime = System.currentTimeMillis(); + userList = getUser(jsonObject, org, sendType, processid); + long endTimes = System.currentTimeMillis(); + // System.out.println(instanceById.getTitle()+"_根据部门获取人员用时===>"+(endTimes-startTime)/1000); + } + + return userList; + } + + // 发送岗位 + public ArrayList sendPost(String post, ArrayList userList, ProcessInstance instanceById, + BO bo_act_coe_publish1, JSONObject jsonObject) { + String processid = instanceById.getId(); + // 获取岗位 + if (StringUtils.isNotEmpty(post)) { + String posts[] = post.split(","); + // 取并集 + String postss = ""; + if (posts.length == 1) { + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + postss = "'" + posts[0] + "'"; + } else { + postss = "'" + StringUtils.join(posts, "','") + "'"; + } + String sql = "select * from ORGUSER where POSITION_NO in (" + postss + ") and userno is not null"; + List maps1 = DBSql.getMaps(sql); + for (RowMap rowMap : maps1) { + String userId = rowMap.getString("USERID"); + if (!userList.contains(userId)) { + userList.add(userId); + } + + } + } + + return userList; + } + + // 发送职级 + public ArrayList sendLevel(String level, ArrayList userList, ProcessInstance instanceById, + BO bo_act_coe_publish1, JSONObject jsonObject) { + String processid = instanceById.getId(); + ArrayList userList_level = new ArrayList(); + // 获取职级 + if (StringUtils.isNotEmpty(level)) { + String ranks[] = level.split(","); + String rankss = ""; + if (ranks.length == 1) { + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + rankss = "'" + ranks[0] + "'"; + } else { + rankss = "'" + StringUtils.join(ranks, "','") + "'"; + } + // 取交集 + String sql2 = "select * from ORGUSER where EXT2 in (" + rankss + ") and userno is not null"; + List maps2 = DBSql.getMaps(sql2); + for (RowMap rowMap : maps2) { + String userId = rowMap.getString("USERID"); + if (userList.contains(userId)) { + userList_level.add(userId); + } + + } + } + + return userList_level; + } + + // 只发送职级 + public ArrayList sendLevel2(String level, ArrayList userList, ProcessInstance instanceById, + BO bo_act_coe_publish1, JSONObject jsonObject) { + String processid = instanceById.getId(); + ArrayList userList_level = new ArrayList(); + // 获取职级 + if (StringUtils.isNotEmpty(level)) { + String ranks[] = level.split(","); + String rankss = ""; + if (ranks.length == 1) { + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + rankss = "'" + ranks[0] + "'"; + } else { + rankss = "'" + StringUtils.join(ranks, "','") + "'"; + } + // 取交集 + String sql2 = "select * from ORGUSER where EXT2 in (" + rankss + ") and userno is not null"; + List maps2 = DBSql.getMaps(sql2); + for (RowMap rowMap : maps2) { + String userId = rowMap.getString("USERID"); + userList_level.add(userId); + } + } + return userList_level; + } + + /** + * 根据部门id获取当前部门以及下级部门的人员信息 + * + * @param processid + * @return + */ + + public ArrayList getUser(JSONObject jsonObject, String depIds, String sendType, String processid) { + ArrayList arr = new ArrayList(); + ArrayList arr_test = new ArrayList(); + // 全集团 + if ("1".equals(sendType)) { + List departmentsByCompanyId = SDK.getORGAPI().getDepartmentsByCompanyId(1, + "8911e732-b42a-4556-853f-ad32761bcbee"); + for (DepartmentModel departmentModel : departmentsByCompanyId) { + String id = departmentModel.getId(); + // 查询未注销的部门并且去掉系统部门 + if (!departmentModel.isClosed() && !"e79281b1-2f81-4895-b30e-9f96e9ad0e2c".equals(id)) { + getUserList(jsonObject, arr_test, arr, id, processid); + + } + } + } else { + if (UtilString.isNotEmpty(depIds)) { + String[] split = depIds.split(","); + for (String depId : split) { + getUserList(jsonObject, arr_test, arr, depId, processid); + } + } + } + + // System.err.println(SDK.getProcessAPI().getInstanceById(processid) + + // "_得到的总人数为:" + arr_test.size()); + // System.err.println(SDK.getProcessAPI().getInstanceById(processid) + + // "_得到的过滤后的人数为:" + arr.size()); + return arr; + } + + public void getUserList(JSONObject jsonObject, ArrayList arr_test, ArrayList arr, + String departmentId, String processid) { + // 获取当前部门下人员 + List userModelList = SDK.getORGAPI().getAllUsersByDepartment(departmentId); + for (UserModel userModel : userModelList) { + if (!userModel.isClosed()) { + String uid = userModel.getUID(); + if (!arr.contains(uid)) { + arr_test.add(uid); + arr.add(userModel.getUID()); + /* + * RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '" + * + processid + "' AND USER_ID = '" + uid + "'"); if (map == null) { + * //System.err.println("发送人员======>" + uid); } + */ + } + } + } + // 获取当前部门的子部门人员 + DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(departmentId); + if (departmentById.isExistSubModelOfCache()) { + getSubDepartments(jsonObject, arr_test, arr, departmentById, processid); + } + + } + + // 获取子部门人员 + public void getSubDepartments(JSONObject jsonObject, ArrayList arr_test, ArrayList arr, + DepartmentModel departmentById, String processid) { + if (!departmentById.isClosed()) { + List subDepartments = SDK.getORGAPI().getSubDepartments(departmentById.getId()); + for (DepartmentModel departmentModel : subDepartments) { + if (!departmentModel.isClosed()) { + String id = departmentModel.getId(); + List userModelList = SDK.getORGAPI().getAllUsersByDepartment(id); + for (UserModel userModel : userModelList) { + if (!userModel.isClosed()) { + String uid = userModel.getUID(); + if (!arr.contains(uid)) { + arr_test.add(uid); + arr.add(uid); + //System.err.println(SDK.getProcessAPI().getInstanceById(processid) + "_发送人员======>" + uid); + + } + } + } + // 递归获取子部门下的子部门 + if (SDK.getORGAPI().isExistSubDepartment(id)) { + getSubDepartments(jsonObject, arr_test, arr, SDK.getORGAPI().getDepartmentById(id), processid); + } + + } + + } + } + } + /** + * 创建线程发送待阅 + * + * @param list 人员集合 + * @param startTime 开始时间 + * @param jsonObject 发送的json串 + * @param processExecutionContext 流程数据 + */ + /* + * public void course(List list,long startTime,JSONObject + * jsonObject,ProcessExecutionContext processExecutionContext){ // + * 创建线程来实现为每300人为一个的线程跑待阅 ExecutorService service = + * Executors.newFixedThreadPool(4); service.execute(new Runnable() { + * + * @Override public void run() { int i=0; for (String[] resrt:list ) { + * + * if ((list.size()-1)==i){ long endTime = System.currentTimeMillis(); + * + * long time = endTime - startTime; long itmes = time/1000/60/60; BO + * bo_eu_pal_read_log = SDK.getBOAPI().query("BO_EU_PAL_READ_LOG", + * true).addQuery("PROCESSID = ", + * processExecutionContext.getProcessInstance().getId()).detail(); + * bo_eu_pal_read_log.set("ENDTIMES",endTime); + * bo_eu_pal_read_log.set("TIMECOUNT",itmes); + * SDK.getBOAPI().update("BO_EU_PAL_READ_LOG",bo_eu_pal_read_log); } try { + * SendOARead(jsonObject,processExecutionContext,resrt); } catch + * (DocumentException e) { e.printStackTrace(); } i++; } } }); } + */ + + /** + * 创建待阅日志 + * + * @param processExecutionContext + * @param jsonObject + * @param users + * @param startTime + */ + + public void createReadLog(ProcessExecutionContext processExecutionContext, JSONObject jsonObject, ArrayList arr, + long startTime,long endTimes) { + BO bo_Read_log = new BO(); + bo_Read_log.set("USREID", processExecutionContext.getUserContext().getUID()); + bo_Read_log.set("DEPID", processExecutionContext.getUserContext().getDepartmentModel().getId()); + bo_Read_log.set("BUNAME", processExecutionContext.getUserContext().getUserModel().getExt4()); + bo_Read_log.set("TITLE", jsonObject.get("title")); + bo_Read_log.set("PROCESSID", processExecutionContext.getProcessInstance().getId()); + bo_Read_log.set("SENDNUM", arr.size()); + BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true) + .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()) + .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + String send_scop = bo_act_coe_publishs.getString("SEND_SCOP"); + bo_Read_log.set("SEND_SCOP", send_scop); + String SEND_SCOPE_ORG = bo_act_coe_publishs.getString("SEND_SCOPE_ORG"); + if (UtilString.isNotEmpty(SEND_SCOPE_ORG)) { + String[] resulr = SEND_SCOPE_ORG.split(","); + bo_Read_log.set("SEND_SCOPE_ORGNUM", resulr.length); + } + String SEND_SCOPE_POST = bo_act_coe_publishs.getString("SEND_SCOPE_POST"); + if (UtilString.isNotEmpty(SEND_SCOPE_POST)) { + String[] resulr = SEND_SCOPE_POST.split(","); + bo_Read_log.set("SEND_SCOPE_POST_NUM", resulr.length); + } + String SEND_SCOPE_LEVEL = bo_act_coe_publishs.getString("SEND_SCOPE_LEVEL"); + if (UtilString.isNotEmpty(SEND_SCOPE_LEVEL)) { + String[] resulr = SEND_SCOPE_LEVEL.split(","); + bo_Read_log.set("SEND_SCOPE_LEVEL_NUM", resulr.length); + } + + bo_Read_log.set("STARTTIMES", startTime); + bo_Read_log.set("ENDTIMES", endTimes); + bo_Read_log.set("TIMECOUNT", (endTimes-startTime)/1000/60+"分钟"); + //文件发布成功回执流程 + ProcessInstance processInst = SDK.getProcessAPI().createProcessInstance("obj_b4700f89a7a144c086d047de0cfe9531", "admin", jsonObject.get("title")+"成功发布回执单"); + SDK.getBOAPI().create("BO_EU_PAL_PULBISH_SUCCESS", bo_Read_log, processInst,UserContext.fromUID("admin")); + TaskInstance taskInst = SDK.getProcessAPI().start(processInst).fetchActiveTasks().get(0); + SDK.getTaskAPI().completeTask(taskInst.getId(), "admin"); + + } + + /** + * 通过发布知识创建知识 + * + * @param bo 发布清单表数据 + * @param wsId 知识库id + * @param filed 文件集合JsonArray格式 + * @param processExecutionContext 流程数据 + * @param bo_act_coe_publish 发布表 + * @param uid 账户合计 + */ + public void createKmsByNew(BO bo, String wsId, JSONArray filed, ProcessExecutionContext processExecutionContext, + BO bo_act_coe_publish, String uid) { + { + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("PUBLISHFILEID"); + filed.add(publishfileid); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; + RowMap map = DBSql.getMap(sql_n); + if (StringUtils.isEmpty(map.getString("EXT4"))) { + // aslp服务地址 + String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl"; +// 参数定义列表 + Map params_create = new HashMap(); +//保密级别, 0: 普通 1:秘密 2:机密,必填 + params_create.put("securityLevel", 0); +//知识名称,必填 + + String level = ""; + + if (map.getString("PLVER").contains(".00")) { + String[] plvers = map.getString("PLVER").split("\\."); + plvers[1] = plvers[1].replaceAll("0", ""); + level = plvers[0] + "." + plvers[1]; + } else { + level = map.getString("PLVER"); + } + + params_create.put("knwlName", map.getString("PLNAME") + "V" + level); +//是否可以评论,必填 + params_create.put("isComment", true); +//是否可以评分,必填 + params_create.put("isRate", true); +//有效期:yyyy-MM-dd,非必填 + params_create.put("validDate", "2099-12-31"); +//只读控制,1:在线阅读和下载 0:在线阅读,必填 + params_create.put("onlineLevel", 1); +//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填 + params_create.put("createUser", "admin"); +//知识内容,非必填 + params_create.put("cardContext", ""); +//sid,必填 + params_create.put("sid", processExecutionContext.getUserContext().getSessionId()); + AppAPI appAPI_create = SDK.getAppAPI(); +//创建知识 + ResponseObject ro_create = appAPI_create.callASLP( + appAPI_create.getAppContext(processExecutionContext.getProcessInstance().getAppId()), + aslps_create, params_create); + System.out.println("ro_create================" + ro_create); + String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); + JSONArray jsonArray1 = new JSONArray(); + if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")) { + String departId = bo_act_coe_publish.getString("SEND_SCOPE_ORG"); + if (StringUtils.isNotEmpty(departId) + && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_LEVEL")) + && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_POST"))) { + String strs[] = departId.split(","); + for (String departmentid : strs) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", departmentid); + jsonArray1.add(jsonObjecta); + } + } else { + + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + + for (String user_id : list) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "user"); + jsonObjecta.put("assignmentId", user_id); + jsonArray1.add(jsonObjecta); + } + } + } else { + List select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT"); + for (RowMap depaid : select_id_from_orgdepartment) { + String id = depaid.getString("ID"); + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", id); + jsonArray1.add(jsonObjecta); + } + } + + AddKnwlAC(processExecutionContext, jsonArray1, processExecutionContext.getUserContext().getSessionId(), + cardId); + + String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '" + cardId + "' WHERE " + + " PLCATEGORY = 'process'and PLMETHODID !='process.framework' " + + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + " '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + " '42c09260-c1d3-44b7-ac3d-f8280e04c294') and ID = '" + publishfileid + "'"; + int update = DBSql.update(update_sql); + System.out.println("更新id为:" + publishfileid + "版本为:的知识对应的资产库的EXT4的影响行数为" + update); + creadteFile(processExecutionContext, "BO_ACT_COE_PUBLISH_N", processExecutionContext.getUserContext(), + cardId, "PUBLISHFILEID = "); + } + } + } + + /** + * 发布生成kms知识 + * + * @param bo 更新发布清单表 + * @param wsId 知识库id + * @param filed 发布清单的发布id + * @param processExecutionContext 流程数据 + * @param bo_act_coe_publish 发布表 + * @param uid 账户集合 + */ + public void CreateKmsByupdate(BO bo, String wsId, JSONArray filed, ProcessExecutionContext processExecutionContext, + BO bo_act_coe_publish, String uid) { + { + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("CHANGEDFILEIDNEW"); + filed.add(publishfileid); + DBSql.update("update APP_ACT_COE_PAL_REPOSITORY set EXT4 = '' where id = '" + publishfileid + "'"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; + RowMap map = DBSql.getMap(sql_n); + if (StringUtils.isEmpty(map.getString("EXT4"))) { + // aslp服务地址 + String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl"; +// 参数定义列表 + Map params_create = new HashMap(); +//保密级别, 0: 普通 1:秘密 2:机密,必填 + params_create.put("securityLevel", 0); +//知识名称,必填 + String level = ""; + if (map != null) { + if (map.getString("PLVER").contains(".00")) { + String[] plvers = map.getString("PLVER").split("\\."); + plvers[1] = plvers[1].replaceAll("0", ""); + level = plvers[0] + "." + plvers[1]; + } else { + level = map.getString("PLVER"); + } + } + + params_create.put("knwlName", map.getString("PLNAME") + "V" + level); +//是否可以评论,必填 + params_create.put("isComment", true); +//是否可以评分,必填 + params_create.put("isRate", true); +//有效期:yyyy-MM-dd,非必填 + params_create.put("validDate", "2099-12-31"); +//只读控制,1:在线阅读和下载 0:在线阅读,必填 + params_create.put("onlineLevel", 1); +//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填 + params_create.put("createUser", "admin"); +//知识内容,非必填 + params_create.put("cardContext", ""); +//sid,必填 + params_create.put("sid", processExecutionContext.getUserContext().getSessionId()); + AppAPI appAPI_create = SDK.getAppAPI(); +//创建知识 + ResponseObject ro_create = appAPI_create.callASLP( + appAPI_create.getAppContext(processExecutionContext.getProcessInstance().getAppId()), + aslps_create, params_create); + System.out.println("ro_create================" + ro_create); + String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); + JSONArray jsonArray1 = new JSONArray(); + if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")) { + String departId = bo_act_coe_publish.getString("SEND_SCOPE_ORG"); + if (StringUtils.isNotEmpty(departId) + && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_LEVEL")) + && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_POST"))) { + String strs[] = departId.split(","); + for (String departmentid : strs) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", departmentid); + jsonArray1.add(jsonObjecta); + } + } else { + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + + for (String user_id : list) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "user"); + jsonObjecta.put("assignmentId", user_id); + jsonArray1.add(jsonObjecta); + } + } + + } else { + List select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT"); + for (RowMap depaid : select_id_from_orgdepartment) { + String id = depaid.getString("ID"); + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", id); + jsonArray1.add(jsonObjecta); + } + } + AddKnwlAC(processExecutionContext, jsonArray1, processExecutionContext.getUserContext().getSessionId(), + cardId); + + String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '" + cardId + "' WHERE " + + " PLCATEGORY = 'process'and PLMETHODID !='process.framework' " + + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + " '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + " '42c09260-c1d3-44b7-ac3d-f8280e04c294') and ID = '" + publishfileid + "'"; + int update = DBSql.update(update_sql); + System.out.println("更新id为:" + publishfileid + "版本为:的知识对应的资产库的EXT4的影响行数为" + update); + creadteFile(processExecutionContext, "BO_ACT_COE_PUBLISH_C", processExecutionContext.getUserContext(), + cardId, " CHANGEDFILEIDNEW="); + } + // 将旧的知识取消发布或者移动到废止发布中 + String publishfileid_old = bo.getString("CHANGEFILEID"); + String sql_c = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid_old + "'"; + RowMap map1 = DBSql.getMap(sql_c); + if (StringUtils.isNotEmpty(map1.getString("EXT4"))) { + CancelPublishKnwl(processExecutionContext, processExecutionContext.getUserContext().getSessionId(), + map1.getString("EXT4")); + DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '" + publishfileid_old + "'"); + } + } + } + + // 创建推送日志 + public void createLog(ProcessInstance instanceById, String uids) { + BO bo = new BO();// BO_EU_PAL_SEND_LOG + bo.set("USREID", instanceById.getCreateUser()); + bo.set("TITLE", instanceById.getTitle()); + bo.set("SENDTIME", instanceById.getEndTime()); + bo.set("PROCESSID", instanceById.getId()); + bo.set("USERNAMES", uids); + bo.set("DEPID", UserContext.fromUID(uids).getDepartmentModel().getId()); + bo.set("POSTNAME", UserContext.fromUID(uids).getUserModel().getPositionName()); + bo.set("BUNAME", UserContext.fromUID(uids).getUserModel().getExt2()); + SDK.getBOAPI().createDataBO("BO_EU_PAL_SEND_LOG", bo, UserContext.fromUID("admin")); + } + + public void sendEHSQ(ProcessExecutionContext processExecutionContext,List bo_act_coe_publish_n) { + for (BO bo : bo_act_coe_publish_n) { + DownloadUtil downloadUtil = new DownloadUtil(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + JSONArray jsonArray_EHSQ = new JSONArray(); + JSONObject jsonObject_ehsq = new JSONObject(new LinkedHashMap<>()); + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + String wsId = model.getWsId(); + String publishfileid = bo.getString("PUBLISHFILEID"); + LinkedHashMap downloadurl = downloadUtil.outputReportDownload( + UserContext.fromUID(processExecutionContext.getProcessInstance().getCreateUser()), + bo.getString("TASKID"), publishfileid); + jsonObject_ehsq.put("fileid", bo.getString("TASKID")); + jsonObject_ehsq.put("filename", bo.getString("PUBLISHFILENAME")); + // jsonObject_ehsq.put("filecode",bo.getString("PUBLISH_NUMBER")); + jsonObject_ehsq.put("filecode", "123456"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; + RowMap map = DBSql.getMap(sql_n); + jsonObject_ehsq.put("version", map.getString("PLVER")); + jsonObject_ehsq.put("releasedate", simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("effectivedate", simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("authorcode", processExecutionContext.getTaskInstance().getTarget()); // jsonObject_ehsq.put("authorcode","00116465"); + jsonObject_ehsq.put("authorname", + UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); + // jsonObject_ehsq.put("authorname","毛鹏程"); + jsonObject_ehsq.put("companycode", + UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()) + .getDepartmentModel().getNo()); + // jsonObject_ehsq.put("companycode","00000013"); + jsonObject_ehsq.put("authorcompany", + UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()) + .getDepartmentModel().getName()); // jsonObject_ehsq.put("authorcompany","总部质量管理部"); + // // + jsonObject_ehsq.put("releasescope", "总部质量管理部"); + BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true) + .addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); + if (bo1 != null) { + if (bo1.getString("PERMTYPE").equals("1")) { + } else { + + String departname = ""; + String orgperm = bo1.getString("ORGPERM"); + String dleass = ""; + String[] deptSplit = orgperm.split(","); + if (deptSplit.length == 1) { + dleass = "'" + deptSplit[0] + "'"; + } + dleass = "'" + StringUtils.join(deptSplit, "','") + "'"; + + List maps = DBSql + .getMaps("select DEPARTMENTNAME from ORGDEPARTMENT where ID in (" + dleass + ")"); + for (RowMap rowmas : maps) { + departname += rowmas.getString("DEPARTMENTNAME") + ";"; + } + jsonObject_ehsq.put("releasescope", "总部质量管理部"); + + } + } + + System.out.println("任务办理者>>>>>>>>>>>" + processExecutionContext.getTaskInstance().getTarget()); + String sessionId = new SSOUtil().registerClientSessionNoPassword( + processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", + LoginConst.DEVICE_PC); + + System.out.println("办理者的sessionid>>>>>>>>>>>" + sessionId); + String downurl = downloadUtil.getzipURL(sessionId, bo.getString("TASKID"), + bo.getString("PUBLISHFILENAME")); + // jsonObject_ehsq.put("downloadurl","http://bpm.yili.com:8088/portal/r"+downurl.toString().substring(1)); + String recordfiles = ""; + String recordurls = ""; + Set keys = downloadurl.keySet(); + for (String key : keys) { + recordfiles += key + ";"; + String cent_url = downloadurl.get(key).substring(downloadurl.get(key).indexOf("/df"), + downloadurl.get(key).length()); + String fileDownurl = "http://bpm.yili.com:8088/portal/r" + cent_url; + recordurls += fileDownurl + ";"; + } + String new_name = ""; + String[] split = recordfiles.split(";"); + if (split.length > 0) { + + for (int i = 1; i < split.length; i++) { + new_name += split[i] + ";"; + } + } + + String new_url = ""; + String[] urls = recordurls.split(";"); + if (urls.length > 0) { + String loadurl = urls[0].replaceAll("&sid=null", "&sid=" + sessionId); + System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<" + loadurl); + jsonObject_ehsq.put("downloadurl", loadurl); + for (int i = 1; i < urls.length; i++) { + String data_url = urls[i].replaceAll("&sid=null", "&sid=" + sessionId); + new_url += data_url + ";"; + } + } + jsonObject_ehsq.put("recordfiles", new_name); + jsonObject_ehsq.put("recordurls", new_url); + jsonArray_EHSQ.add(jsonObject_ehsq); + try { + SendEHSQFile(jsonArray_EHSQ); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public void updateEHSQ(ProcessExecutionContext processExecutionContext,List bo_act_coe_publish_c) { + DownloadUtil downloadUtil = new DownloadUtil(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + for (BO bo : bo_act_coe_publish_c) { + JSONArray jsonArray_EHSQ = new JSONArray(); + JSONObject jsonObject_ehsq = new JSONObject(new LinkedHashMap<>()); + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + String wsId = model.getWsId(); + String publishfileid = bo.getString("CHANGEDFILEIDNEW"); + LinkedHashMap downloadurl = downloadUtil.outputReportDownload( + UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()), + bo.getString("TASKID"), publishfileid); + jsonObject_ehsq.put("fileid", bo.getString("TASKID")); + jsonObject_ehsq.put("filename", bo.getString("CHANGEDFILENAMENEW")); + // jsonObject_ehsq.put("filecode",bo.getString("CHANGE_NUMBER")); + jsonObject_ehsq.put("filecode", "123456"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; + RowMap map = DBSql.getMap(sql_n); + jsonObject_ehsq.put("verion", map.getString("PLVER")); + jsonObject_ehsq.put("releasedate", simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("effectivedate", simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("authorcode", processExecutionContext.getTaskInstance().getTarget()); + jsonObject_ehsq.put("authorname", + UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); + jsonObject_ehsq.put("companycode", + UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()) + .getDepartmentModel().getNo()); + jsonObject_ehsq.put("authorcompany", + UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()) + .getDepartmentModel().getName()); + BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true) + .addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); + if (bo1 != null) { + if (bo1.getString("PERMTYPE").equals("1")) { + jsonObject_ehsq.put("releasescope", "内蒙古伊利实业集团股份有限公司"); + } else { + + String departname = ""; + String orgperm = bo1.getString("ORGPERM"); + String dleass = ""; + String[] deptSplit = orgperm.split(","); + if (deptSplit.length == 1) { + dleass = "'" + deptSplit[0] + "'"; + } + dleass = "'" + StringUtils.join(deptSplit, "','") + "'"; + + List maps = DBSql + .getMaps("select DEPARTMENTNAME from ORGDEPARTMENT where ID in (" + dleass + ")"); + for (RowMap rowmas : maps) { + departname += rowmas.getString("DEPARTMENTNAME") + ";"; + } + jsonObject_ehsq.put("releasescope", departname); + + } + } + + String sessionId = new SSOUtil().registerClientSessionNoPassword( + processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", + LoginConst.DEVICE_PC); + + String downurl = downloadUtil.getzipURL(sessionId, bo.getString("TASKID"), + bo.getString("CHANGEDFILENAMENEW")); + String recordfiles = ""; + String recordurls = ""; + Set keys = downloadurl.keySet(); + for (String key : keys) { + recordfiles += key + ";"; + String cent_url = downloadurl.get(key).substring(downloadurl.get(key).indexOf("/df"), + downloadurl.get(key).length()); + String fileDownurl = "http://bpm.yili.com:8088/portal/r" + cent_url; + recordurls += fileDownurl + ";"; + } + String new_name = ""; + String[] split = recordfiles.split(";"); + if (split.length > 0) { + + for (int i = 1; i < split.length; i++) { + new_name += split[i] + ";"; + } + } + + String new_url = ""; + String[] urls = recordurls.split(";"); + if (urls.length > 0) { + String loadurl = urls[0].replaceAll("&sid=null", "&sid=" + sessionId); + System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<" + loadurl); + jsonObject_ehsq.put("downloadurl", loadurl); + for (int i = 1; i < urls.length; i++) { + String data_url = urls[i].replaceAll("&sid=null", "&sid=" + sessionId); + new_url += data_url + ";"; + } + } + jsonObject_ehsq.put("recordfiles", new_name); + jsonObject_ehsq.put("recordurls", new_url); + jsonArray_EHSQ.add(jsonObject_ehsq); + try { + SendEHSQFile(jsonArray_EHSQ); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } +} \ No newline at end of file diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/sendReadByDataid2.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/sendReadByDataid2.java new file mode 100644 index 00000000..37913d8b --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/sendReadByDataid2.java @@ -0,0 +1,1393 @@ +package com.awspaas.user.apps.integration.job; + +import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst; +import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; +import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager; +import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile; +import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb; +import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +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.database.RowMap; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.server.fs.DCContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.bpms.util.UtilString; +import com.actionsoft.emm.util.AesUtil; +import com.actionsoft.exception.AWSException; +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 com.awspaas.user.apps.integration.util.HttpUtil; +import com.awspaas.user.apps.integration.util.UtilUrl; +import org.apache.commons.lang.StringUtils; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +@SuppressWarnings("all") +public class sendReadByDataid2 { + public void execute(String processid, String taskid) throws JobExecutionException { + ProcessInstance instanceById = SDK.getProcessAPI().getInstanceById(processid); + TaskInstance taskInstance = SDK.getTaskAPI().getInstanceById(taskid); + String wsId = ""; + JSONArray filed = new JSONArray(new LinkedList<>()); + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + //System.out.println("portal======>>>>"+portalUrl); + /*if (portalUrl.equals("http://10.114.11.135:8088/portal")){ + portalUrl = "http://bpm.yili.com:8088/portal/"; + }*/ + try { + + String url = portalUrl + "/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + String mobileurl = "https://bpm.yili.com:8088/portal" + "/r/or?cmd=com.yili_process_page_phone&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Timestamp endTime = instanceById.getStartTime(); + BO boActCoePublish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", instanceById.getId()).addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + + +//ProcessExecutionContext processExecutionContext,String fileCreateName,String fileName,String fileurl,String readingScope_org,String isFullCompany,String fileCreateDate,String relationProcessinstId,String readingScope_post,String readingScope_level,String fileid + String not_url = "/w?cmd=com.yili_process_page&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + + + JSONObject jsonObject = new JSONObject(new LinkedHashMap()); + jsonObject.put("action", "read"); + jsonObject.put("title", " " + + "" + boActCoePublish.getString("PROCESS_TITLE") + ""); + //System.out.println("部门庄户》》》》》》》" + SDK.getORGAPI().getDepartmentByUser(taskInstance.getTarget()).getNo()); + jsonObject.put("dept", SDK.getORGAPI().getDepartmentByUser(taskInstance.getTarget()).getNo());//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo() + String target = taskInstance.getTarget(); + target = taskInstance.getTarget(); + + //System.out.println("当前账户======》》》》" + target); + + jsonObject.put("user", target); + + // jsonObject.put("user",);//processExecutionContext.getProcessInstance().getCreateUser() + jsonObject.put("date", sdf.format(endTime)); + jsonObject.put("remark", boActCoePublish.getString("PROCESS_TITLE")); + jsonObject.put("status", "0"); + jsonObject.put("dataid", instanceById.getId()); + jsonObject.put("pcurl", url); + jsonObject.put("mobileurl", mobileurl); + //list.add(1,"00352394"); + //list.add(2,"00352394"); + BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processid).addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + String uid = ""; + String new_uid = ""; + /** + * 这块的判断主要是将组织,岗位,职级进行合并集进行相关的判断获取人员账户合集 + */ + + + if (bo_act_coe_publish1 != null) { + String sendType = bo_act_coe_publish1.getString("SEND_SCOP"); + + ArrayList userList = new ArrayList<>(); + ArrayList userList2 = new ArrayList(); + //获取组织 + String org = bo_act_coe_publish1.getString("SEND_SCOPE_ORG"); + if (StringUtils.isNotEmpty(org)||"1".equals(sendType)) { + long startTime = System.currentTimeMillis(); + userList = getUser(jsonObject,org,sendType, processid); + long endTimes = System.currentTimeMillis(); + System.out.println(instanceById.getTitle()+"_根据部门获取人员用时===>"+(endTimes-startTime)/1000); + } + //获取岗位 + String post = bo_act_coe_publish1.getString("SEND_SCOPE_POST"); + if (StringUtils.isNotEmpty(post)) { + String posts[] = post.split(","); + //取并集 + String postss = ""; + if (posts.length == 1) { + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + postss = "'" + posts[0] + "'"; + } else { + postss = "'" + StringUtils.join(posts, "','") + "'"; + } + String sql = "select * from ORGUSER where POSITION_NO in (" + postss + ") and userno is not null"; + List maps1 = DBSql.getMaps(sql); + for (RowMap rowMap : maps1) { + String userId = rowMap.getString("USERID"); + RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '"+processid+"' AND USER_ID = '"+userId+"'"); + //BO boList = SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processid).addQuery("USER_ID=",userId).detail(); + if (!userList.contains(userId)&&map==null) { + userList.add(userId); + } + + } + } + //获取职级 + String level = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL"); + if (StringUtils.isNotEmpty(level)) { + String ranks[] = level.split(","); + String rankss = ""; + if (ranks.length == 1) { + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + rankss = "'" + ranks[0] + "'"; + } else { + rankss = "'" + StringUtils.join(ranks, "','") + "'"; + } + //取交集 + String sql2 = "select * from ORGUSER where EXT2 in (" + rankss + ") and userno is not null"; + List maps2 = DBSql.getMaps(sql2); + for (RowMap rowMap : maps2) { + String userId = rowMap.getString("USERID"); + RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '"+processid+"' AND USER_ID = '"+userId+"'"); + //BO boList = SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processid).addQuery("USER_ID=",userId).detail(); + if (userList.contains(userId)&&map==null) { + userList2.add(userId); + } + + } + } + + if (StringUtils.isEmpty(level)) { + for (String uids : userList + ) { + uid += uids + ","; + + BO bo = new BO();//BO_EU_PAL_SEND_LOG + bo.set("USREID",instanceById.getCreateUser()); + bo.set("TITLE",instanceById.getTitle()); + bo.set("SENDTIME",instanceById.getEndTime()); + bo.set("PROCESSID",instanceById.getId()); + bo.set("USERNAMES",uids); + bo.set("DEPID",UserContext.fromUID(uids).getDepartmentModel().getId() + ); + bo.set("POSTNAME",UserContext.fromUID(uids).getUserModel().getPositionName() + ); + bo.set("BUNAME",UserContext.fromUID(uids).getUserModel().getExt2() + ); + SDK.getBOAPI().createDataBO("BO_EU_PAL_SEND_LOG",bo,UserContext.fromUID("admin")); + } + + + } else { + for (String uids : userList2 + ) { + uid += uids + ","; + BO bo = new BO();//BO_EU_PAL_SEND_LOG + bo.set("USREID",instanceById.getCreateUser()); + bo.set("TITLE",instanceById.getTitle()); + bo.set("SENDTIME",instanceById.getEndTime()); + bo.set("PROCESSID",instanceById.getId()); + bo.set("USERNAMES",uids); + bo.set("DEPID",UserContext.fromUID(uids).getDepartmentModel().getId() + ); + bo.set("POSTNAME",UserContext.fromUID(uids).getUserModel().getPositionName() + ); + bo.set("BUNAME",UserContext.fromUID(uids).getUserModel().getExt2() + ); + SDK.getBOAPI().createDataBO("BO_EU_PAL_SEND_LOG",bo,UserContext.fromUID("admin")); + } + } + //System.out.println("部门id》》》》》》》》》》》》》"+org_list ); + //System.out.println("posts_list》》》》》》》》》》》》》"+posts_list); + //System.out.println("ranks_list》》》》》》》》》》》》》"+ranks_list); + //System.out.println("部门数量》》》》》》》》》》》》》"+org_list.size() ); + //System.out.println("岗位数量》》》》》》》》》》》》》"+posts_list.size()); + //System.out.println("职级数量》》》》》》》》》》》》》"+ranks_list.size()); + + } + + + // //System.out.println("userid》》》》》》》》》》》》》》》》》》》"+uid); + if (StringUtils.isNotEmpty(uid + )) { + + uid = uid.substring(0, uid.length() - 1); + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + for (String userid : list + ) { + new_uid += userid + ","; + // //System.out.println("当前账户======》》》》"+userid); + // BO boEuOaReson = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("WORKCODE=", userid).detail(); + // if (boEuOaReson!=null){ + /* BO bo = new BO(); + bo.set("USER_CODE",userid); + bo.set("USER_NAME",SDK.getORGAPI().getUser(userid).getUserName()); + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().createDataBO("BO_EU_YEUWS",bo,userContext);*/ + // } + + } + System.out.println("总推送人数>>>>>>>>>>>>" + list.size()); + } + + System.out.println("账户人员信息>>>>>>>>>>>>>" + new_uid); + + long startTime = System.currentTimeMillis(); +/** + * 对新的账户信息进行截取 + */ + if (StringUtils.isNotEmpty(new_uid + )) { + new_uid = new_uid.substring(0, new_uid.length() - 1); + } + /** + * 这块是对人员以300人为一个发送单位来实现进程的待阅发送 + */ + //System.out.println("new_userid ==========>>>>>>>>>"+new_uid); + String[] users = new_uid.split(","); + int length = 300; + int ys = users.length % length; + if (ys == 0) { + int size = users.length / length; + int flag = 0; + + List list = new LinkedList(); + + for (int i = 0; i < size; i++) { + String[] results; + results = Arrays.copyOfRange(users, flag, flag + 300); + list.add(results); + flag = flag + 300; + } + if(list.size()!=0) { + //corse(list, startTime, jsonObject, instanceById); + } + } else { + int size = users.length / length; + int flag = 0; + List list = new LinkedList(); + for (int i = 0; i < size; i++) { + String[] results; + results = Arrays.copyOfRange(users, flag, flag + 300); + list.add(results); + flag = flag + 300; + } + String[] redata; + redata = Arrays.copyOfRange(users, flag, flag + ys); + list.add(redata); + if(list.size()!=0) { + //corse(list, startTime, jsonObject, instanceById); + } + + + } + +/** + * 创建待阅日志 + */ + CreateReadLog(instanceById, jsonObject, users, startTime); + + BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", instanceById.getId()).addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + + + //流程发布的新增发布 + List bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID=", instanceById.getId()).list(); + List bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).addQuery("BINDID=", instanceById.getId()).list(); + List bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).addQuery("BINDID=", instanceById.getId()).list(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + + JSONArray jsonArray = new JSONArray(); + + +/** + * 这里是去生成EHSQ相关数据 + */ + /* for (BO bo:bo_act_coe_publish_n + ) { + JSONArray jsonArray_EHSQ = new JSONArray(); + JSONObject jsonObject_ehsq = new JSONObject(new LinkedHashMap<>()); + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("PUBLISHFILEID"); + LinkedHashMap downloadurl = downloadUtil.outputReportDownload(UserContext.fromUID(processExecutionContext.getProcessInstance().getCreateUser()), bo.getString("TASKID"), publishfileid); + jsonObject_ehsq.put("fileid",bo.getString("TASKID")); + jsonObject_ehsq.put("filename",bo.getString("PUBLISHFILENAME")); + //jsonObject_ehsq.put("filecode",bo.getString("PUBLISH_NUMBER")); + jsonObject_ehsq.put("filecode","123456"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+publishfileid+"'"; + RowMap map = DBSql.getMap(sql_n); + jsonObject_ehsq.put("version",map.getString("PLVER")); + jsonObject_ehsq.put("releasedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("effectivedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("authorcode",processExecutionContext.getTaskInstance().getTarget()); + // jsonObject_ehsq.put("authorcode","00116465"); + jsonObject_ehsq.put("authorname",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); + //jsonObject_ehsq.put("authorname","毛鹏程"); + jsonObject_ehsq.put("companycode",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo()); + //jsonObject_ehsq.put("companycode","00000013"); + jsonObject_ehsq.put("authorcompany",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); + //jsonObject_ehsq.put("authorcompany","总部质量管理部"); + // jsonObject_ehsq.put("releasescope","总部质量管理部"); + BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true).addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); + if (bo1!=null){ + if (bo1.getString("PERMTYPE").equals("1")){ + }else { + + String departname = ""; + String orgperm = bo1.getString("ORGPERM"); + String dleass = ""; + String[] deptSplit = orgperm.split(","); + if(deptSplit.length==1){ + dleass = "'"+deptSplit[0]+"'"; + } + dleass ="'"+ StringUtils.join(deptSplit, "','")+"'"; + + List maps = DBSql.getMaps("select DEPARTMENTNAME from ORGDEPARTMENT where ID in (" + dleass + ")"); + for (RowMap rowmas:maps + ) { + departname+=rowmas.getString("DEPARTMENTNAME")+";"; + } + jsonObject_ehsq.put("releasescope","总部质量管理部"); + + } + } + + System.out.println("任务办理者>>>>>>>>>>>"+processExecutionContext.getTaskInstance().getTarget()); + String sessionId = new SSOUtil().registerClientSessionNoPassword(processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", LoginConst.DEVICE_PC); + + System.out.println("办理者的sessionid>>>>>>>>>>>"+sessionId); + String downurl = downloadUtil.getzipURL(sessionId,bo.getString("TASKID"),bo.getString("PUBLISHFILENAME")); + //jsonObject_ehsq.put("downloadurl","http://bpm.yili.com:8088/portal/r"+downurl.toString().substring(1)); + + String recordfiles = ""; + String recordurls = ""; + Set keys = downloadurl.keySet(); + for ( String key : keys ) { + recordfiles+=key+";"; + String cent_url = downloadurl.get(key).substring(downloadurl.get(key).indexOf("/df"),downloadurl.get(key).length()); + String fileDownurl = "http://bpm.yili.com:8088/portal/r"+cent_url; + recordurls+=fileDownurl+";"; + } + String new_name = ""; + String[] split = recordfiles.split(";"); + if (split.length>0){ + + for (int i =1;i0){ + String loadurl = urls[0].replaceAll("&sid=null","&sid="+sessionId); + System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<"+loadurl); + jsonObject_ehsq.put("downloadurl",loadurl); + for (int i =1;i()); + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("CHANGEDFILEIDNEW"); + LinkedHashMap downloadurl = downloadUtil.outputReportDownload(UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()), bo.getString("TASKID"), publishfileid); + jsonObject_ehsq.put("fileid",bo.getString("TASKID")); + jsonObject_ehsq.put("filename",bo.getString("CHANGEDFILENAMENEW")); + //jsonObject_ehsq.put("filecode",bo.getString("CHANGE_NUMBER")); + jsonObject_ehsq.put("filecode","123456"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+publishfileid+"'"; + RowMap map = DBSql.getMap(sql_n); + jsonObject_ehsq.put("verion",map.getString("PLVER")); + jsonObject_ehsq.put("releasedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("effectivedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("authorcode",processExecutionContext.getTaskInstance().getTarget()); + jsonObject_ehsq.put("authorname",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); + jsonObject_ehsq.put("companycode",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo()); + jsonObject_ehsq.put("authorcompany",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); + BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true).addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); + if (bo1!=null){ + if (bo1.getString("PERMTYPE").equals("1")){ + jsonObject_ehsq.put("releasescope","内蒙古伊利实业集团股份有限公司"); + }else { + + String departname = ""; + String orgperm = bo1.getString("ORGPERM"); + String dleass = ""; + String[] deptSplit = orgperm.split(","); + if(deptSplit.length==1){ + dleass = "'"+deptSplit[0]+"'"; + } + dleass ="'"+ StringUtils.join(deptSplit, "','")+"'"; + + List maps = DBSql.getMaps("select DEPARTMENTNAME from ORGDEPARTMENT where ID in (" + dleass + ")"); + for (RowMap rowmas:maps + ) { + departname+=rowmas.getString("DEPARTMENTNAME")+";"; + } + jsonObject_ehsq.put("releasescope",departname); + + } + } + + String sessionId = new SSOUtil().registerClientSessionNoPassword(processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", LoginConst.DEVICE_PC); + + String downurl = downloadUtil.getzipURL(sessionId,bo.getString("TASKID"),bo.getString("CHANGEDFILENAMENEW")); + String recordfiles = ""; + String recordurls = ""; + Set keys = downloadurl.keySet(); + for ( String key : keys ) { + recordfiles+=key+";"; + String cent_url = downloadurl.get(key).substring(downloadurl.get(key).indexOf("/df"),downloadurl.get(key).length()); + String fileDownurl = "http://bpm.yili.com:8088/portal/r"+cent_url; + recordurls+=fileDownurl+";"; + } + String new_name = ""; + String[] split = recordfiles.split(";"); + if (split.length>0){ + + for (int i =1;i0){ + String loadurl = urls[0].replaceAll("&sid=null","&sid="+sessionId); + System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<"+loadurl); + jsonObject_ehsq.put("downloadurl",loadurl); + for (int i =1;i>>>>>>" + map); + System.out.println("fileid==》》》》" + fileid); + System.out.println("id==》》》》" + map.getString("ID")); + RowMap rowMap = DBSql.getMap("SELECT * FROM " + bo_name + " where " + fileid + " '" + map.getString("ID") + "'"); + //BO bos = SDK.getBOAPI().query(bo_name,true).addQuery(fileid,"17e7d198-1656-4a2c-8912-a81850170be9").detail(); + if (rowMap != null) { + + if (StringUtils.isNotEmpty(rowMap.getString("TASKID"))) { + + OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID")); + if (model != null) { + System.out.println(",pdel============" + model); + System.out.println("123313123123123==========" + model.getProfileId()); + OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId()); + System.out.println("dajadfas======" + appProfile); + if (appProfile == null) { + throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId()); + } + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + String sql_lever = ""; + if (bo_name.equals("BO_ACT_COE_PUBLISH_N")) { + sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + rowMap.getString("PUBLISHFILEID") + "'"; + + } else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")) { + sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + rowMap.getString("CHANGEDFILEIDNEW") + "'"; + } + String lever = DBSql.getString(sql_lever); + System.out.println("版本号::::::::::::" + lever); + //lever = lever.substring(0,3); + if (lever.length() == 5 && lever.substring(4).equals("0")) { + lever.substring(0, 3); + } else if (lever.length() == 1) { + lever = lever + ".0"; + } + String filename = ""; + if (bo_name.equals("BO_ACT_COE_PUBLISH_N")) { + filename = rowMap.getString("PUBLISHFILENAME"); + } else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")) { + filename = rowMap.getString("CHANGEDFILENAMENEW"); + } + DCContext dcContext = new DCContext(userContext, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), rowMap.getString("TASKID"), filename + "_" + lever + ".doc"); + //UtilFile file = new UtilFile(dcContext.getPath()); + + + Map params = new HashMap(); +//知识ID,必填 + params.put("cardId", cardId); +//sid,必填 + params.put("sid", userContext.getSessionId()); + + params.put("dc", dcContext); + AppAPI appAPI = SDK.getAppAPI(); +//创建文件 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("流程手册的存入=================" + ro); + } + } + + } + String sql_A = "SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where ID = '" + map.getString("ID") + "' AND PLMETHODID != 'process.framework' AND PLMETHODID IN (select distinct PLMETHODID from APP_ACT_COE_PAL_REPOSITORY)"; + List rows = DBSql.getMaps(sql_A); + + for (RowMap bo : rows + ) { + + /** + * 这个是模型中的附件获取的并插入的数据信息,需要做修改 + */ + // 调用App + +// 参数定义列表 + Map paramss = new HashMap(); +//知识ID,必填 + paramss.put("cardId", cardId); +//sid,必填 + paramss.put("sid", userContext.getSessionId()); + + UpfileWeb upfileWeb = new UpfileWeb(userContext); + + + String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID != 'process.framework' AND ID= '" + map.getString("ID") + "'" + + ")"; + List maps = DBSql.getMaps(sql_upfile); + for (RowMap row : maps) { + System.out.println("附件名称>>>>>>" + row.getString("FILENAME")); + if (!row.getString("FILENAME").contains(".xml")) { + UpfileModel upfileModel = new UpfileModel(); + upfileModel.setType(row.getString("FILETYPE")); + upfileModel.setFileName(row.getString("FILENAME")); + upfileModel.setPl_uuid(row.getString("PALREPOSITORYID")); + upfileModel.setShape_uuid(row.getString("SHAPEID")); + DCContext dcContexts = upfileWeb.getDCContext(upfileModel); + paramss.put("dc", dcContexts); + AppAPI appAPIs = SDK.getAppAPI(); + ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, paramss); + System.out.println("流程模型附件的生成=============" + ros); + } + } + +//DCContext对象,必填 + +//创建文件 + } + try { + + PublishKnow(processInstance, userContext, cardId); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + + /** + * 发布知识 + * + * @param processInstance + * @param userContext + * @param id + */ + public void PublishKnow(ProcessInstance processInstance, UserContext userContext, String id) { + + String sql = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id in (select PLPARENTID from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '" + id + "')"; + List maps = DBSql.getMaps(sql); + String ids = ""; + for (RowMap rowmap : maps + ) { + ids += rowmap.getString("EXT4") + ","; + } + String[] deptSplit_id = ids.split(","); + + JSONArray jsonArray = new JSONArray(); + for (String id_names : deptSplit_id + ) { + jsonArray.add(id_names); + } + //jsonObject.put(deptSplit_id); + id += ","; + String[] deptSplit_das = id.split(","); + JSONArray jsonArray_das = new JSONArray(); + for (String das : deptSplit_das + ) { + jsonArray_das.add(das); + } + //jsonObject.put(deptSplit_id); + + if (!jsonArray_das.isEmpty() && !jsonArray.isEmpty()) { + + // 调用App + String sourceAppId = processInstance + .getAppId(); +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl"; +// 参数定义列表 + Map params = new HashMap(); +//要发布到的维度ID的JSON数组字符串,必填 + params.put("dimensionIDArray", jsonArray.toString()); +//要发布的知识ID的JSON数组字符串,必填 + params.put("knwlIDArray", jsonArray_das.toString()); +//标签的JSON数组字符串,非必填 + +//sid,必填 + params.put("sid", userContext.getSessionId()); + AppAPI appAPI = SDK.getAppAPI(); +//发布知识 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + + System.out.println("知识发布============" + ro); + + } + + } + + /** + * 取消发布知识 + * + * @param processInstance + * @param sid + * @param knwlId + * @return + */ + public boolean CancelPublishKnwl(ProcessInstance processInstance, String sid, String knwlId) { +// 调用App + String sourceAppId = processInstance.getAppId(); +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/CancelPublishKnwl"; +// 参数定义列表 + Map params = new HashMap(); +//sid,如果为空,则需要传createUser参数,非必填 + params.put("sid", sid); +//知识ID,必填 + params.put("knwlId", knwlId); + AppAPI appAPI = SDK.getAppAPI(); +//取消发布知识(全部维度) + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("取消发布的ro=====>>>>" + ro); + return ro.isOk(); + } + + /** + * 创建XPage页面上的待阅 + * + * @param processExecutionContext + * @param fileCreateName + * @param fileName + * @param fileurl + * @param readingScope_org + * @param isFullCompany + * @param fileCreateDate + * @param relationProcessinstId + * @param readingScope_post + * @param readingScope_level + * @param fileid + * @return + */ + public boolean execute(ProcessExecutionContext processExecutionContext, String fileCreateName, String fileName, String fileurl, String readingScope_org, String isFullCompany, String fileCreateDate, String relationProcessinstId, String readingScope_post, String readingScope_level, String fileid) { +// 调用App + String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); +// aslp服务地址 + String aslp = "aslp://com.awspaas.user.apps.docview/PushFileToXpage"; +// 参数定义列表 + Map params = new HashMap(); +//发布人,不允许空值,必填 + params.put("fileCreateName", fileCreateName); +//待阅文件标题名称,不允许空值,必填 + params.put("fileName", fileName); +//阅读范围_组织,不允许空值,非必填 + params.put("readingScope_org", readingScope_org); +//是否全公司可见,不允许空值,必填 + params.put("isFullCompany", isFullCompany); +//待阅文件Url,不允许空值,必填 + params.put("fileurl", fileurl); +//发布日期,不允许空值,必填 + params.put("fileCreateDate", fileCreateDate); +//发布流程ID,不允许空值,必填 + params.put("relationProcessinstId", relationProcessinstId); +//阅读范围_岗位,不允许空值,非必填 + params.put("readingScope_post", readingScope_post); +//阅读范围_职级,不允许空值,非必填 + params.put("readingScope_level", readingScope_level); +//待阅文件ID,多个逗号隔开,不允许空值,必填 + params.put("fileid", fileid); + AppAPI appAPI = SDK.getAppAPI(); +//推送待阅文件到xpage门户 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("ros++++++++=====待阅》》》》》》》》》》" + ro); + return ro.isOk(); + } + + + /** + * 给知识授权 + * + * @param processInstance + * @param jsonArray + * @param sid + * @param knwlId + * @return + */ + public boolean AddKnwlAC(ProcessInstance processInstance, JSONArray jsonArray, String sid, String knwlId) { +// 调用App + String sourceAppId = processInstance.getAppId(); +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC"; +// 参数定义列表 + Map params = new HashMap(); +//[{"assignmentType":"department","assignmentId":"62196ff9-a26d-4be5-9480-3ef680886f63"},{"assignmentType":"user","assignmentId":"user1"}],必填 + params.put("acList", jsonArray); +//sid,如果为空,则需要传createUser参数,非必填 + params.put("sid", sid); +//知识ID,必填 + params.put("knwlId", knwlId); + AppAPI appAPI = SDK.getAppAPI(); +//给知识授权 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + return ro.isOk(); + } + + + /** + * 柱军代码,不知道做什么用的 + * + * @param processInstance + * @param wsId + * @param fileId + * @return + */ + public boolean AttrSynAslp(ProcessInstance processInstance, String wsId, JSONArray fileId) { + System.out.println(""); + // 调用App + String sourceAppId = processInstance.getAppId(); +// aslp服务地址 + String aslp = "aslp://com.awspaas.user.apps.yili.reportform/AttrSynAslp"; +// 参数定义列表 + Map params = new HashMap(); +//资产内容库id,必填 + params.put("wsId", wsId); +//文件id;json数组[id1,id2,id3],必填 + params.put("fileId", fileId); + AppAPI appAPI = SDK.getAppAPI(); +//增量同步数据 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("ro>>>>>>>>>>>>>" + ro); + return ro.isOk(); + } + + /** + * 发送OA待阅数据 + * + * @param jsonObject + * @param processInstance + * @param results + * @throws DocumentException + */ + public void SendOARead(JSONObject jsonObject, ProcessInstance processInstance, String[] results) throws DocumentException { + + System.err.println("===推送人员====>"+results); + String userId = ""; + userId = StringUtils.join(results, ","); + if("".equals(userId)||UtilString.isEmpty(userId)) { + return; + } + jsonObject.put("userList", userId); + String xmlStr = "\n" + + " " + + " " + + " " + + " " + + "" + + " " + + " " + + " " + + ""; + System.out.println("xmlStr>>>>>>>>" + xmlStr); + String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl"); + + String postSoap = UtilUrl.doPostSoap(readurl, xmlStr, ""); + Document document = DocumentHelper.parseText(postSoap); + Element rootElement = document.getRootElement(); + System.out.println("rootElement>>>>>>" + rootElement); + Element result = rootElement.element("Body").element("serviceResponse").element("out"); + String resultString = result.getData().toString(); + JSONObject jsonObject1 = JSON.parseObject(resultString); + String datas = jsonObject1.getString("data"); + String status = jsonObject1.getString("status"); + System.out.println("状态是什么》》》》》》》》》》》" + status); + if("false".equals(status)) { + try { + BO bo = new BO(); + bo.set("TITLE", processInstance.getTitle()); + bo.set("NAME", userId); + bo.set("DEPNAME", SDK.getORGAPI().getUser(userId).getDepartmentId()); + SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser()); + } catch (Exception e) { + // TODO: handle exception + } + }else { + System.out.println(processInstance.getTitle()+"待阅推送成功:" + userId); + } + JSONArray resultArray = JSONObject.parseArray(datas); + for (int j = 0; j < resultArray.size(); j++) { + JSONObject jsonObject2 = resultArray.getJSONObject(j); + String user = jsonObject2.get("user").toString(); + String dataid = jsonObject2.get("dataid").toString(); + BO bo = new BO(); + bo.set("TITLE", processInstance.getTitle()); + bo.set("PROCESSID", processInstance.getId()); + bo.set("USER_ID", user); + bo.set("DATAID", dataid); + bo.set("RESULT", status); + SDK.getBOAPI().create("BO_ACT_DATAID", bo, processInstance.getId(), processInstance.getCreateUser()); + } + } + + /** + * 发送EHSQ接口 + * + * @param jsonArray + * @return + * @throws Exception + */ + public String SendEHSQFile(JSONArray jsonArray) throws Exception { + System.out.println("===jsonArray===" + jsonArray); + /** + * 首先需要将传过来的参数进行加密操作,并设置 + */ + AesUtil aesUtil = new AesUtil(); + String system = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "system"); + String AES = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "AES"); + String EHSQUrl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "EHSQUrl"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String date = sdf.format(new Date()); + String s1 = date.replaceAll("-", "").replaceAll(" ", "").replaceAll(":", ""); + + System.out.println("时间>>>>>>>>>>>>" + s1); + String data = system + "##" + s1; + String encrypt = aesUtil.encrypt(data, AES); //获取加密之后的秘钥 + JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); + jsonObject.put("system", system); + jsonObject.put("token", encrypt); + jsonObject.put("infos", jsonArray); + HttpUtil httpUtil = new HttpUtil(); + System.out.println("jsonobject>>>>>>>>>>>>>>>>>>>" + jsonObject); + String s = httpUtil.sendPost(jsonObject, EHSQUrl); + System.out.println("发送到EHSQ是否是正确的>>>>>>>>>" + s); + + return s; + } + + /** + * 根据部门id获取当前部门以及下级部门的人员信息 + * + * @param processid + * @return + */ + + public ArrayList getUser( JSONObject jsonObject,String depIds, String sendType, String processid) { + System.err.println("sendType=====>"+sendType); + ArrayList arr = new ArrayList(); + ArrayList arr_test = new ArrayList(); + //全集团 + if ("1".equals(sendType)) { + List departmentsByCompanyId = SDK.getORGAPI().getDepartmentsByCompanyId(1, "8911e732-b42a-4556-853f-ad32761bcbee"); + for (DepartmentModel departmentModel : departmentsByCompanyId) { + String id = departmentModel.getId(); + if(!departmentModel.isClosed()&&!"e79281b1-2f81-4895-b30e-9f96e9ad0e2c".equals(id)&&!"5bc3a2dc-3bd2-4376-bcc3-5612e28e55fe".equals(id)) { + System.err.println("==depName=====>"+departmentModel.getName()); + getUserList(jsonObject,arr_test,arr,id, processid); + + } + } + } /* + * else { if(UtilString.isNotEmpty(depIds)) { //具体部门 String[] split = + * depIds.split(","); for (String depId : split) { + * getUserList(jsonObject,arr_test,arr, depId, processid); } } } + */ + + + System.err.println(SDK.getProcessAPI().getInstanceById(processid)+"_得到的总人数为:"+arr_test.size()); + System.err.println(SDK.getProcessAPI().getInstanceById(processid)+"_得到的过滤后的人数为:"+arr.size()); + return arr; + } + + public void getUserList( JSONObject jsonObject,ArrayList arr_test,ArrayList arr, String departmentId, String processid) { + // 获取当前部门下人员 + List userModelList = SDK.getORGAPI().getAllUsersByDepartment(departmentId); + for (UserModel userModel : userModelList) { + if (!userModel.isClosed()) { + String uid = userModel.getUID(); + if (!arr.contains(uid)) { + arr_test.add(uid); + RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '"+processid+"' AND USER_ID = '"+uid+"'"); + if (map == null) { + System.err.println("发送人员======>"+uid); + String[] users = uid.split(","); + List list = new LinkedList(); + list.add(users); + long startTime = System.currentTimeMillis(); + corse(list, startTime, jsonObject, SDK.getProcessAPI().getInstanceById(processid)); + arr.add(userModel.getUID()); + } + } + } + } + // 获取当前部门的子部门人员 + DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(departmentId); + if (departmentById.isExistSubModelOfCache()) { + getSubDepartments(jsonObject,arr_test,arr, departmentById, processid); + } + + } + + //获取子部门人员 + public void getSubDepartments(JSONObject jsonObject,ArrayList arr_test,ArrayList arr, DepartmentModel departmentById, String processid) { + if (!departmentById.isClosed()) { + List subDepartments = SDK.getORGAPI().getSubDepartments(departmentById.getId()); + for (DepartmentModel departmentModel : subDepartments) { + if(!departmentModel.isClosed()) { + String id = departmentModel.getId(); + List userModelList = SDK.getORGAPI().getAllUsersByDepartment(id); + for (UserModel userModel : userModelList) { + if (!userModel.isClosed()) { + String uid = userModel.getUID(); + if (!arr.contains(uid)) { + arr_test.add(uid); + RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '"+processid+"' AND USER_ID = '"+uid+"'"); + if (map == null) { + String[] users = uid.split(","); + List list = new LinkedList(); + list.add(users); + long startTime = System.currentTimeMillis(); + corse(list, startTime, jsonObject, SDK.getProcessAPI().getInstanceById(processid)); + System.err.println(SDK.getProcessAPI().getInstanceById(processid)+"_发送人员======>"+uid); + //arr.add(uid); + } + } + } + } + //递归获取子部门下的子部门 + if (SDK.getORGAPI().isExistSubDepartment(id)) { + getSubDepartments(jsonObject,arr_test,arr,SDK.getORGAPI().getDepartmentById(id),processid); + } + + } + + } + } + } + + /** + * 创建更新的知识 + * + * @param bo + * @param wsId + * @param filed + * @param instanceById + * @param bo_act_coe_publish + * @param uid + */ + public void CreateKmsByUpdate(BO bo, String wsId, JSONArray filed, ProcessInstance instanceById, BO bo_act_coe_publish, String uid) { + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("CHANGEDFILEIDNEW"); + filed.add(publishfileid) + + + ; + DBSql.update("update APP_ACT_COE_PAL_REPOSITORY set EXT4 = '' where id = '" + publishfileid + "'"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; + RowMap map = DBSql.getMap(sql_n); + if (StringUtils.isEmpty(map.getString("EXT4"))) { + // aslp服务地址 + String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl"; +// 参数定义列表 + Map params_create = new HashMap(); +//保密级别, 0: 普通 1:秘密 2:机密,必填 + params_create.put("securityLevel", 0); +//知识名称,必填 + String level = ""; + if (map != null) { + if (map.getString("PLVER").contains(".00")) { + String[] plvers = map.getString("PLVER").split("\\."); + plvers[1] = plvers[1].replaceAll("0", ""); + level = plvers[0] + plvers[1]; + } else { + level = map.getString("PLVER"); + } + } + + + params_create.put("knwlName", map.getString("PLNAME") + "V" + level); +//是否可以评论,必填 + params_create.put("isComment", true); +//是否可以评分,必填 + params_create.put("isRate", true); +//有效期:yyyy-MM-dd,非必填 + params_create.put("validDate", "2099-12-31"); +//只读控制,1:在线阅读和下载 0:在线阅读,必填 + params_create.put("onlineLevel", 1); +//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填 + params_create.put("createUser", "admin"); +//知识内容,非必填 + params_create.put("cardContext", ""); +//sid,必填 + params_create.put("sid", UserContext.fromUID(instanceById.getCreateUser()).getSessionId()); + AppAPI appAPI_create = SDK.getAppAPI(); +//创建知识 + ResponseObject ro_create = appAPI_create.callASLP(appAPI_create.getAppContext(instanceById.getAppId()), aslps_create, params_create); + System.out.println("ro_create================" + ro_create); + String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); + JSONArray jsonArray1 = new JSONArray(); + if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")) { + String departId = bo_act_coe_publish.getString("SEND_SCOPE_ORG"); + if (StringUtils.isNotEmpty(departId) && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_LEVEL")) && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_POST"))) { + String strs[] = departId.split(","); + for (String departmentid : strs + ) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", departmentid); + jsonArray1.add(jsonObjecta); + } + } else { + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + + for (String user_id : list + ) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "user"); + jsonObjecta.put("assignmentId", user_id); + jsonArray1.add(jsonObjecta); + } + } + + } else { + List select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT"); + for (RowMap depaid : + select_id_from_orgdepartment) { + String id = depaid.getString("ID"); + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", id); + jsonArray1.add(jsonObjecta); + } + } + AddKnwlAC(instanceById, jsonArray1, UserContext.fromUID(instanceById.getCreateUser()).getSessionId(), cardId); + + String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '" + cardId + "' WHERE " + + " PLCATEGORY = 'process'and PLMETHODID !='process.framework' " + + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + " '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + " '42c09260-c1d3-44b7-ac3d-f8280e04c294') and ID = '" + publishfileid + "'"; + int update = DBSql.update(update_sql); + System.out.println("更新id为:" + publishfileid + "版本为:的知识对应的资产库的EXT4的影响行数为" + update); + creadteFile(instanceById, "BO_ACT_COE_PUBLISH_C", UserContext.fromUID(instanceById.getCreateUser()), cardId, " CHANGEDFILEIDNEW="); + } + //将旧的知识取消发布或者移动到废止发布中 + String publishfileid_old = bo.getString("CHANGEFILEID"); + String sql_c = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid_old + "'"; + RowMap map1 = DBSql.getMap(sql_c); + if (StringUtils.isNotEmpty(map1.getString("EXT4"))) { + CancelPublishKnwl(instanceById, UserContext.fromUID(instanceById.getCreateUser()).getSessionId(), map1.getString("EXT4")); + DBSql.update( + "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '" + publishfileid_old + "'" + ); + } + } + + public void CreateKmsBynew(BO bo, String wsId, JSONArray filed, ProcessInstance instanceById, BO bo_act_coe_publish, String uid) { + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("PUBLISHFILEID"); + filed.add(publishfileid); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; + RowMap map = DBSql.getMap(sql_n); + if (StringUtils.isEmpty(map.getString("EXT4"))) { + // aslp服务地址 + String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl"; +// 参数定义列表 + Map params_create = new HashMap(); +//保密级别, 0: 普通 1:秘密 2:机密,必填 + params_create.put("securityLevel", 0); +//知识名称,必填 + + String level = ""; + + + if (map.getString("PLVER").contains(".00")) { + String[] plvers = map.getString("PLVER").split("\\."); + plvers[1] = plvers[1].replaceAll("0", ""); + level = plvers[0] + plvers[1]; + } else { + level = map.getString("PLVER"); + } + + params_create.put("knwlName", map.getString("PLNAME") + "V" + level); +//是否可以评论,必填 + params_create.put("isComment", true); +//是否可以评分,必填 + params_create.put("isRate", true); +//有效期:yyyy-MM-dd,非必填 + params_create.put("validDate", "2099-12-31"); +//只读控制,1:在线阅读和下载 0:在线阅读,必填 + params_create.put("onlineLevel", 1); +//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填 + params_create.put("createUser", "admin"); +//知识内容,非必填 + params_create.put("cardContext", ""); +//sid,必填 + params_create.put("sid", UserContext.fromUID(instanceById.getCreateUser()).getSessionId()); + AppAPI appAPI_create = SDK.getAppAPI(); +//创建知识 + ResponseObject ro_create = appAPI_create.callASLP(appAPI_create.getAppContext(instanceById.getAppId()), aslps_create, params_create); + System.out.println("ro_create================" + ro_create); + String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); + JSONArray jsonArray1 = new JSONArray(); + if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")) { + String departId = bo_act_coe_publish.getString("SEND_SCOPE_ORG"); + if (StringUtils.isNotEmpty(departId) && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_LEVEL")) && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_POST"))) { + String strs[] = departId.split(","); + for (String departmentid : strs + ) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", departmentid); + jsonArray1.add(jsonObjecta); + } + } else { + + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + + for (String user_id : list + ) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "user"); + jsonObjecta.put("assignmentId", user_id); + jsonArray1.add(jsonObjecta); + } + } + } else { + List select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT"); + for (RowMap depaid : + select_id_from_orgdepartment) { + String id = depaid.getString("ID"); + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", id); + jsonArray1.add(jsonObjecta); + } + } + + + AddKnwlAC(instanceById, jsonArray1, UserContext.fromUID(instanceById.getCreateUser()).getSessionId(), cardId); + + String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '" + cardId + "' WHERE " + + " PLCATEGORY = 'process'and PLMETHODID !='process.framework' " + + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + " '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + " '42c09260-c1d3-44b7-ac3d-f8280e04c294') and ID = '" + publishfileid + "'"; + int update = DBSql.update(update_sql); + System.out.println("更新id为:" + publishfileid + "版本为:的知识对应的资产库的EXT4的影响行数为" + update); + creadteFile(instanceById, "BO_ACT_COE_PUBLISH_N", UserContext.fromUID(instanceById.getCreateUser()), cardId, "PUBLISHFILEID = "); + } + } + + /** + * 以线程进行发送待阅信息 + * + * @param list + * @param startTime + * @param jsonObject + * @param instanceById + */ + public void corse(List list, long startTime, JSONObject jsonObject, ProcessInstance instanceById) { + + int i = 0; + for (String[] resrt : list + ) { + if ((list.size() - 1) == i) { + long endTime = System.currentTimeMillis(); + + long time = endTime - startTime; + long itmes = time / 1000 / 60 / 60; + BO bo_eu_pal_read_log = SDK.getBOAPI().query("BO_EU_PAL_READ_LOG", true).addQuery("PROCESSID = ", instanceById.getId()).detail(); + bo_eu_pal_read_log.set("ENDTIMES", endTime); + bo_eu_pal_read_log.set("TIMECOUNT", itmes); + SDK.getBOAPI().update("BO_EU_PAL_READ_LOG", bo_eu_pal_read_log); + } + try { + SendOARead(jsonObject, instanceById, resrt); + } catch (DocumentException e) { + e.printStackTrace(); + } + i++; + } + + + // 创建线程来实现为每300人为一个的线程跑待阅 + /* + * ExecutorService service = Executors.newFixedThreadPool(1); + * service.execute(new Runnable() { + * + * @Override public void run() { + * + * } }); + */ + } + + /** + * 创建待阅日志信息 + * + * @param instanceById + * @param jsonObject + * @param users + * @param startTime + */ + public void CreateReadLog(ProcessInstance instanceById, JSONObject jsonObject, String[] users, long startTime) { + BO bo_Read_log = new BO(); + bo_Read_log.set("USREID", instanceById.getCreateUser()); + bo_Read_log.set("DEPID", UserContext.fromUID(instanceById.getCreateUser()).getDepartmentModel().getId()); + bo_Read_log.set("BUNAME", UserContext.fromUID(instanceById.getCreateUser()).getUserModel().getExt4()); + bo_Read_log.set("TITLE", jsonObject.get("title")); + bo_Read_log.set("PROCESSID", instanceById.getId()); + bo_Read_log.set("SENDNUM", users.length); + BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", instanceById.getId()).addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + String send_scop = bo_act_coe_publishs.getString("SEND_SCOP"); + bo_Read_log.set("SEND_SCOP", send_scop); + String SEND_SCOPE_ORG = bo_act_coe_publishs.getString("SEND_SCOPE_ORG"); + if (UtilString.isNotEmpty(SEND_SCOPE_ORG)) { + String[] resulr = SEND_SCOPE_ORG.split(","); + bo_Read_log.set("SEND_SCOPE_ORGNUM", resulr.length); + } + String SEND_SCOPE_POST = bo_act_coe_publishs.getString("SEND_SCOPE_POST"); + if (UtilString.isNotEmpty(SEND_SCOPE_POST)) { + String[] resulr = SEND_SCOPE_POST.split(","); + bo_Read_log.set("SEND_SCOPE_POST_NUM", resulr.length); + } + String SEND_SCOPE_LEVEL = bo_act_coe_publishs.getString("SEND_SCOPE_LEVEL"); + if (UtilString.isNotEmpty(SEND_SCOPE_LEVEL)) { + String[] resulr = SEND_SCOPE_LEVEL.split(","); + bo_Read_log.set("SEND_SCOPE_LEVEL_NUM", resulr.length); + } + + bo_Read_log.set("STARTTIMES", startTime); + SDK.getBOAPI().createDataBO("BO_EU_PAL_READ_LOG", bo_Read_log, UserContext.fromUID(instanceById.getCreateUser())); + + } +} \ No newline at end of file diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/sendReadByDataid3.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/sendReadByDataid3.java new file mode 100644 index 00000000..61efdf07 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/sendReadByDataid3.java @@ -0,0 +1,1321 @@ +package com.awspaas.user.apps.integration.job; + +import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst; +import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; +import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager; +import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile; +import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb; +import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +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.database.RowMap; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.server.fs.DCContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.bpms.util.UtilString; +import com.actionsoft.emm.util.AesUtil; +import com.actionsoft.exception.AWSException; +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 com.awspaas.user.apps.integration.util.HttpUtil; +import com.awspaas.user.apps.integration.util.UtilUrl; +import org.apache.commons.lang.StringUtils; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +@SuppressWarnings("all") +public class sendReadByDataid3 { + public void execute(String processid, String taskid) throws JobExecutionException { + ProcessInstance instanceById = SDK.getProcessAPI().getInstanceById(processid); + TaskInstance taskInstance = SDK.getTaskAPI().getInstanceById(taskid); + String wsId = ""; + JSONArray filed = new JSONArray(new LinkedList<>()); + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + //System.out.println("portal======>>>>"+portalUrl); + /*if (portalUrl.equals("http://10.114.11.135:8088/portal")){ + portalUrl = "http://bpm.yili.com:8088/portal/"; + }*/ + try { + + String url = portalUrl + "/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + String mobileurl = "https://bpm.yili.com:8088/portal" + "/r/or?cmd=com.yili_process_page_phone&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Timestamp endTime = instanceById.getStartTime(); + BO boActCoePublish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", instanceById.getId()).addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + String not_url = "/w?cmd=com.yili_process_page&processInstId=" + instanceById.getId() + "&taskInstId=" + taskInstance.getId(); + JSONObject jsonObject = new JSONObject(new LinkedHashMap()); + jsonObject.put("action", "read"); + jsonObject.put("title", " " + + "" + boActCoePublish.getString("PROCESS_TITLE") + ""); + //System.out.println("部门庄户》》》》》》》" + SDK.getORGAPI().getDepartmentByUser(taskInstance.getTarget()).getNo()); + jsonObject.put("dept", SDK.getORGAPI().getDepartmentByUser(taskInstance.getTarget()).getNo());//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo() + String target = taskInstance.getTarget(); + target = taskInstance.getTarget(); + + //System.out.println("当前账户======》》》》" + target); + + jsonObject.put("user", target); + + // jsonObject.put("user",);//processExecutionContext.getProcessInstance().getCreateUser() + jsonObject.put("date", sdf.format(endTime)); + jsonObject.put("remark", boActCoePublish.getString("PROCESS_TITLE")); + jsonObject.put("status", "0"); + jsonObject.put("dataid", instanceById.getId()); + jsonObject.put("pcurl", url); + jsonObject.put("mobileurl", mobileurl); + //list.add(1,"00352394"); + //list.add(2,"00352394"); + BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processid).addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + + /** + * 这块的判断主要是将组织,岗位,职级进行合并集进行相关的判断获取人员账户合集 + */ + + if(bo_act_coe_publish1!=null&&instanceById!=null) { + ArrayList sendList = getSendList(instanceById, bo_act_coe_publish1, jsonObject); + System.err.println(instanceById.getTitle()+"待发送人员列表====>"+sendList); + for (String uid : sendList) { + createLog(instanceById, uid); + long startTime = System.currentTimeMillis(); + SendOARead(jsonObject, instanceById, uid); + //CreateReadLog(instanceById, jsonObject, users, startTime); + } + + } + + + //BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", instanceById.getId()).addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + //流程发布的新增发布 + List bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID=", instanceById.getId()).list(); + List bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).addQuery("BINDID=", instanceById.getId()).list(); + List bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).addQuery("BINDID=", instanceById.getId()).list(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + + JSONArray jsonArray = new JSONArray(); + + +/** + * 这里是去生成EHSQ相关数据 + */ + /* for (BO bo:bo_act_coe_publish_n + ) { + JSONArray jsonArray_EHSQ = new JSONArray(); + JSONObject jsonObject_ehsq = new JSONObject(new LinkedHashMap<>()); + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("PUBLISHFILEID"); + LinkedHashMap downloadurl = downloadUtil.outputReportDownload(UserContext.fromUID(processExecutionContext.getProcessInstance().getCreateUser()), bo.getString("TASKID"), publishfileid); + jsonObject_ehsq.put("fileid",bo.getString("TASKID")); + jsonObject_ehsq.put("filename",bo.getString("PUBLISHFILENAME")); + //jsonObject_ehsq.put("filecode",bo.getString("PUBLISH_NUMBER")); + jsonObject_ehsq.put("filecode","123456"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+publishfileid+"'"; + RowMap map = DBSql.getMap(sql_n); + jsonObject_ehsq.put("version",map.getString("PLVER")); + jsonObject_ehsq.put("releasedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("effectivedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("authorcode",processExecutionContext.getTaskInstance().getTarget()); + // jsonObject_ehsq.put("authorcode","00116465"); + jsonObject_ehsq.put("authorname",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); + //jsonObject_ehsq.put("authorname","毛鹏程"); + jsonObject_ehsq.put("companycode",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo()); + //jsonObject_ehsq.put("companycode","00000013"); + jsonObject_ehsq.put("authorcompany",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); + //jsonObject_ehsq.put("authorcompany","总部质量管理部"); + // jsonObject_ehsq.put("releasescope","总部质量管理部"); + BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true).addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); + if (bo1!=null){ + if (bo1.getString("PERMTYPE").equals("1")){ + }else { + + String departname = ""; + String orgperm = bo1.getString("ORGPERM"); + String dleass = ""; + String[] deptSplit = orgperm.split(","); + if(deptSplit.length==1){ + dleass = "'"+deptSplit[0]+"'"; + } + dleass ="'"+ StringUtils.join(deptSplit, "','")+"'"; + + List maps = DBSql.getMaps("select DEPARTMENTNAME from ORGDEPARTMENT where ID in (" + dleass + ")"); + for (RowMap rowmas:maps + ) { + departname+=rowmas.getString("DEPARTMENTNAME")+";"; + } + jsonObject_ehsq.put("releasescope","总部质量管理部"); + + } + } + + System.out.println("任务办理者>>>>>>>>>>>"+processExecutionContext.getTaskInstance().getTarget()); + String sessionId = new SSOUtil().registerClientSessionNoPassword(processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", LoginConst.DEVICE_PC); + + System.out.println("办理者的sessionid>>>>>>>>>>>"+sessionId); + String downurl = downloadUtil.getzipURL(sessionId,bo.getString("TASKID"),bo.getString("PUBLISHFILENAME")); + //jsonObject_ehsq.put("downloadurl","http://bpm.yili.com:8088/portal/r"+downurl.toString().substring(1)); + + String recordfiles = ""; + String recordurls = ""; + Set keys = downloadurl.keySet(); + for ( String key : keys ) { + recordfiles+=key+";"; + String cent_url = downloadurl.get(key).substring(downloadurl.get(key).indexOf("/df"),downloadurl.get(key).length()); + String fileDownurl = "http://bpm.yili.com:8088/portal/r"+cent_url; + recordurls+=fileDownurl+";"; + } + String new_name = ""; + String[] split = recordfiles.split(";"); + if (split.length>0){ + + for (int i =1;i0){ + String loadurl = urls[0].replaceAll("&sid=null","&sid="+sessionId); + System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<"+loadurl); + jsonObject_ehsq.put("downloadurl",loadurl); + for (int i =1;i()); + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("CHANGEDFILEIDNEW"); + LinkedHashMap downloadurl = downloadUtil.outputReportDownload(UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()), bo.getString("TASKID"), publishfileid); + jsonObject_ehsq.put("fileid",bo.getString("TASKID")); + jsonObject_ehsq.put("filename",bo.getString("CHANGEDFILENAMENEW")); + //jsonObject_ehsq.put("filecode",bo.getString("CHANGE_NUMBER")); + jsonObject_ehsq.put("filecode","123456"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+publishfileid+"'"; + RowMap map = DBSql.getMap(sql_n); + jsonObject_ehsq.put("verion",map.getString("PLVER")); + jsonObject_ehsq.put("releasedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("effectivedate",simpleDateFormat.format(new Date())); + jsonObject_ehsq.put("authorcode",processExecutionContext.getTaskInstance().getTarget()); + jsonObject_ehsq.put("authorname",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getUserName()); + jsonObject_ehsq.put("companycode",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getNo()); + jsonObject_ehsq.put("authorcompany",UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); + BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true).addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); + if (bo1!=null){ + if (bo1.getString("PERMTYPE").equals("1")){ + jsonObject_ehsq.put("releasescope","内蒙古伊利实业集团股份有限公司"); + }else { + + String departname = ""; + String orgperm = bo1.getString("ORGPERM"); + String dleass = ""; + String[] deptSplit = orgperm.split(","); + if(deptSplit.length==1){ + dleass = "'"+deptSplit[0]+"'"; + } + dleass ="'"+ StringUtils.join(deptSplit, "','")+"'"; + + List maps = DBSql.getMaps("select DEPARTMENTNAME from ORGDEPARTMENT where ID in (" + dleass + ")"); + for (RowMap rowmas:maps + ) { + departname+=rowmas.getString("DEPARTMENTNAME")+";"; + } + jsonObject_ehsq.put("releasescope",departname); + + } + } + + String sessionId = new SSOUtil().registerClientSessionNoPassword(processExecutionContext.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "localhost", LoginConst.DEVICE_PC); + + String downurl = downloadUtil.getzipURL(sessionId,bo.getString("TASKID"),bo.getString("CHANGEDFILENAMENEW")); + String recordfiles = ""; + String recordurls = ""; + Set keys = downloadurl.keySet(); + for ( String key : keys ) { + recordfiles+=key+";"; + String cent_url = downloadurl.get(key).substring(downloadurl.get(key).indexOf("/df"),downloadurl.get(key).length()); + String fileDownurl = "http://bpm.yili.com:8088/portal/r"+cent_url; + recordurls+=fileDownurl+";"; + } + String new_name = ""; + String[] split = recordfiles.split(";"); + if (split.length>0){ + + for (int i =1;i0){ + String loadurl = urls[0].replaceAll("&sid=null","&sid="+sessionId); + System.out.println("下载的地址是<<<<<<<<<<<<<<<<<<"+loadurl); + jsonObject_ehsq.put("downloadurl",loadurl); + for (int i =1;i>>>>>>" + map); + System.out.println("fileid==》》》》" + fileid); + System.out.println("id==》》》》" + map.getString("ID")); + RowMap rowMap = DBSql.getMap("SELECT * FROM " + bo_name + " where " + fileid + " '" + map.getString("ID") + "'"); + //BO bos = SDK.getBOAPI().query(bo_name,true).addQuery(fileid,"17e7d198-1656-4a2c-8912-a81850170be9").detail(); + if (rowMap != null) { + + if (StringUtils.isNotEmpty(rowMap.getString("TASKID"))) { + + OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID")); + if (model != null) { + System.out.println("pdel============" + model); + //System.out.println("123313123123123==========" + model.getProfileId()); + OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId()); + System.out.println("dajadfas======" + appProfile); + if (appProfile == null) { + throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId()); + } + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + String sql_lever = ""; + if (bo_name.equals("BO_ACT_COE_PUBLISH_N")) { + sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + rowMap.getString("PUBLISHFILEID") + "'"; + + } else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")) { + sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + rowMap.getString("CHANGEDFILEIDNEW") + "'"; + } + String lever = DBSql.getString(sql_lever); + System.out.println("版本号::::::::::::" + lever); + //lever = lever.substring(0,3); + if (lever.length() == 5 && lever.substring(4).equals("0")) { + lever.substring(0, 3); + } else if (lever.length() == 1) { + lever = lever + ".0"; + } + String filename = ""; + if (bo_name.equals("BO_ACT_COE_PUBLISH_N")) { + filename = rowMap.getString("PUBLISHFILENAME"); + } else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")) { + filename = rowMap.getString("CHANGEDFILENAMENEW"); + } + DCContext dcContext = new DCContext(userContext, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), rowMap.getString("TASKID"), filename + "_" + lever + ".doc"); + //UtilFile file = new UtilFile(dcContext.getPath()); + + + Map params = new HashMap(); +//知识ID,必填 + params.put("cardId", cardId); +//sid,必填 + params.put("sid", userContext.getSessionId()); + + params.put("dc", dcContext); + AppAPI appAPI = SDK.getAppAPI(); +//创建文件 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("流程手册的存入=================" + ro); + } + } + + } + String sql_A = "SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where ID = '" + map.getString("ID") + "' AND PLMETHODID != 'process.framework' AND PLMETHODID IN (select distinct PLMETHODID from APP_ACT_COE_PAL_REPOSITORY)"; + List rows = DBSql.getMaps(sql_A); + + for (RowMap bo : rows + ) { + + /** + * 这个是模型中的附件获取的并插入的数据信息,需要做修改 + */ + // 调用App + +// 参数定义列表 + Map paramss = new HashMap(); +//知识ID,必填 + paramss.put("cardId", cardId); +//sid,必填 + paramss.put("sid", userContext.getSessionId()); + + UpfileWeb upfileWeb = new UpfileWeb(userContext); + + + String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID != 'process.framework' AND ID= '" + map.getString("ID") + "'" + + ")"; + List maps = DBSql.getMaps(sql_upfile); + for (RowMap row : maps) { + System.out.println("附件名称>>>>>>" + row.getString("FILENAME")); + if (!row.getString("FILENAME").contains(".xml")) { + UpfileModel upfileModel = new UpfileModel(); + upfileModel.setType(row.getString("FILETYPE")); + upfileModel.setFileName(row.getString("FILENAME")); + upfileModel.setPl_uuid(row.getString("PALREPOSITORYID")); + upfileModel.setShape_uuid(row.getString("SHAPEID")); + DCContext dcContexts = upfileWeb.getDCContext(upfileModel); + paramss.put("dc", dcContexts); + AppAPI appAPIs = SDK.getAppAPI(); + ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, paramss); + System.out.println("流程模型附件的生成=============" + ros); + } + } + +//DCContext对象,必填 + +//创建文件 + } + try { + + PublishKnow(processInstance, userContext, cardId); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + + /** + * 发布知识 + * + * @param processInstance + * @param userContext + * @param id + */ + public void PublishKnow(ProcessInstance processInstance, UserContext userContext, String id) { + + String sql = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id in (select PLPARENTID from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '" + id + "')"; + List maps = DBSql.getMaps(sql); + String ids = ""; + for (RowMap rowmap : maps + ) { + ids += rowmap.getString("EXT4") + ","; + } + String[] deptSplit_id = ids.split(","); + + JSONArray jsonArray = new JSONArray(); + for (String id_names : deptSplit_id + ) { + jsonArray.add(id_names); + } + //jsonObject.put(deptSplit_id); + id += ","; + String[] deptSplit_das = id.split(","); + JSONArray jsonArray_das = new JSONArray(); + for (String das : deptSplit_das + ) { + jsonArray_das.add(das); + } + //jsonObject.put(deptSplit_id); + + if (!jsonArray_das.isEmpty() && !jsonArray.isEmpty()) { + + // 调用App + String sourceAppId = processInstance + .getAppId(); +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl"; +// 参数定义列表 + Map params = new HashMap(); +//要发布到的维度ID的JSON数组字符串,必填 + params.put("dimensionIDArray", jsonArray.toString()); +//要发布的知识ID的JSON数组字符串,必填 + params.put("knwlIDArray", jsonArray_das.toString()); +//标签的JSON数组字符串,非必填 + +//sid,必填 + params.put("sid", userContext.getSessionId()); + AppAPI appAPI = SDK.getAppAPI(); +//发布知识 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + + System.out.println("知识发布============" + ro); + + } + + } + + /** + * 取消发布知识 + * + * @param processInstance + * @param sid + * @param knwlId + * @return + */ + public boolean CancelPublishKnwl(ProcessInstance processInstance, String sid, String knwlId) { +// 调用App + String sourceAppId = processInstance.getAppId(); +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/CancelPublishKnwl"; +// 参数定义列表 + Map params = new HashMap(); +//sid,如果为空,则需要传createUser参数,非必填 + params.put("sid", sid); +//知识ID,必填 + params.put("knwlId", knwlId); + AppAPI appAPI = SDK.getAppAPI(); +//取消发布知识(全部维度) + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("取消发布的ro=====>>>>" + ro); + return ro.isOk(); + } + + /** + * 创建XPage页面上的待阅 + * + * @param processExecutionContext + * @param fileCreateName + * @param fileName + * @param fileurl + * @param readingScope_org + * @param isFullCompany + * @param fileCreateDate + * @param relationProcessinstId + * @param readingScope_post + * @param readingScope_level + * @param fileid + * @return + */ + public boolean execute(ProcessExecutionContext processExecutionContext, String fileCreateName, String fileName, String fileurl, String readingScope_org, String isFullCompany, String fileCreateDate, String relationProcessinstId, String readingScope_post, String readingScope_level, String fileid) { +// 调用App + String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); +// aslp服务地址 + String aslp = "aslp://com.awspaas.user.apps.docview/PushFileToXpage"; +// 参数定义列表 + Map params = new HashMap(); +//发布人,不允许空值,必填 + params.put("fileCreateName", fileCreateName); +//待阅文件标题名称,不允许空值,必填 + params.put("fileName", fileName); +//阅读范围_组织,不允许空值,非必填 + params.put("readingScope_org", readingScope_org); +//是否全公司可见,不允许空值,必填 + params.put("isFullCompany", isFullCompany); +//待阅文件Url,不允许空值,必填 + params.put("fileurl", fileurl); +//发布日期,不允许空值,必填 + params.put("fileCreateDate", fileCreateDate); +//发布流程ID,不允许空值,必填 + params.put("relationProcessinstId", relationProcessinstId); +//阅读范围_岗位,不允许空值,非必填 + params.put("readingScope_post", readingScope_post); +//阅读范围_职级,不允许空值,非必填 + params.put("readingScope_level", readingScope_level); +//待阅文件ID,多个逗号隔开,不允许空值,必填 + params.put("fileid", fileid); + AppAPI appAPI = SDK.getAppAPI(); +//推送待阅文件到xpage门户 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("ros++++++++=====待阅》》》》》》》》》》" + ro); + return ro.isOk(); + } + + + /** + * 给知识授权 + * + * @param processInstance + * @param jsonArray + * @param sid + * @param knwlId + * @return + */ + public boolean AddKnwlAC(ProcessInstance processInstance, JSONArray jsonArray, String sid, String knwlId) { +// 调用App + String sourceAppId = processInstance.getAppId(); +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC"; +// 参数定义列表 + Map params = new HashMap(); +//[{"assignmentType":"department","assignmentId":"62196ff9-a26d-4be5-9480-3ef680886f63"},{"assignmentType":"user","assignmentId":"user1"}],必填 + params.put("acList", jsonArray); +//sid,如果为空,则需要传createUser参数,非必填 + params.put("sid", sid); +//知识ID,必填 + params.put("knwlId", knwlId); + AppAPI appAPI = SDK.getAppAPI(); +//给知识授权 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + return ro.isOk(); + } + + + /** + * 柱军代码,不知道做什么用的 + * + * @param processInstance + * @param wsId + * @param fileId + * @return + */ + public boolean AttrSynAslp(ProcessInstance processInstance, String wsId, JSONArray fileId) { + System.out.println(""); + // 调用App + String sourceAppId = processInstance.getAppId(); +// aslp服务地址 + String aslp = "aslp://com.awspaas.user.apps.yili.reportform/AttrSynAslp"; +// 参数定义列表 + Map params = new HashMap(); +//资产内容库id,必填 + params.put("wsId", wsId); +//文件id;json数组[id1,id2,id3],必填 + params.put("fileId", fileId); + AppAPI appAPI = SDK.getAppAPI(); +//增量同步数据 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + System.out.println("ro>>>>>>>>>>>>>" + ro); + return ro.isOk(); + } + + /** + * 发送OA待阅数据 + * + * @param jsonObject + * @param processInstance + * @param results + * @throws DocumentException + */ + public void SendOARead(JSONObject jsonObject, ProcessInstance processInstance, String userId) throws DocumentException { + System.err.println(processInstance.getTitle()+"开始发送:"+userId); + if("".equals(userId)||UtilString.isEmpty(userId)) { + return; + } + jsonObject.put("userList", userId); + String xmlStr = "\n" + + " " + + " " + + " " + + " " + + "" + + " " + + " " + + " " + + ""; + System.out.println("xmlStr>>>>>>>>" + xmlStr); + String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl"); + + String postSoap = UtilUrl.doPostSoap(readurl, xmlStr, ""); + Document document = DocumentHelper.parseText(postSoap); + Element rootElement = document.getRootElement(); + System.out.println("rootElement>>>>>>" + rootElement); + Element result = rootElement.element("Body").element("serviceResponse").element("out"); + String resultString = result.getData().toString(); + JSONObject jsonObject1 = JSON.parseObject(resultString); + String datas = jsonObject1.getString("data"); + String status = jsonObject1.getString("status"); + System.out.println("状态是什么》》》》》》》》》》》" + status); + if("false".equals(status)) { + System.out.println(processInstance.getTitle()+"待阅推送失败:" + userId); + try { + BO bo = new BO(); + bo.set("TITLE", processInstance.getTitle()); + bo.set("NAME", userId); + bo.set("DEPNAME", SDK.getORGAPI().getUser(userId).getDepartmentId()); + SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser()); + } catch (Exception e) { + // TODO: handle exception + } + }else { + System.out.println(processInstance.getTitle()+"待阅推送成功:" + userId); + JSONArray resultArray = JSONObject.parseArray(datas); + for (int j = 0; j < resultArray.size(); j++) { + JSONObject jsonObject2 = resultArray.getJSONObject(j); + String user = jsonObject2.get("user").toString(); + String dataid = jsonObject2.get("dataid").toString(); + BO bo = new BO(); + bo.set("TITLE", processInstance.getTitle()); + bo.set("PROCESSID", processInstance.getId()); + bo.set("USER_ID", user); + bo.set("DATAID", dataid); + bo.set("RESULT", status); + SDK.getBOAPI().create("BO_ACT_DATAID", bo, processInstance.getId(), processInstance.getCreateUser()); + } + } + } + + /** + * 发送EHSQ接口 + * + * @param jsonArray + * @return + * @throws Exception + */ + public String SendEHSQFile(JSONArray jsonArray) throws Exception { + System.out.println("===jsonArray===" + jsonArray); + /** + * 首先需要将传过来的参数进行加密操作,并设置 + */ + AesUtil aesUtil = new AesUtil(); + String system = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "system"); + String AES = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "AES"); + String EHSQUrl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "EHSQUrl"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String date = sdf.format(new Date()); + String s1 = date.replaceAll("-", "").replaceAll(" ", "").replaceAll(":", ""); + + System.out.println("时间>>>>>>>>>>>>" + s1); + String data = system + "##" + s1; + String encrypt = aesUtil.encrypt(data, AES); //获取加密之后的秘钥 + JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); + jsonObject.put("system", system); + jsonObject.put("token", encrypt); + jsonObject.put("infos", jsonArray); + HttpUtil httpUtil = new HttpUtil(); + System.out.println("jsonobject>>>>>>>>>>>>>>>>>>>" + jsonObject); + String s = httpUtil.sendPost(jsonObject, EHSQUrl); + System.out.println("发送到EHSQ是否是正确的>>>>>>>>>" + s); + + return s; + } + + +public ArrayList getSendList(ProcessInstance instanceById,BO bo_act_coe_publish1,JSONObject jsonObject){ + + + String sendType = bo_act_coe_publish1.getString("SEND_SCOP"); + String org = bo_act_coe_publish1.getString("SEND_SCOPE_ORG"); + String post = bo_act_coe_publish1.getString("SEND_SCOPE_POST"); + String level = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL"); + ArrayList userList = new ArrayList<>(); + if("1".equals(sendType)) { + System.err.println("发送全集团=====>"+instanceById.getTitle()); + sendOrg(org,userList, instanceById, bo_act_coe_publish1, jsonObject,sendType); + }else { + //如果都不为空,组织/岗位取并集的结果同职级取交集 + if(UtilString.isNotEmpty(org)&&UtilString.isNotEmpty(post)&&UtilString.isNotEmpty(level)) { + System.err.println("发送组织/岗位/职级=====>"+instanceById.getTitle()); + sendOrg(org,userList,instanceById, bo_act_coe_publish1, jsonObject,sendType); + sendPost(post,userList,instanceById, bo_act_coe_publish1, jsonObject); + userList = sendLevel(level,userList,instanceById, bo_act_coe_publish1, jsonObject); + } + //如果职级为空,组织/岗位取并集 + if(UtilString.isNotEmpty(org)&&UtilString.isNotEmpty(post)&&UtilString.isEmpty(level)) { + System.err.println("发送组织/岗位=====>"+instanceById.getTitle()); + sendOrg(org,userList,instanceById, bo_act_coe_publish1, jsonObject,sendType); + sendPost(post,userList,instanceById, bo_act_coe_publish1, jsonObject); + } + //如果岗位为空,组织/职级取并集 + if(UtilString.isNotEmpty(org)&&UtilString.isEmpty(post)&&UtilString.isNotEmpty(level)) { + System.err.println("发送组织/职级=====>"+instanceById.getTitle()); + sendOrg(org,userList,instanceById, bo_act_coe_publish1, jsonObject,sendType); + userList = sendLevel(level,userList,instanceById, bo_act_coe_publish1, jsonObject); + } + + //如果组织为空,岗位/职级取交集 + if(UtilString.isEmpty(org)&&UtilString.isNotEmpty(post)&&UtilString.isNotEmpty(level)) { + System.err.println("发送岗位/职级=====>"+instanceById.getTitle()); + sendPost(post,userList,instanceById, bo_act_coe_publish1, jsonObject); + userList = sendLevel(level,userList,instanceById, bo_act_coe_publish1, jsonObject); + } + + } + + + return userList; + +} +//发送组织 +public ArrayList sendOrg(String org,ArrayList userList,ProcessInstance instanceById,BO bo_act_coe_publish1,JSONObject jsonObject,String sendType) { + String processid =instanceById.getId(); + //获取组织 + if (StringUtils.isNotEmpty(org)||"1".equals(sendType)) { + long startTime = System.currentTimeMillis(); + userList = getUser(jsonObject,org,sendType, processid); + long endTimes = System.currentTimeMillis(); + System.out.println(instanceById.getTitle()+"_根据部门获取人员用时===>"+(endTimes-startTime)/1000); + } + + return userList; + } + +//发送岗位 +public ArrayList sendPost(String post,ArrayList userList,ProcessInstance instanceById,BO bo_act_coe_publish1,JSONObject jsonObject) { + String processid =instanceById.getId(); + //获取岗位 + if (StringUtils.isNotEmpty(post)) { + String posts[] = post.split(","); + //取并集 + String postss = ""; + if (posts.length == 1) { + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + postss = "'" + posts[0] + "'"; + } else { + postss = "'" + StringUtils.join(posts, "','") + "'"; + } + String sql = "select * from ORGUSER where POSITION_NO in (" + postss + ") and userno is not null"; + List maps1 = DBSql.getMaps(sql); + for (RowMap rowMap : maps1) { + String userId = rowMap.getString("USERID"); + RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '"+processid+"' AND USER_ID = '"+userId+"'"); + //BO boList = SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processid).addQuery("USER_ID=",userId).detail(); + if (!userList.contains(userId)&&map==null) { + userList.add(userId); + } + + } + } + + return userList; +} + +//发送职级 +public ArrayList sendLevel(String level,ArrayList userList,ProcessInstance instanceById,BO bo_act_coe_publish1,JSONObject jsonObject) { + String processid =instanceById.getId(); + ArrayList userList_level = new ArrayList(); + //获取职级 + if (StringUtils.isNotEmpty(level)) { + String ranks[] = level.split(","); + String rankss = ""; + if (ranks.length == 1) { + // DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN "); + rankss = "'" + ranks[0] + "'"; + } else { + rankss = "'" + StringUtils.join(ranks, "','") + "'"; + } + //取交集 + String sql2 = "select * from ORGUSER where EXT2 in (" + rankss + ") and userno is not null"; + List maps2 = DBSql.getMaps(sql2); + for (RowMap rowMap : maps2) { + String userId = rowMap.getString("USERID"); + RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '"+processid+"' AND USER_ID = '"+userId+"'"); + //BO boList = SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processid).addQuery("USER_ID=",userId).detail(); + if (userList.contains(userId)&&map==null) { + userList_level.add(userId); + } + + } + } + + return userList_level; +} + + + +/** + * 根据部门id获取当前部门以及下级部门的人员信息 + * + * @param processid + * @return + */ + +public ArrayList getUser(JSONObject jsonObject, String depIds, String sendType, String processid) { + ArrayList arr = new ArrayList(); + ArrayList arr_test = new ArrayList(); + // 全集团 + if ("1".equals(sendType)) { + List departmentsByCompanyId = SDK.getORGAPI().getDepartmentsByCompanyId(1, + "8911e732-b42a-4556-853f-ad32761bcbee"); + for (DepartmentModel departmentModel : departmentsByCompanyId) { + String id = departmentModel.getId(); + //查询未注销的部门并且去掉系统部门 + if (!departmentModel.isClosed() && !"e79281b1-2f81-4895-b30e-9f96e9ad0e2c".equals(id) + && !"5bc3a2dc-3bd2-4376-bcc3-5612e28e55fe".equals(id)) { + getUserList(jsonObject, arr_test, arr, id, processid); + + } + } + } else { + if (UtilString.isNotEmpty(depIds)) { + String[] split = depIds.split(","); + for (String depId : split) { + getUserList(jsonObject, arr_test, arr, depId, processid); + } + } + } + + System.err.println(SDK.getProcessAPI().getInstanceById(processid) + "_得到的总人数为:" + arr_test.size()); + System.err.println(SDK.getProcessAPI().getInstanceById(processid) + "_得到的过滤后的人数为:" + arr.size()); + return arr; +} + + public void getUserList( JSONObject jsonObject,ArrayList arr_test,ArrayList arr, String departmentId, String processid) { + // 获取当前部门下人员 + List userModelList = SDK.getORGAPI().getAllUsersByDepartment(departmentId); + for (UserModel userModel : userModelList) { + if (!userModel.isClosed()) { + String uid = userModel.getUID(); + if (!arr.contains(uid)) { + arr_test.add(uid); + RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '"+processid+"' AND USER_ID = '"+uid+"'"); + if (map == null) { + System.err.println("发送人员======>"+uid); + arr.add(userModel.getUID()); + } + } + } + } + // 获取当前部门的子部门人员 + DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(departmentId); + if (departmentById.isExistSubModelOfCache()) { + getSubDepartments(jsonObject,arr_test,arr, departmentById, processid); + } + + } + + //获取子部门人员 + public void getSubDepartments(JSONObject jsonObject,ArrayList arr_test,ArrayList arr, DepartmentModel departmentById, String processid) { + if (!departmentById.isClosed()) { + List subDepartments = SDK.getORGAPI().getSubDepartments(departmentById.getId()); + for (DepartmentModel departmentModel : subDepartments) { + if(!departmentModel.isClosed()) { + String id = departmentModel.getId(); + List userModelList = SDK.getORGAPI().getAllUsersByDepartment(id); + for (UserModel userModel : userModelList) { + if (!userModel.isClosed()) { + String uid = userModel.getUID(); + if (!arr.contains(uid)) { + arr_test.add(uid); + RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '"+processid+"' AND USER_ID = '"+uid+"'"); + if (map == null) { + arr.add(uid); + System.err.println(SDK.getProcessAPI().getInstanceById(processid)+"_发送人员======>"+uid); + } + } + } + } + //递归获取子部门下的子部门 + if (SDK.getORGAPI().isExistSubDepartment(id)) { + getSubDepartments(jsonObject,arr_test,arr,SDK.getORGAPI().getDepartmentById(id),processid); + } + + } + + } + } + } + + /** + * 创建更新的知识 + * + * @param bo + * @param wsId + * @param filed + * @param instanceById + * @param bo_act_coe_publish + * @param uid + */ + public void CreateKmsByUpdate(BO bo, String wsId, JSONArray filed, ProcessInstance instanceById, BO bo_act_coe_publish, String uid) { + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("CHANGEDFILEIDNEW"); + filed.add(publishfileid) + + + ; + DBSql.update("update APP_ACT_COE_PAL_REPOSITORY set EXT4 = '' where id = '" + publishfileid + "'"); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; + RowMap map = DBSql.getMap(sql_n); + if (StringUtils.isEmpty(map.getString("EXT4"))) { + // aslp服务地址 + String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl"; +// 参数定义列表 + Map params_create = new HashMap(); +//保密级别, 0: 普通 1:秘密 2:机密,必填 + params_create.put("securityLevel", 0); +//知识名称,必填 + String level = ""; + if (map != null) { + if (map.getString("PLVER").contains(".00")) { + String[] plvers = map.getString("PLVER").split("\\."); + plvers[1] = plvers[1].replaceAll("0", ""); + level = plvers[0] + plvers[1]; + } else { + level = map.getString("PLVER"); + } + } + + + params_create.put("knwlName", map.getString("PLNAME") + "V" + level); +//是否可以评论,必填 + params_create.put("isComment", true); +//是否可以评分,必填 + params_create.put("isRate", true); +//有效期:yyyy-MM-dd,非必填 + params_create.put("validDate", "2099-12-31"); +//只读控制,1:在线阅读和下载 0:在线阅读,必填 + params_create.put("onlineLevel", 1); +//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填 + params_create.put("createUser", "admin"); +//知识内容,非必填 + params_create.put("cardContext", ""); +//sid,必填 + params_create.put("sid", UserContext.fromUID(instanceById.getCreateUser()).getSessionId()); + AppAPI appAPI_create = SDK.getAppAPI(); +//创建知识 + ResponseObject ro_create = appAPI_create.callASLP(appAPI_create.getAppContext(instanceById.getAppId()), aslps_create, params_create); + System.out.println("ro_create================" + ro_create); + String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); + JSONArray jsonArray1 = new JSONArray(); + if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")) { + String departId = bo_act_coe_publish.getString("SEND_SCOPE_ORG"); + if (StringUtils.isNotEmpty(departId) && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_LEVEL")) && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_POST"))) { + String strs[] = departId.split(","); + for (String departmentid : strs + ) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", departmentid); + jsonArray1.add(jsonObjecta); + } + } else { + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + + for (String user_id : list + ) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "user"); + jsonObjecta.put("assignmentId", user_id); + jsonArray1.add(jsonObjecta); + } + } + + } else { + List select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT"); + for (RowMap depaid : + select_id_from_orgdepartment) { + String id = depaid.getString("ID"); + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", id); + jsonArray1.add(jsonObjecta); + } + } + AddKnwlAC(instanceById, jsonArray1, UserContext.fromUID(instanceById.getCreateUser()).getSessionId(), cardId); + + String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '" + cardId + "' WHERE " + + " PLCATEGORY = 'process'and PLMETHODID !='process.framework' " + + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + " '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + " '42c09260-c1d3-44b7-ac3d-f8280e04c294') and ID = '" + publishfileid + "'"; + int update = DBSql.update(update_sql); + System.out.println("更新id为:" + publishfileid + "版本为:的知识对应的资产库的EXT4的影响行数为" + update); + creadteFile(instanceById, "BO_ACT_COE_PUBLISH_C", UserContext.fromUID(instanceById.getCreateUser()), cardId, " CHANGEDFILEIDNEW="); + } + //将旧的知识取消发布或者移动到废止发布中 + String publishfileid_old = bo.getString("CHANGEFILEID"); + String sql_c = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid_old + "'"; + RowMap map1 = DBSql.getMap(sql_c); + if (StringUtils.isNotEmpty(map1.getString("EXT4"))) { + CancelPublishKnwl(instanceById, UserContext.fromUID(instanceById.getCreateUser()).getSessionId(), map1.getString("EXT4")); + DBSql.update( + "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '" + publishfileid_old + "'" + ); + } + } + + public void CreateKmsBynew(BO bo, String wsId, JSONArray filed, ProcessInstance instanceById, BO bo_act_coe_publish, String uid) { + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + wsId = model.getWsId(); + String publishfileid = bo.getString("PUBLISHFILEID"); + filed.add(publishfileid); + String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'"; + RowMap map = DBSql.getMap(sql_n); + if (StringUtils.isEmpty(map.getString("EXT4"))) { + // aslp服务地址 + String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl"; +// 参数定义列表 + Map params_create = new HashMap(); +//保密级别, 0: 普通 1:秘密 2:机密,必填 + params_create.put("securityLevel", 0); +//知识名称,必填 + + String level = ""; + + + if (map.getString("PLVER").contains(".00")) { + String[] plvers = map.getString("PLVER").split("\\."); + plvers[1] = plvers[1].replaceAll("0", ""); + level = plvers[0] + plvers[1]; + } else { + level = map.getString("PLVER"); + } + + params_create.put("knwlName", map.getString("PLNAME") + "V" + level); +//是否可以评论,必填 + params_create.put("isComment", true); +//是否可以评分,必填 + params_create.put("isRate", true); +//有效期:yyyy-MM-dd,非必填 + params_create.put("validDate", "2099-12-31"); +//只读控制,1:在线阅读和下载 0:在线阅读,必填 + params_create.put("onlineLevel", 1); +//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填 + params_create.put("createUser", "admin"); +//知识内容,非必填 + params_create.put("cardContext", ""); +//sid,必填 + params_create.put("sid", UserContext.fromUID(instanceById.getCreateUser()).getSessionId()); + AppAPI appAPI_create = SDK.getAppAPI(); +//创建知识 + ResponseObject ro_create = appAPI_create.callASLP(appAPI_create.getAppContext(instanceById.getAppId()), aslps_create, params_create); + System.out.println("ro_create================" + ro_create); + String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString(); + JSONArray jsonArray1 = new JSONArray(); + if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")) { + String departId = bo_act_coe_publish.getString("SEND_SCOPE_ORG"); + if (StringUtils.isNotEmpty(departId) && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_LEVEL")) && StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_POST"))) { + String strs[] = departId.split(","); + for (String departmentid : strs + ) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", departmentid); + jsonArray1.add(jsonObjecta); + } + } else { + + String[] split = uid.split(","); + + List list = new ArrayList(Arrays.asList(split)); + + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + + for (String user_id : list + ) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "user"); + jsonObjecta.put("assignmentId", user_id); + jsonArray1.add(jsonObjecta); + } + } + } else { + List select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT"); + for (RowMap depaid : + select_id_from_orgdepartment) { + String id = depaid.getString("ID"); + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType", "department"); + jsonObjecta.put("assignmentId", id); + jsonArray1.add(jsonObjecta); + } + } + + + AddKnwlAC(instanceById, jsonArray1, UserContext.fromUID(instanceById.getCreateUser()).getSessionId(), cardId); + + String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '" + cardId + "' WHERE " + + " PLCATEGORY = 'process'and PLMETHODID !='process.framework' " + + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + " '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + " '42c09260-c1d3-44b7-ac3d-f8280e04c294') and ID = '" + publishfileid + "'"; + int update = DBSql.update(update_sql); + System.out.println("更新id为:" + publishfileid + "版本为:的知识对应的资产库的EXT4的影响行数为" + update); + creadteFile(instanceById, "BO_ACT_COE_PUBLISH_N", UserContext.fromUID(instanceById.getCreateUser()), cardId, "PUBLISHFILEID = "); + } + } + + + + /** + * 以线程进行发送待阅信息 ,暂停使用 + * + * @param list + * @param startTime + * @param jsonObject + * @param instanceById + */ + public void corse_bak(List list, long startTime, JSONObject jsonObject, ProcessInstance instanceById) { + // 创建线程来实现为每300人为一个的线程跑待阅 + ExecutorService service = Executors.newFixedThreadPool(2); + service.execute(new Runnable() { + @Override + public void run() { + int i = 0; + for (String[] resrt : list + ) { + if ((list.size() - 1) == i) { + long endTime = System.currentTimeMillis(); + + long time = endTime - startTime; + long itmes = time / 1000 / 60 / 60; + BO bo_eu_pal_read_log = SDK.getBOAPI().query("BO_EU_PAL_READ_LOG", true).addQuery("PROCESSID = ", instanceById.getId()).detail(); + bo_eu_pal_read_log.set("ENDTIMES", endTime); + bo_eu_pal_read_log.set("TIMECOUNT", itmes); + SDK.getBOAPI().update("BO_EU_PAL_READ_LOG", bo_eu_pal_read_log); + } + i++; + } + } + }); + } + + /** + * 创建待阅日志信息 + * + * @param instanceById + * @param jsonObject + * @param users + * @param startTime + */ + public void CreateReadLog(ProcessInstance instanceById, JSONObject jsonObject, String[] users, long startTime) { + BO bo_Read_log = new BO(); + bo_Read_log.set("USREID", instanceById.getCreateUser()); + bo_Read_log.set("DEPID", UserContext.fromUID(instanceById.getCreateUser()).getDepartmentModel().getId()); + bo_Read_log.set("BUNAME", UserContext.fromUID(instanceById.getCreateUser()).getUserModel().getExt4()); + bo_Read_log.set("TITLE", jsonObject.get("title")); + bo_Read_log.set("PROCESSID", instanceById.getId()); + bo_Read_log.set("SENDNUM", users.length); + BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", instanceById.getId()).addQuery("OPTIONTYPE IS NOT NULL", null).detail(); + String send_scop = bo_act_coe_publishs.getString("SEND_SCOP"); + bo_Read_log.set("SEND_SCOP", send_scop); + String SEND_SCOPE_ORG = bo_act_coe_publishs.getString("SEND_SCOPE_ORG"); + if (UtilString.isNotEmpty(SEND_SCOPE_ORG)) { + String[] resulr = SEND_SCOPE_ORG.split(","); + bo_Read_log.set("SEND_SCOPE_ORGNUM", resulr.length); + } + String SEND_SCOPE_POST = bo_act_coe_publishs.getString("SEND_SCOPE_POST"); + if (UtilString.isNotEmpty(SEND_SCOPE_POST)) { + String[] resulr = SEND_SCOPE_POST.split(","); + bo_Read_log.set("SEND_SCOPE_POST_NUM", resulr.length); + } + String SEND_SCOPE_LEVEL = bo_act_coe_publishs.getString("SEND_SCOPE_LEVEL"); + if (UtilString.isNotEmpty(SEND_SCOPE_LEVEL)) { + String[] resulr = SEND_SCOPE_LEVEL.split(","); + bo_Read_log.set("SEND_SCOPE_LEVEL_NUM", resulr.length); + } + + bo_Read_log.set("STARTTIMES", startTime); + SDK.getBOAPI().createDataBO("BO_EU_PAL_READ_LOG", bo_Read_log, UserContext.fromUID(instanceById.getCreateUser())); + + } + + //创建推送日志 + public void createLog(ProcessInstance instanceById,String uids) { + BO bo = new BO();//BO_EU_PAL_SEND_LOG + bo.set("USREID",instanceById.getCreateUser()); + bo.set("TITLE",instanceById.getTitle()); + bo.set("SENDTIME",instanceById.getEndTime()); + bo.set("PROCESSID",instanceById.getId()); + bo.set("USERNAMES",uids); + bo.set("DEPID",UserContext.fromUID(uids).getDepartmentModel().getId() + ); + bo.set("POSTNAME",UserContext.fromUID(uids).getUserModel().getPositionName() + ); + bo.set("BUNAME",UserContext.fromUID(uids).getUserModel().getExt2() + ); + SDK.getBOAPI().createDataBO("BO_EU_PAL_SEND_LOG",bo,UserContext.fromUID("admin")); + } +} \ No newline at end of file diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/updateKnowByExt4Empty.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/updateKnowByExt4Empty.java new file mode 100644 index 00000000..6b86b346 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/job/updateKnowByExt4Empty.java @@ -0,0 +1,28 @@ +package com.awspaas.user.apps.integration.job; + +import com.actionsoft.bpms.schedule.IJob; +import com.actionsoft.bpms.util.DBSql; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +/** + * 更新PAL资产库的EXT4字段为空,根据知识 + */ +public class updateKnowByExt4Empty implements IJob { + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + String sql = "update APP_ACT_COE_PAL_REPOSITORY set EXT4 = '' where ID in (select ID from APP_ACT_COE_PAL_REPOSITORY" + + " where PLCATEGORY = 'process'and PLMETHODID !='process.framework'" + + " and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" + + " ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" + + " and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," + + " 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," + + " '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," + + " '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," + + " '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," + + " '42c09260-c1d3-44b7-ac3d-f8280e04c294'))"; + int update = DBSql.update(sql); + String sqls = "update APP_ACT_COE_PAL_REPOSITORY set EXT4 = '' "; + int updates = DBSql.update(sqls); + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaDeleteComponent.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaDeleteComponent.java new file mode 100644 index 00000000..c0f49963 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaDeleteComponent.java @@ -0,0 +1,82 @@ +package com.awspaas.user.apps.integration.oa; +import com.awspaas.user.apps.integration.util.HttpClientUtils; +import org.apache.commons.httpclient.HttpStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance; +import com.actionsoft.bpms.util.ThreadMgr; +import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSONObject; + +/** + * @author LiHongYu + */ +public class OaDeleteComponent { + + private static Logger logger = LoggerFactory.getLogger(OaDeleteComponent.class); + private String uri = SDK.getAppAPI().getProperty("com.hy.apps.integrated", "uri"); + private String userName = SDK.getAppAPI().getProperty("com.hy.apps.integrated", "restUserName"); + private String password = SDK.getAppAPI().getProperty("com.hy.apps.integrated", "restUserPwd"); + + private static class PostPendTask implements Runnable { + int type; + String url; + String taskId; + Object content; + + public PostPendTask(String taskId ,int type, String url, Object content) { + this.type = type; + this.url = url; + this.content = content; + this.taskId = taskId; + } + + @Override + public void run() { + HttpClientUtils httpClientUtil = new HttpClientUtils(); + String params = JSONObject.toJSONString(content); + try { + //httpClientUtil.setPostRequestBody(params,"application/json","UTF-8"); + int httpStatus = 1; + //String result = httpClientUtil.getResponseBodyAsString("utf-8"); + + + if (httpStatus != HttpStatus.SC_OK){ + OaPendComponentLose opl = new OaPendComponentLose(); + TaskInstance instanceById = SDK.getTaskAPI().getInstanceById(taskId); + if(instanceById!=null) { + opl.careateProcess(type,taskId,instanceById.getTarget()); + }else { + opl.careateProcess(type,taskId,""); + } + //logger.info("调用删除推送接口====>type:" + type + "taskId: " + taskId + ",url:" + url + ",失败!","已发起手动推送待办流程!"); + }else{ + //logger.info("调用OA删除任务接口====>type:"+type+",taskId:"+taskId+",url:"+url+",返回结果:"); + } + } catch (Exception e) { + //logger.info("调用OA删除任务接口====>type:"+type+"taskId:"+taskId+",url:"+url+",失败!网络异常!",e.getMessage()); + } + } + + } + + + + + /** + * 删除任务 + * @param taskInstanceId DD + */ + public void deleteOaPending(String taskInstanceId){ + String token = ""; + OaPending pend = new OaPending(); + pend.setTaskId(taskInstanceId); + pend.setRegisterCode("3011"); + pend.setClassify("BPM"); + pend.setToken(token); + ThreadMgr.execute(new PostPendTask(taskInstanceId,3,uri + "/seeyon/rest/thirdPartyCommitted/deleteCommitted?token=" + token,pend)); + } + + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaMessage.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaMessage.java new file mode 100644 index 00000000..e5e040a8 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaMessage.java @@ -0,0 +1,167 @@ +package com.awspaas.user.apps.integration.oa; + +import java.util.Date; + +/** + * Created by kkdo FanGaowei (justfgwlzx@163.com). + * Description: + *
+ * thirdpartyMessageId	第三方消息主键(保证唯一)	必填
+ * thirdpartyRegisterCode	为第三方配置的系统注册编码	必填
+ * messageContent	消息内容	必填
+ * thirdpartySenderId	第三方消息发起人主键(保证唯一)	非必填
+ * thirdpartyReceiverId	第三方消息接收人主键(保证唯一)	必填
+ * creation_date	消息创建时间(格式:yyyy-MM-dd HH:mm:ss)	必填
+ * messageType	0:PC;1:移动URL接入应用;2:本地H5应用;3:本地原生应用;4:PC&移动URL接入应用;5:PC&本地H5应用;6:PC&本地原生应用	必填
+ * downloadUrl	原生应用下载地址(仅3和6类型可选)	非必填
+ * messageURL	PC端穿透链接	非必填
+ * messageH5URL	移动端穿透链接	非必填
+ * appParam	原生应用穿透命令,穿透命令需要按这个顺序:iphone|ipad|android|wp	非必填
+ * 2017年10月9日 下午8:21:39 + */ + +public class OaMessage { + private String thirdpartyMessageId; + private String thirdpartyRegisterCode; + private String messageContent; + private String thirdpartySenderId; + private String thirdpartyReceiverId; + private String thirdpartySenderName; + private String thirdpartyReceiverName; + private Date creationDate; + private int messageType; + private String downloadUrl; + private String messageURL; + private String messageH5URL; + private String appParam; + private String noneBindingSender; + private String noneBindingReceiver; + + public OaMessage() {} + + public String getNoneBindingSender() { + return noneBindingSender; + } + + public void setNoneBindingSender(String noneBindingSender) { + this.noneBindingSender = noneBindingSender; + } + + public String getNoneBindingReceiver() { + return noneBindingReceiver; + } + + + + + public void setNoneBindingReceiver(String noneBindingReceiver) { + this.noneBindingReceiver = noneBindingReceiver; + } + + + + public String getThirdpartySenderName() { + return thirdpartySenderName; + } + + public void setThirdpartySenderName(String thirdpartySenderName) { + this.thirdpartySenderName = thirdpartySenderName; + } + + public String getThirdpartyReceiverName() { + return thirdpartyReceiverName; + } + + public void setThirdpartyReceiverName(String thirdpartyReceiverName) { + this.thirdpartyReceiverName = thirdpartyReceiverName; + } + + public String getThirdpartyMessageId() { + return thirdpartyMessageId; + } + + public void setThirdpartyMessageId(String thirdpartyMessageId) { + this.thirdpartyMessageId = thirdpartyMessageId; + } + + public String getThirdpartyRegisterCode() { + return thirdpartyRegisterCode; + } + + public void setThirdpartyRegisterCode(String thirdpartyRegisterCode) { + this.thirdpartyRegisterCode = thirdpartyRegisterCode; + } + + public String getMessageContent() { + return messageContent; + } + + public void setMessageContent(String messageContent) { + this.messageContent = messageContent; + } + + public String getThirdpartySenderId() { + return thirdpartySenderId; + } + + public void setThirdpartySenderId(String thirdpartySenderId) { + this.thirdpartySenderId = thirdpartySenderId; + } + + public String getThirdpartyReceiverId() { + return thirdpartyReceiverId; + } + + public void setThirdpartyReceiverId(String thirdpartyReceiverId) { + this.thirdpartyReceiverId = thirdpartyReceiverId; + } + + public Date getCreationDate() { + return creationDate; + } + + public void setCreationDate(Date creationDate) { + this.creationDate = creationDate; + } + + public int getMessageType() { + return messageType; + } + + public void setMessageType(int messageType) { + this.messageType = messageType; + } + + public String getDownloadUrl() { + return downloadUrl; + } + + public void setDownloadUrl(String downloadUrl) { + this.downloadUrl = downloadUrl; + } + + public String getMessageURL() { + return messageURL; + } + + public void setMessageURL(String messageURL) { + this.messageURL = messageURL; + } + + public String getMessageH5URL() { + return messageH5URL; + } + + public void setMessageH5URL(String messageH5URL) { + this.messageH5URL = messageH5URL; + } + + public String getAppParam() { + return appParam; + } + + public void setAppParam(String appParam) { + this.appParam = appParam; + } + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaPendComponent.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaPendComponent.java new file mode 100644 index 00000000..561499dc --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaPendComponent.java @@ -0,0 +1,630 @@ +package com.awspaas.user.apps.integration.oa; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.ProcessAPIManager; +import com.actionsoft.bpms.bpmn.engine.core.context.TaskBehaviorContextImpl; +import com.actionsoft.bpms.bpmn.engine.model.run.TaskCommentModel; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance; +import com.actionsoft.bpms.commons.login.constant.LoginConst; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.server.SSOUtil; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.sdk.local.api.AppAPI; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.awspaas.user.apps.integration.XmlDatasUtil; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.lang3.StringUtils; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.dom4j.xpath.DefaultXPath; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance; +import com.actionsoft.bpms.org.cache.UserCache; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.exception.BPMNError; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.NotificationAPI; +import com.alibaba.fastjson.JSONObject; +import com.awspaas.user.apps.integration.util.HttpClientUtils; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import javax.xml.soap.*; + +/** + * @author lihyyu + */ +public class OaPendComponent { + + private static Logger logger = LoggerFactory.getLogger(OaPendComponent.class); + + private NotificationAPI notificationAPI = SDK.getNotificationAPI(); + + private String uri = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "uri"); + private String userName = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "restUserName"); + private String password = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "restUserPwd"); + private String[] GO_BACK = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "GO_BACK").split("\\|"); + + + private static class PostPendTask implements Runnable { + int type; + String url; + String taskId; + Object content; + + public PostPendTask(String taskId, int type, String url, Object content) { + this.type = type; + this.url = url; + this.taskId = taskId; + this.content = content; + } + + @Override + public void run() { + HttpClientUtils httpClientUtil = new HttpClientUtils(); + Map map = new HashMap<>(); + map.put("createTime", new Timestamp(new Date().getTime())); + map.put("calledCount", 1); + if (content instanceof OaPending) { + OaPending pend = (OaPending) this.content; + map.put("paramId", pend.getTaskId()); + map.put("receiver", pend.getNoneBindingReceiver()); + } else if (content instanceof OaMessage) { + OaMessage msg = (OaMessage) this.content; + map.put("paramId", msg.getThirdpartyMessageId()); + map.put("receiver", msg.getNoneBindingReceiver()); + } + String ty= ""; + if (type == 0) { + ty = "推送"; + map.put("method", "sendPending"); + } else if (type == 1) { + ty = "消息"; + map.put("method", "sendMsg"); + } else if (type == 2) { + ty = "更新"; + map.put("method", "updatePending"); + } else { + throw new BPMNError("类型未定义!"); + } + + String params = JSONObject.toJSONString(content); + map.put("params", params); + if (params.contains("subState")) { + + } else { + } + // httpClientUtil.setPostRequestBody(params,"application/json","UTF-8"); + int httpStatus = 1; + if (httpStatus != HttpStatus.SC_OK) { + if(type==0||type==2) { + OaPendComponentLose opl = new OaPendComponentLose(); + int careateProcess = opl.careateProcess(type,taskId, SDK.getTaskAPI().getInstanceById(taskId).getTarget()); + if (careateProcess > 0) { + if (type == 0) { + logger.info("调用OA推送接口====>type:" + type + "taskId: " + taskId + ",url:" + url + ",失败!", + "已发起手动推送待办流程!"); + }else if(type == 2){ + logger.info("调用OA更新接口====>type:" + type + "taskId: " + taskId + ",url:" + url + ",失败!", + "已发起手动更新待办流程!"); + } + } + + }else { + logger.info("调用OA待办消息接口====>type:" + type + ",url:" + url + ",失败!" + "taskId: " + taskId); + } + + + } else { + logger.info("调用OA待办"+ty+"接口====>taskId: " + taskId + "返回结果:"); + } + + map.put("httpStatus", httpStatus); + } + } + + /** + * 发送待办 + * + * @param taskInstance DD + */ + public void sendOaPending(TaskInstance taskInstance, ProcessExecutionContext pec) throws IOException { + if("admin".equals(taskInstance.getTarget())) { + return; + } + XmlDatasUtil xmlDatasUtil = new XmlDatasUtil(); + xmlDatasUtil.setExternal_system_ID("LCZD"); + xmlDatasUtil.setOther_system_to_do_ID(taskInstance.getId()); + BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", pec.getProcessInstance().getId()).detail(); + if (!pec.getProcessInstance().getParentTaskInstId().equals("00000000-0000-0000-0000-000000000000")){ + if (bo_act_coe_publish!=null){ + xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+bo_act_coe_publish.getString("PROCESS_TITLE")+"】,点击进行处理"); + }else { + BO bo_eu_1664184390101 = SDK.getBOAPI().query("BO_EU_1664184390101", true).addQuery("BINDID=", pec.getProcessInstance().getId()).detail(); + if (bo_eu_1664184390101!=null){ + xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+pec.getProcessInstance().getTitle()+"】,点击进行处理"); + }else { + xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+pec.getProcessDef().name+"】,点击进行处理"); + } + } + }else { + xmlDatasUtil.setProcess_title(" 您有一条草稿流程保存成功【"+pec.getProcessInstance().getTitle()+"】"); + } + + + //http://localhost:8089/portal/r/or?cmd=com.yili_form_page_open&processInstId=3505e654-9217-41cd-a31d-4971846b3219&taskInstId=8a71d75e-3ee0-43a2-a226-ecb01419319c&oauthName=oauthLogin&token=admin + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + if (portalUrl.equals("http://10.114.11.135:8088/portal")){ + portalUrl = "https://bpm.yili.com:8088/portal/"; + } + xmlDatasUtil.setPcurl(portalUrl+"/r/or?cmd=com.yili_form_page_open&oauthName=oauthLogin&processInstId="+pec.getProcessInstance().getId()+"&taskInstId="+taskInstance.getId()+"&openState="+taskInstance.getState()); + xmlDatasUtil.setMobileurl(portalUrl+"/r/or?cmd=com.yili_form_page_open&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&casaccount="+taskInstance.getTarget()+"&processInstId="+pec.getProcessInstance().getId()+"&taskInstId="+taskInstance.getId()+"&openState="+taskInstance.getState()); + String target = taskInstance.getTarget(); + + //System.out.println("当前账户======》》》》"+target); + BO bo_eu_oa_reson = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("WORKCODE=" , target).detail(); + //System.out.println("bo>>>>>>>>>>"+bo_eu_oa_reson); + if (bo_eu_oa_reson!=null){ + xmlDatasUtil.setTo_do_login_account(bo_eu_oa_reson.getString("LOGINID")); + } + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义格式,不显示毫秒 + String str = df.format(taskInstance.getBeginTime()); + String substring = str.substring(str.indexOf(" "), str.length()); + xmlDatasUtil.setTo_do_creation_time(substring); + xmlDatasUtil.setTo_do_completion_time(substring); + //if (taskInstance.getState()==1){ + xmlDatasUtil.setTo_do_status("0"); + //} + xmlDatasUtil.setTo_do_official_type("0"); +// if (taskInstance.getReadState()==0){ +// xmlDatasUtil.setViewtype("0"); +// }else if (taskInstance.getReadState()==1){ + xmlDatasUtil.setViewtype("0"); +// } + xmlDatasUtil.setCreatedate(str.substring(0, str.indexOf(" "))); + xmlDatasUtil.setDonedate(str.substring(0, str.indexOf(" "))); + /*String der =""; + if (taskInstance.getReadTime()!=null){ + der = df.format(taskInstance.getReadTime()); + xmlDatasUtil.setReceivedate(der.substring(0, der.indexOf(" "))); + xmlDatasUtil.setReceivetime(der.substring(der.indexOf(" "),der.length())); + }else { + der = df.format(taskInstance.getBeginTime()); + xmlDatasUtil.setReceivedate(der.substring(0, der.indexOf(" "))); + xmlDatasUtil.setReceivetime(der.substring(der.indexOf(" "),der.length())); + }*/ + xmlDatasUtil.setReceivedate(str.substring(0, str.indexOf(" "))); + xmlDatasUtil.setReceivetime(substring); + + xmlDatasUtil.setCurrentnodetype("0"); + xmlDatasUtil.setRequestcode(pec.getProcessInstance().getId()); + xmlDatasUtil.setCurrentnodename(SDK.getRepositoryAPI().getProcessNode(pec.getProcessInstance().getProcessDefId(),taskInstance.getActivityDefId()).getName()); + + // 调用App + String sourceAppId = pec.getProcessInstance().getAppId(); + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.processtrends/processNodeInfoASLP"; + // 参数定义列表 + Map params = new HashMap(); + //流程实例id,必填 + params.put("processInstId", pec.getProcessInstance().getId()); + //,必填 + params.put("sid", pec.getUserContext().getSessionId()); + AppAPI appAPI = SDK.getAppAPI(); + //流程节点数据 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + String username = ""; + String userid = ""; + if (ro.isOk()){ + List list = new ArrayList(); + Object processBudgetModelList = ro.get("processBudgetModelList"); + JSONArray array = JSON.parseArray(String.valueOf(processBudgetModelList)); + + if (!array.isEmpty()){ + for(int i=0;i>>>>>>>>>>>"+s); + BO bo_eu_faid_data = SDK.getBOAPI().query("BO_EU_FAID_DATA", true).addQuery("TASK_ID=", taskInstance.getId()).detail(); + if (bo_eu_faid_data==null){ + ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance("obj_ef1918ca1f9c46948f56bd5f77f4e646", "admin", pec.getUserContext().getUserName() + "失败更新待办"); + BO bo_faid = new BO(); + bo_faid.set("CHANGED","1"); + bo_faid.set("TASK_ID",taskInstance.getId()); + bo_faid.set("PROCESS_ID",pec.getProcessInstance().getId()); + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().create("BO_EU_FAID_DATA",bo_faid,processInstance,userContext); + SDK.getProcessAPI().start(processInstance); + } + } + } + + + /** + * 构造待办打开链接 + * + * @return + */ + private String buildTaskUrl(TaskInstance taskInstance, ProcessExecutionContext pec) { + // portal 地址 + String portalUrl = SDK.getPortalAPI().getPortalUrl(); +// String portalUrl = "http://localhost:8088/portal"; + // 执行人账a户 + String target = taskInstance.getTarget(); + + // 流程实例id + String bindId = pec.getProcessInstance().getId(); + // 任务实例id + String taskId = taskInstance.getId(); + StringBuilder stringBuilder = new StringBuilder(portalUrl); + try { + // final String[] encodeRsa = encodeRsa(target); + stringBuilder.append("/r/or?cmd=com.yili_form_page_open&processInstId=").append(bindId) + .append("&taskInstId=").append(taskId).append("&uid=").append(target) + .append("&oauthName=oauthLogin"); + return stringBuilder.toString(); + } catch (Exception e) { + return null; + } + } + + /** + * 更新待办状态 + * @param taskInstance + * @param pec + */ + public void updatePending(TaskInstance taskInstance, ProcessExecutionContext pec) throws IOException, SOAPException, DocumentException { + if("admin".equals(taskInstance.getTarget())) { + return; + } + XmlDatasUtil xmlDatasUtil = new XmlDatasUtil(); + xmlDatasUtil.setExternal_system_ID("LCZD"); + + xmlDatasUtil.setOther_system_to_do_ID(taskInstance.getId()); + //System.out.println("pec.getProcessInstance()>>>>>>>>"+pec.getProcessInstance()); + if(pec.getProcessInstance()!=null){ + String actionName = getActionName(taskInstance); + if (actionName.equals("传阅")){ + BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", pec.getProcessInstance().getId()).detail(); + if (bo_act_coe_publish!=null){ + xmlDatasUtil.setProcess_title(" 您有一条传阅流程【"+bo_act_coe_publish.getString("PROCESS_TITLE")+"】,点击进行处理"); + }else { + BO bo_eu_1664184390101 = SDK.getBOAPI().query("BO_EU_1664184390101", true).addQuery("BINDID=", pec.getProcessInstance().getId()).detail(); + if (bo_eu_1664184390101!=null){ + xmlDatasUtil.setProcess_title(" 您有一条传阅流程【"+pec.getProcessInstance().getTitle()+"】,点击进行处理"); + }else { + xmlDatasUtil.setProcess_title(" 您有一条传阅流程【"+pec.getProcessDef().name+"】,点击进行处理"); + } + } + }else { + BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", pec.getProcessInstance().getId()).detail(); + if (bo_act_coe_publish!=null){ + xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+bo_act_coe_publish.getString("PROCESS_TITLE")+"】,点击进行处理"); + }else { + BO bo_eu_1664184390101 = SDK.getBOAPI().query("BO_EU_1664184390101", true).addQuery("BINDID=", pec.getProcessInstance().getId()).detail(); + if (bo_eu_1664184390101!=null){ + xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+pec.getProcessInstance().getTitle()+"】,点击进行处理"); + }else { + xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+pec.getProcessDef().name+"】,点击进行处理"); + } + } + } + }else { + xmlDatasUtil.setProcess_title(" 您有一条发布流程被作废,点击进行处理"); + } + + //http://localhost:8089/portal/r/or?cmd=com.yili_form_page_open&processInstId=3505e654-9217-41cd-a31d-4971846b3219&taskInstId=8a71d75e-3ee0-43a2-a226-ecb01419319c&oauthName=oauthLogin&token=admin + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + if (portalUrl.equals("http://10.114.11.135:8088/portal")){ + portalUrl = "https://bpm.yili.com:8088/portal/"; + } + if (pec.getProcessInstance()!=null){ + xmlDatasUtil.setPcurl("https://bpm.yili.com:8088/portal"+"/r/or?cmd=com.yili_form_page_open&oauthName=oauthLogin&processInstId="+pec.getProcessInstance().getId()+"&taskInstId="+taskInstance.getId()+"&openState="+taskInstance.getState()); + xmlDatasUtil.setMobileurl("https://bpm.yili.com:8088/portal"+"/r/or?cmd=com.yili_form_page_open&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId="+pec.getProcessInstance().getId()+"&taskInstId="+taskInstance.getId()+"&openState="+taskInstance.getState()); + }else { + xmlDatasUtil.setPcurl("https://bpm.yili.com:8088/portal"+"/r/or?cmd=CLIENT_BPM_FORM_TRACK_OPEN&oauthName=oauthLogin&processInstId="+taskInstance.getProcessInstId()+"&sourceApp=prm"); + xmlDatasUtil.setMobileurl("https://bpm.yili.com:8088/portal"+"/r/or?cmd=CLIENT_BPM_FORM_TRACK_OPEN&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId="+taskInstance.getProcessInstId()+"&sourceApp=prm"); + } + + String target = taskInstance.getTarget(); + + //System.out.println("当前账户======》》》》"+target); + BO bo_eu_oa_reson = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("WORKCODE=" , target).detail(); + //System.out.println("bo>>>>>>>>>>>>>>"+bo_eu_oa_reson); + if (bo_eu_oa_reson!=null){ + xmlDatasUtil.setTo_do_login_account(bo_eu_oa_reson.getString("LOGINID")); + } + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义格式,不显示毫秒 + if (taskInstance.getBeginTime()!=null){ + String str = df.format(taskInstance.getBeginTime()); + String substring = str.substring(str.indexOf(" "), str.length()); + xmlDatasUtil.setTo_do_creation_time(substring); + xmlDatasUtil.setTo_do_completion_time(df.format(taskInstance.getBeginTime()).substring(df.format(taskInstance.getBeginTime()).indexOf(" "), df.format(taskInstance.getBeginTime()).length())); + xmlDatasUtil.setCreatedate(str.substring(0, str.indexOf(" "))); + xmlDatasUtil.setDonedate(df.format(taskInstance.getBeginTime()).substring(0, df.format(taskInstance.getBeginTime()).indexOf(" "))); + }else { + String str = df.format(new Date()); + String substring = str.substring(str.indexOf(" "), str.length()); + xmlDatasUtil.setTo_do_creation_time(substring); + xmlDatasUtil.setTo_do_completion_time(df.format(new Date()).substring(df.format(new Date()).indexOf(" "), df.format(new Date()).length())); + xmlDatasUtil.setCreatedate(str.substring(0, str.indexOf(" "))); + xmlDatasUtil.setDonedate(df.format(new Date()).substring(0, df.format(new Date()).indexOf(" "))); + } + + xmlDatasUtil.setTo_do_status("1"); + + xmlDatasUtil.setTo_do_official_type("0"); + + xmlDatasUtil.setViewtype("-2"); + + + String der = ""; + if (taskInstance.getReadTime()==null){ + der= df.format(new Date()); + }else { + der= df.format(taskInstance.getReadTime()); + } + + xmlDatasUtil.setReceivedate(der.substring(0, der.indexOf(" "))); + xmlDatasUtil.setReceivetime(der.substring(der.indexOf(" "),der.length())); + if (taskInstance!=null){ + String actionName = getActionName(taskInstance); + if (actionName.equals("确认发布")||equalsAction(GO_BACK, actionName)){ + xmlDatasUtil.setCurrentnodetype("1"); + }else{ + xmlDatasUtil.setCurrentnodetype("0"); + } + }else { + xmlDatasUtil.setCurrentnodetype("0"); + } + + + if (pec.getProcessInstance()!=null) { + xmlDatasUtil.setRequestcode(pec.getProcessInstance().getId()); + xmlDatasUtil.setCurrentnodename(SDK.getRepositoryAPI().getProcessNode(pec.getProcessInstance().getProcessDefId(),taskInstance.getActivityDefId()).getName()); + // 调用App + String sourceAppId = pec.getProcessInstance().getAppId(); + // aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.processtrends/processNodeInfoASLP"; + // 参数定义列表 + Map params = new HashMap(); + //流程实例id,必填 + params.put("processInstId", pec.getProcessInstance().getId()); + //,必填 + if (pec.getUserContext()!=null){ + params.put("sid", pec.getUserContext().getSessionId()); + }else { + String sessionId = new SSOUtil().registerClientSessionNoPassword(pec.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "127.0.0.1", LoginConst.DEVICE_PC); + params.put("sid", sessionId); + } + + AppAPI appAPI = SDK.getAppAPI(); + //流程节点数据 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params); + String username = ""; + String userid = ""; + if (ro.isOk()){ + String data = ro.getData().toString(); + JSONObject jsonObject = JSONObject.parseObject(data); + JSONArray jsonArray = JSONArray.parseArray(jsonObject.getString("processBudgetModelList")); + if (!jsonArray.isEmpty()){ + for(int i=0;i>>>>>>>>>>>"+s); + BO bo_eu_faid_data = SDK.getBOAPI().query("BO_EU_FAID_DATA").addQuery("TASK_ID=", taskInstance.getId()).detail(); + if (bo_eu_faid_data==null){ + ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance("obj_ef1918ca1f9c46948f56bd5f77f4e646", "admin", "admin" + "失败更新待办"); + BO bo_faid = new BO(); + bo_faid.set("CHANGED","2"); + bo_faid.set("TASK_ID",taskInstance.getId()); + if (pec.getProcessInstance()!=null){ + bo_faid.set("PROCESS_ID",pec.getProcessInstance().getId()); + } + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().create("BO_EU_FAID_DATA",bo_faid,processInstance,userContext); + SDK.getProcessAPI().start(processInstance); + } + } + + } + + public void readOa(String taskId) throws Exception { + HttpClientUtils httpClientUtil = new HttpClientUtils(); + String taskurl= SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "taskurl"); + + String s = httpClientUtil.readOa(taskurl, taskId); + //System.out.println("是否更新成已读了》》》》》》》》》》"+s); + } + + private String getActionName(TaskInstance taskInstance) { + if (null == taskInstance) { + return ""; + } + String actionName = ""; + Iterator iterator = null; + if (StringUtils.isNotEmpty(taskInstance.getProcessInstId())){ + iterator= ProcessAPIManager.getInstance() + .getComments(taskInstance.getProcessInstId()).iterator(); + + + TaskCommentModel next; + + while (iterator.hasNext()) { + if ((next = iterator.next()).getTaskInstId().equals(taskInstance.getId())) { + actionName = next.getActionName(); + } + } + } + return actionName; + } + + private boolean equalsAction(String[] actions, String actionName) { + for (int i = 0, n = actions.length; i < n; i++) { + if (actions[i].equals(actionName)) { + return true; + } + } + return false; + } + private String gettaskname(TaskInstance taskInstance) { + if (null == taskInstance) { + return ""; + } + final Iterator iterator = ProcessAPIManager.getInstance() + .getComments(taskInstance.getProcessInstId()).iterator(); + TaskCommentModel next; + String actionName = ""; + while (iterator.hasNext()) { + if ((next = iterator.next()).getTaskInstId().equals(taskInstance.getId())) { + actionName = next.getActionName(); + } + } + return actionName; + } + + + + + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaPendComponentLose.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaPendComponentLose.java new file mode 100644 index 00000000..d2c87ec7 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaPendComponentLose.java @@ -0,0 +1,40 @@ +package com.awspaas.user.apps.integration.oa; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.sdk.local.SDK; + +/** + * 待办推送/更新失败发起手动推送流程 + */ +public class OaPendComponentLose { + + public int careateProcess(int type,String taskId,String target) { + String ty = ""; + if(type==0) { + ty="推送"; + }else if(type==2) { + ty="更新"; + }else if(type==3) { + ty="删除"; + } + + Date date = new Date(System.currentTimeMillis()); + String userName = SDK.getORGAPI().getUser(target).getUserName(); + SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + ProcessInstance processInst = SDK.getProcessAPI().createProcessInstance("obj_a1fb5f704992495982da2a876e5e1146","admin",formatter.format(date)+"收到来自【"+userName+"】的手动待办"+ty+"任务"); + SDK.getProcessAPI().start(processInst).fetchActiveTasks().get(0); + BO bo = new BO(); + bo.set("TASKID", taskId); + bo.set("TAR", SDK.getORGAPI().getUser(target).getUserName()); + bo.set("TYPE",ty); + bo.set("TASKTITLE",SDK.getTaskAPI().getInstanceById(taskId).getTitle()); + int create = SDK.getBOAPI().create("BO_HY_SYNC_LOSE", bo, processInst, UserContext.fromUID("admin")); + return create ; + + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaPending.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaPending.java new file mode 100644 index 00000000..2498cf68 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/OaPending.java @@ -0,0 +1,233 @@ +package com.awspaas.user.apps.integration.oa; + +/** + * @author Administrator + * + */ +public class OaPending { + + private String token; + + /** + * 第三方待办标题 + */ + private String title; + + /** + * 调用类型 + */ + private String type; + /** + * 第三方待发已发已办发送人姓名 + */ + + private String sendName; + /** + * 第三方待办发送人姓名 + */ + private String senderName; + + /** + * 第三方待办发送人ID,在OA中不重要,显示发送人姓名即可,不需要转化 + */ + private String thirdSenderId; + /** + * 第三方待办接收人员ID,需要对于人员绑定表中的ID,在OA中非常重要,可以保存下此ID,并做转化 + */ + private String thirdReceiverId; + /** + * 正文类型:非必填项 + */ + private String contentType; + /** + * 正文内容:非必填项 + */ + private String content; + /** + * 待办PC端连接地址 + */ + private String url; + /** + * 待办移动端H5连接地址 + */ + private String h5Url; + /** + * 移动端app打开参数 + */ + private String appParam; + /** + * 第三方待办ID + */ + private String taskId; + /** + * 业务类型,非必填 + */ + private String classify; + /** + * 创建时间 + */ + protected String creationDate; + /** + * 状态:0:未办理;1:已办理 + */ + private String state; + /** + * 子状态:0/1/2/3同意已办/不同意已办/取消/驳回 + */ + private String subState; + /** + * 注册应用ID + */ + private Long registerId; + + private String noneBindingSender; + + private String noneBindingReceiver; + + /** + * 注册系统编码 + */ + private String registerCode; + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + public String getSendName() { + return sendName; + } + + public void setSendName(String sendName) { + this.sendName = sendName; + } + + public Long getRegisterId() { + return registerId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getNoneBindingSender() { + return noneBindingSender; + } + + + public void setNoneBindingSender(String noneBindingSender) { + this.noneBindingSender = noneBindingSender; + } + + + public String getNoneBindingReceiver() { + return noneBindingReceiver; + } + + + public void setNoneBindingReceiver(String noneBindingReceiver) { + this.noneBindingReceiver = noneBindingReceiver; + } + + public void setRegisterId(Long registerId) { + this.registerId = registerId; + } + public String getTitle() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + + public String getSenderName() { + return senderName; + } + public void setSenderName(String senderName) { + this.senderName = senderName; + } + public String getThirdSenderId() { + return thirdSenderId; + } + public void setThirdSenderId(String thirdSenderId) { + this.thirdSenderId = thirdSenderId; + } + public String getThirdReceiverId() { + return thirdReceiverId; + } + public void setThirdReceiverId(String thirdReceiverId) { + this.thirdReceiverId = thirdReceiverId; + } + public String getContentType() { + return contentType; + } + public void setContentType(String contentType) { + this.contentType = contentType; + } + public String getContent() { + return content; + } + public void setContent(String content) { + this.content = content; + } + public String getUrl() { + return url; + } + public void setUrl(String url) { + this.url = url; + } + public String getH5Url() { + return h5Url; + } + public void setH5Url(String h5Url) { + this.h5Url = h5Url; + } + public String getAppParam() { + return appParam; + } + public void setAppParam(String appParam) { + this.appParam = appParam; + } + public String getTaskId() { + return taskId; + } + public void setTaskId(String taskId) { + this.taskId = taskId; + } + public String getCreationDate() { + return creationDate; + } + public void setCreationDate(String creationDate) { + this.creationDate = creationDate; + } + public String getState() { + return state; + } + public void setState(String state) { + this.state = state; + } + public String getSubState() { + return subState; + } + public void setSubState(String subState) { + this.subState = subState; + } + + public String getRegisterCode() { + return registerCode; + } + public void setRegisterCode(String registerCode) { + this.registerCode = registerCode; + } + public String getClassify() { + return classify; + } + public void setClassify(String classify) { + this.classify = classify; + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/TaskListener.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/TaskListener.java new file mode 100644 index 00000000..0df5ec53 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oa/TaskListener.java @@ -0,0 +1,464 @@ +package com.awspaas.user.apps.integration.oa; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.xml.soap.SOAPException; + +import org.dom4j.DocumentException; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import com.actionsoft.bpms.bpmn.constant.ProcessRuntimeConst; +import com.actionsoft.bpms.bpmn.constant.PublicEventConst; +import com.actionsoft.bpms.bpmn.engine.ProcessAPIManager; +import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext; +import com.actionsoft.bpms.bpmn.engine.listener.ProcessPubicListener; +import com.actionsoft.bpms.bpmn.engine.model.def.ProcessDefinition; +import com.actionsoft.bpms.bpmn.engine.model.run.TaskCommentModel; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.HistoryTaskInstance; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance; +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.bpms.util.UtilString; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.LogAPI; +import com.actionsoft.sdk.local.api.Logger; +import com.actionsoft.sdk.local.api.TaskAPI; + +/** + * @author lihongyu + * + */ +public class TaskListener extends ProcessPubicListener { + + private Logger logger = LogAPI.getLogger(TaskListener.class); + + private String rootScopeId = "00000000-0000-0000-0000-000000000000"; + private String sendEnable = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "sendEnable"); + private String notPushReadyTask = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "notPushReadyTask"); + private String[] AGREE = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "AGREE").split("\\|"); + private String[] GO_BACK = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "GO_BACK").split("\\|"); + private String[] DESI_BACK = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "DESI_BACK").split("\\|"); + private String[] TE_SHI_TE_BAN = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "TE_SHI_TE_BAN") + .split("\\|"); + private String[] TERMINATION = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "TERMINATION").split("\\|"); + private String[] ABOLITION = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "ABOLITION").split("\\|"); + private String[] TRANSFER = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "TRANSFER").split("\\|"); + private String[] GET_BACK = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "GET_BACK").split("\\|"); + private String[] GET_BACKCC = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "GET_BACKCC").split("\\|"); + private String[] GET_BACKD = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "GET_BACK").split("\\|"); + private TaskAPI taskAPI = SDK.getTaskAPI(); + private static Set strings = new HashSet<>(); + private final String close = "2"; + // 通知类型 9 系统通知任务【不影响流程推进】 2 只读传阅任务【不影响流程推进】 + private Integer noticeState = 9; + private Integer tranReadState = 2; + + /** + * 所有人工任务相关行为发生时被触发(见PublicEventConst常量) ProcessPubicListener + * + * @param eventName 事件名称,见PublicEventConst常量 + * @param taskInstance 任务实例对象 + * @param pec 流程引擎提供给监听器的上下文对象 + * @see PublicEventConst + */ + @Override + public void call(String eventName, TaskInstance taskInstance, ProcessExecutionContext pec) { + + System.out.println("eventName>>>>>>>>>>"+eventName); + /** + * 手动作废 增加 开始节点作废删除更新OA待办问题 + * 后台管理员删除流程 process_before_delete 时候删除 更新OA为已办 + */ + if (close.equals(sendEnable)) { + return; + } + OaPendComponent component = new OaPendComponent(); + if (pec!=null){ + if (pec.getProcessInstance()!=null){ + if (eventName.equals("PROCESS_BEFORE_DELETE")&&UtilString.isNotEmpty(pec.getProcessInstance().getParentTaskInstId())){ + try { + /** + * 这是发起人作废的时候,作废的流程实例,需要更新OA数据 + */ + String irt = pec.getProcessInstance().getStartTaskInstId(); + TaskInstance instanceById = SDK.getTaskAPI().getInstanceById(irt); + component.updatePending(instanceById,pec); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + //System.out.println("任务数据>>>>>>>>>>>>>>>>>>>>"+taskInstance); + /*if (eventName.equals(PublicEventConst.PROCESS_REACTIVATE)){ + System.out.println("复活之后的任务数据>>>>>>>>>>>>>"+pec.getProcessInstance().getStartTaskInstId()); + }*/ + + String appId = ""; + /** + * 任务创建后并且是被重新激活的数据需要发送待办数据 + */ + //查询下之前的审批数据是否还有重新激活这几个字样,如果有不发送 + if(PublicEventConst.TASK_CREATE.equals(eventName)&&taskInstance.getTitle().contains("(重新激活)")) { + String sql = "select * from WFC_TASK where PROCESSINSTID = '"+pec.getProcessInstance().getId()+"' and TASKSTATE = '1' AND PARENTTASKINSTID = '00000000-0000-0000-0000-000000000000'"; + RowMap map = DBSql.getMap(sql); + System.out.println("重新激活后的数据>>>>>>>>>>>>>"+map); + if (map!=null){ + ProcessDefinition processDef = pec.getProcessDef(); + if(null!=processDef) { + appId = processDef.getAppId(); + try { + // System.out.println("重新激活之后的数据?>>>>>>>>>>>>>>"+eventName+taskInstance.getTitle()); + component.sendOaPending(taskInstance,pec); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + + if (taskInstance == null) { + return; + } + String actionName = ""; + if (!UtilString.isEmpty(taskInstance.getId())) { + actionName = getActionName(taskInstance); + + } + + System.out.println("按钮名称是>>>>>>>>>>>"+actionName); +/** + * 任务删除,需要更新之前说有的历史节点的任务信息 + */ + if (UtilString.isEmpty(taskInstance.getId()) && PublicEventConst.TASK_DELETE.equals(eventName)) { + + Map parameters2 = pec.getParameters(); + final Object taskLists = parameters2.get("taskList"); + if (null != taskLists) { + List list = (List) taskLists; + list.forEach(h -> { + // //logger.info("调用OA删除任务接口:taskInstanceId:" + h.getId()); + try { + component.readOa(h.getId()); + } catch (Exception e) { + e.printStackTrace(); + } + //OaDeleteComponent(h.getId()); + return; + }); + } +/** + * 任务被作废\收回沟通任务\传阅需要更新相关的待办 + */ + } else if (PublicEventConst.TASK_DELETE.equals(eventName) || taskInstance.getControlState() == "delete") { + if (actionName == ""||actionName.equals("作废")||actionName.equals("收回沟通任务")||(actionName.equals("传阅")&& PublicEventConst.TASK_READ.equals(eventName))||actionName.equals("激活")) { + try { + System.out.println("按钮名称的相关数据>>>>>>>>>>>"+actionName); + component.readOa(taskInstance.getId()); + } catch (Exception e) { + e.printStackTrace(); + } + //OaDeleteComponent(taskInstance.getId()); + } + } + +/** + * 任务完成后需要更新任务数据 + */ + if (PublicEventConst.TASK_COMPLETE.equals(eventName)){ + ProcessDefinition processDef = pec.getProcessDef(); + if(null!=processDef) { + appId = processDef.getAppId(); + try { + component.updatePending(taskInstance,pec); + } catch (Exception e) { + e.printStackTrace(); + } + } + } +/** + * 任务创建后事件,发送OA待办 + */ + if (PublicEventConst.TASK_CREATE.equals(eventName) && (!taskInstance.getParentTaskInstId().equals(rootScopeId))) { + if (eventName.equals(PublicEventConst.PROCESS_REACTIVATE)){ + taskInstance = pec.getTaskInstance(); + // System.out.println("复活之后的任务数据>>>>>>>>>>>>>>>>>"+taskInstance); + } + if (StringUtils.isEmpty(taskInstance.getTarget())) { + return; + } + if (taskInstance.getState() == noticeState) { + try { + component.sendOaPending(taskInstance, pec); + } catch (Exception e) { + e.printStackTrace(); + } + return; + } + + // 根据配置表修改任务标题 by yujh start +// TaskUtil taskUtil =new TaskUtil(); +// String newTitle = taskUtil.updateTaskTitleByBase(pec.getUserContext(), taskInstance.getId(), taskInstance.getActivityDefId(), taskInstance.getTitle()); +// taskInstance = SDK.getTaskAPI().getTaskInstance(taskInstance.getId()); + // 根据配置表修改任务标题 by yujh end + + try { + component.sendOaPending(taskInstance, pec); + } catch (Exception e) { + e.printStackTrace(); + } + // //logger.info("创建OA待办,taskInstanceId:" + taskInstance.getId()); +/** + * 任务已读需要更新OA待办 + */ + } else if (PublicEventConst.TASK_READ.equals(eventName)) { + if (taskInstance.getState() == tranReadState) { + + // //logger.info("更新知会待办,taskInstanceId:" + taskInstance.getId()); + try { + component.updatePending(taskInstance,pec); + } catch (Exception e) { + e.printStackTrace(); + } + } + /** + * 任务完成后是,并且父任务id不是0000,并且是同意,更新OA接口 + */ + } else if (PublicEventConst.TASK_COMPLETE.equals(eventName)) { + if (!taskInstance.getParentTaskInstId().equals(rootScopeId)||notPushReadyTask.contains(appId)) { + // final String actionName = getActionName(taskInstance); + if (equalsAction(AGREE, actionName)) { + try { + component.updatePending(taskInstance,pec); + } catch (Exception e) { + e.printStackTrace(); + } + // //logger.info("更新OA待办:" + "同意"); + } else if (equalsAction(GO_BACK, actionName)) { + try { + component.updatePending(taskInstance,pec); + } catch (Exception e) { + e.printStackTrace(); + } + //logger.info("更新OA待办:" + "回退"); + } else if (equalsAction(DESI_BACK, actionName)) { + try { + component.updatePending(taskInstance,pec); + } catch (Exception e) { + e.printStackTrace(); + } + //logger.info("更新OA待办:" + "指定回退"); + } else if (equalsAction(TE_SHI_TE_BAN, actionName)) { + try { + component.updatePending(taskInstance,pec); + } catch (Exception e) { + e.printStackTrace(); + } + //logger.info("更新OA待办:" + "特事特办"); + } else if (equalsAction(TERMINATION, actionName)) { + try { + component.updatePending(taskInstance,pec); + } catch (Exception e) { + e.printStackTrace(); + } + //logger.info("更新OA待办:" + "终止"); + } else if (equalsAction(TRANSFER, actionName)) { + try { + component.updatePending(taskInstance,pec); + } catch (Exception e) { + e.printStackTrace(); + } + //logger.info("更新OA待办:" + "转办"); + } else { + try { + component.readOa(taskInstance.getId()); + } catch (Exception e) { + e.printStackTrace(); + } + //logger.info("更新OA待办:未定义的操作:" + actionName + ",按同意已办处理"); + } + } + + } else if (PublicEventConst.TASK_TRANSFER.equals(eventName)) { + + // 移交任务 需要更新之前那个人的待办为已办,然后添加当前人的待办 + } else if (PublicEventConst.TASK_DELEGATE.equals(eventName)) { + + final TaskCommentModel comment = getCommentCreateUserId(taskInstance.getProcessInstId(), + taskInstance.getId()); + if (null != comment) { + //logger.info("任务转办"); + taskAPI.createUserTaskInstance(pec.getProcessInstance().getId(), taskInstance.getId(), + comment.getCreateUser(), taskInstance.getActivityDefId(), taskInstance.getTarget(), + "转办:" + pec.getProcessInstance().getTitle()); + taskAPI.completeTask(taskInstance.getId(), comment.getCreateUser(), false); + } + + } else if (UtilString.isNotEmpty(taskInstance.getId()) + && !taskInstance.getParentTaskInstId().equals(rootScopeId)) { + // 撤销流程 + if (UtilString.isEmpty(taskInstance.getId())) { + Map parameters = pec.getParameters(); + if (!CollectionUtils.isEmpty(parameters)) { + // 这个list即是撤销时全部删除的任务实例 + final Object taskList = parameters.get("taskList"); + if (null != taskList) { + List list = (List) taskList; + // OaPendComponent component = new OaPendComponent(); + list.forEach(h -> { + if (!h.getParentTaskInstId().equals(rootScopeId)) { + if (ProcessRuntimeConst.INST_STATE_ACTIVE.equals(h.getControlState()) + && noticeState != h.getState()) { + //logger.info("更新OA待办:取消,taskInstanceId:" + h.getId()); + try { + component.updatePending(h,pec); + } catch (Exception e) { + e.printStackTrace(); + } + + } + } + }); + } + } + } else if (UtilString.isNotEmpty(taskInstance.getId())) { + // final String actionName = getActionName(taskInstance); + if (equalsAction(TE_SHI_TE_BAN, actionName) || equalsAction(TRANSFER, actionName)) { + return; + } + if (equalsAction(ABOLITION, actionName)) { + /* + * //logger.info("更新OA待办:作废,taskInstanceId:" + taskInstance.getId()); + * OaPendComponent component = new OaPendComponent(); + * component.updatePending(taskInstance.getId(), "1", "2"); + * + */ + //logger.info("调用OA删除任务接口:taskInstanceId:" + taskInstance.getId()); + try { + component.readOa(taskInstance.getId()); + } catch (Exception e) { + e.printStackTrace(); + } + return; + } + + if (equalsAction(GET_BACK, actionName) || equalsAction(GET_BACKD, actionName)||equalsAction(GET_BACKCC, actionName)) { + //logger.info("更新OA待办:收回,taskInstanceId:" + taskInstance.getParentTaskInstId()); + + try { + component.updatePending(taskInstance,pec); + } catch (Exception e) { + e.printStackTrace(); + } + return; + } + /* + * if (null == pec.getUserContext() || + * taskInstance.getTarget().equals(pec.getUserContext().getUID())) { return; } + */ + if (strings.contains(taskInstance.getId())) { + strings.remove(taskInstance.getId()); + return; + } else { + strings.add(taskInstance.getId()); + } + + } +/** + * 任务完成,需要更新oa待办数据 + */ + } else if (PublicEventConst.PROCESS_COMPLETE.equals(eventName)) { + try { + component.updatePending(taskInstance,pec); + } catch (IOException e) { + e.printStackTrace(); + } catch (SOAPException e) { + e.printStackTrace(); + } catch (DocumentException e) { + e.printStackTrace(); + } + /** + * 任务取消,更新OA接口 + */ + } else if (PublicEventConst.TASK_CANCEL.equals(eventName)) { + //logger.info("调用OA删除任务接口:taskInstanceId:" + taskInstance.getId()); + try { + component.readOa(taskInstance.getId()); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + private void OaDeleteComponent(String taskId) { + OaDeleteComponent component = new OaDeleteComponent(); + component.deleteOaPending(taskId); + } + + /** + * 获取某个审批步骤的 数据 + * + * @param processInstId + * @param taskInstanceId + * @return + */ + private TaskCommentModel getCommentCreateUserId(String processInstId, String taskInstanceId) { + final Iterator iterator = ProcessAPIManager.getInstance().getComments(processInstId) + .iterator(); + TaskCommentModel next; + while (iterator.hasNext()) { + if ((next = iterator.next()).getTaskInstId().equals(taskInstanceId)) { + return next; + } + } + return null; + } + + private boolean equalsAction(String[] actions, String actionName) { + for (int i = 0, n = actions.length; i < n; i++) { + if (actions[i].equals(actionName)) { + return true; + } + } + return false; + } + + private String getActionName(TaskInstance taskInstance) { + if (null == taskInstance) { + return ""; + } + final Iterator iterator = ProcessAPIManager.getInstance() + .getComments(taskInstance.getProcessInstId()).iterator(); + TaskCommentModel next; + String actionName = ""; + while (iterator.hasNext()) { + if ((next = iterator.next()).getTaskInstId().equals(taskInstance.getId())) { + actionName = next.getActionName(); + } + } + return actionName; + } + + @Override + public String getVersion() { + return "0.0.2"; + } + + @Override + public String getProvider() { + return "伊利集团信息管理部"; + } + + @Override + public String getDescription() { + return "流程待办推送"; + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/App.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/App.java new file mode 100644 index 00000000..2047c021 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/App.java @@ -0,0 +1,71 @@ +package com.awspaas.user.apps.integration.oauth; + +import java.io.UnsupportedEncodingException; +import java.util.HashMap; +import org.apache.commons.codec.binary.Base64; + + +public class App { + // Basic testClient:qwertyuio0987654rfg :: Basic ??? + static String clientId = "prcmgr"; + static String clientSecret = "Mvo634yOQwYAfMfB"; + + // http://cs.idm.yili.com:7777/ms_oauth/oauth2/endpoints/oauthservice/tokens?redirect_uri=http://192.168.88.100:8080/ecs-console/&grant_type=authorization_code&code= + // 获取授权Token接口(authorization_code模式) + public String getTokens(String redirect_uri, String code) { + String tokenJson = ""; + + + String url = "https://idm.yili.com:7777/ms_oauth/oauth2/endpoints/oauthservice/tokens?" + "redirect_uri=" + + redirect_uri + "&grant_type=authorization_code&code=" + code; + + String authoStr = geAuthorization(clientId, clientSecret); + HashMap HeaderMap = new HashMap(); + //HeaderMap.put("Content-Type", "application/x-www-form-urlencoded"); + HeaderMap.put("grant_type","authorization_code"); + HeaderMap.put("Authorization", authoStr); + //HeaderMap.put("accept", "*/*"); + //HeaderMap.put("connection", "Keep-Alive"); + System.out.println("url地址为=============="+url); + System.out.println("参数为=============="+HeaderMap); + // do request + + + tokenJson = HttpJavaUtil.doPost(url, "", HeaderMap); + System.out.println(tokenJson); + return tokenJson; + + } + + public String getUserInfo(String token) { + String userInfoJson = ""; + String url = "https://idm.yili.com:7777/ms_oauth/resources/userprofile/me"; + + String authoStr = token; + HashMap HeaderMap = new HashMap(); + HeaderMap.put("Content-Type", "application/x-www-form-urlencoded"); + HeaderMap.put("Authorization", authoStr); + HeaderMap.put("accept", "*/*"); + HeaderMap.put("connection", "Keep-Alive"); + + // do request get + userInfoJson = HttpJavaUtil.doGet(url, HeaderMap); + System.out.println(userInfoJson); + return userInfoJson; + } + + public String geAuthorization(String clientId, String clientSecret) { + try { + byte[] key = (clientId + ":" + clientSecret).getBytes("utf-8"); + String cc = new String(Base64.encodeBase64(key), "utf-8"); + // String cc = new String(java.util.Base64.getEncoder().encode(key), "utf-8"); + return "Basic " + cc; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + return ""; + } + } + + + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/HttpJavaUtil.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/HttpJavaUtil.java new file mode 100644 index 00000000..48daeef3 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/HttpJavaUtil.java @@ -0,0 +1,336 @@ +package com.awspaas.user.apps.integration.oauth; + +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.nio.charset.Charset; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import java.security.SecureRandom; +import java.security.cert.X509Certificate; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; + +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import org.apache.http.HttpEntity; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; + +public class HttpJavaUtil { + + public static final String DEF_CHATSET = "UTF-8"; + public static final int DEF_CONN_TIMEOUT = 30000; // 是建立连接的超时时间 + public static final int DEF_READ_TIMEOUT = 30000; // 是传递数据的超时时间 + + public static String doGet(String httpUrl, Map HeaderMap) { + HttpURLConnection connection = null; + InputStream is = null; + BufferedReader br = null; + String result = null;// 返回结果字符串 + System.out.println(httpUrl); + try { + // 创建远程url连接对象 + URL url = new URL(httpUrl); + try { + // trustAllHttpsCertificates(); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("【异常】doGet-https-->" + e.getMessage()); + } + trustAllHttpsCertificates(); + connection = (HttpURLConnection) url.openConnection(); + + // 设置header + for (String key : HeaderMap.keySet()) { + connection.setRequestProperty(key, HeaderMap.get(key).toString()); + } + + // 设置连接方式:get + connection.setRequestMethod("GET"); + // 设置连接主机服务器的超时时间:15000毫秒 + connection.setConnectTimeout(15000); + // 设置读取远程返回的数据时间:60000毫秒 + connection.setReadTimeout(60000); + // 发送请求 + connection.connect(); + // 通过connection连接,获取输入流 + if (connection.getResponseCode() == 200) { + is = connection.getInputStream(); + // 封装输入流is,并指定字符集 + br = new BufferedReader(new InputStreamReader(is, "UTF-8")); + // 存放数据 + StringBuffer sbf = new StringBuffer(); + String tempX = ""; + while ((tempX = br.readLine()) != null) { + sbf.append(tempX); + sbf.append("\r\n"); + } + result = sbf.toString(); + System.out.println(result); + } else { + String line; + String message = ""; + br = new BufferedReader(new InputStreamReader(connection.getErrorStream())); + StringBuffer buff = new StringBuffer(); + while ((line = br.readLine()) != null) { + buff.append(line + "\n"); + message += line; + } + message = buff.toString(); + System.out.println(message); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + // 关闭资源 + if (null != br) { + try { + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != is) { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + connection.disconnect();// 关闭远程连接 + } + return result; + } + + public static String doPost(String httpUrl, String BodyParam, Map HeaderMap) { + HttpURLConnection connection = null; + InputStream is = null; + OutputStream os = null; + BufferedReader br = null; + String result = null; + try { + URL url = new URL(httpUrl); + try { + // trustAllHttpsCertificates(); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("【异常】doPost-https-->" + e.getMessage()); + } + connection = (HttpURLConnection) url.openConnection(); + + // 设置header + for (String key : HeaderMap.keySet()) { + connection.setRequestProperty(key, HeaderMap.get(key).toString()); + } + connection.setRequestMethod("POST"); + connection.setConnectTimeout(15000); + connection.setReadTimeout(60000); + connection.setDoOutput(true); + connection.setDoInput(true); + + os = connection.getOutputStream(); + os.write(BodyParam.getBytes()); + int resCode = connection.getResponseCode(); + + is = connection.getInputStream(); + br = new BufferedReader(new InputStreamReader(is, "UTF-8")); + StringBuffer sbf = new StringBuffer(); + String temp = null; + while ((temp = br.readLine()) != null) { + sbf.append(temp); + sbf.append("\r\n"); + } + result = sbf.toString(); + } catch (Exception e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != os) { + try { + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != is) { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + connection.disconnect(); + } + return result; + } + + + + //使用SOAP1.1发送消息 + public static String doPostSoap(String postUrl, String soapXml, Map HeaderMap) { + String retStr = ""; + // 创建HttpClientBuilder + HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); + // HttpClient + CloseableHttpClient closeableHttpClient = httpClientBuilder.build(); + HttpPost httpPost = new HttpPost(postUrl); + // 设置请求和传输超时时间 + RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(6000) + .setConnectTimeout(6000).build(); + httpPost.setConfig(requestConfig); + try { + for (String key : HeaderMap.keySet()) { + httpPost.setHeader(key, HeaderMap.get(key).toString()); + } + + StringEntity data = new StringEntity(soapXml, Charset.forName("UTF-8")); + httpPost.setEntity(data); + CloseableHttpResponse response = closeableHttpClient.execute(httpPost); + HttpEntity httpEntity = response.getEntity(); + if (httpEntity != null) { + // 打印响应内容 + retStr = EntityUtils.toString(httpEntity, "UTF-8"); + System.out.println("restsfagfasfas=======>>>>>>>>>>"+retStr); + } + // 释放资源 + closeableHttpClient.close(); + } catch (Exception e) { + e.printStackTrace(); + } + return retStr; + } + + + /** + * 信任全部https证书 + */ + private static void trustAllHttpsCertificates() throws Exception { + HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { + public boolean verify(String str, SSLSession session) { + return true; + } + }); + javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1]; + javax.net.ssl.TrustManager tm = new miTM(); + trustAllCerts[0] = tm; + javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL"); + sc.init(null, trustAllCerts, null); + javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); + } + + static class miTM implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager { + + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + + public boolean isServerTrusted(java.security.cert.X509Certificate[] certs) { + return true; + } + + public boolean isClientTrusted(java.security.cert.X509Certificate[] certs) { + return true; + } + + public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) + throws java.security.cert.CertificateException { + return; + } + + public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) + throws java.security.cert.CertificateException { + return; + } + } + + public static String sendPost(String url, String param, Map HeaderMap) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection(); + + // 设置header + for (String key : HeaderMap.keySet()) { + conn.setRequestProperty(key, HeaderMap.get(key).toString()); + } + + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + conn.setConnectTimeout(5000000); + conn.setReadTimeout(5000000); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输出流、输入流 + finally { + try { + if (out != null) { + out.close(); + } + if (in != null) { + in.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } + return result; + } + + + + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/OauthLogin.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/OauthLogin.java new file mode 100644 index 00000000..0666f299 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/OauthLogin.java @@ -0,0 +1,258 @@ +package com.awspaas.user.apps.integration.oauth; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.commons.oauth.AbstractOauth; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.server.RequestParams; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.bpms.util.UtilString; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.LogAPI; +import com.actionsoft.sdk.local.api.Logger; +import com.actionsoft.sdk.local.api.ORGAPI; +import com.actionsoft.sdk.service.model.UserModel; +import com.alibaba.fastjson.JSONObject; +import com.yili.wsclient.ClientService; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang.StringUtils; + +/** + * OA系统 跳转登陆PAl + * + * @author lihy + */ + +public class OauthLogin extends AbstractOauth { + private Logger logger = LogAPI.getLogger(OauthLogin.class); + + static String clientId = "testClient"; + static String clientSecret = "1234567890"; + /** + * 这个方法代表是否有登录授权页,返回的值取决于三方系统提供的 SSO 认证方式。一类认 证方式如 Oauth2.0 + * 认证,需要先跳转到三方系统的登录授权页面,授权成功后再跳转到调 用方指定的页面,这类认证方式下,hasOauthPage()方法需要返回 true。 + * 另外一类认证时不 需要跳转到登录授权页, 会直接传过来 ticket 或者 token 参数, hasOauthPage()方法需要返 回 false。 + * + * @return + */ + @Override + public boolean hasOauthPage() { + return false; + } + + /** + * 如果 hasOauthPage()方法返回的值是 false, 返回 null 即可。 如果 hasOauthPage()方法返回 的值是 + * true,则此处返回三方系统的登录授权页地址。 + * @param requestParams + * @return + */ + @Override + public String getOauthPage(RequestParams requestParams) { + return null; + } + @Override + public String validate(RequestParams params) throws IOException { + BO bo = new BO(); + String id = params.get("id"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + long begintime = System.currentTimeMillis(); + bo.set("BEGIN_TIME",sdf.format(new Date())); + String userid = ""; + long login_end_time = 0L; + if (StringUtils.isNotEmpty(params.get("casaccount"))){ + BO detail = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("LOGINID=", params.get("casaccount")).detail(); + String workcode = ""; + if (detail!=null){ + workcode= detail.getString("WORKCODE"); + }else { + workcode= params.get("casaccount"); + } + + login_end_time = System.currentTimeMillis(); + bo.set("END_TIME",login_end_time); + bo.set("USER_ID",params.get("casaccount")); + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().createDataBO("BO_EU_OA_LOGIN",bo,userContext); + if (("5af46cd5-a1bc-4125-a144-86d1a199eec1").equals(id)){ + try { + setUserLog(params.get("casaccount"),"1"); + }catch (Exception e){ + + } + } + return workcode; + + } + + if (StringUtils.isNotEmpty(params.get("usercode"))){ + BO detail = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("LOGINID=", params.get("usercode")).detail(); + String workcode = ""; + if (detail!=null){ + workcode = detail.getString("WORKCODE"); + }else { + workcode = params.get("usercode"); + } + login_end_time = System.currentTimeMillis(); + bo.set("END_TIME",sdf.format(new Date())); + bo.set("USER_ID",params.get("usercode")); + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().createDataBO("BO_EU_OA_LOGIN",bo,userContext); + if (("5af46cd5-a1bc-4125-a144-86d1a199eec1").equals(id)){ + try { + setUserLog(params.get("usercode"),"1"); + }catch (Exception e){ + + } + } + return workcode; + } + + + logger.info("单点登录验证---------"+params); + try { + + long loginbegintime = System.currentTimeMillis(); + bo.set("LOGIN_BEGIN_TIME",sdf.format(new Date())); + String redirect_uri = params.get("code"); + + + if(StringUtils.isEmpty(redirect_uri)){ + logger.error("跳转地址为空,请重新输入"); + return null; + } + + + App app = new App(); + String tokens = app.getTokens("http://10.114.11.135:8088/portal/yili.html", redirect_uri); + if(StringUtils.isEmpty(tokens)){ + logger.error("获取token为空,请重新输入登录信息获取code"); + return null; + }else { + JSONObject jsonObjects = JSONObject.parseObject(tokens); + String access_token = jsonObjects.getString("access_token"); + String userInfo = app.getUserInfo(access_token); + + if (StringUtils.isNotEmpty(userInfo)){ + JSONObject json = JSONObject.parseObject(userInfo); + //System.out.println("json-=====>>>>"+json); + if (StringUtils.isNotEmpty(json.getString("employeenumber"))){ + //System.out.println("userid》》》》》》》》》》"+json.getString("employeenumber")); + if (("5af46cd5-a1bc-4125-a144-86d1a199eec1").equals(id)){ + try { + setUserLog(json.getString("employeenumber"),"1"); + }catch (Exception e){ + + } + } + + userid = json.getString("employeenumber"); + login_end_time = System.currentTimeMillis(); + bo.set("END_TIME",sdf.format(new Date())); + bo.set("SCENDTIME",(login_end_time-loginbegintime)); + bo.set("LOGIN_END_TIME",sdf.format(new Date())); + bo.set("USER_ID",userid); + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().createDataBO("BO_EU_OA_LOGIN",bo,userContext); + + BO detail = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("LOGINID=", json.getString("employeenumber")).detail(); + String workcode = ""; + if(detail!=null){ + workcode = detail.getString("WORKCODE"); + }else { + workcode = json.getString("employeenumber"); + } + + return workcode; + } + } + + } + + + + } catch (Exception e) { + logger.error("统一身份认证失败!", e); + } + return null; + } + + + + public long getCookieTime(UserModel user) { + //System.out.println("session时间>>>>>>>>>>"+user.getSessionTime()); +//下面的值代表与 AWS PaaS 会话过期时间一致, +//因平台会话过期时间以分钟计,所以需要乘以 60 + return 0; + } + + /** + * 统一身份认证接口 + * @param1 webserviceUrl 身份认证接口地址 + * @param2 casaccount 登录账号 OA账号 + * @param3 appaccount 应用系统登录账号 + * @param4 appid 应用系统id + * @param5 validcode 验证码 + * @return true/false + */ + public static String getToken(String casaccount,String appaccount,String appid,String validcode) { + //身份认证接口地址 + String webserviceUrl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "webserviceUrl"); + String checkLogin = ClientService.checkLogin(webserviceUrl,casaccount,appaccount,appid,validcode); + return checkLogin ; + } + + + + public static String geAuthorization(String clientId, String clientSecret) { + try { + byte[] key = (clientId + ":" + clientSecret).getBytes("utf-8"); + String cc = new String(Base64.encodeBase64(key), "utf-8"); + // String cc = new String(java.util.Base64.getEncoder().encode(key), "utf-8"); + return "Basic " + cc; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + return ""; + } + } + + + + /** + * 用户登录日志 + * @param userid + * @param logType + */ + public void setUserLog(String userid,String logType) { + System.err.println("用户登录记录存入日志========>"+userid+"_类型:"+logType); + if (UtilString.isNotEmpty(userid)) { + String logTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + BO bo = new BO(); + /*String slq = "SELECT ID,LOGINCOUNTS FROM BO_EU_USER_LOGIN_LOG WHERE LOGINUSERNAME = '"+userid+"' AND LOGINTIME = '"+logTime+"'"; + List maps = DBSql.getMaps(slq); + if(maps.size()!=0) { + bo = SDK.getBOAPI().get("BO_EU_USER_LOGIN_LOG", maps.get(0).getString("ID")); + bo.set("LOGINCOUNTS", maps.get(0).getInt("LOGINCOUNTS")+1); + SDK.getBOAPI().update("BO_EU_USER_LOGIN_LOG", bo); + }else {*/ + ORGAPI orgapi = SDK.getORGAPI(); + com.actionsoft.bpms.org.model.UserModel user = orgapi.getUser(userid); + DepartmentModel departmentByUser = orgapi.getDepartmentByUser(userid); + bo.set("LOGINUSERNAME", userid); + bo.set("USERBUNAME",user.getExt4()); + bo.set("USERPOST",user.getPositionName()); + bo.set("USERDEPTNAME", departmentByUser.getPathNameOfCache()); + bo.set("LOGINTIME", logTime); + bo.set("LOGINCOUNTS", 1); + bo.set("LOGTYPE", Integer.valueOf(logType)); + + SDK.getBOAPI().createDataBO("BO_EU_USER_LOGIN_LOG", bo, UserContext.fromUID("admin")); + //} + } + } + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/ProcessOathLogin.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/ProcessOathLogin.java new file mode 100644 index 00000000..ee829037 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/ProcessOathLogin.java @@ -0,0 +1,181 @@ +package com.awspaas.user.apps.integration.oauth; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; + +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.commons.oauth.AbstractOauth; +import com.actionsoft.bpms.server.RequestParams; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.LogAPI; +import com.actionsoft.sdk.local.api.Logger; +import com.actionsoft.sdk.service.model.UserModel; +import com.alibaba.fastjson.JSONObject; +import com.yili.wsclient.ClientService; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang.StringUtils; + +/** + * OA系统 跳转登陆PAl + * + * @author lihy + */ + +public class ProcessOathLogin extends AbstractOauth { + private Logger logger = LogAPI.getLogger(OauthLogin.class); + + static String clientId = "testClient"; + static String clientSecret = "1234567890"; + /** + * 这个方法代表是否有登录授权页,返回的值取决于三方系统提供的 SSO 认证方式。一类认 证方式如 Oauth2.0 + * 认证,需要先跳转到三方系统的登录授权页面,授权成功后再跳转到调 用方指定的页面,这类认证方式下,hasOauthPage()方法需要返回 true。 + * 另外一类认证时不 需要跳转到登录授权页, 会直接传过来 ticket 或者 token 参数, hasOauthPage()方法需要返 回 false。 + * + * @return + */ + @Override + public boolean hasOauthPage() { + return false; + } + + /** + * 如果 hasOauthPage()方法返回的值是 false, 返回 null 即可。 如果 hasOauthPage()方法返回 的值是 + * true,则此处返回三方系统的登录授权页地址。 + * @param requestParams + * @return + */ + @Override + public String getOauthPage(RequestParams requestParams) { + return null; + } + @Override + public String validate(RequestParams params) throws IOException { + BO bo = new BO(); + long begintime = System.currentTimeMillis(); + bo.set("BEGIN_TIME",begintime); + String userid = ""; + long login_end_time = 0L; + if (StringUtils.isNotEmpty(params.get("casaccount"))){ + BO detail = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("LOGINID=", params.get("casaccount")).detail(); + String workcode = detail.getString("WORKCODE"); + if (workcode.length()!=8){ + login_end_time = System.currentTimeMillis(); + bo.set("END_TIME",login_end_time); + bo.set("USER_ID","00"+workcode); + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().createDataBO("BO_EU_OA_LOGIN",bo,userContext); + return "00"+workcode; + }else{ + login_end_time = System.currentTimeMillis(); + bo.set("END_TIME",login_end_time); + bo.set("USER_ID",params.get("casaccount")); + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().createDataBO("BO_EU_OA_LOGIN",bo,userContext); + return params.get("casaccount"); + } + } + + if (StringUtils.isNotEmpty(params.get("usercode"))){ + + login_end_time = System.currentTimeMillis(); + bo.set("END_TIME",login_end_time); + bo.set("USER_ID",params.get("usercode")); + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().createDataBO("BO_EU_OA_LOGIN",bo,userContext); + + return params.get("usercode"); + } + + + logger.info("单点登录验证---------"+params); + try { + + long loginbegintime = System.currentTimeMillis(); + bo.set("LOGIN_BEGIN_TIME",loginbegintime); + String redirect_uri = params.get("code"); + + if(StringUtils.isEmpty(redirect_uri)){ + logger.error("跳转地址为空,请重新输入"); + return null; + } + + + App app = new App(); + String tokens = app.getTokens("http://10.114.11.135:8088/portal/process_center.html", redirect_uri); + if(StringUtils.isEmpty(tokens)){ + logger.error("获取token为空,请重新输入登录信息获取code"); + return null; + }else { + JSONObject jsonObjects = JSONObject.parseObject(tokens); + String access_token = jsonObjects.getString("access_token"); + String userInfo = app.getUserInfo(access_token); + + if (StringUtils.isNotEmpty(userInfo)){ + JSONObject json = JSONObject.parseObject(userInfo); + System.out.println("json-=====>>>>"+json); + if (StringUtils.isNotEmpty(json.getString("employeenumber"))){ + System.out.println("userid》》》》》》》》》》"+json.getString("employeenumber")); + userid = json.getString("employeenumber"); + login_end_time = System.currentTimeMillis(); + bo.set("END_TIME",login_end_time); + bo.set("SCENDTIME",(login_end_time-loginbegintime)); + bo.set("LOGIN_END_TIME",login_end_time); + bo.set("USER_ID",userid); + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().createDataBO("BO_EU_OA_LOGIN",bo,userContext); + return json.getString("employeenumber"); + } + } + + } + + + + } catch (Exception e) { + logger.error("统一身份认证失败!", e); + } + return null; + } + + + + public long getCookieTime(UserModel user) { + System.out.println("session时间>>>>>>>>>>"+user.getSessionTime()); +//下面的值代表与 AWS PaaS 会话过期时间一致, +//因平台会话过期时间以分钟计,所以需要乘以 60 + return 0; + } + + /** + * 统一身份认证接口 + * @param1 webserviceUrl 身份认证接口地址 + * @param2 casaccount 登录账号 OA账号 + * @param3 appaccount 应用系统登录账号 + * @param4 appid 应用系统id + * @param5 validcode 验证码 + * @return true/false + */ + public static String getToken(String casaccount,String appaccount,String appid,String validcode) { + //身份认证接口地址 + String webserviceUrl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "webserviceUrl"); + String checkLogin = ClientService.checkLogin(webserviceUrl,casaccount,appaccount,appid,validcode); + return checkLogin ; + } + + + + public static String geAuthorization(String clientId, String clientSecret) { + try { + byte[] key = (clientId + ":" + clientSecret).getBytes("utf-8"); + String cc = new String(Base64.encodeBase64(key), "utf-8"); + // String cc = new String(java.util.Base64.getEncoder().encode(key), "utf-8"); + return "Basic " + cc; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + return ""; + } + } + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/TaskController.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/TaskController.java new file mode 100644 index 00000000..f8a52b1b --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/TaskController.java @@ -0,0 +1,925 @@ +package com.awspaas.user.apps.integration.oauth; + +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.sql.Connection; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.*; + +import com.actionsoft.apps.coe.pal.constant.CoEConstant; +import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager; +import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst; +import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; +import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager; +import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile; +import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; +import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb; +import com.actionsoft.apps.coe.pal.util.HighSecurityUtil; +import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance; +import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance; +import com.actionsoft.bpms.client.form.UserTaskFormsWeb; +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.server.RequestParams; +import com.actionsoft.bpms.server.SSOUtil; +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.fs.DCContext; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.bpms.util.UUIDGener; +import com.actionsoft.bpms.util.UtilString; +import com.actionsoft.exception.AWSException; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.AppAPI; +import com.actionsoft.sdk.local.api.ORGAPI; +import com.actionsoft.sdk.local.api.TaskAPI; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.awspaas.user.apps.integration.event.OutputDCFileProcessor; +import com.awspaas.user.apps.integration.util.HttpClientUtils; +import com.awspaas.user.apps.integration.util.UtilUrl; +import com.google.common.io.ByteStreams; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.commons.httpclient.methods.RequestEntity; +import org.apache.commons.httpclient.methods.StringRequestEntity; +import org.apache.commons.lang.StringUtils; +@SuppressWarnings("all") +@Controller +public class TaskController { + + /** + * OA系统单点访问PAL系统 + * @return + */ + @Mapping("com.yili_pal_portal_open") + public String openPALConsole(String code) throws Exception { + ResponseObject ro = ResponseObject.newOkResponse(); + + + String userid = ""; + + App app = new App(); + String tokens = app.getTokens("http://10.114.11.135:8088/portal/yili.html", code); + if(StringUtils.isEmpty(tokens)){ + //System.out.println("这个认证是失败的,code为空,请联系管理员");; + }else { + JSONObject jsonObjects = JSONObject.parseObject(tokens); + String access_token = jsonObjects.getString("access_token"); + String userInfo = app.getUserInfo(access_token); + + if (StringUtils.isNotEmpty(userInfo)){ + JSONObject json = JSONObject.parseObject(userInfo); + //System.out.println("json-=====>>>>"+json); + if (StringUtils.isNotEmpty(json.getString("employeenumber"))){ + //System.out.println("userid》》》》》》》》》》"+json.getString("employeenumber")); + userid = json.getString("employeenumber"); + try { + setUserLog("",userid,"1"); + } catch (Exception e) { + } + } + } + + } + + + String sessionId = UserContext.fromUID(userid).getSessionId(); + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + + String url = portalUrl +"/r/w?sid="+sessionId+"&cmd=com.actionsoft.apps.skins.mportal3_home_page&id=5af46cd5-a1bc-4125-a144-86d1a199eec1"; + // String palPortalUrl= portalUrl + "/r/w?sid="+sessionId+"&cmd=com.actionsoft.apps.skins.mportal3_home_page&id=5af46cd5-a1bc-4125-a144-86d1a199eec1"; + + String portal_url = "https://bpm.yili.com:8088"+"/portal/r/or?cmd=com.actionsoft.apps.skins.mportal3_home_page&id=5af46cd5-a1bc-4125-a144-86d1a199eec1&sid="+sessionId+"&oauthName=oauthLogin&code="+code; + + //ro.put("new_url",url); + + return portal_url; + + } + + + + /** + * 用户登录日志 + * @param userid + * @param logType + */ + public void setUserLog(String processInstId,String userid,String logType) { + System.err.println("用户登录记录存入日志========>"+userid+"_类型:"+logType); + if (UtilString.isNotEmpty(userid)) { + //待阅更新已读记录 + if("3".equals(logType)) { + DBSql.update("UPDATE BO_ACT_DATAID SET READSTATE = '已读' WHERE PROCESSID = '"+processInstId+"' AND USER_ID = '"+userid+"'"); + } + String logTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + BO bo = new BO(); + ORGAPI orgapi = SDK.getORGAPI(); + UserModel user = orgapi.getUser(userid); + DepartmentModel departmentByUser = orgapi.getDepartmentByUser(userid); + bo.set("LOGINUSERNAME", userid); + bo.set("USERBUNAME",user.getExt4()); + bo.set("USERPOST",user.getPositionName()); + bo.set("USERDEPTNAME", departmentByUser.getPathNameOfCache()); + bo.set("LOGINTIME", logTime); + bo.set("LOGINCOUNTS", 1); + bo.set("LOGTYPE", Integer.valueOf(logType)); + SDK.getBOAPI().createDataBO("BO_EU_USER_LOGIN_LOG", bo, UserContext.fromUID("admin")); + + } + } + + + /** + * OA系统单点访问表单数据 + * @param me + * @param params + * @return + */ + @Mapping("com.yili_form_page_open") + public String openFormPage(UserContext me, RequestParams params) { + //System.out.println("进入表单了==========="); + //System.out.println("参数输出==========="+params.asMap()); + //打开待办时记录日志 + try { + setUserLog("",me.getUID(),"2"); + } catch (Exception e) { + } + String sessionId = me.getSessionId(); + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + if(!SDK.getPortalAPI().checkSession(sessionId)) { + SSOUtil ssoUtil = new SSOUtil(); + sessionId = ssoUtil.registerClientSessionNoPassword(me.getUID(), "cn",portalUrl, me.getDeviceType()); + } + UserContext uc = UserContext.fromSessionId(sessionId); + UserTaskFormsWeb web = new UserTaskFormsWeb(uc); + String processInstId = params.get("processInstId"); + String taskInstId = params.get("taskInstId"); + + + if (!UtilString.isEmpty(taskInstId) && taskInstId.equals("null")) { + taskInstId = ""; + } + int openState = 0; + //根据流程实例去获取表单的 状态 + if (!taskInstId.equals("")){ + TaskAPI taskAPI = SDK.getTaskAPI(); + final TaskInstance taskInstance = taskAPI.getTaskInstance(taskInstId); + if (null == taskInstance){ + taskInstId=""; + }else{ + if ("delete".equals(taskInstance.getControlState())){ + taskInstId=""; + }else{ + openState = taskInstance.getState(); + } + } + } + int currentPage = params.getInt("currentPage", 1); + String formDefId = params.get("formDefId", ""); + String boId = params.get("boId", ""); + String lang = params.get("lang"); + if (!UtilString.isEmpty(lang)) { + me.setLanguages(lang); + } + String extParam = params.get("extParam"); + JSONObject extParamJO = null; + if (!UtilString.isEmpty(extParam)) { + try { + extParamJO = JSONObject.parseObject(URLDecoder.decode(extParam, StandardCharsets.UTF_8.name())); + } catch (UnsupportedEncodingException var14) { + var14.printStackTrace(); + } + } + boolean isDisplayToolbar = params.getBoolean("displayToolbar", true); + String formPage = web.getFormPage(processInstId, taskInstId, openState, currentPage, formDefId, boId, isDisplayToolbar, extParamJO); + //String formURL = SDK.getFormAPI().getFormURL("", sessionId, processInstId,taskInstId, 1, null, null, null); + //System.err.println("单点登录页面链接--->"+formURL); + //return portalUrl+"/r"+formURL.substring(1); + ////System.out.println("输出表单==========="+formPage); + return formPage; + } + + @Mapping("com.yili_process_page") + public String processTest(UserContext me, RequestParams params) throws IOException, SQLException { + //System.out.println("params>>>>>>>>>>>>"+params.toString()); + //System.out.println("UserContext>>>>>>>>>>>>"+me.getUID()); + String userMobile = me.getDeviceType(); + String html = "index_web.html"; + Connection conn = DBSql.open(); + + Map map = new LinkedHashMap(); + try { + JSONArray jsonArray = new JSONArray(); + + //UserContext uc = UserContext.fromSessionId(sid); + String sid = me.getSessionId(); + String processInstId = params.get("processInstId"); + String taskInstId = params.get("taskInstId"); + try { + //用户打开阅览界面日志 + setUserLog(processInstId,me.getUID(),"3"); + } catch (Exception e) { + } + String usercode = "admin"; + if (UtilString.isNotEmpty(params.get("usercode"))) { + usercode = params.get("usercode"); + } + map.put("sid", sid); + + + List list = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID=", processInstId).list(); + List lists = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).addQuery("BINDID=", processInstId).list(); + List list_stop = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).addQuery("BINDID=", processInstId).list(); + int num = 1; + + //发布 + if (list.size()>0) { + //System.out.println("这个是更新的架构数据"); + for (BO bo : list) { + //System.out.println("开始时间》》》》》》》" + System.currentTimeMillis()); + JSONObject jsonObject = new JSONObject(); + String is_not_publish_sql = "SELECT id,PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID ='" + bo.get("PUBLISHFILEID") + "'"; + RowMap Row_maps_is_not_publish = DBSql.getMap(conn, is_not_publish_sql); + String id = bo.getString("TASKID"); + jsonObject.put("title", bo.get("PUBLISHFILENAME")); + jsonObject.put("link", SDK.getPortalAPI().getPortalUrl() + "/r/w?cmd=com.actionsoft.apps.coe.pal.publisher_publish_file_open&uuid=" + Row_maps_is_not_publish.getString("id") + "&sid=" + sid); + jsonObject.put("size", ""); + // jsonObject.put("id", num); + jsonObject.put("taskId", id); + jsonObject.put("id", bo.getString("PUBLISHFILEID")); + jsonArray.add(jsonObject); + num++; + + } + } + + //停用 + if (list_stop.size()>0) { + //System.out.println("这个是作废的架构数据"); + for (BO bo : list_stop) { + //System.out.println("开始时间》》》》》》》" + System.currentTimeMillis()); + JSONObject jsonObject = new JSONObject(); + String is_not_publish_sql = "SELECT id,PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID ='" + bo.get("STOPFILEID") + "'"; + RowMap Row_maps_is_not_publish = DBSql.getMap(conn, is_not_publish_sql); + String id = bo.getString("TASKID"); + jsonObject.put("title", bo.get("STOPFILENAME")); + jsonObject.put("link", SDK.getPortalAPI().getPortalUrl() + "/r/w?cmd=com.actionsoft.apps.coe.pal.publisher_publish_file_open&uuid=" + Row_maps_is_not_publish.getString("id") + "&sid=" + sid); + jsonObject.put("size", ""); + jsonObject.put("id", bo.getString("STOPFILEID")); + jsonObject.put("taskId", id); + jsonArray.add(jsonObject); + num++; + + } + } + //变更 + if(lists.size()>0) { + for (BO bo : lists) { + //System.out.println("这个是更新文件的架构"); + //System.out.println("开始时间》》》》》》》" + System.currentTimeMillis()); + JSONObject jsonObject = new JSONObject(); + String is_not_publish_sql = "SELECT id,PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID ='" + bo.get("CHANGEDFILEIDNEW") + "'"; + RowMap Row_maps_is_not_publish = DBSql.getMap(conn, is_not_publish_sql); + String id = bo.getString("TASKID"); + jsonObject.put("title", bo.get("CHANGEDFILENAMENEW")); + jsonObject.put("link", SDK.getPortalAPI().getPortalUrl() + "/r/w?cmd=com.actionsoft.apps.coe.pal.publisher_publish_file_open&uuid=" + Row_maps_is_not_publish.getString("id") + "&sid=" + sid); + jsonObject.put("size", ""); + jsonObject.put("id", bo.get("CHANGEDFILEIDNEW")); + jsonObject.put("taskId", id); + jsonArray.add(jsonObject); + num++; + + } + } + + String substring = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId).addQuery("OPTIONTYPE IS NOT NULL",null).detail().getString("RELEASE_INSTRUCTIONS"); + BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId).addQuery("OPTIONTYPE IS NOT NULL",null).detail(); + + //} + map.put("subString",substring); + map.put("ProcessTile",bo_act_coe_publishs.getString("PROCESS_TITLE")); + map.put("processInstId",processInstId); + map.put("sid",sid); + //System.out.println("jsonArray=====>>>>>>>>>"+jsonArray); + map.put("jsonlist",jsonArray); + + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + String url = portalUrl + "/r/or?cmd=com.yili_process_page&processInstId=" + processInstId + "&taskInstId=" + taskInstId; + JSONObject jsonObject = new JSONObject(); + + jsonObject.put("action", "read"); + + HttpClientUtils httpClientUtil = new HttpClientUtils(); + // String s = httpClientUtil.SendPreview("http://10.119.22.207:80/services/service_lcglpt?wsdl", jsonObject); + BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId).addQuery("OPTIONTYPE IS NOT NULL",null).detail(); + List bo_act_dataid = SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processInstId).list(); + + if (bo_act_dataid != null) { + try { + + if (SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processInstId).addQuery("USER_ID=",usercode).detail()!=null){ + + String dataid = SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processInstId).addQuery("USER_ID=",usercode).detail().getString("DATAID"); + jsonObject.put("dataid", dataid); + }else { + jsonObject.put("dataid", ""); + } + + }catch (Exception e){ + + } + } + jsonObject.put("status","1"); + String xmlStr = "\n" + + " " + + " " + + " " + + " " + + "" + + " " + + " " + + " " + + ""; + //HttpClientUtil httpClientUtil = new HttpClientUtil(); + //System.out.println("HttpClient 发送SOAP请求"); + HttpClient client = new HttpClient(); + int timeout = 10000; + String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl"); + PostMethod postMethod = new PostMethod(readurl); + // 设置连接超时 + client.getHttpConnectionManager().getParams().setConnectionTimeout(timeout); + // 设置读取时间超时 + client.getHttpConnectionManager().getParams().setSoTimeout(timeout); + // 然后把Soap请求数据添加到PostMethod中 + RequestEntity requestEntity = new StringRequestEntity(xmlStr, "text/xml", "UTF-8"); + // 设置请求体 + postMethod.setRequestEntity(requestEntity); + int status = client.executeMethod(postMethod); + // 打印请求状态码 + //System.out.println("status:" + status); + // 获取响应体输入流 + //System.out.println("xmlstr=================" + xmlStr); + InputStream is = postMethod.getResponseBodyAsStream(); + //System.out.println("s=================+s" + new String(ByteStreams.toByteArray(is))); + ////System.out.println("s==============>>>>>>>>>>>"+s); + String nums = DBSql.getString("select READNUM from BO_EU_PAL_READ_LOG where PROCESSID = '" + processInstId + "'"); + if (UtilString.isNotEmpty(nums)){ + + Integer read_num = Integer.valueOf(nums); + read_num+=1; + DBSql.update("update BO_EU_PAL_READ_LOG set READNUM = '"+read_num+"' where PROCESSID = '"+processInstId+"'"); + } + + //} + }catch (Exception e){ + e.printStackTrace(); + }finally { + conn.close(); + } + return HtmlPageTemplate.merge("com.awspaas.user.apps.yili.integration",html, map); + } + + + @Mapping("com.yili_process_page_phone") + public String processPhone(UserContext me, RequestParams params) throws SQLException { + + //System.out.println("params>>>>>>>>>>>>"+params.get("userid")); + //System.out.println("UserContext>>>>>>>>>>>>"+me.getUID()); + String userMobile = me.getDeviceType(); + Connection conn = DBSql.open(); + JSONArray jsonArray = new JSONArray(); + + String html = "index_phone.html"; + Map map = new LinkedHashMap(); + try{ + //UserContext uc = UserContext.fromSessionId(sid); + String sid = me.getSessionId(); + String processInstId = params.get("processInstId"); + String taskInstId = params.get("taskInstId"); + + try { + //用户打开阅览界面日志 + setUserLog(processInstId,me.getUID(),"3"); + + } catch (Exception e) { + } + String usercode = "admin"; + if(UtilString.isNotEmpty(me.getUID())){ + usercode = me.getUID(); + } + StringBuffer sb = new StringBuffer(); + ProcessInstance instanceById = SDK.getProcessAPI().getInstanceById(processInstId); + String sourceAppId = instanceById.getAppId(); +// aslp服务地址 + String aslp = "aslp://com.actionsoft.apps.addons.onlinedoc/filePreview"; + String substring = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId).addQuery("OPTIONTYPE IS NOT NULL",null).detail().getString("RELEASE_INSTRUCTIONS"); + BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId).addQuery("OPTIONTYPE IS NOT NULL",null).detail(); + + List list = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID=", processInstId).list(); + List lists = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).addQuery("BINDID=", processInstId).list(); + List list_stop = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).addQuery("BINDID=", processInstId).list(); + int num = 1; + + for (BO bo:list) { + + if(StringUtils.isNotEmpty(bo.getString("TASKID"))&& !bo.getString("TASKID").equals("submit_create")){ + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + //System.out.println(",odel>>>>>>>>"+bo.getString("TASKID")); + OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId()); + if (appProfile==null){ + throw new AWSException("Not Find OutputAppProfile! profileId=" + "_900fde3255248317266cad1c72f157b1"); + } + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + String sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '"+bo.getString("PUBLISHFILEID")+"'"; + String lever = DBSql.getString(conn, sql_lever); + //System.out.println("lever====>>>>>"+lever); + if (lever.length()!=5){ + lever = lever+".0"; + } + String name = bo.getString("PUBLISHFILENAME").replaceAll("/",""); + DCContext dcContext = new DCContext(me, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), bo.getString("TASKID"),name+"_"+lever+".doc"); + + + +// 调用App + +// 参数定义列表 + Map params_preview = new HashMap(); +//文档是否允许下载,必填 + params_preview.put("isDownload", true); +//显示文件名,必填 + params_preview.put("fileNameOriginal", name+"_"+lever+".doc"); +//PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填 + params_preview.put("isPDFCovertPNG", 0); +//groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填 + params_preview.put("extParams", ""); +//文档是否允许打印,必填 + params_preview.put("isPrint", true); +//是否显示顶部工具栏的返回按钮,默认显示,非必填 + params_preview.put("isShowBackbtn", false); +//原文件DC,必填 + params_preview.put("sourceDc", dcContext); +//是否显示默认预览工具栏,必填 + params_preview.put("isShowDefaultToolbar", true); +//文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填 + params_preview.put("isCopy", true); +//sessionid,必填 + params_preview.put("sid", sid); +//文档是否加密,必填 + params_preview.put("isEncrypt", false); + AppAPI appAPI = SDK.getAppAPI(); +//文档预览 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params_preview); + + //System.out.println("ro>>>>>>>>>>>>>>>>"+ro); + String is_not_publish_sql = "SELECT id,PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE id ='"+bo.get("PUBLISHFILEID")+"'"; + List Row_maps_is_not_publish = DBSql.getMaps(conn, is_not_publish_sql); + + /*boolean havingStartProcessPermission =SDK.getPermAPI().havingStartProcessPermission(uc.getUID(), processDefId); + if(havingStartProcessPermission) {*/ + BigDecimal big=new BigDecimal(Row_maps_is_not_publish.get(0).getString("PLVER")); + + JSONObject jsonObjects = new JSONObject(); + jsonObjects.put("title",bo.get("PUBLISHFILENAME")); + jsonObjects.put("link","https://bpm.yili.com:8088/portal/r"+ro.get("url").toString().substring(1)); + // jsonObjects.put("size","12k"); + jsonArray.add(jsonObjects); + } + + + + + + String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"+bo.getString("PUBLISHFILEID")+"'" + + ")"; + List maps = DBSql.getMaps(conn,sql_upfile); + UserContext userContext = UserContext.fromSessionId(sid); + UpfileWeb upfileWeb = new UpfileWeb(userContext); + + for (RowMap row : maps) { + UpfileModel upfileModel = new UpfileModel(); + upfileModel.setType(row.getString("FILETYPE")); + upfileModel.setFileName(row.getString("FILENAME")); + upfileModel.setPl_uuid(row.getString("PALREPOSITORYID")); + upfileModel.setShape_uuid(row.getString("SHAPEID")); + DCContext dcContexts = upfileWeb.getDCContext(upfileModel); + Map params_previews = new HashMap(); +//文档是否允许下载,必填 + params_previews.put("isDownload", true); +//显示文件名,必填 + params_previews.put("fileNameOriginal", row.getString("FILENAME")); +//PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填 + params_previews.put("isPDFCovertPNG", 0); +//groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填 + params_previews.put("extParams", ""); +//文档是否允许打印,必填 + params_previews.put("isPrint", true); +//是否显示顶部工具栏的返回按钮,默认显示,非必填 + params_previews.put("isShowBackbtn", ""); +//原文件DC,必填 + params_previews.put("sourceDc", dcContexts); +//是否显示默认预览工具栏,必填 + params_previews.put("isShowDefaultToolbar", true); +//文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填 + params_previews.put("isCopy", true); +//sessionid,必填 + params_previews.put("sid", sid); +//文档是否加密,必填 + params_previews.put("isEncrypt", false); + AppAPI appAPIs = SDK.getAppAPI(); +//文档预览 + ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, params_previews); + + JSONObject jsonObject1 = new JSONObject(); + jsonObject1.put("title",row.getString("FILENAME")); + String base_url = "https://bpm.yili.com:8088/portal/r"; + if (row.getString("FILENAME").toString().contains(".xls")||row.getString("FILENAME").toString().contains(".xlsx")){ + jsonObject1.put("link",ros.get("url").toString().substring(0)); + }else { + jsonObject1.put("link",base_url+ros.get("url").toString().substring(1)); + } + + // jsonObject1.put("size","12k"); + jsonArray.add(jsonObject1); + num++; + } + num++; + } + + +/** + * 这个是作废的显示的文件 + */ + for (BO bo:list_stop) { + + if(StringUtils.isNotEmpty(bo.getString("TASKID"))&& !bo.getString("TASKID").equals("submit_create")){ + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + //System.out.println(",odel>>>>>>>>"+bo.getString("TASKID")); + OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId()); + if (appProfile==null){ + throw new AWSException("Not Find OutputAppProfile! profileId=" + "_900fde3255248317266cad1c72f157b1"); + } + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + String sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '"+bo.getString("STOPFILEID")+"'"; + String lever = DBSql.getString(conn, sql_lever); + //System.out.println("lever====>>>>>"+lever); + if (lever.length()!=5){ + lever = lever+".0"; + } + String name = bo.getString("STOPFILENAME").replaceAll("/",""); + DCContext dcContext = new DCContext(me, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), bo.getString("TASKID"),name+"_"+lever+".doc"); + + + +// 调用App + +// 参数定义列表 + Map params_preview = new HashMap(); +//文档是否允许下载,必填 + params_preview.put("isDownload", true); +//显示文件名,必填 + params_preview.put("fileNameOriginal", name+"_"+lever+".doc"); +//PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填 + params_preview.put("isPDFCovertPNG", 0); +//groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填 + params_preview.put("extParams", ""); +//文档是否允许打印,必填 + params_preview.put("isPrint", true); +//是否显示顶部工具栏的返回按钮,默认显示,非必填 + params_preview.put("isShowBackbtn", false); +//原文件DC,必填 + params_preview.put("sourceDc", dcContext); +//是否显示默认预览工具栏,必填 + params_preview.put("isShowDefaultToolbar", true); +//文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填 + params_preview.put("isCopy", true); +//sessionid,必填 + params_preview.put("sid", sid); +//文档是否加密,必填 + params_preview.put("isEncrypt", false); + AppAPI appAPI = SDK.getAppAPI(); +//文档预览 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params_preview); + + //System.out.println("ro>>>>>>>>>>>>>>>>"+ro); + String is_not_publish_sql = "SELECT id,PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE id ='"+bo.get("STOPFILEID")+"'"; + List Row_maps_is_not_publish = DBSql.getMaps(conn, is_not_publish_sql); + + /*boolean havingStartProcessPermission =SDK.getPermAPI().havingStartProcessPermission(uc.getUID(), processDefId); + if(havingStartProcessPermission) {*/ + BigDecimal big=new BigDecimal(Row_maps_is_not_publish.get(0).getString("PLVER")); + + JSONObject jsonObjects = new JSONObject(); + jsonObjects.put("title",bo.get("STOPFILENAME")); + jsonObjects.put("link","https://bpm.yili.com:8088/portal/r"+ro.get("url").toString().substring(1)); + // jsonObjects.put("size","12k"); + jsonArray.add(jsonObjects); + } + + + + + + String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"+bo.getString("STOPFILEID")+"'" + + ")"; + List maps = DBSql.getMaps(conn,sql_upfile); + UserContext userContext = UserContext.fromSessionId(sid); + UpfileWeb upfileWeb = new UpfileWeb(userContext); + + for (RowMap row : maps) { + UpfileModel upfileModel = new UpfileModel(); + upfileModel.setType(row.getString("FILETYPE")); + upfileModel.setFileName(row.getString("FILENAME")); + upfileModel.setPl_uuid(row.getString("PALREPOSITORYID")); + upfileModel.setShape_uuid(row.getString("SHAPEID")); + DCContext dcContexts = upfileWeb.getDCContext(upfileModel); + Map params_previews = new HashMap(); +//文档是否允许下载,必填 + params_previews.put("isDownload", true); +//显示文件名,必填 + params_previews.put("fileNameOriginal", row.getString("FILENAME")); +//PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填 + params_previews.put("isPDFCovertPNG", 0); +//groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填 + params_previews.put("extParams", ""); +//文档是否允许打印,必填 + params_previews.put("isPrint", true); +//是否显示顶部工具栏的返回按钮,默认显示,非必填 + params_previews.put("isShowBackbtn", ""); +//原文件DC,必填 + params_previews.put("sourceDc", dcContexts); +//是否显示默认预览工具栏,必填 + params_previews.put("isShowDefaultToolbar", true); +//文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填 + params_previews.put("isCopy", true); +//sessionid,必填 + params_previews.put("sid", sid); +//文档是否加密,必填 + params_previews.put("isEncrypt", false); + AppAPI appAPIs = SDK.getAppAPI(); +//文档预览 + ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, params_previews); + + JSONObject jsonObject1 = new JSONObject(); + jsonObject1.put("title",row.getString("FILENAME")); + String base_url = "https://bpm.yili.com:8088/portal/r"; + if (row.getString("FILENAME").toString().contains(".xls")||row.getString("FILENAME").toString().contains(".xlsx")){ + jsonObject1.put("link",ros.get("url").toString().substring(0)); + }else { + jsonObject1.put("link",base_url+ros.get("url").toString().substring(1)); + } + + // jsonObject1.put("size","12k"); + jsonArray.add(jsonObject1); + num++; + } + num++; + } + + + for (BO bo:lists) { + + if(StringUtils.isNotEmpty(bo.getString("TASKID"))&& !bo.getString("TASKID").equals("submit_create")){ + OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); + //System.out.println(",odel>>>>>>>>"+bo.getString("TASKID")); + OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId()); + if (appProfile==null){ + throw new AWSException("Not Find OutputAppProfile! profileId=" + "_900fde3255248317266cad1c72f157b1"); + } + DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT); + if (dcProfile == null) + throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT); + String sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '"+bo.getString("CHANGEDFILEIDNEW")+"'"; + String lever = DBSql.getString(conn, sql_lever); + //System.out.println("lever====>>>>>"+lever); + if (lever.length()!=5){ + lever = lever+".0"; + } + String name = bo.getString("CHANGEDFILENAMENEW").replaceAll("/",""); + DCContext dcContext = new DCContext(me, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), bo.getString("TASKID"),name+"_"+lever+".doc"); + + + +// 调用App + +// 参数定义列表 + Map params_preview = new HashMap(); +//文档是否允许下载,必填 + params_preview.put("isDownload", true); +//显示文件名,必填 + params_preview.put("fileNameOriginal", name+"_"+lever+".doc"); +//PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填 + params_preview.put("isPDFCovertPNG", 0); +//groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填 + params_preview.put("extParams", ""); +//文档是否允许打印,必填 + params_preview.put("isPrint", true); +//是否显示顶部工具栏的返回按钮,默认显示,非必填 + params_preview.put("isShowBackbtn", false); +//原文件DC,必填 + params_preview.put("sourceDc", dcContext); +//是否显示默认预览工具栏,必填 + params_preview.put("isShowDefaultToolbar", true); +//文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填 + params_preview.put("isCopy", true); +//sessionid,必填 + params_preview.put("sid", sid); +//文档是否加密,必填 + params_preview.put("isEncrypt", false); + AppAPI appAPI = SDK.getAppAPI(); +//文档预览 + ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params_preview); + + //System.out.println("ro>>>>>>>>>>>>>>>>"+ro); + String is_not_publish_sql = "SELECT id,PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE id ='"+bo.get("CHANGEDFILEIDNEW")+"'"; + RowMap Row_maps_is_not_publish = DBSql.getMap(conn, is_not_publish_sql); + + /*boolean havingStartProcessPermission =SDK.getPermAPI().havingStartProcessPermission(uc.getUID(), processDefId); + if(havingStartProcessPermission) {*/ + BigDecimal big=new BigDecimal(Row_maps_is_not_publish.getString("PLVER")); + + JSONObject jsonObjects = new JSONObject(); + jsonObjects.put("title",bo.get("CHANGEDFILENAMENEW")); + jsonObjects.put("link","https://bpm.yili.com:8088/portal/r"+ro.get("url").toString().substring(1)); + // jsonObjects.put("size","12k"); + jsonArray.add(jsonObjects); + } + + + + + + String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"+bo.getString("CHANGEDFILEIDNEW")+"'" + + ")"; + List maps = DBSql.getMaps(conn,sql_upfile); + UserContext userContext = UserContext.fromSessionId(sid); + UpfileWeb upfileWeb = new UpfileWeb(userContext); + + for (RowMap row : maps) { + UpfileModel upfileModel = new UpfileModel(); + upfileModel.setType(row.getString("FILETYPE")); + upfileModel.setFileName(row.getString("FILENAME")); + upfileModel.setPl_uuid(row.getString("PALREPOSITORYID")); + upfileModel.setShape_uuid(row.getString("SHAPEID")); + DCContext dcContexts = upfileWeb.getDCContext(upfileModel); + Map params_previews = new HashMap(); +//文档是否允许下载,必填 + params_previews.put("isDownload", true); +//显示文件名,必填 + params_previews.put("fileNameOriginal", row.getString("FILENAME")); +//PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填 + params_previews.put("isPDFCovertPNG", 0); +//groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填 + params_previews.put("extParams", ""); +//文档是否允许打印,必填 + params_previews.put("isPrint", true); +//是否显示顶部工具栏的返回按钮,默认显示,非必填 + params_previews.put("isShowBackbtn", ""); +//原文件DC,必填 + params_previews.put("sourceDc", dcContexts); +//是否显示默认预览工具栏,必填 + params_previews.put("isShowDefaultToolbar", true); +//文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填 + params_previews.put("isCopy", true); +//sessionid,必填 + params_previews.put("sid", sid); +//文档是否加密,必填 + params_previews.put("isEncrypt", false); + AppAPI appAPIs = SDK.getAppAPI(); +//文档预览 + ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, params_previews); + + JSONObject jsonObject1 = new JSONObject(); + jsonObject1.put("title",row.getString("FILENAME")); + if (row.getString("FILENAME").contains(".xlsx")||row.getString("FILENAME").contains(".xls")){ + jsonObject1.put("link",ros.get("url").toString().substring(0)); + }else { + jsonObject1.put("link","https://bpm.yili.com:8088/portal/r"+ros.get("url").toString().substring(1)); + } + + // jsonObject1.put("size","12k"); + jsonArray.add(jsonObject1); + num++; + } + num++; + } + + + //} + //System.out.println("substring>>>>>>>>>>"+substring); + map.put("subString",substring); + map.put("ProcessTile",bo_act_coe_publish.getString("PROCESS_TITLE")); + map.put("processInstId",processInstId); + map.put("sid",sid); + //System.out.println("jsonArray=====>>>>>>>>>"+jsonArray); + map.put("jsonlist",jsonArray); + //DBSql.close(conn); + + String portalUrl = SDK.getPortalAPI().getPortalUrl(); + String url = portalUrl+"/r/or?cmd=com.yili_process_page&processInstId="+processInstId+"&taskInstId="+taskInstId; + String mobileurl = portalUrl+"/r/or?cmd=com.yili_process_page_phone&processInstId="+processInstId+"&taskInstId="+taskInstId; + JSONObject jsonObject = new JSONObject(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String sql = "SELECT * FROM WFC_PROCESS WHERE ID ='"+processInstId+"'"; + List rowMaps = DBSql.getMaps(conn,sql); + if (rowMaps.size()==1){ + + jsonObject.put("action","read"); + //jsonObject.put("dept",me.getDepartmentModel().getNo()); + // jsonObject.put("user",me.getUID()); + // jsonObject.put("remark",""); + jsonObject.put("status","1"); + //jsonObject.put("pcurl",url); + // jsonObject.put("mobileurl",mobileurl); + try { + BO bo_act_dataid = SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processInstId).addQuery("USER_ID=", usercode).detail(); + if (bo_act_dataid!=null){ + jsonObject.put("dataid",bo_act_dataid.getString("DATAID")); + } + }catch (Exception e){ + + } + + //jsonObject.put("userList","00345531"); + HttpClientUtils httpClientUtil = new HttpClientUtils(); + // String s = httpClientUtil.SendPreview("http://10.119.22.207:80/services/service_lcglpt?wsdl", jsonObject); + + String xmlStr = "\n" + + " " + + " " + + " " + + " " + + ""+ + " " + + " " + + " " + + ""; + //HttpClientUtil httpClientUtil = new HttpClientUtil(); + String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl"); + + String s = UtilUrl.doPostSoap(readurl, xmlStr, ""); + //System.out.println("s==============>>>>>>>>>>>"+s); + + } + String nums = DBSql.getString("select READNUM from BO_EU_PAL_READ_LOG where PROCESSID = '" + processInstId + "'"); + if (UtilString.isNotEmpty(nums)){ + + Integer read_num = Integer.valueOf(nums); + read_num+=1; + DBSql.update("update BO_EU_PAL_READ_LOG set READNUM = '"+read_num+"' where PROCESSID = '"+processInstId+"'"); + } + + }catch (Exception e){ + e.printStackTrace(); + }finally { + conn.close(); + } + return HtmlPageTemplate.merge("com.awspaas.user.apps.yili.integration",html, map); + } + + + /** + * 从 String 中提取数字 + * @param string + * @return + */ + public static String getNumberFromString(String string){ + String str = string; + str = str.trim(); + StringBuffer str2 = new StringBuffer(); + if(str != null && !"".equals(str)) { + for (int i = 0; i < str.length(); i++) { + if (str.charAt(i) >= 48 && str.charAt(i) <= 57) { + String s = String.valueOf(str.charAt(i)); + str2.append(s); + } + } + } + return str2.toString(); + } + + + + + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/plugins/Plugins.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/plugins/Plugins.java new file mode 100644 index 00000000..aa2362d4 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/plugins/Plugins.java @@ -0,0 +1,31 @@ +package com.awspaas.user.apps.integration.plugins; + +import java.util.ArrayList; +import java.util.List; + +import com.actionsoft.apps.listener.PluginListener; +import com.actionsoft.apps.resource.AppContext; +import com.actionsoft.apps.resource.plugin.profile.AWSPluginProfile; +import com.actionsoft.apps.resource.plugin.profile.OauthPluginProfile; +import com.actionsoft.apps.resource.plugin.profile.ProcessPublicEventPluginProfile; +import com.awspaas.user.apps.integration.oa.TaskListener; +import com.awspaas.user.apps.integration.oauth.OauthLogin; +import com.awspaas.user.apps.integration.oauth.ProcessOathLogin; + +/** + * @author LHY + */ +public class Plugins implements PluginListener { + @Override + public List register(AppContext context) { + List list = new ArrayList<>(); + + //注册监听器 + //注册外部系统跳转PAL系统 登陆插件 + list.add(new ProcessPublicEventPluginProfile(TaskListener.class.getName(), "待办推送监听器")); + list.add(new OauthPluginProfile("oauthLogin", OauthLogin.class.getName(), "OA系统 跳转登陆PAl")); + list.add(new OauthPluginProfile("processOathLogin", ProcessOathLogin.class.getName(), "流程中心发布")); + return list; + } + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/AesUtil.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/AesUtil.java new file mode 100644 index 00000000..4549d776 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/AesUtil.java @@ -0,0 +1,90 @@ +package com.awspaas.user.apps.integration.util; + +import java.net.URLEncoder; +import java.security.Key; +import java.security.SecureRandom; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; + +import sun.misc.BASE64Decoder; +import sun.misc.BASE64Encoder; + +/** + * AES加密解密工具类 + * + * @author M-Y + */ +public class AesUtil { + + public static String DES = "AES"; // optional value AES/DES/DESede + + public static String CIPHER_ALGORITHM = "AES"; // optional value + // AES/DES/DESede + + public Key getKey(String strKey) { + try { + if (strKey == null) { + strKey = ""; + } + KeyGenerator _generator = KeyGenerator.getInstance("AES"); + SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); + secureRandom.setSeed(strKey.getBytes()); + _generator.init(128, secureRandom); + return _generator.generateKey(); + } catch (Exception e) { + throw new RuntimeException(" 初始化密钥出现异常 "); + } + } + + public String encrypt(String data, String key) throws Exception { + SecureRandom sr = new SecureRandom(); + Key secureKey = getKey(key); + Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM); + cipher.init(Cipher.ENCRYPT_MODE, secureKey, sr); + byte[] bt = cipher.doFinal(data.getBytes()); + String strS = new BASE64Encoder().encode(bt); + return strS; + } + + public String decrypt(String message, String key) { + try { + SecureRandom sr = new SecureRandom(); + Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM); + Key secureKey = getKey(key); + cipher.init(Cipher.DECRYPT_MODE, secureKey, sr); + byte[] res = new BASE64Decoder().decodeBuffer(message); + res = cipher.doFinal(res); + return new String(res); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public String DecryptedMsg(String message, String key) throws Exception, Exception { + String Msg1 = encrypt(message, key); + System.out.println("message is :" + Msg1); + String encryptMsg1 = URLEncoder.encode(encrypt(message, key), "UTF-8"); + System.out.println("encrypted message is :" + encryptMsg1); + return encryptMsg1; + + } + + public static void main(String[] args) throws Exception { + String data = "AUDIT##202210181611"; + String key = "auditY809kUih23"; + String url = "http://10.60.143.183:8088/portal/r/df?groupValue=7d3ca852-a0bd-42e6-80b1-3dcea6f55083&fileValue=d1135309-e376-4ec6-bd27-51947abe26ea&sid=null&repositoryName=output&appId=com.actionsoft.apps.coe.pal.output.pr&attachment=true&fileName=%E5%B9%BF%E5%91%8A%E5%88%9B%E6%84%8F%E7%94%9F%E6%88%90%E6%B5%81%E7%A8%8B_1.0.doc&lastModified=1666352134000"; + String str1 = url.substring(0, url.indexOf("/df")); + + System.out.println("str1>"+str1); + //String encryptMsg1 = AesUtil.encrypt(data, key); + //System.out.println("加密后:" + encryptMsg1); + /*message = "YPS5F%2F%2BVmdbVj0iuxrSINw%3D%3D"; + System.out.println("解密后:" + AesUtil.decrypt(URLDecoder.decode(message), key));*/ + } + + + + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/ChineseIntoLetters.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/ChineseIntoLetters.java new file mode 100644 index 00000000..ab31797a --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/ChineseIntoLetters.java @@ -0,0 +1,222 @@ +package com.awspaas.user.apps.integration.util; + +import java.util.Random; + +public class ChineseIntoLetters { + + /** + + * 返回首字母 + + * @param strChinese + + * @param bUpCase + + * @return + + */ + + public static String getPYIndexStr(String strChinese, boolean bUpCase){ + + try{ + + StringBuffer buffer = new StringBuffer(); + String chinese = ""; + + byte b[] = strChinese.getBytes("GBK");//把中文转化成byte数组 + + for(int i = 0; i < b.length; i++){ + + if((b[i] & 255) > 128){ + + int char1 = b[i++] & 255; + + char1 <<= 8;//左移运算符用“<<”表示,是将运算符左边的对象,向左移动运算符右边指定的位数,并且在低位补零。其实,向左移n位,就相当于乘上2的n次方 + + int chart = char1 + (b[i] & 255); + + buffer.append(getPYIndexChar((char)chart, bUpCase)); + + continue; + + } + + char c = (char)b[i]; + + //确定指定字符是否是汉字、大写字母、数字 + if(!Character.isJavaIdentifierPart(c) || (c >= 'A' && c <= 'Z') || Character.isDigit(c)){ + + buffer.append(c); + + }if (c >= 'a' && c <= 'z'){ + + buffer.append((char) (c - 'a' + 'A')); + + } + + } + if (buffer.toString().contains("-")){ + chinese = buffer.toString().replaceAll("-","_"); + }else if (buffer.toString().contains(" ")){ + chinese = buffer.toString().replaceAll(" ","_"); + }else { + chinese = buffer.toString(); + } + + if (chinese.contains("\\(")){ + chinese = buffer.toString().replaceAll("\\(","L"); + } + + if (chinese.contains(")")){ + chinese = buffer.toString().replaceAll("[)]","R"); + } + + return chinese; + + }catch(Exception e){ + + e.printStackTrace(); + + } + + return null; + + } + + /** + + * 得到首字母 + + * @param strChinese + + * @param bUpCase + + * @return + + */ + + private static char getPYIndexChar(char strChinese, boolean bUpCase){ + + int charGBK = strChinese; + + char result; + + if(charGBK >= 45217 && charGBK <= 45252){ + + result = 'A'; + + }else if(charGBK >= 45253 && charGBK <= 45760){ + + result = 'B'; + + }else if(charGBK >= 45761 && charGBK <= 46317){ + + result = 'C'; + + }else if(charGBK >= 46318 && charGBK <= 46825){ + + result = 'D'; + + } else if(charGBK >= 46826 && charGBK <= 47009){ + + result = 'E'; + + }else if(charGBK >= 47010 && charGBK <= 47296){ + + result = 'F'; + + }else if(charGBK >= 47297 && charGBK <= 47613){ + + result = 'G'; + + }else if(charGBK >= 47614 && charGBK <= 48118){ + + result = 'H'; + + }else if(charGBK >= 48119 && charGBK <= 49061){ + + result = 'J'; + + } else if(charGBK >= 49062 && charGBK <= 49323){ + + result = 'K'; + + }else if(charGBK >= 49324 && charGBK <= 49895){ + + result = 'L'; + + }else if(charGBK >= 49896 && charGBK <= 50370){ + + result = 'M'; + + }else if(charGBK >= 50371 && charGBK <= 50613){ + + result = 'N'; + + }else if(charGBK >= 50614 && charGBK <= 50621){ + + result = 'O'; + + }else if(charGBK >= 50622 && charGBK <= 50905){ + + result = 'P'; + + }else if(charGBK >= 50906 && charGBK <= 51386){ + + result = 'Q'; + + }else if(charGBK >= 51387 && charGBK <= 51445){ + + result = 'R'; + + }else if(charGBK >= 51446 && charGBK <= 52217){ + + result = 'S'; + + }else if(charGBK >= 52218 && charGBK <= 52697){ + + result = 'T'; + + }else if(charGBK >= 52698 && charGBK <= 52979){ + + result = 'W'; + + }else if(charGBK >= 52980 && charGBK <= 53688){ + + result = 'X'; + + }else if(charGBK >= 53689 && charGBK <= 54480){ + + result = 'Y'; + + }else if(charGBK >= 54481 && charGBK <= 55289){ + + result = 'Z'; + + }else{ + + result = (char)(65 + (new Random()).nextInt(25)); + + } + + if(!bUpCase){ + result = Character.toLowerCase(result); + } + + return result; + + } + + /** + * @param args + */ + + public static void main(String[] args) { + + String str=",.;'90中国cD///*-+"; + + System.out.println("中文首字母:" + getPYIndexStr(str,true)); + + } + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/DownloadUtil.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/DownloadUtil.java new file mode 100644 index 00000000..af8dbf39 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/DownloadUtil.java @@ -0,0 +1,138 @@ +package com.awspaas.user.apps.integration.util; + +import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager; +import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; +import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; +import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb; +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.commons.mvc.view.ResponseObject; +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.DBSql; +import com.actionsoft.bpms.util.UUIDGener; +import com.actionsoft.bpms.util.UtilFile; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.AppAPI; +import com.alibaba.fastjson.JSONObject; +import com.awspaas.user.apps.integration.event.OutputDCFileProcessor; + +import java.io.File; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +public class DownloadUtil { + + /** + * 流程手册下载 + * @param _uc + * @param taskId + * @return + */ + public LinkedHashMap outputReportDownload(UserContext _uc, String taskId, String ruuid) { + System.out.println("usercontext>>>>>>>>>>>"+_uc.getUID()); + System.out.println("sid>>>>>>>>>>>"+_uc.getSessionId()); + LinkedHashMap map = new LinkedHashMap<>(); + OutputTaskModel model = new OutputTask().getTaskReportById(taskId); + ResponseObject result = ResponseObject.newOkResponse(); + if (model != null) { + try { + UtilFile file = OutputAPIManager.getInstance().getFilePath(model.getWsId(), taskId, model.getProfileId()); + if (file.exists()) { + File[] fileList = file.listFiles(); + if (fileList.length > 0) { + File docFile = null; + for (File file2 : fileList) { + if (file2.isFile() && "doc".equals((file2.getName().substring(file2.getName().lastIndexOf(".") + 1)))) { + docFile = file2; + break; + } + } + if (docFile == null) { + // return ResponseObject.newErrResponse("没有找到文件").toString(); + } + + PALRepositoryModel plmodel = PALRepositoryCache.getCache().get(ruuid); + if(plmodel!=null) { + String sourceAppId = "com.actionsoft.apps.coe.pal.output.pr"; + String methodId = plmodel.getMethodId(); + if(methodId.contains("control")) { + sourceAppId = "com.awspaas.user.apps.coe.pal.output.zd"; + }else if(methodId.contains("data")) { + sourceAppId = "com.awspaas.user.apps.coe.pal.output.bd"; + } + String filename = docFile.getName(); + DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, model.getWsId(), taskId, filename); + String downUrl= SDK.getConfAPI().getPortalUrl() + "/r/" + sourceDc.getDownloadURL().replace("./", ""); + // result.put("url",downUrl); + map.put(filename,downUrl); + } + + String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"+ruuid+"'" + + ")"; + List maps = DBSql.getMaps(sql_upfile); + UpfileWeb upfileWeb = new UpfileWeb(_uc); + + for (RowMap row : maps) { + UpfileModel upfileModel = new UpfileModel(); + upfileModel.setType(row.getString("FILETYPE")); + upfileModel.setFileName(row.getString("FILENAME")); + upfileModel.setPl_uuid(row.getString("PALREPOSITORYID")); + upfileModel.setShape_uuid(row.getString("SHAPEID")); + DCContext dcContexts = upfileWeb.getDCContext(upfileModel); + String downUrl= SDK.getConfAPI().getPortalUrl() + "/r/" + dcContexts.getDownloadURL().replace("./", ""); + map.put(row.getString("FILENAME"),downUrl); + } + + } + }else{ + result = ResponseObject.newErrResponse("没有可预览文件"); + } + } catch (Exception e) { + e.printStackTrace(); + // return ResponseObject.newErrResponse().toString(); + } + } + return map; + } + + + public String getzipURL(String sid,String taskId,String title){ + System.out.println("taskid》》》》》》》》》》"+taskId); + System.out.println("fileName》》》》》》》》》》"+title); + String reportDownloadURL = ""; + UserContext me = UserContext.fromSessionId(sid); + OutputTaskModel model = new OutputTask().getTaskReportById(taskId); + JSONObject result = new JSONObject(); + if (model != null) { + //三员管理,步骤横表下载重新生成手册 + + String taskName = model.getTaskName(); + if ("步骤横表".equals(taskName)){ + // 重新设置生成id,与用户id + String uuid = UUIDGener.getUUID(); + model.setUserId(me.getUID()); + + // 重新生成手册文件 + OutputAPIManager.getInstance().reGennerReport(me,model,uuid); + + // 重新构建手册下载URL + taskId = uuid; + } + + try { + reportDownloadURL = OutputDCFileProcessor.getReportDownloadURL(model.getWsId(), taskId, model.getProfileId(), me, title+model.getTaskName()); + } catch (Exception e) { + + e.printStackTrace(); + } + } + return reportDownloadURL; + } + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/HttpClientUtils.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/HttpClientUtils.java new file mode 100644 index 00000000..eb12023e --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/HttpClientUtils.java @@ -0,0 +1,123 @@ +package com.awspaas.user.apps.integration.util; + +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.sdk.local.SDK; +import com.awspaas.user.apps.integration.XmlDatasUtil; +import com.google.common.io.ByteStreams; +import org.apache.commons.httpclient.*; +import org.apache.commons.httpclient.methods.*; + +import java.io.*; + +public class HttpClientUtils { + + + + public String SendPend(String url, XmlDatasUtil xmlDatasUtil) throws IOException { + String result = "true"; + StringBuffer sendSoapString = new StringBuffer(); + String xmlStr = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n" + + "\n" + + " \n" + + " "+ xmlDatasUtil.getExternal_system_ID() +"\n" + + " "+ xmlDatasUtil.getOther_system_to_do_ID() +"\n" + + " "+ xmlDatasUtil.getProcess_title() +"\n" + + " "+ xmlDatasUtil.getPcurl() + "\n" + + " "+ xmlDatasUtil.getMobileurl() +"\n" + + " "+ xmlDatasUtil.getTo_do_login_account() +"\n" + + " "+ xmlDatasUtil.getTo_do_creation_time() +"\n" + + " "+ xmlDatasUtil.getTo_do_completion_time() +"\n" + + " "+ xmlDatasUtil.getTo_do_status() +"\n" + + " "+ xmlDatasUtil.getTo_do_official_type() +"\n" + + " "+ xmlDatasUtil.getViewtype() +"\n" + + " "+ xmlDatasUtil.getCreatedate() +"\n" + + " "+ xmlDatasUtil.getDonedate() +"\n" + + " "+ xmlDatasUtil.getReceivedate() +"\n" + + " " + xmlDatasUtil.getReceivetime() +"\n" + + " "+ xmlDatasUtil.getCurrentnodetype() +"\n" + + " "+ xmlDatasUtil.getRequestcode() +"\n" + + " "+ xmlDatasUtil.getCurrentnodename() +"\n" + + " "+ xmlDatasUtil.getNooperator() +"\n" + + " "+ xmlDatasUtil.getWorkcode() +"\n" + + " "+ xmlDatasUtil.getWorkflowname() +"\n" + + " "+ xmlDatasUtil.getCreaterhrcode() +"\n" + + " "+ xmlDatasUtil.getCreaterworkcode() +"\n" + + " \n" + + "\n" + + "]]>\n" + + "\n" + + " \n" + + " \n" + + ""; + + System.out.println("xmlstr================"+xmlStr); + String postSoap = UtilUrl.doPostSoap(url, xmlStr, ""); + + return postSoap; + } + + + public String readOa(String url, String taskid) throws IOException { + String result = "true"; + StringBuffer sendSoapString = new StringBuffer(); + String xmlStr = "\n" + + " \n" + + " \n" + + " \n" + + " LCZD\n" + + " "+taskid+"\n" + + " \n" + + " \n" + + ""; + + System.out.println("xmlstr================"+xmlStr); + String postSoap = UtilUrl.doPostSoap(url, xmlStr, ""); + + return postSoap; + } + + + + + public String SendPreview(String url, String xmlStr) { + String result = "true"; + + + PostMethod postMethod = new PostMethod(url); + StringBuffer soapRequestData = new StringBuffer(xmlStr); + byte[] b = (byte[])null; + + try { + b = soapRequestData.toString().getBytes("utf-8"); + } catch (UnsupportedEncodingException var16) { + var16.printStackTrace(); + } + + InputStream is = new ByteArrayInputStream(b, 0, b.length); + RequestEntity re = new InputStreamRequestEntity(is, (long)b.length, "text/xml; charset=utf-8"); + postMethod.setRequestEntity(re); + HttpClient httpClient = new HttpClient(); + httpClient.setConnectionTimeout(500000000); + httpClient.setTimeout(500000000); + + try { + int statusCode = httpClient.executeMethod(postMethod); + if (statusCode == 200) { + String soapResponseData = postMethod.getResponseBodyAsString(); + return soapResponseData.indexOf("Success") == -1 ? "fail" : result; + } else { + return "error:[" + statusCode + "]!"; + } + } catch (Exception var15) { + var15.printStackTrace(); + return "Exception:[" + var15 + "]!"; + } + } + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/HttpUtil.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/HttpUtil.java new file mode 100644 index 00000000..9f85964a --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/HttpUtil.java @@ -0,0 +1,64 @@ +package com.awspaas.user.apps.integration.util; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicHeader; +import org.apache.http.protocol.HTTP; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +/** + * http请求⼯具 + * @Author wangcy + */ +public class HttpUtil { + private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class); + /** + * 发送post请求 + * @param json + * @param URL + * @return + */ + public String sendPost(JSONObject json,String URL) { + CloseableHttpClient client = HttpClients.createDefault(); + HttpPost post = new HttpPost(URL); + post.setHeader("Content-Type", "application/json"); + //post.addHeader("Authorization", "Basic YWRtaW46"); + String result; + try { + StringEntity s = new StringEntity(json.toString(), "utf-8"); + s.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, + "application/json")); + post.setEntity(s); +// 发送请求 + HttpResponse httpResponse = client.execute(post); +// 获取响应输⼊流 + InputStream inStream = httpResponse.getEntity().getContent(); + BufferedReader reader = new BufferedReader(new InputStreamReader( + inStream, "utf-8")); + StringBuilder strber = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) + strber.append(line + "\n"); + inStream.close(); + result = strber.toString(); + if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { + System.out.println("请求服务器成功,做相应处理"); + } else { + System.out.println("请求服务端失败"); + } + } catch (Exception e) { + logger.error("请求异常:"+e.getMessage()); + throw new RuntimeException(e); + } + return result; + } +} \ No newline at end of file diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/JDBCUtil.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/JDBCUtil.java new file mode 100644 index 00000000..743551a5 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/JDBCUtil.java @@ -0,0 +1,34 @@ +package com.awspaas.user.apps.integration.util; + +import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; +import oracle.jdbc.pool.OracleDataSource; + +import java.sql.*; + +public class JDBCUtil { + + + public void comment(String tablename,String flid,String flidname) throws SQLException { + + try { + //加载驱动 + Class.forName("oracle.jdbc.driver.OracleDriver"); + String url ="jdbc:oracle:thin:@10.119.71.12:1521/bpmprod" ; + Connection conn= DriverManager.getConnection(url,"bpmprod","456rty$%^RTY"); + Statement stmt = conn.createStatement(); + String sql = "COMMENT ON T"+tablename+"."+flid+" IS '"+flidname+"'"; + PreparedStatement pstmt = conn.prepareStatement(sql); + boolean execute = pstmt.execute(); + System.out.println("执行成功与否》》》》》》》》》》》》"+execute); + /*while (rs.next()) { + System.out.println(rs.getString("user_password")); + System.out.println(rs.getString("user_name")); + }*/ + pstmt.close(); + stmt.close(); + } catch (Exception e) { + // TODO 自动生成 catch 块 + e.printStackTrace(); + } + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/PreviewDataUtil.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/PreviewDataUtil.java new file mode 100644 index 00000000..16f269f2 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/PreviewDataUtil.java @@ -0,0 +1,106 @@ +package com.awspaas.user.apps.integration.util; + +import java.util.List; + +public class PreviewDataUtil { + + String action; //固定值"read" + String title; //标题 + String dept;//发布机构(部门编码) + String user; //发布人(员工编码) + String date; //发布日期 yyyy-MM-dd + String remark;//备注 + String status;//发布状态 0未读、1已读 + String pcurl;//PC端链接地址 + String mobileurl;//移动端链接地址 + String dataid;//未读更新为已读时必填 + List userList;//接收人 string数组 + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDept() { + return dept; + } + + public void setDept(String dept) { + this.dept = dept; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getPcurl() { + return pcurl; + } + + public void setPcurl(String pcurl) { + this.pcurl = pcurl; + } + + public String getMobileurl() { + return mobileurl; + } + + public void setMobileurl(String mobileurl) { + this.mobileurl = mobileurl; + } + + public String getDataid() { + return dataid; + } + + public void setDataid(String dataid) { + this.dataid = dataid; + } + + public List getUserList() { + return userList; + } + + public void setUserList(List userList) { + this.userList = userList; + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/SoapUtil.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/SoapUtil.java new file mode 100644 index 00000000..c9fdf0ee --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/SoapUtil.java @@ -0,0 +1,43 @@ +package com.awspaas.user.apps.integration.util; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.*; + +public class SoapUtil { + + + public static String getWebServiceAndSoap(String url,StringBuffer sendSoapString) throws IOException { + String soap = sendSoapString.toString(); + if (soap == null) { + return null; + } + URL soapUrl = new URL(url); + URLConnection conn = soapUrl.openConnection(); + conn.setUseCaches(false); + conn.setDoInput(true); + conn.setDoOutput(true); + conn.setRequestProperty("Content-Length", + Integer.toString(soap.length())); + conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8"); + // 调用的接口方法是 + // conn.setRequestProperty(isClass,isMethod); + OutputStream os = conn.getOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(os, "utf-8"); + osw.write(soap); + osw.flush(); + osw.close(); + // 获取webserivce返回的流 + InputStream is = conn.getInputStream(); + if (is!=null) { + byte[] bytes = new byte[0]; + bytes = new byte[is.available()]; + is.read(bytes); + String str = new String(bytes); + return str; + }else { + return null; + } + } +} \ No newline at end of file diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/UtilUrl.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/UtilUrl.java new file mode 100644 index 00000000..e558e698 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/util/UtilUrl.java @@ -0,0 +1,51 @@ +package com.awspaas.user.apps.integration.util; + +import org.apache.http.HttpEntity; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import java.nio.charset.Charset; + +/** + * @PackageName: com.awspaas.user.apps.yili.integration.util + * @ClassName: UtilUrl + * @author: yujh + * @date: 2022/5/18 21:41 + */ +public class UtilUrl { + + //使用SOAP1.1发送消息 + public static String doPostSoap(String postUrl, String soapXml, String soapAction) { + String retStr = ""; + // 创建HttpClientBuilder + HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); + // HttpClient + CloseableHttpClient closeableHttpClient = httpClientBuilder.build(); + HttpPost httpPost = new HttpPost(postUrl); + // 设置请求和传输超时时间 + RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(600000) + .setConnectTimeout(600000).build(); + httpPost.setConfig(requestConfig); + try { + httpPost.setHeader("Content-Type", "text/xml;charset=UTF-8"); + httpPost.setHeader("SOAPAction", soapAction); + StringEntity data = new StringEntity(soapXml, Charset.forName("UTF-8")); + httpPost.setEntity(data); + CloseableHttpResponse response = closeableHttpClient.execute(httpPost); + HttpEntity httpEntity = response.getEntity(); + if (httpEntity != null) { + // 打印响应内容 + retStr = EntityUtils.toString(httpEntity, "UTF-8"); + } + // 释放资源 + closeableHttpClient.close(); + } catch (Exception e) { + e.printStackTrace(); + } + return retStr; + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/web/UpfileWeb.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/web/UpfileWeb.java new file mode 100644 index 00000000..94013c09 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/web/UpfileWeb.java @@ -0,0 +1,1227 @@ +/** + * + */ +package com.awspaas.user.apps.integration.web; + +import java.io.*; +import java.sql.Timestamp; +import java.util.*; +import java.util.zip.ZipOutputStream; + +import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager; +import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI; +import com.actionsoft.apps.coe.pal.log.CoEOpLogConst; +import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; +import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel; +import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager; +import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask; +import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel; +import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory; +import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao; +import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.cache.DesignerShapeRelationCache; +import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel; +import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil; +import com.actionsoft.apps.coe.pal.pal.repository.web.CoeProcessLevelWeb; +import com.actionsoft.apps.coe.pal.util.HighSecurityUtil; +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.server.DispatcherRequest; +import com.actionsoft.bpms.server.conf.server.AWSServerConf; +import com.actionsoft.bpms.util.DBSql; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; +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.server.UserContext; +import com.actionsoft.bpms.server.fs.DCContext; +import com.actionsoft.bpms.server.fs.dc.DCProfileManager; +import com.actionsoft.bpms.server.fs.dc.DCUtil; +import com.actionsoft.bpms.util.UUIDGener; +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.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +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.sdk.local.SDK; +import com.actionsoft.sdk.local.api.AppAPI; +import org.apache.commons.compress.utils.IOUtils; +import org.springframework.util.StringUtils; + +/** + * coe-附件处理web页面 + * + * @author 作者: renmm + * @version 创建时间:2014-4-8 + * + */ +public class UpfileWeb extends ActionWeb { + + private UserContext _uc; + + /** + * @param userContext + */ + public UpfileWeb(UserContext userContext) { + super(userContext); + _uc = userContext; + } + + /** + * coe-文件-上传附件-Portal-页面 + * @param pl_uuid + * @param shape_uuid + * @param type + * @return + */ + @Deprecated + public String upFilePortalHtml(String pl_uuid, String shape_uuid, String type) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(pl_uuid); + Map macroLibraries = new HashMap(); + macroLibraries.put("sid", super.getContext().getSessionId()); + macroLibraries.put("pl_uuid", pl_uuid); + macroLibraries.put("shape_uuid", shape_uuid); + macroLibraries.put("type", type); + macroLibraries.put("repositoryName", CoeFileConstant.TMP_UPFILE); + //三员管理下,默认文件上传目录 + if (HighSecurityUtil.isON()){ + macroLibraries.put("isHighSecurity", true); + HashMap securityMap = HighSecurityUtil.getObjSecurityMap(); + //筛选用户与文件密级 + Set entrySet = securityMap.keySet(); + Iterator iterator = entrySet.iterator(); + UserContext userContext = DispatcherRequest.getUserContext(); + while (iterator.hasNext()){ + String next = iterator.next(); + PALRepositoryModel plModel = null; + //流程文件switch,双重筛选密级 + if (HighSecurityUtil.fileSecuritySwitch()){ + plModel = model; + } + if (!HighSecurityUtil.hasSecurityLevel(userContext,Integer.parseInt(next),plModel)){ + iterator.remove(); + } + } + macroLibraries.put("securityOptions", JSON.toJSONString(securityMap)); + } + macroLibraries.put("appId", CoEConstant.APP_ID); + macroLibraries.put("userId", super.getContext().getUID()); + macroLibraries.put("readonly", model.isPublish()); + return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.level.upfile.portal.htm", macroLibraries); + } + + + /*** + * + * 获取流程属性信息 + * @param uuid + * @param uc + * @param methodId + * @return + */ + public String processlevelGetPerformance(String uuid,UserContext uc,String methodId){ + + ResponseObject ro = ResponseObject.newOkResponse(); + //如果点击跳转绩效模型执行获取来自跳转模型的数据,并获取名称 + if(methodId.equals("control.kpi")){ + + PALRepositoryModel palModel = PALRepositoryCache.getCache().get(uuid); + + List data=new ArrayList<>(); + String ext2=palModel.getExt2(); + + if(UtilString.isNotEmpty(ext2)){ + List datalist=Arrays.asList(ext2.substring(1,ext2.length()-1).split(",")); + + + String parentId=datalist.get(1).toString(); + + Map> methodAttrsMap = new HashMap<>();// 属性存储 + + Map methodValueAttrsMap = new HashMap<>();// 属性存储 + + PALRepositoryModel parentpalModel = PALRepositoryCache.getCache().get(parentId.trim()); + + //获取流程文件属性中L1/L2/L3 流程名称,流程编号数据用于填充绩效模型数据 + PALRepositoryPropertyDao repositoryPropertyDao = new PALRepositoryPropertyDao(); + List oldPropertyList = repositoryPropertyDao.getPropertysByPlid(parentId.trim(), ""); + List newPropertyList = new ArrayList(); + if (oldPropertyList != null && oldPropertyList.size() > 0) { + for (PALRepositoryPropertyModel propertyModel : oldPropertyList) { + if(propertyModel.getPropertyId().equals("Process_Architecture_L1")){ + methodValueAttrsMap.put(propertyModel.getPropertyId(),propertyModel.getPropertyValue()); + } + if(propertyModel.getPropertyId().equals("Process_Architecture_L2")){ + methodValueAttrsMap.put(propertyModel.getPropertyId(),propertyModel.getPropertyValue()); + } + if(propertyModel.getPropertyId().equals("Process_Architecture_L3")){ + methodValueAttrsMap.put(propertyModel.getPropertyId(),propertyModel.getPropertyValue()); + } + } + } + + methodValueAttrsMap.put("Associated_process_name",parentpalModel.getName()); + + ro.put("methodValueAttrsMap",methodValueAttrsMap); + }else{ + ro.put("methodValueAttrsMap",""); + } + + + + }else{ + ro.put("methodValueAttrsMap",""); + } + + return ro.toString(); + } + + + + + public String addUpFile(String pl_uuid, String shape_uuid, String type, String download, String fileName,String securityLevel) { + UpfileModel model = new UpfileModel(); + UpFileDao dao = new UpFileDao(); + ResponseObject r = null; + model.setUuid(UUIDGener.getUUID()); + model.setPl_uuid(pl_uuid); + model.setShape_uuid(shape_uuid); + model.setDownload("1".equals(download) ? 1 : 0); + model.setCreateUser(super.getContext().getUID()); + model.setCreateTime(new Timestamp(System.currentTimeMillis())); + if("file".equals(type)) { + model.setType("f"); + } else { + model.setType("s"); + } + // model.setFileType(fileType); + model.setFileName(fileName); + //开启三员管理 + boolean on = HighSecurityUtil.isON(); + if (on) { + if (securityLevel.equals("")) { + //删除tmp目录数据 + this.removeTmpFile(model); + r = ResponseObject.newErrResponse().msg(""); + return r.toString(); + } + model.setSecurityLevel(Integer.parseInt(securityLevel)); + } + if (dao.create(model) > 0) { + if(on){ + //移动tmp文件到对应目录,删除tmp原始数据 + this.moveTmpFileToCOE(model); + } + r = ResponseObject.newOkResponse().msg(""); + r.put("uuid", model.getUuid()); + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + if ("f".equals(model.getType())) { + CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_UPLOAD, CoEOpLogConst.INFO_REPOSITORY_FILE_UPLOAD); + } else { + CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_UPLOAD, CoEOpLogConst.INFO_REPOSITORY_SHAPE_FILE_UPLOAD); + } + } + return r.toString(); + } + // 删除dc附件 + DCContext dcContext = getDCContext(model); + if (dcContext != null) { + dcContext.delete(); + } + r = ResponseObject.newErrResponse().msg(""); + return r.toString(); + } + + /** + * 设计器内批量上传附件处理 + * @param pl_uuid + * @param shape_uuid + * @param type + * @param download + * @param files + * @return + */ + public String addUpFile2(String pl_uuid, String shape_uuid, String type, String download, String files) { + JSONArray uuids = new JSONArray(); + UpFileDao dao = new UpFileDao(); + ResponseObject r = ResponseObject.newOkResponse(); + JSONArray fileArr = JSONArray.parseArray(files); + for (int i = 0; i < fileArr.size(); i++) { + JSONObject fileObj = fileArr.getJSONObject(i); + String fileName = fileObj.getString("name"); + String securityLevel = fileObj.getString("securityLevel"); + UpfileModel model = new UpfileModel(); + model.setUuid(UUIDGener.getUUID()); + model.setPl_uuid(pl_uuid); + model.setShape_uuid(shape_uuid); + model.setDownload("1".equals(download) ? 1 : 0); + model.setCreateUser(super.getContext().getUID()); + model.setCreateTime(new Timestamp(System.currentTimeMillis())); + if("file".equals(type)) { + model.setType("f"); + } else { + model.setType("s"); + } + model.setFileName(fileName); + //开启三员管理 + boolean on = HighSecurityUtil.isON(); + if (on) { + model.setSecurityLevel(Integer.parseInt(securityLevel)); + } + if (dao.create(model) > 0) { + uuids.add(model.getUuid()); + //移动tmp文件到对应目录,删除tmp原始数据 + this.moveTmpFileToCOE(model); + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + if ("f".equals(model.getType())) { + CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_UPLOAD, CoEOpLogConst.INFO_REPOSITORY_FILE_UPLOAD); + } else { + CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_UPLOAD, CoEOpLogConst.INFO_REPOSITORY_SHAPE_FILE_UPLOAD); + } + } + } + } + r.put("uuids", uuids); + return r.toString(); + } + + /** + * 删除tmp目录下对应文件 + * @param model + */ + private void removeTmpFile(UpfileModel model){ + DCContext dcContext = getTmpDCContext(model); + if (dcContext != null) { + try { + String path = dcContext.getPath(); + String fName = model.getFileName(); + String dirName = fName.substring(0, fName.lastIndexOf(".")); + String postfix = fName.substring(fName.lastIndexOf(".")); + if (!postfix.equals(".pdf")) { + UtilFile pdfFile = new UtilFile(path + dirName + ".pdf"); + if (pdfFile.exists()) { + UtilFile.removeFile(pdfFile); + } + } + UtilFile dir = new UtilFile(path + dirName); + if (dir.exists() && dir.isDirectory()) { + UtilFile.removeFile(dir); + } + dcContext.delete(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + /** + * 将tmp目录中文件移动到COE目录下,移动后删除tmp目录文件 + * @param model + */ + private void moveTmpFileToCOE(UpfileModel model){ + + DCContext tmpContext = getTmpDCContext(model); + DCContext coeContext = getDCContext(model); + if (tmpContext !=null && coeContext != null){ + String tmpPath = tmpContext.getPath(); + String coePath = coeContext.getPath(); + String fName= model.getFileName(); + try { + UtilFile.moveFile(new File(tmpPath+fName),new File(coePath+fName)); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + + /** + * 删除附件 + * + * @param uuid + * @return + */ + public String delete(String uuid) { + UpFileDao upFileDao = new UpFileDao(); + UpfileModel upfileModel = upFileDao.get(uuid); + ResponseObject r = null; + + int delete = upFileDao.delete(uuid); + if (delete > 0) { + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + if ("f".equals(upfileModel.getType())) { + CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_DELETE, CoEOpLogConst.INFO_REPOSITORY_FILE_DELETE); + } else { + CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_DELETE, CoEOpLogConst.INFO_REPOSITORY_SHAPE_FILE_DELETE); + } + } + + DCContext dcContext = getDCContext(upfileModel); + if (dcContext != null) { + try { + String path = dcContext.getPath(); + String fileName = upfileModel.getFileName(); + String dirName = fileName.substring(0, fileName.lastIndexOf(".")); + String postfix = fileName.substring(fileName.lastIndexOf(".")); + if (!postfix.equals(".pdf")) { + UtilFile pdfFile = new UtilFile(path + dirName + ".pdf"); + if (pdfFile.exists()) { + UtilFile.removeFile(pdfFile); + } + } + UtilFile dir = new UtilFile(path + dirName); + if (dir.exists() && dir.isDirectory()) { + UtilFile.removeFile(dir); + } + dcContext.delete(); + } catch (Exception e) { + e.printStackTrace(); + upFileDao.create(upfileModel); + r = ResponseObject.newErrResponse().msg(""); + return r.toDataString(); + } + r = ResponseObject.newOkResponse().msg(""); + r.put("uuid", upfileModel.getUuid()); + return r.toString(); + } + } + r = ResponseObject.newOkResponse().msg(""); + return r.toString(); + } + + /** + * 附件在线阅读 + * + * @param uuid + * @return + * @author zhangming + */ + public String readFile(String uuid) { + UserContext me = super.getContext(); + ResponseObject ro = ResponseObject.newOkResponse(); + UpFileDao upfileDao = new UpFileDao(); + UpfileModel upfileModel = upfileDao.get(uuid); + DCContext dcContext = getDCContext(upfileModel); + String fileName = upfileModel.getFileName(); + AppAPI appAPI = SDK.getAppAPI(); + if (appAPI.isActive("com.actionsoft.apps.addons.onlinedoc")) { + String support = ""; + Map params1 = new HashMap(); + params1.put("sid", me.getSessionId()); + String aslp1 = "aslp://com.actionsoft.apps.addons.onlinedoc/getSupportType"; + ResponseObject responseObject1 = appAPI.callASLP(appAPI.getAppContext(CoEConstant.APP_ID), aslp1, + params1); + if (responseObject1 != null) { + if (responseObject1.isOk()) { + if (responseObject1.toJsonObject().get("data") != null) { + support = responseObject1.toJsonObject().getJSONObject("data").optString("supportType"); + } + } else { + return ResponseObject.newErrResponse(responseObject1.getMsg()).toString(); + } + } + String suffix = fileName.substring(fileName.lastIndexOf(".") + 1); + if (support.contains(suffix)) { + String aslp = "aslp://com.actionsoft.apps.addons.onlinedoc/filePreview"; + Map params = new HashMap(); + params.put("sid", me.getSessionId()); + params.put("fileNameOriginal", fileName); + // 文件DC + params.put("sourceDc", dcContext); + params.put("isShowDefaultToolbar", true); + params.put("isCopy", true); + params.put("isPrint", true); + //download权限判断依据:1.支持下载 + if(upfileModel.getDownload() == 1) { + params.put("isDownload", true); + } else { + params.put("isDownload", false); + } + params.put("isShowBackbtn", false); + // 文件是否加密(为了解决存储模型附件组件有一个是否加密属性) + params.put("isEncrypt", false); + ResponseObject responseObject = appAPI.callASLP(appAPI.getAppContext(CoEConstant.APP_ID), aslp, + params); + if (responseObject != null) { + if (responseObject.isOk()) { + String url = responseObject.get("url").toString(); + ro.put("url", url); + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + if ("f".equals(upfileModel.getType())) { + CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_ACCESS, CoEOpLogConst.INFO_REPOSITORY_FILE_ACCESS); + } else { + CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_ACCESS, CoEOpLogConst.INFO_REPOSITORY_SHAPE_FILE_ACCESS); + } + } + + } else { + ro = ResponseObject.newErrResponse(responseObject.getMsg()); + } + } + } else { + ro.put("url", dcContext.getDownloadURL()); + ro.put("noSupport", true); + } + } else { + ro = ResponseObject.newErrResponse("文档转换服务不可用"); + } + return ro.toString(); + } + + + + + /** + * 压缩附件下载功能 + * + * @return + * @author zhaolei + */ + public String readZipFileDownLoad(String splitId,String toolbarname,String taskId,String methodId) throws Exception { + UserContext me = super.getContext(); + ResponseObject ro = ResponseObject.newOkResponse(); + UpFileDao upfileDao = new UpFileDao(); + + try { + long times = System.currentTimeMillis(); + final String zipName = toolbarname + ".zip"; + String targetDir = AWSServerConf.getProperty("dc.path") + File.separator + "com.actionsoft.apps.coe.pal" + File.separator + "tmp/grouppackage/zip" + times + "/"; + File targetFileDir = new File(targetDir); + if (!targetFileDir.exists()) { + targetFileDir.mkdirs(); + } + if (UtilString.isNotEmpty(splitId)){ + + // 查找对应应用下模版 + String[] uuidSpilt=splitId.split(","); + if(uuidSpilt.length>0){ + for(String oneuuid:uuidSpilt){ + UpfileModel upfileModel = upfileDao.get(oneuuid); + DCContext dcContext = getDCContext(upfileModel); + File targetFile = new File(targetDir + dcContext.getFileName()); + if (!targetFile.exists()) { + targetFile.createNewFile(); + } + OutputStream out = new FileOutputStream(targetFile); + InputStream in = DCUtil.decryptFile(dcContext); + if (in == null) { + String msg = "+ dcContext.getFileName() + "; + if (dcContext.getDCMessage() != null) { + msg = dcContext.getDCMessage().getMessage(); + } + return ResponseObject.newErrResponse(msg).toString(); + } + try { + IOUtils.copy(in, out); + in.close(); + out.close(); + } finally { + IOUtils.closeQuietly(in); + IOUtils.closeQuietly(out); + } + + } + } + + } + + + //流程手册打包 + if (UtilString.isNotEmpty(taskId)) { + + OutputTaskModel model = new OutputTask().getTaskReportById(taskId); + if (model != null) { + try { + UtilFile file = OutputAPIManager.getInstance().getFilePath(model.getWsId(), taskId, model.getProfileId()); + if (file.exists()) { + File[] fileList = file.listFiles(); + if (fileList.length > 0) { + File docFile = null; + for (File file2 : fileList) { + if (file2.isFile() && "doc".equals((file2.getName().substring(file2.getName().lastIndexOf(".") + 1)))) { + docFile = file2; + break; + } + } + if (docFile == null) { + return ResponseObject.newErrResponse("没有找到文件").toString(); + } + + String sourceAppId = null; + if (methodId.equals("data.form")) { + sourceAppId = "com.awspaas.user.apps.coe.pal.output.bd"; + } + if (methodId.indexOf("process.") > -1) { + sourceAppId="com.actionsoft.apps.coe.pal.output.pr"; + } + if (methodId.equals("control.policy")) { + sourceAppId = "com.awspaas.user.apps.coe.pal.output.zd"; + } + String filename = docFile.getName(); + DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, model.getWsId(), taskId, filename); + + File targetFile = new File(targetDir + filename); + if (!targetFile.exists()) { + targetFile.createNewFile(); + } + OutputStream out = new FileOutputStream(targetFile); + InputStream in = DCUtil.decryptFile(sourceDc); + if (in == null) { + String msg = "+ dcContext.getFileName() + "; + if (sourceDc.getDCMessage() != null) { + msg = sourceDc.getDCMessage().getMessage(); + } + return ResponseObject.newErrResponse(msg).toString(); + } + try { + IOUtils.copy(in, out); + in.close(); + out.close(); + } finally { + IOUtils.closeQuietly(in); + IOUtils.closeQuietly(out); + } + + } + } + } catch (Exception e) { + e.printStackTrace(); + return ResponseObject.newErrResponse().toString(); + } + } + + + } + + + UtilFile.zipCompress(targetDir, new File(targetDir + zipName)); + + File[] files = targetFileDir.listFiles(new FilenameFilter() + { + @Override + public boolean accept(File dir, String name) { + if (name.equals(zipName)) { + return false; + } + return true; + } + }); + for (File file : files) { + try { + file.delete(); + } catch (Exception exception) {} + } + + DCContext zipDcContext = new DCContext(getContext(), DCProfileManager.getDCProfile("com.actionsoft.apps.coe.pal", "tmp"), "com.actionsoft.apps.coe.pal", "grouppackage", "zip" + times, zipName); + + String downUrl=SDK.getConfAPI().getPortalUrl() + "/r/" + zipDcContext.getDownloadURL().replace("./", ""); + ro.put("url",downUrl); + return ro.toString(); + + } catch (Exception e) { + e.printStackTrace(); + return ResponseObject.newErrResponse((e.getMessage() == null) ? e.getCause().getMessage() : e.getMessage()).toString(); + } + + } + + + + + + /** + * 单个附件下载 + * + * @return + * @author zhaolei + */ + public String coePALProcessSingleFileDownload(String fileId) throws Exception { + ResponseObject ro = ResponseObject.newOkResponse(); + UpFileDao upfileDao = new UpFileDao(); + UpfileModel upfileModel = upfileDao.get(fileId); + DCContext dcContext = getDCContext(upfileModel); + + String downUrl=SDK.getConfAPI().getPortalUrl() + "/r/" + dcContext.getDownloadURL().replace("./", ""); + ro.put("url",downUrl); + return ro.toString(); + } + + public String coePALProcessManualLogData(String ruuid) throws Exception { + ResponseObject ro = ResponseObject.newOkResponse(); + BO outputreportBO=SDK.getBOAPI().query("BO_EU_PAL_OUTPUTREPORT").addQuery("PLID=",ruuid).addQuery("RESULT=","手册转换成功!").detail(); + System.out.println("outputreportBO========="+outputreportBO); + if(outputreportBO!=null){ + Map map=new HashMap<>(); + map.put("taskId",outputreportBO.getString("TASKID")); + map.put("plname",outputreportBO.getString("PLNAME")); + ro.put("resultMap",map); + } + return ro.toString(); + } + + + + + /** + * 流程报告模版下载 + * @param appId + * @param templates + * @return + */ + /*public String downloadOutPutReportTemplates(String appId, String templates) { + ResponseObject checkRo = checkAppStatus(appId); + if (checkRo.isErr()) { + return checkRo.toString(); + } + AppContext appContext = SDK.getAppAPI().getAppContext(appId); + String path = appContext.getPath(); + String msg = "模型为空无法下载,请联系系统管理员"; + if (UtilString.isEmpty(templates)) { + return ResponseObject.newErrResponse(msg).toString(); + } + ResponseObject ro = null; + // 查找对应应用下模版 + List files = new ArrayList<>(); + JSONArray templatesArr = JSONArray.parseArray(templates); + if (templatesArr == null || templatesArr.size() == 0) { + return ResponseObject.newErrResponse(msg).toString(); + } + for (Object object : templatesArr) { + String template = (String) object; + if (UtilString.isEmpty(template)) { + return ResponseObject.newErrResponse(msg).toString(); + } + UtilFile file = new UtilFile(path + File.separator + template); + if (file.exists()) { + files.add(file); + } + } + String outputAppId = CoEConstant.APP_ID; + String groupValue = "outputTemplate"; + String dirName = files.get(0).getName(); + dirName = dirName.substring(0, dirName.lastIndexOf(".")); + String fileValue = "download" + System.currentTimeMillis(); + + DCContext dcContext = DCUtil.createTempFileContext(outputAppId, groupValue, fileValue, null); + try { + for (UtilFile sourceFile : files) { + UtilFile.copyFile(sourceFile, new UtilFile(dcContext.getPath() + File.separator + sourceFile.getName())); + } + // 创建压缩包 + DCContext dcContext2 = DCUtil.createTempFileContext(outputAppId, groupValue, fileValue + "_zip", "zip"); + dcContext2.setFileName(dirName+ ".zip"); + File ff = new File(dcContext2.getFilePath()); + File f = new File(dcContext.getPath()); + UtilFile.zipCompress(f.getPath(), ff); + dcContext2.setSession(_uc); + ro = ResponseObject.newOkResponse(); + JSONObject json = new JSONObject(); + json.put("url", dcContext2.getDownloadURL()); + ro.setData(json); + return ro.toString(); + } catch (Exception e) { + e.printStackTrace(); + } + return ResponseObject.newErrResponse("下载失败").toString(); + }*/ + + + /** + * 加载附件 + * + * @param pl_uuid + * @param shape_uuid + * @param type + * @return + */ + public String loadUpFiles(String pl_uuid, String shape_uuid, String type, String uuids, String wsId, String teamId) { + StringBuffer sqlWhere = new StringBuffer(); + UpFileDao upFileDao = new UpFileDao(); + if ("file".equals(type)) { + type = "f"; + sqlWhere.append(" and PALREPOSITORYID ='").append(pl_uuid).append("' and FILETYPE='").append(type) + .append("'"); + } else { + if ("".equals(uuids)) { + return ""; + } + String[] split = uuids.split(","); + sqlWhere.append(" and PALREPOSITORYID ='").append(pl_uuid).append("' AND SHAPEID IN ("); + for (int i = 0, size = split.length; i < size; i++) { + if (i == size - 1) { + sqlWhere.append("'").append(split[i]).append("'"); + break; + } + sqlWhere.append("'").append(split[i]).append("'").append(","); + } + sqlWhere.append(")"); + } + List search = upFileDao.search(sqlWhere.toString()); + //三员管理模式下,过滤文件密级高于用户密级不显示 + if(HighSecurityUtil.isON()){ + PALRepositoryQueryAPIManager.getInstance().upFileSecurityFilter(this._uc,search); + } + ResponseObject ro = ResponseObject.newOkResponse(); + JSONArray list = new JSONArray(); + if (search != null && search.size() > 0) { + for (UpfileModel model : search) { + JSONObject object = JSONObject.parseObject(JSON.toJSONString(model)); + String downloadURL = ""; + DCContext dcContext = getDCContext(model); + if (dcContext != null) { + downloadURL = dcContext.getDownloadURL() + "&isInline=false"; + } + object.put("url", downloadURL); + list.add(object); + } + } + ro.put("list", list); + CoeCooperationAPIManager.getInstance().queryCooperationMemberActionPerm(teamId, _uc.getUID(), ro); + PALRepositoryQueryAPIManager.getInstance().checkHighSecurity(pl_uuid,ro); + return ro.toString(); + } + + /** + * 三员管理加载全部附件,包含未标密 + * @param pl_uuid + * @param shape_uuid + * @param type + * @param uuids + * @param wsId + * @param teamId + * @return + */ + public String loadUpFilesAll(String pl_uuid, String shape_uuid, String type, String uuids, String wsId, String teamId) { + StringBuffer sqlWhere = new StringBuffer(); + UpFileDao upFileDao = new UpFileDao(); + //获取最新version 流程 + PALRepositoryModel versionModel = null; + List repositoryModels = PALRepositoryCache.getByVersionId(wsId, pl_uuid); + for (PALRepositoryModel model:repositoryModels){ + if (model.isUse()){ + versionModel = model; + } + } + if ("file".equals(type)) { + sqlWhere.append(" and PALREPOSITORYID ='").append(null == versionModel?pl_uuid:versionModel.getId()).append("'"); + } else { + if ("".equals(uuids)) { + return ""; + } + String[] split = uuids.split(","); + sqlWhere.append(" and PALREPOSITORYID ='").append(null == versionModel?pl_uuid:versionModel.getId()).append("' AND SHAPEID IN ("); + for (int i = 0, size = split.length; i < size; i++) { + if (i == size - 1) { + sqlWhere.append("'").append(split[i]).append("'"); + break; + } + sqlWhere.append("'").append(split[i]).append("'").append(","); + } + sqlWhere.append(")"); + } + List search = upFileDao.search(sqlWhere.toString()); + //三员管理模式下,过滤文件密级高于用户密级不显示 + if(HighSecurityUtil.isON()){ + PALRepositoryQueryAPIManager.getInstance().upFileSecurityUnmarkFilter(this._uc,search); + } + ResponseObject ro = ResponseObject.newOkResponse(); + JSONArray upfileList = new JSONArray(); + JSONArray shapeList = new JSONArray(); + if (search != null && search.size() > 0) { + for (UpfileModel model : search) { + JSONObject object = JSONObject.parseObject(JSON.toJSONString(model)); + String downloadURL = ""; + DCContext dcContext = getDCContext(model); + if (dcContext != null) { + downloadURL = dcContext.getDownloadURL() + "&isInline=false"; + } + object.put("url", downloadURL); + if (object.get("type").equals("f")){ + upfileList.add(object); + }else { + shapeList.add(object); + } + } + } + ro.put("upfileList", upfileList); + ro.put("shapeList", shapeList); + PALRepositoryQueryAPIManager.getInstance().checkHighSecurity(pl_uuid,ro); + return ro.toString(); + } + + /** + * 三员管理下更新附件密级 + * @param pl_uuid + * @param securityLevel + * @return + */ + public String updateUpFileSecurityLevel(String pl_uuid,String securityLevel){ + ResponseObject ro = null; + if (!HighSecurityUtil.isON()){ + ro = ResponseObject.newErrResponse().msg(""); + return ro.toString(); + } + UpfileModel model = new UpfileModel(); + model.setUuid(pl_uuid); + model.setSecurityLevel(Integer.parseInt(securityLevel)); + int update = new UpFileDao().update(model); + if (update>0){ + //更新成功 + ro = ResponseObject.newOkResponse(); + ro.put("updateNum",update); + return ro.toString(); + } + ro = ResponseObject.newErrResponse().msg(""); + return ro.toString(); + } + + /** + * 三员管理下获取第一个未标定密级文件所在树中path + * @param wsId + * @param teamId + * @return + */ + public String getUpfileUnmarkPath(String wsId,String teamId){ + ResponseObject ro = ResponseObject.newOkResponse(); + + if (!HighSecurityUtil.isON()){ + ro = ResponseObject.newErrResponse().msg("三员管理应用未开启"); + return ro.toString(); + } + + //小组权限 + Set versionIds = CoeProcessLevelUtil.getPermRepositoryVersionIds(wsId, teamId, _uc.getUID(), null, null); + + //获取目标model + PALRepositoryModel targetModel = this.findUpfileUnmarkModel(versionIds,wsId,teamId); + + // 获取文件路径 + List path = new ArrayList<>(); + if (null == targetModel) { + ro.put("path",path.toArray()); + return ro.toString(); + } + JSONArray repositoryPathData = CoeProcessLevelUtil.getRepositoryPath(targetModel.getId()); + // 前面大类不显示,根据小组进行级别处理 + for (int i = 0; i < repositoryPathData.size(); i++) { + JSONObject currObj = repositoryPathData.getJSONObject(i); + PALRepositoryModel currModel = PALRepositoryCache.getCache().get(currObj.getString("id")); + if (currModel != null && versionIds.contains(currModel.getVersionId())) { + path.add(currModel.getVersionId()); + } else if (currObj.getString("id").length() < 36) { + path.add(currObj.getString("id")); + } + } + + ro.put("path",path.toArray()); + return ro.toString(); + } + + /** + * 获取流程树中第一个附件未标密文件的流程文件model + * @param versionIds 小组权限下的流程文件uuid + * @param wsId + * @param teamId + * @return + */ + public PALRepositoryModel findUpfileUnmarkModel(Set versionIds,String wsId,String teamId){ + //获取资产库下所有流程 + List list = PALRepositoryQueryAPIManager.getInstance().getInuseRepositoryList(versionIds, wsId, teamId); + + PALRepositoryModel targetModel = null; + for (PALRepositoryModel model : list){ + //查询附件 是否存在未标定密级 + boolean flag = PALRepositoryQueryAPIManager.getInstance().checkUpfileSecurity(model); + if(flag){ + targetModel = model; + break; + } + } + return targetModel; + } + + + + + + /** + * 拼接文件名 + * + * @param model + * @return + */ + public String joinFileName(UpfileModel model) { + StringBuffer a = new StringBuffer(); + String downloadURL = ""; + String imgs = "*.jpg,*.jpeg,.gif,*.png,*.bmp";// 图片后缀 + String docs = "*.docs,*.docx";// doc文件 + String txt = ".txt"; + if (imgs.lastIndexOf(model.getFileName()) != -1) { + } else if (docs.lastIndexOf(model.getFileName()) != -1) { + } else if (txt.lastIndexOf(model.getFileName()) != -1) { + } else { + + } + // .append("") + DCContext dcContext = getDCContext(model); + if (dcContext != null) { + downloadURL = dcContext.getDownloadURL(); + } + a.append("").append(model.getFileName()).append(""); + return a.toString(); + } + + /** + * 获取dccontext + * + * @param model + * @return + */ + public DCContext getDCContext(UpfileModel model) { + DCContext dcContext = null; + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); + if (dcProfile != null) { + if ("f".equals(model.getType())) {// 文件 + dcContext = new DCContext(super.getContext(), dcProfile, CoEConstant.APP_ID, "file", + model.getPl_uuid(), model.getFileName()); + } else {// 图形 + dcContext = new DCContext(super.getContext(), dcProfile, CoEConstant.APP_ID, model.getPl_uuid(), + model.getShape_uuid(), model.getFileName()); + } + } + return dcContext; + } + + /** + * 获取tmp目录对应DCContext + * @param model + * @return + */ + public DCContext getTmpDCContext(UpfileModel model){ + DCContext dcContext = null; + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.TMP_UPFILE); + if (dcProfile != null) { + if ("f".equals(model.getType())) {// 文件 + dcContext = new DCContext(super.getContext(), dcProfile, CoEConstant.APP_ID, "file", + model.getPl_uuid(), model.getFileName()); + } else {// 图形 + dcContext = new DCContext(super.getContext(), dcProfile, CoEConstant.APP_ID, model.getPl_uuid(), + model.getShape_uuid(), model.getFileName()); + } + } + return dcContext; + } + + /** + * 加载关联附件 + * + * @param uuid 模型Id + * @param shapeId 图形Id + * @param type file/shape(模型附件还是图形附件) + * @return + */ + public String loadRelationUpfiles(String uuid, String shapeId, String type) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONArray result = new JSONArray(); + // 获取属性的关联类型(relationType) + Map relationTypeMap = new HashMap<>(); + PALRepositoryModel m = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + PALMethodModel palMethodModel = PALMethodCache.getPALMethodModelById(m.getMethodId()); + if (palMethodModel != null) { + List attributes = palMethodModel.getAttributes(); + for (PALMethodAttributeModel model : attributes) { + String relationType = "shape"; + if ("relation".equals(model.getType())) { + JSONObject refObj = JSONObject.parseObject(model.getRef()); + relationType = refObj.containsKey("type") ? refObj.getString("type") : "shape"; + } + relationTypeMap.put(model.getKey(), relationType); + } + } + if (UtilString.isEmpty(shapeId) || "file".equals(type)) { + shapeId = ""; + } + Iterator iterator = DesignerShapeRelationCache.getByShapeId(uuid, shapeId); + List list = new ArrayList<>(); + UpFileDao dao = new UpFileDao(); + while (iterator.hasNext()) { + DesignerShapeRelationModel model = iterator.next(); + if (relationTypeMap.containsKey(model.getAttrId())) { + if("file".equals(relationTypeMap.get(model.getAttrId()))) {// 文件 + String versionId = model.getRelationFileId(); + PALRepositoryModel palModel = CoeProcessLevelUtil.getUseRepositoryByVersionId(versionId);// 获取工作版本 + if (palModel != null) { + // 文件:根据relationFileId 和 文件类型 查询 + List list2 = dao.search(palModel.getId(), null, type); + if (list2 != null && list2.size() > 0) { + list.addAll(list2); + } + } + } else {// 形状 + //形状:根据relationFileId 和 relationShapeId 查询 + List list2 = dao.search(model.getRelationFileId(), model.getRelationShapeId(), null); + if (list2 != null && list2.size() > 0) { + list.addAll(list2); + } + } + } + } + //三员管理模式过滤关联附件的密级显示 + if(HighSecurityUtil.isON()){ + PALRepositoryQueryAPIManager.getInstance().upFileSecurityFilter(this._uc,list); + } + Map upfileMap = new HashMap(); + if (list != null && list.size() > 0) { + Collections.sort(list, new Comparator() { + @Override + public int compare(UpfileModel o1, UpfileModel o2) { + return o2.getCreateTime().compareTo(o1.getCreateTime()); + } + }); + for (UpfileModel model : list) { + JSONObject object = JSONObject.parseObject(JSON.toJSONString(model)); + PALRepositoryModel palModel = PALRepositoryCache.getCache().get(model.getPl_uuid()); + if (palModel != null) { + object.put("modelName", palModel.getName()); + String downloadURL = ""; + DCContext dcContext = getDCContext(model); + if (dcContext != null) { + downloadURL = dcContext.getDownloadURL(); + } + object.put("url", downloadURL); + if (upfileMap.containsKey(model.getUuid())) { + continue; + } else { + result.add(object); + upfileMap.put(model.getUuid(), model.getUuid()); + } + } + } + } + ro.put("list", result); + PALRepositoryQueryAPIManager.getInstance().checkHighSecurity(uuid,ro); + return ro.toString(); + } + + /** + * 删除附件 + * + * @param uuid + * @param messages + */ + public void deleteShapeFile(String uuid, String messages) { + StringBuffer sb = new StringBuffer(); + JSONObject mesageObject = JSONObject.parseObject(messages); + Iterator iterator = mesageObject.keySet().iterator(); + while (iterator.hasNext()) { + String shapeId = iterator.next(); + JSONObject shape = JSONObject.parseObject(mesageObject.getString(shapeId)); + if ("remove".equals(shape.getString("action"))) { + sb.append("'").append(shapeId).append("'").append(","); + } + } + if (sb.length() > 0) { + String shapes = sb.substring(0, sb.length() - 1); + UpFileDao dao = new UpFileDao(); + String sqlWhere = " and " + UpfileModel.FIELD_PL_UUID + "='" + uuid + "' and " + + UpfileModel.FIELD_SHAPE_UUID + " in (" + shapes + ")"; + List list = dao.search(sqlWhere); + if (!UtilString.isEmpty(list)) { + int delete = dao.deleteByShape(sqlWhere); + if (delete > 0) { + for (UpfileModel model : list) { + DCContext dcContext = getDCContext(model); + if (dcContext != null) { + try { + String path = dcContext.getPath(); + String fileName = model.getFileName(); + String dirName = fileName.substring(0, fileName.lastIndexOf(".")); + String postfix = fileName.substring(fileName.lastIndexOf(".")); + if (!postfix.equals(".pdf")) { + UtilFile pdfFile = new UtilFile(path + dirName + ".pdf"); + if (pdfFile.exists()) { + UtilFile.removeFile(pdfFile); + } + } + UtilFile dir = new UtilFile(path + dirName); + if (dir.exists() && dir.isDirectory()) { + UtilFile.removeFile(dir); + } + dcContext.delete(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } + } + } + + /** + * 图形粘贴时附件的处理 + * + * @param shapeMap + * @return + */ + public String pasteShapeFile(String shapeMap, String userId) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONArray array = JSONArray.parseArray(shapeMap); + if (!array.isEmpty()) { + UpFileDao dao = new UpFileDao(); + DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE); + if (dcProfile == null) { + return ro.toString(); + } + for (int i = 0; i < array.size(); i++) { + JSONObject object = array.getJSONObject(i); + String copyShapeId = object.getString("copyShapeId"); + String pasteFileId = object.getString("pasteFileId"); + String pasteShapeId = object.getString("pasteShapeId"); + String sqlWhere = " and " + UpfileModel.FIELD_SHAPE_UUID + "='" + copyShapeId + "'" + " and " + UpfileModel.FIELD_TYPE + "='s' "; + List list = dao.search(sqlWhere); + if (list != null && list.size() > 0) { + List pasteList = new ArrayList<>(); + for (UpfileModel model : list) { + // 找到附件 + DCContext dcContext = getDCContext(model); + DCContext pasteDcContxt = new DCContext(super.getContext(), dcProfile, CoEConstant.APP_ID, pasteFileId, pasteShapeId, model.getFileName()); + if (dcContext != null && pasteDcContxt != null) { + if (DCUtil.copyDCFile(dcContext, pasteDcContxt)) { + // 更新数据库 + UpfileModel newModel = new UpfileModel(); + newModel.setUuid(UUIDGener.getUUID()); + newModel.setType(model.getType()); + newModel.setShape_uuid(pasteShapeId); + newModel.setPl_uuid(pasteFileId); + newModel.setFileName(model.getFileName()); + newModel.setDownload(model.getDownload()); + newModel.setCreateUser(userId); + newModel.setCreateTime(new Timestamp(System.currentTimeMillis())); + pasteList.add(newModel); + } else { + pasteDcContxt.delete(); + } + } + } + if (pasteList.size() > 0) { + dao.batchInsert(pasteList); + } + } + } + } + return ro.toString(); + } +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/webapi/WorkFlowAPI.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/webapi/WorkFlowAPI.java new file mode 100644 index 00000000..03ec1d1c --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/webapi/WorkFlowAPI.java @@ -0,0 +1,276 @@ +package com.awspaas.user.apps.integration.webapi; + +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.org.model.UserModel; +import com.actionsoft.bpms.server.bind.annotation.Controller; +import com.actionsoft.bpms.server.bind.annotation.HandlerType; +import com.actionsoft.bpms.server.bind.annotation.Mapping; +import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.sdk.local.SDK; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.awspaas.user.apps.integration.util.UtilUrl; +import com.google.common.reflect.TypeToken; +import com.google.gson.Gson; +import com.google.gson.JsonSyntaxException; +import org.apache.commons.lang.StringUtils; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; + + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + + +@Controller(type = HandlerType.RESTFUL, apiName = "workfolwapi", desc = "这是workflow的相关接口文档") +@Path("/workfolw") +public class WorkFlowAPI { + + @GET + public String sayHello() { + return "hello,world! - get"; + } + + @POST + public String sayHelloPost() { + return "hello,world!- post "; + } + + + /** + * 获取activiti流程信息 + * @return activiti流程信息 + * @throws DocumentException + * @throws ParseException + */ + @Path("/process/history/getProcessByProcessDefId") + @POST + public String getProcessByProcessDefId() throws DocumentException, ParseException { + System.out.println("12312313312"); + //return "{\"code\":\"1\",\"msg\":\"success\",\"body\":[{\"processInstanceId\":\"17253376\",\"processDefinitionId\":\"747487\",\"startUserId\":\"00107759\",\"durationInMillis\":7199,\"processDefinitionName\":\"组织主数据维护流程\",\"startTime\":\"2021-04-03 16:24:03\",\"endTime\":\"2021-04-08 16:24:00\",\"processDefinitionVersion\":\"4\"}]}"; + System.out.println("接口1参数===============接口进来了"); + JSONObject result = new JSONObject(new LinkedHashMap<>()); + List rowMap = DBSql.getMaps("SELECT DISTINCT WORKFLOWID FROM BO_EU_MODEL "); + + + JSONArray jsonArray_new = new JSONArray(new LinkedList<>()); + for (RowMap rowMapsw: + rowMap) { + + List list = SDK. getBOAPI().query("BO_EU_PROCESS_NEW").addQuery("WORKFLOWID=", rowMapsw.getString("WORKFLOWID")).list(); + for (int i=0;i()); + System.out.println("接口2参数===============接口进来了"); + + + + /*JSONObject jsonObject = new JSONObject(new LinkedHashMap()); + jsonObject.put("workflowId",747487); + //jsonObject.put("createDateStart","2019-07-01 00:00:00");//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo() + //jsonObject.put("createDateEnd","2023-09-01 00:00:00");//processExecutionContext.getProcessInstance().getCreateUser() + jsonObject.put("pageIndex",1); + jsonObject.put("pageSize",3000); + String xmlStr = "\n" + + " " + + " " + + " " + + " " + + ""+jsonObject+""+ + " " + + " " + + " " + + ""; + + System.out.println("参数==============="+xmlStr); + //System.out.println("参数==============="+xmls); + //HttpClientUtil httpClientUtil = new HttpClientUtil(); + int timeout = 600000; + // HttpURLConnection 发送SOAP请求 + System.out.println("HttpURLConnection 发送SOAP请求"); + + String postSoap = UtilUrl.doPostSoap("http://10.119.22.207:80/services/WorkflowService", xmlStr, ""); + + + Document document = DocumentHelper.parseText(postSoap); + Element rootElement = document.getRootElement(); + System.out.println("rootElement>>>>>>"+rootElement); + Element results = rootElement.element("Body").element("getFlowListByWfIdResponse").element("out"); + String resultString = results.getData().toString(); + System.out.println("resultString=>>>>>>>>>>"+resultString); + JSONObject jsonObject1 = JSON.parseObject(resultString); + String datas = jsonObject1.getString("datas"); + JSONArray jsonArrays = JSONArray.parseArray(datas); + + System.out.println("jsonArrayData》》》》》》》》》》》》"+jsonArrays);*/ + List rowMap = DBSql.getMaps("SELECT DISTINCT WORKFLOWID FROM BO_EU_OA_PROCESS_TASK"); + + + JSONArray jsonArray_new = new JSONArray(new LinkedList<>()); + for (RowMap rowMapsw: + rowMap) { + + List list = SDK. getBOAPI().query("BO_EU_OA_PROCESS_TASK").addQuery("WORKFLOWID=", rowMapsw.getString("WORKFLOWID")).list(); + + for (int i = 0; i < list.size(); i++) { + if (SDK.getORGAPI().getUser(list.get(i).getString("OPERATORWORKCODE")) != null) { + JSONObject jsonObject2 = new JSONObject(); + jsonObject2.put("id", list.get(i).getString("TASKID")); + // String node_key = JSONObject.parseObject(jsonArrays.get(i).toString()).get("nodeid").toString(); + jsonObject2.put("taskDefinitionKey", list.get(i).getString("NODEID")); + jsonObject2.put("processInstanceId", list.get(i).getString("REQUESTID")); + jsonObject2.put("processDefinitionId", list.get(i).getString("WORKFLOWID")); + jsonObject2.put("name", list.get(i).getString("NODENAME")); + jsonObject2.put("assignee", list.get(i).getString("OPERATORWORKCODE")); + if (SDK.getORGAPI().getCompanyByUser(list.get(i).getString("OPERATORWORKCODE")) != null) { + jsonObject2.put("TARGETCOMPANYID", SDK.getORGAPI().getCompanyByUser(list.get(i).getString("OPERATORWORKCODE")).getId()); + } + //String user = JSONObject.parseObject(jsonArrays.get(i).toString()).get("operatorWorkCode").toString(); + System.out.println("user>>>>>>>" + list.get(i).getString("OPERATORWORKCODE")); + UserModel model = SDK.getORGAPI().getUser(list.get(i).getString("OPERATORWORKCODE")); + System.out.println("model>>>>>>>>>>" + model); + if (model != null) { + jsonObject2.put("assigneeDeptId", model.getDepartmentId()); + jsonObject2.put("assigneeRoleId", model.getRoleId()); + } else { + jsonObject2.put("assigneeDeptId", "a93a7f77-8b11-4261-8770-20b0cdfab315"); + jsonObject2.put("WARNINGTIMEDURRoleId", "d102c89d-55f3-4865-9d5c-c00b7f47b803"); + } + + + jsonObject2.put("actionName", list.get(i).getString("OPERATETYPE")); + jsonObject2.put("startTime", list.get(i).getString("OPERATEDATE")); + jsonObject2.put("endTime", list.get(i).getString("RECEIVEDATE")); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date beginDate = sdf.parse(list.get(i).getString("OPERATEDATE")); + Date endDate = sdf.parse(list.get(i).getString("RECEIVEDATE")); + long dates = (endDate.getTime() - beginDate.getTime()) / (1000 * 60); + jsonObject2.put("durationInMillis", dates); + jsonArray_new.add(jsonObject2); + } + } + } + + result.put("code","1"); + result.put("msg","success"); + result.put("body",jsonArray_new); + return result.toString(); + } + + @Path("/task/history/getTaskNodesByProcessDefId") + @POST + public String getTaskNodesByProcessDefId() throws DocumentException { + JSONObject result = new JSONObject(new LinkedHashMap<>()); + JSONObject jsonObject_newe = new JSONObject(new LinkedHashMap<>()); + JSONArray jsonArray = new JSONArray(new LinkedList<>()); + System.out.println("接口3参数===============接口进来了"); + List rowMap = DBSql.getMaps("SELECT DISTINCT WORKFLOWID FROM BO_EU_PROCESS_NEW "); + + for (RowMap rowMapsw: + rowMap) { + System.out.println("接口中的流程定义id>>>>>>>>>>>>"+rowMapsw.getString("WORKFLOWID")); + JSONObject jsonObject = new JSONObject(new LinkedHashMap<>()); + BO lists = SDK. getBOAPI().query("BO_EU_TASKNODES").addQuery("WORKFLOWID=", rowMapsw.getString("WORKFLOWID")).orderBy("REQUESTID").asc().list().get(0); + BO bo_new = SDK. getBOAPI().query("BO_EU_PROCESS_NEW").addQuery("REQUESTID=", lists.getString("REQUESTID")).detail(); + jsonObject.put("processName",bo_new.getString("WORKFLOWNAME")); + jsonObject.put("category",bo_new.getString("WORKFLOWTYPE_OA")); + BO bos = SDK.getBOAPI().query("BO_EU_OA_PROCESS", true).addQuery("WORKFLOWID=", rowMapsw.getString("WORKFLOWID")).detail(); + if (bos.getString("VERSION")!=null||bos.getString("VERSION")!=""){ + jsonObject.put("version",bos.getString("VERSION")); + }else { + jsonObject.put("version","1"); + } + JSONArray jsonArray1 =new JSONArray(); + String sql = "select DISTINCT NODEID FROM BO_EU_TASKNODES where WORKFLOWID = '"+rowMapsw.getString("WORKFLOWID")+"'"; + List maps = DBSql.getMaps(sql); + for (RowMap rowMap1: + maps) { + JSONObject jsonObject1 = new JSONObject(new LinkedHashMap<>()); + jsonObject1.put("taskNo",rowMap1.getString("NODEID")); + String sql_name = "select * FROM BO_EU_TASKNODES where WORKFLOWID = '"+rowMapsw.getString("WORKFLOWID")+"' AND NODEID = '"+rowMap1.getString("NODEID")+"'"; + RowMap map = DBSql.getMap(sql_name); + jsonObject1.put("taskName",map.getString("NODENAME")); + jsonArray1.add(jsonObject1); + } + /*for (BO bo: + lists_new) { + JSONObject jsonObject1 = new JSONObject(new LinkedHashMap<>()); + jsonObject1.put("taskNo",bo.getString("NODEID")); + jsonObject1.put("taskName",bo.getString("NODENAME")); + jsonArray1.add(jsonObject1); + }*/ + jsonObject.put("taskNodesList",jsonArray1); + jsonObject_newe.put(rowMapsw.getString("WORKFLOWID"),jsonObject); + } + + + /*JSONArray jsonArray_body = new JSONArray(); + jsonArray_body.add(jsonObject_newe);*/ + result.put("code","1"); + result.put("msg","success"); + result.put("body",jsonObject_newe); + return result.toString(); + } + + + + +}