631 lines
26 KiB
Java
631 lines
26 KiB
Java
package com.awspaas.user.apps.integration.oa;
|
||
|
||
import java.io.ByteArrayInputStream;
|
||
import java.io.IOException;
|
||
import java.sql.Timestamp;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.*;
|
||
import java.util.regex.Matcher;
|
||
import java.util.regex.Pattern;
|
||
|
||
import com.actionsoft.bpms.bo.engine.BO;
|
||
import com.actionsoft.bpms.bpmn.engine.ProcessAPIManager;
|
||
import com.actionsoft.bpms.bpmn.engine.core.context.TaskBehaviorContextImpl;
|
||
import com.actionsoft.bpms.bpmn.engine.model.run.TaskCommentModel;
|
||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
|
||
import com.actionsoft.bpms.commons.login.constant.LoginConst;
|
||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||
import com.actionsoft.bpms.server.SSOUtil;
|
||
import com.actionsoft.bpms.server.UserContext;
|
||
import com.actionsoft.sdk.local.api.AppAPI;
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.alibaba.fastjson.JSONArray;
|
||
import com.awspaas.user.apps.integration.XmlDatasUtil;
|
||
import org.apache.commons.httpclient.HttpStatus;
|
||
import org.apache.commons.lang3.StringUtils;
|
||
import org.dom4j.Document;
|
||
import org.dom4j.DocumentException;
|
||
import org.dom4j.DocumentHelper;
|
||
import org.dom4j.Element;
|
||
import org.dom4j.xpath.DefaultXPath;
|
||
import org.slf4j.Logger;
|
||
import org.slf4j.LoggerFactory;
|
||
|
||
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
|
||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance;
|
||
import com.actionsoft.bpms.org.cache.UserCache;
|
||
import com.actionsoft.bpms.org.model.UserModel;
|
||
import com.actionsoft.exception.BPMNError;
|
||
import com.actionsoft.sdk.local.SDK;
|
||
import com.actionsoft.sdk.local.api.NotificationAPI;
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import com.awspaas.user.apps.integration.util.HttpClientUtils;
|
||
import org.w3c.dom.Node;
|
||
import org.w3c.dom.NodeList;
|
||
|
||
import javax.xml.soap.*;
|
||
|
||
/**
|
||
* @author lihyyu
|
||
*/
|
||
public class OaPendComponent {
|
||
|
||
private static Logger logger = LoggerFactory.getLogger(OaPendComponent.class);
|
||
|
||
private NotificationAPI notificationAPI = SDK.getNotificationAPI();
|
||
|
||
private String uri = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "uri");
|
||
private String userName = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "restUserName");
|
||
private String password = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "restUserPwd");
|
||
private String[] GO_BACK = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "GO_BACK").split("\\|");
|
||
|
||
|
||
private static class PostPendTask implements Runnable {
|
||
int type;
|
||
String url;
|
||
String taskId;
|
||
Object content;
|
||
|
||
public PostPendTask(String taskId, int type, String url, Object content) {
|
||
this.type = type;
|
||
this.url = url;
|
||
this.taskId = taskId;
|
||
this.content = content;
|
||
}
|
||
|
||
@Override
|
||
public void run() {
|
||
HttpClientUtils httpClientUtil = new HttpClientUtils();
|
||
Map<String, Object> map = new HashMap<>();
|
||
map.put("createTime", new Timestamp(new Date().getTime()));
|
||
map.put("calledCount", 1);
|
||
if (content instanceof OaPending) {
|
||
OaPending pend = (OaPending) this.content;
|
||
map.put("paramId", pend.getTaskId());
|
||
map.put("receiver", pend.getNoneBindingReceiver());
|
||
} else if (content instanceof OaMessage) {
|
||
OaMessage msg = (OaMessage) this.content;
|
||
map.put("paramId", msg.getThirdpartyMessageId());
|
||
map.put("receiver", msg.getNoneBindingReceiver());
|
||
}
|
||
String ty= "";
|
||
if (type == 0) {
|
||
ty = "推送";
|
||
map.put("method", "sendPending");
|
||
} else if (type == 1) {
|
||
ty = "消息";
|
||
map.put("method", "sendMsg");
|
||
} else if (type == 2) {
|
||
ty = "更新";
|
||
map.put("method", "updatePending");
|
||
} else {
|
||
throw new BPMNError("类型未定义!");
|
||
}
|
||
|
||
String params = JSONObject.toJSONString(content);
|
||
map.put("params", params);
|
||
if (params.contains("subState")) {
|
||
|
||
} else {
|
||
}
|
||
// httpClientUtil.setPostRequestBody(params,"application/json","UTF-8");
|
||
int httpStatus = 1;
|
||
if (httpStatus != HttpStatus.SC_OK) {
|
||
if(type==0||type==2) {
|
||
OaPendComponentLose opl = new OaPendComponentLose();
|
||
int careateProcess = opl.careateProcess(type,taskId, SDK.getTaskAPI().getInstanceById(taskId).getTarget());
|
||
if (careateProcess > 0) {
|
||
if (type == 0) {
|
||
logger.info("调用OA推送接口====>type:" + type + "taskId: " + taskId + ",url:" + url + ",失败!",
|
||
"已发起手动推送待办流程!");
|
||
}else if(type == 2){
|
||
logger.info("调用OA更新接口====>type:" + type + "taskId: " + taskId + ",url:" + url + ",失败!",
|
||
"已发起手动更新待办流程!");
|
||
}
|
||
}
|
||
|
||
}else {
|
||
logger.info("调用OA待办消息接口====>type:" + type + ",url:" + url + ",失败!" + "taskId: " + taskId);
|
||
}
|
||
|
||
|
||
} else {
|
||
logger.info("调用OA待办"+ty+"接口====>taskId: " + taskId + "返回结果:");
|
||
}
|
||
|
||
map.put("httpStatus", httpStatus);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 发送待办
|
||
*
|
||
* @param taskInstance DD
|
||
*/
|
||
public void sendOaPending(TaskInstance taskInstance, ProcessExecutionContext pec) throws IOException {
|
||
if("admin".equals(taskInstance.getTarget())) {
|
||
return;
|
||
}
|
||
XmlDatasUtil xmlDatasUtil = new XmlDatasUtil();
|
||
xmlDatasUtil.setExternal_system_ID("LCZD");
|
||
xmlDatasUtil.setOther_system_to_do_ID(taskInstance.getId());
|
||
BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", pec.getProcessInstance().getId()).detail();
|
||
if (!pec.getProcessInstance().getParentTaskInstId().equals("00000000-0000-0000-0000-000000000000")){
|
||
if (bo_act_coe_publish!=null){
|
||
xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+bo_act_coe_publish.getString("PROCESS_TITLE")+"】,点击进行处理");
|
||
}else {
|
||
BO bo_eu_1664184390101 = SDK.getBOAPI().query("BO_EU_1664184390101", true).addQuery("BINDID=", pec.getProcessInstance().getId()).detail();
|
||
if (bo_eu_1664184390101!=null){
|
||
xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+pec.getProcessInstance().getTitle()+"】,点击进行处理");
|
||
}else {
|
||
xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+pec.getProcessDef().name+"】,点击进行处理");
|
||
}
|
||
}
|
||
}else {
|
||
xmlDatasUtil.setProcess_title(" 您有一条草稿流程保存成功【"+pec.getProcessInstance().getTitle()+"】");
|
||
}
|
||
|
||
|
||
//http://localhost:8089/portal/r/or?cmd=com.yili_form_page_open&processInstId=3505e654-9217-41cd-a31d-4971846b3219&taskInstId=8a71d75e-3ee0-43a2-a226-ecb01419319c&oauthName=oauthLogin&token=admin
|
||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||
if (portalUrl.equals("http://10.114.11.135:8088/portal")){
|
||
portalUrl = "https://bpm.yili.com:8088/portal/";
|
||
}
|
||
xmlDatasUtil.setPcurl(portalUrl+"/r/or?cmd=com.yili_form_page_open&oauthName=oauthLogin&processInstId="+pec.getProcessInstance().getId()+"&taskInstId="+taskInstance.getId()+"&openState="+taskInstance.getState());
|
||
xmlDatasUtil.setMobileurl(portalUrl+"/r/or?cmd=com.yili_form_page_open&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&casaccount="+taskInstance.getTarget()+"&processInstId="+pec.getProcessInstance().getId()+"&taskInstId="+taskInstance.getId()+"&openState="+taskInstance.getState());
|
||
String target = taskInstance.getTarget();
|
||
|
||
//System.out.println("当前账户======》》》》"+target);
|
||
BO bo_eu_oa_reson = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("WORKCODE=" , target).detail();
|
||
//System.out.println("bo>>>>>>>>>>"+bo_eu_oa_reson);
|
||
if (bo_eu_oa_reson!=null){
|
||
xmlDatasUtil.setTo_do_login_account(bo_eu_oa_reson.getString("LOGINID"));
|
||
}
|
||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义格式,不显示毫秒
|
||
String str = df.format(taskInstance.getBeginTime());
|
||
String substring = str.substring(str.indexOf(" "), str.length());
|
||
xmlDatasUtil.setTo_do_creation_time(substring);
|
||
xmlDatasUtil.setTo_do_completion_time(substring);
|
||
//if (taskInstance.getState()==1){
|
||
xmlDatasUtil.setTo_do_status("0");
|
||
//}
|
||
xmlDatasUtil.setTo_do_official_type("0");
|
||
// if (taskInstance.getReadState()==0){
|
||
// xmlDatasUtil.setViewtype("0");
|
||
// }else if (taskInstance.getReadState()==1){
|
||
xmlDatasUtil.setViewtype("0");
|
||
// }
|
||
xmlDatasUtil.setCreatedate(str.substring(0, str.indexOf(" ")));
|
||
xmlDatasUtil.setDonedate(str.substring(0, str.indexOf(" ")));
|
||
/*String der ="";
|
||
if (taskInstance.getReadTime()!=null){
|
||
der = df.format(taskInstance.getReadTime());
|
||
xmlDatasUtil.setReceivedate(der.substring(0, der.indexOf(" ")));
|
||
xmlDatasUtil.setReceivetime(der.substring(der.indexOf(" "),der.length()));
|
||
}else {
|
||
der = df.format(taskInstance.getBeginTime());
|
||
xmlDatasUtil.setReceivedate(der.substring(0, der.indexOf(" ")));
|
||
xmlDatasUtil.setReceivetime(der.substring(der.indexOf(" "),der.length()));
|
||
}*/
|
||
xmlDatasUtil.setReceivedate(str.substring(0, str.indexOf(" ")));
|
||
xmlDatasUtil.setReceivetime(substring);
|
||
|
||
xmlDatasUtil.setCurrentnodetype("0");
|
||
xmlDatasUtil.setRequestcode(pec.getProcessInstance().getId());
|
||
xmlDatasUtil.setCurrentnodename(SDK.getRepositoryAPI().getProcessNode(pec.getProcessInstance().getProcessDefId(),taskInstance.getActivityDefId()).getName());
|
||
|
||
// 调用App
|
||
String sourceAppId = pec.getProcessInstance().getAppId();
|
||
// aslp服务地址
|
||
String aslp = "aslp://com.actionsoft.apps.processtrends/processNodeInfoASLP";
|
||
// 参数定义列表
|
||
Map params = new HashMap<String, Object>();
|
||
//流程实例id,必填
|
||
params.put("processInstId", pec.getProcessInstance().getId());
|
||
//,必填
|
||
params.put("sid", pec.getUserContext().getSessionId());
|
||
AppAPI appAPI = SDK.getAppAPI();
|
||
//流程节点数据
|
||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||
String username = "";
|
||
String userid = "";
|
||
if (ro.isOk()){
|
||
List list = new ArrayList();
|
||
Object processBudgetModelList = ro.get("processBudgetModelList");
|
||
JSONArray array = JSON.parseArray(String.valueOf(processBudgetModelList));
|
||
|
||
if (!array.isEmpty()){
|
||
for(int i=0;i<array.size();i++){
|
||
JSONObject jsonObject = JSONObject.parseObject(array.get(i).toString());
|
||
String executor = jsonObject.get("executor").toString();
|
||
String userid2 = jsonObject.get("userid2").toString();
|
||
//String userid2 = jsonArray.getJSONObject(i).getString("userid2");
|
||
username+=executor+" ";
|
||
}
|
||
}
|
||
}
|
||
if (bo_eu_oa_reson!=null){
|
||
xmlDatasUtil.setNooperator(bo_eu_oa_reson.getString("LOGINID"));
|
||
}
|
||
|
||
xmlDatasUtil.setWorkcode("");
|
||
xmlDatasUtil.setWorkflowname(pec.getProcessInstance().getTitle());
|
||
|
||
if (bo_eu_oa_reson!=null){
|
||
xmlDatasUtil.setCreaterhrcode(bo_eu_oa_reson.getString("LOGINID"));
|
||
}
|
||
xmlDatasUtil.setCreaterworkcode("");
|
||
|
||
|
||
|
||
HttpClientUtils httpClientUtil = new HttpClientUtils();
|
||
String taskurl= SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "taskurl");
|
||
|
||
String s = httpClientUtil.SendPend(taskurl, xmlDatasUtil);
|
||
//System.out.println("状态码============》》》》》》》》》》》"+s);
|
||
|
||
BO bo = new BO();
|
||
bo.set("OUTSYSID",xmlDatasUtil.getExternal_system_ID());
|
||
bo.set("TODOID",xmlDatasUtil.getOther_system_to_do_ID());
|
||
bo.set("CONTENT",xmlDatasUtil.getProcess_title());
|
||
bo.set("PCURL",xmlDatasUtil.getPcurl());
|
||
bo.set("MOBILEURL",xmlDatasUtil.getMobileurl());
|
||
bo.set("HRCODE",xmlDatasUtil.getTo_do_login_account());
|
||
bo.set("STATUS",xmlDatasUtil.getTo_do_status());
|
||
bo.set("WFTYPE",xmlDatasUtil.getTo_do_official_type());
|
||
bo.set("VIEWTYPE",xmlDatasUtil.getViewtype());
|
||
bo.set("CREATEDATES",xmlDatasUtil.getCreatedate());
|
||
bo.set("NEWCREATETIME",xmlDatasUtil.getTo_do_creation_time());
|
||
bo.set("DONEDATE",xmlDatasUtil.getDonedate());
|
||
bo.set("NEWDONETIME",xmlDatasUtil.getTo_do_status());
|
||
bo.set("RECEIVEDATE",xmlDatasUtil.getReceivedate());
|
||
bo.set("RECEIVETIME",xmlDatasUtil.getReceivetime());
|
||
bo.set("CURRENTNODETYPE",xmlDatasUtil.getCurrentnodetype());
|
||
bo.set("REQUESTCODE",xmlDatasUtil.getRequestcode());
|
||
bo.set("CURRENTNODENAME",xmlDatasUtil.getCurrentnodename());
|
||
bo.set("NOOPERATOR",xmlDatasUtil.getNooperator());
|
||
bo.set("CREATERHRCODE",xmlDatasUtil.getCreaterhrcode());
|
||
bo.set("WORKFLOWNAME",xmlDatasUtil.getWorkflowname());
|
||
bo.set("OA_RESULT",s);
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
bo.set("OA_DATE",sdf.format(new Date()));
|
||
SDK.getBOAPI().createDataBO("BO_EU_OA_MOBILEURL",bo,UserContext.fromUID(taskInstance.getTarget()));
|
||
if (s.contains("success")){
|
||
//System.out.println("发送待办任务完成,请去OA系统上查看是否传输完成");
|
||
}else {
|
||
//System.out.println("发送待办任务失败,请联系管理员查看是否出现错误");
|
||
//System.out.println("错误提示>>>>>>>>>>>>"+s);
|
||
BO bo_eu_faid_data = SDK.getBOAPI().query("BO_EU_FAID_DATA", true).addQuery("TASK_ID=", taskInstance.getId()).detail();
|
||
if (bo_eu_faid_data==null){
|
||
ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance("obj_ef1918ca1f9c46948f56bd5f77f4e646", "admin", pec.getUserContext().getUserName() + "失败更新待办");
|
||
BO bo_faid = new BO();
|
||
bo_faid.set("CHANGED","1");
|
||
bo_faid.set("TASK_ID",taskInstance.getId());
|
||
bo_faid.set("PROCESS_ID",pec.getProcessInstance().getId());
|
||
UserContext userContext = UserContext.fromUID("admin");
|
||
SDK.getBOAPI().create("BO_EU_FAID_DATA",bo_faid,processInstance,userContext);
|
||
SDK.getProcessAPI().start(processInstance);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 构造待办打开链接
|
||
*
|
||
* @return
|
||
*/
|
||
private String buildTaskUrl(TaskInstance taskInstance, ProcessExecutionContext pec) {
|
||
// portal 地址
|
||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||
// String portalUrl = "http://localhost:8088/portal";
|
||
// 执行人账a户
|
||
String target = taskInstance.getTarget();
|
||
|
||
// 流程实例id
|
||
String bindId = pec.getProcessInstance().getId();
|
||
// 任务实例id
|
||
String taskId = taskInstance.getId();
|
||
StringBuilder stringBuilder = new StringBuilder(portalUrl);
|
||
try {
|
||
// final String[] encodeRsa = encodeRsa(target);
|
||
stringBuilder.append("/r/or?cmd=com.yili_form_page_open&processInstId=").append(bindId)
|
||
.append("&taskInstId=").append(taskId).append("&uid=").append(target)
|
||
.append("&oauthName=oauthLogin");
|
||
return stringBuilder.toString();
|
||
} catch (Exception e) {
|
||
return null;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 更新待办状态
|
||
* @param taskInstance
|
||
* @param pec
|
||
*/
|
||
public void updatePending(TaskInstance taskInstance, ProcessExecutionContext pec) throws IOException, SOAPException, DocumentException {
|
||
if("admin".equals(taskInstance.getTarget())) {
|
||
return;
|
||
}
|
||
XmlDatasUtil xmlDatasUtil = new XmlDatasUtil();
|
||
xmlDatasUtil.setExternal_system_ID("LCZD");
|
||
|
||
xmlDatasUtil.setOther_system_to_do_ID(taskInstance.getId());
|
||
//System.out.println("pec.getProcessInstance()>>>>>>>>"+pec.getProcessInstance());
|
||
if(pec.getProcessInstance()!=null){
|
||
String actionName = getActionName(taskInstance);
|
||
if (actionName.equals("传阅")){
|
||
BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", pec.getProcessInstance().getId()).detail();
|
||
if (bo_act_coe_publish!=null){
|
||
xmlDatasUtil.setProcess_title(" 您有一条传阅流程【"+bo_act_coe_publish.getString("PROCESS_TITLE")+"】,点击进行处理");
|
||
}else {
|
||
BO bo_eu_1664184390101 = SDK.getBOAPI().query("BO_EU_1664184390101", true).addQuery("BINDID=", pec.getProcessInstance().getId()).detail();
|
||
if (bo_eu_1664184390101!=null){
|
||
xmlDatasUtil.setProcess_title(" 您有一条传阅流程【"+pec.getProcessInstance().getTitle()+"】,点击进行处理");
|
||
}else {
|
||
xmlDatasUtil.setProcess_title(" 您有一条传阅流程【"+pec.getProcessDef().name+"】,点击进行处理");
|
||
}
|
||
}
|
||
}else {
|
||
BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", pec.getProcessInstance().getId()).detail();
|
||
if (bo_act_coe_publish!=null){
|
||
xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+bo_act_coe_publish.getString("PROCESS_TITLE")+"】,点击进行处理");
|
||
}else {
|
||
BO bo_eu_1664184390101 = SDK.getBOAPI().query("BO_EU_1664184390101", true).addQuery("BINDID=", pec.getProcessInstance().getId()).detail();
|
||
if (bo_eu_1664184390101!=null){
|
||
xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+pec.getProcessInstance().getTitle()+"】,点击进行处理");
|
||
}else {
|
||
xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+pec.getProcessDef().name+"】,点击进行处理");
|
||
}
|
||
}
|
||
}
|
||
}else {
|
||
xmlDatasUtil.setProcess_title(" 您有一条发布流程被作废,点击进行处理");
|
||
}
|
||
|
||
//http://localhost:8089/portal/r/or?cmd=com.yili_form_page_open&processInstId=3505e654-9217-41cd-a31d-4971846b3219&taskInstId=8a71d75e-3ee0-43a2-a226-ecb01419319c&oauthName=oauthLogin&token=admin
|
||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||
if (portalUrl.equals("http://10.114.11.135:8088/portal")){
|
||
portalUrl = "https://bpm.yili.com:8088/portal/";
|
||
}
|
||
if (pec.getProcessInstance()!=null){
|
||
xmlDatasUtil.setPcurl("https://bpm.yili.com:8088/portal"+"/r/or?cmd=com.yili_form_page_open&oauthName=oauthLogin&processInstId="+pec.getProcessInstance().getId()+"&taskInstId="+taskInstance.getId()+"&openState="+taskInstance.getState());
|
||
xmlDatasUtil.setMobileurl("https://bpm.yili.com:8088/portal"+"/r/or?cmd=com.yili_form_page_open&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId="+pec.getProcessInstance().getId()+"&taskInstId="+taskInstance.getId()+"&openState="+taskInstance.getState());
|
||
}else {
|
||
xmlDatasUtil.setPcurl("https://bpm.yili.com:8088/portal"+"/r/or?cmd=CLIENT_BPM_FORM_TRACK_OPEN&oauthName=oauthLogin&processInstId="+taskInstance.getProcessInstId()+"&sourceApp=prm");
|
||
xmlDatasUtil.setMobileurl("https://bpm.yili.com:8088/portal"+"/r/or?cmd=CLIENT_BPM_FORM_TRACK_OPEN&corpid=wwb0ae23173b140618&appAgentId=1000014&oauthName=wechat&processInstId="+taskInstance.getProcessInstId()+"&sourceApp=prm");
|
||
}
|
||
|
||
String target = taskInstance.getTarget();
|
||
|
||
//System.out.println("当前账户======》》》》"+target);
|
||
BO bo_eu_oa_reson = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("WORKCODE=" , target).detail();
|
||
//System.out.println("bo>>>>>>>>>>>>>>"+bo_eu_oa_reson);
|
||
if (bo_eu_oa_reson!=null){
|
||
xmlDatasUtil.setTo_do_login_account(bo_eu_oa_reson.getString("LOGINID"));
|
||
}
|
||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义格式,不显示毫秒
|
||
if (taskInstance.getBeginTime()!=null){
|
||
String str = df.format(taskInstance.getBeginTime());
|
||
String substring = str.substring(str.indexOf(" "), str.length());
|
||
xmlDatasUtil.setTo_do_creation_time(substring);
|
||
xmlDatasUtil.setTo_do_completion_time(df.format(taskInstance.getBeginTime()).substring(df.format(taskInstance.getBeginTime()).indexOf(" "), df.format(taskInstance.getBeginTime()).length()));
|
||
xmlDatasUtil.setCreatedate(str.substring(0, str.indexOf(" ")));
|
||
xmlDatasUtil.setDonedate(df.format(taskInstance.getBeginTime()).substring(0, df.format(taskInstance.getBeginTime()).indexOf(" ")));
|
||
}else {
|
||
String str = df.format(new Date());
|
||
String substring = str.substring(str.indexOf(" "), str.length());
|
||
xmlDatasUtil.setTo_do_creation_time(substring);
|
||
xmlDatasUtil.setTo_do_completion_time(df.format(new Date()).substring(df.format(new Date()).indexOf(" "), df.format(new Date()).length()));
|
||
xmlDatasUtil.setCreatedate(str.substring(0, str.indexOf(" ")));
|
||
xmlDatasUtil.setDonedate(df.format(new Date()).substring(0, df.format(new Date()).indexOf(" ")));
|
||
}
|
||
|
||
xmlDatasUtil.setTo_do_status("1");
|
||
|
||
xmlDatasUtil.setTo_do_official_type("0");
|
||
|
||
xmlDatasUtil.setViewtype("-2");
|
||
|
||
|
||
String der = "";
|
||
if (taskInstance.getReadTime()==null){
|
||
der= df.format(new Date());
|
||
}else {
|
||
der= df.format(taskInstance.getReadTime());
|
||
}
|
||
|
||
xmlDatasUtil.setReceivedate(der.substring(0, der.indexOf(" ")));
|
||
xmlDatasUtil.setReceivetime(der.substring(der.indexOf(" "),der.length()));
|
||
if (taskInstance!=null){
|
||
String actionName = getActionName(taskInstance);
|
||
if (actionName.equals("确认发布")||equalsAction(GO_BACK, actionName)){
|
||
xmlDatasUtil.setCurrentnodetype("1");
|
||
}else{
|
||
xmlDatasUtil.setCurrentnodetype("0");
|
||
}
|
||
}else {
|
||
xmlDatasUtil.setCurrentnodetype("0");
|
||
}
|
||
|
||
|
||
if (pec.getProcessInstance()!=null) {
|
||
xmlDatasUtil.setRequestcode(pec.getProcessInstance().getId());
|
||
xmlDatasUtil.setCurrentnodename(SDK.getRepositoryAPI().getProcessNode(pec.getProcessInstance().getProcessDefId(),taskInstance.getActivityDefId()).getName());
|
||
// 调用App
|
||
String sourceAppId = pec.getProcessInstance().getAppId();
|
||
// aslp服务地址
|
||
String aslp = "aslp://com.actionsoft.apps.processtrends/processNodeInfoASLP";
|
||
// 参数定义列表
|
||
Map params = new HashMap<String, Object>();
|
||
//流程实例id,必填
|
||
params.put("processInstId", pec.getProcessInstance().getId());
|
||
//,必填
|
||
if (pec.getUserContext()!=null){
|
||
params.put("sid", pec.getUserContext().getSessionId());
|
||
}else {
|
||
String sessionId = new SSOUtil().registerClientSessionNoPassword(pec.getTaskInstance().getTarget(), LoginConst.DEFAULT_LANG, "127.0.0.1", LoginConst.DEVICE_PC);
|
||
params.put("sid", sessionId);
|
||
}
|
||
|
||
AppAPI appAPI = SDK.getAppAPI();
|
||
//流程节点数据
|
||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||
String username = "";
|
||
String userid = "";
|
||
if (ro.isOk()){
|
||
String data = ro.getData().toString();
|
||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||
JSONArray jsonArray = JSONArray.parseArray(jsonObject.getString("processBudgetModelList"));
|
||
if (!jsonArray.isEmpty()){
|
||
for(int i=0;i<jsonArray.size();i++){
|
||
String filename = jsonArray.getJSONObject(i).getString("executor");
|
||
String userid2 = jsonArray.getJSONObject(i).getString("userid2");
|
||
username+=filename+" ";
|
||
userid+=userid2+" ";
|
||
}
|
||
}
|
||
}
|
||
xmlDatasUtil.setNooperator(username);
|
||
}else {
|
||
xmlDatasUtil.setRequestcode("");
|
||
}
|
||
|
||
|
||
|
||
xmlDatasUtil.setWorkcode("");
|
||
if (pec.getProcessDef()!=null){
|
||
xmlDatasUtil.setWorkflowname(pec.getProcessDef().getName());
|
||
}else {
|
||
xmlDatasUtil.setWorkflowname("流程发布");
|
||
}
|
||
|
||
if (bo_eu_oa_reson!=null){
|
||
xmlDatasUtil.setCreaterhrcode(bo_eu_oa_reson.getString("LOGINID"));
|
||
|
||
|
||
}
|
||
|
||
xmlDatasUtil.setCreaterworkcode("");
|
||
HttpClientUtils httpClientUtil = new HttpClientUtils();
|
||
String taskurl= SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "taskurl");
|
||
|
||
String s = httpClientUtil.SendPend(taskurl, xmlDatasUtil);
|
||
|
||
//System.out.println("已办查看是否修改");
|
||
|
||
|
||
|
||
BO bo = new BO();
|
||
bo.set("OUTSYSID",xmlDatasUtil.getExternal_system_ID());
|
||
bo.set("TODOID",xmlDatasUtil.getOther_system_to_do_ID());
|
||
bo.set("CONTENT",xmlDatasUtil.getProcess_title());
|
||
bo.set("PCURL",xmlDatasUtil.getPcurl());
|
||
bo.set("MOBILEURL",xmlDatasUtil.getMobileurl());
|
||
bo.set("HRCODE",xmlDatasUtil.getTo_do_login_account());
|
||
bo.set("STATUS",xmlDatasUtil.getTo_do_status());
|
||
bo.set("WFTYPE",xmlDatasUtil.getTo_do_official_type());
|
||
bo.set("VIEWTYPE",xmlDatasUtil.getViewtype());
|
||
bo.set("CREATEDATES",xmlDatasUtil.getCreatedate());
|
||
bo.set("NEWCREATETIME",xmlDatasUtil.getTo_do_creation_time());
|
||
bo.set("DONEDATE",xmlDatasUtil.getDonedate());
|
||
bo.set("NEWDONETIME",xmlDatasUtil.getTo_do_status());
|
||
bo.set("RECEIVEDATE",xmlDatasUtil.getReceivedate());
|
||
bo.set("RECEIVETIME",xmlDatasUtil.getReceivetime());
|
||
bo.set("CURRENTNODETYPE",xmlDatasUtil.getCurrentnodetype());
|
||
bo.set("REQUESTCODE",xmlDatasUtil.getRequestcode());
|
||
bo.set("CURRENTNODENAME",xmlDatasUtil.getCurrentnodename());
|
||
bo.set("NOOPERATOR",xmlDatasUtil.getNooperator());
|
||
bo.set("CREATERHRCODE",xmlDatasUtil.getCreaterhrcode());
|
||
bo.set("WORKFLOWNAME",xmlDatasUtil.getWorkflowname());
|
||
bo.set("OA_RESULT",s);
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
bo.set("OA_DATE",sdf.format(new Date()));
|
||
if (taskInstance!=null&&StringUtils.isNotEmpty(taskInstance.getTarget())){
|
||
SDK.getBOAPI().createDataBO("BO_EU_OA_MOBILEURL",bo,UserContext.fromUID(taskInstance.getTarget()));
|
||
}else {
|
||
SDK.getBOAPI().createDataBO("BO_EU_OA_MOBILEURL",bo,UserContext.fromUID("admin"));
|
||
}
|
||
|
||
if (s.contains("success")){
|
||
//System.out.println("发送待办任务完成,请去OA系统上查看是否传输完成");
|
||
}else {
|
||
//System.out.println("发送待办任务失败,请联系管理员查看是否出现错误");
|
||
//System.out.println("错误提示>>>>>>>>>>>>"+s);
|
||
BO bo_eu_faid_data = SDK.getBOAPI().query("BO_EU_FAID_DATA").addQuery("TASK_ID=", taskInstance.getId()).detail();
|
||
if (bo_eu_faid_data==null){
|
||
ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance("obj_ef1918ca1f9c46948f56bd5f77f4e646", "admin", "admin" + "失败更新待办");
|
||
BO bo_faid = new BO();
|
||
bo_faid.set("CHANGED","2");
|
||
bo_faid.set("TASK_ID",taskInstance.getId());
|
||
if (pec.getProcessInstance()!=null){
|
||
bo_faid.set("PROCESS_ID",pec.getProcessInstance().getId());
|
||
}
|
||
UserContext userContext = UserContext.fromUID("admin");
|
||
SDK.getBOAPI().create("BO_EU_FAID_DATA",bo_faid,processInstance,userContext);
|
||
SDK.getProcessAPI().start(processInstance);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
public void readOa(String taskId) throws Exception {
|
||
HttpClientUtils httpClientUtil = new HttpClientUtils();
|
||
String taskurl= SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "taskurl");
|
||
|
||
String s = httpClientUtil.readOa(taskurl, taskId);
|
||
//System.out.println("是否更新成已读了》》》》》》》》》》"+s);
|
||
}
|
||
|
||
private String getActionName(TaskInstance taskInstance) {
|
||
if (null == taskInstance) {
|
||
return "";
|
||
}
|
||
String actionName = "";
|
||
Iterator<TaskCommentModel> iterator = null;
|
||
if (StringUtils.isNotEmpty(taskInstance.getProcessInstId())){
|
||
iterator= ProcessAPIManager.getInstance()
|
||
.getComments(taskInstance.getProcessInstId()).iterator();
|
||
|
||
|
||
TaskCommentModel next;
|
||
|
||
while (iterator.hasNext()) {
|
||
if ((next = iterator.next()).getTaskInstId().equals(taskInstance.getId())) {
|
||
actionName = next.getActionName();
|
||
}
|
||
}
|
||
}
|
||
return actionName;
|
||
}
|
||
|
||
private boolean equalsAction(String[] actions, String actionName) {
|
||
for (int i = 0, n = actions.length; i < n; i++) {
|
||
if (actions[i].equals(actionName)) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
private String gettaskname(TaskInstance taskInstance) {
|
||
if (null == taskInstance) {
|
||
return "";
|
||
}
|
||
final Iterator<TaskCommentModel> iterator = ProcessAPIManager.getInstance()
|
||
.getComments(taskInstance.getProcessInstId()).iterator();
|
||
TaskCommentModel next;
|
||
String actionName = "";
|
||
while (iterator.hasNext()) {
|
||
if ((next = iterator.next()).getTaskInstId().equals(taskInstance.getId())) {
|
||
actionName = next.getActionName();
|
||
}
|
||
}
|
||
return actionName;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
}
|