创建线程执行发布
This commit is contained in:
parent
8c894e7c51
commit
eb6301781f
@ -387,9 +387,61 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
|
|||||||
* for (String user : sendList) { try { SendOARead(jsonObject, instanceById,
|
* for (String user : sendList) { try { SendOARead(jsonObject, instanceById,
|
||||||
* user, "批量推送"); } catch (Exception e) { // TODO: handle exception } }
|
* 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<String[]> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建线程发送待阅数据
|
||||||
|
*/
|
||||||
|
course(list,startTime,jsonObject,processExecutionContext);
|
||||||
|
}else {
|
||||||
|
int size = users.length/length;
|
||||||
|
int flag = 0;
|
||||||
|
List<String[]> 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);
|
||||||
|
// 创建线程来实现为每300人为一个的线程跑待阅
|
||||||
|
/**
|
||||||
|
* 创建线程发送待阅数据
|
||||||
|
*/
|
||||||
|
course(list,startTime,jsonObject,processExecutionContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*int toIndex = 200;
|
||||||
int toIndex = 200;
|
|
||||||
int listSize = sendList.size();
|
int listSize = sendList.size();
|
||||||
boolean shutdown = false;
|
boolean shutdown = false;
|
||||||
|
|
||||||
@ -435,7 +487,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
|
|||||||
System.err.println(instanceById.getTitle() + "单次300条推送单条====>" + "用时:"
|
System.err.println(instanceById.getTitle() + "单次300条推送单条====>" + "用时:"
|
||||||
+ (endTimes1 - startTime1) / 1000 + "秒");
|
+ (endTimes1 - startTime1) / 1000 + "秒");
|
||||||
|
|
||||||
/*
|
*//*
|
||||||
* ExecutorService cachedThreadPool = Executors.newFixedThreadPool(3); // 开启一个线程
|
* ExecutorService cachedThreadPool = Executors.newFixedThreadPool(3); // 开启一个线程
|
||||||
* cachedThreadPool.execute(new Runnable() {
|
* cachedThreadPool.execute(new Runnable() {
|
||||||
*
|
*
|
||||||
@ -443,16 +495,16 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
|
|||||||
* Auto-generated catch block e.printStackTrace(); }
|
* Auto-generated catch block e.printStackTrace(); }
|
||||||
*
|
*
|
||||||
* } });
|
* } });
|
||||||
*/
|
*//*
|
||||||
// 以下是等线程池的全部线程执行结束后,会自动执行。
|
// 以下是等线程池的全部线程执行结束后,会自动执行。
|
||||||
/*
|
*//*
|
||||||
* cachedThreadPool.shutdown(); while (true) { if
|
* cachedThreadPool.shutdown(); while (true) { if
|
||||||
* (cachedThreadPool.isTerminated()) { long time = System.currentTimeMillis() -
|
* (cachedThreadPool.isTerminated()) { long time = System.currentTimeMillis() -
|
||||||
* startTime; //System.out.println("程序结束了,总耗时:" + time + " ms(毫秒)!\n"+toIndex);
|
* startTime; //System.out.println("程序结束了,总耗时:" + time + " ms(毫秒)!\n"+toIndex);
|
||||||
* break; } }
|
* break; } }
|
||||||
*/
|
*//*
|
||||||
|
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// 二次推送
|
// 二次推送
|
||||||
List<RowMap> List = DBSql.getMaps("SELECT NAME FROM BO_EU_READ_COUNT WHERE PROCESSID = '"
|
List<RowMap> 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<String[]> 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
|
* @param results
|
||||||
* @throws DocumentException
|
* @throws DocumentException
|
||||||
*/
|
*/
|
||||||
public void SendOARead(JSONObject jsonObject, ProcessInstance processInstance, List<String> idList,String type)
|
public void SendOARead(JSONObject jsonObject, ProcessInstance processInstance, String[] resrt,String type)
|
||||||
throws DocumentException {
|
throws DocumentException {
|
||||||
|
|
||||||
|
String userIds = "";
|
||||||
|
userIds = StringUtils.join(resrt, ",");
|
||||||
|
|
||||||
|
|
||||||
System.out.println("idList========="+idList.toString());
|
|
||||||
String processInstId = processInstance.getId();
|
String processInstId = processInstance.getId();
|
||||||
// System.err.println(processInstance.getTitle() + "开始发送:" + userId);
|
// System.err.println(processInstance.getTitle() + "开始发送:" + userId);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if ("".equals(userId) || UtilString.isEmpty(userId)) { return; }
|
* if ("".equals(userId) || UtilString.isEmpty(userId)) { return; }
|
||||||
*/
|
*/
|
||||||
if (idList.size() == 0) {
|
if (userIds.length() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String userIds = StringUtils.join(idList, ",");
|
jsonObject.put("userList", resrt);
|
||||||
jsonObject.put("userList", userIds);
|
|
||||||
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\n"
|
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\n"
|
||||||
+ " <soapenv:Header/>" + " <soapenv:Body>" + " <web:service>" + " <web:in0>"
|
+ " <soapenv:Header/>" + " <soapenv:Body>" + " <web:service>" + " <web:in0>"
|
||||||
+ "<![CDATA[" + jsonObject + "]]>" + " </web:in0>" + " </web:service>"
|
+ "<![CDATA[" + jsonObject + "]]>" + " </web:in0>" + " </web:service>"
|
||||||
@ -911,7 +1001,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
|
|||||||
|
|
||||||
if ("true".equals(status)) {
|
if ("true".equals(status)) {
|
||||||
JSONArray resultArray = JSONObject.parseArray(datas);
|
JSONArray resultArray = JSONObject.parseArray(datas);
|
||||||
System.out.println(processInstance.getTitle() + "待阅推送成功:" + idList.size()+"人");
|
//System.out.println(processInstance.getTitle() + "待阅推送成功:" + idList.size()+"人");
|
||||||
//批量入库操作
|
//批量入库操作
|
||||||
//加入时间戳
|
//加入时间戳
|
||||||
if(resultArray.size()>0){
|
if(resultArray.size()>0){
|
||||||
@ -963,9 +1053,10 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
|
|||||||
}
|
}
|
||||||
|
|
||||||
if("单个账号推送".equals(type)) {
|
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 {
|
} else {
|
||||||
|
List<String> idList = Arrays.asList(resrt);
|
||||||
BO bo = null;
|
BO bo = null;
|
||||||
List<BO> recordFailLists = new ArrayList<BO>();
|
List<BO> recordFailLists = new ArrayList<BO>();
|
||||||
if(idList.size()>0){
|
if(idList.size()>0){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user