OA待阅线程批量推送

This commit is contained in:
Mr-wang 2023-07-13 14:41:24 +08:00
parent 9ad0aaa2f2
commit 21330baac3

View File

@ -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;
@ -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,137 +207,16 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
.addQuery("BINDID=", processExecutionContext.getProcessInstance().getId())
.addQuery("OPTIONTYPE IS NOT NULL", null).detail();
// 流程发布的新增发布
List<BO> bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true)
List<BO> bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).connection(open)
.addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list();
List<BO> bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true)
List<BO> bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).connection(open)
.addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list();
List<BO> bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true)
List<BO> 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<RowMap> 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<DepartmentModel> 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<RowMap> mapsl = DBSql.getMaps("SELECT * FROM ORGUSER WHERE CLOSED = '0'");
List<RowMap> 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 = '"
@ -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> bo_eu_oa_read_test = SDK.getBOAPI().query("BO_EU_OA_READ_TEST").list();
List<BO> bo_eu_oa_read_test = SDK.getBOAPI().query("BO_EU_OA_READ_TEST").connection(open).list();
ArrayList<String> sendLists = new ArrayList<String>();
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<size;i++){
String[] results;
results = Arrays.copyOfRange(users, flag, flag+300);
results = Arrays.copyOfRange(users, flag, flag+100);
list.add(results);
flag = flag+300;
flag = flag+100;
}
/**
* 创建线程发送待阅数据
*/
course(list,startTime,jsonObject,processExecutionContext);
course(open,list,startTime,jsonObject,processExecutionContext);
//System.out.println("发送人员数据>>>>>>>>>>>>>>"+list);
}else {
int size = users.length/length;
@ -425,9 +317,9 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
List<String[]> list = new LinkedList();
for (int i=0;i<size;i++){
String[] results;
results = Arrays.copyOfRange(users, flag, flag+300);
results = Arrays.copyOfRange(users, flag, flag+100);
list.add(results);
flag = flag+300;
flag = flag+100;
}
String[] redata;
redata = Arrays.copyOfRange(users, flag, flag+ys);
@ -436,7 +328,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
/**
* 创建线程发送待阅数据
*/
course(list,startTime,jsonObject,processExecutionContext);
course(open,list,startTime,jsonObject,processExecutionContext);
//System.out.println("发送人员数据>>>>>>>>>>>>>>"+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; } }
*//*
}*/
@ -585,6 +477,128 @@ 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<RowMap> 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<DepartmentModel> 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) {
@ -602,25 +616,32 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
* @param jsonObject
* @param processExecutionContext
*/
public void course(List<String[]> list,long startTime,JSONObject jsonObject,ProcessExecutionContext processExecutionContext){
// 创建线程来实现为每300人为一个的线程跑待阅
ExecutorService service = Executors.newFixedThreadPool(4);
public void course(Connection open,List<String[]> 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();
}
}
/**
@ -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) {
/**
* 这个主要是负责对流程手册进行相关的文件的生成
*/
@ -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服务地址
@ -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();
@ -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 = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\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 = "<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>"
+ "<![CDATA[" + jsonObject + "]]>" + " </web:in0>" + " </web:service>"
+ " </soapenv:Body>" + "</soapenv:Envelope>";
// 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<BO> recordLists = new ArrayList<BO>();
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<BO> recordLists = new ArrayList<BO>();
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<RowMap> mapsy = DBSql.getMaps(sqly);
String sqly = "SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '" + processInstId + "' AND SENDTYPE = '1'";
List<RowMap> 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<String> idList = Arrays.asList(resrt);
BO bo = null;
List<BO> recordFailLists = new ArrayList<BO>();
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<String> idList = Arrays.asList(resrt);
BO bo = null;
List<BO> recordFailLists = new ArrayList<BO>();
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);
}
}
}
@ -1300,7 +1336,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
// 发送组织
public ArrayList<String> sendOrg(String org, ArrayList<String> 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<String> sendPost(String post, ArrayList<String> 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<String> sendLevel(String level, ArrayList<String> userList, ProcessInstance instanceById,
BO bo_act_coe_publish1, JSONObject jsonObject) {
BO bo_act_coe_publish1, JSONObject jsonObject) {
String processid = instanceById.getId();
ArrayList<String> userList_level = new ArrayList<String>();
// 获取职级
@ -1380,7 +1416,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
// 只发送职级
public ArrayList<String> sendLevel2(String level, ArrayList<String> userList, ProcessInstance instanceById,
BO bo_act_coe_publish1, JSONObject jsonObject) {
BO bo_act_coe_publish1, JSONObject jsonObject) {
String processid = instanceById.getId();
ArrayList<String> userList_level = new ArrayList<String>();
// 获取职级
@ -1448,7 +1484,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
}
public void getUserList(JSONObject jsonObject, ArrayList<String> arr_test, ArrayList<String> arr,
String departmentId, String processid) {
String departmentId, String processid) {
// 获取当前部门下人员
List<UserModel> 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<String> arr_test, ArrayList<String> arr,
DepartmentModel departmentById, String processid) {
DepartmentModel departmentById, String processid) {
if (!departmentById.isClosed()) {
List<DepartmentModel> subDepartments = SDK.getORGAPI().getSubDepartments(departmentById.getId());
for (DepartmentModel departmentModel : subDepartments) {
@ -1548,7 +1584,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
*/
public void createReadLog(ProcessExecutionContext processExecutionContext, JSONObject jsonObject,
ArrayList<String> arr, long startTime, long endTimes) {
ArrayList<String> arr, long startTime, long endTimes) {
BO bo_Read_log = new BO();
String processInstId = processExecutionContext.getProcessInstance().getId();
bo_Read_log.set("USREID", processExecutionContext.getUserContext().getUID());
@ -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<DepartmentModel> 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(),
@ -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) {