feat: There is no way the
This commit is contained in:
@@ -71,6 +71,29 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- CXF webservice -->
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-features-logging</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- CXF webservice -->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>3.6.0</version>
|
||||
</dependency>
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.ydw.bat.wkflow.business_oa.common;
|
||||
|
||||
import com.ydw.bat.wkflow.business_oa.exception.CommonException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.cxf.endpoint.Client;
|
||||
import org.apache.cxf.frontend.ClientProxy;
|
||||
import org.apache.cxf.interceptor.LoggingInInterceptor;
|
||||
import org.apache.cxf.interceptor.LoggingOutInterceptor;
|
||||
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
|
||||
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
|
||||
import org.apache.cxf.transport.http.HTTPConduit;
|
||||
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* @Description: TODO
|
||||
* @author: super_liu
|
||||
* @date: 2021年09月08日 14:40
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class WebServiceConf {
|
||||
|
||||
/**
|
||||
* 调用webservice 接口
|
||||
*
|
||||
* @param method 调用方法名
|
||||
* @param params 接口传入参数
|
||||
* @return
|
||||
*/
|
||||
public static synchronized Object[] invoke(String wsdlUrl, String method, Object[] params) throws Exception {
|
||||
Object[] objectArr = null;
|
||||
//创建动态客户端
|
||||
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory
|
||||
.newInstance();
|
||||
Client client = dcf.createClient(wsdlUrl);
|
||||
try {
|
||||
//如果返回的address不是远程服务地址,重新制定地址
|
||||
//添加发送请求拦截器
|
||||
if (StringUtils.isEmpty(method)) {
|
||||
throw new CommonException("cxf 调用webservice 执行方法名缺失:method 未传入");
|
||||
}
|
||||
|
||||
|
||||
// cxf 调用webservice method paramsStr
|
||||
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); // 策略
|
||||
httpClientPolicy.setConnectionTimeout(36000); //连接超时
|
||||
httpClientPolicy.setAllowChunking(false);
|
||||
httpClientPolicy.setReceiveTimeout(10000); //接收超时
|
||||
HTTPConduit http = (HTTPConduit) client.getConduit();
|
||||
http.setClient(httpClientPolicy);
|
||||
|
||||
|
||||
objectArr = client.invoke(method, params);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new CommonException("cxf 调用webservice 执行错误:" + e.toString());
|
||||
}finally {
|
||||
client.close();
|
||||
}
|
||||
|
||||
return objectArr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.ydw.bat.wkflow.business_oa.config;
|
||||
|
||||
import okhttp3.ConnectionPool;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Configuration
|
||||
public class OkHttpConfig {
|
||||
|
||||
@Bean
|
||||
public X509TrustManager x509TrustManager() {
|
||||
return new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
||||
}
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
||||
}
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[0];
|
||||
}
|
||||
};
|
||||
}
|
||||
@Bean
|
||||
public SSLSocketFactory sslSocketFactory() {
|
||||
try {
|
||||
//信任任何链接
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, new TrustManager[]{x509TrustManager()}, new SecureRandom());
|
||||
return sslContext.getSocketFactory();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (KeyManagementException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Create a new connection pool with tuning parameters appropriate for a single-user application.
|
||||
* The tuning parameters in this pool are subject to change in future OkHttp releases. Currently
|
||||
*/
|
||||
@Bean
|
||||
public ConnectionPool pool() {
|
||||
return new ConnectionPool(200, 5, TimeUnit.MINUTES);
|
||||
}
|
||||
@Bean
|
||||
public OkHttpClient okHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.sslSocketFactory(sslSocketFactory(), x509TrustManager())
|
||||
.retryOnConnectionFailure(false)//是否开启缓存
|
||||
.connectionPool(pool())//连接池
|
||||
.connectTimeout(10L, TimeUnit.SECONDS)
|
||||
.readTimeout(10L, TimeUnit.SECONDS)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.ydw.bat.wkflow.business_oa.exception;
|
||||
|
||||
/**
|
||||
* 自定义简单异常
|
||||
*
|
||||
*/
|
||||
public class CommonException extends RuntimeException {
|
||||
|
||||
public CommonException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,322 @@
|
||||
package com.ydw.bat.wkflow.business_oa.utils;
|
||||
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class OkHttpUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(OkHttpUtil.class);
|
||||
|
||||
@Autowired
|
||||
private OkHttpClient okHttpClient;
|
||||
/**
|
||||
* get
|
||||
*
|
||||
* @param url 请求的url
|
||||
* @param queries 请求的参数,在浏览器?后面的数据,没有可以传null
|
||||
* @return
|
||||
*/
|
||||
public String get(String url, Map<String, String> queries, Map<String, String> headerParams) {
|
||||
String responseBody = "";
|
||||
StringBuffer sb = new StringBuffer(url);
|
||||
if (queries != null && queries.keySet().size() > 0) {
|
||||
boolean firstFlag = true;
|
||||
Iterator iterator = queries.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry<String, String>) iterator.next();
|
||||
if (firstFlag) {
|
||||
sb.append("?" + entry.getKey() + "=" + entry.getValue());
|
||||
firstFlag = false;
|
||||
} else {
|
||||
sb.append("&" + entry.getKey() + "=" + entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Request.Builder requestBuilder = new Request.Builder().url(url);
|
||||
|
||||
if(headerParams != null){
|
||||
for(Map.Entry<String, String> entry : headerParams.entrySet()) {
|
||||
requestBuilder.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Request request = requestBuilder.url(sb.toString())
|
||||
.build();
|
||||
Response response = null;
|
||||
try {
|
||||
response = okHttpClient.newCall(request).execute();
|
||||
int status = response.code();
|
||||
if (status == 200) {
|
||||
return response.body().string();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("okhttp put error >> ex = {}", ExceptionUtils.getStackTrace(e));
|
||||
} finally {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
return responseBody;
|
||||
}
|
||||
/**
|
||||
* post
|
||||
*
|
||||
* @param url 请求的url
|
||||
* @param params post form 提交的参数
|
||||
* @return
|
||||
*/
|
||||
public String post(String url, Map<String, String> params, Map<String, String> headerParams) {
|
||||
String responseBody = "";
|
||||
FormBody.Builder builder = new FormBody.Builder();
|
||||
//添加参数
|
||||
if (params != null && params.keySet().size() > 0) {
|
||||
for (String key : params.keySet()) {
|
||||
builder.add(key, params.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
Request.Builder requestBuilder = new Request.Builder().url(url);
|
||||
|
||||
for(Map.Entry<String, String> entry : headerParams.entrySet()) {
|
||||
requestBuilder.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
Request request = requestBuilder.post(builder.build()).build();
|
||||
Response response = null;
|
||||
try {
|
||||
response = okHttpClient.newCall(request).execute();
|
||||
int status = response.code();
|
||||
if (status == 200) {
|
||||
return response.body().string();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("okhttp post error >> ex = {}", ExceptionUtils.getStackTrace(e));
|
||||
} finally {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
return responseBody;
|
||||
}
|
||||
|
||||
/**
|
||||
47
|
||||
* 同步GET请求 带Authorization认证
|
||||
48
|
||||
*/
|
||||
|
||||
public String getAuthorization(String get_url, String json, String[] auth_base){
|
||||
|
||||
|
||||
final String credential = Credentials.basic(auth_base[0], auth_base[1]);
|
||||
String result = "";
|
||||
String data_url = get_url + "?" + json;
|
||||
Request request = new Request.Builder()
|
||||
.url(data_url)
|
||||
.header("Authorization", credential)
|
||||
.get()
|
||||
.build();
|
||||
Response response = null;
|
||||
try {
|
||||
response = okHttpClient.newCall(request).execute();
|
||||
int status = response.code();
|
||||
if (status == 200) {
|
||||
return response.body().string();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("okhttp post error >> ex = {}", ExceptionUtils.getStackTrace(e));
|
||||
} finally {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Post请求 带Authorization认证
|
||||
* */
|
||||
public String postAuthorization(String get_url, HashMap<String, Object> getData, String[] authBase){
|
||||
|
||||
String result = "";
|
||||
|
||||
final String credential = Credentials.basic(authBase[0], authBase[1]);
|
||||
|
||||
RequestBody fromBody = generateParametersForPost(getData).build();
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(get_url)
|
||||
.header("Authorization", credential)
|
||||
.post(fromBody)
|
||||
.build();
|
||||
|
||||
Response response = null;
|
||||
try {
|
||||
response = okHttpClient.newCall(request).execute();
|
||||
int status = response.code();
|
||||
if (status == 200) {
|
||||
return response.body().string();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("okhttp post error >> ex = {}", ExceptionUtils.getStackTrace(e));
|
||||
} finally {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
//拼接参数
|
||||
private static String generateParameters(HashMap<String, Object> parameters) {
|
||||
|
||||
String urlAttachment = "";
|
||||
|
||||
if(parameters.size()>0){
|
||||
|
||||
urlAttachment = "?";
|
||||
|
||||
Object[] keys = parameters.keySet().toArray();
|
||||
|
||||
for(Object key : keys)
|
||||
|
||||
urlAttachment += key.toString() + "=" + parameters.get(key).toString() + "&";
|
||||
|
||||
urlAttachment = urlAttachment.substring(0,urlAttachment.length()-1);
|
||||
}
|
||||
|
||||
return urlAttachment;
|
||||
}
|
||||
|
||||
//拼接参数用于POST请求
|
||||
|
||||
private static FormBody.Builder generateParametersForPost(HashMap<String, Object> parameters) {
|
||||
|
||||
FormBody.Builder builder = new FormBody.Builder();
|
||||
|
||||
if(parameters.size()>0){
|
||||
Object[] keys = parameters.keySet().toArray();
|
||||
|
||||
for(Object key : keys){
|
||||
Object ff = parameters.get(key);
|
||||
String aa = parameters.get(key).toString();
|
||||
|
||||
builder.add(key.toString(),parameters.get(key).toString());
|
||||
}
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送私密API请求
|
||||
*
|
||||
* @paramget_url请求地址
|
||||
* @paramget_data 请求参数列表
|
||||
* @return 返回JSON数据
|
||||
*/
|
||||
private String auth_get(){
|
||||
String result = "";
|
||||
String api_key = "apikey";
|
||||
String api_secret = "apisecret";
|
||||
//认证信息
|
||||
String[] baseAuth = {api_key,api_secret};
|
||||
//请求的URL的参数
|
||||
HashMap<String, Object> get_data = new HashMap<>();
|
||||
get_data.put("page","1"); //page参数
|
||||
get_data.put("name","test"); //name参数
|
||||
// result = getAuthorization("http://www.superl.org/page-about.html", get_data, baseAuth);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* post
|
||||
*
|
||||
* @param url 请求的url
|
||||
* @param headerParams post form 提交的参数
|
||||
* @return
|
||||
*/
|
||||
public String postForJson(String url, String json, Map<String, String> headerParams) {
|
||||
RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), json);
|
||||
String responseBody = "";
|
||||
Request.Builder requestBuilder = new Request.Builder().url(url);
|
||||
for(Map.Entry<String, String> entry : headerParams.entrySet()) {
|
||||
requestBuilder.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
Request request = requestBuilder.post(requestBody).build();
|
||||
Response response = null;
|
||||
try {
|
||||
response = okHttpClient.newCall(request).execute();
|
||||
int status = response.code();
|
||||
if (status == 200) {
|
||||
return response.body().string();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("okhttp post error >> ex = {}", ExceptionUtils.getStackTrace(e));
|
||||
} finally {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
return responseBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* post 上传文件
|
||||
*
|
||||
* @param url
|
||||
* @param params
|
||||
* @param fileType
|
||||
* @return
|
||||
*/
|
||||
public String postFile(String url, Map<String, Object> params, String fileType, Map<String, String> headerParams) {
|
||||
String responseBody = "";
|
||||
MultipartBody.Builder builder = new MultipartBody.Builder();
|
||||
//添加参数
|
||||
if (params != null && params.keySet().size() > 0) {
|
||||
for (String key : params.keySet()) {
|
||||
if (params.get(key) instanceof File) {
|
||||
File file = (File) params.get(key);
|
||||
builder.addFormDataPart(key, file.getName(), RequestBody.create(MediaType.parse(fileType), file));
|
||||
continue;
|
||||
}
|
||||
builder.addFormDataPart(key, params.get(key).toString());
|
||||
}
|
||||
}
|
||||
|
||||
Request.Builder requestBuilder = new Request.Builder();
|
||||
for(Map.Entry<String, String> entry : headerParams.entrySet()) {
|
||||
requestBuilder.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
Request request = requestBuilder.url(url).post(builder.build()).build();
|
||||
Response response = null;
|
||||
try {
|
||||
response = okHttpClient.newCall(request).execute();
|
||||
int status = response.code();
|
||||
if (status == 200) {
|
||||
return response.body().string();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("okhttp postFile error >> ex = {}", ExceptionUtils.getStackTrace(e));
|
||||
} finally {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
return responseBody;
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package com.ydw.bat.wkflow.business_oa.webService.controller;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.tmsps.fk.common.util.JsonUtil;
|
||||
import com.ydw.bat.wkflow.business_activiti.dto.*;
|
||||
import com.ydw.bat.wkflow.business_auth.LawsUserInfoService;
|
||||
import com.ydw.bat.wkflow.business_main.datas.entity.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessEntrustService;
|
||||
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNameService;
|
||||
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNewService;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.todoContent.NotifyTodoSendContext;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
|
||||
import com.ydw.bat.wkflow.business_wkflow.form.dto.FormSubmitDto;
|
||||
import com.ydw.bat.wkflow.business_wkflow.form.service.FormValsService;
|
||||
import org.activiti.engine.*;
|
||||
import org.activiti.engine.history.*;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.runtime.ProcessInstanceQuery;
|
||||
import org.activiti.engine.task.NativeTaskQuery;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.tmsps.fk.common.base.action.BaseAction;
|
||||
import com.tmsps.fk.common.util.ChkUtil;
|
||||
import com.tmsps.fk.common.wrapper.WrapMapper;
|
||||
import com.tmsps.fk.common.wrapper.Wrapper;
|
||||
import com.ydw.bat.wkflow.business_activiti.service.TaskTodoService;
|
||||
import com.ydw.bat.wkflow.util.activiti.ActivitiTools;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@Api(description = "WebService管理")
|
||||
@RestController
|
||||
public class WebServiceOAController extends BaseAction {
|
||||
|
||||
@Autowired
|
||||
private WebServiceOAService webServiceOAService;
|
||||
|
||||
@ApiOperation(value = "发送待办接口(")
|
||||
@PostMapping("/sendTodo")
|
||||
public NotifyTodoAppResult sendTodo(){
|
||||
return webServiceOAService.sendTodo(new NotifyTodoSendContext());
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.ydw.bat.wkflow.business_oa.webService.service;
|
||||
|
||||
import com.ydw.bat.wkflow.business_oa.webService.todoContent.NotifyTodoSendContext;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
|
||||
|
||||
public interface WebServiceOAService {
|
||||
|
||||
NotifyTodoAppResult sendTodo(NotifyTodoSendContext notifyTodoSendContext);
|
||||
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
package com.ydw.bat.wkflow.business_oa.webService.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ydw.bat.wkflow.business_oa.common.WebServiceConf;
|
||||
import com.ydw.bat.wkflow.business_oa.utils.OkHttpUtil;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.todoContent.HEAD;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.todoContent.JsonSend;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.todoContent.NotifyTodoSendContext;
|
||||
import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
|
||||
import net.sf.json.JSONArray;
|
||||
import okhttp3.Credentials;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static java.awt.SystemColor.info;
|
||||
|
||||
/**
|
||||
* @Description: TODO
|
||||
* @author: super_liu
|
||||
* @date: 2021年09月08日 15:02
|
||||
*/
|
||||
@Service
|
||||
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
||||
public class WebServiceOAServiceImpl implements WebServiceOAService {
|
||||
private static final Logger log = LoggerFactory.getLogger(WebServiceOAServiceImpl.class);
|
||||
|
||||
private String sonar = "sonar";
|
||||
private String info = "info:{},{}";
|
||||
private String errMes = "异常信息:";
|
||||
|
||||
private String api_key = "OA";
|
||||
private String api_secret = "TEST_oa201611241710";
|
||||
//认证信息
|
||||
private String[] baseAuth = {api_key,api_secret};
|
||||
private String credentials = "";
|
||||
|
||||
@Autowired
|
||||
private OkHttpUtil okHttpUtil;
|
||||
|
||||
public WebServiceOAServiceImpl(){
|
||||
credentials = Credentials.basic(api_key,api_secret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotifyTodoAppResult sendTodo(NotifyTodoSendContext notifyTodoSendContext){
|
||||
NotifyTodoAppResult notifyTodoAppResult = new NotifyTodoAppResult();
|
||||
String result = "";
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
||||
try {
|
||||
HashMap<String,Object> map = new HashMap<>();
|
||||
JsonSend jsonSend = new JsonSend();
|
||||
HEAD head = new HEAD();
|
||||
head.setACCOUNT("OA");
|
||||
head.setBIZTRANSACTIONID("SYC_161320210206133219");
|
||||
head.setCONSUMER("PCMS");
|
||||
head.setCOUNT("1");
|
||||
head.setPASSWORD("TEST_oa201611241710");
|
||||
head.setSRVLEVEL("1");
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(notifyTodoSendContext);
|
||||
jsonSend.setHEAD(head);
|
||||
jsonSend.setLIST(list);
|
||||
net.sf.json.JSONObject json = net.sf.json.JSONObject.fromObject(jsonSend);
|
||||
Map<String,String> mapCtr = new TreeMap<>();
|
||||
mapCtr.put("Authorization",credentials);
|
||||
log.info("处理完文件数据,开始请求发送待办接口数据:【"+sdf.format(new Date())+"】");
|
||||
result = okHttpUtil.postForJson("http://172.24.12.64:85/WP_FOTON_FSOA/APP_DOC_SERVICES/Proxy_Services/TA_OA/DOC_SYC_1019_SendTodo_PS",json.toString(),mapCtr);
|
||||
log.info("请求发送待办接口完毕,返回响应状态:【"+sdf.format(new Date())+"】");
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if(!result.contains("请求成功")){
|
||||
log.error("请求出现异常:"+result);
|
||||
notifyTodoAppResult.setReturnSate(jsonObject.getString("SIGN"));
|
||||
notifyTodoAppResult.setMessage(jsonObject.getString("MASSAGE"));
|
||||
}else {
|
||||
log.info("okHttp请求成功结果:"+result);
|
||||
notifyTodoAppResult.setReturnSate(jsonObject.getString("SIGN"));
|
||||
notifyTodoAppResult.setMessage(jsonObject.getString("MASSAGE"));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(errMes, e.getMessage());
|
||||
}
|
||||
|
||||
return notifyTodoAppResult;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ydw.bat.wkflow.business_oa.webService.todoContent;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: TODO
|
||||
* @author: super_liu
|
||||
* @date: 2021年09月08日 17:12
|
||||
*/
|
||||
@Data
|
||||
public class HEAD {
|
||||
|
||||
private String ACCOUNT;
|
||||
private String BIZTRANSACTIONID;
|
||||
private String CONSUMER;
|
||||
private String COUNT;
|
||||
private String PASSWORD;
|
||||
private String SRVLEVEL;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ydw.bat.wkflow.business_oa.webService.todoContent;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: TODO
|
||||
* @author: super_liu
|
||||
* @date: 2021年09月08日 17:11
|
||||
*/
|
||||
@Data
|
||||
public class JsonSend {
|
||||
|
||||
private HEAD HEAD;
|
||||
|
||||
private List<Object> LIST;
|
||||
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package com.ydw.bat.wkflow.business_oa.webService.todoContent;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: TODO
|
||||
* @author: super_liu
|
||||
* @date: 2021年09月08日 15:05
|
||||
*/
|
||||
@Data
|
||||
public class NotifyTodoSendContext {
|
||||
|
||||
@ApiModelProperty(value = "标识待办来源的系统")
|
||||
private String appName;
|
||||
|
||||
@ApiModelProperty(value = "标识待办来源的模块")
|
||||
private String modelName;
|
||||
|
||||
@ApiModelProperty(value = "标识待办在原系统唯一标识")
|
||||
private String modelId;
|
||||
|
||||
@ApiModelProperty(value = "待办标题")
|
||||
private String subject;
|
||||
|
||||
@ApiModelProperty(value = "对应待办的链接地址(全路径)")
|
||||
private String link;
|
||||
|
||||
@ApiModelProperty(value = "1:表示审批类待办 2:表示为通知类待办")
|
||||
private String type;
|
||||
|
||||
//用于区分同一文档下不同类型待办, 如:会议文档的抄送待办和与会人参加待办属于同一文档的不同类型的待办
|
||||
@ApiModelProperty(value = "待办关键字")
|
||||
private String key;
|
||||
|
||||
//待办附加标识 功能同"关键字",辅助区分不同类型的待办
|
||||
@ApiModelProperty(value = "参数1")
|
||||
private String param1;
|
||||
|
||||
//待办附加标识功能同"关键字",辅助区分不同类型的待办
|
||||
@ApiModelProperty(value = "参数2")
|
||||
private String param2;
|
||||
|
||||
//数据格式为JSON,格式描述请查看组织架构
|
||||
@ApiModelProperty(value = "待办对应接收人")
|
||||
private String targets;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
//数据格式为JSON,格式描述请查看组织架构
|
||||
@ApiModelProperty(value = "待办的创建者")
|
||||
private String docCreator;
|
||||
|
||||
@ApiModelProperty(value = "待办优先级。如:按紧急(1)、急(2)、一般(3)")
|
||||
private String level;
|
||||
|
||||
//数据格式为JSON,格式描述请查看组织架构
|
||||
@ApiModelProperty(value = "消息内容扩展")
|
||||
private String extendContent;
|
||||
|
||||
//备用参数,方便以后参数的扩展。数据格式为JSON,格式如:{ke
|
||||
//y1:value1,key2:value2}。
|
||||
@ApiModelProperty(value = "扩展参数")
|
||||
private String others;
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.ydw.bat.wkflow.business_oa.webService.todoResult;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: TODO
|
||||
* @author: super_liu
|
||||
* @date: 2021年09月08日 15:23
|
||||
*/
|
||||
@Data
|
||||
public class NotifyTodoAppResult {
|
||||
|
||||
@ApiModelProperty(value = "返回状态 0:表示未操作 1:表示操作失败 2:表示操作成功")
|
||||
private String returnSate;
|
||||
|
||||
@ApiModelProperty(value = "返回信息 " +
|
||||
"返回状态值为0时,该值返回空 " +
|
||||
"返回状态值为1时,该值错误信息 " +
|
||||
"返回状态值为2时,该值返回空")
|
||||
private String message;
|
||||
}
|
||||
@@ -47,6 +47,13 @@ public class SwaggerConfig {
|
||||
.build().groupName("表单接口");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket webServiceApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.ydw.bat.wkflow.business_oa")).paths(allowPaths())
|
||||
.build().groupName("webService接口");
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
Contact contact = new Contact("工作流系统", "http://localhost:17211/foton-bat-wkflow", null);
|
||||
return new ApiInfoBuilder().contact(contact).title("工作流系统 API").description("activiti接口及工作流相关业务接口")
|
||||
|
||||
Reference in New Issue
Block a user