OA待阅开发为ALSP调用

This commit is contained in:
zhaol 2025-02-05 17:08:34 +08:00
parent a908f35ffc
commit 742174a615
5 changed files with 256 additions and 32 deletions

View File

@ -33,7 +33,6 @@ public class SendEHSQAlsp implements ASLP {
String isSendEHSQ = String.valueOf(map.get("isSendEHSQ"));
Connection open = DBSql.open();
// 流程发布的新增发布
List<BO> bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).connection(open)
.addQuery("BINDID=", processId).list();

View File

@ -79,7 +79,6 @@ public class SendKMSAlsp implements ASLP {
} catch (Exception e) {
// TODO: handle exception
}
//System.err.println("系统人员=====>" + userList1);
// 项目开发人员
ArrayList<String> userList2 = new ArrayList<String>();
try {
@ -88,7 +87,6 @@ public class SendKMSAlsp implements ASLP {
} catch (Exception e) {
// TODO: handle exception
}
//System.err.println("项目开发人员=====>" + userList2);
// 离退人员
ArrayList<String> userList3 = new ArrayList<String>();
try {
@ -97,12 +95,10 @@ public class SendKMSAlsp implements ASLP {
} catch (Exception e) {
// TODO: handle exception
}
//System.err.println("离退人员=====>" + userList3);
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 = '"
// + instanceById.getId() + "' AND USER_ID = '" + userId + "'");
if (!"10033643".equals(userId) && !userList1.contains(userId)
&& !userList2.contains(userId) && !userList3.contains(userId)) {
sendList.add(userId);

View File

@ -0,0 +1,223 @@
package com.actionsoft.apps.coe.pal.publisher.alsp;
import com.actionsoft.apps.coe.pal.publisher.pubEvent.UtilUrl;
import com.actionsoft.apps.resource.interop.aslp.ASLP;
import com.actionsoft.apps.resource.interop.aslp.Meta;
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.mvc.view.ResponseObject;
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.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 发送OA待阅
*/
public class SendOAReadAlsp implements ASLP {
private int sendTotal;
@Override
@Meta(parameter = {"name:'processId',required:true,desc:'流程实例ID'",
"name:'userIds',required:true,desc:'userIds'"})
public ResponseObject call(Map<String, Object> map) {
String processId = String.valueOf(map.get("processId"));
String userIds = String.valueOf(map.get("userIds"));
String type = String.valueOf(map.get("type"));
ProcessInstance instanceById = SDK.getProcessAPI().getInstanceById(processId);
BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true)
.addQuery("BINDID=", instanceById.getId())
.addQuery("OPTIONTYPE IS NOT NULL", null).detail();
String sql = "SELECT ID FROM WFH_TASK WHERE PROCESSINSTID = '" + instanceById.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="
+ instanceById.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="
+ instanceById.getId() + "&taskInstId="
+ taskInd;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//Timestamp endTime = taskInstance.getBeginTime();
Timestamp endTime = new Timestamp(System.currentTimeMillis());
JSONObject jsonObjects = new JSONObject(new LinkedHashMap());
jsonObjects.put("action", "read");
jsonObjects.put("title", " " + "" + bo_act_coe_publish1.getString("PROCESS_TITLE") + "");
jsonObjects.put("dept", SDK.getORGAPI()
.getDepartmentByUser(ta.getTarget()).getNo());// SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo()
String target = ta.getTarget();
jsonObjects.put("user", target);
// jsonObject.put("user",);//processExecutionContext.getProcessInstance().getCreateUser()
jsonObjects.put("date", sdf.format(endTime));
jsonObjects.put("remark", bo_act_coe_publish1.getString("PROCESS_TITLE"));
jsonObjects.put("status", "0");
jsonObjects.put("dataid",instanceById.getId());
jsonObjects.put("pcurl", url);
jsonObjects.put("mobileurl", mobileurl);
String[] resrt = userIds.split(",");
long start_time = System.currentTimeMillis();
BO bo_OA_read = new BO();
bo_OA_read.set("FIR_NUMS",resrt.length);
bo_OA_read.set("START_TIME",start_time);
jsonObjects.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[" + jsonObjects + "]]>" + " </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");
UtilUrl uc=new UtilUrl();
String postSoap =uc.doPostSoap(readurl, xmlStr, "");
Document document = null;
try {
document = DocumentHelper.parseText(postSoap);
} catch (DocumentException e) {
e.printStackTrace();
}
Element rootElement = document.getRootElement();
Element result = rootElement.element("Body").element("serviceResponse").element("out");
String resultString = result.getData().toString();
JSONObject jsonObject1 = JSON.parseObject(resultString);
String datas = jsonObject1.getString("data");
long have_time = System.currentTimeMillis();
bo_OA_read.set("HAVE_TIME",have_time);
bo_OA_read.set("SUM_TIME",(have_time-start_time));
String status = jsonObject1.getString("status");
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", instanceById.getTitle());
bo.set("PROCESSID", instanceById.getId());
bo.set("USER_ID", user);
if(UtilString.isNotEmpty(SDK.getORGAPI().getUser(user).getDepartmentId())){
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);
}
SDK.getBOAPI().create("BO_ACT_DATAID",recordLists, instanceById, UserContext.fromUID(instanceById.getCreateUser()));
long endTime2 = System.currentTimeMillis();
System.err.println(instanceById.getTitle() + "批量插入OA待阅数据====>" + "用时:"
+ (endTime2 - startTime2) / 1000 + "");
BO oa_real_time=SDK.getBOAPI().query("BO_ACT_OA_REAL_TIME").addQuery("PROCESSID=",instanceById.getId()).detail();
String sqly = "SELECT COUNT(1) FROM BO_ACT_DATAID WHERE PROCESSID=? AND SENDTYPE='1'";
int mapsy = DBSql.getInt(sqly, new Object[]{instanceById.getId()});
if(oa_real_time!=null){
int r1 = DBSql.update("UPDATE BO_ACT_OA_REAL_TIME SET SENDNUMSJ='" +mapsy + "'WHERE PROCESSID ='" + instanceById.getId() + "'");
}else{
BO publishbo=SDK.getBOAPI().query("BO_ACT_COE_PUBLISH").bindId(instanceById.getId()).detail();
String user=publishbo.getString("APPLYUSERNAME");
//插入实时更新人数表
BO realTimeBO=new BO();
realTimeBO.set("USREID", user);
realTimeBO.set("DEPID", "");
realTimeBO.set("BUNAME","");
realTimeBO.set("TITLE", instanceById.getTitle());
realTimeBO.set("PROCESSID", instanceById.getId());
realTimeBO.set("SENDNUMSJ", 1);
realTimeBO.set("SENDNUM",sendTotal);
SDK.getBOAPI().create("BO_ACT_OA_REAL_TIME", realTimeBO, instanceById, UserContext.fromUID(instanceById.getCreateUser()));
}
}
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",instanceById.getId());
SDK.getBOAPI().create("BO_EU_OA_READ_LOG", bo_OA_read, instanceById, UserContext.fromUID(instanceById.getCreateUser()));
if("单个账号推送".equals(type)) {
DBSql.update("UPDATE BO_EU_READ_COUNT SET RESULT = '已重新推送' WHERE PROCESSID = '"+instanceById+"' 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(instanceById.getTitle() + "待阅推送失败:" + userId);
try {
bo= new BO();
bo.set("TITLE", instanceById.getTitle());
bo.set("NAME", userId);
bo.set("TYPE", type);
bo.set("RESULT", "待处理");
bo.set("PROCESSID", instanceById.getId());
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", instanceById.getTitle());
bo.set("NAME", userIds);
bo.set("TYPE", type);
bo.set("RESULT", "待处理");
bo.set("PROCESSID", instanceById.getId());
bo.set("DEPNAME", SDK.getORGAPI().getUser(userIds).getDepartmentId());
//SDK.getBOAPI().create("BO_EU_READ_COUNT", bo, processInstance.getId(), processInstance.getCreateUser());
recordFailLists.add(bo);
}
}
SDK.getBOAPI().create("BO_EU_READ_COUNT", recordFailLists, instanceById, UserContext.fromUID(instanceById.getCreateUser()));
}
}
return null;
}
}

