刷新权限阅览数据局

This commit is contained in:
zhal 2024-07-17 14:33:08 +08:00
parent c46f0526be
commit 6dda0941af

View File

@ -0,0 +1,273 @@
package com.actionsoft.apps.coe.pal.datamigration;
import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
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.commons.login.constant.LoginConst;
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
import com.actionsoft.bpms.schedule.IJob;
import com.actionsoft.bpms.server.SSOUtil;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.sdk.local.SDK;
import com.actionsoft.sdk.local.api.AppAPI;
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 org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
public class sendxgoajob implements IJob {
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
String jobParameter = SDK.getJobAPI().getJobParameter(jobExecutionContext);
String owern = jobParameter.split(",")[0];
String title = jobParameter.split(",")[1];
String bindid = jobParameter.split(",")[2];
ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance("obj_11aeee27b9a54a428aa42a05376ee81d", owern, jobParameter+ "文件的宣贯任务");
SDK.getProcessAPI().start(processInstance);
BO boRecordData=new BO();
boRecordData.set("PROCESS_NAME",title);
SDK.getBOAPI().create("BO_ACT_DOCUMENT_PUBLICITY_TASK", boRecordData, processInstance.getId(), "");
String sessionId = new SSOUtil().registerClientSessionNoPassword(
owern, LoginConst.DEFAULT_LANG, "localhost",
LoginConst.DEVICE_PC);
TaskInstance taskInstance= SDK.getTaskAPI().getInstanceById(processInstance.getStartTaskInstId());
try {
sendOaPending(taskInstance,processInstance,sessionId);
} catch (IOException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
String url="https://bpm.yili.com:8088/portal/r/w?sid="+""+"&cmd=CLIENT_BPM_FORM_MAIN_PAGE_OPEN&processInstId="+processInstance.getId()+"&openState=1&taskInstId="+processInstance.getStartTaskInstId()+"&displayToolbar=true";
int update = DBSql.update("update BO_ACT_COE_PUBLISH set XGRWLJ = '" + url + "' where BINDID = '" +bindid + "'");
}
/**
* 发送待办
*
* @param taskInstance DD
* @throws DocumentException
*/
public void sendOaPending(TaskInstance taskInstance, ProcessInstance processInstance, String sid) throws IOException, DocumentException {
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_DOCUMENT_PUBLICITY_TASK", true).addQuery("BINDID=", processInstance.getId()).addQuery("PROCESS_NAME is not null",null).detail();
if (!processInstance.getParentTaskInstId().equals("00000000-0000-0000-0000-000000000000")){
if (bo_act_coe_publish!=null){
String title = bo_act_coe_publish.getString("PROCESS_NAME");
if(title.contains("&")) {
xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+title.replace("&", "-")+"】,点击进行处理");
}else {
xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+title+"】,点击进行处理");
}
}else {
xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+processInstance.getTitle()+"】,点击进行处理");
}
}else {
xmlDatasUtil.setProcess_title(" 您有一条草稿流程保存成功【"+processInstance.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="+processInstance.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="+processInstance.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"));
}else {
xmlDatasUtil.setTo_do_login_account(target);
}
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(processInstance.getId());
xmlDatasUtil.setCurrentnodename(SDK.getRepositoryAPI().getProcessNode(processInstance.getProcessDefId(),taskInstance.getActivityDefId()).getName());
// 调用App
String sourceAppId = processInstance.getAppId();
// aslp服务地址
String aslp = "aslp://com.actionsoft.apps.processtrends/processNodeInfoASLP";
// 参数定义列表
Map params = new HashMap<String, Object>();
//流程实例id,必填
params.put("processInstId", processInstance.getId());
//,必填
params.put("sid", sid);
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("");
String title = processInstance.getTitle();
if(title.contains("&")) {
xmlDatasUtil.setWorkflowname(title.replaceAll("&", "-"));
}else {
xmlDatasUtil.setWorkflowname(title);
}
//xmlDatasUtil.setWorkflowname(pec.getProcessInstance().getTitle());
if (bo_eu_oa_reson!=null){
xmlDatasUtil.setCreaterhrcode(bo_eu_oa_reson.getString("LOGINID"));
}else {
xmlDatasUtil.setCreaterhrcode(target);
}
xmlDatasUtil.setCreaterworkcode("");
HttpClientUtils httpClientUtil = new HttpClientUtils();
String taskurl= "http://10.105.1.59/services/yili";
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()));
System.out.println("发送待办===>"+processInstance.getTitle()+"===>"+"状态码============》》》》》》》》》》》"+s);
Document document = null;
try {
document = DocumentHelper.parseText(s);
} catch (DocumentException e) {
e.printStackTrace();
}
Element rootElement = document.getRootElement();
//System.out.println("rootElement>>>>>>"+rootElement);
Element result = rootElement.element("Body").element("InsertTodoCominfoResponse").element("out");
String text = result.getText();
document = DocumentHelper.parseText(text);
Element rootElement2 = document.getRootElement();
Element statusElement = rootElement2.element("result");
Element messageElement = rootElement2.element("message");
String status = statusElement.getData().toString();
String message = messageElement.getData().toString();
if ("success".equals(status)){
System.out.println("发送待办成功===>"+processInstance.getTitle()+"===>"+taskInstance.getTarget()+"====>"+status+"===>"+message);
}else {
System.out.println("发送待办失败===>"+processInstance.getTitle()+"===>"+taskInstance.getTarget()+"====>"+status+"===>"+message);
}
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 processInstanceadmin = SDK.getProcessAPI().createProcessInstance("obj_ef1918ca1f9c46948f56bd5f77f4e646", "admin", "" + "失败更新待办");
BO bo_faid = new BO();
bo_faid.set("CHANGED","1");
bo_faid.set("TASK_ID",taskInstance.getId());
bo_faid.set("PROCESS_ID",processInstance.getId());
UserContext userContext = UserContext.fromUID("admin");
SDK.getBOAPI().create("BO_EU_FAID_DATA",bo_faid,processInstanceadmin,userContext);
SDK.getProcessAPI().start(processInstanceadmin);
}
}
}
}