活动清单,由管理员刷新的视图列表,模型查看活动清单清除数据失败问题修改

This commit is contained in:
Mr-wang 2023-07-17 11:25:25 +08:00
parent d8cb9d2791
commit 88946dc738
4 changed files with 687 additions and 85 deletions

View File

@ -0,0 +1,616 @@
package com.actionsoft.apps.coe.pal.datamigration;
import com.actionsoft.apps.coe.pal.datamigration.Utils.UtilUrl;
import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance;
import com.actionsoft.bpms.commons.database.RowMap;
import com.actionsoft.bpms.org.model.DepartmentModel;
import com.actionsoft.bpms.org.model.UserModel;
import com.actionsoft.bpms.schedule.IJob;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.bpms.util.UtilString;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
public class CopyJob implements IJob {
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
String cc = SDK.getJobAPI().getJobParameter(jobExecutionContext);
System.err.println("推送OA待阅执行开始====>");
long startTime = System.currentTimeMillis();
ArrayList<String> sendList = new ArrayList<String>();
ProcessInstance pc = SDK.getProcessAPI().getInstanceById(cc);
BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true)
.addQuery("BINDID=", pc.getId())
.addQuery("OPTIONTYPE IS NOT NULL", null).detail();
String sql = "SELECT ID FROM WFH_TASK WHERE PROCESSINSTID = '" + pc.getId()
+ "' AND ACTIVITYDEFID = 'obj_c9e5a3144b200001b68cffa01ed0153e' ";
String taskInd = DBSql.getString(sql);
TaskInstance ta = SDK.getTaskAPI().getInstanceById(taskInd);
String portalUrl = SDK.getPortalAPI().getPortalUrl();
String url = portalUrl + "/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId="
+ pc.getId() + "&taskInstId="
+ taskInd;
String mobileurl = "https://bpm.yili.com:8088/portal"
+ "/r/or?cmd=com.yili_process_page_phone&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId="
+ pc.getId() + "&taskInstId="
+ taskInd;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//Timestamp endTime = processExecutionContext.getTaskInstance().getBeginTime();
Timestamp endTime = new Timestamp(System.currentTimeMillis());
JSONObject jsonObject = new JSONObject(new LinkedHashMap());
jsonObject.put("action", "read");
jsonObject.put("title", " " + "" + bo_act_coe_publish1.getString("PROCESS_TITLE") + "");
jsonObject.put("dept", SDK.getORGAPI()
.getDepartmentByUser(ta.getTarget()).getNo());// SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo()
String target = ta.getTarget();
jsonObject.put("user", target);
// jsonObject.put("user",);//processExecutionContext.getProcessInstance().getCreateUser()
jsonObject.put("date", sdf.format(endTime));
jsonObject.put("remark", bo_act_coe_publish1.getString("PROCESS_TITLE"));
jsonObject.put("status", "0");
jsonObject.put("dataid", pc.getId());
jsonObject.put("pcurl", url);
jsonObject.put("mobileurl", mobileurl);
int count = 1;
int count2 = 1;
int count3 = 1;
// 发送组织岗位职级
sendList = getSendList(pc, bo_act_coe_publish1, jsonObject);
ArrayList<String> finalList = new ArrayList<String>();
System.out.println("titile==============" + pc.getTitle());
System.out.println("sendList==============" + sendList.toString());
System.out.println("sendList.size()==============" + sendList.size());
List<String> finalLists = new ArrayList<>();
ProcessInstance boProcessInstance = SDK.getProcessAPI()
.createBOProcessInstance("obj_c14a0187c4d0463baa22752711f65947", "admin", "OA补充发送手动清单");
/* for (String oneid : sendList) {
BO actDataid = SDK.getBOAPI().query("BO_ACT_DATAID").addQuery("USER_ID=", oneid).addQuery("PROCESSID=", pc.getId()).detail();
BO actAlreadyDataid = SDK.getBOAPI().query("BO_ACT_ALREADY_DATAID").addQuery("USER_ID=", oneid).addQuery("PROCESSID=", pc.getId()).detail();
*//*if(actDataid==null && actAlreadyDataid==null){*//*
BO bo = new BO();
bo.set("PROCESSTITLE", pc.getTitle());
bo.set("JSRCODE", oneid);
bo.set("FBJG", "总部企业事务部");
bo.set("FFRCODE", "10039924");
bo.set("FBRQ", "2023-07-11");
bo.set("ZT", "未读");
String pcurl = "https://bpm.yili.com:8088/portal/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=" + pc.getId() + "&taskInstId=69bc4788-071b-41e0-a07c-b28ac6574a78&usercode=" + oneid;
bo.set("PCURL", pcurl);
String wqurl = "https://bpm.yili.com:8088/portal/r/or?cmd=com.yili_process_page_phone&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId=" + pc.getId() + "&taskInstId=69bc4788-071b-41e0-a07c-b28ac6574a78";
bo.set("QWURL", wqurl);
SDK.getBOAPI().create("BO_ACT_OA_SUPP_SENDING", bo, boProcessInstance.getId(), "");
*//*}*//*
}*/
List<String> list = new LinkedList<>();
List<BO> bo_eu_require_data = SDK.getBOAPI().query("BO_EU_REQUIRE_DATA", true).addQuery("PROCESS_ID = ", cc).list();
for(BO bo:bo_eu_require_data){
String id = bo.getString("USER_ID");
list.add(id);
}
System.out.println("新list>>>>>>"+list.size());
for (String user : list) {
try {
SendOARead(jsonObject, pc, user, "批量推送");
} catch (Exception e) { // TODO: handle exception
//2023-07-12 14:51:03--job worker-9d60ecf3-d70c-4b15-a271-6cfce754ff25,ijob--sendList.size()==============20393
}
}
long endTimes = System.currentTimeMillis();
// 存入日志
createReadLog(pc, jsonObject, sendList, startTime, endTimes);
System.err.println(pc.getTitle() + "推送OA待阅执行完毕====>" + "用时:"
+ (endTimes - startTime) / 1000 / 60 + "分钟");
}
/**
* 发送OA待阅数据
*
* @param jsonObject
* @param processInstance
* @throws DocumentException
*/
public void SendOARead(JSONObject jsonObject, ProcessInstance processInstance, String userIds, String type)
throws DocumentException {
String processInstId = processInstance.getId();
// System.err.println(processInstance.getTitle() + "开始发送:" + userId);
if ("".equals(userIds) || UtilString.isEmpty(userIds)) {
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"
+ " <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");
try {
String postSoap = UtilUrl.doPostSoap(readurl, xmlStr, "");
Document document = DocumentHelper.parseText(postSoap);
Element rootElement = document.getRootElement();
// System.out.println("rootElement>>>>>>" + rootElement);
Element result = rootElement.element("Body").element("serviceResponse").element("out");
String resultString = result.getData().toString();
JSONObject jsonObject1 = JSON.parseObject(resultString);
String datas = jsonObject1.getString("data");
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()+"");
int sucount = 1;
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);
SDK.getBOAPI().create("BO_ACT_DATAID", bo, processInstance.getId(), processInstance.getCreateUser());
/*BO oa_real_time = SDK.getBOAPI().query("BO_ACT_OA_REAL_TIME").addQuery("PROCESSID=", processInstance.getId()).detail();
if (oa_real_time != null) {
int r1 = DBSql.update("UPDATE BO_ACT_OA_REAL_TIME SET SENDNUMSJ='" + sucount + "'WHERE PROCESSID ='" + processInstId + "'");
} 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);
SDK.getBOAPI().create("BO_ACT_OA_REAL_TIME", bo, processInstance.getId(), processInstance.getCreateUser());
}
sucount++;*/
}
if ("单个账号推送".equals(type)) {
DBSql.update("UPDATE BO_EU_READ_COUNT SET RESULT = '已重新推送' WHERE PROCESSID = '" + processInstId + "' AND NAME = '" + userIds + "'");
}
} else {
System.out.println(processInstance.getTitle() + "待阅推送失败:" + userIds);
try {
BO 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());
} catch (Exception e) {
// TODO: handle exception
}
}
} catch (Exception e) {
System.out.println(processInstance.getTitle() + "待阅推送失败:" + userIds);
BO 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());
}
}
public ArrayList<String> getSendList(ProcessInstance instanceById, BO bo_act_coe_publish1, JSONObject jsonObject) {
String sendType = bo_act_coe_publish1.getString("SEND_SCOP");
String org = bo_act_coe_publish1.getString("SEND_SCOPE_ORG");
String post = bo_act_coe_publish1.getString("SEND_SCOPE_POST");
String level = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL");
ArrayList<String> userList = new ArrayList<>();
if ("1".equals(sendType)) {
//System.err.println("发送全集团=====>" + instanceById.getTitle());
userList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, sendType);
} else {
/**
* 先组织和职级取交集然后再和岗位取并集
*/
if (UtilString.isNotEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isNotEmpty(level)) {
//System.err.println("发送组织/岗位/职级=====>" + instanceById.getTitle());
ArrayList<String> sendOrgList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject,
sendType);
ArrayList<String> sendLevel = sendLevel(level, sendOrgList, instanceById, bo_act_coe_publish1, jsonObject);
userList = sendPost(post, sendLevel, instanceById, bo_act_coe_publish1,
jsonObject);
}
// 如果职级为空组织/岗位取并集
if (UtilString.isNotEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isEmpty(level)) {
//System.err.println("发送组织/岗位=====>" + instanceById.getTitle());
ArrayList<String> sendOrgList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject,
sendType);
userList = sendPost(post, sendOrgList, instanceById, bo_act_coe_publish1, jsonObject);
}
// 如果岗位为空组织/职级取交集
if (UtilString.isNotEmpty(org) && UtilString.isEmpty(post) && UtilString.isNotEmpty(level)) {
//System.err.println("发送组织/职级=====>" + instanceById.getTitle());
ArrayList<String> sendOrgList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject,
sendType);
userList = sendLevel(level, sendOrgList, instanceById, bo_act_coe_publish1, jsonObject);
}
/**
* 组织为空 岗位和职级取并集
*/
if (UtilString.isEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isNotEmpty(level)) {
//System.err.println("发送岗位/职级=====>" + instanceById.getTitle());
ArrayList<String> sendLevel2 = sendLevel2(level, userList, instanceById, bo_act_coe_publish1, jsonObject);
userList = sendPost(post, sendLevel2, instanceById, bo_act_coe_publish1,
jsonObject);
}
// 如果只有组织不为空
if (UtilString.isNotEmpty(org) && UtilString.isEmpty(post) && UtilString.isEmpty(level)) {
//System.err.println("发送组织=====>" + instanceById.getTitle());
userList = sendOrg(org, userList, instanceById, bo_act_coe_publish1, jsonObject, sendType);
}
// 如果只有岗位不为空
if (UtilString.isEmpty(org) && UtilString.isNotEmpty(post) && UtilString.isEmpty(level)) {
//System.err.println("发送岗位=====>" + instanceById.getTitle());
userList = sendPost(post, userList, instanceById, bo_act_coe_publish1, jsonObject);
}
// 如果只有职级不为空
if (UtilString.isEmpty(org) && UtilString.isEmpty(post) && UtilString.isNotEmpty(level)) {
//System.err.println("发送职级=====>" + instanceById.getTitle());
userList = sendLevel2(level, userList, instanceById, bo_act_coe_publish1, jsonObject);
}
}
return userList;
}
// 只发送职级
public ArrayList<String> sendLevel2(String level, ArrayList<String> userList, ProcessInstance instanceById,
BO bo_act_coe_publish1, JSONObject jsonObject) {
String processid = instanceById.getId();
ArrayList<String> userList_level = new ArrayList<String>();
// 获取职级
if (StringUtils.isNotEmpty(level)) {
String ranks[] = level.split(",");
String rankss = "";
if (ranks.length == 1) {
// DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN ");
rankss = "'" + ranks[0] + "'";
} else {
rankss = "'" + StringUtils.join(ranks, "','") + "'";
}
// 取交集
String sql2 = "select * from ORGUSER where EXT2 in (" + rankss + ") and userno is not null";
List<RowMap> maps2 = DBSql.getMaps(sql2);
for (RowMap rowMap : maps2) {
String userId = rowMap.getString("USERID");
boolean closed = SDK.getORGAPI().getUser(userId).isClosed();
if (!closed) {
userList_level.add(userId);
}
}
}
return userList_level;
}
// 发送岗位
public ArrayList<String> sendPost(String post, ArrayList<String> userList, ProcessInstance instanceById,
BO bo_act_coe_publish1, JSONObject jsonObject) {
String processid = instanceById.getId();
// 获取岗位
if (StringUtils.isNotEmpty(post)) {
String posts[] = post.split(",");
// 取并集
String postss = "";
if (posts.length == 1) {
// DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN ");
postss = "'" + posts[0] + "'";
} else {
postss = "'" + StringUtils.join(posts, "','") + "'";
}
String sql = "select * from ORGUSER where POSITION_NO in (" + postss + ") and userno is not null";
List<RowMap> maps1 = DBSql.getMaps(sql);
for (RowMap rowMap : maps1) {
String userId = rowMap.getString("USERID");
if (!userList.contains(userId)) {
boolean closed = SDK.getORGAPI().getUser(userId).isClosed();
if (!closed) {
userList.add(userId);
}
}
}
}
return userList;
}
// 发送组织
public ArrayList<String> sendOrg(String org, ArrayList<String> userList, ProcessInstance instanceById,
BO bo_act_coe_publish1, JSONObject jsonObject, String sendType) {
String processid = instanceById.getId();
// 获取组织
if (StringUtils.isNotEmpty(org) || "1".equals(sendType)) {
long startTime = System.currentTimeMillis();
userList = getUser(jsonObject, org, sendType, processid);
long endTimes = System.currentTimeMillis();
// System.out.println(instanceById.getTitle()+"_根据部门获取人员用时===>"+(endTimes-startTime)/1000);
}
return userList;
}
// 发送职级
public ArrayList<String> sendLevel(String level, ArrayList<String> userList, ProcessInstance instanceById,
BO bo_act_coe_publish1, JSONObject jsonObject) {
String processid = instanceById.getId();
ArrayList<String> userList_level = new ArrayList<String>();
// 获取职级
if (StringUtils.isNotEmpty(level)) {
String ranks[] = level.split(",");
String rankss = "";
if (ranks.length == 1) {
// DBSql.getMap("select USERID from ORGUSER WHERE POSITION_NO IN ");
rankss = "'" + ranks[0] + "'";
} else {
rankss = "'" + StringUtils.join(ranks, "','") + "'";
}
// 取交集
String sql2 = "select * from ORGUSER where EXT2 in (" + rankss + ") and userno is not null";
List<RowMap> maps2 = DBSql.getMaps(sql2);
for (RowMap rowMap : maps2) {
String userId = rowMap.getString("USERID");
if (userList.contains(userId)) {
boolean closed = SDK.getORGAPI().getUser(userId).isClosed();
if (!closed) {
userList_level.add(userId);
}
}
}
}
return userList_level;
}
/**
* 根据部门id获取当前部门以及下级部门的人员信息
*
* @param processid
* @return
*/
public ArrayList<String> getUser(JSONObject jsonObject, String depIds, String sendType, String processid) {
ArrayList<String> arr = new ArrayList<String>();
ArrayList<String> arr_test = new ArrayList<String>();
// 全集团
if ("1".equals(sendType)) {
List<DepartmentModel> departmentsByCompanyId = SDK.getORGAPI().getDepartmentsByCompanyId(1,
"8911e732-b42a-4556-853f-ad32761bcbee");
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)) {
getUserList(jsonObject, arr_test, arr, id, processid);
}
}
} else {
if (UtilString.isNotEmpty(depIds)) {
String[] split = depIds.split(",");
for (String depId : split) {
getUserList(jsonObject, arr_test, arr, depId, processid);
}
}
}
// System.err.println(SDK.getProcessAPI().getInstanceById(processid) +
// "_得到的总人数为" + arr_test.size());
// System.err.println(SDK.getProcessAPI().getInstanceById(processid) +
// "_得到的过滤后的人数为" + arr.size());
return arr;
}
public void getUserList(JSONObject jsonObject, ArrayList<String> arr_test, ArrayList<String> arr,
String departmentId, String processid) {
// 获取当前部门下人员
List<UserModel> userModelList = SDK.getORGAPI().getAllUsersByDepartment(departmentId);
for (UserModel userModel : userModelList) {
if (!userModel.isClosed()) {
String uid = userModel.getUID();
if (!arr.contains(uid)) {
if (!"10033643".equals(uid)) {
// System.err.println("发送人员======>" + uid); }
arr.add(uid);
}
/*
* RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '"
* + processid + "' AND USER_ID = '" + uid + "'"); if (map == null) {
* //System.err.println("发送人员======>" + uid); }
*/
}
}
}
// 获取当前部门的子部门人员
DepartmentModel departmentById = SDK.getORGAPI().getDepartmentById(departmentId);
if (departmentById.isExistSubModelOfCache()) {
getSubDepartments(jsonObject, arr_test, arr, departmentById, processid);
}
}
// 获取子部门人员
public void getSubDepartments(JSONObject jsonObject, ArrayList<String> arr_test, ArrayList<String> arr,
DepartmentModel departmentById, String processid) {
if (!departmentById.isClosed()) {
List<DepartmentModel> subDepartments = SDK.getORGAPI().getSubDepartments(departmentById.getId());
for (DepartmentModel departmentModel : subDepartments) {
if (!departmentModel.isClosed()) {
String id = departmentModel.getId();
List<UserModel> userModelList = SDK.getORGAPI().getAllUsersByDepartment(id);
for (UserModel userModel : userModelList) {
if (!userModel.isClosed()) {
String uid = userModel.getUID();
if (!arr.contains(uid)) {
if (!"10033643".equals(uid)) {
// System.err.println("发送人员======>" + uid); }
arr.add(uid);
}
// System.err.println(SDK.getProcessAPI().getInstanceById(processid) +
// "_发送人员======>" + uid);
}
}
}
// 递归获取子部门下的子部门
if (SDK.getORGAPI().isExistSubDepartment(id)) {
getSubDepartments(jsonObject, arr_test, arr, SDK.getORGAPI().getDepartmentById(id), processid);
}
}
}
}
}
/**
* 创建待阅日志
*
* @param jsonObject
* @param startTime
*/
public void createReadLog(ProcessInstance pc, JSONObject jsonObject,
ArrayList<String> arr, long startTime, long endTimes) {
BO bo_Read_log = new BO();
String processInstId = pc.getId();
bo_Read_log.set("USREID", pc.getCreateUser());
bo_Read_log.set("DEPID", pc.getCreateUserDeptId());
bo_Read_log.set("BUNAME", UserContext.fromUID(pc.getCreateUser()).getUserModel().getExt4());
bo_Read_log.set("TITLE", jsonObject.get("title"));
bo_Read_log.set("PROCESSID", processInstId);
bo_Read_log.set("SENDNUM", arr.size());
String sqly = "SELECT ID FROM BO_ACT_DATAID WHERE PROCESSID = '" + processInstId + "' AND SENDTYPE = '1'";
List<RowMap> mapsy = DBSql.getMaps(sqly);
String alsqly = "SELECT ID FROM BO_ACT_ALREADY_DATAID WHERE PROCESSID = '" + processInstId + "' AND SENDTYPE = '1'";
List<RowMap> almapsy = DBSql.getMaps(alsqly);
bo_Read_log.set("SENDNUMSJ", mapsy.size() + almapsy.size());
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);
String SEND_SCOPE_ORG = bo_act_coe_publishs.getString("SEND_SCOPE_ORG");
if (UtilString.isNotEmpty(SEND_SCOPE_ORG)) {
String[] resulr = SEND_SCOPE_ORG.split(",");
bo_Read_log.set("SEND_SCOPE_ORGNUM", resulr.length);
}
String SEND_SCOPE_POST = bo_act_coe_publishs.getString("SEND_SCOPE_POST");
if (UtilString.isNotEmpty(SEND_SCOPE_POST)) {
String[] resulr = SEND_SCOPE_POST.split(",");
bo_Read_log.set("SEND_SCOPE_POST_NUM", resulr.length);
}
String SEND_SCOPE_LEVEL = bo_act_coe_publishs.getString("SEND_SCOPE_LEVEL");
if (UtilString.isNotEmpty(SEND_SCOPE_LEVEL)) {
String[] resulr = SEND_SCOPE_LEVEL.split(",");
bo_Read_log.set("SEND_SCOPE_LEVEL_NUM", resulr.length);
}
bo_Read_log.set("STARTTIMES", startTime);
bo_Read_log.set("ENDTIMES", endTimes);
long time = endTimes - startTime;
long diffSeconds = time / 1000 % 60;
long diffMinutes = time / (60 * 1000) % 60;
long diffHours = time / (60 * 60 * 1000) % 24;
long diffDays = time / (24 * 60 * 60 * 1000);
String remainTime = "";
if (diffDays != 0 && diffHours != 0) {
remainTime = diffDays + "" + diffHours + "小时" + diffMinutes + "分钟" + diffSeconds + "";
} else if (diffDays == 0 && diffHours != 0 && diffMinutes != 0) {
remainTime = diffHours + "小时" + diffMinutes + "分钟" + diffSeconds + "";
} else if (diffDays == 0 && diffHours == 0 && diffMinutes != 0) {
remainTime = diffMinutes + "分钟" + diffSeconds + "";
} else if (diffDays == 0 && diffHours == 0 && diffMinutes == 0) {
remainTime = diffSeconds + "";
}
bo_Read_log.set("TIMECOUNT", remainTime);
// 文件发布成功回执流程
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");
}
}

