伊利集成项目代码提交
This commit is contained in:
parent
ba2d01c18f
commit
23c442187d
@ -0,0 +1,241 @@
|
||||
package com.awspaas.user.apps.integration;
|
||||
|
||||
/**
|
||||
* @author wangchengye
|
||||
* @description
|
||||
* @createtime 2022-07-09 15:54
|
||||
* @updateAndOther
|
||||
*/
|
||||
public class XmlDatasUtil {
|
||||
//外部系统ID
|
||||
private String External_system_ID;
|
||||
//其他系统待办ID
|
||||
private String Other_system_to_do_ID;
|
||||
//流程标题
|
||||
private String Process_title;
|
||||
////pc端的url地址
|
||||
private String pcurl;
|
||||
//s手机端的url地址
|
||||
private String mobileurl;
|
||||
//待办人的登录账号
|
||||
private String To_do_login_account;
|
||||
//待办创建时间
|
||||
private String To_do_creation_time;
|
||||
////待办办结时间
|
||||
private String To_do_completion_time;
|
||||
//待办状态
|
||||
private String To_do_status;
|
||||
//公文类型的待办
|
||||
private String To_do_official_type;
|
||||
//已读类型
|
||||
private String viewtype;
|
||||
//创建日期
|
||||
private String createdate;
|
||||
//待办办结日期
|
||||
private String donedate;
|
||||
//待办接收日期
|
||||
private String receivedate;
|
||||
//待办接收时间
|
||||
private String receivetime;
|
||||
//当前节点是否已经归档
|
||||
private String currentnodetype;
|
||||
//流程编号
|
||||
private String requestcode;
|
||||
//当前节点
|
||||
private String currentnodename;
|
||||
//未操作者
|
||||
private String nooperator;
|
||||
//待办人员工作工号
|
||||
private String workcode;
|
||||
//工作流程编号
|
||||
private String workflowname;
|
||||
//流程创建人员登录账号
|
||||
private String createrhrcode;
|
||||
//流程创建人员工号
|
||||
private String createrworkcode;
|
||||
|
||||
|
||||
public String getExternal_system_ID() {
|
||||
return External_system_ID;
|
||||
}
|
||||
|
||||
public void setExternal_system_ID(String external_system_ID) {
|
||||
External_system_ID = external_system_ID;
|
||||
}
|
||||
|
||||
public String getOther_system_to_do_ID() {
|
||||
return Other_system_to_do_ID;
|
||||
}
|
||||
|
||||
public void setOther_system_to_do_ID(String other_system_to_do_ID) {
|
||||
Other_system_to_do_ID = other_system_to_do_ID;
|
||||
}
|
||||
|
||||
public String getProcess_title() {
|
||||
return Process_title;
|
||||
}
|
||||
|
||||
public void setProcess_title(String process_title) {
|
||||
Process_title = process_title;
|
||||
}
|
||||
|
||||
public String getPcurl() {
|
||||
return pcurl;
|
||||
}
|
||||
|
||||
public void setPcurl(String pcurl) {
|
||||
this.pcurl = pcurl;
|
||||
}
|
||||
|
||||
public String getMobileurl() {
|
||||
return mobileurl;
|
||||
}
|
||||
|
||||
public void setMobileurl(String mobileurl) {
|
||||
this.mobileurl = mobileurl;
|
||||
}
|
||||
|
||||
public String getTo_do_login_account() {
|
||||
return To_do_login_account;
|
||||
}
|
||||
|
||||
public void setTo_do_login_account(String to_do_login_account) {
|
||||
To_do_login_account = to_do_login_account;
|
||||
}
|
||||
|
||||
public String getTo_do_creation_time() {
|
||||
return To_do_creation_time;
|
||||
}
|
||||
|
||||
public void setTo_do_creation_time(String to_do_creation_time) {
|
||||
To_do_creation_time = to_do_creation_time;
|
||||
}
|
||||
|
||||
public String getTo_do_completion_time() {
|
||||
return To_do_completion_time;
|
||||
}
|
||||
|
||||
public void setTo_do_completion_time(String to_do_completion_time) {
|
||||
To_do_completion_time = to_do_completion_time;
|
||||
}
|
||||
|
||||
public String getTo_do_status() {
|
||||
return To_do_status;
|
||||
}
|
||||
|
||||
public void setTo_do_status(String to_do_status) {
|
||||
To_do_status = to_do_status;
|
||||
}
|
||||
|
||||
public String getTo_do_official_type() {
|
||||
return To_do_official_type;
|
||||
}
|
||||
|
||||
public void setTo_do_official_type(String to_do_official_type) {
|
||||
To_do_official_type = to_do_official_type;
|
||||
}
|
||||
|
||||
public String getViewtype() {
|
||||
return viewtype;
|
||||
}
|
||||
|
||||
public void setViewtype(String viewtype) {
|
||||
this.viewtype = viewtype;
|
||||
}
|
||||
|
||||
public String getCreatedate() {
|
||||
return createdate;
|
||||
}
|
||||
|
||||
public void setCreatedate(String createdate) {
|
||||
this.createdate = createdate;
|
||||
}
|
||||
|
||||
public String getDonedate() {
|
||||
return donedate;
|
||||
}
|
||||
|
||||
public void setDonedate(String donedate) {
|
||||
this.donedate = donedate;
|
||||
}
|
||||
|
||||
public String getReceivedate() {
|
||||
return receivedate;
|
||||
}
|
||||
|
||||
public void setReceivedate(String receivedate) {
|
||||
this.receivedate = receivedate;
|
||||
}
|
||||
|
||||
public String getReceivetime() {
|
||||
return receivetime;
|
||||
}
|
||||
|
||||
public void setReceivetime(String receivetime) {
|
||||
this.receivetime = receivetime;
|
||||
}
|
||||
|
||||
public String getCurrentnodetype() {
|
||||
return currentnodetype;
|
||||
}
|
||||
|
||||
public void setCurrentnodetype(String currentnodetype) {
|
||||
this.currentnodetype = currentnodetype;
|
||||
}
|
||||
|
||||
public String getRequestcode() {
|
||||
return requestcode;
|
||||
}
|
||||
|
||||
public void setRequestcode(String requestcode) {
|
||||
this.requestcode = requestcode;
|
||||
}
|
||||
|
||||
public String getCurrentnodename() {
|
||||
return currentnodename;
|
||||
}
|
||||
|
||||
public void setCurrentnodename(String currentnodename) {
|
||||
this.currentnodename = currentnodename;
|
||||
}
|
||||
|
||||
public String getNooperator() {
|
||||
return nooperator;
|
||||
}
|
||||
|
||||
public void setNooperator(String nooperator) {
|
||||
this.nooperator = nooperator;
|
||||
}
|
||||
|
||||
public String getWorkcode() {
|
||||
return workcode;
|
||||
}
|
||||
|
||||
public void setWorkcode(String workcode) {
|
||||
this.workcode = workcode;
|
||||
}
|
||||
|
||||
public String getWorkflowname() {
|
||||
return workflowname;
|
||||
}
|
||||
|
||||
public void setWorkflowname(String workflowname) {
|
||||
this.workflowname = workflowname;
|
||||
}
|
||||
|
||||
public String getCreaterhrcode() {
|
||||
return createrhrcode;
|
||||
}
|
||||
|
||||
public void setCreaterhrcode(String createrhrcode) {
|
||||
this.createrhrcode = createrhrcode;
|
||||
}
|
||||
|
||||
public String getCreaterworkcode() {
|
||||
return createrworkcode;
|
||||
}
|
||||
|
||||
public void setCreaterworkcode(String createrworkcode) {
|
||||
this.createrworkcode = createrworkcode;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,134 @@
|
||||
package com.awspaas.user.apps.integration.controller;
|
||||
|
||||
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.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.bind.annotation.Controller;
|
||||
import com.actionsoft.bpms.server.bind.annotation.Mapping;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.AppAPI;
|
||||
import com.awspaas.user.apps.integration.XmlDatasUtil;
|
||||
import com.awspaas.user.apps.integration.util.HttpClientUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
public class SendOAProcessController {
|
||||
@Mapping("com.awspaas.user.apps.integration.controller.SendOAProcessController.SendProcessByOA")
|
||||
public void SendProcessByOA(String sid,String taskInstId,String processInstId,String PROCESS_TITLE) throws IOException {
|
||||
ProcessInstance instanceById = SDK.getProcessAPI().getInstanceById(processInstId);
|
||||
TaskInstance instanceById1 = SDK.getTaskAPI().getInstanceById(taskInstId);
|
||||
XmlDatasUtil xmlDatasUtil = new XmlDatasUtil();
|
||||
xmlDatasUtil.setExternal_system_ID("LCZD");
|
||||
xmlDatasUtil.setOther_system_to_do_ID(instanceById1.getId());
|
||||
BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId).detail();
|
||||
if (bo_act_coe_publish!=null){
|
||||
//流程文件发布申请
|
||||
xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+bo_act_coe_publish.getString("PROCESS_TITLE")+"】,点击进行处理");
|
||||
}else {
|
||||
xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+PROCESS_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/";
|
||||
}
|
||||
xmlDatasUtil.setPcurl(portalUrl+"/r/or?cmd=com.yili_form_page_open&oauthName=oauthLogin&processInstId="+instanceById.getId()+"&taskInstId="+instanceById1.getId());
|
||||
xmlDatasUtil.setMobileurl(portalUrl+"/r/or?cmd=com.yili_form_page_open&oauthName=WechatOauthLogin&casaccount="+instanceById1.getTarget()+"&processInstId="+instanceById.getId()+"&taskInstId="+instanceById1.getId());
|
||||
String target = instanceById1.getTarget();
|
||||
if (target.length()==8&&"00".equals(target.substring(0,2))){
|
||||
target = target.substring(2);
|
||||
}
|
||||
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(instanceById1.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(instanceById.getId());
|
||||
xmlDatasUtil.setCurrentnodename(SDK.getRepositoryAPI().getProcessNode(instanceById.getProcessDefId(),instanceById1.getActivityDefId()).getName());
|
||||
|
||||
// 调用App
|
||||
String sourceAppId = instanceById.getAppId();
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.processtrends/processNodeInfoASLP";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
//流程实例id,必填
|
||||
params.put("processInstId", instanceById.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("");
|
||||
xmlDatasUtil.setWorkflowname(instanceById.getTitle());
|
||||
|
||||
if (bo_eu_oa_reson!=null){
|
||||
xmlDatasUtil.setCreaterhrcode(bo_eu_oa_reson.getString("LOGINID"));
|
||||
}
|
||||
xmlDatasUtil.setCreaterworkcode("");
|
||||
|
||||
|
||||
|
||||
HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||||
String s = httpClientUtil.SendPend("http://10.105.1.59/services/yili", xmlDatasUtil);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,366 @@
|
||||
package com.awspaas.user.apps.integration.event;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb;
|
||||
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
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.server.fs.DCContext;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.exception.AWSException;
|
||||
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.apache.commons.lang.StringUtils;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import javax.swing.tree.RowMapper;
|
||||
import java.sql.Connection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 创建已发布的知识
|
||||
*/
|
||||
public class CreateDataKnow implements IJob {
|
||||
|
||||
|
||||
private static String APPID = "com.awspaas.user.apps.yili.integration";
|
||||
|
||||
|
||||
private static String USERID = "admin";
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
SSOUtil ssoUtil = new SSOUtil();
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
String sid = ssoUtil.registerClientSessionNoPassword(USERID, "cn", portalUrl, "pc");
|
||||
UserContext userContext = UserContext.fromSessionId(sid);
|
||||
System.out.println("创建维度准备开始===============");
|
||||
String sql = "select * from APP_ACT_COE_PAL_REPOSITORY " +
|
||||
"where PLCATEGORY = 'process'and PLMETHODID !='process.framework' " +
|
||||
"and ISPUBLISH = '1' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" +
|
||||
",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" +
|
||||
" and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," +
|
||||
"'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," +
|
||||
"'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," +
|
||||
"'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," +
|
||||
"'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," +
|
||||
"'42c09260-c1d3-44b7-ac3d-f8280e04c294')";
|
||||
|
||||
List<RowMap> rowMapList = DBSql.getMaps(sql);
|
||||
for (RowMap rowmap:rowMapList
|
||||
) {
|
||||
String card_sql = "SELECT * FROM APP_ACT_KMS_CARD WHERE CARDNAME like '"+rowmap.getString("PLNAME")+"%'";
|
||||
RowMap map = DBSql.getMap(card_sql);
|
||||
if (map!=null){
|
||||
String sql_pal = "SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE EXT4 = '"+map.getString("ID")+"'";
|
||||
RowMap rowMap = DBSql.getMap(sql_pal);
|
||||
if (rowMap!=null){
|
||||
System.out.println("该知识已经存在于PAL资产库中的EXT4中,并且已经在知识中");
|
||||
}else{
|
||||
CreateKnow(rowmap.getString("PLMETHODID"),rowmap.getString("PLNAME")+rowmap.getString("PLVER"),rowmap.getString("PLNAME"),rowmap.getString("PLVER"),true,true,"2099-12-31","1",USERID,"",sid);
|
||||
/*Map names = new LinkedHashMap<>();
|
||||
|
||||
String plname = rowmap.getString("PLNAME");
|
||||
for (int i=0;i<4;i++) {
|
||||
String sql_de = sql+" and PLNAME = '"+plname+"'";
|
||||
RowMap map1 = DBSql.getMap(sql_de);
|
||||
if (map1!=null){
|
||||
names.put(i,map1.getString("PLNAME"));
|
||||
plname = map1.getString("PLNAME");
|
||||
}else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i=names.size() - 1; i >= 0; i--) {
|
||||
String sql_de = sql+" and PLNAME = '"+names.get(i)+"'";
|
||||
RowMap map1 = DBSql.getMap(sql_de);
|
||||
String sql_decre = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+names.get(i)+"'";
|
||||
RowMap map2 = DBSql.getMap(sql_decre);
|
||||
if (map2==null){
|
||||
|
||||
createDimension(map1.getString("ID"),false,true,"1","","",names.get(i).toString(),sid);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}else {
|
||||
CreateKnow(rowmap.getString("PLMETHODID"),rowmap.getString("PLNAME")+rowmap.getString("PLVER"),rowmap.getString("PLNAME"),rowmap.getString("PLVER"),true,true,"2099-12-31","1",USERID,"",sid);
|
||||
/*Map names = new LinkedHashMap<>();
|
||||
|
||||
|
||||
String plname = rowmap.getString("PLNAME");
|
||||
String plparentid = rowmap.getString("PLPARENTID");
|
||||
for (int i=0;i<4;i++) {
|
||||
String slq = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+plparentid+"'";
|
||||
RowMap map3 = DBSql.getMap(slq);
|
||||
if (map3!=null){
|
||||
names.put(i,map3.getString("PLNAME"));
|
||||
plname = map3.getString("PLNAME");
|
||||
plparentid = map3.getString("PLPARENTID");
|
||||
}else if (plparentid.equals("process")){
|
||||
names.put(i,"流程制度");
|
||||
}else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i=names.size() - 1; i >= 0; i--) {
|
||||
if (names.get(i).equals("流程制度")){
|
||||
String sql_decre = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+names.get(i)+"'";
|
||||
RowMap map2 = DBSql.getMap(sql_decre);
|
||||
if (map2==null){
|
||||
|
||||
createDimension("",false,true,"1","","",names.get(i).toString(),sid);
|
||||
}
|
||||
}else {
|
||||
String sql_de = "select * from APP_ACT_COE_PAL_REPOSITORY " +
|
||||
"where PLCATEGORY = 'process'and PLMETHODID ='process.framework' " +
|
||||
"and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" +
|
||||
",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" +
|
||||
" and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," +
|
||||
"'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," +
|
||||
"'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," +
|
||||
"'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," +
|
||||
"'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," +
|
||||
"'42c09260-c1d3-44b7-ac3d-f8280e04c294')"+" and PLNAME = '"+names.get(i)+"'";
|
||||
RowMap map1 = DBSql.getMap(sql_de);
|
||||
String sql_decre = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+names.get(i)+"'";
|
||||
RowMap map2 = DBSql.getMap(sql_decre);
|
||||
if (map2==null){
|
||||
|
||||
createDimension(map1.getString("ID"),false,true,"1","","",names.get(i).toString(),sid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateKnow(String securityLevel,String knwlName,String plname,String PLVER, boolean isComment,boolean isRate,String validDate,String onlineLevel,String createUser,String cardContext,String sid) {
|
||||
// 调用App
|
||||
UserContext userContext = UserContext.fromSessionId(sid);
|
||||
String sourceAppId = APPID;
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.kms/CreateKnwl";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
//保密级别, 0: 普通 1:秘密 2:机密,必填
|
||||
params.put("securityLevel", 0);
|
||||
//知识名称,必填
|
||||
params.put("knwlName", knwlName);
|
||||
//是否可以评论,必填
|
||||
params.put("isComment", isComment);
|
||||
//是否可以评分,必填
|
||||
params.put("isRate", isRate);
|
||||
//有效期:yyyy-MM-dd,非必填
|
||||
params.put("validDate", validDate);
|
||||
//只读控制,1:在线阅读和下载 0:在线阅读,必填
|
||||
params.put("onlineLevel", 1);
|
||||
//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填
|
||||
|
||||
params.put("createUser", createUser);
|
||||
//知识内容,非必填
|
||||
params.put("cardContext", cardContext);
|
||||
//sid,必填
|
||||
params.put("sid", sid);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//创建知识
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
if (ro.isOk()){
|
||||
String cardId = ((LinkedHashMap) ro.getData()).get("cardId").toString();
|
||||
|
||||
String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '"+cardId+"' WHERE " +
|
||||
" PLCATEGORY = 'process'and PLMETHODID !='process.framework' " +
|
||||
" and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" +
|
||||
" ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" +
|
||||
" and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," +
|
||||
" 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," +
|
||||
" '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," +
|
||||
" '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," +
|
||||
" '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," +
|
||||
" '42c09260-c1d3-44b7-ac3d-f8280e04c294') and PLMETHODID = '"+securityLevel+"' and PLNAME = '"+plname+"' AND PLVER = '"+PLVER+"'";
|
||||
int update = DBSql.update(update_sql);
|
||||
System.out.println("更新名称为:"+plname+"版本为:"+PLVER +"的知识对应的资产库的EXT4的影响行数为"+update);
|
||||
creadteFile(userContext,cardId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void creadteFile(UserContext userContext, String cardId){
|
||||
/**
|
||||
* 这个主要是负责对流程手册进行相关的文件的生成
|
||||
*/
|
||||
String sourceAppId = APPID;
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.kms/CreateFile";
|
||||
|
||||
if (StringUtils.isNotEmpty(cardId)){
|
||||
String sql_ext4 = "select * from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '"+cardId+"'";
|
||||
RowMap map = DBSql.getMap(sql_ext4);
|
||||
BO bos = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N",true).addQuery("PUBLISHFILEID = ",map.getString("ID")).detail();
|
||||
if (bos!=null){
|
||||
|
||||
if (StringUtils.isNotEmpty(bos.getString("TASKID"))) {
|
||||
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(bos.getString("TASKID"));
|
||||
if (model != null) {
|
||||
System.out.println(",pdel============" + model);
|
||||
System.out.println("123313123123123==========" + model.getProfileId());
|
||||
OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId());
|
||||
System.out.println("dajadfas======" + appProfile);
|
||||
if (appProfile == null) {
|
||||
throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId());
|
||||
}
|
||||
DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT);
|
||||
if (dcProfile == null)
|
||||
throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT);
|
||||
String sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + bos.getString("PUBLISHFILEID") + "'";
|
||||
String lever = DBSql.getString( sql_lever);
|
||||
//lever = lever.substring(0,3);
|
||||
if(lever.length()==5&&lever.substring(4).equals("0")){
|
||||
lever.substring(0,3);
|
||||
}else if (lever.length()==1){
|
||||
lever=lever+".0";
|
||||
}
|
||||
DCContext dcContext = new DCContext(userContext, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), bos.getString("TASKID"), bos.getString("PUBLISHFILENAME") + "_" + lever + ".doc");
|
||||
//UtilFile file = new UtilFile(dcContext.getPath());
|
||||
|
||||
|
||||
Map params = new HashMap<String, Object>();
|
||||
//知识ID,必填
|
||||
params.put("cardId", cardId);
|
||||
//sid,必填
|
||||
params.put("sid", userContext.getSessionId());
|
||||
|
||||
params.put("dc", dcContext);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//创建文件
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
System.out.println("流程手册的存入=================" + ro);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
String sql_A = "SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where ID = '"+map.getString("ID")+"' AND PLMETHODID != 'process.framework' AND PLMETHODID IN (select distinct PLMETHODID from APP_ACT_COE_PAL_REPOSITORY)";
|
||||
List<RowMap> rows = DBSql.getMaps(sql_A);
|
||||
|
||||
for (RowMap bo:rows
|
||||
) {
|
||||
|
||||
/**
|
||||
* 这个是模型中的附件获取的并插入的数据信息,需要做修改
|
||||
*/
|
||||
// 调用App
|
||||
|
||||
// 参数定义列表
|
||||
Map paramss = new HashMap<String, Object>();
|
||||
//知识ID,必填
|
||||
paramss.put("cardId", cardId);
|
||||
//sid,必填
|
||||
paramss.put("sid", userContext.getSessionId());
|
||||
|
||||
UpfileWeb upfileWeb = new UpfileWeb(userContext);
|
||||
|
||||
|
||||
|
||||
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID != 'process.framework' AND ID= '"+map.getString("ID")+"'" +
|
||||
")";
|
||||
List<RowMap> maps = DBSql.getMaps(sql_upfile);
|
||||
for (RowMap row : maps) {
|
||||
UpfileModel upfileModel = new UpfileModel();
|
||||
upfileModel.setType(row.getString("FILETYPE"));
|
||||
upfileModel.setFileName(row.getString("FILENAME"));
|
||||
upfileModel.setPl_uuid(row.getString("PALREPOSITORYID"));
|
||||
upfileModel.setShape_uuid(row.getString("SHAPEID"));
|
||||
DCContext dcContexts = upfileWeb.getDCContext(upfileModel);
|
||||
paramss.put("dc", dcContexts);
|
||||
AppAPI appAPIs = SDK.getAppAPI();
|
||||
ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, paramss);
|
||||
System.out.println("流程模型附件的生成============="+ros);
|
||||
}
|
||||
|
||||
//DCContext对象,必填
|
||||
|
||||
//创建文件
|
||||
}
|
||||
PublishKnow(userContext,cardId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void PublishKnow(UserContext userContext,String id){
|
||||
|
||||
String sql = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id in (select PLPARENTID from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '"+id +"')";
|
||||
List<RowMap> maps = DBSql.getMaps(sql);
|
||||
String ids = "";
|
||||
for (RowMap rowmap:maps
|
||||
) {
|
||||
ids+=rowmap.getString("EXT4")+",";
|
||||
}
|
||||
String[] deptSplit_id = ids.split(",");
|
||||
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (String id_names:deptSplit_id
|
||||
) {
|
||||
jsonArray.add(id_names);
|
||||
}
|
||||
//jsonObject.put(deptSplit_id);
|
||||
id+=",";
|
||||
String[] deptSplit_das = id.split(",");
|
||||
JSONArray jsonArray_das = new JSONArray();
|
||||
for (String das:deptSplit_das
|
||||
) {
|
||||
jsonArray_das.add(das);
|
||||
}
|
||||
//jsonObject.put(deptSplit_id);
|
||||
|
||||
|
||||
// 调用App
|
||||
String sourceAppId = APPID;
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
//要发布到的维度ID的JSON数组字符串,必填
|
||||
params.put("dimensionIDArray", jsonArray.toString());
|
||||
//要发布的知识ID的JSON数组字符串,必填
|
||||
params.put("knwlIDArray", jsonArray_das.toString());
|
||||
//标签的JSON数组字符串,非必填
|
||||
|
||||
//sid,必填
|
||||
params.put("sid", userContext.getSessionId());
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//发布知识
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
|
||||
System.out.println("知识发布============"+ro);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package com.awspaas.user.apps.integration.event;
|
||||
|
||||
import bsh.StringUtil;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
|
||||
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FinshKnowAfterEvent extends ExecuteListener {
|
||||
@Override
|
||||
public void execute(ProcessExecutionContext processExecutionContext) throws Exception {
|
||||
List<BO> bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).addQuery("BINDID = ", processExecutionContext.getProcessInstance().getId()).list();
|
||||
List<BO> bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID = ", processExecutionContext.getProcessInstance().getId()).list();
|
||||
List<BO> bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list();
|
||||
|
||||
for (BO bo :
|
||||
bo_act_coe_publish_n) {
|
||||
String sql = "SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '"+bo.getString("PUBLISHFILEID")+"'";
|
||||
RowMap rowMap = DBSql.getMap(sql);
|
||||
String ext4 = rowMap.getString("EXT4");
|
||||
if (StringUtils.isNotEmpty(ext4)){
|
||||
String sql_card = "SELECT * FROM APP_ACT_KMS_CARD WHERE ID = '"+ext4+"'";
|
||||
RowMap map = DBSql.getMap(sql_card);
|
||||
if (ext4.equals(map.getString("ID"))){
|
||||
if (map.getString("CARDNAME").equals(rowMap.getString("PLNAME"))){
|
||||
|
||||
}else {
|
||||
String update_sql_name = "UPDATE APP_ACT_KMS_CARD SET CARDNAME = '"+rowMap.getString("PLNAME")+"' WHERE ID = '"+map.getString("ID")+"'";
|
||||
int update_sql_name_nums = DBSql.update(update_sql_name);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,123 @@
|
||||
package com.awspaas.user.apps.integration.event;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.server.fs.AbstFileProcessor;
|
||||
import com.actionsoft.bpms.server.fs.DCContext;
|
||||
import com.actionsoft.bpms.server.fs.FileProcessorListener;
|
||||
import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
|
||||
import com.actionsoft.bpms.server.fs.dc.DCUtil;
|
||||
import com.actionsoft.bpms.util.UtilFile;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.AppAPI;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class OutputDCFileProcessor extends AbstFileProcessor implements FileProcessorListener {
|
||||
public OutputDCFileProcessor() {
|
||||
}
|
||||
|
||||
public static String getReportDownloadURL(String wsId, String id, String profileId, UserContext _uc, String taskName) throws Exception {
|
||||
UtilFile file = OutputAPIManager.getInstance().getFilePath(wsId, id, profileId);
|
||||
if (file.exists()) {
|
||||
DCContext dcContext = null;
|
||||
DCUtil.getInstance();
|
||||
dcContext = DCUtil.createTempFileContext("com.actionsoft.apps.coe.pal.output.pr", "output", id, "zip");
|
||||
dcContext.setFileName(taskName + ".zip");
|
||||
File ff = new File(dcContext.getFilePath());
|
||||
UtilFile.zipCompressExcludeName(file.getPath(), ff, "log,**/config.txt");
|
||||
dcContext.setSession(_uc);
|
||||
if (SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IS_RECORD_OP_LOG", false)) {
|
||||
CoEOpLogAPI.auditOkOp(_uc, "PAL应用中心", "download", "下载报告手册文档");
|
||||
}
|
||||
|
||||
return dcContext.getDownloadURL();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String doPreviewReport(String wsId, String id, String profileId, UserContext _uc) throws Exception {
|
||||
UtilFile file = OutputAPIManager.getInstance().getFilePath(wsId, id, profileId);
|
||||
ResponseObject result = ResponseObject.newOkResponse();
|
||||
if (file.exists()) {
|
||||
File[] fileList = file.listFiles();
|
||||
if (fileList.length > 0) {
|
||||
File docFile = null;
|
||||
File[] var8 = fileList;
|
||||
int var9 = fileList.length;
|
||||
|
||||
for(int var10 = 0; var10 < var9; ++var10) {
|
||||
File file2 = var8[var10];
|
||||
if (file2.isFile() && "doc".equals(file2.getName().substring(file2.getName().lastIndexOf(".") + 1))) {
|
||||
docFile = file2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (docFile == null) {
|
||||
return ResponseObject.newErrResponse("没有找到文件").toString();
|
||||
}
|
||||
|
||||
if (SDK.getAppAPI().isActive("com.actionsoft.apps.addons.onlinedoc")) {
|
||||
String sourceAppId = "com.actionsoft.apps.coe.pal.output.pr";
|
||||
String filename = docFile.getName();
|
||||
DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, wsId, id, filename);
|
||||
Map<String, Object> aslpParams = new HashMap();
|
||||
aslpParams.put("sid", _uc.getSessionId());
|
||||
aslpParams.put("fileNameOriginal", filename);
|
||||
aslpParams.put("sourceDc", sourceDc);
|
||||
aslpParams.put("isShowDefaultToolbar", "false");
|
||||
aslpParams.put("isEncrypt", true);
|
||||
aslpParams.put("isCopy", "true");
|
||||
aslpParams.put("isPrint", "false");
|
||||
aslpParams.put("isDownload", "false");
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
ResponseObject responseObject = appAPI.callASLP(appAPI.getAppContext(sourceAppId), "aslp://com.actionsoft.apps.addons.onlinedoc/filePreview", aslpParams);
|
||||
if (responseObject != null) {
|
||||
if (responseObject.isOk()) {
|
||||
String url = responseObject.get("url").toString();
|
||||
result.put("url", url);
|
||||
result.put("filename", filename);
|
||||
if (SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IS_RECORD_OP_LOG", false)) {
|
||||
CoEOpLogAPI.auditOkOp(_uc, "PAL应用中心", "access", "访问报告手册文档");
|
||||
}
|
||||
} else {
|
||||
result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = ResponseObject.newErrResponse("没有可预览文件");
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static String getReportLogDownloadURL(String wsId, String id, String profileId, UserContext _uc, String taskName) throws Exception {
|
||||
UtilFile file = OutputAPIManager.getInstance().getFilePath(wsId, id, profileId);
|
||||
if (file.exists()) {
|
||||
DCContext dcContext = null;
|
||||
DCUtil.getInstance();
|
||||
dcContext = DCUtil.createTempFileContext("com.actionsoft.apps.coe.pal.output.pr", "output", id, "zip");
|
||||
dcContext.setFileName("log.zip");
|
||||
File ff = new File(dcContext.getFilePath());
|
||||
UtilFile.zipCompress(file.getPath(), ff, "log");
|
||||
dcContext.setSession(_uc);
|
||||
if (SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IS_RECORD_OP_LOG", false)) {
|
||||
CoEOpLogAPI.auditOkOp(_uc, "PAL应用中心", "download", "下载报告手册文档日志");
|
||||
}
|
||||
|
||||
return dcContext.getDownloadURL();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,961 @@
|
||||
package com.awspaas.user.apps.integration.event;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb;
|
||||
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.bpmn.engine.ProcessAPIManager;
|
||||
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
|
||||
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.TaskCommentModel;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.org.model.DepartmentModel;
|
||||
import com.actionsoft.bpms.org.model.UserModel;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.server.fs.DCContext;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.exception.AWSException;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.AppAPI;
|
||||
import com.actionsoft.sdk.local.api.LogAPI;
|
||||
import com.actionsoft.sdk.local.api.Logger;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.awspaas.user.apps.integration.oa.TaskListener;
|
||||
import com.awspaas.user.apps.integration.util.UtilUrl;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
|
||||
import java.io.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class ProcessEndAfterEvent extends ExecuteListener {
|
||||
private Logger logger = LogAPI.getLogger(TaskListener.class);
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "0.0.1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProvider() {
|
||||
return "ActionSoft";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "流程结束后发送代阅任务";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ProcessExecutionContext processExecutionContext) throws Exception {
|
||||
Connection open = DBSql.open();
|
||||
//http://localhost:8089/portal/r/or?cmd=com.hy_client_bpm_form_main_page_open&oauthName=oauthLogin&processInstId=3505e654-9217-41cd-a31d-4971846b3219
|
||||
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
System.out.println("portal======>>>>"+portalUrl);
|
||||
/*if (portalUrl.equals("http://10.114.11.135:8088/portal")){
|
||||
portalUrl = "http://bpm.yili.com:8088/portal/";
|
||||
}*/
|
||||
try {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String url = portalUrl+"/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId="+processExecutionContext.getProcessInstance().getId()+"&taskInstId="+processExecutionContext.getTaskInstance().getId();
|
||||
String mobileurl = "https://bpm.yili.com:8088/portal"+"/r/or?cmd=com.yili_process_page_phone&oauthName=oauthLogin&processInstId="+processExecutionContext.getProcessInstance().getId()+"&taskInstId="+processExecutionContext.getTaskInstance().getId();
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Timestamp endTime = processExecutionContext.getProcessInstance().getStartTime();
|
||||
BO boActCoePublish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).detail();
|
||||
|
||||
|
||||
//ProcessExecutionContext processExecutionContext,String fileCreateName,String fileName,String fileurl,String readingScope_org,String isFullCompany,String fileCreateDate,String relationProcessinstId,String readingScope_post,String readingScope_level,String fileid
|
||||
String not_url = "/w?cmd=com.yili_process_page&processInstId="+processExecutionContext.getProcessInstance().getId()+"&taskInstId="+processExecutionContext.getTaskInstance().getId();
|
||||
execute(processExecutionContext,boActCoePublish.getString("APPLYUSERNAME"),boActCoePublish.getString("PROCESS_TITLE"),not_url,boActCoePublish.getString("SEND_SCOPE_ORG"),boActCoePublish.getString("SEND_SCOP"),boActCoePublish.getString("APPLYDATE"),processExecutionContext.getProcessInstance().getId(),boActCoePublish.getString("SEND_SCOPE_POST"),boActCoePublish.getString("SEND_SCOPE_LEVEL"),"1");
|
||||
|
||||
|
||||
JSONObject jsonObject = new JSONObject(new LinkedHashMap());
|
||||
jsonObject.put("action","read");
|
||||
jsonObject.put("title"," " +
|
||||
"["+boActCoePublish.getString("PROCESS_TITLE")+"]需要处理");
|
||||
jsonObject.put("dept",SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo());//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo()
|
||||
String target = "";
|
||||
if (processExecutionContext.getProcessInstance().getCreateUser().length()==8&&"00".equals(processExecutionContext.getProcessInstance().getCreateUser().substring(0,2))){
|
||||
target = processExecutionContext.getProcessInstance().getCreateUser().substring(2);
|
||||
}
|
||||
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){
|
||||
jsonObject.put("user",bo_eu_oa_reson.getString("LOGINID"));
|
||||
}
|
||||
// jsonObject.put("user",);//processExecutionContext.getProcessInstance().getCreateUser()
|
||||
jsonObject.put("date",sdf.format(endTime));
|
||||
jsonObject.put("remark",boActCoePublish.getString("PROCESS_TITLE"));
|
||||
jsonObject.put("status","0");
|
||||
jsonObject.put("dataid",processExecutionContext.getProcessInstance().getId());
|
||||
jsonObject.put("pcurl",url);
|
||||
jsonObject.put("mobileurl",mobileurl);
|
||||
//list.add(1,"00352394");
|
||||
//list.add(2,"00352394");
|
||||
BO bo_act_coe_publish1 = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).detail();
|
||||
String uid = "";
|
||||
String new_uid = "";
|
||||
if(bo_act_coe_publish1!=null) {
|
||||
String da = bo_act_coe_publish1.getString("SEND_SCOP");
|
||||
|
||||
if (da.equals("1")) {
|
||||
List<RowMap> select_userid_from_orguser = DBSql.getMaps("select USERID from ORGUSER");
|
||||
for (RowMap row : select_userid_from_orguser
|
||||
) {
|
||||
uid += row.getString("USERID") + ",";
|
||||
}
|
||||
} else {
|
||||
List posts_list = new ArrayList();
|
||||
String strs[] = bo_act_coe_publish1.getString("SEND_SCOPE_ORG").split(",");
|
||||
if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_POST"))) {
|
||||
String posts[] = bo_act_coe_publish1.getString("SEND_SCOPE_POST").split(",");
|
||||
posts_list = Arrays.asList(posts);
|
||||
}
|
||||
List ranks_list = new ArrayList();
|
||||
if (StringUtils.isNotEmpty(bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL"))) {
|
||||
String ranks[] = bo_act_coe_publish1.getString("SEND_SCOPE_LEVEL").split(",");
|
||||
ranks_list = Arrays.asList(ranks);
|
||||
}
|
||||
|
||||
for (String depaartid : strs
|
||||
) {
|
||||
DepartmentModel departmentModel = SDK.getORGAPI().getDepartmentById(depaartid);
|
||||
boolean existSubModelOfCache = departmentModel.isExistSubModelOfCache();
|
||||
//判断选中的是否有下级部门
|
||||
if (existSubModelOfCache) {
|
||||
List<RowMap> maps = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + depaartid + "'");
|
||||
for (RowMap row : maps
|
||||
) {
|
||||
String id = row.getString("ID");
|
||||
DepartmentModel model = SDK.getORGAPI().getDepartmentById(id);
|
||||
|
||||
if (model.isExistSubModelOfCache()) {
|
||||
//有下级部门的选中有下级部门
|
||||
List<RowMap> rowMapList = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + id + "'");
|
||||
for (RowMap wo :
|
||||
rowMapList) {
|
||||
String ids = wo.getString("ID");
|
||||
DepartmentModel model1 = SDK.getORGAPI().getDepartmentById(ids);
|
||||
if (model1.isExistSubModelOfCache()) {
|
||||
List<RowMap> rowMapLists = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + ids + "'");
|
||||
for (RowMap wsa :
|
||||
rowMapLists) {
|
||||
String wsaString = wsa.getString("ID");
|
||||
DepartmentModel model2 = SDK.getORGAPI().getDepartmentById(wsaString);
|
||||
if (model2.isExistSubModelOfCache()) {
|
||||
List<RowMap> rowMapList1 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + wsaString + "'");
|
||||
for (RowMap rows :
|
||||
rowMapList1) {
|
||||
String rowsString = rows.getString("ID");
|
||||
DepartmentModel model3 = SDK.getORGAPI().getDepartmentById(rowsString);
|
||||
if (model3.isExistSubModelOfCache()) {
|
||||
List<RowMap> rowMapList2 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + rowsString + "'");
|
||||
for (RowMap ormap :
|
||||
rowMapList2) {
|
||||
String rowsString1 = ormap.getString("ID");
|
||||
DepartmentModel model4 = SDK.getORGAPI().getDepartmentById(rowsString1);
|
||||
if (model4.isExistSubModelOfCache()) {
|
||||
List<RowMap> rowMaps = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + rowsString1 + "'");
|
||||
for (RowMap owmapr :
|
||||
rowMaps) {
|
||||
String row_id = owmapr.getString("ID");
|
||||
DepartmentModel model5 = SDK.getORGAPI().getDepartmentById(row_id);
|
||||
if (model5.isExistSubModelOfCache()) {
|
||||
List<RowMap> rowMapList3 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + row_id + "'");
|
||||
for (RowMap owzmap :
|
||||
rowMapList3) {
|
||||
String idsa = owzmap.getString("ID");
|
||||
DepartmentModel model6 = SDK.getORGAPI().getDepartmentById(idsa);
|
||||
if (model6.isExistSubModelOfCache()) {
|
||||
|
||||
} else {
|
||||
List<UserModel> allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(idsa);
|
||||
for (UserModel user : allUsersByDepartments
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<UserModel> allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(row_id);
|
||||
for (UserModel user : allUsersByDepartments
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<UserModel> allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(rowsString1);
|
||||
for (UserModel user : allUsersByDepartments
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<UserModel> allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(rowsString);
|
||||
for (UserModel user : allUsersByDepartments
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<UserModel> allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(wsaString);
|
||||
for (UserModel user : allUsersByDepartments
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<UserModel> allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(ids);
|
||||
for (UserModel user : allUsersByDepartments
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<UserModel> allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(id);
|
||||
for (UserModel user : allUsersByDepartments
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//选中的没有下级部门
|
||||
List<UserModel> allUsersByDepartment = SDK.getORGAPI().getAllUsersByDepartment(depaartid);
|
||||
for (UserModel user : allUsersByDepartment
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(uid
|
||||
)) {
|
||||
uid = uid.substring(0, uid.length() - 1);
|
||||
String[] split = uid.split(",");
|
||||
|
||||
List<String> list = new ArrayList(Arrays.asList(split));
|
||||
|
||||
HashSet h = new HashSet(list);
|
||||
list.clear();
|
||||
list.addAll(h);
|
||||
for (String userid:list
|
||||
) {
|
||||
if (userid.length()==8&&"00".equals(userid.substring(0,2))){
|
||||
userid = userid.substring(2);
|
||||
}
|
||||
System.out.println("当前账户======》》》》"+userid);
|
||||
System.out.println("bo>>>>>>>>>>>>>>"+bo_eu_oa_reson);
|
||||
if (bo_eu_oa_reson!=null){
|
||||
new_uid+=bo_eu_oa_reson.getString("LOGINID")+",";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(new_uid
|
||||
)) {
|
||||
new_uid = new_uid.substring(0, new_uid.length() - 1);
|
||||
}
|
||||
System.out.println("new_userid ==========>>>>>>>>>"+new_uid);
|
||||
jsonObject.put("userList",new_uid);
|
||||
|
||||
|
||||
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>";
|
||||
|
||||
String postSoap = UtilUrl.doPostSoap("http://10.105.1.59:80/services/service_lcglpt", 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");
|
||||
JSONArray resultArray = JSONObject.parseArray(datas);
|
||||
for (int i=0;i<resultArray.size();i++) {
|
||||
JSONObject jsonObject2 = resultArray.getJSONObject(i);
|
||||
String user = jsonObject2.get("user").toString();
|
||||
String dataid = jsonObject2.get("dataid").toString();
|
||||
BO bo = new BO();
|
||||
bo.set("PROCESSID",processExecutionContext.getProcessInstance().getId());
|
||||
bo.set("USER_ID",user);
|
||||
bo.set("DATAID",dataid);
|
||||
SDK.getBOAPI().create("BO_ACT_DATAID",bo,processExecutionContext.getProcessInstance().getId(),processExecutionContext.getUserContext().getUID());
|
||||
}
|
||||
// System.out.println("subString==========================="+substring.substring(substring.lastIndexOf(";")+1,substring.length()));
|
||||
// substring = substring.substring(substring.lastIndexOf(";")+1,substring.length());
|
||||
|
||||
|
||||
|
||||
|
||||
BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).detail();
|
||||
|
||||
|
||||
//流程发布的新增发布
|
||||
List<BO> bo_act_coe_publish_n = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list();
|
||||
List<BO> bo_act_coe_publish_c = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list();
|
||||
List<BO> bo_act_coe_publish_s = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).list();
|
||||
String wsId = "";
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
|
||||
|
||||
|
||||
|
||||
int m = 0;
|
||||
for (BO bo:bo_act_coe_publish_n
|
||||
) {
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID"));
|
||||
wsId = model.getWsId();
|
||||
String publishfileid = bo.getString("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"))){
|
||||
// aslp服务地址
|
||||
String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl";
|
||||
// 参数定义列表
|
||||
Map params_create = new HashMap<String, Object>();
|
||||
//保密级别, 0: 普通 1:秘密 2:机密,必填
|
||||
params_create.put("securityLevel", 0);
|
||||
//知识名称,必填
|
||||
params_create.put("knwlName", map.getString("PLNAME")+map.getString("PLVER"));
|
||||
//是否可以评论,必填
|
||||
params_create.put("isComment", true);
|
||||
//是否可以评分,必填
|
||||
params_create.put("isRate", true);
|
||||
//有效期:yyyy-MM-dd,非必填
|
||||
params_create.put("validDate", "2099-12-31");
|
||||
//只读控制,1:在线阅读和下载 0:在线阅读,必填
|
||||
params_create.put("onlineLevel", 1);
|
||||
//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填
|
||||
params_create.put("createUser", "admin");
|
||||
//知识内容,非必填
|
||||
params_create.put("cardContext", "");
|
||||
//sid,必填
|
||||
params_create.put("sid", processExecutionContext.getUserContext().getSessionId());
|
||||
AppAPI appAPI_create = SDK.getAppAPI();
|
||||
//创建知识
|
||||
ResponseObject ro_create = appAPI_create.callASLP(appAPI_create.getAppContext(processExecutionContext.getProcessInstance().getAppId()), aslps_create, params_create);
|
||||
System.out.println("ro_create================"+ro_create);
|
||||
String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString();
|
||||
JSONArray jsonArray1 = new JSONArray();
|
||||
if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")){
|
||||
String departId = bo_act_coe_publish.getString("SEND_SCOPE_ORG");
|
||||
if (StringUtils.isNotEmpty(departId)&&StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_LEVEL"))&&StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_POST"))) {
|
||||
String strs[] = departId.split(",");
|
||||
for (String departmentid : strs
|
||||
) {
|
||||
JSONObject jsonObjecta = new JSONObject();
|
||||
jsonObjecta.put("assignmentType", "department");
|
||||
jsonObjecta.put("assignmentId", departmentid);
|
||||
jsonArray1.add(jsonObjecta);
|
||||
}
|
||||
}else{
|
||||
|
||||
String[] split = uid.split(",");
|
||||
|
||||
List<String> list = new ArrayList(Arrays.asList(split));
|
||||
|
||||
HashSet h = new HashSet(list);
|
||||
list.clear();
|
||||
list.addAll(h);
|
||||
|
||||
for (String user_id:list
|
||||
) {
|
||||
JSONObject jsonObjecta = new JSONObject();
|
||||
jsonObjecta.put("assignmentType","user");
|
||||
jsonObjecta.put("assignmentId",user_id);
|
||||
jsonArray1.add(jsonObjecta);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
List<RowMap> select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT");
|
||||
for (RowMap depaid:
|
||||
select_id_from_orgdepartment) {
|
||||
String id = depaid.getString("ID");
|
||||
JSONObject jsonObjecta = new JSONObject();
|
||||
jsonObjecta.put("assignmentType","department");
|
||||
jsonObjecta.put("assignmentId",id);
|
||||
jsonArray1.add(jsonObjecta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AddKnwlAC(processExecutionContext,jsonArray1,processExecutionContext.getUserContext().getSessionId(),cardId);
|
||||
|
||||
String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '"+cardId+"' WHERE " +
|
||||
" PLCATEGORY = 'process'and PLMETHODID !='process.framework' " +
|
||||
" and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" +
|
||||
" ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" +
|
||||
" and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," +
|
||||
" 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," +
|
||||
" '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," +
|
||||
" '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," +
|
||||
" '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," +
|
||||
" '42c09260-c1d3-44b7-ac3d-f8280e04c294') and ID = '"+publishfileid+"'";
|
||||
int update = DBSql.update(update_sql);
|
||||
System.out.println("更新id为:"+publishfileid+"版本为:的知识对应的资产库的EXT4的影响行数为"+update);
|
||||
creadteFile(processExecutionContext,"BO_ACT_COE_PUBLISH_N", processExecutionContext.getUserContext(),cardId,"PUBLISHFILEID = ");
|
||||
}
|
||||
}
|
||||
|
||||
for (BO bo:bo_act_coe_publish_c
|
||||
) {
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID"));
|
||||
wsId = model.getWsId();
|
||||
String publishfileid = bo.getString("CHANGEDFILEIDNEW");
|
||||
DBSql.update("update APP_ACT_COE_PAL_REPOSITORY set EXT4 = '' where id = '"+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"))){
|
||||
// aslp服务地址
|
||||
String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl";
|
||||
// 参数定义列表
|
||||
Map params_create = new HashMap<String, Object>();
|
||||
//保密级别, 0: 普通 1:秘密 2:机密,必填
|
||||
params_create.put("securityLevel", 0);
|
||||
//知识名称,必填
|
||||
params_create.put("knwlName", map.getString("PLNAME")+map.getString("PLVER"));
|
||||
//是否可以评论,必填
|
||||
params_create.put("isComment", true);
|
||||
//是否可以评分,必填
|
||||
params_create.put("isRate", true);
|
||||
//有效期:yyyy-MM-dd,非必填
|
||||
params_create.put("validDate", "2099-12-31");
|
||||
//只读控制,1:在线阅读和下载 0:在线阅读,必填
|
||||
params_create.put("onlineLevel", 1);
|
||||
//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填
|
||||
params_create.put("createUser", "admin");
|
||||
//知识内容,非必填
|
||||
params_create.put("cardContext", "");
|
||||
//sid,必填
|
||||
params_create.put("sid", processExecutionContext.getUserContext().getSessionId());
|
||||
AppAPI appAPI_create = SDK.getAppAPI();
|
||||
//创建知识
|
||||
ResponseObject ro_create = appAPI_create.callASLP(appAPI_create.getAppContext(processExecutionContext.getProcessInstance().getAppId()), aslps_create, params_create);
|
||||
System.out.println("ro_create================"+ro_create);
|
||||
String cardId = ((LinkedHashMap) ro_create.getData()).get("cardId").toString();
|
||||
JSONArray jsonArray1 = new JSONArray();
|
||||
if (bo_act_coe_publish.getString("SEND_SCOP").equals("0")){
|
||||
String departId = bo_act_coe_publish.getString("SEND_SCOPE_ORG");
|
||||
if (StringUtils.isNotEmpty(departId)&&StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_LEVEL"))&&StringUtils.isEmpty(bo_act_coe_publish.getString("SEND_SCOPE_POST"))){
|
||||
String strs[] = departId.split(",");
|
||||
for (String departmentid:strs
|
||||
) {
|
||||
JSONObject jsonObjecta = new JSONObject();
|
||||
jsonObjecta.put("assignmentType","department");
|
||||
jsonObjecta.put("assignmentId",departmentid);
|
||||
jsonArray1.add(jsonObjecta);
|
||||
}
|
||||
}else{
|
||||
String[] split = uid.split(",");
|
||||
|
||||
List<String> list = new ArrayList(Arrays.asList(split));
|
||||
|
||||
HashSet h = new HashSet(list);
|
||||
list.clear();
|
||||
list.addAll(h);
|
||||
|
||||
for (String user_id:list
|
||||
) {
|
||||
JSONObject jsonObjecta = new JSONObject();
|
||||
jsonObjecta.put("assignmentType","user");
|
||||
jsonObjecta.put("assignmentId",user_id);
|
||||
jsonArray1.add(jsonObjecta);
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
List<RowMap> select_id_from_orgdepartment = DBSql.getMaps("select ID from ORGDEPARTMENT");
|
||||
for (RowMap depaid:
|
||||
select_id_from_orgdepartment) {
|
||||
String id = depaid.getString("ID");
|
||||
JSONObject jsonObjecta = new JSONObject();
|
||||
jsonObjecta.put("assignmentType","department");
|
||||
jsonObjecta.put("assignmentId",id);
|
||||
jsonArray1.add(jsonObjecta);
|
||||
}
|
||||
}
|
||||
AddKnwlAC(processExecutionContext,jsonArray1,processExecutionContext.getUserContext().getSessionId(),cardId);
|
||||
|
||||
String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '"+cardId+"' WHERE " +
|
||||
" PLCATEGORY = 'process'and PLMETHODID !='process.framework' " +
|
||||
" and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" +
|
||||
" ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" +
|
||||
" and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," +
|
||||
" 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," +
|
||||
" '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," +
|
||||
" '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," +
|
||||
" '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," +
|
||||
" '42c09260-c1d3-44b7-ac3d-f8280e04c294') and ID = '"+publishfileid+"'";
|
||||
int update = DBSql.update(update_sql);
|
||||
System.out.println("更新id为:"+publishfileid+"版本为:的知识对应的资产库的EXT4的影响行数为"+update);
|
||||
creadteFile(processExecutionContext,"BO_ACT_COE_PUBLISH_C", processExecutionContext.getUserContext(),cardId," CHANGEDFILEIDNEW=");
|
||||
}
|
||||
//将旧的知识取消发布或者移动到废止发布中
|
||||
String publishfileid_old = bo.getString("CHANGEFILEID");
|
||||
String sql_c = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+publishfileid_old+"'";
|
||||
RowMap map1 = DBSql.getMap(sql_c);
|
||||
if (StringUtils.isNotEmpty(map1.getString("EXT4"))){
|
||||
CancelPublishKnwl(processExecutionContext,processExecutionContext.getUserContext().getSessionId(),map1.getString("EXT4"));
|
||||
DBSql.update(
|
||||
"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '"+publishfileid_old+"'"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (BO bo:bo_act_coe_publish_s
|
||||
) {
|
||||
//将旧的知识取消发布或者移动到废止发布中
|
||||
String publishfileid_stop = bo.getString("STOPFILEID");
|
||||
String sql_s = "select * from APP_ACT_COE_PAL_REPOSITORY where id = '"+publishfileid_stop+"'";
|
||||
RowMap map1 = DBSql.getMap(sql_s);
|
||||
if (StringUtils.isNotEmpty(map1.getString("EXT4"))){
|
||||
|
||||
/**
|
||||
* 废止发布
|
||||
*/
|
||||
CancelPublishKnwl(processExecutionContext,processExecutionContext.getUserContext().getSessionId(),map1.getString("EXT4"));
|
||||
/*String sql_update = "UPDATE APP_ACT_KMS_CARD SET ISPUBLISHED = '0' WHERE ID = '"+map1.getString("EXT4")+"'";
|
||||
int update = DBSql.update(sql_update);
|
||||
System.out.println(bo.getString("STOPFILENAME")+"废止文件发布的影响行数"+update);*/
|
||||
|
||||
DBSql.update(
|
||||
"UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '' WHERE ID = '"+publishfileid_stop+"'"
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
open.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void creadteFile(ProcessExecutionContext processExecutionContext,String bo_name,UserContext userContext, String cardId,String fileid){
|
||||
/**
|
||||
* 这个主要是负责对流程手册进行相关的文件的生成
|
||||
*/
|
||||
String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.kms/CreateFile";
|
||||
|
||||
if (StringUtils.isNotEmpty(cardId)){
|
||||
String sql_ext4 = "select * from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '"+cardId+"'";
|
||||
RowMap map = DBSql.getMap(sql_ext4);
|
||||
System.out.println("maps======>>>>>>>"+map);
|
||||
System.out.println("fileid==》》》》"+fileid);
|
||||
System.out.println("id==》》》》"+map.getString("ID"));
|
||||
RowMap rowMap = DBSql.getMap("SELECT * FROM " + bo_name + " where " + fileid + " '" + map.getString("ID") + "'");
|
||||
//BO bos = SDK.getBOAPI().query(bo_name,true).addQuery(fileid,"17e7d198-1656-4a2c-8912-a81850170be9").detail();
|
||||
if (rowMap!=null){
|
||||
|
||||
if (StringUtils.isNotEmpty(rowMap.getString("TASKID"))) {
|
||||
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(rowMap.getString("TASKID"));
|
||||
if (model != null) {
|
||||
System.out.println(",pdel============" + model);
|
||||
System.out.println("123313123123123==========" + model.getProfileId());
|
||||
OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId());
|
||||
System.out.println("dajadfas======" + appProfile);
|
||||
if (appProfile == null) {
|
||||
throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId());
|
||||
}
|
||||
DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT);
|
||||
if (dcProfile == null)
|
||||
throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT);
|
||||
String sql_lever ="";
|
||||
if (bo_name.equals("BO_ACT_COE_PUBLISH_N")){
|
||||
sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + rowMap.getString("PUBLISHFILEID") + "'";
|
||||
|
||||
}else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")){
|
||||
sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + rowMap.getString("CHANGEDFILEIDNEW") + "'";
|
||||
}
|
||||
String lever = DBSql.getString( sql_lever);
|
||||
System.out.println("版本号::::::::::::"+lever);
|
||||
//lever = lever.substring(0,3);
|
||||
if(lever.length()==5&&lever.substring(4).equals("0")){
|
||||
lever.substring(0,3);
|
||||
}else if (lever.length()==1){
|
||||
lever=lever+".0";
|
||||
}
|
||||
String filename = "";
|
||||
if (bo_name.equals("BO_ACT_COE_PUBLISH_N")){
|
||||
filename = rowMap.getString("PUBLISHFILENAME");
|
||||
}else if (bo_name.equals("BO_ACT_COE_PUBLISH_C")){
|
||||
filename = rowMap.getString("CHANGEDFILENAMENEW");
|
||||
}
|
||||
DCContext dcContext = new DCContext(userContext, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), rowMap.getString("TASKID"), filename+ "_" + lever+ ".doc");
|
||||
//UtilFile file = new UtilFile(dcContext.getPath());
|
||||
|
||||
|
||||
Map params = new HashMap<String, Object>();
|
||||
//知识ID,必填
|
||||
params.put("cardId", cardId);
|
||||
//sid,必填
|
||||
params.put("sid", userContext.getSessionId());
|
||||
|
||||
params.put("dc", dcContext);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//创建文件
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
System.out.println("流程手册的存入=================" + ro);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
String sql_A = "SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where ID = '"+map.getString("ID")+"' AND PLMETHODID != 'process.framework' AND PLMETHODID IN (select distinct PLMETHODID from APP_ACT_COE_PAL_REPOSITORY)";
|
||||
List<RowMap> rows = DBSql.getMaps(sql_A);
|
||||
|
||||
for (RowMap bo:rows
|
||||
) {
|
||||
|
||||
/**
|
||||
* 这个是模型中的附件获取的并插入的数据信息,需要做修改
|
||||
*/
|
||||
// 调用App
|
||||
|
||||
// 参数定义列表
|
||||
Map paramss = new HashMap<String, Object>();
|
||||
//知识ID,必填
|
||||
paramss.put("cardId", cardId);
|
||||
//sid,必填
|
||||
paramss.put("sid", userContext.getSessionId());
|
||||
|
||||
UpfileWeb upfileWeb = new UpfileWeb(userContext);
|
||||
|
||||
|
||||
|
||||
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID != 'process.framework' AND ID= '"+map.getString("ID")+"'" +
|
||||
")";
|
||||
List<RowMap> maps = DBSql.getMaps(sql_upfile);
|
||||
for (RowMap row : maps) {
|
||||
UpfileModel upfileModel = new UpfileModel();
|
||||
upfileModel.setType(row.getString("FILETYPE"));
|
||||
upfileModel.setFileName(row.getString("FILENAME"));
|
||||
upfileModel.setPl_uuid(row.getString("PALREPOSITORYID"));
|
||||
upfileModel.setShape_uuid(row.getString("SHAPEID"));
|
||||
DCContext dcContexts = upfileWeb.getDCContext(upfileModel);
|
||||
paramss.put("dc", dcContexts);
|
||||
AppAPI appAPIs = SDK.getAppAPI();
|
||||
ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, paramss);
|
||||
System.out.println("流程模型附件的生成============="+ros);
|
||||
}
|
||||
|
||||
//DCContext对象,必填
|
||||
|
||||
//创建文件
|
||||
}
|
||||
PublishKnow(processExecutionContext,userContext,cardId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void PublishKnow(ProcessExecutionContext processExecutionContext,UserContext userContext,String id){
|
||||
|
||||
String sql = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id in (select PLPARENTID from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '"+id +"')";
|
||||
List<RowMap> maps = DBSql.getMaps(sql);
|
||||
String ids = "";
|
||||
for (RowMap rowmap:maps
|
||||
) {
|
||||
ids+=rowmap.getString("EXT4")+",";
|
||||
}
|
||||
String[] deptSplit_id = ids.split(",");
|
||||
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (String id_names:deptSplit_id
|
||||
) {
|
||||
jsonArray.add(id_names);
|
||||
}
|
||||
//jsonObject.put(deptSplit_id);
|
||||
id+=",";
|
||||
String[] deptSplit_das = id.split(",");
|
||||
JSONArray jsonArray_das = new JSONArray();
|
||||
for (String das:deptSplit_das
|
||||
) {
|
||||
jsonArray_das.add(das);
|
||||
}
|
||||
//jsonObject.put(deptSplit_id);
|
||||
|
||||
|
||||
// 调用App
|
||||
String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
//要发布到的维度ID的JSON数组字符串,必填
|
||||
params.put("dimensionIDArray", jsonArray.toString());
|
||||
//要发布的知识ID的JSON数组字符串,必填
|
||||
params.put("knwlIDArray", jsonArray_das.toString());
|
||||
//标签的JSON数组字符串,非必填
|
||||
|
||||
//sid,必填
|
||||
params.put("sid", userContext.getSessionId());
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//发布知识
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
|
||||
System.out.println("知识发布============"+ro);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean CancelPublishKnwl(ProcessExecutionContext processExecutionContext,String sid,String knwlId) {
|
||||
// 调用App
|
||||
String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.kms/CancelPublishKnwl";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
//sid,如果为空,则需要传createUser参数,非必填
|
||||
params.put("sid", sid);
|
||||
//知识ID,必填
|
||||
params.put("knwlId", knwlId);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//取消发布知识(全部维度)
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
System.out.println("取消发布的ro=====>>>>"+ro);
|
||||
return ro.isOk();
|
||||
}
|
||||
|
||||
|
||||
public boolean execute(ProcessExecutionContext processExecutionContext,String fileCreateName,String fileName,String fileurl,String readingScope_org,String isFullCompany,String fileCreateDate,String relationProcessinstId,String readingScope_post,String readingScope_level,String fileid) {
|
||||
// 调用App
|
||||
String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.awspaas.user.apps.docview/PushFileToXpage";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
//发布人,不允许空值,必填
|
||||
params.put("fileCreateName", fileCreateName);
|
||||
//待阅文件标题名称,不允许空值,必填
|
||||
params.put("fileName", fileName);
|
||||
//阅读范围_组织,不允许空值,非必填
|
||||
params.put("readingScope_org", readingScope_org);
|
||||
//是否全公司可见,不允许空值,必填
|
||||
params.put("isFullCompany", isFullCompany);
|
||||
//待阅文件Url,不允许空值,必填
|
||||
params.put("fileurl", fileurl);
|
||||
//发布日期,不允许空值,必填
|
||||
params.put("fileCreateDate", fileCreateDate);
|
||||
//发布流程ID,不允许空值,必填
|
||||
params.put("relationProcessinstId", relationProcessinstId);
|
||||
//阅读范围_岗位,不允许空值,非必填
|
||||
params.put("readingScope_post", readingScope_post);
|
||||
//阅读范围_职级,不允许空值,非必填
|
||||
params.put("readingScope_level", readingScope_level);
|
||||
//待阅文件ID,多个逗号隔开,不允许空值,必填
|
||||
params.put("fileid", fileid);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//推送待阅文件到xpage门户
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
System.out.println("ros++++++++=====待阅》》》》》》》》》》"+ro);
|
||||
return ro.isOk();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean AddKnwlAC(ProcessExecutionContext processExecutionContext,JSONArray jsonArray,String sid,String knwlId) {
|
||||
// 调用App
|
||||
String sourceAppId = processExecutionContext.getProcessInstance().getAppId();
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
//[{"assignmentType":"department","assignmentId":"62196ff9-a26d-4be5-9480-3ef680886f63"},{"assignmentType":"user","assignmentId":"user1"}],必填
|
||||
params.put("acList", jsonArray);
|
||||
//sid,如果为空,则需要传createUser参数,非必填
|
||||
params.put("sid", sid);
|
||||
//知识ID,必填
|
||||
params.put("knwlId", knwlId);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//给知识授权
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
return ro.isOk();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.awspaas.user.apps.integration.event;
|
||||
|
||||
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
|
||||
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
|
||||
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListenerInterface;
|
||||
|
||||
/**
|
||||
* @PackageName: com.awspaas.user.apps.yili.event
|
||||
* @ClassName: TestEvent
|
||||
* @author: yujh
|
||||
* @date: 2022/5/30 20:20
|
||||
*/
|
||||
public class TestEvent extends ExecuteListener implements ExecuteListenerInterface {
|
||||
@Override
|
||||
public void execute(ProcessExecutionContext processExecutionContext) throws Exception {
|
||||
System.err.println(">>>>>>>>>111111111");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package com.awspaas.user.apps.integration.event;
|
||||
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
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 org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 更新流程架构中同步到知识维度的数据
|
||||
*/
|
||||
public class UpdateDimensionJob implements IJob {
|
||||
|
||||
|
||||
|
||||
private static String APPID = "com.awspaas.user.apps.yili.integration";
|
||||
|
||||
|
||||
private static String USERID = "admin";
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
|
||||
SSOUtil ssoUtil = new SSOUtil();
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
String sid = ssoUtil.registerClientSessionNoPassword(USERID, "cn", portalUrl, "pc");
|
||||
UserContext userContext = UserContext.fromSessionId(sid);
|
||||
String sql = "select * from APP_ACT_KMS_DIMENSION where ID not in ('obj_e055a421f23547579a75130d27ab3b34','obj_5020f54928c842b58107c3354e450070')";
|
||||
List<RowMap> maps = DBSql.getMaps(sql);
|
||||
for (RowMap row :
|
||||
maps) {
|
||||
String sql_Pal = "select * from APP_ACT_COE_PAL_REPOSITORY where EXT4 = '"+row.getString("ID")+"'";
|
||||
RowMap map = DBSql.getMap(sql_Pal);
|
||||
if (map!=null){
|
||||
if (row.getString("DIMENSIONNAME").equals(map.getString("PLNAME"))){
|
||||
|
||||
}else{
|
||||
String parent_ext4 = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id = '"+map.getString("PLPARENTID")+"'";
|
||||
String ext4 = DBSql.getString("EXT4");
|
||||
updateDimension(row.getString("ID"),map.getString("PLNAME"),ext4,sid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateDimension(String dimensionId,String dimensionName,String parentId,String sid) {
|
||||
// 调用App
|
||||
String sourceAppId = APPID;
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.kms/updateDimension";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
//发布是否需要审批,默认false,非必填
|
||||
params.put("isExamine", false);
|
||||
//维度ID,必填
|
||||
params.put("dimensionId", dimensionId);
|
||||
//是否启用,默认启用,非必填
|
||||
params.put("isEnabled", true);
|
||||
//维度类型,1:允许发布知识 2:不允许发布知识,非必填
|
||||
params.put("showType", 1);
|
||||
//维度描述,非必填
|
||||
params.put("memo", "");
|
||||
//维度名称,非必填
|
||||
params.put("dimensionName", dimensionName);
|
||||
//父维度Id:""表示根维度,非必填
|
||||
params.put("parentId", parentId);
|
||||
//sid,必填
|
||||
params.put("sid", sid);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//修改维度
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,165 @@
|
||||
package com.awspaas.user.apps.integration.event;
|
||||
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
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 org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 创建维度
|
||||
*/
|
||||
public class createDimensionJob implements IJob {
|
||||
|
||||
|
||||
private static String APPID = "com.awspaas.user.apps.yili.integration";
|
||||
private static String USERID = "admin";
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
|
||||
SSOUtil ssoUtil = new SSOUtil();
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
String sid = ssoUtil.registerClientSessionNoPassword(USERID, "cn", portalUrl, "pc");
|
||||
UserContext userContext = UserContext.fromSessionId(sid);
|
||||
String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = 'process' and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试' ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e', 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09', '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5', '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093', '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c', '42c09260-c1d3-44b7-ac3d-f8280e04c294') order by PLORDERINDEX asc";
|
||||
List<RowMap> maps = DBSql.getMaps(sql);
|
||||
for (RowMap rowmap: maps
|
||||
) {
|
||||
|
||||
String sql_decre = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+rowmap.getString("PLNAME")+"'";
|
||||
RowMap map2 = DBSql.getMap(sql_decre);
|
||||
if (map2==null){
|
||||
|
||||
createDimension(rowmap.getString("PLPARENTID"),false,true,"1","","",rowmap.getString("PLNAME").toString(),sid);
|
||||
}
|
||||
|
||||
String sql_parent = "select * from APP_ACT_COE_PAL_REPOSITORY where PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = '"+rowmap.getString("ID")+"' order by PLORDERINDEX asc";
|
||||
List<RowMap> maps1 = DBSql.getMaps(sql_parent);
|
||||
for (RowMap rowMap:
|
||||
maps1) {
|
||||
|
||||
String cime = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+rowMap.getString("PLNAME")+"'";
|
||||
RowMap map = DBSql.getMap(cime);
|
||||
if (map==null){
|
||||
|
||||
createDimension(rowMap.getString("PLPARENTID"),false,true,"1","","",rowMap.getString("PLNAME").toString(),sid);
|
||||
}
|
||||
|
||||
String sql_parent1 = "select * from APP_ACT_COE_PAL_REPOSITORY where PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = '"+rowMap.getString("ID")+"' order by PLORDERINDEX asc";
|
||||
List<RowMap> maps11 = DBSql.getMaps(sql_parent1);
|
||||
for (RowMap rowMap1:
|
||||
maps11) {
|
||||
|
||||
String cle = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+rowMap1.getString("PLNAME")+"'";
|
||||
RowMap mapss = DBSql.getMap(cle);
|
||||
if (mapss==null){
|
||||
|
||||
createDimension(rowMap1.getString("PLPARENTID"),false,true,"1","","",rowMap1.getString("PLNAME").toString(),sid);
|
||||
}
|
||||
|
||||
String sql_parent11 = "select * from APP_ACT_COE_PAL_REPOSITORY where PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = '"+rowMap1.getString("ID")+"' order by PLORDERINDEX asc";
|
||||
List<RowMap> maps111 = DBSql.getMaps(sql_parent11);
|
||||
for (RowMap rowMap2:
|
||||
maps111) {
|
||||
|
||||
String cles = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+rowMap2.getString("PLNAME")+"'";
|
||||
RowMap mapkjs = DBSql.getMap(cles);
|
||||
if (mapkjs==null){
|
||||
|
||||
createDimension(rowMap2.getString("PLPARENTID"),false,true,"1","","",rowMap2.getString("PLNAME").toString(),sid);
|
||||
}
|
||||
|
||||
String sql_parent111 = "select * from APP_ACT_COE_PAL_REPOSITORY where PLCATEGORY = 'process'and PLMETHODID ='process.framework' and PLPARENTID = '"+rowMap2.getString("ID")+"' order by PLORDERINDEX asc";
|
||||
List<RowMap> maps1111 = DBSql.getMaps(sql_parent111);
|
||||
|
||||
for (RowMap rowMap3:
|
||||
maps1111) {
|
||||
String oqka = "select * from APP_ACT_KMS_DIMENSION where DIMENSIONNAME = '"+rowMap3.getString("PLNAME")+"'";
|
||||
RowMap ssaq = DBSql.getMap(oqka);
|
||||
if (ssaq==null){
|
||||
|
||||
createDimension(rowMap3.getString("PLPARENTID"),false,true,"1","","",rowMap3.getString("PLNAME").toString(),sid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
public void createDimension(String id,boolean isExamine,boolean isEnabled,String showType,String memo,String createUser,String dimensionName,String sid) {
|
||||
// 调用App
|
||||
String sourceAppId = APPID;
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.kms/createDimension";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
//发布是否需要审批,默认false,必填
|
||||
params.put("isExamine", isExamine);
|
||||
//是否启用,默认启用,必填
|
||||
params.put("isEnabled", isEnabled);
|
||||
//维度类型,1:允许发布知识 2:不允许发布知识,必填
|
||||
params.put("showType", showType);
|
||||
//维度描述,非必填
|
||||
params.put("memo", memo);
|
||||
//维度名称,必填
|
||||
params.put("dimensionName", dimensionName);
|
||||
//父维度Id:""表示根维度,必填
|
||||
|
||||
String sql = "select EXT4 from APP_ACT_COE_PAL_REPOSITORY where id ='"+id+"'";
|
||||
String string = DBSql.getString(sql);
|
||||
if (id.equals("process")){
|
||||
|
||||
if (SDK.getPortalAPI().getPortalUrl().equals("https://bpm.yili.com:8088/portal")){
|
||||
string = "obj_5020f54928c842b58107c3354e450070";
|
||||
}else if (SDK.getPortalAPI().getPortalUrl().equals("http://10.60.143.183:8088/portal")){
|
||||
string = "obj_e055a421f23547579a75130d27ab3b34";
|
||||
}else{
|
||||
string = "obj_6dcfbc5d374645d5b97c8ec51ea3a234";
|
||||
}
|
||||
}
|
||||
params.put("parentId", string);
|
||||
//sid,必填
|
||||
params.put("sid", sid);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//创建维度
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
|
||||
if (!dimensionName.equals("流程制度")){
|
||||
if (ro.isOk()){
|
||||
|
||||
|
||||
String cardId = ((LinkedHashMap) ro.getData()).get("dimensionId").toString();
|
||||
String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 = '"+cardId+"' WHERE " +
|
||||
" PLCATEGORY = 'process'and PLMETHODID ='process.framework' " +
|
||||
" and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" +
|
||||
" ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" +
|
||||
" and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," +
|
||||
" 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," +
|
||||
" '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," +
|
||||
" '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," +
|
||||
" '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," +
|
||||
" '42c09260-c1d3-44b7-ac3d-f8280e04c294') and PLNAME = '"+dimensionName+"'";
|
||||
int update = DBSql.update(update_sql);
|
||||
System.out.println("更新名称为:"+dimensionName+"的维度对应的资产库的EXT4的影响行数为"+update);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.awspaas.user.apps.integration.event;
|
||||
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
|
||||
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
|
||||
public class gettilePro extends ExecuteListener {
|
||||
@Override
|
||||
public void execute(ProcessExecutionContext processExecutionContext) throws Exception {
|
||||
BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).detail();
|
||||
BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_EU_TEST", true).addQuery("BINDID=", processExecutionContext.getProcessInstance().getId()).detail();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,427 @@
|
||||
package com.awspaas.user.apps.integration.job;
|
||||
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
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.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.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class AddKnowACJob implements IJob {
|
||||
|
||||
private static String APPID = "com.awspaas.user.apps.yili.integration";
|
||||
|
||||
|
||||
private static String USERID = "admin";
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
|
||||
|
||||
String jobParameter = SDK.getJobAPI().getJobParameter(jobExecutionContext);
|
||||
|
||||
SSOUtil ssoUtil = new SSOUtil();
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
String sid = ssoUtil.registerClientSessionNoPassword(USERID, "cn", portalUrl, "pc");
|
||||
UserContext userContext = UserContext.fromSessionId(sid);
|
||||
|
||||
List<BO> bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).list();
|
||||
for (BO bo : bo_act_coe_publish
|
||||
) {
|
||||
String uid = "";
|
||||
String new_uid = "";
|
||||
if (bo != null) {
|
||||
String da = bo.getString("SEND_SCOP");
|
||||
|
||||
if (da.equals("1")) {
|
||||
List<RowMap> select_userid_from_orguser = DBSql.getMaps("select USERID from ORGUSER");
|
||||
for (RowMap row : select_userid_from_orguser
|
||||
) {
|
||||
uid += row.getString("USERID") + ",";
|
||||
}
|
||||
} else {
|
||||
List posts_list = new ArrayList();
|
||||
String strs[] = bo.getString("SEND_SCOPE_ORG").split(",");
|
||||
if (StringUtils.isNotEmpty(bo.getString("SEND_SCOPE_POST"))) {
|
||||
String posts[] = bo.getString("SEND_SCOPE_POST").split(",");
|
||||
posts_list = Arrays.asList(posts);
|
||||
}
|
||||
List ranks_list = new ArrayList();
|
||||
if (StringUtils.isNotEmpty(bo.getString("SEND_SCOPE_LEVEL"))) {
|
||||
String ranks[] = bo.getString("SEND_SCOPE_LEVEL").split(",");
|
||||
ranks_list = Arrays.asList(ranks);
|
||||
}
|
||||
|
||||
for (String depaartid : strs
|
||||
) {
|
||||
DepartmentModel departmentModel = SDK.getORGAPI().getDepartmentById(depaartid);
|
||||
boolean existSubModelOfCache = departmentModel.isExistSubModelOfCache();
|
||||
//判断选中的是否有下级部门
|
||||
if (existSubModelOfCache) {
|
||||
List<RowMap> maps = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + depaartid + "'");
|
||||
for (RowMap row : maps
|
||||
) {
|
||||
String id = row.getString("ID");
|
||||
DepartmentModel model = SDK.getORGAPI().getDepartmentById(id);
|
||||
|
||||
if (model.isExistSubModelOfCache()) {
|
||||
//有下级部门的选中有下级部门
|
||||
List<RowMap> rowMapList = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + id + "'");
|
||||
for (RowMap wo :
|
||||
rowMapList) {
|
||||
String ids = wo.getString("ID");
|
||||
DepartmentModel model1 = SDK.getORGAPI().getDepartmentById(ids);
|
||||
if (model1.isExistSubModelOfCache()) {
|
||||
List<RowMap> rowMapLists = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + ids + "'");
|
||||
for (RowMap wsa :
|
||||
rowMapLists) {
|
||||
String wsaString = wsa.getString("ID");
|
||||
DepartmentModel model2 = SDK.getORGAPI().getDepartmentById(wsaString);
|
||||
if (model2.isExistSubModelOfCache()) {
|
||||
List<RowMap> rowMapList1 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + wsaString + "'");
|
||||
for (RowMap rows :
|
||||
rowMapList1) {
|
||||
String rowsString = rows.getString("ID");
|
||||
DepartmentModel model3 = SDK.getORGAPI().getDepartmentById(rowsString);
|
||||
if (model3.isExistSubModelOfCache()) {
|
||||
List<RowMap> rowMapList2 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + rowsString + "'");
|
||||
for (RowMap ormap :
|
||||
rowMapList2) {
|
||||
String rowsString1 = ormap.getString("ID");
|
||||
DepartmentModel model4 = SDK.getORGAPI().getDepartmentById(rowsString1);
|
||||
if (model4.isExistSubModelOfCache()) {
|
||||
List<RowMap> rowMaps = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + rowsString1 + "'");
|
||||
for (RowMap owmapr :
|
||||
rowMaps) {
|
||||
String row_id = owmapr.getString("ID");
|
||||
DepartmentModel model5 = SDK.getORGAPI().getDepartmentById(row_id);
|
||||
if (model5.isExistSubModelOfCache()) {
|
||||
List<RowMap> rowMapList3 = DBSql.getMaps("SELECT * FROM ORGDEPARTMENT WHERE PARENTDEPARTMENTID = '" + row_id + "'");
|
||||
for (RowMap owzmap :
|
||||
rowMapList3) {
|
||||
String idsa = owzmap.getString("ID");
|
||||
DepartmentModel model6 = SDK.getORGAPI().getDepartmentById(idsa);
|
||||
if (model6.isExistSubModelOfCache()) {
|
||||
|
||||
} else {
|
||||
List<UserModel> allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(idsa);
|
||||
for (UserModel user : allUsersByDepartments
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<UserModel> allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(row_id);
|
||||
for (UserModel user : allUsersByDepartments
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<UserModel> allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(rowsString1);
|
||||
for (UserModel user : allUsersByDepartments
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<UserModel> allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(rowsString);
|
||||
for (UserModel user : allUsersByDepartments
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<UserModel> allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(wsaString);
|
||||
for (UserModel user : allUsersByDepartments
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<UserModel> allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(ids);
|
||||
for (UserModel user : allUsersByDepartments
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<UserModel> allUsersByDepartments = SDK.getORGAPI().getAllUsersByDepartment(id);
|
||||
for (UserModel user : allUsersByDepartments
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//选中的没有下级部门
|
||||
List<UserModel> allUsersByDepartment = SDK.getORGAPI().getAllUsersByDepartment(depaartid);
|
||||
for (UserModel user : allUsersByDepartment
|
||||
) {
|
||||
if (posts_list != null && ranks_list != null) {
|
||||
if (posts_list.contains(user.getPositionNo()) && ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list != null && ranks_list == null) {
|
||||
if (posts_list.contains(user.getPositionNo())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else if (posts_list == null && ranks_list != null) {
|
||||
if (ranks_list.contains(user.getExt2())) {
|
||||
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
} else {
|
||||
uid += user.getUID() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(uid
|
||||
)) {
|
||||
uid = uid.substring(0, uid.length() - 1);
|
||||
String[] split = uid.split(",");
|
||||
|
||||
List<String> list = new ArrayList(Arrays.asList(split));
|
||||
|
||||
HashSet h = new HashSet(list);
|
||||
list.clear();
|
||||
list.addAll(h);
|
||||
for (String userid : list
|
||||
) {
|
||||
new_uid += userid + ",";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(new_uid
|
||||
)) {
|
||||
new_uid = new_uid.substring(0, new_uid.length() - 1);
|
||||
}
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
|
||||
if (bo.getString("SEND_SCOP").equals("0")) {
|
||||
String departId = bo.getString("SEND_SCOPE_ORG");
|
||||
if (StringUtils.isNotEmpty(departId) && StringUtils.isEmpty(bo.getString("SEND_SCOPE_LEVEL")) && StringUtils.isEmpty(bo.getString("SEND_SCOPE_POST"))) {
|
||||
String strs[] = departId.split(",");
|
||||
for (String departmentid : strs
|
||||
) {
|
||||
JSONObject jsonObjecta = new JSONObject();
|
||||
jsonObjecta.put("assignmentType", "department");
|
||||
jsonObjecta.put("assignmentId", departmentid);
|
||||
jsonArray.add(jsonObjecta);
|
||||
}
|
||||
} else {
|
||||
String[] split = uid.split(",");
|
||||
|
||||
List<String> list = new ArrayList(Arrays.asList(split));
|
||||
|
||||
HashSet h = new HashSet(list);
|
||||
list.clear();
|
||||
list.addAll(h);
|
||||
|
||||
for (String user_id : list
|
||||
) {
|
||||
JSONObject jsonObjecta = new JSONObject();
|
||||
jsonObjecta.put("assignmentType", "user");
|
||||
jsonObjecta.put("assignmentId", user_id);
|
||||
jsonArray.add(jsonObjecta);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<BO> list = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID=", bo.getString("BINDID")).list();
|
||||
|
||||
for (BO bo_N:
|
||||
list) {
|
||||
String pr_id = bo_N.getString("PUBLISHFILEID");
|
||||
RowMap map = DBSql.getMap("SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + pr_id + "'");
|
||||
if (map!=null){
|
||||
String ext4 = map.getString("EXT4");
|
||||
if (StringUtils.isNotEmpty(ext4)){
|
||||
AddKnwlAC(jsonArray,userContext.getSessionId(),ext4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<BO> boList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).addQuery("BINDID=", bo.getString("BINDID")).list();
|
||||
|
||||
for (BO bo_N:
|
||||
boList) {
|
||||
String pr_id = bo_N.getString("CHANGEDFILEIDNEW");
|
||||
RowMap map = DBSql.getMap("SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '" + pr_id + "'");
|
||||
if (map!=null){
|
||||
String ext4 = map.getString("EXT4");
|
||||
if (StringUtils.isNotEmpty(ext4)){
|
||||
AddKnwlAC(jsonArray,userContext.getSessionId(),ext4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean AddKnwlAC(JSONArray jsonArray, String sid, String knwlId) {
|
||||
// 调用App
|
||||
String sourceAppId = APPID;
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.kms/AddKnwlAC";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
//[{"assignmentType":"department","assignmentId":"62196ff9-a26d-4be5-9480-3ef680886f63"},{"assignmentType":"user","assignmentId":"user1"}],必填
|
||||
params.put("acList", jsonArray);
|
||||
//sid,如果为空,则需要传createUser参数,非必填
|
||||
params.put("sid", sid);
|
||||
//知识ID,必填
|
||||
params.put("knwlId", knwlId);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//给知识授权
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
return ro.isOk();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,283 @@
|
||||
package com.awspaas.user.apps.integration.job;
|
||||
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.schedule.IJob;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.awspaas.user.apps.integration.util.UtilUrl;
|
||||
import jodd.util.StringUtil;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 伊利OA系统与流程审批节点操作数据查询接口集成
|
||||
*/
|
||||
public class CreateWorkflowServiceJob implements IJob {
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
System.out.println("portal======>>>>"+portalUrl);
|
||||
/*if (portalUrl.equals("http://10.114.11.135:8088/portal")){
|
||||
portalUrl = "http://bpm.yili.com:8088/portal/";
|
||||
}*/
|
||||
Connection open = DBSql.open();
|
||||
|
||||
try {
|
||||
|
||||
|
||||
|
||||
|
||||
//ProcessExecutionContext processExecutionContext,String fileCreateName,String fileName,String fileurl,String readingScope_org,String isFullCompany,String fileCreateDate,String relationProcessinstId,String readingScope_post,String readingScope_level,String fileid
|
||||
|
||||
int tale = 561486;
|
||||
JSONObject jsonObject = new JSONObject(new LinkedHashMap());
|
||||
jsonObject.put("workflowId",tale);
|
||||
jsonObject.put("createDateStart","2019-07-01 00:00:00");//SDK.getORGAPI().getDepartmentByUser(processExecutionContext.getProcessInstance().getCreateUser()).getNo()
|
||||
jsonObject.put("createDateEnd","2023-09-01 00:00:00");//processExecutionContext.getProcessInstance().getCreateUser()
|
||||
jsonObject.put("pageIndex",1);
|
||||
jsonObject.put("pageSize",10);
|
||||
|
||||
|
||||
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.services.weaver.com.cn\">\n" +
|
||||
" <soapenv:Header/>" +
|
||||
" <soapenv:Body>" +
|
||||
" <web:getFormDataByWfId>" +
|
||||
" <web:in0>" +
|
||||
""+jsonObject+""+
|
||||
" </web:in0>" +
|
||||
" </web:getFormDataByWfId>" +
|
||||
" </soapenv:Body>" +
|
||||
"</soapenv:Envelope>";
|
||||
|
||||
|
||||
/* String xmls = "<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[ {\"action\":\"read\",\"title\":\"asdadasdadasda\",\"dept\":\"00000010\",\"user\":\"00345531\",\"date\":\"2022-07-13\",\"remark\":\"分发本部门人员查看\",\"status\":\"0\",\"pcurl\":\"http://10.119.254.49:33018/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=cf8ec45e-8209-4437-a8dd-a2ea278771ae\",\"mobileurl\":\"http://10.119.254.49:33018/r/or?cmd=com.yili_process_page&oauthName=oauthLogin&processInstId=cf8ec45e-8209-4437-a8dd-a2ea278771ae\",\"userList\":\"00345531\"} ]]> </web:in0> </web:service> </soapenv:Body></soapenv:Envelope>";
|
||||
*/
|
||||
System.out.println("参数==============="+xmlStr);
|
||||
//System.out.println("参数==============="+xmls);
|
||||
//HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||||
int timeout = 600000;
|
||||
// HttpURLConnection 发送SOAP请求
|
||||
System.out.println("HttpURLConnection 发送SOAP请求");
|
||||
|
||||
String postSoap = UtilUrl.doPostSoap("http://10.119.22.207:80/services/WorkflowService", xmlStr, "");
|
||||
|
||||
/*// HttpClient发送SOAP请求
|
||||
System.out.println("HttpClient 发送SOAP请求");
|
||||
HttpClient client = new HttpClient();
|
||||
PostMethod postMethod = new PostMethod("http://10.119.22.207:80/services/WorkflowService");
|
||||
// 设置连接超时
|
||||
client.getHttpConnectionManager().getParams().setConnectionTimeout(timeout);
|
||||
// 设置读取时间超时
|
||||
client.getHttpConnectionManager().getParams().setSoTimeout(timeout);
|
||||
// 然后把Soap请求数据添加到PostMethod中
|
||||
RequestEntity requestEntity = new StringRequestEntity(xmlStr, "text/xml", "UTF-8");
|
||||
// 设置请求体
|
||||
postMethod.setRequestEntity(requestEntity);
|
||||
int status = client.executeMethod(postMethod);
|
||||
// 打印请求状态码
|
||||
System.out.println("status:" + status);
|
||||
// 获取响应体输入流
|
||||
String responseBodyAsString = postMethod.getResponseBodyAsString();
|
||||
|
||||
|
||||
System.out.println("responseBodyAsString==========>>>>>>>"+responseBodyAsString);
|
||||
|
||||
System.out.println("result=========>>>>>>>"+responseBodyAsString);*/
|
||||
|
||||
Document document = DocumentHelper.parseText(postSoap);
|
||||
Element rootElement = document.getRootElement();
|
||||
System.out.println("rootElement>>>>>>"+rootElement);
|
||||
Element result = rootElement.element("Body").element("getFormDataByWfIdResponse").element("out");
|
||||
String resultString = result.getData().toString();
|
||||
System.out.println("resultString=>>>>>>>>>>"+resultString);
|
||||
JSONObject jsonObject1 = JSON.parseObject(resultString);
|
||||
String datas = jsonObject1.getString("datas");
|
||||
JSONArray resultArray = JSONObject.parseArray(datas);
|
||||
System.out.println("个数》》》》》》》》"+resultArray.size());
|
||||
StringBuffer allKey = getAllKey(resultArray.getJSONObject(0));
|
||||
System.out.println("所有的字段名称信息输出》》》》》》》》》》》》"+allKey
|
||||
);
|
||||
String strs[] = allKey.toString().split(",");
|
||||
String sql = "create table T"+tale+"(";
|
||||
for (String field:strs
|
||||
) {
|
||||
sql+=field+" "+"nvarchar2(2000),";
|
||||
}
|
||||
sql = sql.substring(0,sql.length()-1)+")";
|
||||
System.out.println("sql>>>>>>>>>>>>>>"+sql);
|
||||
RowMap map = DBSql.getMap("select * from user_tables t where table_name= upper('T"+tale+"')");
|
||||
System.out.println("rowMap>>>>>>>>"+map);
|
||||
if (map==null){
|
||||
int update = DBSql.update(sql
|
||||
);
|
||||
System.out.println("是否已经插入数据"+update);
|
||||
}
|
||||
|
||||
|
||||
// DBSql.update("create index AWS_IN_63A5A52E2FA2 on T"+tale+" (BINDID);");
|
||||
String substring = allKey.substring(0, allKey.length() - 1);
|
||||
String insetr = "insert into T"+tale+"("+substring+") values(";
|
||||
//for (int i =0;i<resultArray.size();i++){
|
||||
|
||||
|
||||
for (int i=0;i<resultArray.size();i++){
|
||||
String data = "";
|
||||
JSONObject jsonObject2 = resultArray.getJSONObject(i);
|
||||
for (String field:strs
|
||||
) {
|
||||
if (jsonObject2.get(field).toString().contains("'")){
|
||||
String basic_data = jsonObject2.get(field).toString().replaceAll("'","'||CHR(39)||'");
|
||||
if (basic_data.length()>2000){
|
||||
DBSql.update("alter table T"+tale+" add "+field+"_temp clob");
|
||||
DBSql.update("update T"+tale+" set "+field+"_temp = "+field+"");
|
||||
DBSql.update("alter table T"+tale+" drop column "+field+"");
|
||||
DBSql.update("alter table T"+tale+" rename column "+field+"_temp to "+field+"");
|
||||
}
|
||||
data +="'"+basic_data+"',";
|
||||
}else{
|
||||
if (jsonObject2.get(field).toString().length()>2000){
|
||||
DBSql.update("alter table T"+tale+" add "+field+"_temp clob");
|
||||
DBSql.update("update T"+tale+" set "+field+"_temp = "+field+"");
|
||||
DBSql.update("alter table T"+tale+" drop column "+field+"");
|
||||
DBSql.update("alter table T"+tale+" rename column "+field+"_temp to "+field+"");
|
||||
}
|
||||
data += "'"+jsonObject2.get(field).toString()+"',";
|
||||
}
|
||||
|
||||
}
|
||||
System.out.println("最后数据=====》》》》》"+data);
|
||||
data = data.substring(0,data.length()-1);
|
||||
String sqsl = insetr+data+")";
|
||||
System.out.println("sqsl>>>>>>>>>>>>"+sqsl);
|
||||
int update = DBSql.update(sqsl);
|
||||
System.out.println("插入数据影响行数》》》》》》》》》》》"+update);
|
||||
}
|
||||
|
||||
|
||||
// }
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
open.close();
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.out.println("同步插入OA表单数据同步完成");
|
||||
}
|
||||
//根据JSONArray获取所有的key
|
||||
public static StringBuffer getAllKey(JSONArray json1) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
if (json1 != null ) {
|
||||
Iterator i1 = json1.iterator();
|
||||
while (i1.hasNext()) {
|
||||
Object key = i1.next();
|
||||
if (key instanceof JSONObject) {
|
||||
JSONObject innerObject = (JSONObject) key;
|
||||
stringBuffer.append(getAllKey(innerObject));
|
||||
} else if (key instanceof JSONArray) {
|
||||
JSONArray innerObject = (JSONArray) key;
|
||||
stringBuffer.append(getAllKey(innerObject));
|
||||
}else{
|
||||
}
|
||||
}
|
||||
}
|
||||
return stringBuffer;
|
||||
}
|
||||
//根据jsonobject获取所有的key
|
||||
public static StringBuffer getAllKey(JSONObject jsonObject) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
Iterator<String> keys = jsonObject.keySet().iterator();// jsonObject.keys();
|
||||
while (keys.hasNext()) {
|
||||
String key = keys.next();
|
||||
stringBuffer.append(key.toString()).append(",");
|
||||
if (jsonObject.get(key) instanceof JSONObject) {
|
||||
JSONObject innerObject = (JSONObject) jsonObject.get(key);
|
||||
stringBuffer.append(getAllKey(innerObject));
|
||||
} else if (jsonObject.get(key) instanceof JSONArray) {
|
||||
JSONArray innerObject = (JSONArray) jsonObject.get(key);
|
||||
stringBuffer.append(getAllKey(innerObject));
|
||||
}
|
||||
}
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
//递归获取jsonObject的所有value
|
||||
private StringBuffer mStringBuffer = new StringBuffer();
|
||||
public String getAllContentFromJson(Object cObject) {
|
||||
|
||||
if(cObject instanceof JSONObject) {
|
||||
JSONObject jsonObject = (JSONObject) cObject;
|
||||
for (Map.Entry<String, Object> entry: jsonObject.entrySet()) {
|
||||
Object o = entry.getValue();
|
||||
if(o instanceof Integer){
|
||||
mStringBuffer.append("'"+entry.getValue()+"',");
|
||||
}else if(o instanceof Double){
|
||||
mStringBuffer.append("'"+entry.getValue()+"',");
|
||||
}else if(o instanceof Float){
|
||||
mStringBuffer.append("'"+entry.getValue()+"',");
|
||||
}else if(o instanceof Byte){
|
||||
mStringBuffer.append("'"+entry.getValue()+"',");
|
||||
}else if(o instanceof Long){
|
||||
mStringBuffer.append("'"+entry.getValue()+"',");
|
||||
}else if(o instanceof String) {
|
||||
Object object = null;
|
||||
try{
|
||||
object=JSONObject.parseObject((String)o);
|
||||
getAllContentFromJson(object);
|
||||
}catch (Exception e){
|
||||
mStringBuffer.append("'"+entry.getValue()+"',");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
getAllContentFromJson(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(cObject instanceof JSONArray) {
|
||||
JSONArray jsonArray = (JSONArray) cObject;
|
||||
for(int i = 0; i < jsonArray.size(); i ++) {
|
||||
getAllContentFromJson(jsonArray.get(i));
|
||||
}
|
||||
}
|
||||
return mStringBuffer.toString();
|
||||
}
|
||||
|
||||
public static String replaceStr(String sourceStr) {
|
||||
if (StringUtil.isBlank(sourceStr)) {
|
||||
return "";
|
||||
}
|
||||
String substring = sourceStr.substring(1, sourceStr.length() - 1);
|
||||
if (substring.contains("'")) {
|
||||
String replaceStr = substring.replace("'", "''");
|
||||
return "'" + replaceStr + "'";
|
||||
}
|
||||
return sourceStr;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,407 @@
|
||||
package com.awspaas.user.apps.integration.job;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb;
|
||||
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.SSOUtil;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.server.fs.DCContext;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.bpms.util.UtilFile;
|
||||
import com.actionsoft.exception.AWSException;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.AppAPI;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class InsertKnowlJob implements Job {
|
||||
private static String APPID = "com.awspaas.user.apps.yili.integration";
|
||||
|
||||
|
||||
private static String USERID = "admin";
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
Connection open = DBSql.open();
|
||||
try {
|
||||
|
||||
|
||||
String jobParameter = SDK.getJobAPI().getJobParameter(jobExecutionContext);
|
||||
|
||||
SSOUtil ssoUtil = new SSOUtil();
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
String sid = ssoUtil.registerClientSessionNoPassword(USERID, "cn", portalUrl, "pc");
|
||||
UserContext userContext = UserContext.fromSessionId(sid);
|
||||
System.out.println("创建维度准备开始===============");
|
||||
String sql = "select * from APP_ACT_COE_PAL_REPOSITORY where ID not in (select PLPARENTID from APP_ACT_COE_PAL_REPOSITORY) and PLCATEGORY ='process'";
|
||||
|
||||
List<RowMap> list = DBSql.getMaps(open, sql);
|
||||
for (RowMap bo : list
|
||||
) {
|
||||
String repository_sql = "select PLNAME from APP_ACT_COE_PAL_REPOSITORY where ID IN (select PLPARENTID from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID like '%process%' AND PLNAME ='" + bo.getString("PLNAME") + "')";
|
||||
String PLNAME = DBSql.getString(open, repository_sql);
|
||||
System.out.println("repository_sql>>>>>>>>>>>>>>>>>>>" + repository_sql);
|
||||
if (StringUtils.isEmpty(PLNAME)) {
|
||||
PLNAME = bo.getString("PLNAME");
|
||||
}
|
||||
String add_name = PLNAME + ",";
|
||||
|
||||
Map names = new LinkedHashMap<>();
|
||||
names.put(0, bo.getString("PLNAME"));
|
||||
names.put(1, PLNAME);
|
||||
for (int i = 2; i < 5; i++) {
|
||||
String repository_sqls = "select PLNAME from APP_ACT_COE_PAL_REPOSITORY where ID IN (select PLPARENTID from APP_ACT_COE_PAL_REPOSITORY where PLCATEGORY = 'process' AND PLNAME ='" + PLNAME + "')";//and PLMETHODID !='process.framework'
|
||||
String parent_name = DBSql.getString(open, repository_sqls);
|
||||
if (names.containsValue(parent_name)) {
|
||||
break;
|
||||
}
|
||||
String util_space = "select PLCATEGORY from APP_ACT_COE_PAL_REPOSITORY where PLPARENTID in ('process') and PLNAME = '" + PLNAME + "'";
|
||||
String fisrt_name = DBSql.getString(open, util_space);
|
||||
if (names.containsValue(fisrt_name)) {
|
||||
break;
|
||||
}
|
||||
if (fisrt_name.equals("process")) {
|
||||
names.put(i, "流程制度");
|
||||
} else if (fisrt_name.equals("org")) {
|
||||
names.put(i, "组织");
|
||||
} else if (fisrt_name.equals("data")) {
|
||||
names.put(i, "数据");
|
||||
} else if (fisrt_name.equals("itsystem")) {
|
||||
names.put(i, "IT系统");
|
||||
} else if (fisrt_name.equals("control")) {
|
||||
names.put(i, "控制");
|
||||
}
|
||||
if (StringUtils.isEmpty(parent_name)) {
|
||||
break;
|
||||
}
|
||||
PLNAME = parent_name;
|
||||
names.put(i, PLNAME);
|
||||
add_name = PLNAME + ",";
|
||||
}
|
||||
add_name = names.get(0) + ",";
|
||||
System.out.println("add_name=============="
|
||||
+ add_name);
|
||||
String dimensionId = "";
|
||||
String de_name = "";
|
||||
System.out.println("names==========" + names);
|
||||
for (int i = names.size() - 1; i >= 0; i--) {
|
||||
System.out.println("name" + i + "=================?>>>>>>>>>>" + names.get(i));
|
||||
String dimensionId_sql = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='" + names.get(i) + "'";
|
||||
dimensionId = DBSql.getString(open, dimensionId_sql);
|
||||
String sql_Frameworks = "select PLNAME from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID != 'process.framework' and PLNAME = '" + names.get(i) + "'";//
|
||||
String framework = DBSql.getString(open, sql_Frameworks);//&& StringUtils.isEmpty(framework)
|
||||
|
||||
if (StringUtils.isNotEmpty(dimensionId) ) {
|
||||
|
||||
} else {
|
||||
System.out.println("进入知识");
|
||||
String sql_Framework = "select PLNAME from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID like '%process.%' AND PLMETHODID != 'process.framework' and PLNAME = '" + names.get(i) + "'";//PLMETHODID = 'process.framework' and
|
||||
String frameworks = DBSql.getString(open, sql_Framework);//&& StringUtils.isEmpty(framework)
|
||||
if (bo.getString("PLNAME").equals(names.get(i))) {
|
||||
String card_sql = "select ID from APP_ACT_KMS_CARD where CARDNAME ='" + names.get(i) + "'";
|
||||
String card = DBSql.getString(open, card_sql);
|
||||
if (StringUtils.isNotEmpty(card)) {
|
||||
// creadteFile(userContext, open, bo.getString("PLNAME"), add_name);
|
||||
|
||||
} else {
|
||||
|
||||
// aslp服务地址
|
||||
String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl";
|
||||
// 参数定义列表
|
||||
Map params_create = new HashMap<String, Object>();
|
||||
//保密级别, 0: 普通 1:秘密 2:机密,必填
|
||||
params_create.put("securityLevel", 0);
|
||||
//知识名称,必填
|
||||
params_create.put("knwlName", names.get(i));
|
||||
//是否可以评论,必填
|
||||
params_create.put("isComment", true);
|
||||
//是否可以评分,必填
|
||||
params_create.put("isRate", true);
|
||||
//有效期:yyyy-MM-dd,非必填
|
||||
params_create.put("validDate", "2099-12-31");
|
||||
//只读控制,1:在线阅读和下载 0:在线阅读,必填
|
||||
params_create.put("onlineLevel", 1);
|
||||
//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填
|
||||
params_create.put("createUser", "admin");
|
||||
//知识内容,非必填
|
||||
params_create.put("cardContext", "");
|
||||
//sid,必填
|
||||
params_create.put("sid", userContext.getSessionId());
|
||||
AppAPI appAPI_create = SDK.getAppAPI();
|
||||
//创建知识
|
||||
ResponseObject ro_create = appAPI_create.callASLP(appAPI_create.getAppContext(APPID), aslps_create, params_create);
|
||||
System.out.println("ro_create================" + ro_create);
|
||||
// creadteFile(userContext, open, names.get(i).toString(), add_name);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
if (StringUtils.isEmpty(dimensionId)){
|
||||
// 调用App
|
||||
String sourceAppId = APPID;
|
||||
// aslp服务地址
|
||||
String aslps_de = "aslp://com.actionsoft.apps.kms/createDimension";
|
||||
// 参数定义列表
|
||||
Map paramss = new HashMap<String, Object>();
|
||||
//发布是否需要审批,默认false,必填
|
||||
paramss.put("isExamine", false);
|
||||
//是否启用,默认启用,必填
|
||||
paramss.put("isEnabled", true);
|
||||
//维度类型,1:允许发布知识 2:不允许发布知识,必填
|
||||
paramss.put("showType", 1);
|
||||
//维度描述,非必填
|
||||
paramss.put("memo", "");
|
||||
//创建人,非必填
|
||||
paramss.put("createUser", "admin");
|
||||
//维度名称,必填
|
||||
paramss.put("dimensionName", names.get(i));
|
||||
|
||||
String dimensionId_sql_i = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='" + names.get(i + 1) + "'";
|
||||
de_name = DBSql.getString(open, dimensionId_sql_i);
|
||||
//父维度Id:""表示根维度,必填
|
||||
paramss.put("parentId", de_name);
|
||||
//sid,必填
|
||||
paramss.put("sid", userContext.getSessionId());
|
||||
AppAPI appAPIs = SDK.getAppAPI();
|
||||
//创建维度
|
||||
ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslps_de, paramss);
|
||||
|
||||
System.out.println("ros==================" + ros);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("定时器执行完毕");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
open.close();
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void creadteFile(UserContext userContext, Connection open, String name, String add_name){
|
||||
/**
|
||||
* 这个主要是负责对流程手册进行相关的文件的生成
|
||||
*/
|
||||
String sourceAppId = APPID;
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.kms/CreateFile";
|
||||
|
||||
String sql = "SELECT ID FROM APP_ACT_KMS_CARD WHERE CARDNAME = '"+name+"'";
|
||||
String id = DBSql.getString(open,sql);
|
||||
if (StringUtils.isNotEmpty(id)){
|
||||
BO bos = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N",true).addQuery("PUBLISHFILENAME = ",name).detail();
|
||||
if (bos!=null){
|
||||
|
||||
|
||||
if (StringUtils.isNotEmpty(bos.getString("TASKID"))) {
|
||||
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(bos.getString("TASKID"));
|
||||
if (model != null) {
|
||||
System.out.println(",pdel============" + model);
|
||||
System.out.println("123313123123123==========" + model.getProfileId());
|
||||
OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId());
|
||||
System.out.println("dajadfas======" + appProfile);
|
||||
if (appProfile == null) {
|
||||
throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId());
|
||||
}
|
||||
DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT);
|
||||
if (dcProfile == null)
|
||||
throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT);
|
||||
String sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME = '" + bos.getString("PUBLISHFILENAME") + "'";
|
||||
String lever = DBSql.getString(open, sql_lever);
|
||||
//lever = lever.substring(0,3);
|
||||
DCContext dcContext = new DCContext(userContext, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), bos.getString("TASKID"), bos.getString("PUBLISHFILENAME") + "_" + lever + ".doc");
|
||||
//UtilFile file = new UtilFile(dcContext.getPath());
|
||||
|
||||
|
||||
Map params = new HashMap<String, Object>();
|
||||
//知识ID,必填
|
||||
params.put("cardId", id);
|
||||
//sid,必填
|
||||
params.put("sid", userContext.getSessionId());
|
||||
|
||||
params.put("dc", dcContext);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//创建文件
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
System.out.println("流程手册的存入=================" + ro);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
String sql_A = "SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where PLNAME = '"+name+"' AND PLMETHODID != 'process.framework' AND PLMETHODID IN (select distinct PLMETHODID from APP_ACT_COE_PAL_REPOSITORY)";
|
||||
List<RowMap> rows = DBSql.getMaps(open,sql_A);
|
||||
|
||||
for (RowMap bo:rows
|
||||
) {
|
||||
|
||||
/**
|
||||
* 这个是模型中的附件获取的并插入的数据信息,需要做修改
|
||||
*/
|
||||
// 调用App
|
||||
|
||||
// 参数定义列表
|
||||
Map paramss = new HashMap<String, Object>();
|
||||
//知识ID,必填
|
||||
paramss.put("cardId", id);
|
||||
//sid,必填
|
||||
paramss.put("sid", userContext.getSessionId());
|
||||
|
||||
UpfileWeb upfileWeb = new UpfileWeb(userContext);
|
||||
|
||||
|
||||
|
||||
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID != 'process.framework' AND PLNAME= '"+bo.getString("PLNAME")+"'" +
|
||||
")";
|
||||
List<RowMap> maps = DBSql.getMaps(open,sql_upfile);
|
||||
for (RowMap row : maps) {
|
||||
UpfileModel upfileModel = new UpfileModel();
|
||||
upfileModel.setType(row.getString("FILETYPE"));
|
||||
upfileModel.setFileName(row.getString("FILENAME"));
|
||||
upfileModel.setPl_uuid(row.getString("PALREPOSITORYID"));
|
||||
upfileModel.setShape_uuid(row.getString("SHAPEID"));
|
||||
DCContext dcContexts = upfileWeb.getDCContext(upfileModel);
|
||||
paramss.put("dc", dcContexts);
|
||||
AppAPI appAPIs = SDK.getAppAPI();
|
||||
ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, paramss);
|
||||
System.out.println("流程模型附件的生成============="+ros);
|
||||
}
|
||||
|
||||
//DCContext对象,必填
|
||||
|
||||
//创建文件
|
||||
}
|
||||
// PublishKnow(userContext,open,add_name,id);
|
||||
}
|
||||
}
|
||||
|
||||
public void PublishKnow(UserContext userContext,Connection open,String add_name,String id){
|
||||
System.out.println("add_name================="+add_name);
|
||||
String result = add_name.substring(0,add_name.length()-1);
|
||||
String[] deptSplit = result.split(",");
|
||||
|
||||
if(deptSplit.length==1){
|
||||
result = "'"+deptSplit[0]+"'";
|
||||
}
|
||||
result ="'"+ StringUtils.join(deptSplit, "','")+"'";
|
||||
System.out.println(">>>>>NO =" + result);
|
||||
|
||||
String sql = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME IN ("+result+") ";
|
||||
List<RowMap> maps = DBSql.getMaps(open, sql);
|
||||
if (maps.size()==0){
|
||||
String sql_DIMENSIONNAME = "SELECT PLPARENTID FROM APP_ACT_COE_PAL_REPOSITORY where PLCATEGORY = 'process' and PLNAME IN ("+result+") ";
|
||||
String maps_first = DBSql.getString(open, sql_DIMENSIONNAME);
|
||||
|
||||
if (maps_first.equals("itsystem")){
|
||||
String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='IT系统' ";
|
||||
maps = DBSql.getMaps(open, sql_id);
|
||||
}else if (maps_first.equals("control")){
|
||||
String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='控制' ";
|
||||
maps = DBSql.getMaps(open, sql_id);
|
||||
}else if (maps_first.equals("process")){
|
||||
String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='流程制度' ";
|
||||
maps = DBSql.getMaps(open, sql_id);
|
||||
}else if (maps_first.equals("org")){
|
||||
String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='组织' ";
|
||||
maps = DBSql.getMaps(open, sql_id);
|
||||
}else if (maps_first.equals("data")){
|
||||
String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='数据' ";
|
||||
maps = DBSql.getMaps(open, sql_id);
|
||||
}else {
|
||||
String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME =(SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where ID ='"+maps_first+"')";
|
||||
maps = DBSql.getMaps(open, sql_id);
|
||||
}
|
||||
}
|
||||
String ids = "";
|
||||
if (maps.size()!=0){
|
||||
|
||||
for (RowMap rowmap:maps
|
||||
) {
|
||||
ids+=rowmap.getString("ID")+",";
|
||||
}
|
||||
ids = ids.substring(0,ids.length()-1);
|
||||
|
||||
}else {
|
||||
for (RowMap rowmap:maps
|
||||
) {
|
||||
ids+=rowmap.getString("ID")+",";
|
||||
}
|
||||
ids = ids.substring(0,ids.length()-1);
|
||||
}
|
||||
|
||||
String[] deptSplit_id = ids.split(",");
|
||||
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (String id_names:deptSplit_id
|
||||
) {
|
||||
jsonArray.add(id_names);
|
||||
}
|
||||
//jsonObject.put(deptSplit_id);
|
||||
id+=",";
|
||||
String[] deptSplit_das = id.split(",");
|
||||
JSONArray jsonArray_das = new JSONArray();
|
||||
for (String das:deptSplit_das
|
||||
) {
|
||||
jsonArray_das.add(das);
|
||||
}
|
||||
//jsonObject.put(deptSplit_id);
|
||||
|
||||
|
||||
// 调用App
|
||||
String sourceAppId = APPID;
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
//要发布到的维度ID的JSON数组字符串,必填
|
||||
params.put("dimensionIDArray", jsonArray.toString());
|
||||
//要发布的知识ID的JSON数组字符串,必填
|
||||
params.put("knwlIDArray", jsonArray_das.toString());
|
||||
//标签的JSON数组字符串,非必填
|
||||
|
||||
//sid,必填
|
||||
params.put("sid", userContext.getSessionId());
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//发布知识
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
|
||||
System.out.println("知识发布============"+ro);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,461 @@
|
||||
package com.awspaas.user.apps.integration.job;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb;
|
||||
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.SSOUtil;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.server.fs.DCContext;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.exception.AWSException;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.AppAPI;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @PackageName: com.awspaas.user.apps.yili.integration.job
|
||||
* @ClassName: UpdateKnowJob
|
||||
* @author: wangcy
|
||||
* @date: 2022/8/10 14:41
|
||||
*/
|
||||
public class UpdateKnowJob implements Job {
|
||||
|
||||
private static String APPID = "com.awspaas.user.apps.yili.integration";
|
||||
|
||||
|
||||
private static String USERID = "admin";
|
||||
|
||||
@Override
|
||||
|
||||
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
|
||||
Connection open = DBSql.open();
|
||||
try {
|
||||
|
||||
|
||||
String jobParameter = SDK.getJobAPI().getJobParameter(jobExecutionContext);
|
||||
|
||||
SSOUtil ssoUtil = new SSOUtil();
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
String sid = ssoUtil.registerClientSessionNoPassword(USERID, "cn", portalUrl, "pc");
|
||||
UserContext userContext = UserContext.fromSessionId(sid);
|
||||
System.out.println("创建维度准备开始===============");
|
||||
String sql = "select * from APP_ACT_COE_PAL_REPOSITORY " +
|
||||
"where PLCATEGORY = 'process'and PLMETHODID !='process.framework' " +
|
||||
"and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" +
|
||||
",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" +
|
||||
" and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," +
|
||||
"'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," +
|
||||
"'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," +
|
||||
"'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," +
|
||||
"'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," +
|
||||
"'42c09260-c1d3-44b7-ac3d-f8280e04c294')";
|
||||
|
||||
|
||||
List<RowMap> list = DBSql.getMaps(open, sql);
|
||||
for (RowMap bo : list
|
||||
) {
|
||||
String repository_sql = " select PLNAME from APP_ACT_COE_PAL_REPOSITORY " +
|
||||
"where PLCATEGORY = 'process'and PLMETHODID ='process.framework' " +
|
||||
"and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" +
|
||||
",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" +
|
||||
" and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," +
|
||||
"'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," +
|
||||
"'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," +
|
||||
"'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," +
|
||||
"'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," +
|
||||
"'42c09260-c1d3-44b7-ac3d-f8280e04c294')" + " and PLNAME ='" + bo.getString("PLNAME") + "'";
|
||||
String PLNAME = DBSql.getString(open, repository_sql);
|
||||
System.out.println("repository_sql>>>>>>>>>>>>>>>>>>>" + repository_sql);
|
||||
if (StringUtils.isEmpty(PLNAME)) {
|
||||
PLNAME = bo.getString("EXT4");
|
||||
}
|
||||
String add_name = PLNAME + ",";
|
||||
|
||||
Map names = new LinkedHashMap<>();
|
||||
names.put(0, bo.getString("EXT4"));
|
||||
names.put(1, PLNAME);
|
||||
for (int i = 2; i < 5; i++) {
|
||||
String repository_sqls = " select EXT4 from APP_ACT_COE_PAL_REPOSITORY " +
|
||||
"where PLCATEGORY = 'process'and PLMETHODID ='process.framework' " +
|
||||
"and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" +
|
||||
",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" +
|
||||
" and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," +
|
||||
"'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," +
|
||||
"'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," +
|
||||
"'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," +
|
||||
"'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," +
|
||||
"'42c09260-c1d3-44b7-ac3d-f8280e04c294')"+" and EXT4 ='" + PLNAME + "'";//and PLMETHODID !='process.framework'
|
||||
String parent_name = DBSql.getString(open, repository_sqls);
|
||||
if (names.containsValue(parent_name)) {
|
||||
break;
|
||||
}
|
||||
String util_space = "select PLCATEGORY from APP_ACT_COE_PAL_REPOSITORY where PLPARENTID in ('process') and PLNAME = '" + PLNAME + "'";
|
||||
String fisrt_name = DBSql.getString(open, util_space);
|
||||
if (names.containsValue(fisrt_name)) {
|
||||
break;
|
||||
}
|
||||
if (fisrt_name.equals("process")) {
|
||||
names.put(i, "obj_5020f54928c842b58107c3354e450070");
|
||||
}
|
||||
if (StringUtils.isEmpty(parent_name)) {
|
||||
break;
|
||||
}
|
||||
PLNAME = parent_name;
|
||||
names.put(i, PLNAME);
|
||||
add_name = PLNAME + ",";
|
||||
}
|
||||
add_name = names.get(0) + ",";
|
||||
System.out.println("add_name=============="
|
||||
+ add_name);
|
||||
String dimensionId = "";
|
||||
String de_name = "";
|
||||
System.out.println("names==========" + names);
|
||||
for (int i = names.size() - 1; i >= 0; i--) {
|
||||
System.out.println("name" + i + "=================?>>>>>>>>>>" + names.get(i));
|
||||
String dimensionId_sql = "SELECT ID FROM APP_ACT_KMS_DIMENSION where ID ='" + names.get(i) + "'";
|
||||
dimensionId = DBSql.getString(open, dimensionId_sql);
|
||||
String sql_Frameworks = " select EXT4 from APP_ACT_COE_PAL_REPOSITORY " +
|
||||
"where PLCATEGORY = 'process'and PLMETHODID ='process.framework' " +
|
||||
"and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" +
|
||||
",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" +
|
||||
" and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," +
|
||||
"'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," +
|
||||
"'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," +
|
||||
"'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," +
|
||||
"'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," +
|
||||
"'42c09260-c1d3-44b7-ac3d-f8280e04c294')"+" and EXT4 = '" + names.get(i) + "'";//
|
||||
String framework = DBSql.getString(open, sql_Frameworks);//&& StringUtils.isEmpty(framework)
|
||||
|
||||
if (StringUtils.isNotEmpty(dimensionId) || StringUtils.isEmpty(framework)) {
|
||||
|
||||
} else {
|
||||
System.out.println("进入知识");
|
||||
String sql_Framework = " select EXT4 from APP_ACT_COE_PAL_REPOSITORY " +
|
||||
"where PLCATEGORY = 'process'and PLMETHODID !='process.framework' " +
|
||||
"and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" +
|
||||
",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" +
|
||||
" and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," +
|
||||
"'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," +
|
||||
"'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," +
|
||||
"'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," +
|
||||
"'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," +
|
||||
"'42c09260-c1d3-44b7-ac3d-f8280e04c294')"+"and EXT4 = '" + names.get(i) + "'";//PLMETHODID = 'process.framework' and
|
||||
String frameworks = DBSql.getString(open, sql_Framework);//&& StringUtils.isEmpty(framework)
|
||||
if (bo.getString("EXT4").equals(names.get(i))) {
|
||||
String card_sql = "select ID from APP_ACT_KMS_CARD where ID ='" + names.get(i) + "'";
|
||||
String card = DBSql.getString(open, card_sql);
|
||||
String card_sql_name = "select CARDNAME from APP_ACT_KMS_CARD where ID ='" + names.get(i) + "'";
|
||||
String card_name = DBSql.getString(open, card_sql_name);
|
||||
if (StringUtils.isNotEmpty(card)) {
|
||||
creadteFile(userContext, open, bo.getString("PLNAME"), add_name);
|
||||
|
||||
} else {
|
||||
|
||||
// aslp服务地址
|
||||
String aslps_create = "aslp://com.actionsoft.apps.kms/CreateKnwl";
|
||||
// 参数定义列表
|
||||
Map params_create = new HashMap<String, Object>();
|
||||
//保密级别, 0: 普通 1:秘密 2:机密,必填
|
||||
params_create.put("securityLevel", 0);
|
||||
//知识名称,必填
|
||||
params_create.put("knwlName", card_name);
|
||||
//是否可以评论,必填
|
||||
params_create.put("isComment", true);
|
||||
//是否可以评分,必填
|
||||
params_create.put("isRate", true);
|
||||
//有效期:yyyy-MM-dd,非必填
|
||||
params_create.put("validDate", "2099-12-31");
|
||||
//只读控制,1:在线阅读和下载 0:在线阅读,必填
|
||||
params_create.put("onlineLevel", 1);
|
||||
//知识创建人,某些特殊场景下,sid和createUser代表的用户并不一样,如果此参数为null,则使用sid代表的用户,非必填
|
||||
params_create.put("createUser", "admin");
|
||||
//知识内容,非必填
|
||||
params_create.put("cardContext", "");
|
||||
//sid,必填
|
||||
params_create.put("sid", userContext.getSessionId());
|
||||
AppAPI appAPI_create = SDK.getAppAPI();
|
||||
//创建知识
|
||||
ResponseObject ro_create = appAPI_create.callASLP(appAPI_create.getAppContext(APPID), aslps_create, params_create);
|
||||
System.out.println("ro_create================" + ro_create);
|
||||
creadteFile(userContext, open, names.get(i).toString(), add_name);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
if (StringUtils.isNotEmpty(dimensionId)) {
|
||||
// 调用App
|
||||
String sourceAppId = APPID;
|
||||
// aslp服务地址
|
||||
String aslps_de = "aslp://com.actionsoft.apps.kms/createDimension";
|
||||
// 参数定义列表
|
||||
Map paramss = new HashMap<String, Object>();
|
||||
//发布是否需要审批,默认false,必填
|
||||
paramss.put("isExamine", false);
|
||||
//是否启用,默认启用,必填
|
||||
paramss.put("isEnabled", true);
|
||||
//维度类型,1:允许发布知识 2:不允许发布知识,必填
|
||||
paramss.put("showType", 1);
|
||||
//维度描述,非必填
|
||||
paramss.put("memo", "");
|
||||
//创建人,非必填
|
||||
paramss.put("createUser", "admin");
|
||||
|
||||
String sql_fa = " select PLNAME from APP_ACT_COE_PAL_REPOSITORY " +
|
||||
"where PLCATEGORY = 'process'and PLMETHODID ='process.framework' " +
|
||||
"and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" +
|
||||
",'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" +
|
||||
" and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," +
|
||||
"'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," +
|
||||
"'36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," +
|
||||
"'98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," +
|
||||
"'79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," +
|
||||
"'42c09260-c1d3-44b7-ac3d-f8280e04c294')"+" and EXT4 = '" + names.get(i) + "'";
|
||||
String plname = DBSql.getString(open, sql_fa);
|
||||
//维度名称,必填
|
||||
paramss.put("dimensionName", plname);
|
||||
|
||||
String dimensionId_sql_i = "SELECT ID FROM APP_ACT_KMS_DIMENSION where ID ='" + names.get(i + 1) + "'";
|
||||
de_name = DBSql.getString(open, dimensionId_sql_i);
|
||||
//父维度Id:""表示根维度,必填
|
||||
paramss.put("parentId", de_name);
|
||||
//sid,必填
|
||||
paramss.put("sid", userContext.getSessionId());
|
||||
AppAPI appAPIs = SDK.getAppAPI();
|
||||
//创建维度
|
||||
ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslps_de, paramss);
|
||||
|
||||
System.out.println("ros==================" + ros);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("定时器执行完毕");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
open.close();
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void creadteFile(UserContext userContext, Connection open, String name, String add_name) {
|
||||
/**
|
||||
* 这个主要是负责对流程手册进行相关的文件的生成
|
||||
*/
|
||||
String sourceAppId = APPID;
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.kms/CreateFile";
|
||||
|
||||
String sql = "SELECT CARDNAME FROM APP_ACT_KMS_CARD WHERE ID = '" + name + "'";
|
||||
String id = DBSql.getString(open, sql);
|
||||
if (StringUtils.isNotEmpty(id)) {
|
||||
BO bos = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("PUBLISHFILENAME = ", name).detail();
|
||||
if (bos != null) {
|
||||
|
||||
|
||||
if (StringUtils.isNotEmpty(bos.getString("TASKID"))) {
|
||||
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(bos.getString("TASKID"));
|
||||
if (model != null) {
|
||||
System.out.println(",pdel============" + model);
|
||||
System.out.println("123313123123123==========" + model.getProfileId());
|
||||
OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId());
|
||||
System.out.println("dajadfas======" + appProfile);
|
||||
if (appProfile == null) {
|
||||
throw new AWSException("Not Find OutputAppProfile! profileId=" + model.getProfileId());
|
||||
}
|
||||
DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT);
|
||||
if (dcProfile == null)
|
||||
throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT);
|
||||
String sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME = '" + bos.getString("PUBLISHFILENAME") + "'";
|
||||
String lever = DBSql.getString(open, sql_lever);
|
||||
//lever = lever.substring(0,3);
|
||||
DCContext dcContext = new DCContext(userContext, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), bos.getString("TASKID"), bos.getString("PUBLISHFILENAME") + "_" + lever + ".doc");
|
||||
//UtilFile file = new UtilFile(dcContext.getPath());
|
||||
|
||||
|
||||
Map params = new HashMap<String, Object>();
|
||||
//知识ID,必填
|
||||
params.put("cardId", id);
|
||||
//sid,必填
|
||||
params.put("sid", userContext.getSessionId());
|
||||
|
||||
params.put("dc", dcContext);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//创建文件
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
System.out.println("流程手册的存入=================" + ro);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
String sql_A = "SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where PLNAME = '" + name + "' AND PLMETHODID != 'process.framework' AND PLMETHODID IN (select distinct PLMETHODID from APP_ACT_COE_PAL_REPOSITORY)";
|
||||
List<RowMap> rows = DBSql.getMaps(open, sql_A);
|
||||
|
||||
for (RowMap bo : rows
|
||||
) {
|
||||
|
||||
/**
|
||||
* 这个是模型中的附件获取的并插入的数据信息,需要做修改
|
||||
*/
|
||||
// 调用App
|
||||
|
||||
// 参数定义列表
|
||||
Map paramss = new HashMap<String, Object>();
|
||||
//知识ID,必填
|
||||
paramss.put("cardId", id);
|
||||
//sid,必填
|
||||
paramss.put("sid", userContext.getSessionId());
|
||||
|
||||
UpfileWeb upfileWeb = new UpfileWeb(userContext);
|
||||
|
||||
|
||||
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where PLMETHODID != 'process.framework' AND PLNAME= '" + bo.getString("PLNAME") + "'" +
|
||||
")";
|
||||
List<RowMap> maps = DBSql.getMaps(open, sql_upfile);
|
||||
for (RowMap row : maps) {
|
||||
UpfileModel upfileModel = new UpfileModel();
|
||||
upfileModel.setType(row.getString("FILETYPE"));
|
||||
upfileModel.setFileName(row.getString("FILENAME"));
|
||||
upfileModel.setPl_uuid(row.getString("PALREPOSITORYID"));
|
||||
upfileModel.setShape_uuid(row.getString("SHAPEID"));
|
||||
DCContext dcContexts = upfileWeb.getDCContext(upfileModel);
|
||||
paramss.put("dc", dcContexts);
|
||||
AppAPI appAPIs = SDK.getAppAPI();
|
||||
ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, paramss);
|
||||
System.out.println("流程模型附件的生成=============" + ros);
|
||||
}
|
||||
|
||||
//DCContext对象,必填
|
||||
|
||||
//创建文件
|
||||
}
|
||||
PublishKnow(userContext, open, add_name, id);
|
||||
}
|
||||
}
|
||||
|
||||
public void PublishKnow(UserContext userContext, Connection open, String add_name, String id) {
|
||||
System.out.println("add_name=================" + add_name);
|
||||
/*String result = add_name.substring(0, add_name.length() - 1);
|
||||
String[] deptSplit = result.split(",");
|
||||
|
||||
if (deptSplit.length == 1) {
|
||||
result = "'" + deptSplit[0] + "'";
|
||||
}
|
||||
result = "'" + StringUtils.join(deptSplit, "','") + "'";
|
||||
System.out.println(">>>>>NO =" + result);
|
||||
|
||||
String sql = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME IN (" + result + ") ";
|
||||
List<RowMap> maps = DBSql.getMaps(open, sql);
|
||||
if (maps.size() == 0) {
|
||||
String sql_DIMENSIONNAME = "SELECT PLPARENTID FROM APP_ACT_COE_PAL_REPOSITORY where PLCATEGORY = 'process' and PLNAME IN (" + result + ") ";
|
||||
String maps_first = DBSql.getString(open, sql_DIMENSIONNAME);
|
||||
|
||||
if (maps_first.equals("itsystem")) {
|
||||
String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='IT系统' ";
|
||||
maps = DBSql.getMaps(open, sql_id);
|
||||
} else if (maps_first.equals("control")) {
|
||||
String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='控制' ";
|
||||
maps = DBSql.getMaps(open, sql_id);
|
||||
} else if (maps_first.equals("process")) {
|
||||
String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='流程制度' ";
|
||||
maps = DBSql.getMaps(open, sql_id);
|
||||
} else if (maps_first.equals("org")) {
|
||||
String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='组织' ";
|
||||
maps = DBSql.getMaps(open, sql_id);
|
||||
} else if (maps_first.equals("data")) {
|
||||
String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME ='数据' ";
|
||||
maps = DBSql.getMaps(open, sql_id);
|
||||
} else {
|
||||
String sql_id = "SELECT ID FROM APP_ACT_KMS_DIMENSION where DIMENSIONNAME =(SELECT PLNAME FROM APP_ACT_COE_PAL_REPOSITORY where ID ='" + maps_first + "')";
|
||||
maps = DBSql.getMaps(open, sql_id);
|
||||
}
|
||||
}
|
||||
String ids = "";
|
||||
if (maps.size() != 0) {
|
||||
|
||||
for (RowMap rowmap : maps
|
||||
) {
|
||||
ids += rowmap.getString("ID") + ",";
|
||||
}
|
||||
ids = ids.substring(0, ids.length() - 1);
|
||||
|
||||
} else {
|
||||
for (RowMap rowmap : maps
|
||||
) {
|
||||
ids += rowmap.getString("ID") + ",";
|
||||
}
|
||||
ids = ids.substring(0, ids.length() - 1);
|
||||
}*/
|
||||
|
||||
String[] deptSplit_id = add_name.split(",");
|
||||
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (String id_names : deptSplit_id
|
||||
) {
|
||||
jsonArray.add(id_names);
|
||||
}
|
||||
//jsonObject.put(deptSplit_id);
|
||||
id += ",";
|
||||
String[] deptSplit_das = id.split(",");
|
||||
JSONArray jsonArray_das = new JSONArray();
|
||||
for (String das : deptSplit_das
|
||||
) {
|
||||
jsonArray_das.add(das);
|
||||
}
|
||||
//jsonObject.put(deptSplit_id);
|
||||
|
||||
|
||||
// 调用App
|
||||
String sourceAppId = APPID;
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.kms/PublishKnwl";
|
||||
// 参数定义列表
|
||||
Map params = new HashMap<String, Object>();
|
||||
//要发布到的维度ID的JSON数组字符串,必填
|
||||
params.put("dimensionIDArray", jsonArray.toString());
|
||||
//要发布的知识ID的JSON数组字符串,必填
|
||||
params.put("knwlIDArray", jsonArray_das.toString());
|
||||
//标签的JSON数组字符串,非必填
|
||||
|
||||
//sid,必填
|
||||
params.put("sid", userContext.getSessionId());
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//发布知识
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
|
||||
System.out.println("知识发布============" + ro);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,80 @@
|
||||
package com.awspaas.user.apps.integration.job;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb;
|
||||
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.server.fs.DCContext;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.exception.AWSException;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.AppAPI;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @PackageName: com.awspaas.user.apps.yili.integration.job
|
||||
* @ClassName: UpdatePalRepositoryExt4
|
||||
* @author: wangcy
|
||||
* @date: 2022/8/10 13:42
|
||||
*/
|
||||
public class UpdatePalRepositoryExt4 implements Job {
|
||||
|
||||
private static String APPID = "com.awspaas.user.apps.yili.integration";
|
||||
|
||||
|
||||
private static String USERID = "admin";
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
String sql ="select ID,DIMENSIONNAME from APP_ACT_KMS_DIMENSION where DIMENSIONNAME " +
|
||||
" in (select PLNAME from APP_ACT_COE_PAL_REPOSITORY where " +
|
||||
"PLMETHODID = 'process.framework'and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试','8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试'))";
|
||||
List<RowMap> rowMapList = DBSql.getMaps(sql);
|
||||
for (RowMap rowmap:rowMapList
|
||||
) {
|
||||
String dimensionname = rowmap.getString("DIMENSIONNAME");
|
||||
String Id = rowmap.getString("ID");
|
||||
String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 ="+Id+" WHERE PLMETHODID = 'process.framework'and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试','8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') AND PLNAME = '"+dimensionname+"'";
|
||||
int update = DBSql.update(update_sql);
|
||||
System.out.println(dimensionname+">>>>>>>>>>>>>>>>"+update);
|
||||
}
|
||||
|
||||
String know_sql = "select ID,cardname from APP_ACT_KMS_CARD where cardname in (select PLNAME from APP_ACT_COE_PAL_REPOSITORY " +
|
||||
" where PLCATEGORY = 'process'and PLMETHODID !='process.framework' " +
|
||||
" and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" +
|
||||
" ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" +
|
||||
" and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," +
|
||||
" 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," +
|
||||
" '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," +
|
||||
" '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," +
|
||||
" '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," +
|
||||
" '42c09260-c1d3-44b7-ac3d-f8280e04c294'))";
|
||||
List<RowMap> rowMapList_know = DBSql.getMaps(know_sql);
|
||||
for (RowMap rowmap:rowMapList_know
|
||||
) {
|
||||
String dimensionname = rowmap.getString("cardname");
|
||||
String Id = rowmap.getString("ID");
|
||||
String update_sql = "UPDATE APP_ACT_COE_PAL_REPOSITORY SET EXT4 ="+Id+" WHERE PLMETHODID != 'process.framework'and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试','8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试') AND PLNAME = '"+dimensionname+"'";
|
||||
int update = DBSql.update(update_sql);
|
||||
System.out.println(dimensionname+">>>>APP_ACT_KMS_CARD"+">>>>>>>>>>>>>>>>"+update);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.awspaas.user.apps.integration.job;
|
||||
|
||||
import com.actionsoft.bpms.schedule.IJob;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
public class createBoJob implements IJob {
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
DBSql.update("update APP_ACT_COE_PAL_REPOSITORY set EXT4 = '' where ID in ('4e84f39c-0487-4014-9917-d02649ae145f')");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.awspaas.user.apps.integration.job;
|
||||
|
||||
import com.actionsoft.bpms.schedule.IJob;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
/**
|
||||
* 清空表数据,知识发布的相关知识
|
||||
*/
|
||||
public class deleteKnowJob implements IJob {
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
//APP_ACT_KMS_CARD
|
||||
// APP_ACT_KMS_PUBLISH
|
||||
//APP_ACT_KMS_DIMENSION
|
||||
//APP_ACT_KMS_FILE
|
||||
String sql_delete = "delete from APP_ACT_KMS_CARD";
|
||||
DBSql.update(sql_delete);
|
||||
String sql_da = "delete from APP_ACT_KMS_PUBLISH";
|
||||
DBSql.update(sql_da);
|
||||
String sql_das = "delete from APP_ACT_KMS_DIMENSION where DIMENSIONNAME !='流程制度' ";
|
||||
DBSql.update(sql_das);
|
||||
String sql_dass = "delete from APP_ACT_KMS_FILE";
|
||||
DBSql.update(sql_dass);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.awspaas.user.apps.integration.job;
|
||||
|
||||
import com.actionsoft.bpms.schedule.IJob;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
public class deleteTestBO implements IJob {
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
DBSql.update(
|
||||
"drop table T561486"
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.awspaas.user.apps.integration.job;
|
||||
|
||||
import com.actionsoft.bpms.schedule.IJob;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
public class updateKnowByExt4Empty implements IJob {
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
String sql = "update APP_ACT_COE_PAL_REPOSITORY set EXT4 = '' where ID in (select ID from APP_ACT_COE_PAL_REPOSITORY" +
|
||||
" where PLCATEGORY = 'process'and PLMETHODID !='process.framework'" +
|
||||
" and PLNAME not in ('流程架构图','测试用','GMY-截图用','sx批量测试'" +
|
||||
" ,'8.2培训使用','用户练习使用','YX测试分部','yx测试人员','yx测试部','流程架构测试')" +
|
||||
" and PLPARENTID not in ('63ff93c6-2f27-4851-a396-6830c428db2e'," +
|
||||
" 'c84f497a-4de3-4404-86e8-cd5af71c3b47','94dabf55-b032-4316-a4c3-00b83763da09'," +
|
||||
" '36ac7cdd-a361-4bd3-9511-c03c1b3627a4','84e534b4-e51a-4874-9ff1-8a0206d9e0c5'," +
|
||||
" '98bd5917-7563-4b29-b775-815e91d9864c','f07da63c-3423-4c1e-ae75-b323c6a69093'," +
|
||||
" '79cb4c35-d2f7-4c43-a7db-44038b557eac','7ad79a73-a497-417a-a5ec-d4c9fd45061c'," +
|
||||
" '42c09260-c1d3-44b7-ac3d-f8280e04c294'))";
|
||||
int update = DBSql.update(sql);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
package com.awspaas.user.apps.integration.oa;
|
||||
import com.awspaas.user.apps.integration.util.HttpClientUtil;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance;
|
||||
import com.actionsoft.bpms.util.ThreadMgr;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* @author LiHongYu
|
||||
*/
|
||||
public class OaDeleteComponent {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(OaDeleteComponent.class);
|
||||
private String uri = SDK.getAppAPI().getProperty("com.hy.apps.integrated", "uri");
|
||||
private String userName = SDK.getAppAPI().getProperty("com.hy.apps.integrated", "restUserName");
|
||||
private String password = SDK.getAppAPI().getProperty("com.hy.apps.integrated", "restUserPwd");
|
||||
|
||||
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.content = content;
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||||
String params = JSONObject.toJSONString(content);
|
||||
try {
|
||||
//httpClientUtil.setPostRequestBody(params,"application/json","UTF-8");
|
||||
int httpStatus = 1;
|
||||
//String result = httpClientUtil.getResponseBodyAsString("utf-8");
|
||||
|
||||
|
||||
if (httpStatus != HttpStatus.SC_OK){
|
||||
OaPendComponentLose opl = new OaPendComponentLose();
|
||||
TaskInstance instanceById = SDK.getTaskAPI().getInstanceById(taskId);
|
||||
if(instanceById!=null) {
|
||||
opl.careateProcess(type,taskId,instanceById.getTarget());
|
||||
}else {
|
||||
opl.careateProcess(type,taskId,"");
|
||||
}
|
||||
//logger.info("调用删除推送接口====>type:" + type + "taskId: " + taskId + ",url:" + url + ",失败!","已发起手动推送待办流程!");
|
||||
}else{
|
||||
//logger.info("调用OA删除任务接口====>type:"+type+",taskId:"+taskId+",url:"+url+",返回结果:");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//logger.info("调用OA删除任务接口====>type:"+type+"taskId:"+taskId+",url:"+url+",失败!网络异常!",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 删除任务
|
||||
* @param taskInstanceId DD
|
||||
*/
|
||||
public void deleteOaPending(String taskInstanceId){
|
||||
String token = "";
|
||||
OaPending pend = new OaPending();
|
||||
pend.setTaskId(taskInstanceId);
|
||||
pend.setRegisterCode("3011");
|
||||
pend.setClassify("BPM");
|
||||
pend.setToken(token);
|
||||
ThreadMgr.execute(new PostPendTask(taskInstanceId,3,uri + "/seeyon/rest/thirdPartyCommitted/deleteCommitted?token=" + token,pend));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,167 @@
|
||||
package com.awspaas.user.apps.integration.oa;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by kkdo FanGaowei (justfgwlzx@163.com).
|
||||
* Description:
|
||||
* <pre>
|
||||
* thirdpartyMessageId 第三方消息主键(保证唯一) 必填
|
||||
* thirdpartyRegisterCode 为第三方配置的系统注册编码 必填
|
||||
* messageContent 消息内容 必填
|
||||
* thirdpartySenderId 第三方消息发起人主键(保证唯一) 非必填
|
||||
* thirdpartyReceiverId 第三方消息接收人主键(保证唯一) 必填
|
||||
* creation_date 消息创建时间(格式:yyyy-MM-dd HH:mm:ss) 必填
|
||||
* messageType 0:PC;1:移动URL接入应用;2:本地H5应用;3:本地原生应用;4:PC&移动URL接入应用;5:PC&本地H5应用;6:PC&本地原生应用 必填
|
||||
* downloadUrl 原生应用下载地址(仅3和6类型可选) 非必填
|
||||
* messageURL PC端穿透链接 非必填
|
||||
* messageH5URL 移动端穿透链接 非必填
|
||||
* appParam 原生应用穿透命令,穿透命令需要按这个顺序:iphone|ipad|android|wp 非必填</pre>
|
||||
* 2017年10月9日 下午8:21:39
|
||||
*/
|
||||
|
||||
public class OaMessage {
|
||||
private String thirdpartyMessageId;
|
||||
private String thirdpartyRegisterCode;
|
||||
private String messageContent;
|
||||
private String thirdpartySenderId;
|
||||
private String thirdpartyReceiverId;
|
||||
private String thirdpartySenderName;
|
||||
private String thirdpartyReceiverName;
|
||||
private Date creationDate;
|
||||
private int messageType;
|
||||
private String downloadUrl;
|
||||
private String messageURL;
|
||||
private String messageH5URL;
|
||||
private String appParam;
|
||||
private String noneBindingSender;
|
||||
private String noneBindingReceiver;
|
||||
|
||||
public OaMessage() {}
|
||||
|
||||
public String getNoneBindingSender() {
|
||||
return noneBindingSender;
|
||||
}
|
||||
|
||||
public void setNoneBindingSender(String noneBindingSender) {
|
||||
this.noneBindingSender = noneBindingSender;
|
||||
}
|
||||
|
||||
public String getNoneBindingReceiver() {
|
||||
return noneBindingReceiver;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setNoneBindingReceiver(String noneBindingReceiver) {
|
||||
this.noneBindingReceiver = noneBindingReceiver;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getThirdpartySenderName() {
|
||||
return thirdpartySenderName;
|
||||
}
|
||||
|
||||
public void setThirdpartySenderName(String thirdpartySenderName) {
|
||||
this.thirdpartySenderName = thirdpartySenderName;
|
||||
}
|
||||
|
||||
public String getThirdpartyReceiverName() {
|
||||
return thirdpartyReceiverName;
|
||||
}
|
||||
|
||||
public void setThirdpartyReceiverName(String thirdpartyReceiverName) {
|
||||
this.thirdpartyReceiverName = thirdpartyReceiverName;
|
||||
}
|
||||
|
||||
public String getThirdpartyMessageId() {
|
||||
return thirdpartyMessageId;
|
||||
}
|
||||
|
||||
public void setThirdpartyMessageId(String thirdpartyMessageId) {
|
||||
this.thirdpartyMessageId = thirdpartyMessageId;
|
||||
}
|
||||
|
||||
public String getThirdpartyRegisterCode() {
|
||||
return thirdpartyRegisterCode;
|
||||
}
|
||||
|
||||
public void setThirdpartyRegisterCode(String thirdpartyRegisterCode) {
|
||||
this.thirdpartyRegisterCode = thirdpartyRegisterCode;
|
||||
}
|
||||
|
||||
public String getMessageContent() {
|
||||
return messageContent;
|
||||
}
|
||||
|
||||
public void setMessageContent(String messageContent) {
|
||||
this.messageContent = messageContent;
|
||||
}
|
||||
|
||||
public String getThirdpartySenderId() {
|
||||
return thirdpartySenderId;
|
||||
}
|
||||
|
||||
public void setThirdpartySenderId(String thirdpartySenderId) {
|
||||
this.thirdpartySenderId = thirdpartySenderId;
|
||||
}
|
||||
|
||||
public String getThirdpartyReceiverId() {
|
||||
return thirdpartyReceiverId;
|
||||
}
|
||||
|
||||
public void setThirdpartyReceiverId(String thirdpartyReceiverId) {
|
||||
this.thirdpartyReceiverId = thirdpartyReceiverId;
|
||||
}
|
||||
|
||||
public Date getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
|
||||
public void setCreationDate(Date creationDate) {
|
||||
this.creationDate = creationDate;
|
||||
}
|
||||
|
||||
public int getMessageType() {
|
||||
return messageType;
|
||||
}
|
||||
|
||||
public void setMessageType(int messageType) {
|
||||
this.messageType = messageType;
|
||||
}
|
||||
|
||||
public String getDownloadUrl() {
|
||||
return downloadUrl;
|
||||
}
|
||||
|
||||
public void setDownloadUrl(String downloadUrl) {
|
||||
this.downloadUrl = downloadUrl;
|
||||
}
|
||||
|
||||
public String getMessageURL() {
|
||||
return messageURL;
|
||||
}
|
||||
|
||||
public void setMessageURL(String messageURL) {
|
||||
this.messageURL = messageURL;
|
||||
}
|
||||
|
||||
public String getMessageH5URL() {
|
||||
return messageH5URL;
|
||||
}
|
||||
|
||||
public void setMessageH5URL(String messageH5URL) {
|
||||
this.messageH5URL = messageH5URL;
|
||||
}
|
||||
|
||||
public String getAppParam() {
|
||||
return appParam;
|
||||
}
|
||||
|
||||
public void setAppParam(String appParam) {
|
||||
this.appParam = appParam;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,427 @@
|
||||
package com.awspaas.user.apps.integration.oa;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.bpmn.engine.ProcessAPIManager;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.TaskCommentModel;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
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.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.HttpClientUtil;
|
||||
|
||||
/**
|
||||
* @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() {
|
||||
HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||||
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 {
|
||||
|
||||
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 (bo_act_coe_publish!=null){
|
||||
xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+bo_act_coe_publish.getString("PROCESS_TITLE")+"】,点击进行处理");
|
||||
}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());
|
||||
xmlDatasUtil.setMobileurl(portalUrl+"/r/or?cmd=com.yili_form_page_open&oauthName=WechatOauthLogin&casaccount="+pec.getTaskInstance().getTarget()+"&processInstId="+pec.getProcessInstance().getId()+"&taskInstId="+taskInstance.getId());
|
||||
String target = taskInstance.getTarget();
|
||||
if (target.length()==8&&"00".equals(target.substring(0,2))){
|
||||
target = target.substring(2);
|
||||
}
|
||||
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(),pec.getTaskInstance().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("");
|
||||
|
||||
|
||||
|
||||
HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||||
String s = httpClientUtil.SendPend("http://10.105.1.59/services/yili", xmlDatasUtil);
|
||||
System.out.println("状态码============》》》》》》》》》》》"+s);
|
||||
if (s.equals("Success")){
|
||||
logger.info("发送待办任务完成,请去OA系统上查看是否传输完成");
|
||||
}else if (s.equals("fail")){
|
||||
logger.error("发送待办任务失败,请联系管理员查看是否出现错误");
|
||||
}
|
||||
// pend.setTitle(taskInstance.getTitle());
|
||||
UserModel targetUserModel = UserCache.getModel(taskInstance.getTarget());
|
||||
// if (null == targetUserModel || StringUtils.isBlank(targetUserModel.getExt5())) {
|
||||
// String msg = "账号对应的OA账号为空!待办不能推送,请补充完善账号信息!BPM账号:" + taskInstance.getTarget();
|
||||
// logger.error(msg);
|
||||
//
|
||||
// // 给 admin 推消息
|
||||
// notificationAPI.sendSystemMessage("admin", msg, "error");
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构造待办打开链接
|
||||
*
|
||||
* @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 {
|
||||
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 (bo_act_coe_publish!=null){
|
||||
xmlDatasUtil.setProcess_title(" 您有一条待办流程【"+bo_act_coe_publish.getString("PROCESS_TITLE")+"】,点击进行处理");
|
||||
}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("https://bpm.yili.com:8088/portal"+"/r/or?cmd=com.yili_form_page_open&oauthName=oauthLogin&processInstId="+pec.getProcessInstance().getId()+"&taskInstId="+taskInstance.getId());
|
||||
xmlDatasUtil.setMobileurl("https://bpm.yili.com:8088/portal"+"/r/or?cmd=com.yili_form_page_open&oauthName=WechatOauthLogin&casaccount="+pec.getTaskInstance().getTarget()+"&processInstId="+pec.getProcessInstance().getId()+"&taskInstId="+taskInstance.getId());
|
||||
|
||||
String target = taskInstance.getTarget();
|
||||
if (target.length()==8&&"00".equals(target.substring(0,2))){
|
||||
target = target.substring(2);
|
||||
}
|
||||
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(df.format(taskInstance.getBeginTime()).substring(df.format(taskInstance.getBeginTime()).indexOf(" "), df.format(taskInstance.getBeginTime()).length()));
|
||||
|
||||
xmlDatasUtil.setTo_do_status("1");
|
||||
|
||||
xmlDatasUtil.setTo_do_official_type("0");
|
||||
|
||||
xmlDatasUtil.setViewtype("-2");
|
||||
|
||||
xmlDatasUtil.setCreatedate(str.substring(0, str.indexOf(" ")));
|
||||
xmlDatasUtil.setDonedate(df.format(taskInstance.getBeginTime()).substring(0, df.format(taskInstance.getBeginTime()).indexOf(" ")));
|
||||
String der = df.format(taskInstance.getReadTime());
|
||||
xmlDatasUtil.setReceivedate(der.substring(0, der.indexOf(" ")));
|
||||
xmlDatasUtil.setReceivetime(der.substring(der.indexOf(" "),der.length()));
|
||||
String actionName = getActionName(taskInstance);
|
||||
if (actionName.equals("确认发布")||equalsAction(GO_BACK, actionName)){
|
||||
xmlDatasUtil.setCurrentnodetype("1");
|
||||
}else{
|
||||
xmlDatasUtil.setCurrentnodetype("0");
|
||||
}
|
||||
|
||||
xmlDatasUtil.setRequestcode(pec.getProcessInstance().getId());
|
||||
xmlDatasUtil.setCurrentnodename(SDK.getRepositoryAPI().getProcessNode(pec.getProcessInstance().getProcessDefId(),pec.getTaskInstance().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()){
|
||||
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);
|
||||
xmlDatasUtil.setWorkcode("");
|
||||
xmlDatasUtil.setWorkflowname(pec.getProcessDef().getName());
|
||||
if (bo_eu_oa_reson!=null){
|
||||
xmlDatasUtil.setCreaterhrcode(bo_eu_oa_reson.getString("LOGINID"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
xmlDatasUtil.setCreaterworkcode("");
|
||||
HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||||
String s = httpClientUtil.SendPend("http://10.105.1.59/services/yili", xmlDatasUtil);
|
||||
if (s.equals("Success")){
|
||||
logger.info("发送已办任务更新完成,请去OA系统上查看是否传输完成");
|
||||
}else if (s.equals("fail")){
|
||||
logger.error("发送已办任务更新失败,请联系管理员查看是否出现错误");
|
||||
}
|
||||
System.out.println("已办查看是否修改");
|
||||
UserModel targetUserModel = UserCache.getModel(taskInstance.getTarget());
|
||||
// if (null == targetUserModel || StringUtils.isBlank(targetUserModel.getExt5())) {
|
||||
// String msg = "账号对应的OA账号为空!待办不能推送,请补充完善账号信息!BPM账号:" + taskInstance.getTarget();
|
||||
// logger.error(msg);
|
||||
//
|
||||
// // 给 admin 推消息
|
||||
// notificationAPI.sendSystemMessage("admin", msg, "error");
|
||||
// return;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private String getActionName(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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package com.awspaas.user.apps.integration.oa;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
|
||||
/**
|
||||
* 待办推送/更新失败发起手动推送流程
|
||||
*/
|
||||
public class OaPendComponentLose {
|
||||
|
||||
public int careateProcess(int type,String taskId,String target) {
|
||||
String ty = "";
|
||||
if(type==0) {
|
||||
ty="推送";
|
||||
}else if(type==2) {
|
||||
ty="更新";
|
||||
}else if(type==3) {
|
||||
ty="删除";
|
||||
}
|
||||
|
||||
Date date = new Date(System.currentTimeMillis());
|
||||
String userName = SDK.getORGAPI().getUser(target).getUserName();
|
||||
SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
ProcessInstance processInst = SDK.getProcessAPI().createProcessInstance("obj_a1fb5f704992495982da2a876e5e1146","admin",formatter.format(date)+"收到来自【"+userName+"】的手动待办"+ty+"任务");
|
||||
SDK.getProcessAPI().start(processInst).fetchActiveTasks().get(0);
|
||||
BO bo = new BO();
|
||||
bo.set("TASKID", taskId);
|
||||
bo.set("TAR", SDK.getORGAPI().getUser(target).getUserName());
|
||||
bo.set("TYPE",ty);
|
||||
bo.set("TASKTITLE",SDK.getTaskAPI().getInstanceById(taskId).getTitle());
|
||||
int create = SDK.getBOAPI().create("BO_HY_SYNC_LOSE", bo, processInst, UserContext.fromUID("admin"));
|
||||
return create ;
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,233 @@
|
||||
package com.awspaas.user.apps.integration.oa;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public class OaPending {
|
||||
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 第三方待办标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 调用类型
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 第三方待发已发已办发送人姓名
|
||||
*/
|
||||
|
||||
private String sendName;
|
||||
/**
|
||||
* 第三方待办发送人姓名
|
||||
*/
|
||||
private String senderName;
|
||||
|
||||
/**
|
||||
* 第三方待办发送人ID,在OA中不重要,显示发送人姓名即可,不需要转化
|
||||
*/
|
||||
private String thirdSenderId;
|
||||
/**
|
||||
* 第三方待办接收人员ID,需要对于人员绑定表中的ID,在OA中非常重要,可以保存下此ID,并做转化
|
||||
*/
|
||||
private String thirdReceiverId;
|
||||
/**
|
||||
* 正文类型:非必填项
|
||||
*/
|
||||
private String contentType;
|
||||
/**
|
||||
* 正文内容:非必填项
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 待办PC端连接地址
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 待办移动端H5连接地址
|
||||
*/
|
||||
private String h5Url;
|
||||
/**
|
||||
* 移动端app打开参数
|
||||
*/
|
||||
private String appParam;
|
||||
/**
|
||||
* 第三方待办ID
|
||||
*/
|
||||
private String taskId;
|
||||
/**
|
||||
* 业务类型,非必填
|
||||
*/
|
||||
private String classify;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
protected String creationDate;
|
||||
/**
|
||||
* 状态:0:未办理;1:已办理
|
||||
*/
|
||||
private String state;
|
||||
/**
|
||||
* 子状态:0/1/2/3同意已办/不同意已办/取消/驳回
|
||||
*/
|
||||
private String subState;
|
||||
/**
|
||||
* 注册应用ID
|
||||
*/
|
||||
private Long registerId;
|
||||
|
||||
private String noneBindingSender;
|
||||
|
||||
private String noneBindingReceiver;
|
||||
|
||||
/**
|
||||
* 注册系统编码
|
||||
*/
|
||||
private String registerCode;
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
public String getSendName() {
|
||||
return sendName;
|
||||
}
|
||||
|
||||
public void setSendName(String sendName) {
|
||||
this.sendName = sendName;
|
||||
}
|
||||
|
||||
public Long getRegisterId() {
|
||||
return registerId;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getNoneBindingSender() {
|
||||
return noneBindingSender;
|
||||
}
|
||||
|
||||
|
||||
public void setNoneBindingSender(String noneBindingSender) {
|
||||
this.noneBindingSender = noneBindingSender;
|
||||
}
|
||||
|
||||
|
||||
public String getNoneBindingReceiver() {
|
||||
return noneBindingReceiver;
|
||||
}
|
||||
|
||||
|
||||
public void setNoneBindingReceiver(String noneBindingReceiver) {
|
||||
this.noneBindingReceiver = noneBindingReceiver;
|
||||
}
|
||||
|
||||
public void setRegisterId(Long registerId) {
|
||||
this.registerId = registerId;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getSenderName() {
|
||||
return senderName;
|
||||
}
|
||||
public void setSenderName(String senderName) {
|
||||
this.senderName = senderName;
|
||||
}
|
||||
public String getThirdSenderId() {
|
||||
return thirdSenderId;
|
||||
}
|
||||
public void setThirdSenderId(String thirdSenderId) {
|
||||
this.thirdSenderId = thirdSenderId;
|
||||
}
|
||||
public String getThirdReceiverId() {
|
||||
return thirdReceiverId;
|
||||
}
|
||||
public void setThirdReceiverId(String thirdReceiverId) {
|
||||
this.thirdReceiverId = thirdReceiverId;
|
||||
}
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
public String getH5Url() {
|
||||
return h5Url;
|
||||
}
|
||||
public void setH5Url(String h5Url) {
|
||||
this.h5Url = h5Url;
|
||||
}
|
||||
public String getAppParam() {
|
||||
return appParam;
|
||||
}
|
||||
public void setAppParam(String appParam) {
|
||||
this.appParam = appParam;
|
||||
}
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
public void setTaskId(String taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
public String getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
public void setCreationDate(String creationDate) {
|
||||
this.creationDate = creationDate;
|
||||
}
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
public String getSubState() {
|
||||
return subState;
|
||||
}
|
||||
public void setSubState(String subState) {
|
||||
this.subState = subState;
|
||||
}
|
||||
|
||||
public String getRegisterCode() {
|
||||
return registerCode;
|
||||
}
|
||||
public void setRegisterCode(String registerCode) {
|
||||
this.registerCode = registerCode;
|
||||
}
|
||||
public String getClassify() {
|
||||
return classify;
|
||||
}
|
||||
public void setClassify(String classify) {
|
||||
this.classify = classify;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,302 @@
|
||||
|
||||
package com.awspaas.user.apps.integration.oa;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.awspaas.user.apps.integration.util.HttpClientUtil;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.def.ProcessDefinition;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
|
||||
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.bpms.util.ThreadMgr;
|
||||
import com.actionsoft.exception.BPMNError;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.NotificationAPI;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
|
||||
/**
|
||||
* @author DengPeng 待发
|
||||
*/
|
||||
public class OaReadyComponent {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(OaReadyComponent.class);
|
||||
|
||||
private NotificationAPI notificationAPI = SDK.getNotificationAPI();
|
||||
|
||||
private String uri = SDK.getAppAPI().getProperty("com.hy.apps.integrated", "uri");
|
||||
private String userName = SDK.getAppAPI().getProperty("com.hy.apps.integrated", "restUserName");
|
||||
private String password = SDK.getAppAPI().getProperty("com.hy.apps.integrated", "restUserPwd");
|
||||
|
||||
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() {
|
||||
HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
|
||||
map.put("createTime",new Timestamp(new Date().getTime()));
|
||||
System.out.println(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){
|
||||
map.put("method","sendMsg");
|
||||
}else if (type == 2){
|
||||
ty = "新增";
|
||||
map.put("method","updatePending");
|
||||
}else {
|
||||
throw new BPMNError("类型未定义!");
|
||||
}
|
||||
|
||||
String params = JSONObject.toJSONString(content);
|
||||
if(params.contains("subState")) {
|
||||
// httpClientUtil.setPostRequestBody("["+params+"]","application/json","UTF-8");
|
||||
}else {
|
||||
//httpClientUtil.setPostRequestBody(params,"application/json","UTF-8");
|
||||
}
|
||||
map.put("params",params);
|
||||
int httpStatus = 1;
|
||||
String result = httpClientUtil.toString();
|
||||
if (httpStatus != HttpStatus.SC_OK){
|
||||
logger.info("调用OA待发"+ty+"接口====>type:"+type+",url:"+url+",失败!"+"taskId: "+taskId);
|
||||
}else{
|
||||
logger.info("调用OA待发"+ty+"接口====>taskId: "+taskId+",返回结果:"+result);
|
||||
}
|
||||
|
||||
map.put("httpStatus",httpStatus);
|
||||
map.put("result",result);
|
||||
|
||||
try{
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
map.put("success",jsonObject.getString("success"));
|
||||
}catch (Exception e){
|
||||
map.put("success","error");
|
||||
}
|
||||
// RowMap oldRecord = DBSql.getMap("SELECT id FROM app_hy_integrated_call_oa_recording WHERE paramId=? and method=?", map.get("paramId"),map.get("method"));
|
||||
//if (!CollectionUtils.isEmpty(oldRecord)){
|
||||
// map.put("id",oldRecord.getLong("ID"));
|
||||
// DBSql.update("UPDATE app_hy_integrated_call_oa_recording SET params=:params,receiver=:receiver,httpStatus=:httpStatus,result=:result,success=:success,calledCount=calledCount+1,lastCallTime=NOW() WHERE id=:id",map);
|
||||
// }else{
|
||||
// DBSql.update(DBSql.getInsertStatement("app_hy_integrated_call_oa_recording", map), map);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送待发
|
||||
* @param taskInstance DD
|
||||
*/
|
||||
public void sendOaPending(TaskInstance taskInstance, ProcessExecutionContext pec){
|
||||
String token = "";
|
||||
OaPending pend = new OaPending();
|
||||
pend.setTaskId(taskInstance.getId());
|
||||
ProcessInstance processInstance = pec.getProcessInstance();
|
||||
pend.setTitle(processInstance.getTitle());
|
||||
ProcessDefinition processDef = pec.getProcessDef();
|
||||
String appId = processDef.getAppId();
|
||||
if("com.hy.apps.swgl".equals(appId)||"com.hy.apps.rmm".equals(appId)||"com.hy.apps.mms".equals(appId)) {
|
||||
pend.setRegisterCode("3001");
|
||||
pend.setClassify("明源");
|
||||
}else {
|
||||
pend.setRegisterCode("3011");
|
||||
pend.setClassify("BPM");
|
||||
}
|
||||
|
||||
pend.setSendName(SDK.getORGAPI().getUser(processInstance.getCreateUser()).getUserName());
|
||||
UserModel targetUserModel = UserCache.getModel(taskInstance.getTarget());
|
||||
if (null == targetUserModel || StringUtils.isBlank(targetUserModel.getExt5())){
|
||||
String msg = "账号对应的OA账号为空!待发不能推送,请补充完善账号信息!BPM账号:"+taskInstance.getTarget();
|
||||
logger.error(msg);
|
||||
|
||||
//给 杨波 推消息
|
||||
notificationAPI.sendSystemMessage("admin", msg,"error");
|
||||
return;
|
||||
}
|
||||
pend.setCreationDate(taskInstance.getBeginTime().toString());
|
||||
pend.setNoneBindingReceiver(targetUserModel.getExt5());
|
||||
pend.setState("10");
|
||||
pend.setType("add");
|
||||
|
||||
String taskUrl = buildTaskUrl(taskInstance,pec);
|
||||
if (null == taskUrl){
|
||||
return;
|
||||
}
|
||||
pend.setUrl(taskUrl);
|
||||
pend.setH5Url(taskUrl);
|
||||
|
||||
ThreadMgr.execute(new PostPendTask(taskInstance.getId(),0,uri + "/seeyon/rest/thirdPartyCommittedWillDone/addSingleWillDone?token=" + token,pend));
|
||||
OaMessage msg = buildMsg(taskInstance, pec, taskUrl);
|
||||
if (null != msg){
|
||||
//ThreadMgr.execute(new PostPendTask(1,uri + "/seeyon/rest/thirdpartyMessage/receive/singleMessage?token=" + token,msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void sendOaPending(OaPending pend){
|
||||
String token = "";
|
||||
pend.setToken(token);
|
||||
pend.setRegisterCode("3011");
|
||||
pend.setState("0");
|
||||
pend.setSubState("0");
|
||||
ThreadMgr.execute(new PostPendTask("",0,uri + "/seeyon/rest/thirdPartyCommittedWillDone/addSingleWillDone?token=" + token,pend));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造待发打开链接
|
||||
* @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 {
|
||||
stringBuilder.append("/r/or?cmd=com.hy_client_bpm_form_main_page_open&processInstId=").append(bindId).append("&taskInstId=").append(taskId).append("&uid=").append(target)
|
||||
.append("&oauthName=oauthLogin");
|
||||
|
||||
//append(URLEncoder.encode(encodeRsa[0],"UTF-8"))
|
||||
return stringBuilder.toString();
|
||||
} catch (Exception e) {
|
||||
logger.error("构造ticket失败!",e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新待发状态
|
||||
*/
|
||||
public void updatePending(String taskInstanceId,String state,String subState) {
|
||||
String token = "";
|
||||
OaPending pend = new OaPending();
|
||||
pend.setTaskId(taskInstanceId);
|
||||
pend.setState(state);
|
||||
pend.setSubState(subState);
|
||||
pend.setToken(token);
|
||||
TaskInstance taskInstance = SDK.getTaskAPI().getTaskInstance(taskInstanceId);
|
||||
ProcessDefinition processDefinition = SDK.getRepositoryAPI().getProcessDefinition(taskInstance.getProcessDefId());
|
||||
String appId = processDefinition.getAppId();
|
||||
if("com.hy.apps.swgl".equals(appId)||"com.hy.apps.rmm".equals(appId)||"com.hy.apps.mms".equals(appId)) {
|
||||
pend.setRegisterCode("3001");
|
||||
}else {
|
||||
pend.setRegisterCode("3011");
|
||||
}
|
||||
ThreadMgr.execute(new PostPendTask(taskInstanceId,2,uri + "/seeyon/rest/thirdPartyCommitted/updateState?token=" + token,pend));
|
||||
}
|
||||
|
||||
public void updatePending(OaPending pend,boolean async) {
|
||||
String token = "";
|
||||
pend.setRegisterCode("3011");
|
||||
pend.setToken(token);
|
||||
if (async){
|
||||
ThreadMgr.execute(new PostPendTask("",2,uri + "/seeyon/rest/thirdPartyCommitted/updateState?token=" + token,pend));
|
||||
}else {
|
||||
PostPendTask postPendTask = new PostPendTask("",1, uri + "/seeyon/rest/thirdPartyCommitted/updateState?token=" + token, pend);
|
||||
postPendTask.run();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updatePending(OaPending pend) {
|
||||
updatePending(pend,true);
|
||||
}
|
||||
|
||||
|
||||
public void sendMessage(TaskInstance taskInstance, ProcessExecutionContext pec){
|
||||
String taskUrl = buildTaskUrl(taskInstance, pec);
|
||||
if (null == taskUrl){
|
||||
return;
|
||||
}
|
||||
OaMessage oaMessage = buildMsg(taskInstance, pec, taskUrl);
|
||||
if (null != oaMessage){
|
||||
String token = "";
|
||||
ThreadMgr.execute(new PostPendTask(taskInstance.getId(),1,uri + "/seeyon/rest/thirdpartyMessage/receive/singleMessage?token=" + token,oaMessage));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void sendMessage(OaMessage msg){
|
||||
msg.setThirdpartyRegisterCode("3011");
|
||||
String token = "";
|
||||
ThreadMgr.execute(new PostPendTask("",1,uri + "/seeyon/rest/thirdpartyMessage/receive/singleMessage?token=" + token,msg));
|
||||
}
|
||||
|
||||
private OaMessage buildMsg(TaskInstance taskInstance, ProcessExecutionContext pec, String msgUrl){
|
||||
ProcessInstance processInstance = pec.getProcessInstance();
|
||||
OaMessage msg = new OaMessage();
|
||||
ProcessDefinition processDef = pec.getProcessDef();
|
||||
String appId = processDef.getAppId();
|
||||
|
||||
if("com.hy.apps.swgl".equals(appId)||"com.hy.apps.rmm".equals(appId)||"com.hy.apps.mms".equals(appId)) {
|
||||
msg.setThirdpartyRegisterCode("3001");
|
||||
}else {
|
||||
msg.setThirdpartyRegisterCode("3011");
|
||||
}
|
||||
msg.setThirdpartyMessageId(taskInstance.getId()+System.currentTimeMillis());
|
||||
msg.setMessageContent("收到待发事项:"+processInstance.getTitle());
|
||||
msg.setThirdpartyReceiverId(taskInstance.getTarget());
|
||||
msg.setThirdpartySenderId(processInstance.getCreateUser());
|
||||
|
||||
UserModel targetUserModel = UserCache.getModel(taskInstance.getTarget());
|
||||
if (null == targetUserModel || StringUtils.isBlank(targetUserModel.getExt5())){
|
||||
String content = "账号对应的OA账号为空!待发不能推送,请补充完善账号信息!BPM账号:"+taskInstance.getTarget();
|
||||
logger.error(content);
|
||||
|
||||
//给 杨波 推消息
|
||||
notificationAPI.sendSystemMessage("admin",content,"error");
|
||||
return null;
|
||||
}
|
||||
|
||||
msg.setNoneBindingReceiver(targetUserModel.getExt5());
|
||||
msg.setNoneBindingSender("group-admin");
|
||||
msg.setCreationDate(new Date());
|
||||
// 0:PC;1:移动URL接入应用;2:本地H5应用;3: 本地原生应用;4:PC&移动URL接入应用;5:PC&本地H5应用;6:PC&本地原生应用
|
||||
msg.setMessageType(0);
|
||||
msg.setMessageURL(msgUrl);
|
||||
msg.setMessageH5URL(msgUrl);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,121 @@
|
||||
package com.awspaas.user.apps.integration.oa;
|
||||
/*
|
||||
* package com.hy.apps.integrated.oa;
|
||||
*
|
||||
* import java.sql.Date; import java.sql.PreparedStatement; import
|
||||
* java.util.List;
|
||||
*
|
||||
* import org.slf4j.Logger; import org.slf4j.LoggerFactory;
|
||||
*
|
||||
* import com.actionsoft.bpms.commons.database.BatchPreparedStatementSetter;
|
||||
* import com.actionsoft.bpms.commons.database.RowMap; import
|
||||
* com.actionsoft.bpms.commons.pagination.impl.OraclePagination; import
|
||||
* com.actionsoft.bpms.util.UUIDGener; import com.actionsoft.sdk.local.SDK;
|
||||
* import com.actionsoft.sdk.local.api.NotificationAPI; import
|
||||
* com.actionsoft.sdk.local.api.internal.cc.RDSAPIImpl;
|
||||
*
|
||||
* public class PendingCheck {
|
||||
*
|
||||
* private static Logger logger = LoggerFactory.getLogger(PendingCheck.class);
|
||||
*
|
||||
* private String ehr_cc_id =
|
||||
* SDK.getAppAPI().getProperty("com.hy.apps.integrated", "ehr_cc_id"); private
|
||||
* String oa_cc_id = SDK.getAppAPI().getProperty("com.hy.apps.integrated",
|
||||
* "oa_cc_id");
|
||||
*
|
||||
*//**
|
||||
* 将OA EHR 待办抓取到 EHR系统
|
||||
*
|
||||
* @param updateFlag
|
||||
*/
|
||||
/*
|
||||
* public void getOAPendingToEhr(boolean updateFlag){ RDSAPIImpl ehrRdsApi =
|
||||
* (RDSAPIImpl) SDK.getCCAPI().getRDSAPI(ehr_cc_id); // //删除历史的待办数据
|
||||
* ehrRdsApi.update("DELETE FROM daiban_tmp"); RDSAPIImpl rdsApi = (RDSAPIImpl)
|
||||
* SDK.getCCAPI().getRDSAPI(oa_cc_id); int anInt = rdsApi.
|
||||
* getInt("SELECT COUNT(0) FROM THIRDPARTY_PENDING p WHERE STATE=0 AND REGISTER_ID='775681212246869729'"
|
||||
* ); int index = 0; int pageSize = 200; while (index <= anInt){ String
|
||||
* limitString = (new OraclePagination()).getLimitString("SELECT TASK_ID " +
|
||||
* "FROM THIRDPARTY_PENDING p WHERE STATE=0 AND REGISTER_ID='775681212246869729'"
|
||||
* , index, pageSize);
|
||||
*
|
||||
* index = index +pageSize; List<RowMap> maps = rdsApi.getMaps(limitString);
|
||||
* BatchPreparedStatementSetter setter=new BatchPreparedStatementSetter() {
|
||||
* public int getBatchSize() { return maps.size(); } public void
|
||||
* setValues(PreparedStatement ps, int i) { try { RowMap rowMap = maps.get(i);
|
||||
* ps.setString(1, rowMap.getString("TASK_ID")); } catch (Exception e) {
|
||||
* e.printStackTrace(); } } };
|
||||
* ehrRdsApi.batch("INSERT INTO daiban_tmp (TASK_ID) VALUES (?)",setter); }
|
||||
* //获取EHR已完成的,OA 未消除的待办 List<RowMap> taskMaps = ehrRdsApi.
|
||||
* getMaps("SELECT t.TASK_ID FROM daiban_tmp t INNER JOIN we_task wt ON wt.TASK_ID = t.TASK_ID AND wt.CURRENT_STATE='COMPLETED'"
|
||||
* ); RDSAPIImpl oaRdsApi = (RDSAPIImpl) SDK.getCCAPI().getRDSAPI(oa_cc_id);
|
||||
* //删除历史的待办数据 oaRdsApi.update("DELETE FROM BO_HY_INTEGRATED_EHR_TASK");
|
||||
*
|
||||
* BatchPreparedStatementSetter setter=new BatchPreparedStatementSetter() {
|
||||
* public int getBatchSize() { return taskMaps.size(); } public void
|
||||
* setValues(PreparedStatement ps, int i) { try { RowMap rowMap =
|
||||
* taskMaps.get(i); ps.setString(1, UUIDGener.getUUID()); ps.setString(2,
|
||||
* rowMap.getString("TASK_ID")); } catch (Exception e) { e.printStackTrace(); }
|
||||
* } }; oaRdsApi.
|
||||
* batch("INSERT INTO \"BO_HY_INTEGRATED_EHR_TASK\" (\"ID\", \"TASK_ID\") VALUES (?,?)"
|
||||
* ,setter);
|
||||
*
|
||||
* logger.info("获取并插入EHR总待办条数:"+oaRdsApi.
|
||||
* getInt("SELECT COUNT(0) FROM BO_HY_INTEGRATED_EHR_TASK")); if (updateFlag){
|
||||
* int update = oaRdsApi.
|
||||
* update("UPDATE THIRDPARTY_PENDING TP SET TP.UPDATE_DATE=SYSDATE WHERE EXISTS (SELECT 1 FROM BO_HY_INTEGRATED_EHR_TASK et WHERE et.TASK_ID = TP.TASK_ID ) AND TP.STATE=0"
|
||||
* ); logger.info("更新OA待办为已办条数:"+update); }else{ int count =
|
||||
* oaRdsApi.getInt(" SELECT COUNT(0) FROM BO_HY_INTEGRATED_EHR_TASK "); if
|
||||
* (count>0){ NotificationAPI notificationAPI = SDK.getNotificationAPI();
|
||||
* notificationAPI.sendSystemMessage("18512383665",
|
||||
* "发现OA有未更新的EHR待办:"+count+"条","warning"); }
|
||||
* logger.info("参数未false,不更新OA待办数据。可更新条数:"+count); } }
|
||||
*
|
||||
*
|
||||
*//**
|
||||
* 导EHR 待办进 OA数据库
|
||||
*//*
|
||||
* @Deprecated public void getEHRPending(boolean updateFlag){ RDSAPIImpl
|
||||
* oaRdsApi = (RDSAPIImpl) SDK.getCCAPI().getRDSAPI(oa_cc_id); //删除历史的待办数据
|
||||
* oaRdsApi.update("DELETE FROM BO_HY_INTEGRATED_EHR_TASK"); RDSAPIImpl
|
||||
* ehrRdsApi = (RDSAPIImpl) SDK.getCCAPI().getRDSAPI(ehr_cc_id); int anInt =
|
||||
* ehrRdsApi.getInt("SELECT COUNT(0) \n" +
|
||||
* "FROM we_task wt INNER JOIN we_process wp ON wt.business_key=wp.business_key WHERE wt.CURRENT_STATE IN ('WAITING','ACCEPTED')\n"
|
||||
* + "AND wp.current_state = 'running' AND wt.PRIORITY>1 "); int index = 0; int
|
||||
* pageSize = 500; while (index <= anInt){ String limitString =
|
||||
* "SELECT wt.TASK_ID,wt.ACTIVITY_NAME,wt.current_state,wt.TITLE,wt.PARTICIPANT_NAME,CREATE_TIME \n"
|
||||
* +
|
||||
* "FROM we_task wt INNER JOIN we_process wp ON wt.business_key=wp.business_key WHERE wt.CURRENT_STATE IN ('WAITING','ACCEPTED')\n"
|
||||
* + "AND wp.current_state = 'running' AND wt.PRIORITY>1 limit "+index+","+
|
||||
* pageSize; index = index +pageSize; List<RowMap> maps =
|
||||
* ehrRdsApi.getMaps(limitString); BatchPreparedStatementSetter setter=new
|
||||
* BatchPreparedStatementSetter() { public int getBatchSize() { return
|
||||
* maps.size(); } public void setValues(PreparedStatement ps, int i) { try {
|
||||
* RowMap rowMap = maps.get(i); ps.setString(1, UUIDGener.getUUID());
|
||||
* ps.setString(2, rowMap.getString("TASK_ID")); ps.setString(3,
|
||||
* rowMap.getString("ACTIVITY_NAME")); ps.setString(4,
|
||||
* rowMap.getString("CURRENT_STATE")); ps.setString(5,
|
||||
* rowMap.getString("TITLE")); ps.setString(6,
|
||||
* rowMap.getString("PARTICIPANT_NAME")); ps.setDate(7, new
|
||||
* Date(rowMap.getDate("CREATE_TIME").getTime())); } catch (Exception e) {
|
||||
* e.printStackTrace(); } } }; oaRdsApi.
|
||||
* batch("INSERT INTO \"BO_HY_INTEGRATED_EHR_TASK\" (\"ID\", \"TASK_ID\", \"ACTIVITY_NAME\", \"CURRENT_STATE\", \"TITLE\", \"PARTICIPANT_NAME\", \"CREATE_TIME\") VALUES (?,?, ?,?,?,?,?)"
|
||||
* ,setter); } logger.info("获取并插入EHR总待办条数:"+oaRdsApi.
|
||||
* getInt("SELECT COUNT(0) FROM BO_HY_INTEGRATED_EHR_TASK")); if (updateFlag){
|
||||
* //TODO 更新待办 有问题。 // int update = oaRdsApi.
|
||||
* update("UPDATE THIRDPARTY_PENDING TP SET TP.STATE=1 WHERE EXISTS (\n" + //
|
||||
* "\tSELECT 1 FROM (\n" + //
|
||||
* "\t\tSELECT p.TASK_ID FROM THIRDPARTY_PENDING p \n" + //
|
||||
* "\t\tLEFT JOIN BO_HY_INTEGRATED_EHR_TASK t ON p.TASK_ID = t.TASK_ID\n" + //
|
||||
* "\t\tWHERE STATE=0 AND REGISTER_ID='775681212246869729' AND t.TASK_ID IS NULL\n"
|
||||
* + // "\t) y WHERE y.TASK_ID = TP.TASK_ID ) \n" + // "AND TP.STATE=0"); //
|
||||
* logger.info("更新OA待办为已办条数:"+update); }else{ int count =
|
||||
* oaRdsApi.getInt(" SELECT \"COUNT\"(0) FROM THIRDPARTY_PENDING p \n" +
|
||||
* " LEFT JOIN BO_HY_INTEGRATED_EHR_TASK t ON p.TASK_ID = t.TASK_ID\n" +
|
||||
* " WHERE STATE=0 AND REGISTER_ID='775681212246869729' AND t.TASK_ID IS NULL");
|
||||
* logger.info("参数未false,不更新OA待办数据。可更新条数:"+count); }
|
||||
*
|
||||
* }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
@ -0,0 +1,380 @@
|
||||
package com.awspaas.user.apps.integration.oa;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import com.actionsoft.bpms.bpmn.constant.ProcessRuntimeConst;
|
||||
import com.actionsoft.bpms.bpmn.constant.PublicEventConst;
|
||||
import com.actionsoft.bpms.bpmn.engine.ProcessAPIManager;
|
||||
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
|
||||
import com.actionsoft.bpms.bpmn.engine.listener.ProcessPubicListener;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.def.ProcessDefinition;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.TaskCommentModel;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.HistoryTaskInstance;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.LogAPI;
|
||||
import com.actionsoft.sdk.local.api.Logger;
|
||||
import com.actionsoft.sdk.local.api.TaskAPI;
|
||||
|
||||
/**
|
||||
* @author lihongyu
|
||||
*
|
||||
*/
|
||||
public class TaskListener extends ProcessPubicListener {
|
||||
|
||||
private Logger logger = LogAPI.getLogger(TaskListener.class);
|
||||
|
||||
private String rootScopeId = "00000000-0000-0000-0000-000000000000";
|
||||
private String sendEnable = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "sendEnable");
|
||||
private String notPushReadyTask = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "notPushReadyTask");
|
||||
private String[] AGREE = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "AGREE").split("\\|");
|
||||
private String[] GO_BACK = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "GO_BACK").split("\\|");
|
||||
private String[] DESI_BACK = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "DESI_BACK").split("\\|");
|
||||
private String[] TE_SHI_TE_BAN = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "TE_SHI_TE_BAN")
|
||||
.split("\\|");
|
||||
private String[] TERMINATION = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "TERMINATION").split("\\|");
|
||||
private String[] ABOLITION = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "ABOLITION").split("\\|");
|
||||
private String[] TRANSFER = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "TRANSFER").split("\\|");
|
||||
private String[] GET_BACK = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "GET_BACK").split("\\|");
|
||||
private String[] GET_BACKCC = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "GET_BACKCC").split("\\|");
|
||||
private String[] GET_BACKD = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "GET_BACK").split("\\|");
|
||||
private TaskAPI taskAPI = SDK.getTaskAPI();
|
||||
private static Set<String> strings = new HashSet<>();
|
||||
private final String close = "2";
|
||||
// 通知类型 9 系统通知任务【不影响流程推进】 2 只读传阅任务【不影响流程推进】
|
||||
private Integer noticeState = 9;
|
||||
private Integer tranReadState = 2;
|
||||
|
||||
/**
|
||||
* 所有人工任务相关行为发生时被触发(见PublicEventConst常量) ProcessPubicListener
|
||||
*
|
||||
* @param eventName 事件名称,见PublicEventConst常量
|
||||
* @param taskInstance 任务实例对象
|
||||
* @param pec 流程引擎提供给监听器的上下文对象
|
||||
* @see PublicEventConst
|
||||
*/
|
||||
@Override
|
||||
public void call(String eventName, TaskInstance taskInstance, ProcessExecutionContext pec) {
|
||||
//System.out.println("11111111111111");
|
||||
if (close.equals(sendEnable)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (taskInstance == null) {
|
||||
return;
|
||||
}
|
||||
String actionName = "";
|
||||
if (!UtilString.isEmpty(taskInstance.getId())) {
|
||||
actionName = getActionName(taskInstance);
|
||||
|
||||
}
|
||||
OaPendComponent component = new OaPendComponent();
|
||||
if (UtilString.isEmpty(taskInstance.getId()) && PublicEventConst.TASK_DELETE.equals(eventName)) {
|
||||
|
||||
Map<String, Object> parameters2 = pec.getParameters();
|
||||
final Object taskLists = parameters2.get("taskList");
|
||||
if (null != taskLists) {
|
||||
List<HistoryTaskInstance> list = (List<HistoryTaskInstance>) taskLists;
|
||||
list.forEach(h -> {
|
||||
logger.info("调用OA删除任务接口:taskInstanceId:" + h.getId());
|
||||
try {
|
||||
component.updatePending(taskInstance,pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//OaDeleteComponent(h.getId());
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
} else if (PublicEventConst.TASK_DELETE.equals(eventName) || taskInstance.getControlState() == "delete") {
|
||||
if (actionName == "") {
|
||||
logger.info("调用OA删除任务接口:taskInstanceId:" + taskInstance.getId());
|
||||
try {
|
||||
component.updatePending(taskInstance,pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//OaDeleteComponent(taskInstance.getId());
|
||||
}
|
||||
}
|
||||
String appId = "";
|
||||
if(PublicEventConst.TASK_CREATE.equals(eventName)||PublicEventConst.TASK_COMPLETE.equals(eventName)) {
|
||||
ProcessDefinition processDef = pec.getProcessDef();
|
||||
if(null!=processDef) {
|
||||
appId = processDef.getAppId();
|
||||
}
|
||||
}
|
||||
|
||||
if (PublicEventConst.TASK_CREATE.equals(eventName) && (!taskInstance.getParentTaskInstId().equals(rootScopeId)||notPushReadyTask.contains(appId))) {
|
||||
if (StringUtils.isEmpty(taskInstance.getTarget())) {
|
||||
return;
|
||||
}
|
||||
if (taskInstance.getState() == noticeState) {
|
||||
try {
|
||||
component.sendOaPending(taskInstance, pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据配置表修改任务标题 by yujh start
|
||||
// TaskUtil taskUtil =new TaskUtil();
|
||||
// String newTitle = taskUtil.updateTaskTitleByBase(pec.getUserContext(), taskInstance.getId(), taskInstance.getActivityDefId(), taskInstance.getTitle());
|
||||
// taskInstance = SDK.getTaskAPI().getTaskInstance(taskInstance.getId());
|
||||
// 根据配置表修改任务标题 by yujh end
|
||||
|
||||
try {
|
||||
component.sendOaPending(taskInstance, pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.info("创建OA待办,taskInstanceId:" + taskInstance.getId());
|
||||
|
||||
} else if (PublicEventConst.TASK_READ.equals(eventName)) {
|
||||
if (taskInstance.getState() == tranReadState) {
|
||||
|
||||
logger.info("更新知会待办,taskInstanceId:" + taskInstance.getId());
|
||||
try {
|
||||
component.updatePending(taskInstance,pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else if (PublicEventConst.TASK_COMPLETE.equals(eventName)) {
|
||||
if (!taskInstance.getParentTaskInstId().equals(rootScopeId)||notPushReadyTask.contains(appId)) {
|
||||
// final String actionName = getActionName(taskInstance);
|
||||
if (equalsAction(AGREE, actionName)) {
|
||||
try {
|
||||
component.updatePending(taskInstance,pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.info("更新OA待办:" + "同意");
|
||||
} else if (equalsAction(GO_BACK, actionName)) {
|
||||
try {
|
||||
component.updatePending(taskInstance,pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.info("更新OA待办:" + "回退");
|
||||
} else if (equalsAction(DESI_BACK, actionName)) {
|
||||
try {
|
||||
component.updatePending(taskInstance,pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.info("更新OA待办:" + "指定回退");
|
||||
} else if (equalsAction(TE_SHI_TE_BAN, actionName)) {
|
||||
try {
|
||||
component.updatePending(taskInstance,pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.info("更新OA待办:" + "特事特办");
|
||||
} else if (equalsAction(TERMINATION, actionName)) {
|
||||
try {
|
||||
component.updatePending(taskInstance,pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.info("更新OA待办:" + "终止");
|
||||
} else if (equalsAction(TRANSFER, actionName)) {
|
||||
try {
|
||||
component.updatePending(taskInstance,pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.info("更新OA待办:" + "转办");
|
||||
} else {
|
||||
try {
|
||||
component.updatePending(taskInstance,pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.info("更新OA待办:未定义的操作:" + actionName + ",按同意已办处理");
|
||||
}
|
||||
}
|
||||
|
||||
} else if (PublicEventConst.TASK_TRANSFER.equals(eventName)) {
|
||||
|
||||
// 移交任务 需要更新之前那个人的待办为已办,然后添加当前人的待办
|
||||
} else if (PublicEventConst.TASK_DELEGATE.equals(eventName)) {
|
||||
|
||||
final TaskCommentModel comment = getCommentCreateUserId(taskInstance.getProcessInstId(),
|
||||
taskInstance.getId());
|
||||
if (null != comment) {
|
||||
logger.info("任务转办");
|
||||
taskAPI.createUserTaskInstance(pec.getProcessInstance().getId(), taskInstance.getId(),
|
||||
comment.getCreateUser(), taskInstance.getActivityDefId(), taskInstance.getTarget(),
|
||||
"转办:" + pec.getProcessInstance().getTitle());
|
||||
taskAPI.completeTask(taskInstance.getId(), comment.getCreateUser(), false);
|
||||
}
|
||||
|
||||
} else if (UtilString.isNotEmpty(taskInstance.getId())
|
||||
&& !taskInstance.getParentTaskInstId().equals(rootScopeId)) {
|
||||
// 撤销流程
|
||||
if (UtilString.isEmpty(taskInstance.getId())) {
|
||||
Map<String, Object> parameters = pec.getParameters();
|
||||
if (!CollectionUtils.isEmpty(parameters)) {
|
||||
// 这个list即是撤销时全部删除的任务实例
|
||||
final Object taskList = parameters.get("taskList");
|
||||
if (null != taskList) {
|
||||
List<HistoryTaskInstance> list = (List<HistoryTaskInstance>) taskList;
|
||||
// OaPendComponent component = new OaPendComponent();
|
||||
list.forEach(h -> {
|
||||
if (!h.getParentTaskInstId().equals(rootScopeId)) {
|
||||
if (ProcessRuntimeConst.INST_STATE_ACTIVE.equals(h.getControlState())
|
||||
&& noticeState != h.getState()) {
|
||||
logger.info("更新OA待办:取消,taskInstanceId:" + h.getId());
|
||||
try {
|
||||
component.updatePending(taskInstance,pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (UtilString.isNotEmpty(taskInstance.getId())) {
|
||||
// final String actionName = getActionName(taskInstance);
|
||||
if (equalsAction(TE_SHI_TE_BAN, actionName) || equalsAction(TRANSFER, actionName)) {
|
||||
return;
|
||||
}
|
||||
if (equalsAction(ABOLITION, actionName)) {
|
||||
/*
|
||||
* logger.info("更新OA待办:作废,taskInstanceId:" + taskInstance.getId());
|
||||
* OaPendComponent component = new OaPendComponent();
|
||||
* component.updatePending(taskInstance.getId(), "1", "2");
|
||||
*
|
||||
*/
|
||||
logger.info("调用OA删除任务接口:taskInstanceId:" + taskInstance.getId());
|
||||
try {
|
||||
component.updatePending(taskInstance,pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (equalsAction(GET_BACK, actionName) || equalsAction(GET_BACKD, actionName)||equalsAction(GET_BACKCC, actionName)) {
|
||||
logger.info("更新OA待办:收回,taskInstanceId:" + taskInstance.getParentTaskInstId());
|
||||
|
||||
try {
|
||||
component.updatePending(taskInstance,pec);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* if (null == pec.getUserContext() ||
|
||||
* taskInstance.getTarget().equals(pec.getUserContext().getUID())) { return; }
|
||||
*/
|
||||
if (strings.contains(taskInstance.getId())) {
|
||||
strings.remove(taskInstance.getId());
|
||||
return;
|
||||
} else {
|
||||
strings.add(taskInstance.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (PublicEventConst.PROCESS_COMPLETE.equals(eventName)) {
|
||||
ProcessInstance processInstance = pec.getProcessInstance();
|
||||
// 流程删除或取消
|
||||
if (ProcessRuntimeConst.INST_STATE_TERMINATE.equals(processInstance.getControlState())
|
||||
|| ProcessRuntimeConst.INST_STATE_CANCEL.equals(processInstance.getControlState())) {
|
||||
List<HistoryTaskInstance> list = SDK.getHistoryTaskQueryAPI().processInstId(processInstance.getId())
|
||||
.list();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
HistoryTaskInstance historyTaskInstance = list.get(i);
|
||||
if (ProcessRuntimeConst.INST_STATE_TERMINATE.equals(historyTaskInstance.getControlState())
|
||||
|| ProcessRuntimeConst.INST_STATE_CANCEL.equals(historyTaskInstance.getControlState())) {
|
||||
logger.info("调用OA删除任务接口:taskInstanceId:" + taskInstance.getId());
|
||||
OaDeleteComponent(taskInstance.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (PublicEventConst.TASK_CANCEL.equals(eventName)) {
|
||||
logger.info("调用OA删除任务接口:taskInstanceId:" + taskInstance.getId());
|
||||
OaDeleteComponent(taskInstance.getId());
|
||||
}
|
||||
}
|
||||
|
||||
private void OaDeleteComponent(String taskId) {
|
||||
OaDeleteComponent component = new OaDeleteComponent();
|
||||
component.deleteOaPending(taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个审批步骤的 数据
|
||||
*
|
||||
* @param processInstId
|
||||
* @param taskInstanceId
|
||||
* @return
|
||||
*/
|
||||
private TaskCommentModel getCommentCreateUserId(String processInstId, String taskInstanceId) {
|
||||
final Iterator<TaskCommentModel> iterator = ProcessAPIManager.getInstance().getComments(processInstId)
|
||||
.iterator();
|
||||
TaskCommentModel next;
|
||||
while (iterator.hasNext()) {
|
||||
if ((next = iterator.next()).getTaskInstId().equals(taskInstanceId)) {
|
||||
return next;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
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 getActionName(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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "0.0.2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProvider() {
|
||||
return "伊利集团信息管理部";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "流程待办推送";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
package com.awspaas.user.apps.integration.oauth;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
|
||||
public class App {
|
||||
// Basic testClient:qwertyuio0987654rfg :: Basic ???
|
||||
static String clientId = "prcmgr";
|
||||
static String clientSecret = "Mvo634yOQwYAfMfB";
|
||||
|
||||
// http://cs.idm.yili.com:7777/ms_oauth/oauth2/endpoints/oauthservice/tokens?redirect_uri=http://192.168.88.100:8080/ecs-console/&grant_type=authorization_code&code=
|
||||
// 获取授权Token接口(authorization_code模式)
|
||||
public String getTokens(String redirect_uri, String code) {
|
||||
String tokenJson = "";
|
||||
|
||||
|
||||
String url = "https://idm.yili.com:7777/ms_oauth/oauth2/endpoints/oauthservice/tokens?" + "redirect_uri="
|
||||
+ redirect_uri + "&grant_type=authorization_code&code=" + code;
|
||||
|
||||
String authoStr = geAuthorization(clientId, clientSecret);
|
||||
HashMap<String, String> HeaderMap = new HashMap();
|
||||
//HeaderMap.put("Content-Type", "application/x-www-form-urlencoded");
|
||||
HeaderMap.put("grant_type","authorization_code");
|
||||
HeaderMap.put("Authorization", authoStr);
|
||||
//HeaderMap.put("accept", "*/*");
|
||||
//HeaderMap.put("connection", "Keep-Alive");
|
||||
System.out.println("url地址为=============="+url);
|
||||
System.out.println("参数为=============="+HeaderMap);
|
||||
// do request
|
||||
|
||||
|
||||
tokenJson = HttpJavaUtil.doPost(url, "", HeaderMap);
|
||||
System.out.println(tokenJson);
|
||||
return tokenJson;
|
||||
|
||||
}
|
||||
|
||||
public String getUserInfo(String token) {
|
||||
String userInfoJson = "";
|
||||
String url = "https://idm.yili.com:7777/ms_oauth/resources/userprofile/me";
|
||||
|
||||
String authoStr = token;
|
||||
HashMap<String, String> HeaderMap = new HashMap();
|
||||
HeaderMap.put("Content-Type", "application/x-www-form-urlencoded");
|
||||
HeaderMap.put("Authorization", authoStr);
|
||||
HeaderMap.put("accept", "*/*");
|
||||
HeaderMap.put("connection", "Keep-Alive");
|
||||
|
||||
// do request get
|
||||
userInfoJson = HttpJavaUtil.doGet(url, HeaderMap);
|
||||
System.out.println(userInfoJson);
|
||||
return userInfoJson;
|
||||
}
|
||||
|
||||
public String geAuthorization(String clientId, String clientSecret) {
|
||||
try {
|
||||
byte[] key = (clientId + ":" + clientSecret).getBytes("utf-8");
|
||||
String cc = new String(Base64.encodeBase64(key), "utf-8");
|
||||
// String cc = new String(java.util.Base64.getEncoder().encode(key), "utf-8");
|
||||
return "Basic " + cc;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,336 @@
|
||||
package com.awspaas.user.apps.integration.oauth;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.security.cert.X509Certificate;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
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;
|
||||
|
||||
public class HttpJavaUtil {
|
||||
|
||||
public static final String DEF_CHATSET = "UTF-8";
|
||||
public static final int DEF_CONN_TIMEOUT = 30000; // 是建立连接的超时时间
|
||||
public static final int DEF_READ_TIMEOUT = 30000; // 是传递数据的超时时间
|
||||
|
||||
public static String doGet(String httpUrl, Map<String, String> HeaderMap) {
|
||||
HttpURLConnection connection = null;
|
||||
InputStream is = null;
|
||||
BufferedReader br = null;
|
||||
String result = null;// 返回结果字符串
|
||||
System.out.println(httpUrl);
|
||||
try {
|
||||
// 创建远程url连接对象
|
||||
URL url = new URL(httpUrl);
|
||||
try {
|
||||
// trustAllHttpsCertificates();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("【异常】doGet-https-->" + e.getMessage());
|
||||
}
|
||||
trustAllHttpsCertificates();
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
// 设置header
|
||||
for (String key : HeaderMap.keySet()) {
|
||||
connection.setRequestProperty(key, HeaderMap.get(key).toString());
|
||||
}
|
||||
|
||||
// 设置连接方式:get
|
||||
connection.setRequestMethod("GET");
|
||||
// 设置连接主机服务器的超时时间:15000毫秒
|
||||
connection.setConnectTimeout(15000);
|
||||
// 设置读取远程返回的数据时间:60000毫秒
|
||||
connection.setReadTimeout(60000);
|
||||
// 发送请求
|
||||
connection.connect();
|
||||
// 通过connection连接,获取输入流
|
||||
if (connection.getResponseCode() == 200) {
|
||||
is = connection.getInputStream();
|
||||
// 封装输入流is,并指定字符集
|
||||
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
// 存放数据
|
||||
StringBuffer sbf = new StringBuffer();
|
||||
String tempX = "";
|
||||
while ((tempX = br.readLine()) != null) {
|
||||
sbf.append(tempX);
|
||||
sbf.append("\r\n");
|
||||
}
|
||||
result = sbf.toString();
|
||||
System.out.println(result);
|
||||
} else {
|
||||
String line;
|
||||
String message = "";
|
||||
br = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
|
||||
StringBuffer buff = new StringBuffer();
|
||||
while ((line = br.readLine()) != null) {
|
||||
buff.append(line + "\n");
|
||||
message += line;
|
||||
}
|
||||
message = buff.toString();
|
||||
System.out.println(message);
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 关闭资源
|
||||
if (null != br) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != is) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
connection.disconnect();// 关闭远程连接
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String doPost(String httpUrl, String BodyParam, Map<String, String> HeaderMap) {
|
||||
HttpURLConnection connection = null;
|
||||
InputStream is = null;
|
||||
OutputStream os = null;
|
||||
BufferedReader br = null;
|
||||
String result = null;
|
||||
try {
|
||||
URL url = new URL(httpUrl);
|
||||
try {
|
||||
// trustAllHttpsCertificates();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("【异常】doPost-https-->" + e.getMessage());
|
||||
}
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
// 设置header
|
||||
for (String key : HeaderMap.keySet()) {
|
||||
connection.setRequestProperty(key, HeaderMap.get(key).toString());
|
||||
}
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setConnectTimeout(15000);
|
||||
connection.setReadTimeout(60000);
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(true);
|
||||
|
||||
os = connection.getOutputStream();
|
||||
os.write(BodyParam.getBytes());
|
||||
int resCode = connection.getResponseCode();
|
||||
|
||||
is = connection.getInputStream();
|
||||
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
StringBuffer sbf = new StringBuffer();
|
||||
String temp = null;
|
||||
while ((temp = br.readLine()) != null) {
|
||||
sbf.append(temp);
|
||||
sbf.append("\r\n");
|
||||
}
|
||||
result = sbf.toString();
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (null != br) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != os) {
|
||||
try {
|
||||
os.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != is) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
connection.disconnect();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//使用SOAP1.1发送消息
|
||||
public static String doPostSoap(String postUrl, String soapXml, Map<String, String> HeaderMap) {
|
||||
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 {
|
||||
for (String key : HeaderMap.keySet()) {
|
||||
httpPost.setHeader(key, HeaderMap.get(key).toString());
|
||||
}
|
||||
|
||||
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");
|
||||
System.out.println("restsfagfasfas=======>>>>>>>>>>"+retStr);
|
||||
}
|
||||
// 释放资源
|
||||
closeableHttpClient.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return retStr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信任全部https证书
|
||||
*/
|
||||
private static void trustAllHttpsCertificates() throws Exception {
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
|
||||
public boolean verify(String str, SSLSession session) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1];
|
||||
javax.net.ssl.TrustManager tm = new miTM();
|
||||
trustAllCerts[0] = tm;
|
||||
javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL");
|
||||
sc.init(null, trustAllCerts, null);
|
||||
javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
}
|
||||
|
||||
static class miTM implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {
|
||||
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isServerTrusted(java.security.cert.X509Certificate[] certs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isClientTrusted(java.security.cert.X509Certificate[] certs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
||||
throws java.security.cert.CertificateException {
|
||||
return;
|
||||
}
|
||||
|
||||
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
||||
throws java.security.cert.CertificateException {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static String sendPost(String url, String param, Map<String, String> HeaderMap) {
|
||||
PrintWriter out = null;
|
||||
BufferedReader in = null;
|
||||
String result = "";
|
||||
try {
|
||||
URL realUrl = new URL(url);
|
||||
// 打开和URL之间的连接
|
||||
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
|
||||
|
||||
// 设置header
|
||||
for (String key : HeaderMap.keySet()) {
|
||||
conn.setRequestProperty(key, HeaderMap.get(key).toString());
|
||||
}
|
||||
|
||||
// 发送POST请求必须设置如下两行
|
||||
conn.setDoOutput(true);
|
||||
conn.setDoInput(true);
|
||||
conn.setConnectTimeout(5000000);
|
||||
conn.setReadTimeout(5000000);
|
||||
// 获取URLConnection对象对应的输出流
|
||||
out = new PrintWriter(conn.getOutputStream());
|
||||
// 发送请求参数
|
||||
out.print(param);
|
||||
// flush输出流的缓冲
|
||||
out.flush();
|
||||
// 定义BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
result += line;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("发送 POST 请求出现异常!" + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 使用finally块来关闭输出流、输入流
|
||||
finally {
|
||||
try {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,156 @@
|
||||
package com.awspaas.user.apps.integration.oauth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.commons.oauth.AbstractOauth;
|
||||
import com.actionsoft.bpms.server.RequestParams;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.LogAPI;
|
||||
import com.actionsoft.sdk.local.api.Logger;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yili.wsclient.ClientService;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* OA系统 跳转登陆PAl
|
||||
*
|
||||
* @author lihy
|
||||
*/
|
||||
|
||||
public class OauthLogin extends AbstractOauth {
|
||||
private Logger logger = LogAPI.getLogger(OauthLogin.class);
|
||||
|
||||
static String clientId = "testClient";
|
||||
static String clientSecret = "1234567890";
|
||||
/**
|
||||
* 这个方法代表是否有登录授权页,返回的值取决于三方系统提供的 SSO 认证方式。一类认 证方式如 Oauth2.0
|
||||
* 认证,需要先跳转到三方系统的登录授权页面,授权成功后再跳转到调 用方指定的页面,这类认证方式下,hasOauthPage()方法需要返回 true。
|
||||
* 另外一类认证时不 需要跳转到登录授权页, 会直接传过来 ticket 或者 token 参数, hasOauthPage()方法需要返 回 false。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean hasOauthPage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果 hasOauthPage()方法返回的值是 false, 返回 null 即可。 如果 hasOauthPage()方法返回 的值是
|
||||
* true,则此处返回三方系统的登录授权页地址。
|
||||
* @param requestParams
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getOauthPage(RequestParams requestParams) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String validate(RequestParams params) throws IOException {
|
||||
|
||||
|
||||
if (StringUtils.isNotEmpty(params.get("casaccount"))){
|
||||
BO detail = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("LOGINID=", params.get("casaccount")).detail();
|
||||
String workcode = detail.getString("WORKCODE");
|
||||
if (workcode.length()!=8){
|
||||
return "00"+workcode;
|
||||
}else{
|
||||
return params.get("casaccount");
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(params.get("usercode"))){
|
||||
return params.get("usercode");
|
||||
}
|
||||
|
||||
|
||||
logger.info("单点登录验证---------"+params);
|
||||
try {
|
||||
String redirect_uri = params.get("code");
|
||||
|
||||
if(StringUtils.isEmpty(redirect_uri)){
|
||||
logger.error("跳转地址为空,请重新输入");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
App app = new App();
|
||||
String tokens = app.getTokens("http://10.114.11.135:8088/portal/yili.html", redirect_uri);
|
||||
if(StringUtils.isEmpty(tokens)){
|
||||
logger.error("获取token为空,请重新输入登录信息获取code");
|
||||
return null;
|
||||
}else {
|
||||
JSONObject jsonObjects = JSONObject.parseObject(tokens);
|
||||
String access_token = jsonObjects.getString("access_token");
|
||||
String userInfo = app.getUserInfo(access_token);
|
||||
|
||||
if (StringUtils.isNotEmpty(userInfo)){
|
||||
JSONObject json = JSONObject.parseObject(userInfo);
|
||||
System.out.println("json-=====>>>>"+json);
|
||||
if (StringUtils.isNotEmpty(json.getString("employeenumber"))){
|
||||
return json.getString("employeenumber");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//统一身份认证
|
||||
//String result = getToken(casaccount, appaccount, appid, validcode);
|
||||
/* if("true".equals(result)) {
|
||||
// 验证账号是否存在
|
||||
if (UserCache.getModel(appaccount) != null) {
|
||||
// 身份认证成功
|
||||
return appaccount;
|
||||
}else {
|
||||
logger.error("单点登录查找用户失败!");
|
||||
return null;
|
||||
}
|
||||
}else if ("false".equals(result)){
|
||||
//身份认证失败
|
||||
logger.error("统一身份认证失败!");
|
||||
return null;
|
||||
}else {
|
||||
//身份认证失败
|
||||
logger.error("统一身份认证失败!网络连接超时,请联系管理员进行查看连接是否联通");
|
||||
return null;
|
||||
}*/
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("统一身份认证失败!", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一身份认证接口
|
||||
* @param1 webserviceUrl 身份认证接口地址
|
||||
* @param2 casaccount 登录账号 OA账号
|
||||
* @param3 appaccount 应用系统登录账号
|
||||
* @param4 appid 应用系统id
|
||||
* @param5 validcode 验证码
|
||||
* @return true/false
|
||||
*/
|
||||
public static String getToken(String casaccount,String appaccount,String appid,String validcode) {
|
||||
//身份认证接口地址
|
||||
String webserviceUrl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "webserviceUrl");
|
||||
String checkLogin = ClientService.checkLogin(webserviceUrl,casaccount,appaccount,appid,validcode);
|
||||
return checkLogin ;
|
||||
}
|
||||
|
||||
|
||||
public static String geAuthorization(String clientId, String clientSecret) {
|
||||
try {
|
||||
byte[] key = (clientId + ":" + clientSecret).getBytes("utf-8");
|
||||
String cc = new String(Base64.encodeBase64(key), "utf-8");
|
||||
// String cc = new String(java.util.Base64.getEncoder().encode(key), "utf-8");
|
||||
return "Basic " + cc;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,578 @@
|
||||
package com.awspaas.user.apps.integration.oauth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb;
|
||||
import com.actionsoft.apps.coe.pal.util.HighSecurityUtil;
|
||||
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
|
||||
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.client.form.UserTaskFormsWeb;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.RequestParams;
|
||||
import com.actionsoft.bpms.server.SSOUtil;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.server.bind.annotation.Controller;
|
||||
import com.actionsoft.bpms.server.bind.annotation.Mapping;
|
||||
import com.actionsoft.bpms.server.fs.DCContext;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.bpms.util.UUIDGener;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.exception.AWSException;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.AppAPI;
|
||||
import com.actionsoft.sdk.local.api.TaskAPI;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.awspaas.user.apps.integration.event.OutputDCFileProcessor;
|
||||
import com.awspaas.user.apps.integration.util.HttpClientUtil;
|
||||
import com.awspaas.user.apps.integration.util.UtilUrl;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
@Controller
|
||||
public class TaskController {
|
||||
|
||||
/**
|
||||
* OA系统单点访问PAL系统
|
||||
* @param me
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.yili_pal_portal_open")
|
||||
public String openPALConsole(UserContext me, RequestParams params) throws Exception {
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
String sessionId = me.getSessionId();
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
//http://localhost:8089/portal/r/w?cmd=com.actionsoft.apps.coe.pal_user_home_page&sid=0161dfa4-922f-4645-a45a-a68133c160a1#/repository
|
||||
//打开控制台
|
||||
// String palConsoleUrl= portalUrl + "/r/w?cmd=com.actionsoft.apps.coe.pal_user_home_page&sid="+sessionId+"#/repository";
|
||||
//打开个人门户、
|
||||
|
||||
String url = portalUrl +"/r/w?sid="+sessionId+"&cmd=com.actionsoft.apps.skins.mportal3_home_page&id=5af46cd5-a1bc-4125-a144-86d1a199eec1";
|
||||
// String palPortalUrl= portalUrl + "/r/w?sid="+sessionId+"&cmd=com.actionsoft.apps.skins.mportal3_home_page&id=5af46cd5-a1bc-4125-a144-86d1a199eec1";
|
||||
|
||||
|
||||
//ro.put("new_url",url);
|
||||
|
||||
return url;
|
||||
|
||||
}
|
||||
|
||||
@Mapping("com.wechat.oathLogin")
|
||||
public String postFr(String sid,String code){
|
||||
WechatApp app = new WechatApp();
|
||||
String tokens = app.getTokens(code);
|
||||
JSONObject jsonObjects = JSONObject.parseObject(tokens);
|
||||
String access_token = jsonObjects.getString("UserId");
|
||||
return access_token;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* OA系统单点访问表单数据
|
||||
* @param me
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.yili_form_page_open")
|
||||
public String openFormPage(UserContext me, RequestParams params) {
|
||||
System.out.println("进入表单了===========");
|
||||
System.out.println("参数输出==========="+params.asMap());
|
||||
if (StringUtils.isNotEmpty(params.get("state"))){
|
||||
|
||||
if (params.get("state").equals("STATE")){
|
||||
String code = params.get("code");
|
||||
WechatApp app = new WechatApp();
|
||||
String tokens = app.getTokens(code);
|
||||
if(StringUtils.isEmpty(tokens)){
|
||||
//logger.error("获取token为空,请重新输入登录信息获取code");
|
||||
return null;
|
||||
}else {
|
||||
JSONObject jsonObjects = JSONObject.parseObject(tokens);
|
||||
String access_token = jsonObjects.getString("UserId");
|
||||
System.out.println("UserId======>>>>>>>"+access_token);
|
||||
//BO detail = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("WORKCODE=", access_token).detail();
|
||||
// String workcode = detail.getString("WORKCODE");
|
||||
//if (workcode.length()!=8){
|
||||
// UserContext userContext = UserContext.fromUID(access_token);
|
||||
//}else{
|
||||
UserContext userContext = UserContext.fromUID(access_token);
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String sessionId = me.getSessionId();
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
if(!SDK.getPortalAPI().checkSession(sessionId)) {
|
||||
SSOUtil ssoUtil = new SSOUtil();
|
||||
sessionId = ssoUtil.registerClientSessionNoPassword(me.getUID(), "cn",portalUrl, me.getDeviceType());
|
||||
}
|
||||
UserContext uc = UserContext.fromSessionId(sessionId);
|
||||
UserTaskFormsWeb web = new UserTaskFormsWeb(uc);
|
||||
String processInstId = params.get("processInstId");
|
||||
String taskInstId = params.get("taskInstId");
|
||||
if (!UtilString.isEmpty(taskInstId) && taskInstId.equals("null")) {
|
||||
taskInstId = "";
|
||||
}
|
||||
int openState = 0;
|
||||
//根据流程实例去获取表单的 状态
|
||||
if (!taskInstId.equals("")){
|
||||
TaskAPI taskAPI = SDK.getTaskAPI();
|
||||
final TaskInstance taskInstance = taskAPI.getTaskInstance(taskInstId);
|
||||
if (null == taskInstance){
|
||||
taskInstId="";
|
||||
}else{
|
||||
if ("delete".equals(taskInstance.getControlState())){
|
||||
taskInstId="";
|
||||
}else{
|
||||
openState = taskInstance.getState();
|
||||
}
|
||||
}
|
||||
}
|
||||
int currentPage = params.getInt("currentPage", 1);
|
||||
String formDefId = params.get("formDefId", "");
|
||||
String boId = params.get("boId", "");
|
||||
String lang = params.get("lang");
|
||||
if (!UtilString.isEmpty(lang)) {
|
||||
me.setLanguages(lang);
|
||||
}
|
||||
String extParam = params.get("extParam");
|
||||
JSONObject extParamJO = null;
|
||||
if (!UtilString.isEmpty(extParam)) {
|
||||
try {
|
||||
extParamJO = JSONObject.parseObject(URLDecoder.decode(extParam, StandardCharsets.UTF_8.name()));
|
||||
} catch (UnsupportedEncodingException var14) {
|
||||
var14.printStackTrace();
|
||||
}
|
||||
}
|
||||
boolean isDisplayToolbar = params.getBoolean("displayToolbar", true);
|
||||
String formPage = web.getFormPage(processInstId, taskInstId, openState, currentPage, formDefId, boId, isDisplayToolbar, extParamJO);
|
||||
//String formURL = SDK.getFormAPI().getFormURL("", sessionId, processInstId,taskInstId, 1, null, null, null);
|
||||
//System.err.println("单点登录页面链接--->"+formURL);
|
||||
//return portalUrl+"/r"+formURL.substring(1);
|
||||
//System.out.println("输出表单==========="+formPage);
|
||||
return formPage;
|
||||
}
|
||||
|
||||
@Mapping("com.yili_process_page")
|
||||
public String processTest(UserContext me, RequestParams params) throws IOException, SQLException {
|
||||
String userMobile = me.getDeviceType();
|
||||
String html = "index_web.html";
|
||||
Connection conn = DBSql.open();
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
try {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
|
||||
//UserContext uc = UserContext.fromSessionId(sid);
|
||||
String sid = me.getSessionId();
|
||||
String processInstId = params.get("processInstId");
|
||||
String taskInstId = params.get("taskInstId");
|
||||
String usercode = params.get("usercode");
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
map.put("sid", sid);
|
||||
|
||||
|
||||
|
||||
List<BO> list = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID=", processInstId).list();
|
||||
int num = 1;
|
||||
|
||||
|
||||
|
||||
for (BO bo : list) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String is_not_publish_sql = "SELECT id,PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME ='" + bo.get("PUBLISHFILENAME") + "'";
|
||||
List<RowMap> Row_maps_is_not_publish = DBSql.getMaps(conn, is_not_publish_sql);
|
||||
/*boolean havingStartProcessPermission =SDK.getPermAPI().havingStartProcessPermission(uc.getUID(), processDefId);
|
||||
if(havingStartProcessPermission) {*/
|
||||
String id = bo.getString("TASKID");
|
||||
jsonObject.put("title",bo.get("PUBLISHFILENAME"));
|
||||
jsonObject.put("link",SDK.getPortalAPI().getPortalUrl()+ "/r/w?cmd=com.actionsoft.apps.coe.pal.publisher_publish_file_open&uuid=" + Row_maps_is_not_publish.get(0).getString("id") + "&sid=" + sid);
|
||||
jsonObject.put("size","");
|
||||
jsonObject.put("id",num);
|
||||
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(id);
|
||||
JSONObject json = new JSONObject();
|
||||
if (model != null) {
|
||||
//三员管理,步骤横表下载重新生成手册
|
||||
|
||||
String taskName = model.getTaskName();
|
||||
if ("步骤横表".equals(taskName)){
|
||||
// 重新设置生成id,与用户id
|
||||
String uuid = UUIDGener.getUUID();
|
||||
model.setUserId(me.getUID());
|
||||
|
||||
// 重新生成手册文件
|
||||
OutputAPIManager.getInstance().reGennerReport(me,model,uuid);
|
||||
|
||||
// 重新构建手册下载URL
|
||||
id = uuid;
|
||||
}
|
||||
|
||||
try {
|
||||
jsonObject.put("url", OutputDCFileProcessor.getReportDownloadURL(model.getWsId(), id, model.getProfileId(), me, bo.get("PUBLISHFILENAME")+model.getTaskName()));
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
jsonArray.add(jsonObject);
|
||||
num++;
|
||||
|
||||
}
|
||||
String substring = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId).detail().getString("RELEASE_INSTRUCTIONS");
|
||||
BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId).detail();
|
||||
|
||||
//}
|
||||
map.put("subString",substring);
|
||||
map.put("ProcessTile",bo_act_coe_publishs.getString("PROCESS_TITLE"));
|
||||
map.put("processInstId",processInstId);
|
||||
map.put("sid",sid);
|
||||
System.out.println("jsonArray=====>>>>>>>>>"+jsonArray);
|
||||
map.put("jsonlist",jsonArray);
|
||||
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
String url = portalUrl + "/r/or?cmd=com.yili_process_page&processInstId=" + processInstId + "&taskInstId=" + taskInstId;
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String sql = "SELECT * FROM WFC_PROCESS WHERE ID ='" + processInstId + "'";
|
||||
List<RowMap> rowMaps = DBSql.getMaps(conn, sql);
|
||||
//if (rowMaps.size()==1){
|
||||
/* for (RowMap rowmp:
|
||||
rowMaps) {
|
||||
jsonObject.put("title",rowmp.getString("PROCESSTITLE"));
|
||||
String endTime = rowmp.getString("ENDTIME");
|
||||
String time = endTime.substring(0,endTime.indexOf(" "));
|
||||
jsonObject.put("date",time);
|
||||
}*/
|
||||
|
||||
jsonObject.put("action", "read");
|
||||
// jsonObject.put("dept",UserContext.fromUID(usercode).getDepartmentModel().getNo());
|
||||
// jsonObject.put("user",usercode);
|
||||
// jsonObject.put("remark","");
|
||||
jsonObject.put("status", "1");
|
||||
// jsonObject.put("pcurl",url);
|
||||
// jsonObject.put("mobileurl",url);
|
||||
|
||||
// jsonObject.put("userList","00345531");
|
||||
HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||||
// String s = httpClientUtil.SendPreview("http://10.119.22.207:80/services/service_lcglpt?wsdl", jsonObject);
|
||||
BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId).detail();
|
||||
List<BO> bo_act_dataid = SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processInstId).list();
|
||||
|
||||
if (bo_act_dataid != null) {
|
||||
String dataid = SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processInstId).addQuery("USER_ID=",usercode).detail().getString("DATAID");
|
||||
jsonObject.put("dataid", dataid);
|
||||
} else {
|
||||
BO test = SDK.getBOAPI().query("BO_EU_TEST", true).addQuery("BINDID=", processInstId).detail();
|
||||
if (test != null) {
|
||||
String dataid = test.getString("DATAID");
|
||||
if (dataid.contains(usercode)) {
|
||||
dataid = dataid.substring(dataid.indexOf(usercode + "","dataid":"") + 40, dataid.indexOf(usercode + "","dataid":"") + 47);
|
||||
dataid = getNumberFromString(dataid);
|
||||
System.out.println("待阅dataid输出" + dataid);
|
||||
}
|
||||
jsonObject.put("dataid", dataid);
|
||||
}
|
||||
}
|
||||
|
||||
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>";
|
||||
//HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||||
System.out.println("HttpClient 发送SOAP请求");
|
||||
HttpClient client = new HttpClient();
|
||||
int timeout = 10000;
|
||||
PostMethod postMethod = new PostMethod("http://10.105.1.59:80/services/service_lcglpt");
|
||||
// 设置连接超时
|
||||
client.getHttpConnectionManager().getParams().setConnectionTimeout(timeout);
|
||||
// 设置读取时间超时
|
||||
client.getHttpConnectionManager().getParams().setSoTimeout(timeout);
|
||||
// 然后把Soap请求数据添加到PostMethod中
|
||||
RequestEntity requestEntity = new StringRequestEntity(xmlStr, "text/xml", "UTF-8");
|
||||
// 设置请求体
|
||||
postMethod.setRequestEntity(requestEntity);
|
||||
int status = client.executeMethod(postMethod);
|
||||
// 打印请求状态码
|
||||
System.out.println("status:" + status);
|
||||
// 获取响应体输入流
|
||||
System.out.println("xmlstr=================" + xmlStr);
|
||||
InputStream is = postMethod.getResponseBodyAsStream();
|
||||
System.out.println("s=================+s" + new String(ByteStreams.toByteArray(is)));
|
||||
//System.out.println("s==============>>>>>>>>>>>"+s);
|
||||
|
||||
//}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
conn.close();
|
||||
}
|
||||
return HtmlPageTemplate.merge("com.awspaas.user.apps.yili.integration",html, map);
|
||||
}
|
||||
|
||||
|
||||
@Mapping("com.yili_process_page_phone")
|
||||
public String processPhone(UserContext me, RequestParams params) throws SQLException {
|
||||
String userMobile = me.getDeviceType();
|
||||
Connection conn = DBSql.open();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
|
||||
String html = "index_phone.html";
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
try{
|
||||
//UserContext uc = UserContext.fromSessionId(sid);
|
||||
String sid = me.getSessionId();
|
||||
String processInstId = params.get("processInstId");
|
||||
String taskInstId = params.get("taskInstId");
|
||||
String usercode = params.get("usercode");
|
||||
StringBuffer sb = new StringBuffer();
|
||||
ProcessInstance instanceById = SDK.getProcessAPI().getInstanceById(processInstId);
|
||||
String sourceAppId = instanceById.getAppId();
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.addons.onlinedoc/filePreview";
|
||||
String substring = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId).detail().getString("RELEASE_INSTRUCTIONS");
|
||||
BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId).detail();
|
||||
|
||||
List<BO> list = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID=", processInstId).list();
|
||||
int num = 1;
|
||||
|
||||
for (BO bo:list) {
|
||||
|
||||
if(StringUtils.isNotEmpty(bo.getString("TASKID"))){
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID"));
|
||||
OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId());
|
||||
if (appProfile==null){
|
||||
throw new AWSException("Not Find OutputAppProfile! profileId=" + "_900fde3255248317266cad1c72f157b1");
|
||||
}
|
||||
DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(), OutputConst.EXT_APP_DC_OUTPUT);
|
||||
if (dcProfile == null)
|
||||
throw new AWSException("Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT);
|
||||
String sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME = '"+bo.getString("PUBLISHFILENAME")+"'";
|
||||
String lever = DBSql.getString(conn, sql_lever);
|
||||
System.out.println("lever====>>>>>"+lever);
|
||||
lever = lever+".0";
|
||||
DCContext dcContext = new DCContext(me, dcProfile, appProfile.getAppContext().getId(), model.getWsId(), bo.getString("TASKID"),bo.getString("PUBLISHFILENAME")+"_"+lever+".doc");
|
||||
|
||||
|
||||
|
||||
// 调用App
|
||||
|
||||
// 参数定义列表
|
||||
Map params_preview = new HashMap<String, Object>();
|
||||
//文档是否允许下载,必填
|
||||
params_preview.put("isDownload", true);
|
||||
//显示文件名,必填
|
||||
params_preview.put("fileNameOriginal", bo.getString("PUBLISHFILENAME")+"_"+lever+".doc");
|
||||
//PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填
|
||||
params_preview.put("isPDFCovertPNG", 0);
|
||||
//groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填
|
||||
params_preview.put("extParams", "");
|
||||
//文档是否允许打印,必填
|
||||
params_preview.put("isPrint", true);
|
||||
//是否显示顶部工具栏的返回按钮,默认显示,非必填
|
||||
params_preview.put("isShowBackbtn", false);
|
||||
//原文件DC,必填
|
||||
params_preview.put("sourceDc", dcContext);
|
||||
//是否显示默认预览工具栏,必填
|
||||
params_preview.put("isShowDefaultToolbar", true);
|
||||
//文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填
|
||||
params_preview.put("isCopy", true);
|
||||
//sessionid,必填
|
||||
params_preview.put("sid", sid);
|
||||
//文档是否加密,必填
|
||||
params_preview.put("isEncrypt", false);
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//文档预览
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params_preview);
|
||||
|
||||
System.out.println("ro>>>>>>>>>>>>>>>>"+ro);
|
||||
String is_not_publish_sql = "SELECT id,PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME ='"+bo.get("PUBLISHFILENAME")+"'";
|
||||
List<RowMap> Row_maps_is_not_publish = DBSql.getMaps(conn, is_not_publish_sql);
|
||||
|
||||
/*boolean havingStartProcessPermission =SDK.getPermAPI().havingStartProcessPermission(uc.getUID(), processDefId);
|
||||
if(havingStartProcessPermission) {*/
|
||||
BigDecimal big=new BigDecimal(Row_maps_is_not_publish.get(0).getString("PLVER"));
|
||||
|
||||
JSONObject jsonObjects = new JSONObject();
|
||||
jsonObjects.put("title",bo.get("PUBLISHFILENAME"));
|
||||
jsonObjects.put("link","https://bpm.yili.com:8088/portal/r"+ro.get("url").toString().substring(1));
|
||||
// jsonObjects.put("size","12k");
|
||||
jsonArray.add(jsonObjects);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where PLNAME= '"+bo.getString("PUBLISHFILENAME")+"'" +
|
||||
")";
|
||||
List<RowMap> maps = DBSql.getMaps(conn,sql_upfile);
|
||||
UserContext userContext = UserContext.fromSessionId(sid);
|
||||
UpfileWeb upfileWeb = new UpfileWeb(userContext);
|
||||
|
||||
for (RowMap row : maps) {
|
||||
UpfileModel upfileModel = new UpfileModel();
|
||||
upfileModel.setType(row.getString("FILETYPE"));
|
||||
upfileModel.setFileName(row.getString("FILENAME"));
|
||||
upfileModel.setPl_uuid(row.getString("PALREPOSITORYID"));
|
||||
upfileModel.setShape_uuid(row.getString("SHAPEID"));
|
||||
DCContext dcContexts = upfileWeb.getDCContext(upfileModel);
|
||||
Map params_previews = new HashMap<String, Object>();
|
||||
//文档是否允许下载,必填
|
||||
params_previews.put("isDownload", true);
|
||||
//显示文件名,必填
|
||||
params_previews.put("fileNameOriginal", row.getString("FILENAME"));
|
||||
//PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填
|
||||
params_previews.put("isPDFCovertPNG", 0);
|
||||
//groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填
|
||||
params_previews.put("extParams", "");
|
||||
//文档是否允许打印,必填
|
||||
params_previews.put("isPrint", true);
|
||||
//是否显示顶部工具栏的返回按钮,默认显示,非必填
|
||||
params_previews.put("isShowBackbtn", "");
|
||||
//原文件DC,必填
|
||||
params_previews.put("sourceDc", dcContexts);
|
||||
//是否显示默认预览工具栏,必填
|
||||
params_previews.put("isShowDefaultToolbar", true);
|
||||
//文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填
|
||||
params_previews.put("isCopy", true);
|
||||
//sessionid,必填
|
||||
params_previews.put("sid", sid);
|
||||
//文档是否加密,必填
|
||||
params_previews.put("isEncrypt", false);
|
||||
AppAPI appAPIs = SDK.getAppAPI();
|
||||
//文档预览
|
||||
ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp, params_previews);
|
||||
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("title",row.getString("FILENAME"));
|
||||
jsonObject1.put("link","https://bpm.yili.com:8088/portal/r"+ros.get("url").toString().substring(1));
|
||||
// jsonObject1.put("size","12k");
|
||||
jsonArray.add(jsonObject1);
|
||||
num++;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
//}
|
||||
System.out.println("substring>>>>>>>>>>"+substring);
|
||||
map.put("subString",substring);
|
||||
map.put("ProcessTile",bo_act_coe_publish.getString("PROCESS_TITLE"));
|
||||
map.put("processInstId",processInstId);
|
||||
map.put("sid",sid);
|
||||
System.out.println("jsonArray=====>>>>>>>>>"+jsonArray);
|
||||
map.put("jsonlist",jsonArray);
|
||||
//DBSql.close(conn);
|
||||
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
String url = portalUrl+"/r/or?cmd=com.yili_process_page&processInstId="+processInstId+"&taskInstId="+taskInstId;
|
||||
String mobileurl = portalUrl+"/r/or?cmd=com.yili_process_page_phone&processInstId="+processInstId+"&taskInstId="+taskInstId;
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String sql = "SELECT * FROM WFC_PROCESS WHERE ID ='"+processInstId+"'";
|
||||
List<RowMap> rowMaps = DBSql.getMaps(conn,sql);
|
||||
if (rowMaps.size()==1){
|
||||
|
||||
jsonObject.put("action","read");
|
||||
//jsonObject.put("dept",me.getDepartmentModel().getNo());
|
||||
// jsonObject.put("user",me.getUID());
|
||||
// jsonObject.put("remark","");
|
||||
jsonObject.put("status","1");
|
||||
//jsonObject.put("pcurl",url);
|
||||
// jsonObject.put("mobileurl",mobileurl);
|
||||
BO bo_act_dataid = SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=", processInstId).addQuery("USER_ID=", usercode).detail();
|
||||
if (bo_act_dataid!=null){
|
||||
jsonObject.put("dataid",bo_act_dataid.getString("DATAID"));
|
||||
}
|
||||
|
||||
//jsonObject.put("userList","00345531");
|
||||
HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||||
// String s = httpClientUtil.SendPreview("http://10.119.22.207:80/services/service_lcglpt?wsdl", jsonObject);
|
||||
|
||||
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>";
|
||||
//HttpClientUtil httpClientUtil = new HttpClientUtil();
|
||||
String s = UtilUrl.doPostSoap("http://10.105.1.59:80/services/service_lcglpt", xmlStr, "");
|
||||
System.out.println("s==============>>>>>>>>>>>"+s);
|
||||
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
conn.close();
|
||||
}
|
||||
return HtmlPageTemplate.merge("com.awspaas.user.apps.yili.integration",html, map);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从 String 中提取数字
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
public static String getNumberFromString(String string){
|
||||
String str = string;
|
||||
str = str.trim();
|
||||
StringBuffer str2 = new StringBuffer();
|
||||
if(str != null && !"".equals(str)) {
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
if (str.charAt(i) >= 48 && str.charAt(i) <= 57) {
|
||||
String s = String.valueOf(str.charAt(i));
|
||||
str2.append(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
return str2.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
package com.awspaas.user.apps.integration.oauth;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
public class WechatApp {
|
||||
// Basic testClient:qwertyuio0987654rfg :: Basic ???
|
||||
static String clientId = "wwb0ae23173b140618";
|
||||
static String clientSecret = "kkuVjcNmkjqvGs36l2L2_p6iJMk0eTsxcKDyydsX36k";
|
||||
|
||||
public String getAccessTokens() {
|
||||
String tokenJson = "";
|
||||
|
||||
//String url = "https://wechat.yili.com/connect/oauth2/authorize?appid=prcmgr&redirect_uri=https://bpm.yili.com:8088/portal//r/or?cmd=com.yili_form_page_open&oauthName=oauthLogin&processInstId=274157ca-cd16-47bc-b055-f440d2ff718f&taskInstId=5ad2abeb-25ce-4388-a7b3-92572ed4b389&casaccount=10056870&validcode=8d62447812dbfd5ef4727fb8b8c05ecf&fromsys=OA&response_type=code&scope=SCOPE&agentid=AGENTID&state=STATE#wechat_redirect";
|
||||
|
||||
String url = "https://wechat.yili.com/cgi-bin/gettoken?corpid="+clientId+"&corpsecret="+clientSecret;
|
||||
|
||||
HashMap<String, String> HeaderMap = new HashMap();
|
||||
//HeaderMap.put("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
|
||||
tokenJson = HttpJavaUtil.doPost(url, "", HeaderMap);
|
||||
System.out.println(tokenJson);
|
||||
return tokenJson;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// http://cs.idm.yili.com:7777/ms_oauth/oauth2/endpoints/oauthservice/tokens?redirect_uri=http://192.168.88.100:8080/ecs-console/&grant_type=authorization_code&code=
|
||||
// 获取授权Token接口(authorization_code模式)
|
||||
public String getTokens( String code) {
|
||||
String tokenJson = "";
|
||||
|
||||
//String url = "https://wechat.yili.com/connect/oauth2/authorize?appid=prcmgr&redirect_uri=https://bpm.yili.com:8088/portal//r/or?cmd=com.yili_form_page_open&oauthName=oauthLogin&processInstId=274157ca-cd16-47bc-b055-f440d2ff718f&taskInstId=5ad2abeb-25ce-4388-a7b3-92572ed4b389&casaccount=10056870&validcode=8d62447812dbfd5ef4727fb8b8c05ecf&fromsys=OA&response_type=code&scope=SCOPE&agentid=AGENTID&state=STATE#wechat_redirect";
|
||||
String accessTokens = getAccessTokens();
|
||||
JSONObject jsonObjects = JSONObject.parseObject(accessTokens);
|
||||
String access_token = jsonObjects.getString("access_token");
|
||||
String url = "https://wechat.yili.com/cgi-bin/user/getuserinfo?access_token="+access_token+"&code="+code;
|
||||
System.out.println("url======>>>>>"+url);
|
||||
HashMap<String, String> HeaderMap = new HashMap();
|
||||
HeaderMap.put("grant_type", "aauthorization_code");
|
||||
|
||||
tokenJson = HttpJavaUtil.doPost(url, "", HeaderMap);
|
||||
System.out.println(tokenJson);
|
||||
return tokenJson;
|
||||
|
||||
}
|
||||
|
||||
public String getUserInfo(String token) {
|
||||
String userInfoJson = "";
|
||||
String url = "https://idm.yili.com:7777/ms_oauth/resources/userprofile/me";
|
||||
|
||||
String authoStr = token;
|
||||
HashMap<String, String> HeaderMap = new HashMap();
|
||||
HeaderMap.put("Content-Type", "application/x-www-form-urlencoded");
|
||||
HeaderMap.put("Authorization", authoStr);
|
||||
HeaderMap.put("accept", "*/*");
|
||||
HeaderMap.put("connection", "Keep-Alive");
|
||||
|
||||
// do request get
|
||||
userInfoJson = HttpJavaUtil.doGet(url, HeaderMap);
|
||||
System.out.println(userInfoJson);
|
||||
return userInfoJson;
|
||||
}
|
||||
|
||||
public String geAuthorization(String clientId, String clientSecret) {
|
||||
try {
|
||||
byte[] key = (clientId + ":" + clientSecret).getBytes("utf-8");
|
||||
String cc = new String(Base64.encodeBase64(key), "utf-8");
|
||||
// String cc = new String(java.util.Base64.getEncoder().encode(key), "utf-8");
|
||||
return "Basic " + cc;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,128 @@
|
||||
package com.awspaas.user.apps.integration.oauth;
|
||||
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.commons.oauth.AbstractOauth;
|
||||
import com.actionsoft.bpms.server.RequestParams;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.LogAPI;
|
||||
import com.actionsoft.sdk.local.api.Logger;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yili.wsclient.ClientService;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* OA系统 跳转登陆PAl
|
||||
*
|
||||
* @author lihy
|
||||
*/
|
||||
|
||||
public class WechatOauthLogin extends AbstractOauth {
|
||||
private Logger logger = LogAPI.getLogger(WechatOauthLogin.class);
|
||||
|
||||
//static String clientId = "testClient";
|
||||
//static String clientSecret = "1234567890";
|
||||
/**
|
||||
* 这个方法代表是否有登录授权页,返回的值取决于三方系统提供的 SSO 认证方式。一类认 证方式如 Oauth2.0
|
||||
* 认证,需要先跳转到三方系统的登录授权页面,授权成功后再跳转到调 用方指定的页面,这类认证方式下,hasOauthPage()方法需要返回 true。
|
||||
* 另外一类认证时不 需要跳转到登录授权页, 会直接传过来 ticket 或者 token 参数, hasOauthPage()方法需要返 回 false。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean hasOauthPage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果 hasOauthPage()方法返回的值是 false, 返回 null 即可。 如果 hasOauthPage()方法返回 的值是
|
||||
* true,则此处返回三方系统的登录授权页地址。
|
||||
* @param requestParams
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getOauthPage(RequestParams requestParams) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String validate(RequestParams params) throws IOException {
|
||||
|
||||
|
||||
logger.info("企业微信单点登录单点登录验证---------"+params);
|
||||
try {
|
||||
String redirect_uri = params.get("code");
|
||||
System.out.println("code=====>>>>>"+redirect_uri);
|
||||
if(StringUtils.isEmpty(redirect_uri)){
|
||||
logger.error("跳转地址为空,请重新输入");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
WechatApp app = new WechatApp();
|
||||
String tokens = app.getTokens(redirect_uri);
|
||||
if(StringUtils.isEmpty(tokens)){
|
||||
logger.error("获取token为空,请重新输入登录信息获取code");
|
||||
return null;
|
||||
}else {
|
||||
JSONObject jsonObjects = JSONObject.parseObject(tokens);
|
||||
String access_token = jsonObjects.getString("UserId");
|
||||
|
||||
if (StringUtils.isNotEmpty(access_token)){
|
||||
UserContext userContext = UserContext.fromUID(access_token);
|
||||
if (userContext!=null){
|
||||
return access_token;
|
||||
}else{
|
||||
BO detail = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("LOGINID=", access_token).detail();
|
||||
String workcode = detail.getString("WORKCODE");
|
||||
if (workcode.length()!=8){
|
||||
return "00"+workcode;
|
||||
}else{
|
||||
return params.get("htcode");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("统一身份认证失败!", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一身份认证接口
|
||||
* @param1 webserviceUrl 身份认证接口地址
|
||||
* @param2 casaccount 登录账号 OA账号
|
||||
* @param3 appaccount 应用系统登录账号
|
||||
* @param4 appid 应用系统id
|
||||
* @param5 validcode 验证码
|
||||
* @return true/false
|
||||
*/
|
||||
public static String getToken(String casaccount,String appaccount,String appid,String validcode) {
|
||||
//身份认证接口地址
|
||||
String webserviceUrl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "webserviceUrl");
|
||||
String checkLogin = ClientService.checkLogin(webserviceUrl,casaccount,appaccount,appid,validcode);
|
||||
return checkLogin ;
|
||||
}
|
||||
|
||||
|
||||
public static String geAuthorization(String clientId, String clientSecret) {
|
||||
try {
|
||||
byte[] key = (clientId + ":" + clientSecret).getBytes("utf-8");
|
||||
String cc = new String(Base64.encodeBase64(key), "utf-8");
|
||||
// String cc = new String(java.util.Base64.getEncoder().encode(key), "utf-8");
|
||||
return "Basic " + cc;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.awspaas.user.apps.integration.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.actionsoft.apps.listener.PluginListener;
|
||||
import com.actionsoft.apps.resource.AppContext;
|
||||
import com.actionsoft.apps.resource.plugin.profile.AWSPluginProfile;
|
||||
import com.actionsoft.apps.resource.plugin.profile.OauthPluginProfile;
|
||||
import com.actionsoft.apps.resource.plugin.profile.ProcessPublicEventPluginProfile;
|
||||
import com.awspaas.user.apps.integration.oa.TaskListener;
|
||||
import com.awspaas.user.apps.integration.oauth.OauthLogin;
|
||||
import com.awspaas.user.apps.integration.oauth.WechatOauthLogin;
|
||||
|
||||
/**
|
||||
* @author LHY
|
||||
*/
|
||||
public class Plugins implements PluginListener {
|
||||
@Override
|
||||
public List<AWSPluginProfile> register(AppContext context) {
|
||||
List<AWSPluginProfile> list = new ArrayList<>();
|
||||
|
||||
//注册监听器
|
||||
//注册外部系统跳转PAL系统 登陆插件
|
||||
list.add(new ProcessPublicEventPluginProfile(TaskListener.class.getName(), "待办推送监听器"));
|
||||
list.add(new OauthPluginProfile("oauthLogin", OauthLogin.class.getName(), "OA系统 跳转登陆PAl"));
|
||||
list.add(new OauthPluginProfile("WechatOauthLogin", WechatOauthLogin.class.getName(), "企业微信认证"));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,138 @@
|
||||
package com.awspaas.user.apps.integration.util;
|
||||
|
||||
import com.awspaas.user.apps.integration.XmlDatasUtil;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import org.apache.commons.httpclient.*;
|
||||
import org.apache.commons.httpclient.methods.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class HttpClientUtil {
|
||||
|
||||
|
||||
|
||||
public String SendPend(String url, XmlDatasUtil xmlDatasUtil) throws IOException {
|
||||
String result = "true";
|
||||
StringBuffer sendSoapString = new StringBuffer();
|
||||
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:com=\"com.synctooa.webservices\">\n" +
|
||||
" <soapenv:Header/>\n" +
|
||||
" <soapenv:Body>\n" +
|
||||
" <com:InsertTodoCominfo>\n" +
|
||||
" <com:in0>\n" +
|
||||
"<![CDATA[ \n" +
|
||||
"<?xml version='1.0' encoding='UTF-8'?>\n" +
|
||||
"<root>\n" +
|
||||
" <Todo>\n" +
|
||||
" <outsysid>"+ xmlDatasUtil.getExternal_system_ID() +"</outsysid>\n" +
|
||||
" <todoid>"+ xmlDatasUtil.getOther_system_to_do_ID() +"</todoid>\n" +
|
||||
" <content>"+ xmlDatasUtil.getProcess_title() +"</content>\n" +
|
||||
" <pcurl>"+ xmlDatasUtil.getPcurl() + "</pcurl>\n" +
|
||||
" <mobileurl>"+ xmlDatasUtil.getMobileurl() +"</mobileurl>\n" +
|
||||
" <hrcode>"+ xmlDatasUtil.getTo_do_login_account() +"</hrcode>\n" +
|
||||
" <createtime>"+ xmlDatasUtil.getTo_do_creation_time() +"</createtime>\n" +
|
||||
" <donetime>"+ xmlDatasUtil.getTo_do_completion_time() +"</donetime>\n" +
|
||||
" <status>"+ xmlDatasUtil.getTo_do_status() +"</status>\n" +
|
||||
" <wftype>"+ xmlDatasUtil.getTo_do_official_type() +"</wftype>\n" +
|
||||
" <viewtype>"+ xmlDatasUtil.getViewtype() +"</viewtype>\n" +
|
||||
" <createdate>"+ xmlDatasUtil.getCreatedate() +"</createdate>\n" +
|
||||
" <donedate>"+ xmlDatasUtil.getDonedate() +"</donedate>\n" +
|
||||
" <receivedate>"+ xmlDatasUtil.getReceivedate() +"</receivedate>\n" +
|
||||
" <receivetime>" + xmlDatasUtil.getReceivetime() +"</receivetime>\n" +
|
||||
" <currentnodetype>"+ xmlDatasUtil.getCurrentnodetype() +"</currentnodetype>\n" +
|
||||
" <requestcode>"+ xmlDatasUtil.getRequestcode() +"</requestcode>\n" +
|
||||
" <currentnodename>"+ xmlDatasUtil.getCurrentnodename() +"</currentnodename>\n" +
|
||||
" <nooperator>"+ xmlDatasUtil.getNooperator() +"</nooperator>\n" +
|
||||
" <workcode>"+ xmlDatasUtil.getWorkcode() +"</workcode>\n" +
|
||||
" <workflowname>"+ xmlDatasUtil.getWorkflowname() +"</workflowname>\n" +
|
||||
" <createrhrcode>"+ xmlDatasUtil.getCreaterhrcode() +"</createrhrcode>\n" +
|
||||
" <createrworkcode>"+ xmlDatasUtil.getCreaterworkcode() +"</createrworkcode>\n" +
|
||||
" </Todo>\n" +
|
||||
"</root>\n" +
|
||||
"]]>\n" +
|
||||
"</com:in0>\n" +
|
||||
" </com:InsertTodoCominfo>\n" +
|
||||
" </soapenv:Body>\n" +
|
||||
"</soapenv:Envelope>";
|
||||
|
||||
System.out.println("xmlstr================"+xmlStr);
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
int timeout = 10000;
|
||||
|
||||
PostMethod postMethod = new PostMethod(url);
|
||||
// 设置连接超时
|
||||
client.getHttpConnectionManager().getParams().setConnectionTimeout(timeout);
|
||||
// 设置读取时间超时
|
||||
client.getHttpConnectionManager().getParams().setSoTimeout(timeout);
|
||||
// 然后把Soap请求数据添加到PostMethod中
|
||||
//RequestEntity requestEntity = new StringRequestEntity(xmlStr, "text/xml", "UTF-8");
|
||||
RequestEntity re = new StringRequestEntity(xmlStr, "text/xml", "utf-8");
|
||||
|
||||
// 设置请求体
|
||||
postMethod.setRequestHeader("SOAPAction", "");
|
||||
postMethod.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
|
||||
postMethod.setRequestEntity(re);
|
||||
int status = client.executeMethod(postMethod);
|
||||
// 打印请求状态码
|
||||
System.out.println("status:" + status);
|
||||
// 获取响应体输入流
|
||||
InputStream iss = postMethod.getResponseBodyAsStream();
|
||||
|
||||
|
||||
|
||||
/*try {
|
||||
int statusCode = httpClient.executeMethod(postMethod);
|
||||
System.out.println("statusCode==================="+statusCode);
|
||||
if (statusCode == 200) {
|
||||
String soapResponseData = postMethod.getResponseBodyAsString();
|
||||
return soapResponseData.indexOf("Success") == -1 ? "fail" : result;
|
||||
} else {
|
||||
return "error:[" + statusCode + "]!";
|
||||
}
|
||||
} catch (Exception var15) {
|
||||
var15.printStackTrace();
|
||||
return "Exception:[" + var15 + "]!";
|
||||
*/
|
||||
return new String(ByteStreams.toByteArray(iss));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String SendPreview(String url, String xmlStr) {
|
||||
String result = "true";
|
||||
|
||||
|
||||
PostMethod postMethod = new PostMethod(url);
|
||||
StringBuffer soapRequestData = new StringBuffer(xmlStr);
|
||||
byte[] b = (byte[])null;
|
||||
|
||||
try {
|
||||
b = soapRequestData.toString().getBytes("utf-8");
|
||||
} catch (UnsupportedEncodingException var16) {
|
||||
var16.printStackTrace();
|
||||
}
|
||||
|
||||
InputStream is = new ByteArrayInputStream(b, 0, b.length);
|
||||
RequestEntity re = new InputStreamRequestEntity(is, (long)b.length, "text/xml; charset=utf-8");
|
||||
postMethod.setRequestEntity(re);
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.setConnectionTimeout(500000000);
|
||||
httpClient.setTimeout(500000000);
|
||||
|
||||
try {
|
||||
int statusCode = httpClient.executeMethod(postMethod);
|
||||
if (statusCode == 200) {
|
||||
String soapResponseData = postMethod.getResponseBodyAsString();
|
||||
return soapResponseData.indexOf("Success") == -1 ? "fail" : result;
|
||||
} else {
|
||||
return "error:[" + statusCode + "]!";
|
||||
}
|
||||
} catch (Exception var15) {
|
||||
var15.printStackTrace();
|
||||
return "Exception:[" + var15 + "]!";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
package com.awspaas.user.apps.integration.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PreviewDataUtil {
|
||||
|
||||
String action; //固定值"read"
|
||||
String title; //标题
|
||||
String dept;//发布机构(部门编码)
|
||||
String user; //发布人(员工编码)
|
||||
String date; //发布日期 yyyy-MM-dd
|
||||
String remark;//备注
|
||||
String status;//发布状态 0未读、1已读
|
||||
String pcurl;//PC端链接地址
|
||||
String mobileurl;//移动端链接地址
|
||||
String dataid;//未读更新为已读时必填
|
||||
List userList;//接收人 string数组
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDept() {
|
||||
return dept;
|
||||
}
|
||||
|
||||
public void setDept(String dept) {
|
||||
this.dept = dept;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getPcurl() {
|
||||
return pcurl;
|
||||
}
|
||||
|
||||
public void setPcurl(String pcurl) {
|
||||
this.pcurl = pcurl;
|
||||
}
|
||||
|
||||
public String getMobileurl() {
|
||||
return mobileurl;
|
||||
}
|
||||
|
||||
public void setMobileurl(String mobileurl) {
|
||||
this.mobileurl = mobileurl;
|
||||
}
|
||||
|
||||
public String getDataid() {
|
||||
return dataid;
|
||||
}
|
||||
|
||||
public void setDataid(String dataid) {
|
||||
this.dataid = dataid;
|
||||
}
|
||||
|
||||
public List getUserList() {
|
||||
return userList;
|
||||
}
|
||||
|
||||
public void setUserList(List userList) {
|
||||
this.userList = userList;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package com.awspaas.user.apps.integration.util;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.*;
|
||||
|
||||
public class SoapUtil {
|
||||
|
||||
|
||||
public static String getWebServiceAndSoap(String url,StringBuffer sendSoapString) throws IOException {
|
||||
String soap = sendSoapString.toString();
|
||||
if (soap == null) {
|
||||
return null;
|
||||
}
|
||||
URL soapUrl = new URL(url);
|
||||
URLConnection conn = soapUrl.openConnection();
|
||||
conn.setUseCaches(false);
|
||||
conn.setDoInput(true);
|
||||
conn.setDoOutput(true);
|
||||
conn.setRequestProperty("Content-Length",
|
||||
Integer.toString(soap.length()));
|
||||
conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
|
||||
// 调用的接口方法是
|
||||
// conn.setRequestProperty(isClass,isMethod);
|
||||
OutputStream os = conn.getOutputStream();
|
||||
OutputStreamWriter osw = new OutputStreamWriter(os, "utf-8");
|
||||
osw.write(soap);
|
||||
osw.flush();
|
||||
osw.close();
|
||||
// 获取webserivce返回的流
|
||||
InputStream is = conn.getInputStream();
|
||||
if (is!=null) {
|
||||
byte[] bytes = new byte[0];
|
||||
bytes = new byte[is.available()];
|
||||
is.read(bytes);
|
||||
String str = new String(bytes);
|
||||
return str;
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package com.awspaas.user.apps.integration.util;
|
||||
|
||||
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(600000)
|
||||
.setConnectTimeout(600000).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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user