From 21330baac38296d4019f54850029d234fe11b219 Mon Sep 17 00:00:00 2001 From: Mr-wang Date: Thu, 13 Jul 2023 14:41:24 +0800 Subject: [PATCH] =?UTF-8?q?OA=E5=BE=85=E9=98=85=E7=BA=BF=E7=A8=8B=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pubEvent/ProcessEndAfterEvent_new.java | 692 +++++++++--------- 1 file changed, 364 insertions(+), 328 deletions(-) diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_new.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_new.java index 98816756..8535b96d 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_new.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_new.java @@ -1,5 +1,6 @@ package com.actionsoft.apps.coe.pal.publisher.pubEvent; +import java.sql.Connection; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -57,7 +58,7 @@ import com.alibaba.fastjson.JSONObject; /** * 流程结束后发送待阅数据 - * + * * @author wangchengye * @time 2022/11/4 */ @@ -86,35 +87,47 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute //用户点击确认发布按钮后进行触发推送任务 Boolean isConfirmRelease = SDK.getTaskAPI().isChoiceActionMenu(ext.getTaskInstance(), "确认发布"); + Connection open = DBSql.open(); + try { - if(isConfirmRelease==true){ - ProcessInstance boProcessInstance = SDK.getProcessAPI() - .createBOProcessInstance("obj_7946c848674f422fbe2817ad5d047337", ext.getUserContext().getUID(), "OA任务状态记录"); - BO executiveTaskBO=new BO(); - executiveTaskBO.set("TASKTITLE",ext.getProcessInstance().getTitle()); - executiveTaskBO.set("TASKID",ext.getProcessInstance().getId()); - executiveTaskBO.set("TASKSTATUS",1); - executiveTaskBO.set("ISTASKEND",1); - SDK.getBOAPI().create("BO_ACT_EXECUTIVE_TASK",executiveTaskBO,boProcessInstance.getId(),""); - ExecutorService service = Executors.newFixedThreadPool(1); - service.execute(new Runnable() { - @Override - public void run() { - try { - System.out.println("进入方法==============="); - ProcessData(ext); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + + if(isConfirmRelease==true){ + ProcessInstance boProcessInstance = SDK.getProcessAPI() + .createBOProcessInstance("obj_7946c848674f422fbe2817ad5d047337", ext.getUserContext().getUID(), "OA任务状态记录"); + BO executiveTaskBO=new BO(); + executiveTaskBO.set("TASKTITLE",ext.getProcessInstance().getTitle()); + executiveTaskBO.set("TASKID",ext.getProcessInstance().getId()); + executiveTaskBO.set("TASKSTATUS",1); + executiveTaskBO.set("ISTASKEND",1); + SDK.getBOAPI().create("BO_ACT_EXECUTIVE_TASK",executiveTaskBO,boProcessInstance.getId(),""); + ExecutorService service = Executors.newFixedThreadPool(1); + service.execute(new Runnable() { + @Override + public void run() { + try { + System.out.println("进入方法==============="); + ProcessData(ext,open); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } + }); + try { + service.shutdown(); + // DBSql.close(open); + }catch (Exception e){ + service.shutdown(); + //DBSql.close(open); } - }); + } + }catch (Exception e){ + e.printStackTrace(); } - } - public void ProcessData(ProcessExecutionContext processExecutionContext) throws Exception { + public void ProcessData(ProcessExecutionContext processExecutionContext,Connection open) throws Exception { System.err.println(processExecutionContext.getTaskInstance().getTitle() + "_推送文件开始========>"); // http://localhost:8089/portal/r/or?cmd=com.hy_client_bpm_form_main_page_open&oauthName=oauthLogin&processInstId=3505e654-9217-41cd-a31d-4971846b3219 /** @@ -145,7 +158,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute Timestamp endTime = new Timestamp(System.currentTimeMillis()); - BO boActCoePublish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true) + BO boActCoePublish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).connection(open) .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()) .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); @@ -184,7 +197,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute 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) + BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).connection(open) .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()) .addQuery("OPTIONTYPE IS NOT NULL", null).detail(); String crateUserId = target; @@ -194,138 +207,17 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute .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) + List bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).connection(open) .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list(); - List bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true) + List bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).connection(open) .addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list(); - List bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true) + List bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).connection(open) .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 - } - } - - /** - * 同步PAL文件表文件版本标识,用于部门视图 - */ - if(bo_act_coe_publish_n.size()>0) { - for (BO bo : bo_act_coe_publish_n) { - try { - String fileId = bo.getString("PUBLISHFILEID"); - DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '1' WHERE ID = '"+fileId+"'"); - } catch (Exception e) { - } - } - } - if(bo_act_coe_publish_c.size()>0) { - for (BO bo : bo_act_coe_publish_c) { - try { - String changefileId = bo.getString("CHANGEFILEID"); - String changefileIdNew = bo.getString("CHANGEDFILEIDNEW"); - DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '0' WHERE ID = '"+changefileId+"'"); - DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '1' WHERE ID = '"+changefileIdNew+"'"); - } catch (Exception e) { - } - } - } - - if(bo_act_coe_publish_s.size()>0) { - for (BO bo : bo_act_coe_publish_s) { - try { - String fileId = bo.getString("STOPFILEID"); - DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '0' WHERE ID = '"+fileId+"'"); - } catch (Exception e) { - } - } - } - /** - * 推送到EHSQ - */ - boolean sendEhqs = true; - String depId = processExecutionContext.getUserContext().getDepartmentModel().getId(); - //获取EHSQ配置表判断是否发送 - String sql = "SELECT * FROM BO_ACT_ACT_ESQ_SEND"; - List maps = DBSql.getMaps(sql); - for (RowMap rowMap : maps) { - String dempet = rowMap.getString("DEMPET"); - String issend = rowMap.getString("ISSEND"); - DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(dempet); - if(departmentById!=null) { - String departemenId = departmentById.getId(); - if(departemenId.equals(depId)&&"是".equals(issend)) { - sendEhqs = true; - } /* - * else { List subDepartments = - * SDK.getORGAPI().getSubDepartments(departmentById.getId()); for - * (DepartmentModel departmentModel : subDepartments) { String subDeartmentId = - * departmentModel.getId(); if(subDeartmentId.equals(depId)&&"是".equals(issend)) - * { sendEhqs = true; } } - * - * } - */ - } - } - if(!sendEhqs) { - System.err.println("本次发文不推送EHSQ====>"+processExecutionContext.getProcessInstance().getTitle()); - } - if ("true".equals(isSendEHSQ)&&sendEhqs) { - try { - // 推送EHSQ - if(bo_act_coe_publish_n.size()>0) { - sendEHSQ(processExecutionContext, bo_act_coe_publish_n); - } - // 更新EHSQ - if(bo_act_coe_publish_c.size()>0) { - updateEHSQ(processExecutionContext, bo_act_coe_publish_c); - } - } catch (Exception e) { - // TODO: handle exception - } - } - /** - * 更新数据看板底表 - */ - try { - AttrSynAslp(processExecutionContext, wsId, filed); - } catch (Exception e) { - } - /** * 推送待阅文件到OA */ @@ -364,7 +256,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute // TODO: handle exception } //System.err.println("离退人员=====>" + userList3); - List mapsl = DBSql.getMaps("SELECT * FROM ORGUSER WHERE CLOSED = '0'"); + List mapsl = DBSql.getMaps(open,"SELECT * FROM ORGUSER WHERE CLOSED = '0'"); for (RowMap rowMap : mapsl) { String userId = rowMap.getString("USERID"); // RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '" @@ -378,8 +270,8 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute // 发送组织岗位职级 sendList = getSendList(instanceById, bo_act_coe_publish1, jsonObject); } - - + + long countTime = System.currentTimeMillis(); System.err.println(instanceById.getTitle() + "待发送人员数量====>" + sendList.size() + " 计算用时===>" + (countTime - startTime) + "毫秒"); @@ -387,16 +279,16 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * for (String user : sendList) { try { SendOARead(jsonObject, instanceById, * user, "批量推送"); } catch (Exception e) { // TODO: handle exception } } */ - List bo_eu_oa_read_test = SDK.getBOAPI().query("BO_EU_OA_READ_TEST").list(); + List bo_eu_oa_read_test = SDK.getBOAPI().query("BO_EU_OA_READ_TEST").connection(open).list(); ArrayList sendLists = new ArrayList(); for (BO uid:bo_eu_oa_read_test) { - sendLists.add(uid.getString("USER_ID")); + sendLists.add(uid.getString("USER_ID")); } new_uid = new_uid.join(",", sendLists); long startTimes = System.currentTimeMillis(); String[] users = new_uid.split(","); System.out.println("new_uid>>>>>>>>>>>>>>"+users.length); - int length = 300; + int length = 100; int ys = users.length%length; /** * 这个是以300人作为一个发送单位去放到list中并发送待阅数据 @@ -409,15 +301,15 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute for (int i=0;i>>>>>>>>>>>>>"+list); }else { int size = users.length/length; @@ -425,9 +317,9 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute List list = new LinkedList(); for (int i=0;i>>>>>>>>>>>>>"+list); } @@ -490,21 +382,21 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute + (endTimes1 - startTime1) / 1000 + "秒"); *//* - * ExecutorService cachedThreadPool = Executors.newFixedThreadPool(3); // 开启一个线程 - * cachedThreadPool.execute(new Runnable() { - * - * @Override public void run() { try { } catch (DocumentException e) { // TODO - * Auto-generated catch block e.printStackTrace(); } - * - * } }); - *//* + * ExecutorService cachedThreadPool = Executors.newFixedThreadPool(3); // 开启一个线程 + * cachedThreadPool.execute(new Runnable() { + * + * @Override public void run() { try { } catch (DocumentException e) { // TODO + * Auto-generated catch block e.printStackTrace(); } + * + * } }); + *//* // 以下是等线程池的全部线程执行结束后,会自动执行。 *//* - * cachedThreadPool.shutdown(); while (true) { if - * (cachedThreadPool.isTerminated()) { long time = System.currentTimeMillis() - - * startTime; //System.out.println("程序结束了,总耗时:" + time + " ms(毫秒)!\n"+toIndex); - * break; } } - *//* + * cachedThreadPool.shutdown(); while (true) { if + * (cachedThreadPool.isTerminated()) { long time = System.currentTimeMillis() - + * startTime; //System.out.println("程序结束了,总耗时:" + time + " ms(毫秒)!\n"+toIndex); + * break; } } + *//* }*/ @@ -583,9 +475,131 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute } } - - + + /** + * 推送到知识库 + */ + 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(open,sql_s); + if (StringUtils.isNotEmpty(map1.getString("EXT4"))) { + CancelPublishKnwl(processExecutionContext, + processExecutionContext.getUserContext().getSessionId(), + map1.getString("EXT4")); + + DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '" + + publishfileid_stop + "'"); + } + } + } catch (Exception e) { + // TODO: handle exception + } + } + + /** + * 同步PAL文件表文件版本标识,用于部门视图 + */ + if(bo_act_coe_publish_n.size()>0) { + for (BO bo : bo_act_coe_publish_n) { + try { + String fileId = bo.getString("PUBLISHFILEID"); + DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '1' WHERE ID = '"+fileId+"'"); + } catch (Exception e) { + } + } + } + if(bo_act_coe_publish_c.size()>0) { + for (BO bo : bo_act_coe_publish_c) { + try { + String changefileId = bo.getString("CHANGEFILEID"); + String changefileIdNew = bo.getString("CHANGEDFILEIDNEW"); + DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '0' WHERE ID = '"+changefileId+"'"); + DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '1' WHERE ID = '"+changefileIdNew+"'"); + } catch (Exception e) { + } + } + } + + if(bo_act_coe_publish_s.size()>0) { + for (BO bo : bo_act_coe_publish_s) { + try { + String fileId = bo.getString("STOPFILEID"); + DBSql.update(open,"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT5 = '0' WHERE ID = '"+fileId+"'"); + } catch (Exception e) { + } + } + } + /** + * 推送到EHSQ + */ + boolean sendEhqs = true; + String depId = processExecutionContext.getUserContext().getDepartmentModel().getId(); + //获取EHSQ配置表判断是否发送 + String sql = "SELECT * FROM BO_ACT_ACT_ESQ_SEND"; + List maps = DBSql.getMaps(open,sql); + for (RowMap rowMap : maps) { + String dempet = rowMap.getString("DEMPET"); + String issend = rowMap.getString("ISSEND"); + DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(dempet); + if(departmentById!=null) { + String departemenId = departmentById.getId(); + if(departemenId.equals(depId)&&"是".equals(issend)) { + sendEhqs = true; + } /* + * else { List subDepartments = + * SDK.getORGAPI().getSubDepartments(departmentById.getId()); for + * (DepartmentModel departmentModel : subDepartments) { String subDeartmentId = + * departmentModel.getId(); if(subDeartmentId.equals(depId)&&"是".equals(issend)) + * { sendEhqs = true; } } + * + * } + */ + } + } + if(!sendEhqs) { + System.err.println("本次发文不推送EHSQ====>"+processExecutionContext.getProcessInstance().getTitle()); + } + if ("true".equals(isSendEHSQ)&&sendEhqs) { + try { + // 推送EHSQ + if(bo_act_coe_publish_n.size()>0) { + sendEHSQ(processExecutionContext, bo_act_coe_publish_n); + } + // 更新EHSQ + if(bo_act_coe_publish_c.size()>0) { + updateEHSQ(processExecutionContext, bo_act_coe_publish_c); + } + } catch (Exception e) { + // TODO: handle exception + } + } + /** + * 更新数据看板底表 + */ + try { + AttrSynAslp(processExecutionContext, wsId, filed); + } catch (Exception e) { + } + } catch (Exception e) { e.printStackTrace(); @@ -602,30 +616,37 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param jsonObject * @param processExecutionContext */ - public void course(List list,long startTime,JSONObject jsonObject,ProcessExecutionContext processExecutionContext){ - // 创建线程来实现为每300人为一个的线程跑待阅 - ExecutorService service = Executors.newFixedThreadPool(4); + public void course(Connection open,List list,long startTime,JSONObject jsonObject,ProcessExecutionContext processExecutionContext){ + // 创建线程来实现为每100人为一个的线程跑待阅 + ExecutorService service = Executors.newFixedThreadPool(5); + for (String[] resrt:list + ) { service.execute(new Runnable() { @Override public void run() { int i=0; - for (String[] resrt:list - ) { + System.out.println("最后一个数组是什么>>>>>>>"+Arrays.asList(resrt).size()); try { - SendOARead(jsonObject, processExecutionContext.getProcessInstance(), resrt,"批量推送"); + SendOARead(open,jsonObject, processExecutionContext.getProcessInstance(), resrt,"批量推送"); } catch (DocumentException e) { e.printStackTrace(); } i++; } - } + }); + } + try { + service.shutdown(); + }catch (Exception e){ + service.shutdown(); + } } /** * 创建附件及文件 - * + * * @param processExecutionContext * @param bo_name * @param userContext @@ -633,7 +654,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param fileid */ public void creadteFile(ProcessExecutionContext processExecutionContext, String bo_name, UserContext userContext, - String cardId, String fileid) { + String cardId, String fileid) { /** * 这个主要是负责对流程手册进行相关的文件的生成 */ @@ -757,7 +778,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute /** * 发布知识 - * + * * @param processExecutionContext * @param userContext * @param id @@ -814,7 +835,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute /** * 取消发布知识 - * + * * @param processExecutionContext * @param sid * @param knwlId @@ -840,7 +861,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute /** * 创建XPage页面上的待阅文件 - * + * * @param processExecutionContext * @param fileCreateName * @param fileName @@ -855,8 +876,8 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @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) { + 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服务地址 @@ -892,7 +913,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute /** * 给知识授权 - * + * * @param processExecutionContext * @param jsonArray * @param sid @@ -900,7 +921,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @return */ public boolean AddKnwlAC(ProcessExecutionContext processExecutionContext, JSONArray jsonArray, String sid, - String knwlId) { + String knwlId) { // 调用App String sourceAppId = processExecutionContext.getProcessInstance().getAppId(); @@ -922,7 +943,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute /** * 柱军的ASLP - * + * * @param processExecutionContext * @param wsId * @param fileId @@ -955,13 +976,13 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param results * @throws DocumentException */ - public void SendOARead(JSONObject jsonObject, ProcessInstance processInstance, String[] resrt,String type) + public void SendOARead(Connection open,JSONObject jsonObject, ProcessInstance processInstance, String[] resrt,String type) throws DocumentException { String userIds = ""; userIds = StringUtils.join(resrt, ","); - String processInstId = processInstance.getId(); + String processInstId = processInstance.getId(); // System.err.println(processInstance.getTitle() + "开始发送:" + userId); /* @@ -970,122 +991,137 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute if (resrt.length == 0) { return; } - - jsonObject.put("userList", userIds); - String xmlStr = "\n" + long start_time = System.currentTimeMillis(); + System.out.println("待阅推送开始时间>>>>>>>>>>>>"+start_time); + BO bo_OA_read = new BO(); + bo_OA_read.set("FIR_NUMS",resrt.length); + bo_OA_read.set("START_TIME",start_time); + jsonObject.put("userList", userIds); + 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(); - Element result = rootElement.element("Body").element("serviceResponse").element("out"); - String resultString = result.getData().toString(); - JSONObject jsonObject1 = JSON.parseObject(resultString); - System.out.println("jsonObject1==============="+jsonObject1); - String datas = jsonObject1.getString("data"); - System.out.println("data================="+datas); - String status = jsonObject1.getString("status"); - System.out.println("推送》》》》》》》》》》》" + status); + // 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(); + Element result = rootElement.element("Body").element("serviceResponse").element("out"); + String resultString = result.getData().toString(); + JSONObject jsonObject1 = JSON.parseObject(resultString); + System.out.println("jsonObject1==============="+jsonObject1); + String datas = jsonObject1.getString("data"); + long have_time = System.currentTimeMillis(); + System.out.println("接收到返回的待阅ID时间>>>>>>>>>>>>>>>>"+have_time); + bo_OA_read.set("HAVE_TIME",have_time); + System.out.println("接收到返回的待阅耗时时间>>>>>>>>>>>>"+(have_time-start_time)); + bo_OA_read.set("SUM_TIME",(have_time-start_time)); + System.out.println("data================="+datas); + String status = jsonObject1.getString("status"); + System.out.println("推送》》》》》》》》》》》" + status); - if ("true".equals(status)) { - JSONArray resultArray = JSONObject.parseArray(datas); - //System.out.println(processInstance.getTitle() + "待阅推送成功:" + idList.size()+"人"); - //批量入库操作 - //加入时间戳 - if(resultArray.size()>0){ - List recordLists = new ArrayList(); - long startTime2 = System.currentTimeMillis(); - for (int j = 0; j < resultArray.size(); j++) { + if ("true".equals(status)) { + JSONArray resultArray = JSONObject.parseArray(datas); + //System.out.println(processInstance.getTitle() + "待阅推送成功:" + idList.size()+"人"); + //批量入库操作 + //加入时间戳 + long set_start_time = System.currentTimeMillis(); + bo_OA_read.set("SET_TIME",set_start_time); + if(resultArray.size()>0){ + List recordLists = new ArrayList(); + long startTime2 = System.currentTimeMillis(); + 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("USERDEP", SDK.getORGAPI().getUser(user).getDepartmentId()); - bo.set("DATAID", dataid); - bo.set("RESULT", status); - bo.set("SENDTYPE", "1"); - bo.set("READSTATE", "未读"); - bo.set("TYPE", type); - recordLists.add(bo); + 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("USERDEP", SDK.getORGAPI().getUser(user).getDepartmentId()); + bo.set("DATAID", dataid); + bo.set("RESULT", status); + bo.set("SENDTYPE", "1"); + bo.set("READSTATE", "未读"); + bo.set("TYPE", type); + recordLists.add(bo); - BO oa_real_time=SDK.getBOAPI().query("BO_ACT_OA_REAL_TIME").addQuery("PROCESSID=",processInstance.getId()).detail(); + BO oa_real_time=SDK.getBOAPI().query("BO_ACT_OA_REAL_TIME").addQuery("PROCESSID=",processInstance.getId()).detail(); - String sqly = "SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '" + processInstId + "' AND SENDTYPE = '1'"; - List mapsy = DBSql.getMaps(sqly); + String sqly = "SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '" + processInstId + "' AND SENDTYPE = '1'"; + List mapsy = DBSql.getMaps(open,sqly); - if(oa_real_time!=null){ - int r1 = DBSql.update("UPDATE BO_ACT_OA_REAL_TIME SET SENDNUMSJ='" + mapsy.size() + "'WHERE PROCESSID ='" + processInstance.getId() + "'"); - }else{ - //插入实时更新人数表 - BO realTimeBO=new BO(); - realTimeBO.set("USREID", user); - realTimeBO.set("DEPID", SDK.getORGAPI().getUser(user).getDepartmentId()); - realTimeBO.set("BUNAME",SDK.getORGAPI().getUser(user).getExt4()); - realTimeBO.set("TITLE", processInstance.getTitle()); - realTimeBO.set("PROCESSID", processInstance.getId()); - realTimeBO.set("SENDNUMSJ", 1); - realTimeBO.set("SENDNUM",sendTotal); - SDK.getBOAPI().create("BO_ACT_OA_REAL_TIME", bo, processInstance.getId(), processInstance.getCreateUser()); - } - - } - SDK.getBOAPI().create("BO_ACT_DATAID",recordLists, processInstance.getId(), processInstance.getCreateUser()); - - long endTime2 = System.currentTimeMillis(); - System.err.println(processInstance.getTitle() + "批量插入OA待阅数据====>" + "用时:" - + (endTime2 - startTime2) / 1000 + "秒"); - } - - if("单个账号推送".equals(type)) { - DBSql.update("UPDATE BO_EU_READ_COUNT SET RESULT = '已重新推送' WHERE PROCESSID = '"+processInstId+"' AND NAME = '"+resrt+"'"); - } - } else { - List idList = Arrays.asList(resrt); - BO bo = null; - List recordFailLists = new ArrayList(); - if(idList.size()>0){ - for (String userId : idList) { - System.out.println(processInstance.getTitle() + "待阅推送失败:" + userId); - try { - bo= new BO(); - bo.set("TITLE", processInstance.getTitle()); - bo.set("NAME", userId); - bo.set("TYPE", type); - bo.set("RESULT", "待处理"); - bo.set("PROCESSID", processInstId); - bo.set("DEPNAME", SDK.getORGAPI().getUser(userId).getDepartmentId()); - //SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser()); - recordFailLists.add(bo); - } catch (Exception e) { - bo= new BO(); - bo.set("TITLE", processInstance.getTitle()); - bo.set("NAME", userIds); - bo.set("TYPE", type); - bo.set("RESULT", "待处理"); - bo.set("PROCESSID", processInstId); - bo.set("DEPNAME", SDK.getORGAPI().getUser(userIds).getDepartmentId()); - //SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser()); - recordFailLists.add(bo); - } - } - System.out.println("recordFailLists========="+recordFailLists.size()); - SDK.getBOAPI().create("BO_EU_READ_COUNT", recordFailLists, processInstance.getId(), processInstance.getCreateUser()); + if(oa_real_time!=null){ + int r1 = DBSql.update(open,"UPDATE BO_ACT_OA_REAL_TIME SET SENDNUMSJ='" + mapsy.size() + "'WHERE PROCESSID ='" + processInstance.getId() + "'"); + }else{ + //插入实时更新人数表 + BO realTimeBO=new BO(); + realTimeBO.set("USREID", user); + realTimeBO.set("DEPID", SDK.getORGAPI().getUser(user).getDepartmentId()); + realTimeBO.set("BUNAME",SDK.getORGAPI().getUser(user).getExt4()); + realTimeBO.set("TITLE", processInstance.getTitle()); + realTimeBO.set("PROCESSID", processInstance.getId()); + realTimeBO.set("SENDNUMSJ", 1); + realTimeBO.set("SENDNUM",sendTotal); + SDK.getBOAPI().create("BO_ACT_OA_REAL_TIME", bo, processInstance, UserContext.fromUID(processInstance.getCreateUser()),open); } + } + SDK.getBOAPI().create("BO_ACT_DATAID",recordLists, processInstance, UserContext.fromUID(processInstance.getCreateUser()),open); - - - - + long endTime2 = System.currentTimeMillis(); + System.err.println(processInstance.getTitle() + "批量插入OA待阅数据====>" + "用时:" + + (endTime2 - startTime2) / 1000 + "秒"); } + long set_end_time = System.currentTimeMillis(); + bo_OA_read.set("SET_END_TIME",set_end_time); + bo_OA_read.set("SET_SUM_TIME",(set_end_time-set_start_time)); + bo_OA_read.set("PROCESS_ID",processInstance.getId()); + SDK.getBOAPI().create("BO_EU_OA_READ_LOG", bo_OA_read, processInstance, UserContext.fromUID(processInstance.getCreateUser()),open); + if("单个账号推送".equals(type)) { + DBSql.update(open,"UPDATE BO_EU_READ_COUNT SET RESULT = '已重新推送' WHERE PROCESSID = '"+processInstId+"' AND NAME = '"+resrt+"'"); + } + } else { + List idList = Arrays.asList(resrt); + BO bo = null; + List recordFailLists = new ArrayList(); + if(idList.size()>0){ + for (String userId : idList) { + System.out.println(processInstance.getTitle() + "待阅推送失败:" + userId); + try { + bo= new BO(); + bo.set("TITLE", processInstance.getTitle()); + bo.set("NAME", userId); + bo.set("TYPE", type); + bo.set("RESULT", "待处理"); + bo.set("PROCESSID", processInstId); + bo.set("DEPNAME", SDK.getORGAPI().getUser(userId).getDepartmentId()); + //SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser()); + recordFailLists.add(bo); + } catch (Exception e) { + bo= new BO(); + bo.set("TITLE", processInstance.getTitle()); + bo.set("NAME", userIds); + bo.set("TYPE", type); + bo.set("RESULT", "待处理"); + bo.set("PROCESSID", processInstId); + bo.set("DEPNAME", SDK.getORGAPI().getUser(userIds).getDepartmentId()); + //SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser()); + recordFailLists.add(bo); + } + } + System.out.println("recordFailLists========="+recordFailLists.size()); + SDK.getBOAPI().create("BO_EU_READ_COUNT", recordFailLists, processInstance, UserContext.fromUID(processInstance.getCreateUser()),open); + } + + + + + + + } } @@ -1198,7 +1234,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute /** * 发送EHSQ数据 - * + * * @param jsonArray * @return * @throws Exception @@ -1300,7 +1336,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute // 发送组织 public ArrayList sendOrg(String org, ArrayList userList, ProcessInstance instanceById, - BO bo_act_coe_publish1, JSONObject jsonObject, String sendType) { + BO bo_act_coe_publish1, JSONObject jsonObject, String sendType) { String processid = instanceById.getId(); // 获取组织 if (StringUtils.isNotEmpty(org) || "1".equals(sendType)) { @@ -1315,7 +1351,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute // 发送岗位 public ArrayList sendPost(String post, ArrayList userList, ProcessInstance instanceById, - BO bo_act_coe_publish1, JSONObject jsonObject) { + BO bo_act_coe_publish1, JSONObject jsonObject) { String processid = instanceById.getId(); // 获取岗位 if (StringUtils.isNotEmpty(post)) { @@ -1347,7 +1383,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute // 发送职级 public ArrayList sendLevel(String level, ArrayList userList, ProcessInstance instanceById, - BO bo_act_coe_publish1, JSONObject jsonObject) { + BO bo_act_coe_publish1, JSONObject jsonObject) { String processid = instanceById.getId(); ArrayList userList_level = new ArrayList(); // 获取职级 @@ -1380,7 +1416,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute // 只发送职级 public ArrayList sendLevel2(String level, ArrayList userList, ProcessInstance instanceById, - BO bo_act_coe_publish1, JSONObject jsonObject) { + BO bo_act_coe_publish1, JSONObject jsonObject) { String processid = instanceById.getId(); ArrayList userList_level = new ArrayList(); // 获取职级 @@ -1448,7 +1484,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute } public void getUserList(JSONObject jsonObject, ArrayList arr_test, ArrayList arr, - String departmentId, String processid) { + String departmentId, String processid) { // 获取当前部门下人员 List userModelList = SDK.getORGAPI().getAllUsersByDepartment(departmentId); for (UserModel userModel : userModelList) { @@ -1478,7 +1514,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute // 获取子部门人员 public void getSubDepartments(JSONObject jsonObject, ArrayList arr_test, ArrayList arr, - DepartmentModel departmentById, String processid) { + DepartmentModel departmentById, String processid) { if (!departmentById.isClosed()) { List subDepartments = SDK.getORGAPI().getSubDepartments(departmentById.getId()); for (DepartmentModel departmentModel : subDepartments) { @@ -1511,7 +1547,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute } /** * 创建线程发送待阅 - * + * * @param list 人员集合 * @param startTime 开始时间 * @param jsonObject 发送的json串 @@ -1522,11 +1558,11 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * 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 = ", @@ -1540,7 +1576,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute /** * 创建待阅日志 - * + * * @param processExecutionContext * @param jsonObject * @param users @@ -1548,7 +1584,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute */ public void createReadLog(ProcessExecutionContext processExecutionContext, JSONObject jsonObject, - ArrayList arr, long startTime, long endTimes) { + ArrayList arr, long startTime, long endTimes) { BO bo_Read_log = new BO(); String processInstId = processExecutionContext.getProcessInstance().getId(); bo_Read_log.set("USREID", processExecutionContext.getUserContext().getUID()); @@ -1615,7 +1651,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute /** * 通过发布知识创建知识 - * + * * @param bo 发布清单表数据 * @param wsId 知识库id * @param filed 文件集合JsonArray格式 @@ -1624,7 +1660,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param uid 账户合计 */ public void createKmsByNew(BO bo, String wsId, JSONArray filed, ProcessExecutionContext processExecutionContext, - BO bo_act_coe_publish, String uid) { + BO bo_act_coe_publish, String uid) { { OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); wsId = model.getWsId(); @@ -1708,17 +1744,17 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute } } else { List departmentsByCompanyId = SDK.getORGAPI().getDepartmentsByCompanyId(1, - "8911e732-b42a-4556-853f-ad32761bcbee"); - for (DepartmentModel departmentModel : departmentsByCompanyId) { - String depId = departmentModel.getId(); - // 查询未注销的部门并且去掉系统部门 - if (!departmentModel.isClosed()&& !"e79281b1-2f81-4895-b30e-9f96e9ad0e2c".equals(depId)&& !"65048aee-157f-49f2-a2dc-5903dd26f519".equals(depId)) { - JSONObject jsonObjecta = new JSONObject(); - jsonObjecta.put("assignmentType","department"); - jsonObjecta.put("assignmentId",depId); - jsonArray1.add(jsonObjecta); - } - } + "8911e732-b42a-4556-853f-ad32761bcbee"); + for (DepartmentModel departmentModel : departmentsByCompanyId) { + String depId = departmentModel.getId(); + // 查询未注销的部门并且去掉系统部门 + if (!departmentModel.isClosed()&& !"e79281b1-2f81-4895-b30e-9f96e9ad0e2c".equals(depId)&& !"65048aee-157f-49f2-a2dc-5903dd26f519".equals(depId)) { + JSONObject jsonObjecta = new JSONObject(); + jsonObjecta.put("assignmentType","department"); + jsonObjecta.put("assignmentId",depId); + jsonArray1.add(jsonObjecta); + } + } } AddKnwlAC(processExecutionContext, jsonArray1, processExecutionContext.getUserContext().getSessionId(), @@ -1744,7 +1780,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute /** * 发布生成kms知识 - * + * * @param bo 更新发布清单表 * @param wsId 知识库id * @param filed 发布清单的发布id @@ -1753,7 +1789,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param uid 账户集合 */ public void CreateKmsByupdate(BO bo, String wsId, JSONArray filed, ProcessExecutionContext processExecutionContext, - BO bo_act_coe_publish, String uid) { + BO bo_act_coe_publish, String uid) { { OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID")); wsId = model.getWsId(); @@ -1927,7 +1963,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute // jsonObject_ehsq.put("companycode","00000013"); jsonObject_ehsq.put("authorcompany", UserContext .fromUID(processExecutionContext.getTaskInstance().getTarget()).getDepartmentModel().getName()); // jsonObject_ehsq.put("authorcompany","总部质量管理部"); - // // + // // BO bo1 = SDK.getBOAPI().query("BO_ACT_PUBLISH_PERM_SCOPE", true) .addQuery("PALNAME=", bo.getString("PUBLISHFILENAME")).detail(); if (bo1 != null) { @@ -1999,7 +2035,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute jsonObject_ehsq.put("recordfiles", new_name); jsonObject_ehsq.put("recordurls", new_url); jsonArray_EHSQ.add(jsonObject_ehsq); - + Date date = new Date(); SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); UserContext uc = processExecutionContext.getUserContext();