View File

@ -51,9 +51,11 @@ public class ViewRefishBeforeEvent implements DataWindowBeforeLoadEventInterface
continue;
}
ProcessInstance processInst = SDK.getProcessAPI().createBOProcessInstance("obj_f188537a313e4c6a9bb44eb65f2a0ecd", userContext.getUID(), "流程清单");
BO oldBo = (BO) ((BOQueryAPI) SDK.getBOAPI().query("BO_ACT_PAL_PROCESS_MANIFEST").addQuery("MODELID = ", publishFileId)).detail();
if (oldBo != null) {
SDK.getBOAPI().removeByBindId("BO_ACT_PAL_PROCESS_MANIFEST", oldBo.getBindId());
List<RowMap> maps = DBSql.getMaps("select distinct BINDID from BO_ACT_PAL_PROCESS_MANIFEST where MODELID = '" + publishFileId + "'");
if (maps != null) {
for (RowMap rowMap:maps){
SDK.getBOAPI().removeByBindId("BO_ACT_PAL_PROCESS_MANIFEST",rowMap.getString("BINDID"));
}
SDK.getBOAPI().create("BO_ACT_PAL_PROCESS_MANIFEST", bos, processInst, userContext);
} else {
SDK.getBOAPI().create("BO_ACT_PAL_PROCESS_MANIFEST", bos, processInst, userContext);

View File

@ -4569,9 +4569,12 @@ public class ProcessPublishWeb extends ActionWeb {
return ResponseObject.newErrResponse("模型不存在活动节点").toString();
}
ProcessInstance processInst = SDK.getProcessAPI().createBOProcessInstance("obj_f188537a313e4c6a9bb44eb65f2a0ecd", _uc.getUID(), "流程清单");
BO oldBo = (BO) ((BOQueryAPI) SDK.getBOAPI().query("BO_ACT_PAL_PROCESS_MANIFEST").addQuery("MODELID = ", publishFileId)).detail();
if (oldBo != null) {
SDK.getBOAPI().removeByBindId("BO_ACT_PAL_PROCESS_MANIFEST", oldBo.getBindId());
List<RowMap> maps = DBSql.getMaps("select distinct BINDID from BO_ACT_PAL_PROCESS_MANIFEST where MODELID = '" + publishFileId + "'");
if (maps != null) {
for (RowMap rowMap:maps){
System.out.println("执行了吧");
SDK.getBOAPI().removeByBindId("BO_ACT_PAL_PROCESS_MANIFEST",rowMap.getString("BINDID"));
}
SDK.getBOAPI().create("BO_ACT_PAL_PROCESS_MANIFEST", bos, processInst, _uc);
} else {
SDK.getBOAPI().create("BO_ACT_PAL_PROCESS_MANIFEST", bos, processInst, _uc);

View File

@ -272,12 +272,7 @@ 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").connection(open).list();
ArrayList<String> sendLists = new ArrayList<String>();
for (BO uid:bo_eu_oa_read_test) {
sendLists.add(uid.getString("USER_ID"));
}
new_uid = new_uid.join(",", sendLists);
new_uid = new_uid.join(",", sendList);
long startTimes = System.currentTimeMillis();
String[] users = new_uid.split(",");
System.out.println("new_uid>>>>>>>>>>>>>>"+users.length);
@ -302,7 +297,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
/**
* 创建线程发送待阅数据
*/
course(list,startTime,jsonObject,processExecutionContext);
course(list,startTime,jsonObject,processExecutionContext,sendList);
//System.out.println("发送人员数据>>>>>>>>>>>>>>"+list);
}else {
int size = users.length/length;
@ -321,7 +316,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
/**
* 创建线程发送待阅数据
*/
course(list,startTime,jsonObject,processExecutionContext);
course(list,startTime,jsonObject,processExecutionContext,sendList);
//System.out.println("发送人员数据>>>>>>>>>>>>>>"+list);
}
@ -394,76 +389,6 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
}*/
// 二次推送
List<RowMap> List = DBSql.getMaps("SELECT NAME FROM BO_EU_READ_COUNT WHERE PROCESSID = '"
+ instanceById.getId() + "' AND RESULT = '待处理'");
if (List.size() != 0) {
System.err.println(instanceById.getTitle() + "批量推送失败后执行二次推送=======>" + List.size());
/*BO executiveTaskBO=SDK.getBOAPI().query("BO_ACT_EXECUTIVE_TASK").addQuery("TASKID=",processExecutionContext.getProcessInstance().getId()).addQuery("TASKSTATUS=",2).detail();
if(executiveTaskBO!=null){
for (RowMap rowMap : List) {
BO bo = new BO();
bo.set("TITLE", processExecutionContext.getProcessInstance().getTitle());
bo.set("NAME", rowMap.getString("NAME"));
bo.set("TYPE", "批量推送");
bo.set("RESULT", "待处理");
bo.set("PROCESSID", processExecutionContext.getProcessInstance().getId());
bo.set("DEPNAME", SDK.getORGAPI().getUser(rowMap.getString("NAME")).getDepartmentId());
SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processExecutionContext.getProcessInstance().getId(), processExecutionContext.getProcessInstance().getCreateUser());
}
return;
}*/
for (RowMap rowMap : List) {
try {
ArrayList<String> secondUserList = new ArrayList<String>();
secondUserList.add(rowMap.getString("NAME"));
System.err.println(instanceById.getTitle() + "二次推送账号=======>" + secondUserList);
BO executiveTaskBO=SDK.getBOAPI().query("BO_ACT_EXECUTIVE_TASK").addQuery("TASKID=",processExecutionContext.getProcessInstance().getId()).addQuery("TASKSTATUS=",2).detail();
if(executiveTaskBO!=null){
List<BO> recordFailLists = new ArrayList<BO>();
for(RowMap oneuserId:List){
BO bo = new BO();
bo.set("TITLE", processExecutionContext.getProcessInstance().getTitle());
bo.set("NAME", oneuserId.getString("NAME"));
bo.set("TYPE", "批量推送");
bo.set("RESULT", "待处理");
bo.set("PROCESSID", processExecutionContext.getProcessInstance().getId());
bo.set("DEPNAME", SDK.getORGAPI().getUser(oneuserId.getString("NAME")).getDepartmentId());
recordFailLists.add(bo);
}
SDK.getBOAPI().create("BO_EU_READ_COUNT", recordFailLists, processExecutionContext.getProcessInstance().getId(), processExecutionContext.getProcessInstance().getCreateUser());
return;
}
secondSendOARead(jsonObject, instanceById, secondUserList, "单个账号推送");
} catch (Exception e) { // TODO: handle exception
}
}
}
long endTimes = System.currentTimeMillis();
// 存入日志
createReadLog(processExecutionContext, jsonObject, sendList, startTime, endTimes);
System.err.println(instanceById.getTitle() + "推送OA待阅执行完毕====>" + "用时:"
+ (endTimes - startTime) / 1000 / 60 + "分钟");
//发送消息通知
List<BO> readCountBO=SDK.getBOAPI().query("BO_EU_READ_COUNT").addQuery("PROCESSID=",processExecutionContext.getProcessInstance().getId()).list();
if(readCountBO.size()>0){
SDK.getNotificationAPI().sendMessage("admin", "admin", "文件名称:"+processExecutionContext.getProcessInstance().getTitle()+"文件有失败记录,请及时处理!!!");
}
//更新任务状态
int r1 = DBSql.update("UPDATE BO_ACT_EXECUTIVE_TASK SET ISTASKEND='2' WHERE TASKID ='" + processExecutionContext.getProcessInstance().getId() + "'");
}
@ -609,8 +534,9 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
* @param jsonObject
* @param processExecutionContext
*/
public void course(List<String[]> list,long startTime,JSONObject jsonObject,ProcessExecutionContext processExecutionContext){
public void course(List<String[]> list,long startTime,JSONObject jsonObject,ProcessExecutionContext processExecutionContext,ArrayList<String> sendList){
// 创建线程来实现为每100人为一个的线程跑待阅
ProcessInstance instanceById = processExecutionContext.getProcessInstance();
ExecutorService service = Executors.newFixedThreadPool(5);
for (String[] resrt:list
) {
@ -624,6 +550,61 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
SendOARead(jsonObject, processExecutionContext.getProcessInstance(), resrt,"批量推送");
} catch (DocumentException e) {
e.printStackTrace();
}finally {
if (i== list.size()-1){
List<RowMap> List = DBSql.getMaps("SELECT NAME FROM BO_EU_READ_COUNT WHERE PROCESSID = '"
+ instanceById.getId() + "' AND RESULT = '待处理'");
if (List.size() != 0) {
System.err.println(instanceById.getTitle() + "批量推送失败后执行二次推送=======>" + List.size());
for (RowMap rowMap : List) {
try {
ArrayList<String> secondUserList = new ArrayList<String>();
secondUserList.add(rowMap.getString("NAME"));
System.err.println(instanceById.getTitle() + "二次推送账号=======>" + secondUserList);
BO executiveTaskBO=SDK.getBOAPI().query("BO_ACT_EXECUTIVE_TASK").addQuery("TASKID=",processExecutionContext.getProcessInstance().getId()).addQuery("TASKSTATUS=",2).detail();
if(executiveTaskBO!=null){
List<BO> recordFailLists = new ArrayList<BO>();
for(RowMap oneuserId:List){
BO bo = new BO();
bo.set("TITLE", processExecutionContext.getProcessInstance().getTitle());
bo.set("NAME", oneuserId.getString("NAME"));
bo.set("TYPE", "批量推送");
bo.set("RESULT", "待处理");
bo.set("PROCESSID", processExecutionContext.getProcessInstance().getId());
bo.set("DEPNAME", SDK.getORGAPI().getUser(oneuserId.getString("NAME")).getDepartmentId());
recordFailLists.add(bo);
}
SDK.getBOAPI().create("BO_EU_READ_COUNT", recordFailLists, processExecutionContext.getProcessInstance().getId(), processExecutionContext.getProcessInstance().getCreateUser());
return;
}
secondSendOARead(jsonObject, instanceById, secondUserList, "单个账号推送");
} catch (Exception e) { // TODO: handle exception
}
}
}
long endTimes = System.currentTimeMillis();
// 存入日志
createReadLog(processExecutionContext, jsonObject, sendList, startTime, endTimes);
System.err.println(instanceById.getTitle() + "推送OA待阅执行完毕====>" + "用时:"
+ (endTimes - startTime) / 1000 / 60 + "分钟");
//发送消息通知
List<BO> readCountBO=SDK.getBOAPI().query("BO_EU_READ_COUNT").addQuery("PROCESSID=",processExecutionContext.getProcessInstance().getId()).list();
if(readCountBO.size()>0){
SDK.getNotificationAPI().sendMessage("admin", "admin", "文件名称:"+processExecutionContext.getProcessInstance().getTitle()+"文件有失败记录,请及时处理!!!");
}
//更新任务状态
int r1 = DBSql.update("UPDATE BO_ACT_EXECUTIVE_TASK SET ISTASKEND='2' WHERE TASKID ='" + processExecutionContext.getProcessInstance().getId() + "'");
}
}
i++;
}