View File

@ -356,15 +356,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
long countTime = System.currentTimeMillis();
System.err.println(instanceById.getTitle() + "待发送人员数量====>" + sendList.size() + " 计算用时===>"
+ (countTime - sendUserstartTime) + "毫秒");
/*
* 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"));
}*/
String sql = "SELECT ID FROM WFH_TASK WHERE PROCESSINSTID = '" + processInstance.getId()
+ "' AND ACTIVITYDEFID = 'obj_c9e5a3144b200001b68cffa01ed0153e' ";
String taskInd = DBSql.getString(sql);
@ -441,10 +433,10 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
/**
* 更新数据看板底表
*/
try {
/*try {
AttrSynAslp(processInstance, wsId, filed);
} catch (Exception e) {
}
}*/
} catch (Exception e) {
@ -494,14 +486,12 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
// 创建线程来实现为每100人为一个的线程跑待阅
ProcessInstance instanceById = processInstance;
CountDownLatch countDownLatch = new CountDownLatch(list.size());
ExecutorService service = Executors.newFixedThreadPool(4);
//ExecutorService service = Executors.newFixedThreadPool(4);
int m = 0;
for (String[] resrt:list
) {
int finalM = m;
for (String[] resrt:list) {
/*int finalM = m;
service.execute(new Runnable() {
@Override
public void run() {
String userIds = "";
userIds = StringUtils.join(resrt, ",");
@ -514,9 +504,25 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
}
});
m++;
m++;*/
// 调用方
String sourceAppId = "com.actionsoft.apps.coe.pal.publisher";
// 服务地址
String aslp = "aslp://com.actionsoft.apps.coe.pal.publisher/SendOAReadAlsp";
Map<String, Object> params = new HashMap<String, Object>();
// 给定必填参数
params.put("processId", processInstance.getId());
String userIds = "";
userIds = StringUtils.join(resrt, ",");
params.put("userIds",userIds);
AppAPI appApi = SDK.getAppAPI();
//统一接口中心请求调用
appApi.asynCallASLP(appApi.getAppContext(sourceAppId), aslp, params);
}
countDownLatch.await();
/*countDownLatch.await();
if (countDownLatch.getCount()==0){
try {
@ -567,7 +573,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
}
} else {
System.out.println("超过等待时间,部分任务未执行完毕");
}
}*/
}
@ -888,7 +894,6 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
* @return
*/
public boolean AttrSynAslp(ProcessInstance processInstance, String wsId, JSONArray fileId) {
System.out.println("");
// 调用App
String sourceAppId = processInstance.getAppId();
// aslp服务地址
@ -1685,9 +1690,10 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
wsId = model.getWsId();
String publishfileid = bo.getString("PUBLISHFILEID");
filed.add(publishfileid);
String sql_n = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '" + publishfileid + "'";
RowMap map = DBSql.getMap(sql_n);
if (StringUtils.isEmpty(map.getString("EXT4"))) {
PALRepositoryModel plmodel = PALRepositoryCache.getCache().get(publishfileid);
if (StringUtils.isEmpty(plmodel.getExt4())) {
// aslp服务地址
String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl";
// 参数定义列表
@ -1697,8 +1703,8 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
//知识名称,必填
String level = "";
if (map != null) {
String pver = map.getString("PLVER");
if (plmodel != null) {
String pver = String.valueOf(plmodel.getLevel());
if (UtilString.isNotEmpty(pver)) {
if (pver.contains(".00")) {
String levels = pver;
@ -1710,7 +1716,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
}
}
}
params_create.put("knwlName", map.getString("PLNAME") + "V" + level);
params_create.put("knwlName",plmodel.getName() + "V" + level);
//是否可以评论,必填
params_create.put("isComment", true);
//是否可以评分,必填