1.生成编号时排序生成

2.推送oa待阅改为每次推送300条
This commit is contained in:
lihongyu 2022-11-23 12:58:46 +08:00
parent b093205609
commit bba471fc4e
2 changed files with 184 additions and 153 deletions

View File

@ -120,9 +120,9 @@ public class ProcesNumberUtil {
System.out.println("生成编号并写入数据库===============");
// 查询出所有的发布流程
List<BO> dataList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").addQuery("BINDID=", bindId).list();
List<BO> dataList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").addQuery("BINDID=", bindId).orderByCreated().asc().list();
// 查询出所有的变更流程
List<BO> changList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").addQuery("BINDID=", bindId).list();
List<BO> changList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").addQuery("BINDID=", bindId).orderByCreated().asc().list();
if (changList.size() != 0) {
for (BO changData : changList) {
String change_numner = changData.getString("CHANGE_NUMBER");

View File

@ -74,6 +74,7 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
public String getVersion() {
return "1.0";
}
@Override
public void execute(ProcessExecutionContext ext) throws Exception {
ExecutorService service = Executors.newFixedThreadPool(1);
@ -102,7 +103,7 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
String wsId = "";
JSONArray filed = new JSONArray(new LinkedList<>());
String portalUrl = SDK.getPortalAPI().getPortalUrl();
System.out.println("portal======>>>>" + portalUrl);
//System.out.println("portal======>>>>" + portalUrl);
/*
* if (portalUrl.equals("http://10.114.11.135:8088/portal")){ portalUrl =
* "http://bpm.yili.com:8088/portal/"; }
@ -185,7 +186,8 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
}
// 更新知识库
for (BO bo : bo_act_coe_publish_c) {
CreateKmsByupdate(bo, wsId, filed, processExecutionContext, bo_act_coe_publish, crateUserId);
CreateKmsByupdate(bo, wsId, filed, processExecutionContext, bo_act_coe_publish,
crateUserId);
}
// 废止知识库文件
@ -193,14 +195,16 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
// 将旧的知识取消发布或者移动到废止发布中
String publishfileid_stop = bo.getString("STOPFILEID");
filed.add(publishfileid_stop);
String sql_s = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + 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"));
processExecutionContext.getUserContext().getSessionId(),
map1.getString("EXT4"));
DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '" + publishfileid_stop
+ "'");
DBSql.update("UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '"
+ publishfileid_stop + "'");
}
}
} catch (Exception e) {
@ -227,24 +231,44 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
long startTime = System.currentTimeMillis();
ArrayList<String> sendList = getSendList(instanceById, bo_act_coe_publish1, jsonObject);
System.err.println(instanceById.getTitle() + "待发送人员数量====>" + sendList.size());
for (String uid : sendList) {
try {
SendOARead(jsonObject, instanceById, uid);
int toIndex = 300;
int listSize = sendList.size();
boolean shutdown = false;
for (int i = 0; i < sendList.size(); i += 300) {
if (i + 300 > listSize) {
toIndex = listSize - i;
}
List<String> idList = sendList.subList(i, i + toIndex);
SendOARead(jsonObject, instanceById, idList);
/*
* ExecutorService service = Executors.newFixedThreadPool(5);
* ExecutorService service = Executors.newFixedThreadPool(3);
* service.execute(new Runnable() {
*
* @Override public void run() { try { } catch (Exception e) { // TODO
* Auto-generated catch block e.printStackTrace(); } } });
*/
} catch (Exception e) {
}
}
/*
* for (String uid : sendList) { try { SendOARead(jsonObject, instanceById,
* uid);
*
* ExecutorService service = Executors.newFixedThreadPool(5);
* service.execute(new Runnable() {
*
* @Override public void run() { try { } 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+"分钟");
System.err.println(instanceById.getTitle() + "推送OA待阅执行完毕====>" + "用时:"
+ (endTimes - startTime) / 1000 / 60 + "分钟");
}
}
@ -262,12 +286,10 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
open.close();
}
}
@ -510,7 +532,8 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
* @param fileid
* @return
*/
public boolean execute(ProcessExecutionContext processExecutionContext, String fileCreateName, String fileName,String fileurl, String readingScope_org, String isFullCompany, String fileCreateDate,
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();
@ -554,7 +577,8 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
* @param knwlId
* @return
*/
public boolean AddKnwlAC(ProcessExecutionContext processExecutionContext, JSONArray jsonArray, String sid,String knwlId) {
public boolean AddKnwlAC(ProcessExecutionContext processExecutionContext, JSONArray jsonArray, String sid,
String knwlId) {
// 调用App
String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
@ -609,20 +633,24 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
* @param results
* @throws DocumentException
*/
public void SendOARead(JSONObject jsonObject, ProcessInstance processInstance, String userId)
public void SendOARead(JSONObject jsonObject, ProcessInstance processInstance, List<String> idList)
throws DocumentException {
// System.err.println(processInstance.getTitle() + "开始发送:" + userId);
if ("".equals(userId) || UtilString.isEmpty(userId)) {
/*
* if ("".equals(userId) || UtilString.isEmpty(userId)) { return; }
*/
if (idList.size() == 0) {
return;
}
jsonObject.put("userList", userId);
String userIds = StringUtils.join(idList, ",");
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();
@ -634,6 +662,7 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
String status = jsonObject1.getString("status");
// System.out.println("推送》》》》》》》》》》》" + status);
if ("false".equals(status)) {
for (String userId : idList) {
System.out.println(processInstance.getTitle() + "待阅推送失败:" + userId);
try {
BO bo = new BO();
@ -644,9 +673,10 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
} catch (Exception e) {
// TODO: handle exception
}
}
} else {
//System.out.println(processInstance.getTitle() + "待阅推送成功:" + userId);
JSONArray resultArray = JSONObject.parseArray(datas);
System.out.println(processInstance.getTitle() + "待阅推送成功:" + idList);
for (int j = 0; j < resultArray.size(); j++) {
JSONObject jsonObject2 = resultArray.getJSONObject(j);
String user = jsonObject2.get("user").toString();
@ -758,7 +788,6 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
userList = sendLevel2(level, userList, instanceById, bo_act_coe_publish1, jsonObject);
}
}
return userList;
@ -882,7 +911,9 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
for (DepartmentModel departmentModel : departmentsByCompanyId) {
String id = departmentModel.getId();
// 查询未注销的部门并且去掉系统部门
if (!departmentModel.isClosed() && !"5bc3a2dc-3bd2-4376-bcc3-5612e28e55fe".equals(id)&&!"e79281b1-2f81-4895-b30e-9f96e9ad0e2c".equals(id)&&!"65048aee-157f-49f2-a2dc-5903dd26f519".equals(id)) {
if (!departmentModel.isClosed() && !"5bc3a2dc-3bd2-4376-bcc3-5612e28e55fe".equals(id)
&& !"e79281b1-2f81-4895-b30e-9f96e9ad0e2c".equals(id)
&& !"65048aee-157f-49f2-a2dc-5903dd26f519".equals(id)) {
getUserList(jsonObject, arr_test, arr, id, processid);
}
@ -911,8 +942,10 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
if (!userModel.isClosed()) {
String uid = userModel.getUID();
if (!arr.contains(uid)) {
arr_test.add(uid);
arr.add(userModel.getUID());
if(!"10033643".equals(uid)) {
//arr_test.add(uid);
arr.add(uid);
}
/*
* RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '"
* + processid + "' AND USER_ID = '" + uid + "'"); if (map == null) {
@ -942,9 +975,13 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
if (!userModel.isClosed()) {
String uid = userModel.getUID();
if (!arr.contains(uid)) {
arr_test.add(uid);
if (!"10033643".equals(uid)) {
// arr_test.add(uid);
arr.add(uid);
//System.err.println(SDK.getProcessAPI().getInstanceById(processid) + "_发送人员======>" + uid);
}
// System.err.println(SDK.getProcessAPI().getInstanceById(processid) +
// "_发送人员======>" + uid);
}
}
@ -997,8 +1034,8 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
* @param startTime
*/
public void createReadLog(ProcessExecutionContext processExecutionContext, JSONObject jsonObject, ArrayList<String> arr,
long startTime,long endTimes) {
public void createReadLog(ProcessExecutionContext processExecutionContext, JSONObject jsonObject,
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());
@ -1010,8 +1047,7 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
String sqly = "SELECT * FROM BO_ACT_DATAID WHERE PROCESSID = '" + processInstId + "' AND SENDTYPE = '1'";
List<RowMap> mapsy = DBSql.getMaps(sqly);
bo_Read_log.set("SENDNUMSJ", mapsy.size());
BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true)
.addQuery("BINDID=", processInstId)
BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId)
.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);
@ -1035,7 +1071,8 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
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")+"成功发布回执单");
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");
@ -1223,7 +1260,7 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
ResponseObject ro_create = appAPI_create.callASLP(
appAPI_create.getAppContext(processExecutionContext.getProcessInstance().getAppId()),
aslps_create, params_create);
System.out.println("ro_create================" + ro_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")) {
@ -1334,13 +1371,11 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
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", 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("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)
@ -1374,8 +1409,7 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
LoginConst.DEVICE_PC);
System.out.println("办理者的sessionid>>>>>>>>>>>" + sessionId);
String downurl = downloadUtil.getzipURL(sessionId, bo.getString("TASKID"),
bo.getString("PUBLISHFILENAME"));
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 = "";
@ -1429,8 +1463,8 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
String wsId = model.getWsId();
String publishfileid = bo.getString("CHANGEDFILEIDNEW");
LinkedHashMap<String, String> downloadurl = downloadUtil.outputReportDownload(
UserContext.fromUID(processExecutionContext.getTaskInstance().getTarget()),
bo.getString("TASKID"), publishfileid);
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"));
@ -1443,12 +1477,10 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
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());
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) {
@ -1523,5 +1555,4 @@ public class ProcessEndAfterEvent extends ExecuteListener implements ExecuteList
}
}
}