Commit a8c7b7d9 authored by chenhao's avatar chenhao

删除common中的remoteWorkflowService代码

parent 4ed0ef43
package com.yeejoin.amos.boot.biz.common.workflow;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.biz.common.workflow.business.util.HttpUtil;
import com.yeejoin.amos.boot.biz.common.workflow.constants.XJConstant;
import com.yeejoin.amos.boot.biz.common.workflow.enums.WorkFlowUriEnum;
import com.yeejoin.amos.boot.biz.common.workflow.enums.YesOrNoEnum;
@Service("remoteWorkFlowService")
public class RemoteWorkFlowService {
private final Logger logger = LoggerFactory.getLogger(RemoteWorkFlowService.class);
@Value("${params.work.flow.address}")
private String address;
@Value("${params.work.flow.processDefinitionKey}")
private String processDefinitionKey;
private String buildUrl(String address, WorkFlowUriEnum workFlowUriEnum, Map<String, String> map) {
String uri = workFlowUriEnum.getUri();
String params = workFlowUriEnum.getParams();
if (!StringUtils.isEmpty(params) && map != null) {
String[] paramsArr = params.split(",");
for (String param : paramsArr) {
uri = uri.replace("{" + param + "}", map.get(param));
}
}
return address + uri;
}
private JSONObject handleResult(String resultStr) {
if (resultStr == null) {
return null;
}
JSONObject json = JSON.parseObject(resultStr);
if ("200".equals(json.getString("code"))) {
return json;
}
return null;
}
public JSONObject start(String businessKey, String processDefinitionKey) {
String url = buildUrl(address, WorkFlowUriEnum.启动流程, null);
JSONObject body = new JSONObject();
body.put("businessKey", businessKey);
body.put("processDefinitionKey", processDefinitionKey);
String resultStr = HttpUtil.sendHttpPostJson(url, body.toJSONString());
return handleResult(resultStr);
}
public JSONObject getChildNodeDetail(String instanceId) {
Map<String, String> map = Maps.newHashMap();
map.put("instanceId", instanceId);
String url = buildUrl(address, WorkFlowUriEnum.子节点信息, map);
Map<String, String> headerMap = Maps.newHashMap();
headerMap.put(XJConstant.TOKEN_KEY, RequestContext.getToken());
headerMap.put(XJConstant.PRODUCT, RequestContext.getProduct());
headerMap.put(XJConstant.APPKEY, RequestContext.getAppKey());
String resultStr = HttpUtil.sendHttpGetWithHeader(url, headerMap);
logger.info("\r\n请求路径=======================>" + url + "\r\n请求参数=======================>" + instanceId + "\r\n返回参数=======================>" + resultStr);
return handleResult(resultStr);
}
public JSONObject start(Long dangerId, String businessKey, String processDefinitionKey) {
String url = buildUrl(address, WorkFlowUriEnum.启动流程, null);
Map<String, String> headerMap = Maps.newHashMap();
headerMap.put(XJConstant.TOKEN_KEY, RequestContext.getToken());
headerMap.put(XJConstant.PRODUCT, RequestContext.getProduct());
headerMap.put(XJConstant.APPKEY, RequestContext.getAppKey());
JSONObject body = new JSONObject();
body.put("businessKey", businessKey);
body.put("processDefinitionKey", processDefinitionKey);
JSONArray variables = new JSONArray();
// JSONObject companyJson = new JSONObject();
// companyJson.put("name", "companyId");
// companyJson.put("value", companyId);
// JSONObject departmentJson = new JSONObject();
// departmentJson.put("name", "departmentId");
// departmentJson.put("value", departmentId);
JSONObject dangerIdJson = new JSONObject();
// dangerIdJson.put("name", "dangerId");
dangerIdJson.put("dangerId", dangerId);
// variables.add(companyJson);
// variables.add(departmentJson);
// variables.add(dangerIdJson);
// body.put("variables", variables);
// String requestBody = body.toJSONString();
body.put("variables", dangerIdJson);
String resultStr = HttpUtil.sendHttpPostJsonWithHeader(url, body.toJSONString(), headerMap);
logger.info("\r\n请求路径=======================>" + url + "\r\n请求参数=======================>" + body + "\r\n返回参数=======================>" + resultStr);
return JSON.parseObject(resultStr);
}
public JSONObject startWithAppKey(JSONObject body) {
Map<String, String> map = Maps.newHashMap();
map.put(XJConstant.TOKEN_KEY, RequestContext.getToken());
map.put(XJConstant.PRODUCT, RequestContext.getProduct());
map.put(XJConstant.APPKEY, RequestContext.getAppKey());
String url = buildUrl(address, WorkFlowUriEnum.启动免登录流程, map);
String requestBody = body.toJSONString();
String resultStr = HttpUtil.sendHttpPostJson(url, requestBody);
logger.info("\r\n请求路径=======================>" + url + "\r\n请求参数=======================>" + requestBody + "\r\n返回参数=======================>" + resultStr);
return handleResult(resultStr);
}
public JSONObject startNew(Long dangerId, String businessKey, String processDefinitionKey) {
String url = buildUrl(address, WorkFlowUriEnum.合并启动流程, null);
Map<String, String> headerMap = Maps.newHashMap();
headerMap.put(XJConstant.TOKEN_KEY, RequestContext.getToken());
headerMap.put(XJConstant.PRODUCT, RequestContext.getProduct());
headerMap.put(XJConstant.APPKEY, RequestContext.getAppKey());
JSONObject body = new JSONObject();
body.put("businessKey", businessKey);
body.put("processDefinitionKey", processDefinitionKey);
JSONObject dangerIdJson = new JSONObject();
dangerIdJson.put("dangerId", dangerId);
body.put("variables", dangerIdJson);
String resultStr = HttpUtil.sendHttpPostJsonWithHeader(url, body.toJSONString(), headerMap);
logger.info("\r\n请求路径=======================>" + url + "\r\n请求参数=======================>" + body + "\r\n返回参数=======================>" + resultStr);
return JSON.parseObject(resultStr);
}
// public JSONObject stop(String processInstanceId, String deleteReason) {
// Map<String, String> map = Maps.newHashMap();
// map.put("deleteReason", deleteReason);
// map.put("processInstanceId", processInstanceId);
// String url = buildUrl(address, WorkFlowUriEnum.终止流程, map);
// String resultStr = HttpUtil.sendHttpDelete(url);
// JSONObject json = handleResult(resultStr);
// logger.info("\r\n终止流程请求路径=======================>" + url + "\r\n终止流程返回参数=======================>" + resultStr);
// return json;
// }
public JSONObject stop(String processInstanceId) {
Map<String, String> map = Maps.newHashMap();
// map.put("deleteReason", deleteReason);
map.put("processInstanceId", processInstanceId);
Map<String, String> headerMap = Maps.newHashMap();
headerMap.put(XJConstant.TOKEN_KEY, RequestContext.getToken());
headerMap.put(XJConstant.PRODUCT, RequestContext.getProduct());
headerMap.put(XJConstant.APPKEY, RequestContext.getAppKey());
String url = buildUrl(address, WorkFlowUriEnum.终止流程, map);
String resultStr = HttpUtil.sendHttpDeleteWithHeader(url, headerMap);
JSONObject json = handleResult(resultStr);
logger.info("\r\n请求路径=======================>" + url + "\r\n返回参数=======================>" + resultStr);
return json;
}
// public JSONObject excute(String taskId, String requestBody) {
// Map<String, String> map = Maps.newHashMap();
// map.put("taskId", taskId);
// String url = buildUrl(address, WorkFlowUriEnum.执行流程, map);
// String resultStr = HttpUtil.sendHttpPostJson(url, requestBody);
// JSONObject json = handleResult(resultStr);
// logger.info("\r\n执行任务请求路径=======================>" + url + "\r\n执行任务请求参数=======================>" + requestBody + "\r\n执行任务返回参数=======================>" + resultStr);
// return json;
// }
public JSONObject excute(String taskId, String requestBody) {
Map<String, String> map = Maps.newHashMap();
map.put("taskId", taskId);
Map<String, String> headerMap = Maps.newHashMap();
headerMap.put(XJConstant.TOKEN_KEY, RequestContext.getToken());
headerMap.put(XJConstant.PRODUCT, RequestContext.getProduct());
headerMap.put(XJConstant.APPKEY, RequestContext.getAppKey());
String url = buildUrl(address, WorkFlowUriEnum.执行流程, map);
String resultStr = HttpUtil.sendHttpPostJsonWithHeader(url, requestBody, headerMap);
JSONObject json = handleResult(resultStr);
logger.info("\r\n请求路径=======================>" + url + "\r\n请求参数=======================>" + requestBody + "\r\n返回参数=======================>" + resultStr);
return json;
}
public JSONObject currentTask(String instanceId) {
Map<String, String> map = Maps.newHashMap();
map.put("processInstanceId", instanceId);
String url = buildUrl(address, WorkFlowUriEnum.当前节点, map);
String resultStr = HttpUtil.sendHttpGet(url);
JSONObject json = handleResult(resultStr);
logger.info("\r\n当前任务请求路径=======================>" + url + "\r\n当前任务返回参数=======================>" + resultStr);
if (json == null) {
return null;
}
JSONArray reviewContent = json.getJSONObject("dataList").getJSONArray("content");
if (reviewContent != null && reviewContent.size() > 0) {
return reviewContent.getJSONObject(0);
}
return null;
}
public JSONObject allTasksInProcessInstanceId(String instanceId) {
Map<String, String> map = Maps.newHashMap();
map.put("processInstanceId", instanceId);
String url = buildUrl(address, WorkFlowUriEnum.工作流流水, map);
Map<String, String> headerMap = Maps.newHashMap();
headerMap.put(XJConstant.TOKEN_KEY, RequestContext.getToken());
headerMap.put(XJConstant.PRODUCT, RequestContext.getProduct());
headerMap.put(XJConstant.APPKEY, RequestContext.getAppKey());
String resultStr = HttpUtil.sendHttpGetWithHeader(url, headerMap);
JSONObject json = handleResult(resultStr);
logger.info("\r\n请求路径=======================>" + url + "\r\n返回参数=======================>" + resultStr);
if (json == null) {
return null;
}
JSONArray allContent = json.getJSONArray("dataList");
if (allContent != null && allContent.size() > 0) {
return allContent.getJSONObject(allContent.size() - 1);
}
return null;
}
public JSONObject pageTask(String userId,Integer BelongType) {
Map<String, String> map = Maps.newHashMap();
String url = "";
map.put("processDefinitionKey", processDefinitionKey);
if(Integer.parseInt(YesOrNoEnum.YES.getCode())==BelongType){
map.put("userId", userId);
url = buildUrl(address, WorkFlowUriEnum.我的代办有ID, map);
}else{
url = buildUrl(address, WorkFlowUriEnum.我的代办, map);
}
Map<String, String> headerMap = Maps.newHashMap();
headerMap.put(XJConstant.TOKEN_KEY, RequestContext.getToken());
headerMap.put(XJConstant.PRODUCT, RequestContext.getProduct());
headerMap.put(XJConstant.APPKEY, RequestContext.getAppKey());
String resultStr = HttpUtil.sendHttpGetWithHeader(url, headerMap);
JSONObject json = handleResult(resultStr);
logger.info("\r\n请求路径=======================>" + url + "\r\n返回参数=======================>" + resultStr);
return json;
}
public JSONObject completedPageTask(String userId,Integer BelongType) {
Map<String, String> map = Maps.newHashMap();
String url = "";
map.put("processDefinitionKey", processDefinitionKey);
if(Integer.parseInt(YesOrNoEnum.YES.getCode())==BelongType){
map.put("userId", userId);
url = buildUrl(address, WorkFlowUriEnum.已执行任务有ID, map);
}else{
url = buildUrl(address, WorkFlowUriEnum.已执行任务, map);
}
Map<String, String> headerMap = Maps.newHashMap();
headerMap.put(XJConstant.TOKEN_KEY, RequestContext.getToken());
headerMap.put(XJConstant.PRODUCT, RequestContext.getProduct());
headerMap.put(XJConstant.APPKEY, RequestContext.getAppKey());
String resultStr = HttpUtil.sendHttpGetWithHeader(url, headerMap);
JSONObject json = handleResult(resultStr);
logger.info("\r\n请求路径=======================>" + url + "\r\n返回参数=======================>" + resultStr);
return json;
}
public JSONObject queryTask(String id) {
Map<String, String> map = Maps.newHashMap();
map.put("processInstanceId", id);
String url = buildUrl(address, WorkFlowUriEnum.流程任务, map);
Map<String, String> headerMap = Maps.newHashMap();
headerMap.put(XJConstant.TOKEN_KEY, RequestContext.getToken());
headerMap.put(XJConstant.PRODUCT, RequestContext.getProduct());
headerMap.put(XJConstant.APPKEY, RequestContext.getAppKey());
String resultStr = HttpUtil.sendHttpGetWithHeader(url, headerMap);
JSONObject json = handleResult(resultStr);
logger.info("\r\n请求路径=======================>" + url + "\r\n返回参数=======================>" + resultStr);
return json;
}
public JSONObject queryTaskDetail(String taskId) {
Map<String, String> map = Maps.newHashMap();
map.put("taskId", taskId);
String url = buildUrl(address, WorkFlowUriEnum.流程详情, map);
Map<String, String> headerMap = Maps.newHashMap();
headerMap.put(XJConstant.TOKEN_KEY, RequestContext.getToken());
headerMap.put(XJConstant.PRODUCT, RequestContext.getProduct());
headerMap.put(XJConstant.APPKEY, RequestContext.getAppKey());
String resultStr = HttpUtil.sendHttpGetWithHeader(url, headerMap);
JSONObject json = handleResult(resultStr);
logger.info("\r\n请求路径=======================>" + url + "\r\n返回参数=======================>" + resultStr);
return json;
}
public JSONObject queryFinishTaskDetail(String taskId) {
Map<String, String> map = Maps.newHashMap();
map.put("taskId", taskId);
String url = buildUrl(address, WorkFlowUriEnum.所有已执行任务详情, map);
Map<String, String> headerMap = Maps.newHashMap();
headerMap.put(XJConstant.TOKEN_KEY, RequestContext.getToken());
headerMap.put(XJConstant.PRODUCT, RequestContext.getProduct());
headerMap.put(XJConstant.APPKEY, RequestContext.getAppKey());
String resultStr = HttpUtil.sendHttpGetWithHeader(url, headerMap);
JSONObject json = handleResult(resultStr);
logger.info("\r\n请求路径=======================>" + url + "\r\n返回参数=======================>" + resultStr);
return json;
}
public JSONObject queryFinishTaskDetailByInstanceId(String InstanceId) {
Map<String, String> map = Maps.newHashMap();
map.put("processInstanceId", InstanceId);
String url = buildUrl(address, WorkFlowUriEnum.所有已执行任务集合, map);
Map<String, String> headerMap = Maps.newHashMap();
headerMap.put(XJConstant.TOKEN_KEY, RequestContext.getToken());
headerMap.put(XJConstant.PRODUCT, RequestContext.getProduct());
headerMap.put(XJConstant.APPKEY, RequestContext.getAppKey());
String resultStr = HttpUtil.sendHttpGetWithHeader(url, headerMap);
JSONObject json = handleResult(resultStr);
logger.info("\r\n请求路径=======================>" + url + "\r\n返回参数=======================>" + resultStr);
return json;
}
}
package com.yeejoin.amos.boot.biz.common.workflow.business.util;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
public class HttpUtil {
// utf-8字符编码
private static final String CHARSET_UTF_8 = "utf-8";
// HTTP内容类型。
private static final String CONTENT_TYPE_TEXT_HTML = "text/xml";
// HTTP内容类型。相当于form表单的形式,提交数据
private static final String CONTENT_TYPE_FORM_URL = "application/x-www-form-urlencoded";
// HTTP内容类型。相当于form表单的形式,提交数据
private static final String CONTENT_TYPE_JSON_URL = "application/json;charset=utf-8";
// 连接管理器
private static PoolingHttpClientConnectionManager pool;
// 请求配置
private static RequestConfig requestConfig;
static {
try {
//System.out.println("初始化HttpClientTest~~~开始");
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
builder.build());
// 配置同时支持 HTTP 和 HTPPS
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create().register(
"http", PlainConnectionSocketFactory.getSocketFactory()).register(
"https", sslsf).build();
// 初始化连接管理器
pool = new PoolingHttpClientConnectionManager(
socketFactoryRegistry);
// 将最大连接数增加到200,实际项目最好从配置文件中读取这个值
pool.setMaxTotal(200);
// 设置最大路由
pool.setDefaultMaxPerRoute(2);
// 根据默认超时限制初始化requestConfig
int socketTimeout = 10000;
int connectTimeout = 10000;
int connectionRequestTimeout = 10000;
requestConfig = RequestConfig.custom().setConnectionRequestTimeout(
connectionRequestTimeout).setSocketTimeout(socketTimeout).setConnectTimeout(
connectTimeout).build();
//System.out.println("初始化HttpClientTest~~~结束");
} catch (Exception e) {
e.printStackTrace();
}
// 设置请求超时时间
requestConfig = RequestConfig.custom().setSocketTimeout(50000).setConnectTimeout(50000)
.setConnectionRequestTimeout(50000).build();
}
private static CloseableHttpClient getHttpClient() {
return HttpClients.custom()
// 设置连接池管理
.setConnectionManager(pool)
// 设置请求配置
.setDefaultRequestConfig(requestConfig)
// 设置重试次数
.setRetryHandler(new DefaultHttpRequestRetryHandler(0, false))
.build();
}
/**
* 发送Post请求
*/
private static String sendHttpPost(HttpPost httpPost) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
// 响应内容
String responseContent = null;
try {
// 创建默认的httpClient实例.
httpClient = getHttpClient();
// 配置请求信息
httpPost.setConfig(requestConfig);
// 执行请求
response = httpClient.execute(httpPost);
// 得到响应实例
HttpEntity entity = response.getEntity();
// 可以获得响应头
// Header[] headers = response.getHeaders(HttpHeaders.CONTENT_TYPE);
// for (Header header : headers) {
// System.out.println(header.getName());
// }
// 得到响应类型
// System.out.println(ContentType.getOrDefault(response.getEntity()).getMimeType());
// 判断响应状态
if (response.getStatusLine().getStatusCode() >= 300) {
throw new Exception(
"HTTP Request is not success, Response code is " + response.getStatusLine().getStatusCode());
}
if (HttpStatus.SC_OK == response.getStatusLine().getStatusCode() || HttpStatus.SC_CREATED == response.getStatusLine().getStatusCode()) {
responseContent = EntityUtils.toString(entity, CHARSET_UTF_8);
EntityUtils.consume(entity);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
// 释放资源
if (response != null) {
response.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return responseContent;
}
/**
* 发送Post请求
*
* @param httpPut
* @return
*/
private static String sendHttpPut(HttpPut httpPut) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
// 响应内容
String responseContent = null;
try {
// 创建默认的httpClient实例.
httpClient = getHttpClient();
// 配置请求信息
httpPut.setConfig(requestConfig);
// 执行请求
response = httpClient.execute(httpPut);
// 得到响应实例
HttpEntity entity = response.getEntity();
// 可以获得响应头
// Header[] headers = response.getHeaders(HttpHeaders.CONTENT_TYPE);
// for (Header header : headers) {
// System.out.println(header.getName());
// }
// 得到响应类型
// System.out.println(ContentType.getOrDefault(response.getEntity()).getMimeType());
// 判断响应状态
if (response.getStatusLine().getStatusCode() >= 300) {
throw new Exception(
"HTTP Request is not success, Response code is " + response.getStatusLine().getStatusCode());
}
if (HttpStatus.SC_OK == response.getStatusLine().getStatusCode() || HttpStatus.SC_CREATED == response.getStatusLine().getStatusCode()) {
responseContent = EntityUtils.toString(entity, CHARSET_UTF_8);
EntityUtils.consume(entity);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
// 释放资源
if (response != null) {
response.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return responseContent;
}
/**
* 发送Post请求
*
* @param httpDelete
* @return
*/
private static String sendHttpDelete(HttpDelete httpDelete) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
// 响应内容
String responseContent = null;
try {
// 创建默认的httpClient实例.
httpClient = getHttpClient();
// 配置请求信息
httpDelete.setConfig(requestConfig);
// 执行请求
response = httpClient.execute(httpDelete);
// 得到响应实例
HttpEntity entity = response.getEntity();
// 可以获得响应头
// Header[] headers = response.getHeaders(HttpHeaders.CONTENT_TYPE);
// for (Header header : headers) {
// System.out.println(header.getName());
// }
// 得到响应类型
// System.out.println(ContentType.getOrDefault(response.getEntity()).getMimeType());
// 判断响应状态
if (response.getStatusLine().getStatusCode() >= 300) {
throw new Exception(
"HTTP Request is not success, Response code is " + response.getStatusLine().getStatusCode());
}
if (HttpStatus.SC_OK == response.getStatusLine().getStatusCode() || HttpStatus.SC_CREATED == response.getStatusLine().getStatusCode()) {
responseContent = EntityUtils.toString(entity, CHARSET_UTF_8);
EntityUtils.consume(entity);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
// 释放资源
if (response != null) {
response.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return responseContent;
}
/**
* 发送Get请求
*
* @param httpGet
* @return
*/
private static String sendHttpGet(HttpGet httpGet) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
// 响应内容
String responseContent = null;
try {
// 创建默认的httpClient实例.
httpClient = getHttpClient();
// 配置请求信息
httpGet.setConfig(requestConfig);
// 执行请求
response = httpClient.execute(httpGet);
// 得到响应实例
HttpEntity entity = response.getEntity();
// 可以获得响应头
// Header[] headers = response.getHeaders(HttpHeaders.CONTENT_TYPE);
// for (Header header : headers) {
// System.out.println(header.getName());
// }
// 得到响应类型
// System.out.println(ContentType.getOrDefault(response.getEntity()).getMimeType());
// 判断响应状态
if (response.getStatusLine().getStatusCode() >= 300) {
throw new Exception(
"HTTP Request is not success, Response code is " + response.getStatusLine().getStatusCode());
}
if (HttpStatus.SC_OK == response.getStatusLine().getStatusCode()) {
responseContent = EntityUtils.toString(entity, CHARSET_UTF_8);
EntityUtils.consume(entity);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
// 释放资源
if (response != null) {
response.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return responseContent;
}
/**
* 发送 post请求
*
* @param httpUrl 地址
*/
public static String sendHttpPost(String httpUrl) {
// 创建httpPost
HttpPost httpPost = new HttpPost(httpUrl);
return sendHttpPost(httpPost);
}
/**
* 发送 delete请求
*
* @param httpUrl 地址
*/
public static String sendHttpDelete(String httpUrl) {
// 创建httpPost
HttpDelete httpDelete = new HttpDelete(httpUrl);
return sendHttpDelete(httpDelete);
}
/**
* 发送 post请求
*
* @param httpUrl 地址
*/
public static String sendHttpPostWithHeader(String httpUrl, Map<String, String> headerMap) {
// 创建httpPost
HttpPost httpPost = new HttpPost(httpUrl);
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
httpPost.setHeader(entry.getKey(), entry.getValue());
}
return sendHttpPost(httpPost);
}
/**
* 发送 get请求
*
* @param httpUrl
*/
public static String sendHttpGet(String httpUrl) {
// 创建get请求
HttpGet httpGet = new HttpGet(httpUrl);
return sendHttpGet(httpGet);
}
/**
* 发送 delete请求带请求头
*/
public static String sendHttpDeleteWithHeader(String httpUrl, Map<String, String> headerMap) {
// 创建get请求
HttpDelete httpDelete = new HttpDelete(httpUrl);
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
httpDelete.setHeader(entry.getKey(), entry.getValue());
}
return sendHttpDelete(httpDelete);
}
/**
* 发送 get请求带请求头
*/
public static String sendHttpGetWithHeader(String httpUrl, Map<String, String> headerMap) {
// 创建get请求
HttpGet httpGet = new HttpGet(httpUrl);
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
httpGet.setHeader(entry.getKey(), entry.getValue());
}
return sendHttpGet(httpGet);
}
/**
* 发送 delete请求带请求头
*/
public static String sendHttpDeleteJsonWithHeader(String httpUrl, String paramsJson, Map<String, String> headerMap) {
StringBuffer content = new StringBuffer();
try {
URL url = new URL(httpUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("DELETE");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
connection.setRequestProperty(entry.getKey(), entry.getValue());
}
PrintWriter printWriter = new PrintWriter(connection.getOutputStream());
printWriter.write(paramsJson);
printWriter.flush();
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
content.append(line);
}
br.close();
connection.disconnect();
} catch (Exception e) {
}
return content.toString();
}
/**
* 发送 post请求
*
* @param httpUrl 地址
* @param params 参数(格式:key1=value1&key2=value2)
*/
public static String sendHttpPost(String httpUrl, String params) {
HttpPost httpPost = new HttpPost(httpUrl);// 创建httpPost
try {
// 设置参数
if (params != null && params.trim().length() > 0) {
StringEntity stringEntity = new StringEntity(params, "UTF-8");
stringEntity.setContentType(CONTENT_TYPE_FORM_URL);
httpPost.setEntity(stringEntity);
}
} catch (Exception e) {
e.printStackTrace();
}
return sendHttpPost(httpPost);
}
/**
* 发送 post请求
*
* @param maps 参数
*/
public static String sendHttpPost(String httpUrl, Map<String, String> maps) {
String parem = convertStringParamter(maps);
return sendHttpPost(httpUrl, parem);
}
/**
* 发送 post请求 发送json数据
*
* @param httpUrl 地址
* @param paramsJson 参数(格式 json)
*/
public static String sendHttpPostJsonWithHeader(String httpUrl, String paramsJson, Map<String, String> headerMap) {
HttpPost httpPost = new HttpPost(httpUrl);// 创建httpPost
try {
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
httpPost.setHeader(entry.getKey(), entry.getValue());
}
// 设置参数
if (paramsJson != null && paramsJson.trim().length() > 0) {
StringEntity stringEntity = new StringEntity(paramsJson, "UTF-8");
stringEntity.setContentType(CONTENT_TYPE_JSON_URL);
httpPost.setEntity(stringEntity);
}
} catch (Exception e) {
e.printStackTrace();
}
return sendHttpPost(httpPost);
}
/**
* 发送 put请求 发送json数据
*
* @param httpUrl 地址
* @param paramsJson 参数(格式 json)
*/
public static String sendHttpPutJsonWithHeader(String httpUrl, String paramsJson, Map<String, String> headerMap) {
HttpPut httpPost = new HttpPut(httpUrl);// 创建HttpPut
try {
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
httpPost.setHeader(entry.getKey(), entry.getValue());
}
// 设置参数
if (paramsJson != null && paramsJson.trim().length() > 0) {
StringEntity stringEntity = new StringEntity(paramsJson, "UTF-8");
stringEntity.setContentType(CONTENT_TYPE_JSON_URL);
httpPost.setEntity(stringEntity);
}
} catch (Exception e) {
e.printStackTrace();
}
return sendHttpPut(httpPost);
}
/**
* 发送 post请求 发送json数据
*
* @param httpUrl 地址
* @param paramsJson 参数(格式 json)
*/
public static String sendHttpPostJson(String httpUrl, String paramsJson) {
HttpPost httpPost = new HttpPost(httpUrl);// 创建httpPost
try {
// 设置参数
if (paramsJson != null && paramsJson.trim().length() > 0) {
StringEntity stringEntity = new StringEntity(paramsJson, "UTF-8");
stringEntity.setContentType(CONTENT_TYPE_JSON_URL);
httpPost.setEntity(stringEntity);
}
} catch (Exception e) {
e.printStackTrace();
}
return sendHttpPost(httpPost);
}
/**
* 发送 post请求 发送xml数据
*
* @param httpUrl 地址
* @param paramsXml 参数(格式 Xml)
*/
public static String sendHttpPostXml(String httpUrl, String paramsXml) {
HttpPost httpPost = new HttpPost(httpUrl);// 创建httpPost
try {
// 设置参数
if (paramsXml != null && paramsXml.trim().length() > 0) {
StringEntity stringEntity = new StringEntity(paramsXml, "UTF-8");
stringEntity.setContentType(CONTENT_TYPE_TEXT_HTML);
httpPost.setEntity(stringEntity);
}
} catch (Exception e) {
e.printStackTrace();
}
return sendHttpPost(httpPost);
}
/**
* 将map集合的键值对转化成:key1=value1&key2=value2 的形式
*
* @param parameterMap 需要转化的键值对集合
* @return 字符串
*/
private static String convertStringParamter(Map parameterMap) {
StringBuffer parameterBuffer = new StringBuffer();
if (parameterMap != null) {
Iterator iterator = parameterMap.keySet().iterator();
String key = null;
String value = null;
while (iterator.hasNext()) {
key = (String) iterator.next();
if (parameterMap.get(key) != null) {
value = (String) parameterMap.get(key);
} else {
value = "";
}
parameterBuffer.append(key).append("=").append(value);
if (iterator.hasNext()) {
parameterBuffer.append("&");
}
}
}
return parameterBuffer.toString();
}
}
\ No newline at end of file
/**
*
*/
package com.yeejoin.amos.boot.biz.common.workflow.constants;
import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat;
/**
* 常量
*/
public class XJConstant {
public static final String ROOT_PATH = "F:/software/nginx-1.14.2/html/";
public static final String NGINX_ADDRESS = "172.16.3.77:8081/";
public static final String DEFAULT_RISKDESC = "默认";
public static final String JPUSH_USER_KEY ="BANK88";
public static final String CHECK_TYPE = "CHECK_TYPE";
public static final String DEPT_WF_MAP_DIC_CODE = "DEPT_WF_MAP";
/**
* 构造方法
*/
private XJConstant() {
LoggerFactory.getLogger(this.getClass()).debug(XJConstant.CONSTRUCTOR);
}
/**
* 网络服务ip
*/
public static final String NET_SERVER_HOST = "0.0.0.0";
/**
* 请求头key
*/
public static final String TOKEN_KEY = "token";
/**
* 请求头key
*/
public static final String PRODUCT = "product";
/**
* 请求头key
*/
public static final String APPKEY = "appKey";
/**
* 时间格式(yyyy-MM-dd HH:mm:ss)
*/
public static final SimpleDateFormat SIMPLEDATAFORMAT_YMDHMS = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
/**
* 构造方法字符串
*/
public static final String CONSTRUCTOR = "constructor...";
/**
* 轮询job最大线程数
*/
public static final int POLLING_JOB_THREAD_MAX_NUM = 20;
/**
* amos线程池数量
*/
public static final int AMOS_THREAD_NUM = 20;
/**
* 设备测试最大线程数
*/
public static final int TEST_EQUIPMENT_THREAD_MAX_NUM = 5;
/**
* 时间格式字符串:yyyy-MM-dd HH:mm:ss
*/
public static final String DATE_TIME_STR_YMDHMS = "yyyy-MM-dd HH:mm:ss";
/**
* bar
*/
public static final String BAR = "-";
/**
* Underline
*/
public static final String UNDERLINE = "_";
/**
* user
*/
public static final String USER = "user";
/**
* token
*/
public static final String TOKEN = "token";
/**
* loginType
*/
public static final String LOGIN_TYPE = "loginType";
/**
* subGraphId
*/
public static final String SUB_GRAPH_ID = "subGraphId";
public static final String ADMIN_ID = "1";
/**
* 帧报文异常
*/
public static final String FRAME_EXECPTION = "FRAME";
/**
* 性能指标
*/
public static final String METRIC = "METRIC";
/**
* 报文通道
*/
public static final String CHANNEL = "CHANNEL";
/**
* 设备状态(掉线)告警
*/
public static final String EQUIPMENT_STATUS = "EQUIPMENT_STATUS";
/**
* 设备连通性告警告警
*/
public static final String EQUIPMENT_CONNECTION = "EQUIPMENT_CONNECTION";
/**
* 通道注册
*/
public static final String REGISTER = "REGISTER";
/**
* 通道注销
*/
public static final String UNREGISTER = "UNREGISTER";
/**
* 报文正常
*/
public static final String NORMAL = "NORMAL";
/**
* 报文异常
*/
public static final String UNNORMAL = "UNNORMAL";
/**
* 告警socket类型
*/
public static final String ALARM_SOCKET = "ALARM_SOCKET";
/**
* 数据socket类型
*/
public static final String METRIC_SOCKET = "METRIC_SOCKET";
/**
* 数据socket类型
*/
public static final String MORPHIC_SOCKET = "MORPHIC_SOCKET";
/**
* false
*/
public static final Boolean FAIL_BOOLEAN_VALUE = Boolean.FALSE;
/**
* 0
*/
public static final Integer ZERO_INT_VALUE = Integer.parseInt("0");
/**
* -1
*/
public static final Integer FAIL_INT_VALUE = Integer.parseInt("-1");
/**
* -1
*/
public static final Long FAIL_LONG_VALUE = Long.parseLong("-1");
/**
* -1
*/
public static final Short FAIL_SHORT_VALUE = Short.parseShort("-1");
/**
*
*/
public static final Float FAIL_FLOAT_VALUE = Float.parseFloat("-1");
/**
* -1
*/
public static final Double FAIL_DOUBLE_VALUE = Double.parseDouble("-1");
/**
* 空格
*/
public static final Character FAIL_CHARACTER_VALUE = Character.valueOf(' ');
/**
* 失败
*/
public static final int FAILURE = 0;
/**
* 成功
*/
public static final int SUCCESS = 1;
/**
* 在线
*/
public static final String ONLINE = "在线";
/**
* 掉线
*/
public static final String OFFLINE = "掉线";
/**
* 通
*/
public static final String OPEN = "通";
/**
* 不通
*/
public static final String OFF = "不通";
/**
* ip
*/
public static final String IP = "ip";
/**
* #
*/
public static final String SHARP = "#";
/**
* TCP
*/
public static final String TCP = "TCP";
public static final String PIE_CHAR = "pieChar";
public static final String BAR_CHAR = "barChar";
public static final String HBAR_CHAR = "hbarChar";
public static final String LINE_CHAR = "lineChar";
public static final String DOUGHUNT_CHAR = "doughuntChar";
public static final String ROSE_CHAR = "roseChar";
public static final String AREA_CHAR = "areaChar";
public static final String DIMENSION = "dimension";
public static final String MEASURE = "measure";
/**
* xunjian
*/
public static final String TABLE_USERS = "Users";
public static final String EDIT_PWD = "editPassword";
public static final String EDIT_NOT_PWD = "editUsersInfo";
public static final String SAVE_USERS = "saveTableById";
public static final String SAVE_COM_USER = "saveComUserInfo";
public static final String EDIT_COM_USER = "editComUserInfo";
public static final String TABLE_CHECK = "Check";
public static final String TABLE_COM_USER = "companyUser";
public static final int FINISH_YES = 2;
public static final int FINISH_ING = 1;
public static final int FINISH_NO = 0;
public static final String SAVE_DEPART = "saveDepartMent";
public static final String EDIT_DEPART = "editsDepartMent";
public static final String TABLE_DEPART = "Group";
public static final String TABLE_ERROR = "Error";//隐患表
public static final String SAVE_ERROR = "saveErrorByID";//更新隐患表
public static final int XJ_ADMIN_ROLE = 9;//巡检管理员角色ID
public static final int XJ_USER_ROLE = 0;//巡检普通用户角色ID
public static final int TASK_STATUS_TIMEOUT = 3;//已超时
public static final int TASK_STATUS_FINISH = 2;//已结束
public static final int TASK_STATUS_DEAL = 1;//进行中
public static final int TASK_STATUS_NO_START = 0;//未开始
public static final String PLAN_TASK_DET_FINISH_NO = "0";//任务明细状态:未完成
public static final String PLAN_TASK_DET_FINISH_YES = "1";//任务明细状态:完成
public static final String PLAN_TASK_DET_FINISH_OUT = "2";//任务明细状态:超时漏检
public static final String USER_DATA_ADMIN = "全部可见"; //用户数据可见范围
public static final String USER_DATA_DEPART = "部门可见"; //用户数据可见范围
public static final String USER_DATA_PERSON = "个人可见"; //用户数据可见范围
public static final String USER_ROLE_SUPERADMIN = "1"; //权限id-超级管理员
public static final String USER_ROLE_ADMIN = "2"; //权限id-管理员
public static final String USER_ROLE_DEPART = "3"; //权限id-部门管理
public static final String USER_ROLE_PERSON = "4"; //权限id-普通用户
public static final String ROLE_NAME_SUPERADMIN = "SUPERADMIN"; //数据权限-超级管理员
public static final String ROLE_NAME_ADMIN = "ADMIN"; //数据权限-超级管理员
public static final String ROLE_NAME_DEPTADMIN = "DEPTADMIN"; //数据权限-部门
public static final String ROLE_NAME_PERSON = "PERSONAL"; //数据权限-个人
public static final String ADMIN_FLAG = "2"; //权限标记
public static final String DEPART_FLAG = "1"; //权限标记
public static final String PERSON_FLAG = "0";//权限标记
public static final String ADMIN_FLAG_NO = "0"; //标记 0-无关
public static final String ADMIN_FLAG_UP = "1"; //1-上级admin
public static final String ADMIN_FLAG_THIS = "2"; //2-本级admin
public static final String UNCLASSIFIED = "Unclassifed"; //巡检点未分类
public static final String ADMIN_ORG_CODE = "2";
public static final String CHECK_CHANGE_NO = "0";//是否记为合格:否
public static final String CHECK_CHANGE_YES = "1";//是否记为合格:是
public static final String SCHED_FLAG = "99";//自动任务标记
public static final String REGEN_FLAG = "98";//重做任务标记
public static final String FIX_DATE_NO = "0";//不固定日期(区间)
public static final String FIX_DATE_YES = "1";//固定日期
//计划类型
public static final String PLAN_TYPE_DAY = "1";//日计划
public static final String PLAN_TYPE_WEEK = "2";//周计划
public static final String PLAN_TYPE_MONTH = "3";//月计划
public static final String PLAN_TYPE_YEAR = "4";//年计划
//月类型
public static final String MONTH_TYPE_DAY = "1";//第几天
public static final String MONTH_TYPE_AT = "2";//在第几周的第几天
public static final String INTERVAL_UNIT_HOUR = "1";//执行间隔小时
public static final String INTERVAL_UNIT_MINUTE = "2";//执行间隔分钟
public static final String INTERVAL_UNIT_SECOND = "3";//执行间隔秒
public static final String ZERO_TIME = "00:00:00";//time
public static final String PLAN_STATUS_START = "0";//计划状态:正常
public static final String PLAN_STATUS_STOP = "1";//计划状态:已停用
public static final int PLAN_FIRST_STATUS_YES = 0;//计划:初始状态
public static final int PLAN_FIRST_STATUS_NO = 1;//计划:非初始状态
public static final String UPD_PLAN_GEN_DATE = "1";//更新plan表日期
public static final String UPD_PLAN_STATUS = "2";//更新plan表next_gen_status
public static final int DAY_RATE_ONE = 0;//0-1次
public static final int DAY_RATE_MANY = 1;//1-多次
public static final int IS_DETETE_NO = 0;//未删除
public static final int IS_DETETE_YES = 1;//删除
public static final String UPLOAD_ROOT_PATH = "upload";
public static final String INPUT_ITEM_TEXT = "文本";
public static final String INPUT_ITEM_NUMBER = "数字";
public static final String INPUT_ITEM_SELECT = "选择";
public static final String CHECK_TYPE_ALWAYS_OK = "始终合格";
public static final String CHECK_TYPE_ALWAYS_NO = "始终不合格";
public static final String CHECK_TYPE_NO_CONTEXT_OK = "无内容合格";
public static final String CHECK_TYPE_CONTEXT_OK = "有内容合格";
public static final String OK = "合格";
public static final String NO = "不合格";
public static final String YES = "是";
public static final String NOT = "否";
public static final String INPUT_ITEM_OK_SCORE = "OkScore";
public static final String INPUT_ITEM_NOT_SCORE = "NoScore";
public static final String POINT_OK_SCORE = "1";
public static final String POINT_NOT_SCORE = "0";
/**
* 任务是否发送消息状态
*/
public static final String TASK_WARN = "是";
public static final String TASK_NOT_WARN = "否";
/**
* 系统定时任务类型
*/
public static final String STATUS_MONITOR_START = "statusMonitorStart"; //状态监控是否开始
public static final String STATUS_MONITOR_END = "statusMonitorEnd"; //状态监控是否结束
public static final String PLAN_TASK_WARN_MSG_PUSH = "planTaskWarnMsgPush"; //计划即将开始消息提醒推送
public static final String PLAN_TASK_BEGIN_MSG_PUSH = "planTaskBeginMsgPush"; //计划已经开始消息提醒推送
public static final String PLAN_TASK_END_MSG_PUSH = "planTaskEndMsgPush"; //计划已经开始消息提醒推送
public static final String MESSAGE_PUSH = "messagePush"; //消息推送
public static final int IS_SENT = 1; //已发送
public static final int NOT_SENT = 0; //未发送
public static final String IS_FIXED_YES = "1"; //固定点
}
package com.yeejoin.amos.boot.biz.common.workflow.enums;
public enum WorkFlowUriEnum {
启动流程("启动流程", "/workflow/task/startTask", ""),
流程详情("流程详情", "/workflow/task/{taskId}", "taskId"),
合并启动流程("合并启动流程", "/workflow/task/startProcess", ""),
所有已执行任务详情("所有已执行任务详情","/workflow/activitiHistory/task/detail/{taskId}","taskId"),
流程任务("流程任务", "/workflow/task?processInstanceId={processInstanceId}", "processInstanceId"),
我的代办("我的代办", "/workflow/task/all-list?processDefinitionKey={processDefinitionKey}", "processDefinitionKey"),
我的代办有ID("我的代办有ID", "/workflow/task/all-list?processDefinitionKey={processDefinitionKey}&userId={userId}", "processDefinitionKey,userId"),
已执行任务("已执行任务", "/workflow/activitiHistory/all-historytasks?processDefinitionKey={processDefinitionKey}", "processDefinitionKey"),
已执行任务有ID("已执行任务有ID", "/workflow/activitiHistory/all-historytasks?processDefinitionKey={processDefinitionKey}&userId={userId}", "processDefinitionKey,userId"),
启动免登录流程("启动免登录流程", "/processes/{appKey}", "appKey"),
当前节点("当前节点", "/wf/taskstodo?processInstanceId={processInstanceId}", "processInstanceId"),
执行流程("执行流程", "/workflow/task/pickupAndCompleteTask/{taskId}", "taskId"),
终止流程("终止流程", "/wf/processes/{processInstanceId}?deleteReason={deleteReason}", "processInstanceId,deleteReason"),
当前子节点("当前子节点", "/wf/processes/{processInstanceId}/tasks?taskDefinitionKey={taskDefinitionKey}", "processInstanceId,taskDefinitionKey"),
工作流流水("工作流流水","/wf/processes/{processInstanceId}/tasks", "processInstanceId"),
子节点信息("子节点信息","/workflow/task/list/all/{instanceId}", "instanceId"),
所有已执行任务集合("所有已执行任务集合","/workflow/activitiHistory/tasks/{processInstanceId}", "processInstanceId");
private String desc;
private String uri;
private String params;
WorkFlowUriEnum(String desc, String uri, String params) {
this.desc = desc;
this.uri = uri;
this.params = params;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
}
package com.yeejoin.amos.boot.biz.common.workflow.enums;
/**
* 是否枚举
* @author WJK
*
*/
public enum YesOrNoEnum {
NO("否","0"),
YES("是","1" );
/**
* 名称,描述
*/
private String name;
/**
* 编码
*/
private String code;
private YesOrNoEnum(String name, String code){
this.name = name;
this.code = code;
}
public static YesOrNoEnum getEnum(String code) {
YesOrNoEnum jPushTypeEnum = null;
for(YesOrNoEnum type: YesOrNoEnum.values()) {
if (type.getCode().equals(code)) {
jPushTypeEnum = type;
break;
}
}
return jPushTypeEnum;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
package com.yeejoin.amos.boot.biz.common.workflow.feign;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @Author: xl
* @Description:
* @Date: 2020/3/30 16:26
*/
@Configuration
public class CommonMultipartSupportConfig {
@Autowired
private ObjectFactory<HttpMessageConverters> messageConverters;
@Bean
public Encoder feignCommonFormEncoder() {
return new SpringFormEncoder(new SpringEncoder(messageConverters));
}
}
package com.yeejoin.amos.boot.biz.common.workflow.feign;
import java.util.HashMap;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.alibaba.fastjson.JSONObject;
@FeignClient(name = "AMOS-API-WORKFLOW",path = "workflow", configuration = {CommonMultipartSupportConfig.class})
public interface WorkflowFeignService {
/**
* 发起流程
* @param params
* @return
*/
@RequestMapping(value = "/task/startProcess", method = RequestMethod.POST)
JSONObject startByVariable(@RequestBody Object params) ;
/**
* 完成任务
* @param taskID
* @param variable
* @return
* @throws Exception
*/
@RequestMapping(value = "/task/pickupAndCompleteTask/{taskId}", method = RequestMethod.POST)
JSONObject pickupAndCompleteTask(@PathVariable("taskId") String taskID, @RequestBody(required = false) HashMap<String, Object> variable) throws Exception;
/**
* 查询当前流程下所有的可执行任务
* @param processInstanceId
* @return
*/
@RequestMapping(value = "/task/list/all/{processInstanceId}", method = RequestMethod.GET)
JSONObject getTaskList(@PathVariable("processInstanceId") String processInstanceId) ;
}
......@@ -52,28 +52,21 @@ public class FailureDetailsController extends BaseController {
* 新增
*
* @return
* @throws Exception
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增", notes = "新增")
public ResponseModel<Object> save(@RequestBody FailureDetailsDto model) {
Object result = failureDetailsServiceImpl.savemodel(model,getSelectedOrgInfo());
return ResponseHelper.buildResponse(result);
// CommonResponse commonResponse = new CommonResponse();
// try {
// AgencyUserModel user = getUserInfo();
// if (ObjectUtils.isEmpty(user)) {
// return CommonResponseUtil.failure("用户session过期");
// }
// return failureDetailsServiceImpl.savemodel(model);
// } catch (Exception e) {
// logger.error("", e.getMessage());
// return CommonResponseUtil.failure("系统繁忙,请稍后再试");
// }
public ResponseModel<Object> save(@RequestBody FailureDetailsDto model) {
Object result;
try {
result = failureDetailsServiceImpl.savemodel(model,getSelectedOrgInfo());
return ResponseHelper.buildResponse(result);
} catch (Exception e) {
// TODO Auto-generated catch block
return ResponseHelper.buildResponse("erro");
}
}
......
......@@ -21,9 +21,8 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.workflow.RemoteWorkFlowService;
import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService;
import com.yeejoin.amos.boot.module.common.api.dto.FailureDetailsDto;
import com.yeejoin.amos.boot.module.common.api.entity.FailureAudit;
import com.yeejoin.amos.boot.module.common.api.entity.FailureDetails;
......@@ -44,9 +43,9 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
@Autowired
SourceFileServiceImpl sourceFileServiceImpl;
@Autowired
RemoteWorkFlowService remoteWorkFlowService;
WorkflowFeignService workflowFeignService;
@Value("${failure.work.flow.processDefinitionKey}")
private String processDefinitionKey;
......@@ -84,11 +83,15 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
/**
* 发起故障保修单
* @throws Exception
*/
@Transactional
public Object savemodel(FailureDetailsDto failureDetailsDto, ReginParams userInfo) {
public Object savemodel(FailureDetailsDto failureDetailsDto, ReginParams userInfo) throws Exception {
String businessKey = buildOrderNo();
JSONObject jsonObject = remoteWorkFlowService.startNew(null, businessKey, processDefinitionKey);
JSONObject body = new JSONObject();
body.put("businessKey", businessKey);
body.put("processDefinitionKey", processDefinitionKey);
JSONObject jsonObject = workflowFeignService.startByVariable(body);
if (jsonObject == null) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
// return CommonResponseUtil.failure("启动流程失败");
......@@ -120,12 +123,12 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
public boolean excuteTask( Long sequenceNbr, ReginParams userInfo,
String condition) {
Map<String, Object> conditionMap = new HashMap<String, Object>();
HashMap<String, Object> conditionMap = new HashMap<String, Object>();
conditionMap.put("condition", condition);
Map<String,Object> map= checkExcuteTaskAuthMap(sequenceNbr,userInfo);
try {
if(Boolean.parseBoolean(map.get("checkFlag").toString())) {
remoteWorkFlowService.excute(map.get("taskId").toString(), conditionMap.toString());
workflowFeignService.pickupAndCompleteTask(map.get("taskId").toString(), conditionMap);
}
} catch (Exception e) {
return false;
......@@ -134,15 +137,15 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
}
public boolean excuteTask(String procressId, ReginParams userInfo,
String condition) {
Map<String, Object> conditionMap = new HashMap<String, Object>();
String condition) throws Exception {
HashMap<String, Object> conditionMap = new HashMap<String, Object>();
conditionMap.put("condition", condition);
JSONObject teskObject = remoteWorkFlowService.getChildNodeDetail(procressId);
JSONObject teskObject =workflowFeignService.getTaskList(procressId);
if (ObjectUtils.isNotEmpty(teskObject)) {
JSONArray taskDetailArray = teskObject.getJSONArray("data");
for (Object obj : taskDetailArray) {
JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(obj));
remoteWorkFlowService.excute(detail.getString("id"), conditionMap.toString());
workflowFeignService.pickupAndCompleteTask(detail.getString("id"), conditionMap);
}
}
return true;
......@@ -160,7 +163,7 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
FailureDetails details = this.baseMapper.selectById(sequenceNbr);
String procressId = details.getProcessId();
Long seq = userInfo.getDepartment().getSequenceNbr();
JSONObject teskObject = remoteWorkFlowService.getChildNodeDetail(procressId);
JSONObject teskObject =workflowFeignService.getTaskList(procressId);
if (ObjectUtils.isNotEmpty(teskObject)) {
JSONArray taskDetailArray = teskObject.getJSONArray("data");
for (Object obj : taskDetailArray) {
......@@ -190,7 +193,6 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
public Object getCurrentProcessHistoryTask(Long id) {
FailureDetailsDto failureDetailsDto = this.queryBySeq(id);
String processId = failureDetailsDto.getProcessId();
JSONObject historyObject = remoteWorkFlowService.queryFinishTaskDetailByInstanceId(processId);
return logger;
}
......
......@@ -39,9 +39,4 @@ file.url=http://39.98.45.134:9000/
video.url=https://11.11.16.4:443/
params.work.flow.normalProcessDefinitionKey=normalHazardManagement
params.work.flow.processDefinitionKey=hazardManagement
params.work.flow.address=http://172.16.3.4:30040
#params.work.flow.address=http://172.16.10.80:30040
params.spc.address=http://172.16.3.89:9001
failure.work.flow.processDefinitionKey=malfunction_repair
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment