定时器发送待阅

This commit is contained in:
zhal 2023-07-12 11:02:42 +08:00
parent 6e44cecf3f
commit 297c68760e
4 changed files with 718 additions and 0 deletions

View File

@ -0,0 +1,52 @@
package com.actionsoft.apps.coe.pal.datamigration.Utils;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import java.nio.charset.Charset;
/**
* @PackageName: com.awspaas.user.apps.yili.integration.util
* @ClassName: UtilUrl
* @author: lihongyu
* @date: 2022/5/18 21:41
*/
public class UtilUrl {
//使用SOAP1.1发送消息
public static String doPostSoap(String postUrl, String soapXml, String soapAction) {
String retStr = "";
// 创建HttpClientBuilder
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
// HttpClient
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
HttpPost httpPost = new HttpPost(postUrl);
// 设置请求和传输超时时间
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(900000)
.setConnectTimeout(900000).build();
httpPost.setConfig(requestConfig);
try {
httpPost.setHeader("Content-Type", "text/xml;charset=UTF-8");
httpPost.setHeader("SOAPAction", soapAction);
StringEntity data = new StringEntity(soapXml, Charset.forName("UTF-8"));
httpPost.setEntity(data);
CloseableHttpResponse response = closeableHttpClient.execute(httpPost);
HttpEntity httpEntity = response.getEntity();
if (httpEntity != null) {
// 打印响应内容
retStr = EntityUtils.toString(httpEntity, "UTF-8");
}
// 释放资源
closeableHttpClient.close();
} catch (Exception e) {
e.printStackTrace();
}
return retStr;
}
}

View File

@ -0,0 +1,613 @@
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.List;
public class ijob implements IJob {
private int sucount = 1;
@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("a4de6914-4158-45ab-984c-44ec812d879e");
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(), "");
*//*}*//*
}*/
for (String user : sendList) {
try {
SendOARead(jsonObject, pc, user, "批量推送");
} catch (Exception e) { // TODO: handle exception
}
}
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
* @param results
* @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 processExecutionContext
* @param jsonObject
* @param users
* @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", "10039924");
bo_Read_log.set("DEPID", "84bac1df-9374-4879-8706-4c4dcaf90201");
bo_Read_log.set("BUNAME", "总部");
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

@ -0,0 +1,53 @@
package com.actionsoft.apps.coe.pal.datamigration.utills;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import java.nio.charset.Charset;
/**
* @PackageName: com.awspaas.user.apps.yili.integration.util
* @ClassName: UtilUrl
* @author: yujh
* @date: 2022/5/18 21:41
*/
public class UtilUrl {
//使用SOAP1.1发送消息
public static String doPostSoap(String postUrl, String soapXml, String soapAction) {
String retStr = "";
// 创建HttpClientBuilder
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
// HttpClient
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
HttpPost httpPost = new HttpPost(postUrl);
// 设置请求和传输超时时间
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(6000)
.setConnectTimeout(6000).build();
httpPost.setConfig(requestConfig);
try {
httpPost.setHeader("Content-Type", "text/xml;charset=UTF-8");
httpPost.setHeader("SOAPAction", soapAction);
StringEntity data = new StringEntity(soapXml, Charset.forName("UTF-8"));
httpPost.setEntity(data);
CloseableHttpResponse response = closeableHttpClient.execute(httpPost);
HttpEntity httpEntity = response.getEntity();
if (httpEntity != null) {
// 打印响应内容
retStr = EntityUtils.toString(httpEntity, "UTF-8");
}
// 释放资源
closeableHttpClient.close();
} catch (Exception e) {
e.printStackTrace();
}
return retStr;
}
}