From eb6301781f6a107f24a888928c02e00587a4fd43 Mon Sep 17 00:00:00 2001 From: Mr-wang Date: Mon, 10 Jul 2023 10:50:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=BA=BF=E7=A8=8B=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pubEvent/ProcessEndAfterEvent_new.java | 121 +++++++++++++++--- 1 file changed, 106 insertions(+), 15 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 f486d558..6762915f 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 @@ -387,9 +387,61 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * for (String user : sendList) { try { SendOARead(jsonObject, instanceById, * user, "批量推送"); } catch (Exception e) { // TODO: handle exception } } */ + + + + + if (StringUtils.isNotEmpty(new_uid + )) { + new_uid = new_uid.substring(0, new_uid.length() - 1); + } + long startTimes = System.currentTimeMillis(); + System.out.println("new_userid ==========>>>>>>>>>"+new_uid); + String[] users = new_uid.split(","); + int length = 300; + int ys = users.length%length; + /** + * 这个是以300人作为一个发送单位去放到list中并发送待阅数据 + */ + 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" + "用时:" + (endTimes1 - startTime1) / 1000 + "秒"); - /* + *//* * ExecutorService cachedThreadPool = Executors.newFixedThreadPool(3); // 开启一个线程 * cachedThreadPool.execute(new Runnable() { * @@ -443,16 +495,16 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * 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; } } - */ + *//* - } + }*/ // 二次推送 List List = DBSql.getMaps("SELECT NAME FROM BO_EU_READ_COUNT WHERE PROCESSID = '" @@ -540,6 +592,45 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute } } + + /** + * 根据线程创建待阅日志 + * @param list + * @param startTime + * @param jsonObject + * @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.getProcessInstance(), resrt,"批量推送"); + } catch (DocumentException e) { + e.printStackTrace(); + } + i++; + } + } + }); + } + /** * 创建附件及文件 * @@ -872,24 +963,23 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute * @param results * @throws DocumentException */ - public void SendOARead(JSONObject jsonObject, ProcessInstance processInstance, List idList,String type) + public void SendOARead(JSONObject jsonObject, ProcessInstance processInstance, String[] resrt,String type) throws DocumentException { + String userIds = ""; + userIds = StringUtils.join(resrt, ","); - - System.out.println("idList========="+idList.toString()); String processInstId = processInstance.getId(); // System.err.println(processInstance.getTitle() + "开始发送:" + userId); /* * if ("".equals(userId) || UtilString.isEmpty(userId)) { return; } */ - if (idList.size() == 0) { + if (userIds.length() == 0) { return; } - String userIds = StringUtils.join(idList, ","); - jsonObject.put("userList", userIds); + jsonObject.put("userList", resrt); String xmlStr = "\n" + " " + " " + " " + " " + "" + " " + " " @@ -911,7 +1001,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute if ("true".equals(status)) { JSONArray resultArray = JSONObject.parseArray(datas); - System.out.println(processInstance.getTitle() + "待阅推送成功:" + idList.size()+"人"); + //System.out.println(processInstance.getTitle() + "待阅推送成功:" + idList.size()+"人"); //批量入库操作 //加入时间戳 if(resultArray.size()>0){ @@ -963,9 +1053,10 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute } if("单个账号推送".equals(type)) { - DBSql.update("UPDATE BO_EU_READ_COUNT SET RESULT = '已重新推送' WHERE PROCESSID = '"+processInstId+"' AND NAME = '"+userIds+"'"); + 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){