commit
876007e5d5
|
@ -1,54 +0,0 @@
|
|||
package com.api.bokang.xiao.porsche_repush.controller;
|
||||
|
||||
import aiyh.utils.ApiResult;
|
||||
import aiyh.utils.Util;
|
||||
import com.api.bokang.xiao.porsche_repush.service.ContractRePushService;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName ContractRePushController
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/5/10 10:47
|
||||
* @Description <h1></h1>
|
||||
**/
|
||||
@Path("/xbk/porsche_repush")
|
||||
public class ContractRePushController {
|
||||
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
private final ContractRePushService contractRePushService = new ContractRePushService();
|
||||
|
||||
/**
|
||||
* <h2>获取流程的总数</h2>
|
||||
* @param request 请求体
|
||||
* @param response 响应体
|
||||
* @param param 请求参数
|
||||
* @return 请求结果
|
||||
*/
|
||||
@Path("/contractRePush")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String contractRePush(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
|
||||
try{
|
||||
log.info("into contractRePush success params ==> "+param);
|
||||
User loginUser = HrmUserVarify.getUser(request, response);
|
||||
List<Map<String,Boolean>> result = contractRePushService.contractRePushService(param,loginUser);
|
||||
return ApiResult.success(result);
|
||||
}catch (Exception e){
|
||||
log.error("contractRePush error ==> "+ Util.getErrString(e));
|
||||
return ApiResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package com.api.bokang.xiao.porsche_repush.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName QueryMapper
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/5/10 11:00
|
||||
* @Description <h1></h1>
|
||||
**/
|
||||
@SqlMapper
|
||||
public interface QueryMapper {
|
||||
|
||||
@Select("select * from uf_zcht where id in $t{ids}")
|
||||
List<Map<String,Object>> queryContractByIds(@ParamMapper("ids")String ids);
|
||||
|
||||
@Select("select * from actionsettingdetail where ACTIONID = (select id from actionsetting where actionname = #{actionName})")
|
||||
List<Map<String,Object>> queryActionParam(@ParamMapper("actionName")String actionName);
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
package com.api.bokang.xiao.porsche_repush.service;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.api.bokang.xiao.porsche_repush.mapper.QueryMapper;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.aiyh_pcn.common_fadada.action.CommonContractRevocationAction;
|
||||
import weaver.aiyh_pcn.common_fadada.action.CommonCreateContractAction;
|
||||
import weaver.aiyh_pcn.common_fadada.action.CommonOneselfSignAction;
|
||||
import weaver.hrm.User;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName ContractRePushService
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/5/10 10:48
|
||||
* @Description <h1></h1>
|
||||
**/
|
||||
public class ContractRePushService {
|
||||
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
private final QueryMapper queryMapper = Util.getMapper(QueryMapper.class);
|
||||
|
||||
public List<Map<String, Boolean>> contractRePushService(Map<String,Object> param, User loginUser) {
|
||||
String ids = Util.null2String(param.get("ids"));
|
||||
int labelId = Util.getIntValue(String.valueOf(param.get("labelId")));
|
||||
String contractCreateAction = Util.null2String(param.get("contractCreateAction"));
|
||||
String signOtherAction = Util.null2String(param.get("signOtherAction"));
|
||||
String contractRevocationAction = Util.null2String(param.get("ContractRevocationAction"));
|
||||
String workflowField = Util.null2String(param.get("workflowField"));
|
||||
List<Map<String, Object>> createList = queryMapper.queryActionParam(contractCreateAction);
|
||||
List<Map<String, Object>> signOtherList = queryMapper.queryActionParam(signOtherAction);
|
||||
List<Map<String, Object>> contractRevocationList = queryMapper.queryActionParam(contractRevocationAction);
|
||||
Map<String, String> contractActionParam = createList.stream().collect(Collectors
|
||||
.toMap(
|
||||
item -> Util.null2String(item.get("attrname")),
|
||||
item -> Util.null2String(item.get("attrvalue"))
|
||||
)
|
||||
);
|
||||
Map<String, String> signOtherActionParam = signOtherList.stream().collect(Collectors
|
||||
.toMap(
|
||||
item -> Util.null2String(item.get("attrname")),
|
||||
item -> Util.null2String(item.get("attrvalue"))
|
||||
)
|
||||
);
|
||||
Map<String, String> contractRevocationParam = contractRevocationList.stream().collect(Collectors
|
||||
.toMap(
|
||||
item -> Util.null2String(item.get("attrname")),
|
||||
item -> Util.null2String(item.get("attrvalue"))
|
||||
)
|
||||
);
|
||||
log.info(String.format("contractCreateAction ==> param:%s signOtherAction ==> param:%s contractRevocationAction ==> param:%s",
|
||||
JSON.toJSONString(contractRevocationParam),
|
||||
JSON.toJSONString(contractActionParam),
|
||||
JSON.toJSONString(signOtherActionParam)
|
||||
));
|
||||
List<Map<String,Object>> contractList = queryMapper.queryContractByIds(ids);
|
||||
List<Map<String, Boolean>> result = new ArrayList<>();
|
||||
for (Map<String, Object> contract : contractList) {
|
||||
String signStatus = Util.null2String(contract.get("zcgsqszt"));
|
||||
if("1".equals(signStatus)){
|
||||
throw new CustomerException(SystemEnv.getHtmlLabelName(labelId, loginUser.getLanguage()));
|
||||
}
|
||||
}
|
||||
for (Map<String, Object> contract : contractList) {
|
||||
Map<String,Boolean> info = new HashMap<>();
|
||||
int requestId = Util.getIntValue(String.valueOf(contract.get(workflowField)));
|
||||
try{
|
||||
//合同撤回
|
||||
Util.actionTest(CommonContractRevocationAction.class,requestId,contractRevocationParam);
|
||||
//合同创建
|
||||
Util.actionTest(CommonCreateContractAction.class,requestId,contractActionParam);
|
||||
//对方签署
|
||||
Util.actionTest(CommonOneselfSignAction.class,requestId,signOtherActionParam);
|
||||
}catch (CustomerException exception){
|
||||
info.put(String.valueOf(requestId),false);
|
||||
}
|
||||
info.put(String.valueOf(requestId),true);
|
||||
result.add(info);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.api.chaoyang.he.hcy_anyong.accessinterface.controller;
|
||||
|
||||
import aiyh.utils.ApiResult;
|
||||
import com.api.chaoyang.he.hcy_anyong.accessinterface.service.AccessInterfaceReturnParamsService;
|
||||
import com.api.chaoyang.he.hcy_anyong.accessinterface.service.impl.AccessInterfaceReturnParamsServiceImpl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Path("/access/hcy/")
|
||||
public class AccessInterfaceReturnParamsController {
|
||||
|
||||
private final AccessInterfaceReturnParamsService accessInterfaceReturnParamsService = new AccessInterfaceReturnParamsServiceImpl();
|
||||
|
||||
@POST
|
||||
@Path("/interface/return/params")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String returnParams(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
return accessInterfaceReturnParamsService.paramsString(request, response);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ApiResult.error(500,"fail");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.api.chaoyang.he.hcy_anyong.accessinterface.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
||||
@SqlMapper
|
||||
public interface AccessInterfaceReturnParamsMapper {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.api.chaoyang.he.hcy_anyong.accessinterface.service;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public interface AccessInterfaceReturnParamsService {
|
||||
String paramsString(HttpServletRequest request, HttpServletResponse response);
|
||||
}
|
|
@ -0,0 +1,405 @@
|
|||
package com.api.chaoyang.he.hcy_anyong.accessinterface.service.impl;
|
||||
|
||||
import aiyh.utils.ApiResult;
|
||||
import aiyh.utils.Util;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.chaoyang.he.hcy_anyong.accessinterface.service.AccessInterfaceReturnParamsService;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.log4j.Logger;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.entity.EntityBuilder;
|
||||
import org.apache.http.client.methods.RequestBuilder;
|
||||
import org.apache.http.client.utils.URIBuilder;
|
||||
import org.apache.http.config.ConnectionConfig;
|
||||
import org.apache.http.config.Registry;
|
||||
import org.apache.http.config.RegistryBuilder;
|
||||
import org.apache.http.config.SocketConfig;
|
||||
import org.apache.http.conn.socket.ConnectionSocketFactory;
|
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.DefaultHostnameVerifier;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import java.io.Closeable;
|
||||
|
||||
|
||||
public class AccessInterfaceReturnParamsServiceImpl implements AccessInterfaceReturnParamsService {
|
||||
|
||||
/**
|
||||
* 访问域名或ip
|
||||
*/
|
||||
private static final String HOST = "https://7efeed4ac5b94e42b40fd1ab3f5a6715-cn-shanghai-vpc.alicloudapi.com";
|
||||
/**
|
||||
* 应用appKey
|
||||
*/
|
||||
private static final String APP_KEY = "204191153";
|
||||
/**
|
||||
* 应用appSecret
|
||||
*/
|
||||
private static final String APP_SECRET = "dJfXKZFZoZb0tSjvl8fImM0m5nvMckCl";
|
||||
/**
|
||||
* apiId
|
||||
*/
|
||||
private static final String API_ID = "11863";
|
||||
/**
|
||||
* 日志处理
|
||||
*/
|
||||
private final Logger logger = Util.getLogger();
|
||||
|
||||
/**
|
||||
* 请求头
|
||||
*/
|
||||
private static final Map<String, String> headers = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* 根据前端获取的数据,查询接口返回数据
|
||||
* @param request req
|
||||
* @param response res
|
||||
* @return 接口返回值
|
||||
*/
|
||||
public String paramsString(HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
String keyId = request.getParameter("keyId");
|
||||
HashMap<Object, Object> bodyMap = new HashMap<>();
|
||||
bodyMap.put("keyId",keyId);
|
||||
String bodyJsonStr = JSONObject.toJSONString(bodyMap);
|
||||
createHears(bodyJsonStr);
|
||||
//获取返回结果
|
||||
String result = sendSyncRequest(headers, bodyJsonStr.getBytes(StandardCharsets.UTF_8));
|
||||
return ApiResult.success(result,200, "success");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ApiResult.error(500, "fail");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 封装header
|
||||
* @throws UnsupportedEncodingException 抛出异常
|
||||
* @throws InvalidKeyException 抛出异常
|
||||
* @throws NoSuchAlgorithmException 抛出异常
|
||||
*/
|
||||
private void createHears(String bodyJsonStr) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException {
|
||||
//date,设置请求头中的时间戳
|
||||
Date current = new Date();
|
||||
headers.put("date", getHttpDateHeaderValue(current));
|
||||
logger.info("生成header[date]:"+getHttpDateHeaderValue(current));
|
||||
|
||||
|
||||
//x-ca-timestamp,设置请求头中的时间戳,以timeIntervalSince1970的形式
|
||||
headers.put("x-ca-timestamp", String.valueOf(current.getTime()));
|
||||
logger.info("生成header[x-ca-timestamp]:"+ current.getTime());
|
||||
|
||||
|
||||
//host,设置请求头中的主机地址
|
||||
headers.put("host", HOST);
|
||||
logger.info("生成header[host]:"+ HOST);
|
||||
|
||||
//x-ca-key,设置请求头中的Api绑定的的AppKey
|
||||
headers.put("x-ca-key", APP_KEY);
|
||||
logger.info("生成header[x-ca-key]:"+ APP_KEY);
|
||||
|
||||
|
||||
//content-type,设置请求数据类型
|
||||
headers.put("content-type", "application/json; charset=utf-8");
|
||||
logger.info("生成header[content-type]:application/json; charset=utf-8");
|
||||
|
||||
//accept,设置应答数据类型
|
||||
headers.put("accept", "application/json; charset=utf-8");
|
||||
logger.info("生成header[accept]:application/json; charset=utf-8");
|
||||
|
||||
//x-ca-signature-method,签名加密方式
|
||||
headers.put("x-ca-signature-method", "HmacSHA256");
|
||||
logger.info("生成header[x-ca-signature-method]:HmacSHA256");
|
||||
|
||||
String md5 = base64AndMD5(bodyJsonStr.getBytes(StandardCharsets.UTF_8));
|
||||
headers.put("content-md5", md5);
|
||||
logger.info("生成header[content-md5]:"+md5);
|
||||
|
||||
//x-ca-signature,签名用作服务器校验
|
||||
String stringToSign = buildStringToSign(headers);
|
||||
String signature = sign(stringToSign);
|
||||
headers.put("x-ca-signature",signature);
|
||||
logger.info("生成header[x-ca-signature]:"+signature);
|
||||
|
||||
//x-ca-stage,生产环境标识
|
||||
headers.put("x-ca-stage","RELEASE");
|
||||
logger.info("生成header[x-ca-stage]:RELEASE");
|
||||
|
||||
//x-ca-signature-headers,同时所有加入签名的头的列表,需要用逗号分隔形成一个字符串,加入一个新HTTP头@"X-Ca-Signature-Headers"
|
||||
logger.info("生成header[x-ca-signature-headers]:"+headers.get("x-ca-signature-headers"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日期
|
||||
* @param date 日期
|
||||
* @return 日期字符串
|
||||
*/
|
||||
private static String getHttpDateHeaderValue(Date date) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
|
||||
|
||||
public static String base64AndMD5(byte[] bytes) {
|
||||
if (bytes == null) {
|
||||
throw new IllegalArgumentException("bytes can not be null");
|
||||
}
|
||||
try {
|
||||
final MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.reset();
|
||||
md.update(bytes);
|
||||
byte[] md5Result = md.digest();
|
||||
String base64Result = Base64.encodeBase64String(md5Result);
|
||||
/*
|
||||
* 正常情况下,base64的结果为24位,因与服务器有约定,在超过24位的情况下,截取前24位
|
||||
*/
|
||||
return base64Result.length() > 24 ? base64Result.substring(0, 23) : base64Result;
|
||||
} catch (final NoSuchAlgorithmException e) {
|
||||
throw new IllegalArgumentException("unknown algorithm MD5");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//换行符
|
||||
private static final String CLOUDAPI_LF = "\n";
|
||||
private static final String HTTP_METHOD = "POST";
|
||||
/**
|
||||
* path为oneservice创建的API指定的请求方式(get或者list)+API_ID生成
|
||||
*/
|
||||
private static final String PATH = "/get/"+API_ID;
|
||||
private static final String ENV = "PROD";
|
||||
private static final String URL = PATH+"?appKey="+APP_KEY+"&env="+ENV;
|
||||
|
||||
|
||||
/**
|
||||
* 构建需要参与签名的字符串
|
||||
*/
|
||||
public static String buildStringToSign(Map<String, String> headers) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(HTTP_METHOD).append(CLOUDAPI_LF);
|
||||
|
||||
//如果有@"Accept"头,这个头需要参与签名
|
||||
if (headers.get("accept") != null) {
|
||||
sb.append(headers.get("accept"));
|
||||
}
|
||||
sb.append(CLOUDAPI_LF);
|
||||
|
||||
//如果有@"Content-MD5"头,这个头需要参与签名
|
||||
if (headers.get("content-md5") != null) {
|
||||
sb.append(headers.get("content-md5"));
|
||||
}
|
||||
sb.append(CLOUDAPI_LF);
|
||||
|
||||
//如果有@"Content-Type"头,这个头需要参与签名
|
||||
if (headers.get("content-type") != null) {
|
||||
sb.append(headers.get("content-type"));
|
||||
}
|
||||
sb.append(CLOUDAPI_LF);
|
||||
|
||||
//签名优先读取HTTP_CA_HEADER_DATE,因为通过浏览器过来的请求不允许自定义Date(会被浏览器认为是篡改攻击)
|
||||
if (headers.get("date") != null) {
|
||||
sb.append(headers.get("date"));
|
||||
}
|
||||
sb.append(CLOUDAPI_LF);
|
||||
|
||||
//将headers合成一个字符串
|
||||
sb.append(buildHeaders(headers));
|
||||
|
||||
//url
|
||||
sb.append(URL);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将headers合成一个字符串
|
||||
* 需要注意的是,HTTP头需要按照字母排序加入签名字符串
|
||||
* 同时所有加入签名的头的列表,需要用逗号分隔形成一个字符串,加入一个新HTTP头@"X-Ca-Signature-Headers"
|
||||
*/
|
||||
private static String buildHeaders(Map<String, String> headers) {
|
||||
//使用TreeMap,默认按照字母排序
|
||||
Map<String, String> headersToSign = new TreeMap<>();
|
||||
|
||||
|
||||
StringBuilder signHeadersStringBuilder = new StringBuilder();
|
||||
|
||||
int flag = 0;
|
||||
for (Map.Entry<String, String> header : headers.entrySet()) {
|
||||
if (header.getKey().startsWith("x-ca-")) {
|
||||
if (flag != 0) {
|
||||
signHeadersStringBuilder.append(",");
|
||||
}
|
||||
flag++;
|
||||
signHeadersStringBuilder.append(header.getKey());
|
||||
headersToSign.put(header.getKey(), header.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
//同时所有加入签名的头的列表,需要用逗号分隔形成一个字符串,加入一个新HTTP头@"X-Ca-Signature-Headers"
|
||||
headers.put("x-ca-signature-headers",signHeadersStringBuilder.toString());
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map.Entry<String, String> e : headersToSign.entrySet()) {
|
||||
sb.append(e.getKey()).append(':').append(e.getValue()).append(CLOUDAPI_LF);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成签名串
|
||||
* @param stringToSign 签名串
|
||||
* @return 生成的签名串
|
||||
*/
|
||||
public static String sign(String stringToSign) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
|
||||
Mac hmacSha256 = Mac.getInstance("HmacSHA256");
|
||||
byte[] keyBytes = APP_SECRET.getBytes(StandardCharsets.UTF_8);
|
||||
hmacSha256.init(new SecretKeySpec(keyBytes, 0, keyBytes.length, "HmacSHA256"));
|
||||
return new String(Base64.encodeBase64(hmacSha256.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8))));
|
||||
}
|
||||
|
||||
|
||||
public String sendSyncRequest(Map<String, String> headers,byte[] body) {
|
||||
HttpUriRequest httpRequest = buildRequest(headers,body);
|
||||
CloseableHttpResponse httpResponse = null;
|
||||
try {
|
||||
httpResponse = httpClient.execute(httpRequest);
|
||||
return parseToApiResponse(httpResponse);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
closeQuietly(httpResponse);
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeQuietly(Closeable closeable) {
|
||||
try {
|
||||
if (closeable != null) {
|
||||
closeable.close();
|
||||
}
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static HttpUriRequest buildRequest(Map<String, String> headers,byte[] body) {
|
||||
RequestBuilder builder = RequestBuilder.create(HTTP_METHOD);
|
||||
|
||||
/*
|
||||
* 拼接URL
|
||||
* HTTP + HOST + PATH(With pathparameter) + Query Parameter
|
||||
*/
|
||||
try {
|
||||
URIBuilder uriBuilder = new URIBuilder();
|
||||
uriBuilder.setScheme("HTTP");
|
||||
uriBuilder.setHost(HOST);
|
||||
uriBuilder.setPath(PATH);
|
||||
//增加url上参数,/get/1254131194177714180?appKey=203787616&env=PROD
|
||||
uriBuilder.addParameter("appKey",APP_KEY);
|
||||
uriBuilder.addParameter("env",ENV);
|
||||
builder.setUri(uriBuilder.build());
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException("build http request uri failed", e);
|
||||
}
|
||||
|
||||
EntityBuilder bodyBuilder = EntityBuilder.create();
|
||||
bodyBuilder.setContentType(ContentType.parse("application/octet-stream; charset=utf-8"));
|
||||
bodyBuilder.setBinary(body);
|
||||
builder.setEntity(bodyBuilder.build());
|
||||
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
builder.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static CloseableHttpClient httpClient;
|
||||
|
||||
|
||||
public static void init() {
|
||||
SocketConfig socketConfig = SocketConfig.custom().setTcpNoDelay(true).setSoKeepAlive(true).setSoReuseAddress(true)
|
||||
.setSoTimeout(10000).build();
|
||||
Registry<ConnectionSocketFactory> registry = getRegistry();
|
||||
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry);
|
||||
connectionManager.setDefaultConnectionConfig(ConnectionConfig.custom().build());
|
||||
connectionManager.setDefaultSocketConfig(socketConfig);
|
||||
connectionManager.setMaxTotal(64);
|
||||
connectionManager.setDefaultMaxPerRoute(5);
|
||||
RequestConfig defaultConfig = RequestConfig.custom()
|
||||
.setConnectTimeout(10000)
|
||||
.setSocketTimeout(10000)
|
||||
.setConnectionRequestTimeout(10000)
|
||||
.build();
|
||||
httpClient = HttpClients.custom().setConnectionManager(connectionManager).setDefaultRequestConfig(defaultConfig).build();
|
||||
}
|
||||
|
||||
private static Registry<ConnectionSocketFactory> getRegistry() {
|
||||
RegistryBuilder<ConnectionSocketFactory> registryBuilder = RegistryBuilder.create();
|
||||
try {
|
||||
registryBuilder.register("http", PlainConnectionSocketFactory.INSTANCE).build();
|
||||
registryBuilder.register("https",new SSLConnectionSocketFactory(SSLContext.getDefault(), new DefaultHostnameVerifier()));
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("HttpClientUtil init failure !", e);
|
||||
}
|
||||
return registryBuilder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理接口返回参数
|
||||
* @param httpResponse 相应信息
|
||||
* @return 返回接口中的内容封装成字符串
|
||||
* @throws IOException 异常
|
||||
*/
|
||||
private String parseToApiResponse(HttpResponse httpResponse) throws IOException {
|
||||
logger.info("code:"+httpResponse.getStatusLine().getStatusCode());
|
||||
// message
|
||||
logger.info("message:"+httpResponse.getStatusLine().getReasonPhrase());
|
||||
|
||||
if(httpResponse.getEntity() != null){
|
||||
// content type
|
||||
Header contentType = httpResponse.getEntity().getContentType();
|
||||
if(contentType != null){
|
||||
logger.info("ContentType:"+contentType.getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.info("ContentType:application/text; charset=utf-8");
|
||||
}
|
||||
logger.info(httpResponse.getEntity());
|
||||
// body
|
||||
return new String(EntityUtils.toByteArray(httpResponse.getEntity()));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -26,6 +26,7 @@ import java.io.IOException;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class BuilderPackageEcology extends Application {
|
||||
|
||||
|
@ -115,7 +116,11 @@ public class BuilderPackageEcology extends Application {
|
|||
try {
|
||||
FileCompressor.compressFiles(filePaths, outputFile.getAbsolutePath(), path -> {
|
||||
String rootPath = Util.class.getResource("/").getPath();
|
||||
rootPath = rootPath.split(File.separator + FileTreeBuilder.targetPath)[0] + File.separator + FileTreeBuilder.targetPath + FileTreeBuilder.classPath;
|
||||
if(rootPath.startsWith("/")){
|
||||
rootPath = rootPath.substring(1);
|
||||
rootPath = rootPath.replace("/",File.separator);
|
||||
}
|
||||
rootPath = rootPath.split(Pattern.quote(File.separator + FileTreeBuilder.targetPath))[0] + File.separator + FileTreeBuilder.targetPath + FileTreeBuilder.classPath;
|
||||
String replace = "/ecology/" + (isEcology ? "WEB-INF/classes/" : "classbean/");
|
||||
if (path.endsWith(".jar")) {
|
||||
replace = "/ecology/WEB-INF/lib/";
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* <h1>测试自动打包</h1>
|
||||
|
@ -25,7 +26,12 @@ public class AutoPackageJar {
|
|||
|
||||
public static void createJar(String targetPath) {
|
||||
String path = AutoPackageJar.class.getResource("").getPath();
|
||||
String finalPath = path.split(File.separator + targetPath)[0] + File.separator + targetPath + FileTreeBuilder.classPath;
|
||||
if(path.startsWith("/")){
|
||||
path = path.substring(1);
|
||||
path = path.replace("/",File.separator);
|
||||
}
|
||||
String regex = File.separator + targetPath;
|
||||
String finalPath = path.split(Pattern.quote(regex))[0] + File.separator + targetPath + FileTreeBuilder.classPath;
|
||||
createJar(finalPath + "aiyh", finalPath + "aiyh_utils.jar");
|
||||
createJar(finalPath + "ebu7common", finalPath + "ebu7common.jar");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package chaoyang.he.hangtiankeji;
|
||||
|
||||
import basetest.BaseTest;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DemoTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void test01(){
|
||||
System.out.println("测试成功");
|
||||
}
|
||||
}
|
|
@ -84,10 +84,10 @@ INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename,
|
|||
VALUES (-989, 'workflowid', '工作流id:workflowid', 'workflow_requestbase', 999, 'main table', '单行文本', '1');
|
||||
-- 创建试图
|
||||
create
|
||||
or replace view workflow_field_table_view as
|
||||
or replace view workflow_field_table_view as
|
||||
select wb.id,
|
||||
wb.fieldname,
|
||||
concat(ht.indexdesc, ':', wb.fieldname) indexdesc,
|
||||
concat(ht.indexdesc, ':', wb.fieldname,'(',wb.id,')') indexdesc,
|
||||
(
|
||||
case
|
||||
when wb.detailtable is null then (select distinct tablename from workflow_bill where id = wb.billid)
|
||||
|
@ -103,16 +103,12 @@ select wb.id,
|
|||
when wb.detailtable is null then 'main table'
|
||||
else wb.detailtable end
|
||||
) showtablename,
|
||||
(case
|
||||
when wb.fieldhtmltype = '1' then '单行文本框'
|
||||
when wb.FIELDHTMLTYPE = '2' then '多行文本框'
|
||||
when wb.FIELDHTMLTYPE = '3' then '流览框'
|
||||
when wb.FIELDHTMLTYPE = '4' then 'check框'
|
||||
when wb.FIELDHTMLTYPE = '5' then '选择框'
|
||||
else '附件上传' end) fieldhtmltype,
|
||||
|
||||
wf.TYPENAME as fieldhtmltype,
|
||||
wb.FIELDHTMLTYPE fieldtype
|
||||
from workflow_billfield wb
|
||||
left join htmllabelindex ht on wb.fieldlabel = ht.id
|
||||
left join workflow_fieldtype wf on wf.ID = wb.fieldhtmltype
|
||||
union all
|
||||
select *
|
||||
from cus_workflow_base_field_assist;
|
||||
|
|
|
@ -91,7 +91,7 @@ VALUES (-989, 'workflowid', '工作流id:workflowid', 'workflow_requestbase',
|
|||
create or replace view workflow_field_table_view as
|
||||
select wb.id,
|
||||
wb.fieldname,
|
||||
(ht.indexdesc || ':' || wb.fieldname) indexdesc,
|
||||
(ht.indexdesc || ':' || wb.fieldname || '(' || CAST(wb.id as VARCHAR2(10)) || ')') indexdesc,
|
||||
(
|
||||
case
|
||||
when wb.detailtable is null then (select distinct tablename from workflow_bill where id = wb.billid)
|
||||
|
@ -107,16 +107,11 @@ select wb.id,
|
|||
when wb.detailtable is null then 'main table'
|
||||
else wb.detailtable end
|
||||
) showtablename,
|
||||
(case
|
||||
when wb.fieldhtmltype = '1' then '单行文本框'
|
||||
when wb.FIELDHTMLTYPE = '2' then '多行文本框'
|
||||
when wb.FIELDHTMLTYPE = '3' then '流览框'
|
||||
when wb.FIELDHTMLTYPE = '4' then 'check框'
|
||||
when wb.FIELDHTMLTYPE = '5' then '选择框'
|
||||
else '附件上传' end) fieldhtmltype,
|
||||
wf.TYPENAME as fieldhtmltype,
|
||||
wb.FIELDHTMLTYPE fieldtype
|
||||
from workflow_billfield wb
|
||||
left join htmllabelindex ht on wb.fieldlabel = ht.id
|
||||
left join workflow_fieldtype wf on wf.ID = wb.fieldhtmltype
|
||||
union all
|
||||
select *
|
||||
from cus_workflow_base_field_assist /
|
||||
|
|
|
@ -95,7 +95,7 @@ drop view workflow_field_table_view
|
|||
create view workflow_field_table_view as
|
||||
select wb.id,
|
||||
wb.fieldname,
|
||||
(ht.indexdesc + ':' + wb.fieldname) indexdesc,
|
||||
(ht.indexdesc + ':' + wb.fieldname + '(' + CONVERT(varchar(10),wb.id) + ')') indexdesc,
|
||||
(
|
||||
case
|
||||
when wb.detailtable is null then (select distinct tablename from workflow_bill where id = wb.billid)
|
||||
|
@ -111,16 +111,11 @@ select wb.id,
|
|||
when wb.detailtable is null then 'main table'
|
||||
else wb.detailtable end
|
||||
) showtablename,
|
||||
(case
|
||||
when wb.fieldhtmltype = '1' then '单行文本框'
|
||||
when wb.FIELDHTMLTYPE = '2' then '多行文本框'
|
||||
when wb.FIELDHTMLTYPE = '3' then '流览框'
|
||||
when wb.FIELDHTMLTYPE = '4' then 'check框'
|
||||
when wb.FIELDHTMLTYPE = '5' then '选择框'
|
||||
else '附件上传' end) fieldhtmltype,
|
||||
wf.TYPENAME as fieldhtmltype,
|
||||
wb.FIELDHTMLTYPE fieldtype
|
||||
from workflow_billfield wb
|
||||
left join htmllabelindex ht on wb.fieldlabel = ht.id
|
||||
left join workflow_fieldtype wf on wf.ID = wb.fieldhtmltype
|
||||
union all
|
||||
select *
|
||||
from cus_workflow_base_field_assist go
|
||||
|
|
Loading…
Reference in New Issue