package cn.autoform.web.client.impl;
|
|
import cn.autoform.db.entity.IpAndPortEntity;
|
import cn.autoform.db.exten.Process;
|
import cn.autoform.util.thread.Keys;
|
import cn.autoform.util.thread.ThreadData;
|
import cn.autoform.util.tool.JSONTool;
|
import cn.autoform.web.client.WorkflowClient;
|
import cn.autoform.web.client.util.HttpClientTool;
|
import cn.autoform.web.client.util.IpAndPortTool;
|
import cn.autoform.web.mapper.process.ProcessInstanceMapper;
|
import com.alibaba.fastjson.TypeReference;
|
import com.iemsoft.framework.cloud.core.tools.http.Http;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.io.IOException;
|
import java.util.Collections;
|
import java.util.HashMap;
|
import java.util.Map;
|
import java.util.concurrent.TimeoutException;
|
@Slf4j
|
@Service
|
public class WorkflowClientImpl implements WorkflowClient {
|
|
@Value("${autoForm.processSystem}")
|
private String ProcessClient;
|
|
private static final Map<String,String> ipMap = new HashMap<>();
|
|
/**
|
* 用于保存流程实例
|
*/
|
@Resource
|
private ProcessInstanceMapper processInstanceMapper;
|
|
|
|
static {
|
ipMap.put("definedelete", "%s/ubp/ubp-api-control/process/def/delete");
|
ipMap.put("definedeploy", "%s/ubp/ubp-api-control/process/def/deploy");
|
ipMap.put("defineseache", "%s/ubp/ubp-api-seache/process/def/seache");
|
ipMap.put("definecreate", "%s/ubp/ubp-api-control/process/def/create");
|
|
ipMap.put("instback", "%s/ubp/ubp-api-control/process/inst/back");
|
ipMap.put("agentcreat", "%s/ubp/ubp-api-control/process/create/agent");
|
ipMap.put("instcreate", "%s/ubp/ubp-api-control/process/inst/create");
|
ipMap.put("autoFinish", "%s/ubp/ubp-api-control/process/inst/autofinish");
|
ipMap.put("instdrawback", "%s/ubp/ubp-api-control/process/inst/drawBack");
|
ipMap.put("instover", "%s/ubp/ubp-api-control/process/inst/over");
|
ipMap.put("chargecreate", "%s/ubp/ubp-api-control/process/create/charge");
|
ipMap.put("instfinish", "%s/ubp/ubp-api-control/process/inst/otherfinish");
|
ipMap.put("instseachehandle", "%s/ubp/ubp-api-seache/process/inst/seache/handle");
|
ipMap.put("instlog", "%s/ubp/ubp-api-seache/process/inst/log");
|
ipMap.put("getback", "%s/ubp/ubp-api-seache/process/get/back");
|
ipMap.put("instagent", "%s/ubp/ubp-api-seache/process/inst/agent");
|
ipMap.put("instagentdefmsg", "%s/ubp/ubp-api-seache/process/inst/agent/defMsg");
|
ipMap.put("instseache", "%s/ubp/ubp-api-seache/process/inst/seache");
|
ipMap.put("querypeople", "%s/ubp/ubp-api-seache/process/inst/querypeople");
|
ipMap.put("setp", "%s/ubp/ubp-api-control/process/inst/setp");
|
|
ipMap.put("appcreate", "%s/ubp/ubp-api-control/process/app/create");
|
ipMap.put("getSystem", "%s/ubp/process-system/system/userInfo");
|
|
ipMap.put("initialization", "%s/ubp/ubp-api-control/process/rest/initialization");
|
ipMap.put("check", "%s/ubp/ubp-api-control/process/rest/check");
|
}
|
|
@Autowired
|
IpAndPortTool ipAndPortTool;
|
|
/**
|
* 返回安全登录码
|
*/
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> getSystem(Process process) throws TimeoutException, IOException {
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("getSystem"), ipAndPortEntity.getIp()));
|
System.out.println("IP:"+String.format(ipMap.get("getSystem"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
System.out.println("参数:"+JSONTool.toJson(process.getFlowmap()));
|
Map<String,Object> cookie = new HashMap();
|
cookie.put("token",ThreadData.get(Keys.TOKEN));
|
cookie.put("openId",ThreadData.get(Keys.OPEN_ID));
|
cookie.put("companyId", ThreadData.get(Keys.COMPANY_ID));
|
cookie.put("appId", 1);
|
cookie.put("tenantId",ThreadData.get(Keys.TENANT_ID));
|
hc.setCookie(cookie);
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> defineDelete(Process process) throws TimeoutException {
|
// TODO 删除流程定义
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("definedelete"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> definePeploy(Process process) throws TimeoutException {
|
// TODO 部署流程定义
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("definedeploy"), ipAndPortEntity.getIp()));
|
System.out.println("最后的参数:"+JSONTool.toJson(process.getFlowmap()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> defineSeache(Process process) throws TimeoutException {
|
// TODO 流程定义分页查询
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("defineseache"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> defineCreate(Process process) throws TimeoutException {
|
// TODO 创建流程定义
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
System.out.println("IP:"+JSONTool.toJson(ipAndPortEntity));
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("definecreate"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, String> instBack(Process process) throws TimeoutException {
|
// TODO 退回流程实例
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("instback"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, String> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, String>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> agentCreat(Process process) throws TimeoutException {
|
// TODO 设置代理
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("agentcreat"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> instCreat(Process process) throws TimeoutException {
|
// TODO 创建流程实例
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
return (Map<String, Object>)
|
Http.post(String.format(ipMap.get("instcreate"), ipAndPortEntity.getIp()), Map.class)
|
.addUrlParam(process.getFlowmap())
|
.execute(new TypeReference<Map<String, Object>>(){}.getType())
|
.orElse(Collections.emptyMap());
|
}
|
|
@Override
|
public Map<String, Object> autoFinish(Process process) {
|
// TODO 创建流程实例并执行第一个活动
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
return (Map<String, Object>)
|
Http.post(String.format(ipMap.get("autoFinish"), ipAndPortEntity.getIp()), Map.class)
|
.addUrlParam(process.getFlowmap())
|
.execute(new TypeReference<Map<String, Object>>(){}.getType())
|
.orElse(Collections.emptyMap());
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> instDrawBack(Process process) throws TimeoutException {
|
// TODO 撤销流程实例
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("instdrawback"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> instOver(Process process) throws TimeoutException {
|
// TODO 结束流程实例
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("instover"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> chargeCreate(Process process) throws TimeoutException {
|
// TODO 设置代办
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("chargecreate"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> instFinish(Process process) throws TimeoutException {
|
// TODO 执行流程实例
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
return (Map<String, Object>)
|
Http.post(String.format(ipMap.get("instfinish"), ipAndPortEntity.getIp()), Map.class)
|
.addUrlParam(process.getFlowmap())
|
.execute(new TypeReference<Map<String, Object>>(){}.getType())
|
.orElse(Collections.emptyMap());
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> instSeacheHandle(Process process) throws TimeoutException {
|
// TODO 查询流程待办
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
return (Map<String, Object>)
|
Http.post(String.format(ipMap.get("instseachehandle"), ipAndPortEntity.getIp()), Map.class)
|
.addUrlParam(process.getFlowmap())
|
.execute(new TypeReference<Map<String, Object>>(){}.getType())
|
.orElse(Collections.emptyMap());
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> instLog(Process process) throws TimeoutException {
|
// TODO 流程实例log(参数为空即查询所有)
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("instlog"), ipAndPortEntity.getIp()));
|
System.out.println("IP"+String.format(ipMap.get("instlog"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> getBack(Process process) throws TimeoutException {
|
// TODO 获取所有可退回项目
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("getback"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> instAgent(Process process) throws TimeoutException {
|
// TODO 查询代理(参数为空即查询所有信息)
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("instagent"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> instAgentDefMsg(Process process) throws TimeoutException {
|
// TODO 查询代理去除流程定义信息
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("instagentdefmsg"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> instSeache(Process process) throws TimeoutException {
|
// TODO 查询流程实例(参数都为空,即查询所有)
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("instseache"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> appCreate(Process process) throws TimeoutException {
|
// TODO 租户注册系统
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("appcreate"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
}
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> initialization(Process process) throws TimeoutException {
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("initialization"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> check(Process process) throws TimeoutException {
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("check"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
|
}
|
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> querypeople(Process process) throws TimeoutException {
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("querypeople"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
|
}
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Override
|
public Map<String, Object> setp(Process process) throws TimeoutException {
|
IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(ProcessClient);
|
HttpClientTool<Map> hc = new HttpClientTool(String.format(ipMap.get("setp"), ipAndPortEntity.getIp()));
|
hc.setBodyInfos(HttpClientTool.getUrlEntity(process.getFlowmap()));
|
Map<String, Object> hcData = hc.sendPost(j->JSONTool.toObj(j, new TypeReference<Map<String, Object>>(){}));
|
return hcData;
|
|
}
|
|
|
}
|