first commit

This commit is contained in:
陈现府
2025-11-20 10:45:16 +08:00
commit 8355431361
2643 changed files with 291314 additions and 0 deletions
@@ -0,0 +1,344 @@
package Test;
import com.alipay.api.AlipayApiException;
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponse;
import com.aliyun.dingtalkworkflow_1_0.models.*;
import com.aliyun.tea.*;
import com.baomidou.mybatisplus.extension.exceptions.ApiException;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiV2UserGetuserinfoRequest;
import com.dingtalk.api.response.OapiV2UserGetuserinfoResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mhd.common.core.domain.thirdparty.dingtalk.UserGetuserinfoDTO;
import org.json.JSONArray;
import java.rmi.ServerException;
import java.util.ArrayList;
import java.util.List;
public class Test {
/**
* <b>description</b> :
* <p>使用 Token 初始化账号Client</p>
* @return Client
*
* @throws Exception
*/
public static com.aliyun.dingtalkoauth2_1_0.Client createClient() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
config.protocol = "https";
config.regionId = "central";
return new com.aliyun.dingtalkoauth2_1_0.Client(config);
}
public static com.aliyun.dingtalkworkflow_1_0.Client createClient1() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
config.protocol = "https";
config.regionId = "central";
return new com.aliyun.dingtalkworkflow_1_0.Client(config);
}
public static void main(String[] args_) throws Exception {
// oauth2AccessToken();//获取企业accessToken(企业内部应用)
// getuserinfo();//通过免登码获取用户userid(v2)
//processCodes();//通过 processCode 获取表单 schema 信息
//processInstances();//通过创建审批实例
processInstancesMore();//通过创建审批实例
//processInstancesMoretest();
// workflowProcessInstances();//获取单个审批实例详情
}
public static String oauth2AccessToken() throws Exception {
com.aliyun.dingtalkoauth2_1_0.Client client = Test.createClient();
com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest getAccessTokenRequest = new com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest()
.setAppKey("dingmacsiwfqeowfii7t")
.setAppSecret("o0LyJKP9gM9W_GUzbdfTsFzGcipJQlSj9Q0-Mhi8WXgeLuOOp4999e2GmaNrjSo2");
try {
GetAccessTokenResponse getAccessTokenResponse=client.getAccessToken(getAccessTokenRequest);
System.out.println(getAccessTokenResponse.getBody().getAccessToken());
return getAccessTokenResponse.getBody().getAccessToken();
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
}
return null;
}
/**
* 通过免登码获取用户userid(v2)
* @param
* @return
* @throws ServerException
*/
public static void getuserinfo() throws ServerException, AlipayApiException {
try {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/getuserinfo");
OapiV2UserGetuserinfoRequest req = new OapiV2UserGetuserinfoRequest();
req.setCode("922b5b36b9a8333ba0b46d140a105ea8");
OapiV2UserGetuserinfoResponse rsp = null;
try {
rsp = client.execute(req, "c8ae82fc8c5f37cf984e655663a9e4cd");
System.out.println(rsp.getResult().getName());
} catch (com.taobao.api.ApiException e) {
e.printStackTrace();
}
System.out.println(rsp.getBody());
} catch (ApiException e) {
e.printStackTrace();
}
}
public static void processCodes() throws Exception {
com.aliyun.dingtalkworkflow_1_0.Client client = Test.createClient1();
com.aliyun.dingtalkworkflow_1_0.models.QuerySchemaByProcessCodeHeaders querySchemaByProcessCodeHeaders = new com.aliyun.dingtalkworkflow_1_0.models.QuerySchemaByProcessCodeHeaders();
querySchemaByProcessCodeHeaders.xAcsDingtalkAccessToken = "5e44e689c0663d6bb3ff643e6a15b6c2";
com.aliyun.dingtalkworkflow_1_0.models.QuerySchemaByProcessCodeRequest querySchemaByProcessCodeRequest = new com.aliyun.dingtalkworkflow_1_0.models.QuerySchemaByProcessCodeRequest()
.setProcessCode("PROC-9F77654D-7598-4445-8A95-653924FBA62F");
try {
QuerySchemaByProcessCodeResponse querySchemaByProcessCodeResponse= client.querySchemaByProcessCodeWithOptions(querySchemaByProcessCodeRequest, querySchemaByProcessCodeHeaders, new com.aliyun.teautil.models.RuntimeOptions());
System.out.println(querySchemaByProcessCodeResponse.getBody());
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
}
}
public static void processInstances() throws Exception {
com.aliyun.dingtalkworkflow_1_0.Client client = Test.createClient1();
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceHeaders startProcessInstanceHeaders = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceHeaders();
startProcessInstanceHeaders.xAcsDingtalkAccessToken = "5e44e689c0663d6bb3ff643e6a15b6c2";
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues0 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues()
.setName("科目")
.setValue("测试");
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues1 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues()
.setName("金额")
.setValue("100");
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues2 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues()
.setName("备注")
.setValue("测试");
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest startProcessInstanceRequest = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest()
.setDeptId(3933973362L)
.setOriginatorUserId("1036532433418969377")
.setProcessCode("PROC-9F77654D-7598-4445-8A95-653924FBA62F")
.setFormComponentValues(java.util.Arrays.asList(
formComponentValues0,formComponentValues1,formComponentValues2
));
try {
StartProcessInstanceResponse startProcessInstanceResponse=client.startProcessInstanceWithOptions(startProcessInstanceRequest, startProcessInstanceHeaders, new com.aliyun.teautil.models.RuntimeOptions());
System.out.println(startProcessInstanceResponse.getBody());
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
}
}
public static void processInstancesMore() throws Exception {
String tokrn=oauth2AccessToken();
com.aliyun.dingtalkworkflow_1_0.Client client = Test.createClient1();
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceHeaders startProcessInstanceHeaders = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceHeaders();
startProcessInstanceHeaders.xAcsDingtalkAccessToken = tokrn;
List<StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails> details=
new ArrayList<StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails>();
List<StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails> details1=
new ArrayList<StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails>();
List<String> detailsList=
new ArrayList<String>();
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails formComponentValues0Details0 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails()
.setName("业务单据号")
.setValue("测试单11111111");
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails formComponentValues0Details1 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails()
.setName("科目")
.setValue("车辆运费");
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails formComponentValues0Details2 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails()
.setName("二级科目")
.setValue("到付运费)");
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails formComponentValues0Details3 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails()
.setName("金额(元)")
.setValue("111");
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails formComponentValues0Details4 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails()
.setName("收款人")
.setValue("顾瑶");
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails formComponentValues0Details5 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails()
.setName("车辆")
.setValue("11111111");
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails formComponentValues0Details6 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails()
.setName("部门")
.setValue("研发");
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails formComponentValues0Details7 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails()
.setName("备注")
.setValue("测试");
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails formComponentValues0Details8 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails()
.setName("摘要(自有车辆)")
.setValue("211111");
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails formComponentValues0Details9 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails()
.setName("借款单据)")
.setValue("")
.setId("DDPhotoField_1MUIE7O4J4A9S");
ObjectMapper objectMapper = new ObjectMapper();
details.add(formComponentValues0Details0);
details.add(formComponentValues0Details1);
details.add(formComponentValues0Details2);
details.add(formComponentValues0Details3);
details.add(formComponentValues0Details4);
details.add(formComponentValues0Details5);
details.add(formComponentValues0Details6);
details.add(formComponentValues0Details7);
details.add(formComponentValues0Details8);
details.add(formComponentValues0Details9);
details1.add(formComponentValues0Details0);
details1.add(formComponentValues0Details1);
details1.add(formComponentValues0Details2);
details1.add(formComponentValues0Details3);
details1.add(formComponentValues0Details4);
details1.add(formComponentValues0Details5);
details1.add(formComponentValues0Details6);
details1.add(formComponentValues0Details7);
details1.add(formComponentValues0Details8);
details1.add(formComponentValues0Details9);
String detailsStr=objectMapper.writeValueAsString(details);
detailsList.add(detailsStr);
detailsList.add(objectMapper.writeValueAsString(details1));
String jsonString = objectMapper.writeValueAsString(detailsList);
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues0 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues()
.setName("表格")
.setValue(jsonString);
/* .setDetails(java.util.Arrays.asList(
formComponentValues0Details0,formComponentValues0Details1,formComponentValues0Details2,formComponentValues0Details3,formComponentValues0Details4,
formComponentValues0Details5,formComponentValues0Details6,formComponentValues0Details7,formComponentValues0Details8,formComponentValues0Details9
));*/
/*FormComponentProps formComponentProps12 = new FormComponentProps()
.setComponentId("TableField-abcd")
.setUpper("0")
.setTableViewMode("table")
.setLabel("表格");
FormComponent formComponent12 = new FormComponent()
.setComponentType("TableField")
.setProps(formComponentProps12)
.setChildren(java.util.Arrays.asList(childFormComponentChild1, childFormComponent2));*/
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues1 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues()
.setName("费用合计(元)")
.setValue("111");
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest startProcessInstanceRequest = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest()
.setDeptId(3933973362L)
.setOriginatorUserId("115819335835409924")
.setProcessCode("PROC-FC2B7E4F-FE47-45AD-88D7-1C530A729C22")
.setFormComponentValues(java.util.Arrays.asList(
formComponentValues0,formComponentValues1
));
try {
StartProcessInstanceResponse startProcessInstanceResponse=client.startProcessInstanceWithOptions(startProcessInstanceRequest, startProcessInstanceHeaders, new com.aliyun.teautil.models.RuntimeOptions());
System.out.println(startProcessInstanceResponse.getBody());
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
}
}
public static void processInstancesMoretest() throws Exception {
com.aliyun.dingtalkworkflow_1_0.Client client = Test.createClient1();
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceHeaders startProcessInstanceHeaders = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceHeaders();
startProcessInstanceHeaders.xAcsDingtalkAccessToken = "34994cc137f13b8d8e2df6e7f15600fa";
List<StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails> details=
new ArrayList<StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails>();
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails formComponentValues0Details0 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValuesDetails()
.setName("业务单号")
.setValue("测试单11111111");
details.add(formComponentValues0Details0);
ObjectMapper objectMapper = new ObjectMapper();
String jsonString = objectMapper.writeValueAsString(details);
String value="["+jsonString+"]";
JSONArray jsonArray=new JSONArray(details);
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues1 = new StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues()
.setName("表格")
.setValue(value)
.setComponentType("TableField") ;
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest startProcessInstanceRequest = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest()
.setDeptId(3933973362L)
.setOriginatorUserId("1036532433418969377")
.setProcessCode("PROC-CBBD8B9F-6753-4AFF-A313-CCFF6F97D3AC")
.setFormComponentValues(java.util.Arrays.asList(
formComponentValues1
));
try {
StartProcessInstanceResponse startProcessInstanceResponse=client.startProcessInstanceWithOptions(startProcessInstanceRequest, startProcessInstanceHeaders, new com.aliyun.teautil.models.RuntimeOptions());
System.out.println(startProcessInstanceResponse.getBody());
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
}
}
public static void workflowProcessInstances() throws Exception {
com.aliyun.dingtalkworkflow_1_0.Client client = Test.createClient1();
com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceHeaders getProcessInstanceHeaders = new com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceHeaders();
getProcessInstanceHeaders.xAcsDingtalkAccessToken = "34994cc137f13b8d8e2df6e7f15600fa";
com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceRequest getProcessInstanceRequest = new com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceRequest()
.setProcessInstanceId("iqXjSd0VRnOxD1cgtKsUNg02721752201661 ");
try {
GetProcessInstanceResponse getProcessInstanceResponse= client.getProcessInstanceWithOptions(getProcessInstanceRequest, getProcessInstanceHeaders, new com.aliyun.teautil.models.RuntimeOptions());
System.out.println("===1111111111111111======================");
System.out.println(getProcessInstanceResponse.getBody().getResult().getResult());
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
}
}
}
@@ -0,0 +1,230 @@
package com.linke.thirdParty;
import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"com.linke.thirdParty.infrastructure.feign", "com.mhd.system.api"})
@MapperScan("com.linke.thirdParty.domain.**.mapper")
@EnableAutoDataSourceProxy
public class ThirdPartyApplication {
public static void main(String[] args) {
SpringApplication.run(ThirdPartyApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 三方中台模块启动成功 ლ(´ڡ`ლ)゙ " +
"# _oo0oo_\n" +
"# o8888888o\n" +
"# 88\" . \"88\n" +
"# (| -_- |)\n" +
"# 0\\ = /0\n" +
"# ___/`---'\\___\n" +
"# .' \\\\| |// '.\n" +
"# / \\\\||| : |||// \\\n" +
"# / _||||| -:- |||||- \\\n" +
"# | | \\\\\\ - /// | |\n" +
"# | \\_| ''\\---/'' |_/ |\n" +
"# \\ .-\\__ '-' ___/-. /\n" +
"# ___'. .' /--.--\\ `. .'___\n" +
"# .\"\" '< `.___\\_<|>_/___.' >' \"\".\n" +
"# | | : `- \\`.;`\\ _ /`;.`/ - ` : | |\n" +
"# \\ \\ `_. \\_ __\\ /__ _/ .-` / /\n" +
"# =====`-.____`.___ \\_____/___.-`___.-'=====\n" +
"# `=---='\n" +
"#\n" +
"#\n" +
"# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
"#\n" +
"# 佛祖保佑 永无BUG\n" +
"#\n" +
"#    ┏┓   ┏┓\n" +
"#   ┏┛┻━━━┛┻┓\n" +
"#   ┃       \n" +
"#   ┃   ━   \n" +
"#   ┃ ┳┛ ┗┳ ┃\n" +
"#   ┃       \n" +
"#   ┃   ┻   \n" +
"#   ┃       \n" +
"#   ┗━┓   ┏━┛Codes are far away from bugs with the animal protecting\n" +
"#     ┃   ┃ 神兽保佑,代码无bug\n" +
"#     ┃   ┃\n" +
"#     ┃   ┗━━━┓\n" +
"#     ┃      ┣┓\n" +
"#     ┃     ┏┛\n" +
"#     ┗┓┓┏━┳┓┏┛\n" +
"#      ┃┫┫ ┃┫┫\n" +
"#      ┗┻┛ ┗┻┛\n" +
"#\n" +
"#    ┏┓   ┏┓\n" +
"#   ┏┛┻━━━┛┻┓\n" +
"#   ┃        \n" +
"#   ┃   ━   \n" +
"#   ┃    <┃\n" +
"#   ┃       \n" +
"#   ┃ . ⌒ ..┃\n" +
"#   ┃       \n" +
"#   ┗━┓   ┏━┛\n" +
"#     ┃   ┃ Codes are far away from bugs with the animal protecting       \n" +
"#     ┃   ┃ 神兽保佑,代码无bug\n" +
"#     ┃   ┃           \n" +
"#     ┃   ┃       \n" +
"#     ┃   ┃\n" +
"#     ┃   ┃           \n" +
"#     ┃   ┗━━━┓\n" +
"#     ┃       ┣┓\n" +
"#     ┃       ┏┛\n" +
"#     ┗┓┓┏━┳┓┏┛\n" +
"#      ┃┫┫ ┃┫┫\n" +
"#      ┗┻┛ ┗┻┛\n" +
"# ┏┓   ┏┓+ +\n" +
"#   ┏┛┻━━━┛┻┓ + +\n" +
"#   ┃       ┃  \n" +
"#   ┃   ━   ┃ ++ + + +\n" +
"#   ████━████ ┃+\n" +
"#   ┃       ┃ +\n" +
"#   ┃   ┻   ┃\n" +
"#   ┃       ┃ + +\n" +
"#   ┗━┓   ┏━┛\n" +
"#     ┃   ┃           \n" +
"#     ┃   ┃ + + + +\n" +
"#     ┃   ┃    Codes are far away from bugs with the animal protecting   \n" +
"#     ┃   ┃ +     神兽保佑,代码无bug  \n" +
"#     ┃   ┃\n" +
"#     ┃   ┃  +         \n" +
"#     ┃    ┗━━━┓ + +\n" +
"#     ┃        ┣┓\n" +
"#     ┃        ┏┛\n" +
"#     ┗┓┓┏━┳┓┏┛ + + + +\n" +
"#      ┃┫┫ ┃┫┫\n" +
"#      ┗┻┛ ┗┻┛+ + + +\n" +
"# d*##$.\n" +
"# zP\"\"\"\"\"$e. $\" $o\n" +
"#4$ '$ $\" $\n" +
"#'$ '$ J$ $F\n" +
"# 'b $k $> $\n" +
"# $k $r J$ d$\n" +
"# '$ $ $\" $~\n" +
"# '$ \"$ '$E $\n" +
"# $ $L $\" $F ...\n" +
"# $. 4B $ $$$*\"\"\"*b\n" +
"# '$ $. $$ $$ $F\n" +
"# \"$ R$ $F $\" $\n" +
"# $k ?$ u* dF .$\n" +
"# ^$. $$\" z$ u$$$$e\n" +
"# #$b $E.dW@e$\" ?$\n" +
"# #$ .o$$# d$$$$c ?F\n" +
"# $ .d$$#\" . zo$> #$r .uF\n" +
"# $L .u$*\" $&$$$k .$$d$$F\n" +
"# $$\" \"\"^\"$$$P\"$P9$\n" +
"# JP .o$$$$u:$P $$\n" +
"# $ ..ue$\" \"\" $\"\n" +
"# d$ $F $\n" +
"# $$ ....udE 4B\n" +
"# #$ \"\"\"\"` $r @$\n" +
"# ^$L '$ $F\n" +
"# RN 4N $\n" +
"# *$b d$\n" +
"# $$k $F\n" +
"# $$b $F\n" +
"# $\"\" $F\n" +
"# '$ $\n" +
"# $L $\n" +
"# '$ $\n" +
"# $ $\n" +
"#\n" +
"#\n" +
"# ┌─┐ ┌─┐\n" +
"# ┌──┘ ┴───────┘ ┴──┐\n" +
"# │ │\n" +
"# │ ─── │\n" +
"# │ ─┬┘ └┬─ │\n" +
"# │ │\n" +
"# │ ─┴─ │\n" +
"# │ │\n" +
"# └───┐ ┌───┘\n" +
"# │ │\n" +
"# │ │\n" +
"# │ │\n" +
"# │ └──────────────┐\n" +
"# │ │\n" +
"# │ ├─┐\n" +
"# │ ┌─┘\n" +
"# │ │\n" +
"# └─┐ ┐ ┌───────┬──┐ ┌──┘\n" +
"# │ ─┤ ─┤ │ ─┤ ─┤\n" +
"# └──┴──┘ └──┴──┘\n" +
"# 神兽保佑\n" +
"# 代码无BUG!\n" +
"#\n" +
"# ___====-_ _-====___\n" +
"# _--^^^#####// \\\\#####^^^--_\n" +
"# _-^##########// ( ) \\\\##########^-_\n" +
"# -############// |\\^^/| \\\\############-\n" +
"# _/############// (@::@) \\\\############\\_\n" +
"# /#############(( \\\\// ))#############\\\n" +
"# -###############\\\\ (oo) //###############-\n" +
"# -#################\\\\ / VV \\ //#################-\n" +
"# -###################\\\\/ \\//###################-\n" +
"# _#/|##########/\\######( /\\ )######/\\##########|\\#_\n" +
"# |/ |#/\\#/\\#/\\/ \\#/\\##\\ | | /##/\\#/ \\/\\#/\\#/\\#| \\|\n" +
"# ` |/ V V ` V \\#\\| | | |/#/ V ' V V \\| '\n" +
"# ` ` ` ` / | | | | \\ ' ' ' '\n" +
"# ( | | | | )\n" +
"# __\\ | | | | /__\n" +
"# (vvv(VVV)(VVV)vvv)\n" +
"# 神兽保佑\n" +
"# 代码无BUG!\n" +
"# __----~~~~~~~~~~~------___\n" +
"# . . ~~//====...... __--~ ~~\n" +
"# -. \\_|// |||\\\\ ~~~~~~::::... /~\n" +
"# ___-==_ _-~o~ \\/ ||| \\\\ _/~~-\n" +
"# __---~~~.==~||\\=_ -_--~/_-~|- |\\\\ \\\\ _/~\n" +
"# _-~~ .=~ | \\\\-_ '-~7 /- / || \\ /\n" +
"# .~ .~ | \\\\ -_ / /- / || \\ /\n" +
"# / ____ / | \\\\ ~-_/ /|- _/ .|| \\ /\n" +
"# |~~ ~~|--~~~~--_ \\ ~==-/ | \\~--===~~ .\\\n" +
"# ' ~-| /| |-~\\~~ __--~~\n" +
"# |-~~-_/ | | ~\\_ _-~ /\\\n" +
"# / \\ \\__ \\/~ \\__\n" +
"# _--~ _/ | .-~~____--~-/ ~~==.\n" +
"# ((->/~ '.|||' -_| ~~-/ , . _||\n" +
"# -_ ~\\ ~~---l__i__i__i--~~_/\n" +
"# _-~-__ ~) \\--______________--~~\n" +
"# //.-~~~-~_--~- |-------~~~~~~~~\n" +
"# //.-~~~--\\\n" +
"# 神兽保佑\n" +
"# 代码无BUG!\n" +
"# ,----------------, ,---------,\n" +
"# ,-----------------------, ,\" ,\"|\n" +
"# ,\" ,\"| ,\" ,\" |\n" +
"# +-----------------------+ | ,\" ,\" |\n" +
"# | .-----------------. | | +---------+ |\n" +
"# | | | | | | -==----'| |\n" +
"# | | I LOVE DOS! | | | | | |\n" +
"# | | Bad command or | | |/----|`---= | |\n" +
"# | | C:\\>_ | | | ,/|==== ooo | ;\n" +
"# | | | | | // |(((( [33]| ,\"\n" +
"# | `-----------------' |,\" .;'| |(((( | ,\"\n" +
"# +-----------------------+ ;; | | |,\"\n" +
"# /_)______________(_/ //' | +---------+\n" +
"# ___________________________/___ `,\n" +
"# / oooooooooooooooo .o. oooo /, \\,\"-----------\n" +
"# / ==ooooooooooooooo==.o. ooo= // ,`\\--{)B ,\"\n" +
"# /_==__==========__==_ooo__ooo=_/' /___________,\"\n" +
"#\n" +
"# .-~~~~~~~~~-._ _.-~~~~~~~~~-.\n" +
"# __.' ~. .~ `.__\n" +
"# .'// \\./ \\\\`.\n" +
"# .'// | \\\\`.\n" +
"# .'// .-~\"\"\"\"\"\"\"~~~~-._ | _,-~~~~\"\"\"\"\"\"\"~-. \\\\`.\n" +
"# .'//.-\" `-. | .-' \"-.\\\\`.\n" +
"# .'//______.============-.. \\ | / ..-============.______\\\\`.\n" +
"# .'______________________________\\|/______________________________`.");
}
}
@@ -0,0 +1,273 @@
package com.linke.thirdParty.application.server;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.internal.util.AlipaySignature;
import com.alipay.api.request.AlipayTradeAppPayRequest;
import com.alipay.api.response.AlipayTradeAppPayResponse;
import com.linke.thirdParty.domain.departInterfaceInfo.repository.todo.SysDepartInterfaceInfoDo;
import com.linke.thirdParty.domain.thridCall.entity.ThridCall;
import com.linke.thirdParty.domain.thridCall.repository.todo.ThridCallDO;
import com.linke.thirdParty.domain.thridCall.service.ThridCallDomainService;
import com.mhd.common.core.domain.po.AplipayTransferPO;
import com.mhd.common.core.domain.po.thirdparty.SysDepartInterfaceInfoPo;
import com.mhd.common.core.domain.thirdparty.AlipayPrepayDTO;
import com.mhd.common.core.domain.thirdparty.AlipayRequestInfoDTO;
import com.mhd.common.core.domain.thirdparty.AplipayTransferDTO;
import com.mhd.common.core.domain.thirdparty.ThridPayCallDTO;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.system.api.FinanceServiceFeign;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alipay.api.AlipayConfig;
import com.alipay.api.request.AlipayFundTransUniTransferRequest;
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
import com.alipay.api.domain.AlipayFundTransUniTransferModel;
import com.alipay.api.domain.Participant;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.rmi.ServerException;
import java.util.*;
@Service
public class AlipayApplicationService {
@Autowired
private ThridCallDomainService thridCallDomainService;
@Autowired
private FinanceServiceFeign financeServiceFeign;
@Autowired
private SysDepartInterfaceInfoApplicationService sysDepartInterfaceInfoApplicationService;
//支付宝支付回调地址
private static final ThreadLocal<String> notify_url = new ThreadLocal<>();
/**
* APP下单
* @param alipayPrepayDTO
* @return
* @throws ServerException
*/
public String alipayPrepay(AlipayPrepayDTO alipayPrepayDTO) throws ServerException, AlipayApiException {
// 初始化SDK(证书用法)
AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
request.setNotifyUrl(notify_url.get());
JSONObject bizContent = new JSONObject();
bizContent.put("out_trade_no", alipayPrepayDTO.getOutTradeNo());
bizContent.put("total_amount", alipayPrepayDTO.getTotalAmount());
bizContent.put("subject", alipayPrepayDTO.getSubject());
// bizContent.put("product_code", "QUICK_MSECURITY_PAY");
//bizContent.put("time_expire", "2022-08-01 22:00:00");
//// 商品明细信息,按需传入
//JSONArray goodsDetail = new JSONArray();
//JSONObject goods1 = new JSONObject();
//goods1.put("goods_id", "goodsNo1");
//goods1.put("goods_name", "子商品1");
//goods1.put("quantity", 1);
//goods1.put("price", 0.01);
//goodsDetail.add(goods1);
//bizContent.put("goods_detail", goodsDetail);
//// 扩展信息,按需传入
//JSONObject extendParams = new JSONObject();
//extendParams.put("sys_service_provider_id", "2088511833207846");
//bizContent.put("extend_params", extendParams);
request.setBizContent(bizContent.toString());
AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
String orderStr = response.getBody();
if(response.isSuccess()){
System.out.println("调用成功");
return orderStr;
} else {
throw new ServerException("调用失败");
// System.out.println("调用失败");
}
}
public void payCall(HttpServletRequest request) throws AlipayApiException {
String servletPath = request.getServletPath();
String serverName = request.getServerName();
StringBuffer requestURL = request.getRequestURL();
//获取支付宝POST过来反馈信息
Map<String,String> params = new HashMap<String,String>();
Map requestParams = request.getParameterMap();
for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext ();) {
String name = ( String )iter.next();
String[] values = (String[])requestParams.get(name);
String valueStr="";
for(int i = 0;i < values.length; i++){
valueStr = (i== values.length-1)?valueStr+values[i]:valueStr+values[i] + ",";
}
//乱码解决,这段代码在出现乱码时使用。
//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
params.put(name,valueStr);
}
//切记alipayPublicCertPath是支付宝公钥证书路径,请去open.alipay.com对应应用下载。
//boolean AlipaySignature.rsaCertCheckV1(Map<String, String> params, String publicKeyCertPath, String charset,String signType)
boolean flag = AlipaySignature.rsaCertCheckV1(params,
"/cert/alipayPublicCert.crt",
"UTF-8",
"RSA2");
ThridCallDO thridCall = new ThridCallDO();
thridCall.setCallMethod("/alipayApi/payCall");
thridCall.setCallType(1L);
thridCall.setCallParam(params.toString());
thridCall.setCreateTime(new Date());
thridCallDomainService.insert(thridCall);
System.out.println("支付成功!!!!!!!!!!!!!!!!!");
//成功回调财务进行支付流水保存
if (flag){
ThridPayCallDTO thridPayCallDTO = new ThridPayCallDTO();
thridPayCallDTO.setOutTradeNo(params.get("out_trade_no"));
thridPayCallDTO.setTradeNo(params.get("trade_no"));
thridPayCallDTO.setTotalAmount(new BigDecimal(params.get("total_amount")));
if (params.get("trade_status").equals("TRADE_SUCCESS")){
thridPayCallDTO.setTradeType(1);
}else {
thridPayCallDTO.setTradeType(2);
}
//财务发起保存流水
financeServiceFeign.thridPayCall(thridPayCallDTO);
}
}
public AplipayTransferPO alipayTransfer(AplipayTransferDTO aplipayTransferDTO) throws AlipayApiException, ServerException {
// 初始化SDK
AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
// 构造请求参数以调用接口
AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest();
AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel();
// 设置转账业务的标题
model.setOrderTitle(aplipayTransferDTO.getOrderTitle());
// 设置描述特定的业务场景
model.setBizScene(aplipayTransferDTO.getBizScene());
JSONObject jsonObject = new JSONObject();
jsonObject.put("payer_show_name_use_alias",aplipayTransferDTO.getPayerShowNameUseAlias());
// 设置转账业务请求的扩展参数
model.setBusinessParams(jsonObject.toJSONString());
// 设置业务备注
model.setRemark(aplipayTransferDTO.getRemark());
// 设置商家侧唯一订单号
model.setOutBizNo(aplipayTransferDTO.getOutBizNo());
// 设置订单总金额
model.setTransAmount(aplipayTransferDTO.getTransAmount());
// 设置业务产品码
model.setProductCode(aplipayTransferDTO.getProductCode());
// 设置收款方信息
Participant payeeInfo = new Participant();
payeeInfo.setIdentity(aplipayTransferDTO.getIdentity());
payeeInfo.setName(aplipayTransferDTO.getName());
payeeInfo.setIdentityType(aplipayTransferDTO.getIdentityType());
model.setPayeeInfo(payeeInfo);
request.setBizModel(model);
AlipayFundTransUniTransferResponse response = alipayClient.certificateExecute(request);
String body = response.getBody();
JSONObject jsonObject1 = JSONObject.parseObject(body);
AplipayTransferPO aplipayTransferPO = JSON.parseObject(jsonObject1.get("alipay_fund_trans_uni_transfer_response").toString(), AplipayTransferPO.class);
System.out.println(response.getBody());
//保存转账记录
ThridCallDO thridCall = new ThridCallDO();
thridCall.setCallMethod("/alipayApi/alipayTransfer");
thridCall.setCallType(2L);
thridCall.setCallParam(response.getBody());
thridCall.setCreateTime(new Date());
thridCallDomainService.insert(thridCall);
if (response.isSuccess()) {
System.out.println("调用成功");
} else {
throw new ServerException(aplipayTransferPO.getSub_msg());
// System.out.println("调用失败");
// sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接
// String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response);
// System.out.println(diagnosisUrl);
}
return aplipayTransferPO;
}
/**
* 初始化SDK
* @return
*/
private AlipayConfig getAlipayConfig() {
AlipayRequestInfoDTO alipayRequestInfoDTO = getAppInfo();
// String privateKey = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCdGnWIuFSDMVzngENCBttbSJ5pYDWVlmxpHIDriF5bfau9z4KsqlFtBHURhM/vuald5MF1JLP40du2h3LfdjjhBPcMv24t1zF67S8zp4iEhOz0lhG3xpSFmLxdJfcyRVmh65JK49hCaKz3ck+K//75K2PsqNaDalJerSyaLKmFR+oJDZDMWoDwx+xJsipmjkBCbLOpp1rE7bc5u63ir2CEcNu4540FDsOdPhQWfUV194KtVFr8Ndl7v/ccpgm/snZQaSk7YlFGHnhl1vBv53ME/IoUmA9wjxsad89Jdb2jJzHnPaKfSUVxVMBp0xWqTMNkEAWEL785NW5LyG8+zqhtAgMBAAECggEAfo8BHhm4Y1ORzyDBjeAuN9RBYQxTPmVGgkqnBJb/xF5xyt/vGh++pr8PfARs6ma7rNsKic7+eLS+dcWZ4bDAU22Hg6p3HNCdmLSX8NnGnVLj/IkkTtLXdOQ84iEiiUna0hkO6euwnJbsuA5LS+O8SIgO4GiHHqi5IHILW0wdaDLmd4LTYt8OstBaSJm8PH8nRpbx2C/q2BN5J1TbZ0HlvglMlhv0lQkjCJsJIxzQ7BEnOU7k2BjEHQM04ccbQKNm9usXAltIRMStcBsQHBF+LB/spI9RS+cxTqeUPRhzh/FtlsQjHzm8XSoorNNTbiR3QTf+ONC+GOm4jHTO7jy9gQKBgQDrOq0ckVFOhjMld22Hp/j7WGMlgNQ3qw8YKVuaPMTmYbUQykaP2gFdWcPVNaEW6+HuxWAlGadDus17kP3sXVdu91lSVvAH+4P0Br3YEHv2MgdwarB/X+p4H1e5WVyxpxrHz1m2128lx7D6E686zyCsqQp1FqKEW3+bNvq2hjOpYQKBgQCq+cJEddUChOLtNe7m/0BmNBWgiA8lwiBd98RQvocX19JwaPrJvEeSaNzPtLXu40t3rteu9BZ5wcjV5V819H1o3klN+vLveWQsiK4d4+PdxpPdkYE9tGJ9vecyymnRRsfWjHhPFxMk98cnRtJ+RKRhJNvCYLn0/9GQJ8BlESEejQKBgCgtm4f3okWhUnch0QmMvVBhJn4vZRAlHazo04aivpcDNWQqyKale/ov7O0r/dnmbG7WM7fii9lbvOFQQK7wupBvm0gfJVyXr1AtHpwbJLFGllKzRnZbMbdW0ysLgnOtsTtTxWUfoxJ261mrpxCKdHBJZ0ncleG5pzAh0ez/Oy/BAoGABhzNxDLOPbvQfRiLhPilLcI477dNi1UIYTOlchmNrN2LaXdnV+UCTgqvskFMq9C2dv3qOhgB4bJ64qLDp6MpBKHFzyLkookderYcO3dVQy2BRc+Y5kLXrpUmedtgsxmrtVDqUDGL/qtZFF9k0RzVH5/4t1dL7qVisZuqNjLJk1UCgYANwzQ0dut5HUGO6LISSjGuQUXATEkjSg0zeGcsd++Mih+NCWnXa5x9Q1vjgOuZST+n2LzcKYL9be1EpptLjeZmiU91NGezPd+p1jBJpOATh10+sOWvnIccwy68fL93VEKAXCF4RgsNrflqa71yRskx/mYKfzj/B7S3U0TSdEOzJw==";
AlipayConfig alipayConfig = new AlipayConfig();
alipayConfig.setPrivateKey(alipayRequestInfoDTO.getPrivateKey());
alipayConfig.setServerUrl(alipayRequestInfoDTO.getServerUrl());
alipayConfig.setAppId(alipayRequestInfoDTO.getAppId());
alipayConfig.setCharset("UTF-8");
alipayConfig.setSignType("RSA2");
alipayConfig.setFormat("json");
//应用公钥证书文件路径
alipayConfig.setAppCertPath(alipayRequestInfoDTO.getAppCertPath());
//支付宝公钥证书文件路径
alipayConfig.setAlipayPublicCertPath(alipayRequestInfoDTO.getAlipayPublicCertPath());
//支付宝根证书文件路径
alipayConfig.setRootCertPath(alipayRequestInfoDTO.getRootCertPath());
return alipayConfig;
}
/**
* 封装基础参数并返回商户服务
* @return
*/
public AlipayRequestInfoDTO getAppInfo(){
AlipayRequestInfoDTO alipayRequestInfoDTO = new AlipayRequestInfoDTO();
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
sysDepartInterfaceInfoDo.setInterfaceType("alipay");
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPos = sysDepartInterfaceInfoApplicationService.queryList(sysDepartInterfaceInfoDo);
for (SysDepartInterfaceInfoPo sysDepartInterfaceInfoPo : sysDepartInterfaceInfoPos) {
String interfaceTypeKey = sysDepartInterfaceInfoPo.getInterfaceTypeKey();
String interfaceTypeValue = sysDepartInterfaceInfoPo.getInterfaceTypeValue();
switch (interfaceTypeKey) {
case "private_key":
alipayRequestInfoDTO.setPrivateKey(interfaceTypeValue);
break;
case "server_url":
alipayRequestInfoDTO.setServerUrl(interfaceTypeValue);
break;
case "app_id":
alipayRequestInfoDTO.setAppId(interfaceTypeValue);
break;
case "app_cert_path1":
alipayRequestInfoDTO.setAppCertPath(interfaceTypeValue);
break;
case "alipay_public_cert_path1":
alipayRequestInfoDTO.setAlipayPublicCertPath(interfaceTypeValue);
break;
case "root_cert_path1":
alipayRequestInfoDTO.setRootCertPath(interfaceTypeValue);
break;
case "notify_url":
notify_url.set(interfaceTypeValue);
break;
default:
break;
}
}
return alipayRequestInfoDTO;
}
}
@@ -0,0 +1,289 @@
package com.linke.thirdParty.application.server;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.linke.thirdParty.domain.departInterfaceInfo.entity.SysDepartInterfaceInfo;
import com.linke.thirdParty.domain.departInterfaceInfo.service.SysDepartInterfaceInfoDomainService;
import com.mhd.common.core.domain.thirdparty.AmapDTO;
import com.mhd.common.core.domain.po.thirdparty.RegeocodesAddressPo;
import com.mhd.common.core.domain.po.thirdparty.RegeocodesPo;
import com.mhd.common.core.domain.thirdparty.AmapPoiKeywordDTO;
import com.mhd.common.core.domain.thirdparty.AmapPoiLocationDTO;
import com.mhd.common.core.utils.HttpClientUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Transactional
@Slf4j
public class AmapApplicationService {
@Autowired
private SysDepartInterfaceInfoDomainService sysDepartInterfaceInfoDomainService;
/**
* 高德Key 用户在高德地图官网申请Web服务API类型Key
*/
public static String AMAP_KEY="02dee5658cd0b368b3d62a70dccd1851";
/**
* 地理编码
*/
public static String GEOCODE = "http://restapi.amap.com/v3/geocode/geo?key=";
/**
* 距离测量
*/
public static String DISTANCE = "http://restapi.amap.com/v3/distance?key=";
/**
* @Description 逆地理编码API服务地址,通过经纬度获取地址详细信息
* @Author Alex
* @Date 2022/2/12 13:27
*/
public static String regeo = "https://restapi.amap.com/v3/geocode/regeo?key=";
/**
* 搜索poi
* @param amapDTO
* @return
*/
public static String poi = "https://restapi.amap.com/v3/place/text?key=";
public String queryDistance(AmapDTO amapDTO) {
getBaseInfo();
String result = "";
try {
String origins;
String destination;
if (StrUtil.isNotEmpty(amapDTO.getOrigin()) && StrUtil.isNotEmpty(amapDTO.getDestination())) {
origins = amapDTO.getOrigin();
destination = amapDTO.getDestination();
} else {
String loadAddress = amapDTO.getLoadingAddress();
String unloadAddress = amapDTO.getUnloadAddress();
origins = geo(loadAddress.trim());
destination = geo(unloadAddress.trim());
}
result = distance(origins,destination);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
* @Description 逆地理编码
* location:经纬度坐标;最多支持20个坐标点;多个点之间用"|"分割。
* extensionsextensions 参数默认取值是 base,也就是返回基本地址信息;
* extensions 参数默认取值是 base,也就是返回基本地址信息; extensions 参数取值为 all 时会返回基本地址信息、附近 POI 内容、道路信息以及道路交叉口信息
* batchbatch=true为批量查询。batch=false为单点查询
* @Author Alex
* @Date 2022/2/12 13:44
*/
public List<RegeocodesAddressPo> regeo(String lnglat){
getBaseInfo();
List<RegeocodesAddressPo> regeocodesAddressVOList = new ArrayList<>();
Map<String,String> result = new HashMap<>();
try {
if (StringUtils.isNotBlank(lnglat)){
lnglat = URLEncoder.encode(lnglat, "UTF-8");
String regeoUrl = regeo+AMAP_KEY+"&output=JSON&location="+lnglat+"&extensions=base&batch=true";
regeoUrl = regeoUrl.trim();
String res = HttpClientUtil.requestByGetMethod(regeoUrl, false);
//String res = "{\"infocode\":\"10000\",\"regeocodes\":[{\"formatted_address\":\"湖北省武汉市东西湖区慈惠街道武汉兴旺鑫纸箱包装有限公司武汉硚鑫制冷设备公司\",\"addressComponent\":{\"businessAreas\":[[]],\"country\":\"中国\",\"province\":\"湖北省\",\"citycode\":\"027\",\"city\":\"武汉市\",\"adcode\":\"420112\",\"streetNumber\":{\"number\":\"72号\",\"distance\":\"26.7536\",\"street\":\"九通路\",\"location\":\"114.119147,30.607552\",\"direction\":\"东南\"},\"towncode\":\"420112005000\",\"district\":\"东西湖区\",\"neighborhood\":{\"name\":[],\"type\":[]},\"township\":\"慈惠街道\",\"building\":{\"name\":[],\"type\":[]}}},{\"formatted_address\":\"湖北省咸宁市通山县通羊镇通山一中教师公寓瑞杏园\",\"addressComponent\":{\"businessAreas\":[[]],\"country\":\"中国\",\"province\":\"湖北省\",\"citycode\":\"0715\",\"city\":\"咸宁市\",\"adcode\":\"421224\",\"streetNumber\":{\"number\":\"97号\",\"distance\":\"250.405\",\"street\":\"洋都大道\",\"location\":\"114.477694,29.606653\",\"direction\":\"东北\"},\"towncode\":\"421224100000\",\"district\":\"通山县\",\"neighborhood\":{\"name\":[],\"type\":[]},\"township\":\"通羊镇\",\"building\":{\"name\":[],\"type\":[]}}}],\"status\":\"1\",\"info\":\"OK\"}";
JSONObject jsonObject = JSONObject.parseObject(res);
log.info(jsonObject.toString());
String infocode = jsonObject.get("infocode").toString();
if("10000".equals(infocode)){
JSONArray regeocodes = jsonObject.getJSONArray("regeocodes");
List<RegeocodesPo> regeocodesList = regeocodes.toJavaList(RegeocodesPo.class);
//返回数据类
for(RegeocodesPo regeocodesPo : regeocodesList){
RegeocodesAddressPo regeocodesAddressVO = new RegeocodesAddressPo();
String formattedAddress = regeocodesPo.getFormatted_address();
String adcode = regeocodesPo.getAddressComponent().getAdcode();
regeocodesAddressVO.setFormattedAddress(formattedAddress);
regeocodesAddressVO.setAdcode(adcode);
regeocodesAddressVOList.add(regeocodesAddressVO);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return regeocodesAddressVOList;
}
public void getBaseInfo() {
String interfaceType = "Amap";
List<SysDepartInterfaceInfo> sysDepartInterfaceInfoList = sysDepartInterfaceInfoDomainService.queryListByInterfaceType(interfaceType);
for (SysDepartInterfaceInfo sysDepartInterfaceInfo : sysDepartInterfaceInfoList) {
String interfaceTypeKey = sysDepartInterfaceInfo.getInterfaceTypeKey();//接口参数
String interfaceTypeValue = sysDepartInterfaceInfo.getInterfaceTypeValue();//接口参数值
switch (interfaceTypeKey) {
case "webKey":
AMAP_KEY = interfaceTypeValue;
break;
default:
break;
}
}
}
/**
* @Description 地理编码获取经纬度
* @Author Alex
* @Date 2020-09-12 11:34
*/
public String geo(String address){
getBaseInfo();
String result = "";
// https://restapi.amap.com/v3/geocode/geo?address=北京市朝阳区阜通东大街6号&output=XML&key=<用户的key>
try {
if (StringUtils.isNotBlank(address)){
String s = address.replaceAll(" ", "");
s = s.trim();
result = HttpClientUtil.requestByGetMethod(GEOCODE+AMAP_KEY+"&address="+s, false);
JSONObject jsonObject = JSONObject.parseObject(result);
result = jsonObject.getJSONArray("geocodes").getJSONObject(0).getString("location");
}
System.out.println(result);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
* @Description 计算距离
* @Author Alex
* @Date 2020-09-14 14:02
*/
public String distance(String origins,String destination){
getBaseInfo();
String result = "";
try {
result = HttpClientUtil.requestByGetMethod(DISTANCE+AMAP_KEY+"&origins="+origins+"&destination="+destination+"&type=1", false);
JSONObject jsonObject = JSONObject.parseObject(result);
result = jsonObject.getJSONArray("results").getJSONObject(0).getString("distance");
System.out.println(result);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
* @Description 逆地理编码
* location:经纬度坐标;最多支持20个坐标点;多个点之间用"|"分割。
* extensionsextensions 参数默认取值是 base,也就是返回基本地址信息;
* extensions 参数默认取值是 base,也就是返回基本地址信息; extensions 参数取值为 all 时会返回基本地址信息、附近 POI 内容、道路信息以及道路交叉口信息
* batchbatch=true为批量查询。batch=false为单点查询
* @Author Alex
* @Date 2022/2/12 13:44
*/
public String regeos(String lnglat){
getBaseInfo();
String res = "";
try {
if (StringUtils.isNotBlank(lnglat)){
lnglat = URLEncoder.encode(lnglat, "UTF-8");
String regeoUrl = regeo+AMAP_KEY+"&output=JSON&location="+lnglat+"&extensions=base&batch=true";
regeoUrl = regeoUrl.trim();
res = HttpClientUtil.requestByGetMethod(regeoUrl, false);
}
} catch (Exception e) {
e.printStackTrace();
}
return res;
}
/**
* @Description 地理编码获取经纬度
* @Author Alex
* @Date 2020-09-12 11:34
*/
public String geos(String address){
getBaseInfo();
String result = "";
// https://restapi.amap.com/v3/geocode/geo?address=北京市朝阳区阜通东大街6号&output=XML&key=<用户的key>
try {
if (StringUtils.isNotBlank(address)){
String s = address.replaceAll(" ", "");
s = s.trim();
result = HttpClientUtil.requestByGetMethod(GEOCODE+AMAP_KEY+"&address="+s, false);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public String poiByKeyword(AmapPoiKeywordDTO amapPoiDTO) {
getBaseInfo();
String result = "";
try {
String uri = "";
if (StringUtils.isNotBlank(amapPoiDTO.getKeywords())){
String s = amapPoiDTO.getKeywords().replaceAll(" ", "");
s = s.trim();
uri = "https://restapi.amap.com/v3/place/text?keywords="+s
+(StringUtils.isNotBlank(amapPoiDTO.getTypes()) ? "&types=" + amapPoiDTO.getTypes() : "")
+(StringUtils.isNotBlank(amapPoiDTO.getCity()) ? "&city=" + amapPoiDTO.getCity() : "")
+(StringUtils.isNotBlank(amapPoiDTO.getCitylimit()) ? "&citylimit=" + amapPoiDTO.getCitylimit() : "")
+(StringUtils.isNotBlank(amapPoiDTO.getChildren()) ? "&children=" + amapPoiDTO.getChildren() : "")
+(StringUtils.isNotBlank(amapPoiDTO.getOffset()) ? "&offset=" + amapPoiDTO.getOffset() : "20")
+(StringUtils.isNotBlank(amapPoiDTO.getPage()) ? "&page=" + amapPoiDTO.getPage() : "1")
+ "&key="+AMAP_KEY
+(StringUtils.isNotBlank(amapPoiDTO.getExtensions()) ? "&extensions=" + amapPoiDTO.getExtensions() : "all");
// uri = GEOCODE+AMAP_KEY+"&keywords="+s+"&city="+amapPoiDTO.getCity()+"&types="+amapPoiDTO.getTypes();
result = HttpClientUtil.requestByGetMethod(uri, false);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public String poiByLocation(AmapPoiLocationDTO amapPoiDTO) {
getBaseInfo();
String result = "";
try {
String uri = "";
if (StringUtils.isNotBlank(amapPoiDTO.getLocation())){
String s = amapPoiDTO.getLocation().replaceAll(" ", "");
s = s.trim();
uri = "https://restapi.amap.com/v3/place/around?location="+s
+(StringUtils.isNotBlank(amapPoiDTO.getKeywords()) ? "&keywords=" + amapPoiDTO.getKeywords() : "")
+(StringUtils.isNotBlank(amapPoiDTO.getTypes()) ? "&types=" + amapPoiDTO.getTypes() : "")
+(StringUtils.isNotBlank(amapPoiDTO.getCity()) ? "&city=" + amapPoiDTO.getCity() : "")
+(StringUtils.isNotBlank(amapPoiDTO.getRadius()) ? "&radius=" + amapPoiDTO.getRadius() : "")
+(StringUtils.isNotBlank(amapPoiDTO.getSortrule()) ? "&sortrule=" + amapPoiDTO.getSortrule() : "")
+(StringUtils.isNotBlank(amapPoiDTO.getOffset()) ? "&offset=" + amapPoiDTO.getOffset() : "20")
+(StringUtils.isNotBlank(amapPoiDTO.getPage()) ? "&page=" + amapPoiDTO.getPage() : "1")
+ "&key="+AMAP_KEY
+(StringUtils.isNotBlank(amapPoiDTO.getExtensions()) ? "&extensions=" + amapPoiDTO.getExtensions() : "all");
// uri = GEOCODE+AMAP_KEY+"&keywords="+s+"&city="+amapPoiDTO.getCity()+"&types="+amapPoiDTO.getTypes();
result = HttpClientUtil.requestByGetMethod(uri, false);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}
@@ -0,0 +1,174 @@
package com.linke.thirdParty.application.server;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.linke.thirdParty.domain.departInterfaceInfo.repository.todo.SysDepartInterfaceInfoDo;
import com.mhd.common.core.constant.CacheConstants;
import com.mhd.common.core.domain.po.thirdparty.BaiduNlpAddressPO;
import com.mhd.common.core.domain.po.thirdparty.SysDepartInterfaceInfoPo;
import com.mhd.common.core.domain.thirdparty.BaiduNlpAddressDTO;
import com.mhd.common.core.domain.thirdparty.SysDepartInterfaceInfoDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.redis.service.RedisService;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.*;
import java.rmi.ServerException;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* 百度智能云 - 百度自然语言智能识别
*/
@Service
@Slf4j
public class BaiduNlpApplicationService {
static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();
@Autowired
private RedisService redisService;
@Autowired
private SysDepartInterfaceInfoApplicationService sysDepartInterfaceInfoApplicationService;
/**
* 获取初始化鉴权
* @return
*/
public String getInitData() throws IOException {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
// 获取请求所用的鉴权,首先从redis中获取,若redis中未找到,则重新从远端拉取,并保存到redis中,有效期30天
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
sysDepartInterfaceInfoDo.setOrganizationId(loginUser.getUserPo().getOrganizationId());
sysDepartInterfaceInfoDo.setInterfaceType("baidu_nlp");
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPos = sysDepartInterfaceInfoApplicationService.queryListByOrg(sysDepartInterfaceInfoDo);
if(null == sysDepartInterfaceInfoPos){
throw new ServiceException("百度智能云配置信息未找到,请联系管理员");
}
SysDepartInterfaceInfoPo sysDepartInterfaceInfoPo = sysDepartInterfaceInfoPos.stream().filter(item -> ObjectUtil.equal(item.getInterfaceTypeKey(),"client_id")).findAny().orElse(null);
if(null == sysDepartInterfaceInfoPo){
throw new ServiceException("百度智能云配置信息未找到,请联系管理员");
}
SysDepartInterfaceInfoPo sysDepartInterfaceInfoPoSecret = sysDepartInterfaceInfoPos.stream().filter(item -> ObjectUtil.equal(item.getInterfaceTypeKey(),"client_secret")).findAny().orElse(null);
if(null == sysDepartInterfaceInfoPoSecret){
throw new ServiceException("百度智能云配置信息未找到,请联系管理员");
}
//根据id当做key,根据租户获取当前百度智能云配置
String redisKey = CacheConstants.BAIDU_NLP + sysDepartInterfaceInfoPo.getInterfaceTypeValue();
String tokenRedis = redisService.getCacheObject(redisKey);
if(null == tokenRedis){
//调用远端鉴权获取token
tokenRedis = getAccessToken(sysDepartInterfaceInfoPo.getInterfaceTypeValue(),sysDepartInterfaceInfoPoSecret.getInterfaceTypeValue());
if(!StringUtils.isNotBlank(tokenRedis)){
throw new ServiceException("鉴权失败");
}
//设置redis鉴权,设置29天失效
redisService.setCacheObject(redisKey,tokenRedis,29L, TimeUnit.DAYS);
}
return tokenRedis;
}
/**
* 获取鉴权token
* @return
*/
public String getAccessToken(String client_id,String client_secret) throws IOException {
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://aip.baidubce.com/oauth/2.0/token?client_id="+ client_id +"&client_secret="+ client_secret +"&grant_type=client_credentials")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
Response response = HTTP_CLIENT.newCall(request).execute();
String result = Objects.requireNonNull(response.body()).string();
if(!StringUtils.isNotBlank(result)){
throw new ServiceException("鉴权失败,请重试");
}
JSONObject jsonObject = JSON.parseObject(result);
if(null != jsonObject){
return jsonObject.getString("access_token");
}
return null;
}
/**
* 自然语言-地址识别
* @param baiduNlpAddressDTO 地址文本
* @return 识别后地址信息
*/
public BaiduNlpAddressPO addressRecognition(BaiduNlpAddressDTO baiduNlpAddressDTO) throws IOException {
String address = baiduNlpAddressDTO.getAddress();
if(!StringUtils.isNotBlank(address)){
throw new ServiceException("地址文本不能为空");
}
if(address.length()>500){
throw new ServiceException("文本长度不能超过500字");
}
JSONObject param = new JSONObject();
param.put("text",address);
String text = param.toJSONString();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, text);
Request request = new Request.Builder()
.url("https://aip.baidubce.com/rpc/2.0/nlp/v1/address?access_token=" + getInitData())
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
Response response = HTTP_CLIENT.newCall(request).execute();
String result = Objects.requireNonNull(response.body()).string();
if(!StringUtils.isNotBlank(result)){
throw new ServiceException("识别失败");
}
return JSONObject.parseObject(result,BaiduNlpAddressPO.class);
}
}
@@ -0,0 +1,279 @@
package com.linke.thirdParty.application.server;
import Test.Test;
import com.alibaba.fastjson2.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradeAppPayRequest;
import com.alipay.api.response.AlipayTradeAppPayResponse;
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponse;
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse;
import com.aliyun.dingtalkworkflow_1_0.models.QuerySchemaByProcessCodeResponse;
import com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest;
import com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceResponse;
import com.baomidou.mybatisplus.extension.exceptions.ApiException;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiV2UserGetRequest;
import com.dingtalk.api.request.OapiV2UserGetuserinfoRequest;
import com.dingtalk.api.response.OapiV2UserGetResponse;
import com.dingtalk.api.response.OapiV2UserGetuserinfoResponse;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.linke.thirdParty.domain.departInterfaceInfo.entity.SysDepartInterfaceInfo;
import com.linke.thirdParty.domain.departInterfaceInfo.repository.todo.SysDepartInterfaceInfoDo;
import com.mhd.common.core.domain.po.thirdparty.SysDepartInterfaceInfoPo;
import com.mhd.common.core.domain.thirdparty.AlipayPrepayDTO;
import com.mhd.common.core.domain.thirdparty.dingtalk.Oauth2AccessTokenDTO;
import com.mhd.common.core.domain.thirdparty.dingtalk.SchemasProcessCodesDTO;
import com.mhd.common.core.domain.thirdparty.dingtalk.UserGetuserinfoDTO;
import com.mhd.common.core.domain.thirdparty.dingtalk.WorkflowProcessInstancesDTO;
import org.json.JSONArray;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aliyun.tea.*;
import org.springframework.web.bind.annotation.RequestParam;
import java.rmi.ServerException;
import java.util.ArrayList;
import java.util.List;
@Service
public class DingtalkService {
private static String appKey;
private static String appSecret;
@Autowired
private SysDepartInterfaceInfoApplicationService sysDepartInterfaceInfoApplicationService;
/**
* @Description 获取配置信息
* @Author Alex
* @Date 2020/3/10 16:42
*/
public void getBaseInfo() {
//获取E签宝平台信息
String interfaceType = "dingtalk";
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
sysDepartInterfaceInfoDo.setInterfaceType(interfaceType);
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPos = sysDepartInterfaceInfoApplicationService.queryList(sysDepartInterfaceInfoDo);
for (SysDepartInterfaceInfoPo sysDepartInterfaceInfo : sysDepartInterfaceInfoPos) {
String interfaceTypeKey = sysDepartInterfaceInfo.getInterfaceTypeKey();//接口参数
String interfaceTypeValue = sysDepartInterfaceInfo.getInterfaceTypeValue();//接口参数值
String appPackageName = sysDepartInterfaceInfo.getInterfaceTypeDescription();//描述(包名)
switch (interfaceTypeKey) {
case "appKey":
appKey=interfaceTypeValue;
break;
case "appSecret":
appSecret=interfaceTypeValue;
break;
default:
break;
}
}
}
/**
* <b>description</b> :
* <p>使用 Token 初始化账号Client</p>
* @return Client
*
* @throws Exception
*/
public com.aliyun.dingtalkoauth2_1_0.Client createClient() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
config.protocol = "https";
config.regionId = "central";
return new com.aliyun.dingtalkoauth2_1_0.Client(config);
}
public static com.aliyun.dingtalkworkflow_1_0.Client createClient1() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
config.protocol = "https";
config.regionId = "central";
return new com.aliyun.dingtalkworkflow_1_0.Client(config);
}
/**
* 获取企业accessToken(企业内部应用)
* @param
* @return
* @throws ServerException
*/
public String oauth2AccessToken() throws ServerException, AlipayApiException {
getBaseInfo();
com.aliyun.dingtalkoauth2_1_0.Client client = null;
try {
client = createClient();
} catch (Exception e) {
e.printStackTrace();
}
com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest getAccessTokenRequest = new com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest()
.setAppKey(appKey)
.setAppSecret(appSecret);
try {
GetAccessTokenResponse getAccessTokenResponse= client.getAccessToken(getAccessTokenRequest);
return getAccessTokenResponse.getBody().getAccessToken();
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
}
return null;
}
/**
* 通过免登码获取用户userid(v2)
* @param userGetuserinfoDTO
* @return
* @throws ServerException
*/
public String getuserinfo(UserGetuserinfoDTO userGetuserinfoDTO) throws ServerException, AlipayApiException {
try {
String token=oauth2AccessToken();
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/getuserinfo");
OapiV2UserGetuserinfoRequest req = new OapiV2UserGetuserinfoRequest();
req.setCode(userGetuserinfoDTO.getCode());
OapiV2UserGetuserinfoResponse rsp = null;
try {
rsp = client.execute(req, token);
} catch (com.taobao.api.ApiException e) {
e.printStackTrace();
}
System.out.println(rsp.getBody());
return rsp.getResult().getUserid();
} catch (ApiException e) {
e.printStackTrace();
}
return null;
}
/**
* 通过 processCode 获取表单 schema 信息
* @param schemasProcessCodesDTO
* @return
* @throws ServerException
*/
public QuerySchemaByProcessCodeResponse schemasProcessCodes(SchemasProcessCodesDTO schemasProcessCodesDTO) throws ServerException, AlipayApiException {
String token=oauth2AccessToken();
try {
com.aliyun.dingtalkworkflow_1_0.Client client = null;
try {
client = createClient1();
} catch (Exception e) {
e.printStackTrace();
}
com.aliyun.dingtalkworkflow_1_0.models.QuerySchemaByProcessCodeHeaders querySchemaByProcessCodeHeaders = new com.aliyun.dingtalkworkflow_1_0.models.QuerySchemaByProcessCodeHeaders();
querySchemaByProcessCodeHeaders.xAcsDingtalkAccessToken = token;
com.aliyun.dingtalkworkflow_1_0.models.QuerySchemaByProcessCodeRequest querySchemaByProcessCodeRequest = new com.aliyun.dingtalkworkflow_1_0.models.QuerySchemaByProcessCodeRequest()
.setProcessCode(schemasProcessCodesDTO.getProcessCode());
try {
QuerySchemaByProcessCodeResponse querySchemaByProcessCodeResponse= client.querySchemaByProcessCodeWithOptions(querySchemaByProcessCodeRequest, querySchemaByProcessCodeHeaders, new com.aliyun.teautil.models.RuntimeOptions());
System.out.println(querySchemaByProcessCodeResponse.getBody());
return querySchemaByProcessCodeResponse;
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
}
} catch (ApiException e) {
e.printStackTrace();
}
return null;
}
/**
* 创建审批实例
*/
public StartProcessInstanceResponse workflowProcessInstances(WorkflowProcessInstancesDTO workflowProcessInstancesDTO) throws ServerException, AlipayApiException, JsonProcessingException {
String token=oauth2AccessToken();
com.aliyun.dingtalkworkflow_1_0.Client client = null;
try {
client = createClient1();
} catch (Exception e) {
e.printStackTrace();
}
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceHeaders startProcessInstanceHeaders = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceHeaders();
startProcessInstanceHeaders.xAcsDingtalkAccessToken = token;
ObjectMapper objectMapper = new ObjectMapper();
String jsonString = objectMapper.writeValueAsString(workflowProcessInstancesDTO.getFormComponentValues().get(0).getDetailsDTOList());
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues0 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues()
.setName(workflowProcessInstancesDTO.getFormComponentValues().get(0).getName())
.setValue(workflowProcessInstancesDTO.getFormComponentValues().get(0).getValue());
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues1 = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues()
.setName(workflowProcessInstancesDTO.getFormComponentValues().get(1).getName())
.setValue(workflowProcessInstancesDTO.getFormComponentValues().get(1).getValue());
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest startProcessInstanceRequest = new com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest()
.setDeptId(Long.valueOf(workflowProcessInstancesDTO.getDeptId()))
.setOriginatorUserId(workflowProcessInstancesDTO.getOriginatorUserId())
.setProcessCode(workflowProcessInstancesDTO.getProcessCode())
.setFormComponentValues(java.util.Arrays.asList(
formComponentValues0,formComponentValues1
));
StartProcessInstanceResponse startProcessInstanceResponse= null;
try {
startProcessInstanceResponse = client.startProcessInstanceWithOptions(startProcessInstanceRequest, startProcessInstanceHeaders, new com.aliyun.teautil.models.RuntimeOptions());
} catch (Exception e) {
e.printStackTrace();
}
return startProcessInstanceResponse;
}
public GetProcessInstanceResponse workflowProcessInstancesById(@RequestParam(name="processInstanceId") String processInstanceId) throws Exception {
String token=oauth2AccessToken();
com.aliyun.dingtalkworkflow_1_0.Client client = Test.createClient1();
com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceHeaders getProcessInstanceHeaders = new com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceHeaders();
getProcessInstanceHeaders.xAcsDingtalkAccessToken = token;
com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceRequest getProcessInstanceRequest = new com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceRequest()
.setProcessInstanceId(processInstanceId);
try {
GetProcessInstanceResponse getProcessInstanceResponse= client.getProcessInstanceWithOptions(getProcessInstanceRequest, getProcessInstanceHeaders, new com.aliyun.teautil.models.RuntimeOptions());
System.out.println("===1111111111111111======================");
System.out.println(getProcessInstanceResponse.getBody().getResult().getResult());
return getProcessInstanceResponse;
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
}
return null;
}
public OapiV2UserGetResponse userGet(@RequestParam(name="userId") String userId) throws Exception {
String token=oauth2AccessToken();
try {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
OapiV2UserGetRequest req = new OapiV2UserGetRequest();
req.setUserid(userId);
OapiV2UserGetResponse rsp = client.execute(req, token);
System.out.println(rsp.getBody());
return rsp;
} catch (ApiException e) {
e.printStackTrace();
}
return null;
}
}
@@ -0,0 +1,167 @@
package com.linke.thirdParty.application.server;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.linke.thirdParty.infrastructure.config.ESTConfig;
import com.linke.thirdParty.infrastructure.config.EsignHttpHelper;
import com.linke.thirdParty.infrastructure.dict.EsignRequestType;
import com.mhd.common.core.domain.po.EsignHttpResponse;
import com.mhd.common.core.domain.thirdparty.esignsaas.*;
import com.mhd.common.core.exception.EsignDemoException;
import com.mhd.common.core.exception.ServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
public class ESignSaasApplicationService {
private static String eSignHost= ESTConfig.EsignHost;
private static String eSignAppId=ESTConfig.EsignAppId;
private static String eSignAppSecret=ESTConfig.EsignAppSecret;
/**
* 创建个人账号
* @param signatureDTO
* @return
* @throws EsignDemoException
*/
public String personBean(EsignSaasPersonalSignatureDTO signatureDTO) throws EsignDemoException {
String url ="/v1/accounts/createByThirdPartyUserId";
String result = getResult(url, signatureDTO, EsignRequestType.POST);
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
return map.get("accountId").toString();
}
/**
* 创建个人印章模板
* @param accountId
* @param sealDTO
* @return
*/
public String creatPersonSeal(String accountId, EsignSaasPersonalSealDTO sealDTO) throws EsignDemoException {
String url ="/v1/accounts/"+accountId+"/seals/personaltemplate";
String result = getResult(url, sealDTO, EsignRequestType.POST);
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
return map.get("sealId").toString();
}
/**
* 创建机构印章
* @param accountId
* @param sealDTO
* @return
*/
public String creatOrganizationSeal(String accountId, EsignSaasOrganizationSealDTO sealDTO) throws EsignDemoException {
String url ="/v1/organizations/"+accountId+"/seals/officialtemplate";
String result = getResult(url, sealDTO, EsignRequestType.POST);
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
return map.get("sealId").toString();
}
/**
* 创建企业账号
* @param signatureDTO
* @return
*/
public String addAccount(EsignSaasOrganizationSignatureDTO signatureDTO) throws EsignDemoException {
String url = "/v1/organizations/createByThirdPartyUserId";
String result = getResult(url, signatureDTO, EsignRequestType.POST);
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
return map.get("accountId").toString();
}
/**
* 填充模板
* @param signatureDTO
* @return
*/
public String filltemplate(EsignSaasFillTemplateDTO signatureDTO) throws EsignDemoException {
String url = "/v3/files/create-by-doc-template";
String result = getResult(url, signatureDTO, EsignRequestType.POST);
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
return map.get("fileId").toString();
}
/**
* 基于文件发起签署
* @param signatureDTO
* @return
*/
public String signContractByFile(EsignSaasSignContractV3DTO signatureDTO) throws EsignDemoException {
String url = "/v3/sign-flow/create-by-file";
String result = getResult(url, signatureDTO, EsignRequestType.POST);
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
return map.get("signFlowId").toString();
}
/**
* 一步发起签署
* @param signatureDTO
* @return
*/
public String signContract(EsignSaasSignContractDTO signatureDTO) throws EsignDemoException {
String url = "/api/v2/signflows/createFlowOneStep";
String result = getResult(url, signatureDTO, EsignRequestType.POST);
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
return map.get("flowId").toString();
}
/**
* 下载签署文件
* @param signFlowId
* @return
* @throws EsignDemoException
*/
public String downloadSignContract(String signFlowId) throws EsignDemoException {
String url = "/v1/signflows/"+signFlowId+"/documents";
String result = getResult(url, null, EsignRequestType.GET);
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
String string = map.get("docs").toString();
List<EsignSaasSignContractCallDTO> list = com.alibaba.fastjson.JSONObject.parseArray(string, EsignSaasSignContractCallDTO.class);
if (CollectionUtil.isNotEmpty(list)){
return list.get(0).getFileUrl();
}
return null;
}
/**
* 设置静默签署授权
* @param accountId
* @return
*/
public String signAuth(String accountId) throws EsignDemoException {
String url = "/v1/signAuth/"+accountId;
String result = getResult(url, null, EsignRequestType.POST);
return result;
}
/**
* 发起请求
* @param url 请求地址
* @param param post请求参数
* @param requestType 请求方式
* @return
* @throws EsignDemoException
*/
public String getResult(String url, Object param, EsignRequestType requestType) throws EsignDemoException {
String jsonObjectStr = JSON.toJSONString(param);
//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
//生成签名鉴权方式的的header
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonObjectStr,requestType.name(),url,true);
//发起接口请求
EsignHttpResponse esignHttpResponse = EsignHttpHelper.doCommHttp(eSignHost, url, requestType, jsonObjectStr, header, true);
String body = esignHttpResponse.getBody();
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(body, Map.class);
if ("0".equals(map.get("code").toString())){
return map.get("data").toString();
}else {
throw new ServiceException(map.get("message").toString());
}
}
}
@@ -0,0 +1,424 @@
package com.linke.thirdParty.application.server;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONObject;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.linke.thirdParty.application.server.userAuthEsign.UserAuthEsignApplicationService;
import com.linke.thirdParty.domain.departInterfaceInfo.repository.todo.SysDepartInterfaceInfoDo;
import com.linke.thirdParty.domain.userAuthEsign.repository.todo.UserAuthEsignDO;
import com.linke.thirdParty.infrastructure.config.ESTConfig;
import com.linke.thirdParty.infrastructure.config.EsignHttpHelper;
import com.linke.thirdParty.infrastructure.dict.EsignRequestType;
import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.domain.po.EsignHttpResponse;
import com.mhd.common.core.domain.po.thirdparty.EsginMemberPo;
import com.mhd.common.core.domain.po.thirdparty.EsginOwnSealPo;
import com.mhd.common.core.domain.po.thirdparty.SysDepartInterfaceInfoPo;
import com.mhd.common.core.domain.thirdparty.esignsaas.*;
import com.mhd.common.core.exception.EsignDemoException;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.oss.configure.OSSClientPrivateUtil;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
public class ESignSaasApplicationV3Service {
//环境域名
private static final ThreadLocal<String> esign_host = new ThreadLocal<>();
//E签宝projectId
private static final ThreadLocal<String> esign_app_id = new ThreadLocal<>();
//E签宝projectsecret
private static final ThreadLocal<String> esign_app_secret = new ThreadLocal<>();
//认证&授权回调接口
private static final ThreadLocal<String> esign_obtain_auth = new ThreadLocal<>();
//跨企业印章授权
private static final ThreadLocal<String> esign_seal_auth = new ThreadLocal<>();
//当前E签宝注册统一信用代码
private static final ThreadLocal<String> credit_code = new ThreadLocal<>();
//当前E签宝企业名称
private static final ThreadLocal<String> credit_name = new ThreadLocal<>();
@Resource
private SysDepartInterfaceInfoApplicationService interfaceInfoApplicationService;
@Autowired
private OssUploadApplicationService ossUploadApplicationService;
@Autowired
private UserAuthEsignApplicationService userAuthEsignApplicationService;
public void getInfoConfig(){
Long topOrganizationId = 1L;
//获取当前登录人
LoginUser loginUser = SecurityUtils.getLoginUser();
if(loginUser != null){
topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
}
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
sysDepartInterfaceInfoDo.setInterfaceType("esign_saas");
sysDepartInterfaceInfoDo.setTopOrganizationId(topOrganizationId);
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPoList = interfaceInfoApplicationService.queryList(sysDepartInterfaceInfoDo);
for (SysDepartInterfaceInfoPo sysDepartInterfaceInfoPo : sysDepartInterfaceInfoPoList) {
String interfaceTypeKey = sysDepartInterfaceInfoPo.getInterfaceTypeKey();
String interfaceTypeValue = sysDepartInterfaceInfoPo.getInterfaceTypeValue();
switch (interfaceTypeKey){
case "esign_host" :
esign_host.set(interfaceTypeValue);
break;
case "esign_app_id" :
esign_app_id.set(interfaceTypeValue);
break;
case "esign_app_secret" :
esign_app_secret.set(interfaceTypeValue);
break;
case "esign_obtain_auth" :
esign_obtain_auth.set(interfaceTypeValue);
break;
case "esign_seal_auth" :
esign_seal_auth.set(interfaceTypeValue);
break;
case "credit_code" :
credit_code.set(interfaceTypeValue);
break;
case "credit_name" :
credit_name.set(interfaceTypeValue);
break;
default :
break;
}
}
}
/**
* 填充模板
* @param signatureDTO
* @return
*/
public String filltemplate(EsignSaasFillTemplateDTO signatureDTO) throws EsignDemoException {
String url = "/v3/files/create-by-doc-template";
String result = getResult(url, signatureDTO, EsignRequestType.POST);
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
return map.get("fileId").toString();
}
/**
* 基于文件发起签署
* @param signatureDTO
* @return
*/
public String signContractByFile(EsignSaasSignContractV3DTO signatureDTO) throws EsignDemoException {
String url = "/v3/sign-flow/create-by-file";
String result = getResult(url, signatureDTO, EsignRequestType.POST);
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
return map.get("signFlowId").toString();
}
/**
* 获取签署页面链接
* @param signatureDTO
* @return
*/
public String getSignByFlowId(EsignSaasGetSignByFlowIdDTO signatureDTO) throws EsignDemoException {
String url = "/v3/sign-flow/"+signatureDTO.getSignFlowId()+"/sign-url";
String result = getResult(url, signatureDTO, EsignRequestType.POST);
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
return map.get("url").toString();
}
/**
* E签宝获取签署文件地址
* @param signFlowId 流程ID
* @param docFileId 文件ID
* @param type 类型 1-签署中。2-已签署
* @return 签署文件地址
*/
public String getSignUrl(String signFlowId,String docFileId,int type){
//首先从E签宝获取签署文件链接地址,拿到地址后,上传到OSS,获取自己的链接,返回
String outUrl = null;
try {
if(type == 1){
if(StringUtils.isBlank(signFlowId) || StringUtils.isBlank(docFileId)){
throw new ServiceException("获取链接关键参数不能为空");
}
outUrl = downloadSigningContract(signFlowId,docFileId);
}else if(type == 2){
if(StringUtils.isBlank(signFlowId)){
throw new ServiceException("流程ID不能为空");
}
outUrl = downloadSignedContract(signFlowId);
}else {
throw new ServiceException("类型错误");
}
if(null == outUrl){
throw new ServiceException(signFlowId + "签署链接查询失败,请重试");
}
//上传OSS,获取自己的链接
return ossUploadApplicationService.getOutUrl(outUrl);
}catch (Exception e){
log.error(signFlowId + "获取签署链接失败" + e.getMessage());
}
return outUrl;
}
/**
* 下载签署中文件
*/
public String downloadSigningContract(String signFlowId,String docFileId) throws EsignDemoException {
String url = "/v3/sign-flow/"+signFlowId+"/preview-file-download-url";
url = url + "?docFileId=" + docFileId;
String result = getResult(url, null, EsignRequestType.GET);
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
if(map != null){
return map.get("fileDownloadUrl").toString();
}
return null;
}
/**
* 下载签署完成的文件
*/
public String downloadSignedContract(String signFlowId) throws EsignDemoException {
String url = "/v3/sign-flow/"+signFlowId+"/file-download-url";
String result = getResult(url, null, EsignRequestType.GET);
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(result);
JSONArray jsonArray = jsonObject.getJSONArray("files");
if(jsonArray != null && jsonArray.size() > 0){
Object urlJson = jsonArray.get(0);
//object转map
Map<String,Object> map = JSON.parseObject(urlJson.toString(), Map.class);
return map.get("downloadUrl").toString();
}
return null;
}
/**
* 发起请求
* @param url 请求地址
* @param param post请求参数
* @param requestType 请求方式
* @return
* @throws EsignDemoException
*/
public String getResult(String url, Object param, EsignRequestType requestType) throws EsignDemoException {
getInfoConfig();
String jsonObjectStr = JSON.toJSONString(param);
//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
//生成签名鉴权方式的的header
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(esign_app_id.get(),esign_app_secret.get(),jsonObjectStr,requestType.name(),url,true);
//发起接口请求
EsignHttpResponse esignHttpResponse = EsignHttpHelper.doCommHttp(esign_host.get(), url, requestType, jsonObjectStr, header, true);
String body = esignHttpResponse.getBody();
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(body, Map.class);
if ("0".equals(map.get("code").toString())){
return map.get("data").toString();
}else {
throw new ServiceException(map.get("message").toString());
}
}
public boolean feelContractCallBank(JSONObject jsonObject) {
log.info("签署完成111"+jsonObject.toString());
String flowStatus = "";
String flowId = "";
try {
flowStatus = jsonObject.getObj("flowStatus").toString();
flowId = jsonObject.getObj("flowId").toString();
}catch (Exception e){
return true;
}
if (StringUtils.isNotBlank(flowStatus) && flowStatus.equals("2")){
}
return true;
}
/**
* 获取签署详情
* @Return 签署状态
* 0 - 草稿
* 1 - 签署中
* 2 - 完成
* 3 - 撤销
* 5 - 过期(签署截至日期到期后触发)
* 7 - 拒签
*/
public String getSignDetailByFlowId(EsignSaasGetSignByFlowIdDTO signatureDTO) throws Exception{
if(StringUtils.isBlank(signatureDTO.getSignFlowId())){
throw new ServiceException("流程id不能为空");
}
String url = "/v3/sign-flow/"+signatureDTO.getSignFlowId()+"/detail";
String result = getResult(url, null, EsignRequestType.GET);
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
if(map != null){
return map.get("signFlowStatus").toString();
}
return null;
}
/**
* 跨企业印章授权
* @param sealAuthV3DTO
* @return
*/
public String sealAuthorization(EsignSaasSealAuthV3DTO sealAuthV3DTO) throws Exception{
String url = "/v3/seals/org-seals/external-auth";
return getResult(url, sealAuthV3DTO, EsignRequestType.POST);
}
/**
* 系统用户使用跨企业印章授权
* @param sealAuthV3DTO
* @return
*/
public String sealAuthorizationForUser(EsignSaasSealAuthV3DTO sealAuthV3DTO) {
String result = null;
try {
//获取机构信息
Map<String,Object> orgId = getIdentityInfo(sealAuthV3DTO.getOrgId());
sealAuthV3DTO.setOrgId(orgId.get("orgId").toString());
EsignSaasSealAuthV3DTO.AuthorizedOrgInfo authorizedOrgInfo = new EsignSaasSealAuthV3DTO.AuthorizedOrgInfo();
authorizedOrgInfo.setOrgName(credit_name.get());
authorizedOrgInfo.setOrgIDCardNum(credit_code.get());
sealAuthV3DTO.setAuthorizedOrgInfo(authorizedOrgInfo);
//获取当前时间时间戳
sealAuthV3DTO.setEffectiveTime(System.currentTimeMillis());
//获取当前时间推迟三年后时间戳
sealAuthV3DTO.setExpireTime(System.currentTimeMillis()+31536000000L*3);
result = sealAuthorization(sealAuthV3DTO);
if(null != result){
Map<String,Object> resultMap = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
//保存用户印章授权信息到数据库中
UserAuthEsignDO userAuthEsignDO = new UserAuthEsignDO();
userAuthEsignDO.setSealauthbizids(String.valueOf(resultMap.get("sealAuthBizIds")));
userAuthEsignDO.setAuthorizationsignshorturl(String.valueOf(resultMap.get("authorizationSignShortUrl")));
userAuthEsignDO.setAuthorizationsignurl(String.valueOf(resultMap.get("authorizationSignUrl")));
userAuthEsignApplicationService.insert(userAuthEsignDO);
}
}catch (Exception e){
throw new ServiceException("调用e签宝接口失败:" + e.getMessage());
}
return result;
}
/**
* 获取机构认证&授权页面链接
* @param esignObtainAuthorizationV3DTO
* @return
*/
public Map<String, String> obtainAuthorization(EsignObtainAuthorizationV3DTO esignObtainAuthorizationV3DTO) {
//填充默认参数
EsignObtainAuthorizationV3DTO.OrgInfo orgInfo = esignObtainAuthorizationV3DTO.getOrgAuthConfig().getOrgInfo();
orgInfo.setOrgIDCardType("CRED_ORG_USCC");
orgInfo.setLegalRepIDCardType("CRED_PSN_CH_IDCARD");
EsignObtainAuthorizationV3DTO.AuthorizeConfig authorizeConfig = new EsignObtainAuthorizationV3DTO.AuthorizeConfig();
List<String> authorizedScopes = new ArrayList<>();
authorizedScopes.add("get_org_identity_info");
authorizedScopes.add("org_initiate_sign");
authorizedScopes.add("manage_org_seal");
authorizedScopes.add("manage_org_member");
authorizeConfig.setAuthorizedScopes(authorizedScopes);
esignObtainAuthorizationV3DTO.setAuthorizeConfig(authorizeConfig);
EsignObtainAuthorizationV3DTO.RedirectConfig redirectConfig = esignObtainAuthorizationV3DTO.getRedirectConfig();
if(null == redirectConfig){
redirectConfig = new EsignObtainAuthorizationV3DTO.RedirectConfig();
}
if(StringUtils.isBlank(redirectConfig.getNotifyUrl())){
//查询三方配置表
getInfoConfig();
redirectConfig.setNotifyUrl(esign_obtain_auth.get());
esignObtainAuthorizationV3DTO.setRedirectConfig(redirectConfig);
}
String url = "/v3/org-auth-url";
String result;
try {
result = getResult(url, esignObtainAuthorizationV3DTO, EsignRequestType.POST);
}catch (Exception e){
throw new ServiceException("申请授权失败:" + e.getMessage());
}
return com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
}
/**
* 查询内部印章
* @param pageNum
* @return
*/
public String searchInternally(String pageNum, String creditCode) {
//获取当前内部机构的orgId
Map<String,Object> orgId = getIdentityInfo(creditCode);
String url = "/v3/seals/org-own-seal-list?orgId=" + orgId.get("orgId").toString() + "&pageNum=" + pageNum + "&pageSize=20&sealBizTypes=CONTRACT" ;
String result;
try {
result = getResult(url, null, EsignRequestType.GET);
}catch (Exception e){
throw new ServiceException("查询内部印章失败:" + e.getMessage());
}
return com.alibaba.fastjson.JSONObject.parseObject(result).get("seals").toString();
}
/**
* 获取机构ID
* @return
*/
private Map<String,Object> getIdentityInfo(String creditCode) {
String result;
if(StringUtils.isBlank(creditCode)){
//查询三方配置表
getInfoConfig();
creditCode = credit_code.get();
}
String url = "/v3/organizations/identity-info?orgIDCardNum="+creditCode+"&orgIDCardType=CRED_ORG_USCC";
try {
result = getResult(url, null, EsignRequestType.GET);
}catch (Exception e){
throw new ServiceException("查询机构信息失败:" + e.getMessage());
}
Map<String,Object> map = com.alibaba.fastjson.JSONObject.parseObject(result, Map.class);
return map;
}
/**
* 查询企业成员列表
* @param pageNum
* @return
*/
public String searchMemberList(String pageNum,String creditCode) {
//获取当前内部机构的orgId
Map<String,Object> orgId = getIdentityInfo(creditCode);
String url = "/v3/organizations/"+ orgId.get("orgId").toString() +"/member-list?pageNum=" + pageNum + "&pageSize=100";
String result;
try {
result = getResult(url, null, EsignRequestType.GET);
}catch (Exception e){
throw new ServiceException("查询企业机构成员失败:" + e.getMessage());
}
return com.alibaba.fastjson.JSONObject.parseObject(result).get("members").toString();
}
}
@@ -0,0 +1,37 @@
package com.linke.thirdParty.application.server;
import com.mhd.common.core.domain.thirdparty.AuroraPushDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 极光推送 Service层
*
* @author Administrator
*/
@Service
public class JPushApplicationService {
@Autowired
private JPushAsyncApplicationService jPushAsyncApplicationService;
/**
* 极光消息推送
*
* @param auroraPushDTO 推送信息
*/
public Integer auroraPush(AuroraPushDTO auroraPushDTO){
Integer result = 0;
result = jPushAsyncApplicationService.auroraPush(auroraPushDTO);
return result;
}
/**
* 极光消息推送
*/
public void auroraPushT(AuroraPushDTO auroraPushDTO) {
jPushAsyncApplicationService.pushAndSendMsgByAlias(auroraPushDTO);
}
}
@@ -0,0 +1,312 @@
package com.linke.thirdParty.application.server;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import cn.jiguang.common.ClientConfig;
import cn.jiguang.common.DeviceType;
import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.Message;
import cn.jpush.api.push.model.Options;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.AndroidNotification;
import cn.jpush.api.push.model.notification.IosNotification;
import cn.jpush.api.push.model.notification.Notification;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.linke.thirdParty.domain.departInterfaceInfo.entity.SysDepartInterfaceInfo;
import com.mhd.common.core.domain.thirdparty.AuroraPushDTO;
import com.mhd.common.core.enums.MessageTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* @author Administrator
*/
@Slf4j
@Service
public class JPushAsyncApplicationService {
@Autowired
private SysDepartInterfaceInfoApplicationService sysDepartInterfaceInfoApplicationService;
/**
* @Description 获取jpush配置信息及推送环境
* @Author Alex
* @Date 2020-06-02 11:54
*/
public JPushClient getClient() {
String appKey = "";
String masterSecrect = "";
//获取乐信通短信平台信息
String interfaceType = "jpush";
List<SysDepartInterfaceInfo> sysDepartInterfaceInfoList = sysDepartInterfaceInfoApplicationService.queryListByInterfaceType(interfaceType);
for (SysDepartInterfaceInfo sysDepartInterfaceInfo : sysDepartInterfaceInfoList) {
String interfaceTypeKey = sysDepartInterfaceInfo.getInterfaceTypeKey();//接口参数
String interfaceTypeValue = sysDepartInterfaceInfo.getInterfaceTypeValue();//接口参数值
switch (interfaceTypeKey) {
case "AppKey":
appKey = interfaceTypeValue;
break;
case "MasterSecret":
masterSecrect = interfaceTypeValue;
break;
default:
break;
}
}
//统一修改生产模式
return new JPushClient(masterSecrect, appKey);
}
/**
* @param sysOrgCode 部门编码,tag
* @param userType 接收人信息,0-司机,1-货主
* @Description 获取jpush配置信息及推送环境
*/
public JPushClient getClient(String sysOrgCode, Integer userType) {
String appKey = "";
String masterSecrect = "";
//获取乐信通短信平台信息
String interfaceType = "jpush";
List<SysDepartInterfaceInfo> sysDepartInterfaceInfoList = sysDepartInterfaceInfoApplicationService.queryListByInterfaceType(interfaceType);
for (SysDepartInterfaceInfo sysDepartInterfaceInfo : sysDepartInterfaceInfoList) {
String interfaceTypeKey = sysDepartInterfaceInfo.getInterfaceTypeKey();//接口参数
String interfaceTypeValue = sysDepartInterfaceInfo.getInterfaceTypeValue();//接口参数值
if (ObjUtil.isNotNull(userType) && userType == 0) {
switch (interfaceTypeKey) {
case "driverAppKey":
appKey = interfaceTypeValue;
break;
case "driverMasterSecret":
masterSecrect = interfaceTypeValue;
break;
default:
break;
}
} else if (ObjUtil.isNotNull(userType) &&userType == 1) {
switch (interfaceTypeKey) {
case "shipperAppKey":
appKey = interfaceTypeValue;
break;
case "shipperMasterSecret":
masterSecrect = interfaceTypeValue;
break;
default:
break;
}
} else {
switch (interfaceTypeKey) {
case "AppKey":
appKey = interfaceTypeValue;
break;
case "MasterSecret":
masterSecrect = interfaceTypeValue;
break;
default:
break;
}
}
}
ClientConfig clientConfig = ClientConfig.getInstance();
//统一修改生产模式
return new JPushClient(masterSecrect, appKey);
}
public Integer auroraPush(AuroraPushDTO auroraPushDTO) {
// JPushClient client = getClient();
String sysOrgCode = auroraPushDTO.getSysOrgCode();
Integer userType = auroraPushDTO.getUserType();
JPushClient client = getClient(sysOrgCode, userType);
PushPayload pushPayload = getPushPayload(auroraPushDTO);
try {
PushResult pushResult = client.sendPush(pushPayload);
System.out.println(pushResult);
if (pushResult.getResponseCode() == 200) {
return 1;
}
} catch (APIConnectionException e) {
e.printStackTrace();
} catch (APIRequestException e) {
e.printStackTrace();
}
return 0;
}
/**
* @Description 根据别名(用户ID)推送
*/
public void pushAndSendMsgByAlias(AuroraPushDTO auroraPushDTO) {
try {
Set<String> alias = new HashSet<String>();
if (CollUtil.isNotEmpty(auroraPushDTO.getAlias())) {
alias.addAll(auroraPushDTO.getAlias());
}
// 根据别名推送
pushNoticeByAlias(alias, auroraPushDTO);
} catch (Exception e) {
log.error("极光推送失败:", e);
}
}
/**
* 给指定的用户推送通知
*
* @param
* @throws InterruptedException
*/
public void pushNoticeByAlias(final Set<String> aliases, AuroraPushDTO auroraPushDTO) throws Exception {
try {
Map<String, Object> params = new HashMap<String, Object>();
// params.put("sysOrgCode", sysUser.getOrgCode());
// params.put("userRole", sysUser.getUserRole());
params.put("title", auroraPushDTO.getTitle());
params.put("content", auroraPushDTO.getContent());
//将一些需要额外传的参数放在extra中
Map<String, String> extras = new HashMap<>();
if (StrUtil.isNotEmpty(auroraPushDTO.getType())) {
extras.put("type", auroraPushDTO.getType());
}
params.put("extras", extras);
sendJPushByAlias(auroraPushDTO, params, aliases);
} catch (Exception e) {
log.error("极光推送失败:", e);
}
}
/**
* @param params key:extras 额外参数hashMap类型, key:alert 通知内容字符串类型,key:branchCodekey:userRole
* @Description 根据别名推送 alias
* @Author Alex
* @Date 2020-06-02 21:15
*/
public void sendJPushByAlias(AuroraPushDTO auroraPushDTO, Map<String, Object> params, Set<String> aliases) throws Exception {
String sysOrgCode = auroraPushDTO.getSysOrgCode();
Integer userType = auroraPushDTO.getUserType();
JPushClient jpush = getClient(sysOrgCode, userType);
PushPayload.Builder builderAndroid = getPushBuilder(auroraPushDTO, params, DeviceType.Android.value());
builderAndroid.setAudience(Audience.alias(aliases));
PushPayload payloadAndroid = builderAndroid.build();
PushPayload.Builder builderIos = getPushBuilder(auroraPushDTO, params, DeviceType.IOS.value());
builderIos.setAudience(Audience.alias(aliases));
PushPayload payloadIos = builderIos
.setPlatform(Platform.ios())
.setNotification(Notification.newBuilder()
.setAlert(auroraPushDTO.getContent())
.addPlatformNotification(IosNotification.newBuilder()
.addExtra("type", auroraPushDTO.getMessageType())
//传一个IosAlert对象,指定apns title、title、subtitle等
.setAlert(auroraPushDTO.getTitle())
//直接传alert
//此项是指定此推送的badge自动加1
.setBadge(1)
//此字段的值default表示系统默认声音;传sound.caf表示此推送以项目里面打包的sound.caf声音来提醒,
// 如果系统没有此音频则以系统默认声音提醒;此字段如果传空字符串,iOS9及以上的系统是无声音提醒,以下的系统是默认声音
.setSound("sound.caf")
//此字段为透传字段,不会显示在通知栏。用户可以通过此字段来做一些定制需求,如特定的key传要指定跳转的页面(value)
//此项说明此推送是一个background推送,想了解background看:http://docs.jpush.io/client/ios_tutorials/#ios-7-background-remote-notification
// .setContentAvailable(true)
.build()
)
.build()
)
//Platform指定了哪些平台就会像指定平台中符合推送条件的设备进行推送。 jpush的自定义消息,
// sdk默认不做任何处理,不会有通知提示。建议看文档http://docs.jpush.io/guideline/faq/的
// [通知与自定义消息有什么区别?]了解通知和自定义消息的区别
.setMessage(Message.content(auroraPushDTO.getContent()))
.setOptions(Options.newBuilder()
//此字段的值是用来指定本推送要推送的apns环境,false表示开发,true表示生产;对android和自定义消息无意义
.setApnsProduction(false)
//此字段是给开发者自己给推送编号,方便推送者分辨推送记录
.setSendno(1)
//此字段的值是用来指定本推送的离线保存时长,如果不传此字段则默认保存一天,最多指定保留十天,单位为秒
.setTimeToLive(86400)
.build()
)
.build();
try {
jpush.sendPush(payloadAndroid);
jpush.sendPush(payloadIos);
} catch (APIConnectionException e) {
log.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
log.error("Error response from JPush server. Should review and fix it. ", e);
log.info("HTTP Status: " + e.getStatus());
log.info("Error Code: " + e.getErrorCode());
log.info("Error Message: " + e.getErrorMessage());
}
}
/**
* @Description 获取builder封装信息
* @Author Alex
* @Date 2020-06-02 11:54
*/
@SuppressWarnings("all")
private PushPayload.Builder getPushBuilder(AuroraPushDTO auroraPushDTO, Map<String, Object> params, String deviceType) throws JsonProcessingException {
Map<String, String> extras = new HashMap<String, String>();
if (null != params.get("extras")) {
extras = (Map<String, String>) params.get("extras");
}
String name = MessageTypeEnum.getInfo(auroraPushDTO.getMessageType());
extras.put("key", name);
String title = (String) params.get("title");
String content = (String) params.get("content");
//测试发现extras中的内容无用
extras.put("title", title);
extras.put("content", content);
PushPayload.Builder builder = PushPayload.newBuilder().setPlatform(Platform.android_ios());
if (StrUtil.isNotEmpty(content)) {
if (DeviceType.Android.value().equals(deviceType)) {
builder.setNotification(Notification.android(content, title, extras));
} else {
builder.setNotification(Notification.ios(content, extras));
}
}
// builder.setMessage(Message.newBuilder().setMsgContent(content).setTitle(title).addExtras(extras).build());
return builder;
}
private PushPayload getPushPayload(AuroraPushDTO auroraPushDTO) {
return PushPayload.newBuilder()
//指定要推送的平台(0-全部推送,1-Android2-IOS
.setPlatform("1".equals(auroraPushDTO.getPlatForm()) ? Platform.android()
: "2".equals(auroraPushDTO.getPlatForm()) ? Platform.ios() : Platform.all())
//指定要推送的接收对象(0-tag全部推送,1-alias根据别名推送,2-registrationId根据应用id推送)
.setAudience("1".equals(auroraPushDTO.getType()) ? Audience.alias(auroraPushDTO.getAlias())
: "2".equals(auroraPushDTO.getType()) ? Audience.registrationId(auroraPushDTO.getRegistrationIds()) : Audience.all())
// jpush的通知
.setNotification(Notification.newBuilder()
// 指定当前推送的通知
.addPlatformNotification("1".equals(auroraPushDTO.getPlatForm()) ? AndroidNotification.newBuilder()
.setAlert(auroraPushDTO.getContent())
.setTitle(auroraPushDTO.getTitle())
.build()
: IosNotification.newBuilder().setThreadId(auroraPushDTO.getTitle()).setAlert(auroraPushDTO.getContent()).build())
.build())
.setOptions(Options.newBuilder()
// 此字段的值是用来指定本推送要推送的apns环境,false表示开发,true表示生产;对android和自定义消息无意义
.setApnsProduction(false)
// 此字段是给开发者自己给推送编号,方便推送者分辨推送记录
.setSendno(1)
// 此字段的值是用来指定本推送的离线保存时长,如果不传此字段则默认保存一天,最多指定保留十天;
.setTimeToLive(86400)
.build())
.build();
}
}
@@ -0,0 +1,558 @@
package com.linke.thirdParty.application.server;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.oss.ServiceException;
import com.linke.thirdParty.domain.departInterfaceInfo.entity.SysDepartInterfaceInfo;
import com.linke.thirdParty.domain.departInterfaceInfo.service.SysDepartInterfaceInfoDomainService;
import com.linke.thirdParty.domain.tuanyou.mapper.TmsDriverOilMapper;
import com.linke.thirdParty.domain.tuanyou.service.NewLinkDomainService;
import com.linke.thirdParty.infrastructure.utils.EncryptionUtils;
import com.linke.thirdParty.infrastructure.utils.HttpUtils;
import com.linke.thirdParty.interfaces.vo.tuanyou.GetSecretCodeVO;
import com.linke.thirdParty.interfaces.vo.tuanyou.TmsDriverOilVO;
import com.mhd.common.core.utils.AddressUtils;
import com.mhd.common.core.utils.IPUtils;
import com.mhd.common.core.utils.ServletUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* TODO 能链企服-对接接⼝⽂档
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-07 15:50:28
*/
@Service
@Slf4j
public class NewLinkApplicationService {
private String host = ""; // 请求地址
private String allEnterprise = "open-api/enterprise/getAllEnterprise"; // 获取当前企业及⼦企业信息
private String addStaff = "open-api/enterprise/staff/add"; // 新增员⼯
private String availableAmount = "open-api/enterprise/staff/update/availableAmount"; // 修改⽤⼾可⽤额度
private String updateMobile = "open-api/enterprise/staff/updateMobile"; // 修改员⼯⼿机号(根据⽤⼾Id
private String getAccountInfo = "open-api/enterprise/staff/getAccountInfo"; // 获取员⼯详情(根据⽤⼾Id或⼿机号)
private String getSecretCode = "open-api/enterprise/staff/getSecretCode"; // 获取加油网站页面url---获取授权码
private String time = ""; // 生成签名的时间戳
private String ipconfig = ""; // ip最终地址
/**
* 团油-app_secret
*/
public static String app_secret;
/**
* 团油-app_key
*/
public static String app_key;
/**
* 团油-sign
*/
public static String sign;
@Autowired
private SysDepartInterfaceInfoDomainService sysDepartInterfaceInfoDomainService;
// @Autowired
// private ITmsTuanyouLogService tmsTuanyouLogService;
@Autowired
private NewLinkDomainService newLinkDomainService;
@Resource
private TmsDriverOilMapper tmsDriverOilMapper;
// @Resource
// private TmsExpenseRecordMapper tmsExpenseRecordMapper;
// @Resource
// private TmsDriverMapper tmsDriverMapper;
// @Resource
// private SysUserMapper sysUserMapper;
// @Resource
// private TmsOnlineooilCardConsumptionRecordMapper tmsOnlineooilCardConsumptionRecordMapper;
// @Autowired
// private TmsDriveroilRecordMapper tmsDriveroilRecordMapper;
private void setIpConfig() {
//获取request
HttpServletRequest request = ServletUtils.getRequest();
String ip = IPUtils.getIpAddr(request);
AddressUtils addressUtils = new AddressUtils();
String ip2 = addressUtils.getV4IP();
if (StringUtils.isBlank(ip2)) {
ipconfig = ip;
} else {
ipconfig = ip2;
}
}
public void getBaseInfo() {
// 调用 ip 地址获取
setIpConfig();
//获取团油三方配置
String interfaceType = "tuanyou";
List<SysDepartInterfaceInfo> sysDepartInterfaceInfoList = sysDepartInterfaceInfoDomainService.queryListByInterfaceType(interfaceType);
for (SysDepartInterfaceInfo sysDepartInterfaceInfo : sysDepartInterfaceInfoList) {
String interfaceTypeKey = sysDepartInterfaceInfo.getInterfaceTypeKey();//接口参数
String interfaceTypeValue = sysDepartInterfaceInfo.getInterfaceTypeValue();//接口参数值
switch (interfaceTypeKey) {
case "app_secret":
app_secret = interfaceTypeValue;
break;
case "app_key":
app_key = interfaceTypeValue;
break;
case "host":
host = interfaceTypeValue;
break;
default:
break;
}
}
//获取签名
time = String.valueOf(System.currentTimeMillis());
log.error("time=====" + time);
sign = EncryptionUtils.toMd5(time, app_key, app_secret);
log.info("sign======" + sign);
}
//
// /**
// * @param
// * @description:获取当前企业及⼦企业信息
// * @return: org.jeecg.modules.interfaces.tuanyou.vo.AllEnterpriseVO
// * @author: LianZhijian
// * @time: 2023-02-07 16:59:54
// */
//
// public AllEnterpriseVO getAllEnterprise() {
// getBaseInfo();
// String all_url = host + allEnterprise;
// AllEnterpriseVO allEnterpriseVO = new AllEnterpriseVO();
// try {
// String result = HttpUtils.sendPost(app_key, sign, time, all_url, "");
// log.info("getAllEnterprise----result=====" + result);
// JSONObject jsonObject = JSONObject.parseObject(result);
// if (StringUtils.isNotBlank(jsonObject.getString("code")) && "200".equals(jsonObject.getString("code"))) {
// List<EnterpriseDetailVO> enterpriseDetailVOList = JSON.parseArray(jsonObject.getString("data"), EnterpriseDetailVO.class);
// allEnterpriseVO.setData(enterpriseDetailVOList);
// } else {
// log.info("getAllEnterprise---error=====" + jsonObject.getString("msg"));
// allEnterpriseVO.setCode(Integer.parseInt(jsonObject.getString("code")));
// allEnterpriseVO.setMsg(jsonObject.getString("msg"));
// }
// TmsTuanyouLog tmsTuanyouLog = new TmsTuanyouLog();
// tmsTuanyouLog.setMethod("/open-api/enterprise/getAllEnterprise");
// tmsTuanyouLog.setResponseBody(result);
// tmsTuanyouLogService.save(tmsTuanyouLog);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return allEnterpriseVO;
// }
//
// /**
// * @param addStaffDTO
// * @description:新增员⼯
// * @return: org.jeecg.modules.interfaces.tuanyou.vo.AddStaffVO
// * @author: LianZhijian
// * @time: 2023-02-07 17:29:09
// */
//
// public AddStaffVO addStaff(AddStaffDTO addStaffDTO) {
// getBaseInfo();
// String add_url = host + addStaff;
// JSONObject map = new JSONObject();
// map.put("staff", addStaffDTO.getStaff());
// map.put("staffQuotaRule", addStaffDTO.getStaffQuotaRule());
// map.put("needSms", addStaffDTO.getNeedSms());
// String body = JSONObject.toJSONString(map);
// log.info("addStaff---body=====" + body);
// AddStaffVO addStaffVO = new AddStaffVO();
// try {
// String result = HttpUtils.sendPost(app_key, sign, time, add_url, body);
// log.info("addStaff---result=====" + result);
// JSONObject jsonObject = JSONObject.parseObject(result);
// addStaffVO.setCode(Integer.parseInt(jsonObject.getString("code")));
// addStaffVO.setMsg(jsonObject.getString("msg"));
// CreateStaffRespVO createStaffRespVO = JSON.parseObject(jsonObject.getString("data"), CreateStaffRespVO.class);
// addStaffVO.setData(createStaffRespVO);
// TmsTuanyouLog tmsTuanyouLog = new TmsTuanyouLog();
// tmsTuanyouLog.setMethod("/open-api/enterprise/staff/add");
// tmsTuanyouLog.setRequestBody(body);
// tmsTuanyouLog.setResponseBody(result);
// tmsTuanyouLog.setOrderId(addStaffDTO.getStaff().getPhone());
// tmsTuanyouLogService.save(tmsTuanyouLog);
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// return addStaffVO;
// }
//
// /**
// * @param availableAmountDTO
// * @description:修改⽤⼾可⽤额度
// * @return: org.jeecg.modules.interfaces.tuanyou.vo.AvailableAmountVO
// * @author: LianZhijian
// * @time: 2023-02-08 10:19:14
// */
//
// public AvailableAmountVO availableAmount(AvailableAmountDTO availableAmountDTO) {
// getBaseInfo();
// String availableAmount_url = host + availableAmount;
// JSONObject map = new JSONObject();
// map.put("uuid", availableAmountDTO.getUuid());
// map.put("userId", availableAmountDTO.getUserId());
// map.put("adjustmentType", availableAmountDTO.getAdjustmentType());
// map.put("adjustmentAmount", availableAmountDTO.getAdjustmentAmount());
// map.put("direction", availableAmountDTO.getDirection());
// String body = JSONObject.toJSONString(map);
// log.info("availableAmount---body=====" + body);
// AvailableAmountVO availableAmountVO = new AvailableAmountVO();
// try {
// String result = HttpUtils.sendPost(app_key, sign, time, availableAmount_url, body);
// log.info("availableAmount---result=====" + result);
// JSONObject jsonObject = JSON.parseObject(result);
// if (StringUtils.isNotBlank(jsonObject.getString("code")) && "200".equals(jsonObject.getString("code"))) {
// availableAmountVO.setCode(Integer.parseInt(jsonObject.getString("code")));
// availableAmountVO.setMsg(jsonObject.getString("msg"));
// } else {
// log.error("availableAmount---error=====" + jsonObject.getString("msg"));
// availableAmountVO.setCode(Integer.parseInt(jsonObject.getString("code")));
// availableAmountVO.setMsg(jsonObject.getString("msg"));
// }
// TmsTuanyouLog tmsTuanyouLog = new TmsTuanyouLog();
// tmsTuanyouLog.setMethod("/open-api/enterprise/staff/availableAmount");
// tmsTuanyouLog.setRequestBody(body);
// tmsTuanyouLog.setResponseBody(result);
// tmsTuanyouLog.setOrderId(availableAmountDTO.getUuid());
// tmsTuanyouLogService.save(tmsTuanyouLog);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return availableAmountVO;
// }
//
// /**
// * @param updateMobileDTO
// * @description:修改员⼯⼿机号(根据⽤⼾Id)
// * @return: org.jeecg.modules.interfaces.tuanyou.vo.AvailableAmountVO
// * @author: LianZhijian
// * @time: 2023-02-08 10:34:18
// */
//
// public AvailableAmountVO updateMobile(UpdateMobileDTO updateMobileDTO) {
// getBaseInfo();
// String updateMobile_url = host + updateMobile;
// JSONObject map = new JSONObject();
// map.put("userId", updateMobileDTO.getUserId());
// map.put("newMobile", updateMobileDTO.getNewMobile());
// String body = JSONObject.toJSONString(map);
// log.info("updateMobile---body=====" + body);
// AvailableAmountVO availableAmountVO = new AvailableAmountVO();
// try {
// String result = HttpUtils.sendPost(app_key, sign, time, updateMobile_url, body);
// log.info("updateMobile---result=====" + result);
// JSONObject jsonObject = JSON.parseObject(result);
// if (StringUtils.isNotBlank(jsonObject.getString("code")) && "200".equals(jsonObject.getString("code"))) {
// availableAmountVO.setCode(Integer.parseInt(jsonObject.getString("code")));
// availableAmountVO.setMsg(jsonObject.getString("msg"));
// } else {
// log.error("updateMobile---error=====" + jsonObject.getString("msg"));
// availableAmountVO.setCode(Integer.parseInt(jsonObject.getString("code")));
// availableAmountVO.setMsg(jsonObject.getString("msg"));
// }
// TmsTuanyouLog tmsTuanyouLog = new TmsTuanyouLog();
// tmsTuanyouLog.setMethod("/open-api/enterprise/staff/updateMobile");
// tmsTuanyouLog.setRequestBody(body);
// tmsTuanyouLog.setResponseBody(result);
// tmsTuanyouLog.setOrderId(updateMobileDTO.getUserId().toString());
// tmsTuanyouLogService.save(tmsTuanyouLog);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return availableAmountVO;
// }
//
// /**
// * @param getAccountInfoDTO
// * @description:获取员⼯详情(根据⽤⼾Id或⼿机号)
// * @return: org.jeecg.modules.interfaces.tuanyou.vo.GetAccountInfoVO
// * @author: LianZhijian
// * @time: 2023-02-09 9:44:34
// */
//
// public GetAccountInfoVO getAccountInfo(GetAccountInfoDTO getAccountInfoDTO) {
// getBaseInfo();
// String getAccountInfo_url = host + getAccountInfo;
// JSONObject map = new JSONObject();
// map.put("userId", getAccountInfoDTO.getUserId());
// map.put("phone", getAccountInfoDTO.getPhone());
// String body = JSONObject.toJSONString(map);
// log.info("getAccountInfo---body=====" + body);
// GetAccountInfoVO getAccountInfoVO = new GetAccountInfoVO();
// try {
// String result = HttpUtils.sendPost(app_key, sign, time, getAccountInfo_url, body);
// log.info("getAccountInfo---result=====" + result);
// JSONObject jsonObject = JSON.parseObject(result);
// if (StringUtils.isNotBlank(jsonObject.getString("code")) && "200".equals(jsonObject.getString("code"))) {
// getAccountInfoVO.setCode(Integer.parseInt(jsonObject.getString("code")));
// getAccountInfoVO.setMsg(jsonObject.getString("msg"));
// StaffInfoVO staffInfoVO = JSON.parseObject(jsonObject.getString("data"), StaffInfoVO.class);
// getAccountInfoVO.setData(staffInfoVO);
// } else {
// log.error("getAccountInfo---error=====" + jsonObject.getString("msg"));
// getAccountInfoVO.setCode(Integer.parseInt(jsonObject.getString("code")));
// getAccountInfoVO.setMsg(jsonObject.getString("msg"));
// }
// TmsTuanyouLog tmsTuanyouLog = new TmsTuanyouLog();
// tmsTuanyouLog.setMethod("/open-api/enterprise/staff/getAccountInfo");
// tmsTuanyouLog.setRequestBody(body);
// tmsTuanyouLog.setResponseBody(result);
// tmsTuanyouLog.setOrderId(getAccountInfoDTO.getUserId().toString());
// tmsTuanyouLogService.save(tmsTuanyouLog);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return getAccountInfoVO;
// }
public GetSecretCodeVO getSecretCode(String driverId) throws Exception {
TmsDriverOilVO tmsDriverOilVO = newLinkDomainService.queryOilByDriverId(driverId);
if (null == tmsDriverOilVO) {
throw new ServiceException("该用户没有开通油卡账户,请联系管理员");
}
GetSecretCodeVO getSecretCodeVO = new GetSecretCodeVO();
getBaseInfo();
String getAccountInfoUrl = host + getSecretCode;
JSONObject map = new JSONObject();
map.put("phone", tmsDriverOilVO.getUserPhone());
String body = JSONObject.toJSONString(map);
String result = HttpUtils.sendPost(app_key, sign, time, getAccountInfoUrl, body);
JSONObject jsonObject = JSON.parseObject(result);
String code = jsonObject.getString("code");
if ("200".equals(code)) {
JSONObject data = jsonObject.getJSONObject("data");
String url = data.getString("url");
String secretCode = data.getString("secretCode");
getSecretCodeVO.setUrl(url);
getSecretCodeVO.setSecretCode(secretCode);
} else {
String message = jsonObject.getString("message");
throw new ServiceException(message);
}
return getSecretCodeVO;
}
// public void getOilExpenseRecordInfo(JSONObject jsonObject) {
//
// String userId = jsonObject.getString("userId");//油卡持有人手机号
// String phone = jsonObject.getString("phone");//油卡持有人手机号
// String gasName = jsonObject.getString("gasName");//油站名称
// String gasAddress = jsonObject.getString("gasAddress");//油站地址
// String gunNo = jsonObject.getString("gunNo");//枪号
// String oilNo = jsonObject.getString("oilNo");//油号
// String oilName = jsonObject.getString("oilName");//油号名称
// String licensePlate = jsonObject.getString("licensePlate");//车牌号
// String num = jsonObject.getString("num");//加油升数
// String orderNo = jsonObject.getString("orderNo");//能链订单号
// String uuid = jsonObject.getString("uuid");//流⽔号
// Integer orderStatus = jsonObject.getInteger("orderStatus");//订单状态 0-待⽀付 1-已⽀付 2-退款中 4-订单取消 5-已退款 7-退款失败
// BigDecimal totalOrderAmount = jsonObject.getBigDecimal("totalOrderAmount");//订单油费金额
// BigDecimal totalUserRealAmount = jsonObject.getBigDecimal("totalUserRealAmount");//实际支付金额
// BigDecimal totalUserDiscountAmount = jsonObject.getBigDecimal("totalUserDiscountAmount");//优惠金额
// BigDecimal userRealPrice = jsonObject.getBigDecimal("userRealPrice");//优惠金额
// Date orderTime = jsonObject.getDate("orderTime");
//
// BigDecimal accountBalance = BigDecimal.ZERO;//油卡余额-司机账户
// BigDecimal accountBalance1 = BigDecimal.ZERO;//油卡余额-油卡账户
// TmsDriverOil tmsDriverOil = tmsDriverOilMapper.queryByPhoneAndUserId(phone, userId);//获取油卡账号
//
// TmsDriver tmsDriver = tmsDriverMapper.selectByDriverId(tmsDriverOil.getDriverId());//获取司机账号
// SysUser sysUser = sysUserMapper.selectById(tmsDriverOil.getDriverId());
// /*if (1 == orderStatus) {
// accountBalance1 = tmsDriverOil.getOilMonery().subtract(totalUserRealAmount);
// tmsDriverOil.setOilMonery(accountBalance1);
// accountBalance = tmsDriver.getOilCardBalance().subtract(totalUserRealAmount);
// tmsDriver.setOilCardBalance(accountBalance);
//
// TmsExpenseRecord tmsExpenseRecord = new TmsExpenseRecord();
// tmsExpenseRecord.setSerialNumber(uuid);
// tmsExpenseRecord.setSerialNumberType(1);
// tmsExpenseRecord.setReasonsForChange(3);
// tmsExpenseRecord.setRevenueAndExpenditureTypes(1);
// tmsExpenseRecord.setTransactionAmount(totalUserRealAmount);
// tmsExpenseRecord.setAccountBalance(accountBalance);
// if(sysUser.getUserRole().equals("driver")){
// tmsExpenseRecord.setAccountType(2);
// }else{
// tmsExpenseRecord.setAccountType(3);
// }
// tmsExpenseRecord.setAccountName(tmsDriver.getDriverName());
// tmsExpenseRecord.setAccountNumber(tmsDriver.getPhone());
// tmsExpenseRecord.setAccountId(tmsDriver.getDriverId());
// tmsExpenseRecord.setDriverInformation(tmsDriver.getVehicleLicenseNumber() + tmsDriver.getDriverName());
// tmsExpenseRecord.setCreateTime(new Date());
// tmsExpenseRecord.setConsumptionTime(orderTime);
// tmsExpenseRecord.setTransactionTime(orderTime);
// tmsExpenseRecord.setTradeStatus(1);
// tmsExpenseRecord.setPayType(0);
// tmsExpenseRecord.setFuelQuantity(num);
// tmsExpenseRecord.setGunNumber(gunNo);
// tmsExpenseRecord.setGasStation(gasName);
// tmsExpenseRecord.setGasAddress(gasAddress);
// tmsExpenseRecord.setOilGrade(oilNo);
// tmsExpenseRecordMapper.insert(tmsExpenseRecord);
// //新增油卡记录
// TmsDriveroilRecord tmsDriveroilRecord=new TmsDriveroilRecord();
// tmsDriveroilRecord.setCardNo(tmsDriver.getPhone());
// tmsDriveroilRecord.setCardName(tmsDriver.getDriverName());
// tmsDriveroilRecord.setSerialNumber(uuid);
// tmsDriveroilRecord.setSerialType("平台油卡");
// tmsDriveroilRecord.setSerialBeca("平台油卡--加油");
// tmsDriveroilRecord.setCardMonery(totalUserRealAmount);
// tmsDriveroilRecord.setCardBalance(accountBalance1);
// tmsDriveroilRecord.setDatetime(new Date());
// tmsDriveroilRecordMapper.insert(tmsDriveroilRecord);
// tmsDriverMapper.updateById(tmsDriver);
// tmsDriverOilMapper.updateById(tmsDriverOil);
//
// TmsTuanyouLog tmsTuanyouLog = new TmsTuanyouLog();
// tmsTuanyouLog.setMethod("payPush");
// tmsTuanyouLog.setRequestBody(JSON.toJSONString(jsonObject));
// tmsTuanyouLog.setOrderId(uuid);
// tmsTuanyouLogService.save(tmsTuanyouLog);
// }*/
//
//
//
//
// /*TmsOnlineooilCardConsumptionRecord tmsOnlineooilCardConsumptionRecord = new TmsOnlineooilCardConsumptionRecord();
// tmsOnlineooilCardConsumptionRecord.setSerialNumber(uuid);
// tmsOnlineooilCardConsumptionRecord.setOilCardNo(userId);
// tmsOnlineooilCardConsumptionRecord.setVehicleLicenseNumber(licensePlate);
// tmsOnlineooilCardConsumptionRecord.setName(tmsDriver.getDriverName());
// tmsOnlineooilCardConsumptionRecord.setPhone(tmsDriver.getPhone());
// tmsOnlineooilCardConsumptionRecord.setTotalConsumptionAmount(totalUserRealAmount);
// tmsOnlineooilCardConsumptionRecord.setFuelQuantity(num);
// tmsOnlineooilCardConsumptionRecord.setUnitPrice(userRealPrice);
// tmsOnlineooilCardConsumptionRecord.setOilGrade(oilNo);
// tmsOnlineooilCardConsumptionRecord.setProductName(oilName);
// tmsOnlineooilCardConsumptionRecord.setGunNumber(gunNo);
// tmsOnlineooilCardConsumptionRecord.setGasStation(gasName);
// tmsOnlineooilCardConsumptionRecord.setLookOilOrderNumber(orderNo);
// tmsOnlineooilCardConsumptionRecord.setDissipate(orderTime);
// tmsOnlineooilCardConsumptionRecord.setExpenseRecordSerialNumber(tmsExpenseRecord.getSerialNumber());
// tmsOnlineooilCardConsumptionRecord.setCreateTime(new Date());
// //订单所有状态0-待⽀付 1-已⽀付 2-退款中4-订单取消 5-已退款 7-退款失败
// //订单状态(1-取消,2-成功,3-失败,4-处理中,5-撤销) tmsOnlineooilCardConsumptionRecord
// if(orderStatus==0){
// tmsOnlineooilCardConsumptionRecord.setOrderStatus(4);
// }else if(orderStatus==1){
// tmsOnlineooilCardConsumptionRecord.setOrderStatus(2);
// }else if(orderStatus==2){
// tmsOnlineooilCardConsumptionRecord.setOrderStatus(4);
// }else if(orderStatus==4){
// tmsOnlineooilCardConsumptionRecord.setOrderStatus(5);
// }else if(orderStatus==5){
// tmsOnlineooilCardConsumptionRecord.setOrderStatus(2);
// }else if(orderStatus==7){
// tmsOnlineooilCardConsumptionRecord.setOrderStatus(3);
// }else {
// tmsOnlineooilCardConsumptionRecord.setOrderStatus(2);
// }
// tmsOnlineooilCardConsumptionRecord.setGasAddress(gasAddress);
//
// tmsOnlineooilCardConsumptionRecordMapper.insert(tmsOnlineooilCardConsumptionRecord);*/
// }
//
//
// public void getOilExpenseRecordPayInfo(JSONObject jsonObject) {
// String userId = jsonObject.getString("userId");//油卡持有人手机号
// String phone = jsonObject.getString("phone");//油卡持有人手机号
// String orderNo = jsonObject.getString("orderNo");//能链订单号
// String gasId = jsonObject.getString("gasId");//油站id
// String gasName = jsonObject.getString("gasName");//油站名称
// String gasAddress = jsonObject.getString("gasAddress");//油站地址
// Integer orderStatus = jsonObject.getInteger("orderStatus");//订单状态 0-待⽀付 1-已⽀付 2-退款中 4-订单取消 5-已退款 7-退款失败
//
// String gunNo = jsonObject.getString("gunNo");//枪号
// String oilNo = jsonObject.getString("oilNo");//油号
// String oilName = jsonObject.getString("oilName");//油号名称
// String licensePlate = jsonObject.getString("licensePlate");//车牌号
// String num = jsonObject.getString("num");//加油升数
//
// String uuid = jsonObject.getString("uuid");//流⽔号
//
// BigDecimal totalOrderAmount = jsonObject.getBigDecimal("totalOrderAmount");//订单油费金额
// BigDecimal totalUserRealAmount = jsonObject.getBigDecimal("totalUserRealAmount");//实际支付金额
// BigDecimal totalUserDiscountAmount = jsonObject.getBigDecimal("totalUserDiscountAmount");//优惠金额
// BigDecimal userRealPrice = jsonObject.getBigDecimal("userRealPrice");//优惠金额
// Date orderTime = jsonObject.getDate("orderTime");
//
// BigDecimal accountBalance = BigDecimal.ZERO;//油卡余额-司机账户
// BigDecimal accountBalance1 = BigDecimal.ZERO;//油卡余额-油卡账户
// TmsDriverOil tmsDriverOil = tmsDriverOilMapper.queryByPhoneAndUserId(phone, userId);//获取油卡账号
//
// TmsDriver tmsDriver = tmsDriverMapper.selectByDriverId(tmsDriverOil.getDriverId());//获取司机账号
// SysUser sysUser = sysUserMapper.selectById(tmsDriverOil.getDriverId());
// if (1 == orderStatus) {
// accountBalance1 = tmsDriverOil.getOilMonery().subtract(totalUserRealAmount);
// tmsDriverOil.setOilMonery(accountBalance1);
// accountBalance = tmsDriver.getOilCardBalance().subtract(totalUserRealAmount);
// tmsDriver.setOilCardBalance(accountBalance);
//
// TmsExpenseRecord tmsExpenseRecord = new TmsExpenseRecord();
// tmsExpenseRecord.setSerialNumber(uuid);
// tmsExpenseRecord.setSerialNumberType(1);
// tmsExpenseRecord.setReasonsForChange(3);
// tmsExpenseRecord.setRevenueAndExpenditureTypes(1);
// tmsExpenseRecord.setTransactionAmount(totalUserRealAmount);
// tmsExpenseRecord.setAccountBalance(accountBalance);
// if (sysUser.getUserRole().equals("driver")) {
// tmsExpenseRecord.setAccountType(2);
// } else {
// tmsExpenseRecord.setAccountType(3);
// }
// tmsExpenseRecord.setAccountName(tmsDriver.getDriverName());
// tmsExpenseRecord.setAccountNumber(tmsDriver.getPhone());
// tmsExpenseRecord.setAccountId(tmsDriver.getDriverId());
// tmsExpenseRecord.setDriverInformation(tmsDriver.getVehicleLicenseNumber() + tmsDriver.getDriverName());
// tmsExpenseRecord.setCreateTime(new Date());
// tmsExpenseRecord.setConsumptionTime(orderTime);
// tmsExpenseRecord.setTransactionTime(orderTime);
// tmsExpenseRecord.setTradeStatus(1);
// tmsExpenseRecord.setPayType(0);
// tmsExpenseRecord.setFuelQuantity(num);
// tmsExpenseRecord.setGunNumber(gunNo);
// tmsExpenseRecord.setGasStation(gasName);
// tmsExpenseRecord.setGasAddress(gasAddress);
// tmsExpenseRecord.setOilGrade(oilNo);
// tmsExpenseRecordMapper.insert(tmsExpenseRecord);
// //新增油卡记录
// TmsDriveroilRecord tmsDriveroilRecord = new TmsDriveroilRecord();
// tmsDriveroilRecord.setCardNo(tmsDriver.getPhone());
// tmsDriveroilRecord.setCardName(tmsDriver.getDriverName());
// tmsDriveroilRecord.setSerialNumber(uuid);
// tmsDriveroilRecord.setSerialType("平台油卡");
// tmsDriveroilRecord.setSerialBeca("平台油卡--加油");
// tmsDriveroilRecord.setCardMonery(totalUserRealAmount);
// tmsDriveroilRecord.setCardBalance(accountBalance1);
// tmsDriveroilRecord.setDatetime(new Date());
// tmsDriveroilRecordMapper.insert(tmsDriveroilRecord);
// tmsDriverMapper.updateById(tmsDriver);
// tmsDriverOilMapper.updateById(tmsDriverOil);
//
// TmsTuanyouLog tmsTuanyouLog = new TmsTuanyouLog();
// tmsTuanyouLog.setMethod("/ntocc/newlink/getOilExpenseRecordPayInfo");
// tmsTuanyouLog.setResponseBody(JSON.toJSONString(jsonObject));
// tmsTuanyouLog.setOrderId(uuid);
// tmsTuanyouLogService.save(tmsTuanyouLog);
// }
// }
}
@@ -0,0 +1,261 @@
package com.linke.thirdParty.application.server;
import com.aliyun.oss.ClientConfiguration;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.common.auth.DefaultCredentialProvider;
import com.aliyun.oss.internal.OSSHeaders;
import com.aliyun.oss.model.CannedAccessControlList;
import com.aliyun.oss.model.ObjectMetadata;
import com.aliyun.oss.model.PutObjectRequest;
import com.aliyun.oss.model.StorageClass;
import com.mhd.common.core.domain.po.thirdparty.SysDepartInterfaceInfoPo;
import com.linke.thirdParty.domain.departInterfaceInfo.repository.todo.SysDepartInterfaceInfoDo;
import com.mhd.common.core.oss.configure.OSSClientPrivateUtil;
import com.mhd.common.core.oss.entity.OssInterfaceInfo;
import com.mhd.common.core.oss.service.OssPrivateService;
import com.mhd.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.List;
import java.util.Random;
@Service
@Slf4j
public class OssUploadApplicationService {
@Resource
private OssPrivateService ossPrivateService;
@Resource
private SysDepartInterfaceInfoApplicationService interfaceInfoApplicationService;
private static String endPoint;
private static String accessKeyId;
private static String accessKeySecret;
private static String bucketName;
/**
* 上传文件到oss
*
* @param file 文件
* @return 文件路径
*/
public String uploadOssPrivate(File file) {
OssInterfaceInfo ossInterfaceInfo = getOssInterface();
String FILE_URL = ossPrivateService.uploadOssPrivate(file, ossInterfaceInfo);
return FILE_URL;
}
/**
* @Description 获取加密后url地址
* @Author Alex
* @Date 2023/5/4 13:45
*/
public String getFileUrlsPrivate(String fileUrl) {
OssInterfaceInfo ossInterfaceInfo = getOssInterface();
String FILE_URL = OSSClientPrivateUtil.preSignPrivateURL(fileUrl, ossInterfaceInfo);
return FILE_URL;
}
/**
* @Description 从阿里云对象存储中删除,防止垃圾文件堆积浪费存储空间
* @Author Alex
* @Date 2023/5/4 14:44
*/
public void batchDeleteFile(String fileUrl) {
OssInterfaceInfo ossInterfaceInfo = getOssInterface();
OSSClientPrivateUtil.batchDeleteFile(fileUrl, ossInterfaceInfo);
}
/**
* 进行文件上传,支持各种形式的流
*
* @param inputStream 输入流
* @param suffix 文件名后缀
* @param dir 文件名
* @return 返回上传后的对象url 地址
*/
public String simpleUpload(InputStream inputStream, String suffix, String dir) {
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
sysDepartInterfaceInfoDo.setInterfaceType("oss_upload");
String interfaceType = "oss_upload";
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPoList = interfaceInfoApplicationService.queryList(sysDepartInterfaceInfoDo);
for (SysDepartInterfaceInfoPo sysDepartInterfaceInfo: sysDepartInterfaceInfoPoList) {
String interfaceTypeKey = sysDepartInterfaceInfo.getInterfaceTypeKey();//接口参数
String interfaceTypeValue = sysDepartInterfaceInfo.getInterfaceTypeValue();//接口参数值
switch (interfaceTypeKey){
case "bucketName" :
bucketName = interfaceTypeValue;
break;
case "secretKey" :
accessKeySecret = interfaceTypeValue;
break;
case "accessKey" :
accessKeyId = interfaceTypeValue;
break;
case "endpoint" :
endPoint = interfaceTypeValue;
break;
default :
break;
}
}
initOSS(endPoint, accessKeyId, accessKeySecret);
//获取oss信息
if (inputStream == null) {
log.error("通过OSS 流式上传时,输入流为空");
return "";
}
String filename = dir + "." + suffix;
this.put(filename, inputStream);
return resourceUrl(filename);
}
/**
* 把文件liu传到 oss
*/
private void put(String filename, InputStream inputStream) {
OSS ossClient = this.buildOss();
ossClient.putObject(
jurisdiction(
this.buildRequest(filename, inputStream)
)
);
ossClient.shutdown();
}
/**
* 构建oss 组件
*/
private OSS buildOss() {
return new OSSClientBuilder().build(
endPoint, accessKeyId, accessKeySecret);
}
/**
* 设置存储类型与访问权限
*
* @param request 文件请求
*/
private static PutObjectRequest jurisdiction(PutObjectRequest request) {
ObjectMetadata metadata = new ObjectMetadata();
metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString());
metadata.setObjectAcl(CannedAccessControlList.PublicRead);
request.setMetadata(metadata);
return request;
}
/**
* 构建请求对象
*
* @param filename 文件名
* @param inputStream 流
*/
private PutObjectRequest buildRequest(String filename, InputStream inputStream) {
return new PutObjectRequest(bucketName, filename, inputStream);
}
/**
* 获取上传到 oss 后文件的链接
*/
private String resourceUrl(String filename) {
return "https://" + bucketName + "." + endPoint + "/" + filename;
}
/**
* oss 工具客户端
*/
private static OSSClient ossClient = null;
/**
* 初始化 oss 客户端
*
* @return
*/
private static OSSClient initOSS(String endpoint, String accessKeyId, String accessKeySecret) {
if (ossClient == null) {
ossClient = new OSSClient(endpoint,
new DefaultCredentialProvider(accessKeyId, accessKeySecret),
new ClientConfiguration());
}
return ossClient;
}
public OssInterfaceInfo getOssInterface(){
OssInterfaceInfo ossInterfaceInfo = new OssInterfaceInfo();
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
sysDepartInterfaceInfoDo.setInterfaceType("oss_upload");
sysDepartInterfaceInfoDo.setTopOrganizationId(2L);
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPoList = interfaceInfoApplicationService.queryList(sysDepartInterfaceInfoDo);
for (SysDepartInterfaceInfoPo sysDepartInterfaceInfo : sysDepartInterfaceInfoPoList) {
String interfaceTypeKey = sysDepartInterfaceInfo.getInterfaceTypeKey();//接口参数
String interfaceTypeValue = sysDepartInterfaceInfo.getInterfaceTypeValue();//接口参数值
switch (interfaceTypeKey) {
case "bucketName":
ossInterfaceInfo.setBucketName(interfaceTypeValue);
break;
case "secretKey":
ossInterfaceInfo.setAccessKeySecret(interfaceTypeValue);
break;
case "accessKey":
ossInterfaceInfo.setAccessKeyId(interfaceTypeValue);
break;
case "endpoint":
ossInterfaceInfo.setEndpoint(interfaceTypeValue);
break;
default:
break;
}
}
return ossInterfaceInfo;
}
public String analysisUrl(String url) {
if (StringUtils.isNotBlank(url)) {
//查询三方接口信息
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
sysDepartInterfaceInfoDo.setInterfaceType("oss_upload");
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPoList = interfaceInfoApplicationService.queryList1(sysDepartInterfaceInfoDo);
OssInterfaceInfo ossInterfaceInfo = OSSClientPrivateUtil.getInterfaceInfo(sysDepartInterfaceInfoPoList);
String[] split = url.split(",");
StringBuilder urls = new StringBuilder();
for (String s : split) {
if (url.contains(".png")
|| url.contains(".jpg")
|| url.contains(".jpeg")
|| url.contains(".gif")
|| url.contains(".pdf")
) {
String s1 = OSSClientPrivateUtil.preSignPrivateURL(s, ossInterfaceInfo);
if (StringUtils.isBlank(urls.toString())) {
urls.append(s1);
} else {
urls.append("," + s1);
}
}
}
return urls.toString();
}
return null;
}
public String getOutUrl(String outUrl) throws Exception {
// 线上地址
URL url = new URL(outUrl);
URLConnection connection = url.openConnection();
// 打开连接获取输入流
InputStream inputStream = connection.getInputStream();
Random random = new Random(10000);
String name = random.nextInt(10000) + System.currentTimeMillis() + "data";
return simpleUpload(inputStream,"pdf", name);
}
}
@@ -0,0 +1,492 @@
package com.linke.thirdParty.application.server;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.alibaba.fastjson.JSON;
import com.aliyun.oss.ServiceException;
import com.linke.thirdParty.application.server.common.CommonApplicationService;
import com.linke.thirdParty.domain.departInterfaceInfo.entity.SysDepartInterfaceInfo;
import com.linke.thirdParty.domain.departInterfaceInfo.service.SysDepartInterfaceInfoDomainService;
import com.linke.thirdParty.domain.sms.entity.SysSendsmsNum;
import com.linke.thirdParty.domain.sms.repository.mapper.SysSendsmsNumMapper;
import com.linke.thirdParty.domain.sms.repository.todo.SysSendsmsNumDo;
import com.linke.thirdParty.domain.sms.service.SysSendsmsNumDomainService;
import com.linke.thirdParty.infrastructure.feign.UserServiceFeign;
import com.mhd.common.core.constant.*;
import com.mhd.common.core.domain.dto.NoticeMessageLoggingDto;
import com.mhd.common.core.domain.po.SysTenantsPo;
import com.mhd.common.core.domain.po.UserConfigSwitchPo;
import com.mhd.common.core.domain.thirdparty.SmsDTO;
import com.mhd.common.core.domain.thirdparty.SmsMessageDTO;
import com.mhd.common.core.enums.MessageTypeEnum;
import com.mhd.common.core.exception.CaptchaException;
import com.mhd.common.core.regular.CommonRegular;
import com.mhd.common.core.utils.IPUtils;
import com.mhd.common.core.utils.sms.CommonConstant;
import com.mhd.common.core.utils.sms.Result;
import com.mhd.common.core.utils.sms.SendSmsResult;
import com.mhd.common.core.utils.sms.httpclient.*;
import com.mhd.common.core.utils.sms.utils.SmsSenderUtil;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.redis.service.RedisService;
import com.mhd.system.api.OrganizationServiceFeign;
import com.mhd.system.api.SystemServiceFeign;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Service
public class SmsApplicationService {
private String url = "http://api.51welink.com/EncryptionSubmit/SendSms.ashx";
@Autowired
private SysSendsmsNumDomainService sysSendsmsNumDomainService;
@Resource
private SysSendsmsNumMapper sysSendsmsNumMapper;
@Autowired
private CommonApplicationService commonApplicationService;
@Resource
private RedisService redisService;
@Resource
private SystemServiceFeign systemServiceFeign;
@Autowired
private SysDepartInterfaceInfoDomainService sysDepartInterfaceInfoDomainService;
@Resource
private OrganizationServiceFeign organizationServiceFeign;
public Result sendMsg(SmsDTO smsDTO, HttpServletRequest request) {
//请求域名
String path = smsDTO.getPath();
if (StringUtils.isBlank(path)){
path = "dytt.manhuoda.com";
}
//租户一级组织ID
AjaxResult topOrganizationIdR = organizationServiceFeign.getOrganizationByPath(path, SecurityConstants.INNER);
if (ObjectUtil.isNull(topOrganizationIdR) || ObjectUtil.isNull(topOrganizationIdR.get("data"))) {
throw new ServiceException("一级组织不存在异常或请求域名有误");
}
SysTenantsPo sysTenantsPo = JSON.parseObject(JSON.toJSONString(topOrganizationIdR.get("data")), SysTenantsPo.class);
//图片验证码校验
if (StrUtil.equals(smsDTO.getIsCheckCaptcha(),"1")){
checkCaptcha(smsDTO);
}
Result result = new Result();
//手机号
String phone = smsDTO.getPhone();
String ip = IPUtils.getIpAddr(request);
String smsmode = smsDTO.getSmsmode();
if(StringUtils.isBlank(phone)){
throw new ServiceException("手机号不能为空");
}
if(StringUtils.isBlank(smsmode)){
throw new ServiceException("短信模板不能为空");
}
//TODO 暂时注释,配置的验证码发送平台需要组织ID获取,如果是登陆发送验证码没有登录人
// UserConfigSwitchPo configSwitch = commonApplicationService.getUserConfigSwitch();
//校验手机号格式
Pattern pattern = Pattern.compile(CommonRegular.PHONE);
Matcher match = pattern.matcher(phone);
if (!match.matches()) {
throw new ServiceException("请输入正确手机号");
}
String key;
if (CommonConstant.SMS_TPL_TYPE_0.equals(smsmode)) {
key = CacheConstants.SMS_LOGIN + phone;
}else if(CommonConstant.SMS_TPL_TYPE_1.equals(smsmode)){
key = CacheConstants.SMS_REGISTER + phone;
}else if(CommonConstant.SMS_TPL_TYPE_2.equals(smsmode)) {
key = CacheConstants.SMS_FORGET + phone;
} else if(CommonConstant.SMS_TPL_TYPE_3.equals(smsmode)) {
key = CacheConstants.SMS_CHANGE + phone;
}else if(CommonConstant.SMS_TPL_TYPE_4.equals(smsmode)) {
key = CacheConstants.SMS_EDIT_PHONE + phone;
}else if(CommonConstant.SMS_TPL_TYPE_5.equals(smsmode)) {
key = CacheConstants.SMS_PAY_CHANGE + phone;
}else {
throw new com.mhd.common.core.exception.ServiceException("暂无短信模板");
}
//调用缓存校验验证码是否有效,避免重复发送
Object object = redisService.getCacheObject(key);
if (object != null) {
throw new ServiceException("验证码5分钟内,仍然有效!");
}
//生成验证码
final String captcha = RandomUtil.randomNumbers(6);
SysSendsmsNum sysSendsmsNum = sysSendsmsNumMapper.queryLastSmsNoticeByPhone(phone);
if(sysSendsmsNum!=null){
Calendar dateOne= Calendar.getInstance();
Calendar dateTwo=Calendar.getInstance();
dateOne.setTime(new Date()); //设置为当前系统时间
dateTwo.setTime(sysSendsmsNum.getCreateTime()); //获取数据库中的时间
long timeOne=dateOne.getTimeInMillis();
long timeTwo=dateTwo.getTimeInMillis();
long minute=(timeOne-timeTwo)/(1000*60);//转化minute
if(minute<1){
throw new ServiceException("短信一分钟内只允许发送一次!");
}
}
List<SysSendsmsNum> tmsSendsmsNumList = sysSendsmsNumMapper.queryTodaySmsNoticeByPhone(phone);
if(tmsSendsmsNumList.size()>=20){
throw new ServiceException("手机号"+phone+"一天内最多发送20次!");
}
// List<SysSendsmsNum> tmsSendsmsNumList1 = sysSendsmsNumMapper.queryTodaySmsNoticeByIP(ip);
//if(tmsSendsmsNumList1.size()>=20){
//throw new ServiceException("同一ip"+ip+"一天内最多发送20次!");
//}
//调用三方发送验证码
// if (0 == configSwitch.getSmsSendingPlatform()) {
// //乐信通
// result = smsWelink(smsDTO,captcha);
// } else if (1 == configSwitch.getSmsSendingPlatform()) {
// //网上行
// } else if (2 == configSwitch.getSmsSendingPlatform()) {
// //腾讯云
// }
result = smsWelink(smsDTO, captcha);
//验证码5分钟内有效 redis中的key由类型和手机号组成
redisService.setCacheObject(key,captcha, 300L, TimeUnit.SECONDS);
SysSendsmsNumDo sysSendsmsNumDo = new SysSendsmsNumDo();
sysSendsmsNumDo.setCreateTime(new Date());
sysSendsmsNumDo.setPhone(phone);
sysSendsmsNumDo.setIp(ip);
sysSendsmsNumDo.setCaptcha(captcha);
sysSendsmsNumDomainService.save(sysSendsmsNumDo);
//新增消息(推送)
NoticeMessageLoggingDto noticeMessageLoggingDto = new NoticeMessageLoggingDto();
noticeMessageLoggingDto.setUserId(sysTenantsPo.getUserId());
noticeMessageLoggingDto.setJumpPage(0);
String text = "";
if (CommonConstant.SMS_TPL_TYPE_1.equals(smsmode)) {
text = com.mhd.common.core.utils.StringUtils.format(NoticeConstants.verify_code_success,smsDTO.getPhone(),"注册",captcha);
}else if(CommonConstant.SMS_TPL_TYPE_0.equals(smsmode)){
text = com.mhd.common.core.utils.StringUtils.format(NoticeConstants.verify_code_success,smsDTO.getPhone(), "登录",captcha);
}else if(CommonConstant.SMS_TPL_TYPE_2.equals(smsmode)) {
text = com.mhd.common.core.utils.StringUtils.format(NoticeConstants.verify_code_success,smsDTO.getPhone(), "忘记密码",captcha);
} else if(CommonConstant.SMS_TPL_TYPE_3.equals(smsmode)) {
text = com.mhd.common.core.utils.StringUtils.format(NoticeConstants.verify_code_success,smsDTO.getPhone(), "修改密码",captcha);
} else if(CommonConstant.SMS_TPL_TYPE_4.equals(smsmode)) {
text = com.mhd.common.core.utils.StringUtils.format(NoticeConstants.verify_code_success,smsDTO.getPhone(), "修改手机号",captcha);
}else {
text = com.mhd.common.core.utils.StringUtils.format(NoticeConstants.verify_code_success,smsDTO.getPhone(), "修改支付密码",captcha);
}
noticeMessageLoggingDto.setNoticeMessageContent(text);
noticeMessageLoggingDto.setNoticeMessageTitle(NoticeConstants.verify_code_title);
noticeMessageLoggingDto.setCreateTime(new Date());
noticeMessageLoggingDto.setMessagePushTime(new Date());
noticeMessageLoggingDto.setMessageReceivingTime(new Date());
noticeMessageLoggingDto.setNoticeMessageType(MessageTypeEnum.code_notifications.getCode());
noticeMessageLoggingDto.setNoticeMessageName(MessageTypeEnum.code_notifications.getInfo());
systemServiceFeign.addMessageLogging(noticeMessageLoggingDto);
return result;
}
/**
* 验证码图片校验
* @param smsDTO
* @throws CaptchaException
*/
public void checkCaptcha(SmsDTO smsDTO) throws CaptchaException {
String code = smsDTO.getCode();
String uuid = smsDTO.getUuid();
if (StrUtil.isEmpty(code)) {
throw new CaptchaException("验证码不能为空");
}
if (StrUtil.isEmpty(uuid)) {
throw new CaptchaException("验证码已失效");
}
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
String captcha = redisService.getCacheObject(verifyKey);
redisService.deleteObject(verifyKey);
if (!code.equalsIgnoreCase(captcha)) {
throw new CaptchaException("验证码错误");
}
}
/***
* @Author:
* @Description: 调用乐信通短信发送
* @Date: 2020/10/12 9:16
* @Param smsDTO:
* @return: org.jeecg.common.api.vo.Result
**/
public Result<String> smsWelink(SmsDTO smsDTO, String captcha){
Result<String> result = new Result<String>();
//获取登录用户信息
String phone = smsDTO.getPhone();
String smsmode = smsDTO.getSmsmode();
// String organizationName = StringUtils.isBlank(smsDTO.getOrganizationName()) ? "数字物流":smsDTO.getOrganizationName();
String organizationName = "数字物流";
SendSmsResult sendSmsResult = new SendSmsResult();
try {
/**
* smsmode 短信模板方式 0 .登录模板、1.注册模板、2.忘记密码模板、3.修改密码模板、4.修改手机
*/
String content;
//注册模板
if (CommonConstant.SMS_TPL_TYPE_1.equals(smsmode)) {
content = com.mhd.common.core.utils.StringUtils.format(SmsConstants.registerText,organizationName,captcha);
}else if(CommonConstant.SMS_TPL_TYPE_0.equals(smsmode)){
content = com.mhd.common.core.utils.StringUtils.format(SmsConstants.loginText,organizationName,captcha);
}else if(CommonConstant.SMS_TPL_TYPE_2.equals(smsmode)) {
content = com.mhd.common.core.utils.StringUtils.format(SmsConstants.forgotPasswordText,organizationName,captcha);
} else if(CommonConstant.SMS_TPL_TYPE_3.equals(smsmode)) {
content = com.mhd.common.core.utils.StringUtils.format(SmsConstants.changePasswordText,organizationName,captcha);
} else if(CommonConstant.SMS_TPL_TYPE_4.equals(smsmode)) {
content = com.mhd.common.core.utils.StringUtils.format(SmsConstants.changePhoneText,organizationName,captcha);
}else if(CommonConstant.SMS_TPL_TYPE_5.equals(smsmode)) {
content = com.mhd.common.core.utils.StringUtils.format(SmsConstants.changePayPasswordText,organizationName,captcha);
}else {
throw new com.mhd.common.core.exception.ServiceException("暂无短信模板");
}
sendSmsResult = send(phone,content);
//判断短信发送是否成功
if(!sendSmsResult.getResult().equals("succ")){
result.setResult(sendSmsResult.getReason()+sendSmsResult.getResult());
throw new ServiceException(sendSmsResult.getReason()+sendSmsResult.getResult());
}else {
result.setResult(sendSmsResult.getReason());
result.setCode(CommonConstant.SC_OK_200);
}
} catch (ServiceException e) {
e.printStackTrace();
throw new ServiceException(e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
throw new ServiceException(e.getMessage());
}
return result;
}
/**
* @Description 发送短信
* @Author Alex
* @Date 2020/2/15 17:33
*/
public SendSmsResult send(String phone ,String content){
try {
String accountId = "";
String password = "";
String signName = "";
String ExtendNo = "";
String ProductId = "";
ArrayList<String> PhoneNos = new ArrayList<>();
PhoneNos.add(phone);
String SendTime = "";
String OutId = "";
//获取乐信通短信平台信息
String interfaceType = "sms_welink";
List<SysDepartInterfaceInfo> sysDepartInterfaceInfoList= sysDepartInterfaceInfoDomainService.queryListByInterfaceType(interfaceType);
for (SysDepartInterfaceInfo sysDepartInterfaceInfo: sysDepartInterfaceInfoList) {
String interfaceTypeKey = sysDepartInterfaceInfo.getInterfaceTypeKey();//接口参数
String interfaceTypeValue = sysDepartInterfaceInfo.getInterfaceTypeValue();//接口参数值
switch (interfaceTypeKey){
case "account_id" :
accountId = interfaceTypeValue;
break;
case "product_id" :
ProductId = interfaceTypeValue;
break;
case "password" :
password = interfaceTypeValue;
break;
case "sign_name" :
signName = interfaceTypeValue;
break;
default :
break;
}
}
//随机数
long Random = SmsSenderUtil.getRandom();
//时间戳
long Timestamp = SmsSenderUtil.getCurrentTime();
//拼装
JSONObject body = new JSONObject()
.put("AccountId", accountId)
.put("ExtendNo", SmsSenderUtil.isNotEmpty(ExtendNo) ? ExtendNo : "")
.put("ProductId", SmsSenderUtil.isNotEmpty(ProductId) ? ProductId : "")
.put("PhoneNos", String.join(",", PhoneNos))
.put("Content", SmsSenderUtil.isNotEmpty(content) ? content : "")
.put("AccessKey", SmsSenderUtil.calcSendSmsSign(accountId, PhoneNos.get(0), password, Random, Timestamp))
.put("Timestamp", Timestamp)
.put("Random", Random)
.put("OutId", SmsSenderUtil.isNotEmpty(OutId) ? OutId : "")
.put("SendTime", SmsSenderUtil.isNotEmpty(SendTime) ? SendTime : "");
HttpRequest request = new HttpRequest(HttpMethod.POST, this.url)
.addHeader("Content-Type", "application/json")
.setConnectTimeout(60 * 1000)
.setRequestTimeout(60 * 1000)
.setBody(body.toString());
HttpResponse response = new DefaultHttpClient().fetch(request);
handleError(response);
return (new SendSmsResult()).parseFromHttpResponse(response);
} catch (URISyntaxException | HttpException | IOException e) {
throw new RuntimeException("API url has been modified, current url: " + url);
}
}
/***
* @Author:
* @Description: 调用乐信通短信发送
* @Date: 2020/10/12 9:16
* @Param smsDTO:
* @return: org.jeecg.common.api.vo.Result
**/
public Result<String> smsWelink(List<String> phones, String content){
Result<String> result = new Result<String>();
SendSmsResult sendSmsResult = new SendSmsResult();
try {
sendSmsResult = send(phones,content);
//判断短信发送是否成功
if(!sendSmsResult.getResult().equals("succ")){
result.setResult(sendSmsResult.getReason()+sendSmsResult.getResult());
throw new ServiceException(sendSmsResult.getReason()+sendSmsResult.getResult());
}else {
result.setResult(sendSmsResult.getReason());
result.setCode(CommonConstant.SC_OK_200);
}
} catch (ServiceException e) {
e.printStackTrace();
throw new ServiceException(e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
throw new ServiceException(e.getMessage());
}
return result;
}
/**
* @Description 批量发送短信
* @Author Alex
* @Date 2020/2/15 17:33
*/
public SendSmsResult send(List<String> phones, String content) {
try {
String accountId = "";
String password = "";
String signName = "";
String ExtendNo = "";
String ProductId = "";
String SendTime = "";
String OutId = "";
//获取乐信通短信平台信息
String interfaceType = "sms_welink";
List<SysDepartInterfaceInfo> sysDepartInterfaceInfoList = sysDepartInterfaceInfoDomainService.queryListByInterfaceType(interfaceType);
for (SysDepartInterfaceInfo sysDepartInterfaceInfo : sysDepartInterfaceInfoList) {
String interfaceTypeKey = sysDepartInterfaceInfo.getInterfaceTypeKey();//接口参数
String interfaceTypeValue = sysDepartInterfaceInfo.getInterfaceTypeValue();//接口参数值
switch (interfaceTypeKey) {
case "account_id":
accountId = interfaceTypeValue;
break;
case "product_id":
ProductId = interfaceTypeValue;
break;
case "password":
password = interfaceTypeValue;
break;
case "sign_name":
signName = interfaceTypeValue;
break;
default:
break;
}
}
//随机数
long Random = SmsSenderUtil.getRandom();
//时间戳
long Timestamp = SmsSenderUtil.getCurrentTime();
//拼装
JSONObject body = new JSONObject()
.put("AccountId", accountId)
.put("ExtendNo", SmsSenderUtil.isNotEmpty(ExtendNo) ? ExtendNo : "")
.put("ProductId", SmsSenderUtil.isNotEmpty(ProductId) ? ProductId : "")
.put("PhoneNos", String.join(",", phones))
.put("Content", SmsSenderUtil.isNotEmpty(content) ? content : "")
.put("AccessKey", SmsSenderUtil.calcSendSmsSign(accountId, phones.get(0), password, Random, Timestamp))
.put("Timestamp", Timestamp)
.put("Random", Random)
.put("OutId", SmsSenderUtil.isNotEmpty(OutId) ? OutId : "")
.put("SendTime", SmsSenderUtil.isNotEmpty(SendTime) ? SendTime : "");
HttpRequest request = new HttpRequest(HttpMethod.POST, this.url)
.addHeader("Content-Type", "application/json")
.setConnectTimeout(60 * 1000)
.setRequestTimeout(60 * 1000)
.setBody(body.toString());
HttpResponse response = new DefaultHttpClient().fetch(request);
handleError(response);
return (new SendSmsResult()).parseFromHttpResponse(response);
} catch (URISyntaxException | HttpException | IOException e) {
throw new RuntimeException("API url has been modified, current url: " + url);
}
}
public HttpResponse handleError(HttpResponse response) throws HttpException {
if(response.statusCode < 200 || response.statusCode >= 300) {
throw new HttpException(response.statusCode, response.reason);
}
return response;
}
public Result sendMessage(SmsMessageDTO smsMessageDTO) {
// String phone = smsMessageDTO.getPhone();
List<String> phones = smsMessageDTO.getPhones();
UserConfigSwitchPo configSwitch = commonApplicationService.getUserConfigSwitch();
String content = smsMessageDTO.getContent();
// if (StringUtils.isBlank(phone)) {
// throw new ServiceException("手机号不能为空");
// }
if (CollUtil.isEmpty(phones)) {
throw new ServiceException("手机号不能为空");
}
if (StringUtils.isBlank(content)) {
throw new ServiceException("短信内容不能为空");
}
Result<String> result = new Result<String>();
//调用三方发送验证码
String organizationName = "数字物流";
content = com.mhd.common.core.utils.StringUtils.format(SmsConstants.signrReceiptText,organizationName,content);
//调用三方发送验证码
if (0 == configSwitch.getSmsSendingPlatform()) {
//乐信通
result = smsWelink(phones, content);
} else if (1 == configSwitch.getSmsSendingPlatform()) {
//网上行
} else if (2 == configSwitch.getSmsSendingPlatform()) {
//腾讯云
}
return result;
}
}
@@ -0,0 +1,278 @@
package com.linke.thirdParty.application.server;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.linke.thirdParty.domain.departInterfaceInfo.entity.SysDepartInterfaceInfo;
import com.linke.thirdParty.domain.departInterfaceInfo.repository.todo.SysDepartInterfaceInfoDo;
import com.linke.thirdParty.domain.departInterfaceInfo.service.SysDepartInterfaceInfoDomainService;
import com.linke.thirdParty.infrastructure.feign.ProductServiceFeign;
import com.mhd.common.core.constant.CacheConstants;
import com.mhd.common.core.domain.entity.OrgProductConfig;
import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.domain.po.SysTenantsPo;
import com.mhd.common.core.domain.po.thirdparty.SysDepartInterfaceInfoPo;
import com.mhd.common.core.domain.thirdparty.SysDepartInterfaceInfoDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.redis.service.RedisService;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @Description: 三方接口信息
* @Author: Alex
* @Date: 2020-03-03 10:11:17
* @Version: V1.0
*/
@Service
@Slf4j
public class SysDepartInterfaceInfoApplicationService {
@Autowired
private SysDepartInterfaceInfoDomainService sysDepartInterfaceInfoDomainService;
@Resource
private RedisService redisService;
@Autowired
private ProductServiceFeign productServiceFeign;
public List<SysDepartInterfaceInfoPo> queryList(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo) {
if(sysDepartInterfaceInfoDo.getTopOrganizationId() == null){
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
sysDepartInterfaceInfoDo.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
}
return sysDepartInterfaceInfoDomainService.queryList(sysDepartInterfaceInfoDo);
}
public List<SysDepartInterfaceInfoPo> queryList1(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo) {
return sysDepartInterfaceInfoDomainService.queryList(sysDepartInterfaceInfoDo);
}
/**
* 新增
*/
public Boolean save(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo) {
//获取当前登录人
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
sysDepartInterfaceInfoDo.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
R<SysTenantsPo> tenantsByOrgan = productServiceFeign.getTenantsByOrgan(sysDepartInterfaceInfoDo.getOrganizationId());
if (R.SUCCESS == tenantsByOrgan.getCode()) {
SysTenantsPo sysTenantsPo = tenantsByOrgan.getData();
if (null != sysTenantsPo) {
sysDepartInterfaceInfoDo.setTenantsName(sysTenantsPo.getTenantsName());
sysDepartInterfaceInfoDo.setTopOrganizationId(sysTenantsPo.getTopOrganizationId());
}
} else {
throw new ServiceException("获取租户信息失败");
}
return sysDepartInterfaceInfoDomainService.save(sysDepartInterfaceInfoDo);
}
/**
* 修改
*/
public Boolean update(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo) {
//获取当前登录人
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
sysDepartInterfaceInfoDo.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
R<SysTenantsPo> tenantsByOrgan = productServiceFeign.getTenantsByOrgan(sysDepartInterfaceInfoDo.getOrganizationId());
if (R.SUCCESS == tenantsByOrgan.getCode()) {
SysTenantsPo sysTenantsPo = tenantsByOrgan.getData();
if (null != sysTenantsPo) {
sysDepartInterfaceInfoDo.setTenantsName(sysTenantsPo.getTenantsName());
sysDepartInterfaceInfoDo.setTopOrganizationId(sysTenantsPo.getTopOrganizationId());
}
} else {
throw new ServiceException("获取租户信息失败");
}
//做更新时,如果有需要更新Redis的,在此处方法增加
Boolean update = sysDepartInterfaceInfoDomainService.update(sysDepartInterfaceInfoDo);
refreshRedis(sysDepartInterfaceInfoDo);
return update;
}
/**
* 刷新Redis
* @param sysDepartInterfaceInfoDo
*/
private void refreshRedis(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo) {
LoginUser userInfo = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(userInfo)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//token过期时间
if (ObjectUtil.equal(sysDepartInterfaceInfoDo.getInterfaceTypeKey(),"login_expire_time")){
String key = CacheConstants.TOKEN_EXPIRE_TIME + userInfo.getUserPo().getTopOrganizationId();
redisService.setCacheObject(key, sysDepartInterfaceInfoDo.getInterfaceTypeValue());
}
//是否含有网货产品、是否含有商城产品
if(ObjectUtil.equal(sysDepartInterfaceInfoDo.getInterfaceType(),"wlhy") || ObjectUtil.equal(sysDepartInterfaceInfoDo.getInterfaceType(),"mall")){
String key = CacheConstants.ORG_PRODUCT_KEY + userInfo.getUserPo().getTopOrganizationId();
//从三方配置表中取值
SysDepartInterfaceInfoDo wlhy = new SysDepartInterfaceInfoDo();
wlhy.setTopOrganizationId(userInfo.getUserPo().getTopOrganizationId());
wlhy.setInterfaceType("wlhy");
wlhy.setInterfaceTypeKey("has_wlhy");
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPos = queryList(wlhy);
int wlhyFlag = 2;
if (CollUtil.isNotEmpty(sysDepartInterfaceInfoPos)) {
String interfaceTypeValue = sysDepartInterfaceInfoPos.get(0).getInterfaceTypeValue();
if (StrUtil.equals("1", interfaceTypeValue)) {
wlhyFlag = 1;
}
}
wlhy.setTopOrganizationId(userInfo.getUserPo().getTopOrganizationId());
wlhy.setInterfaceType("mall");
wlhy.setInterfaceTypeKey("has_mall");
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoTwo = queryList(wlhy);
int mallFlag = 2;
if (CollUtil.isNotEmpty(sysDepartInterfaceInfoTwo)) {
String interfaceTypeValue = sysDepartInterfaceInfoTwo.get(0).getInterfaceTypeValue();
if (StrUtil.equals("1", interfaceTypeValue)) {
mallFlag = 1;
}
}
OrgProductConfig orgProductConfigFlag = new OrgProductConfig();
orgProductConfigFlag.setWlhyFlag(wlhyFlag);
orgProductConfigFlag.setMallFlag(mallFlag);
redisService.setCacheObject(key, orgProductConfigFlag);
}
}
/**
* 删除
*/
public int delete(Long[] ids) {
return sysDepartInterfaceInfoDomainService.delete(ids);
}
/**
* @Description 根据接口类型查询三方接口信息
* @Author Alex
* @Date 2020/2/15 14:21
*/
public List<SysDepartInterfaceInfo> queryListByInterfaceTypeSysOrgCode(String interfaceType, String sysOrgCode) {
return sysDepartInterfaceInfoDomainService.queryListByInterfaceTypeSysOrgCode(interfaceType,sysOrgCode);
}
public List<SysDepartInterfaceInfo> queryListByInterfaceType(String interfaceType) {
log.info("无缓存dictCache的时候调用这里!");
return sysDepartInterfaceInfoDomainService.queryListByInterfaceType(interfaceType);
}
public SysDepartInterfaceInfo queryListByInterfaceTypeAndKey(String interfaceType, String interfaceTypeKey) {
log.info("无缓存dictCache的时候调用这里!");
return sysDepartInterfaceInfoDomainService.queryListByInterfaceTypeAndKey(interfaceType,interfaceTypeKey);
}
public List<SysDepartInterfaceInfoPo> getDeptInterfaceInfoList(String sysOrgCode) {
return sysDepartInterfaceInfoDomainService.getDeptInterfaceInfoList(sysOrgCode);
}
public void saveSysDeptInterfaceInfo(
String sysOrgCode,
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPos,
Integer netTransportPlate,
Integer environment) {
sysDepartInterfaceInfoDomainService.saveSysDeptInterfaceInfo(sysOrgCode,sysDepartInterfaceInfoPos,netTransportPlate,environment);
}
public SysDepartInterfaceInfoPo queryById(Long id) {
SysDepartInterfaceInfo sysDepartInterfaceInfo = sysDepartInterfaceInfoDomainService.queryById(id);
SysDepartInterfaceInfoPo sysDepartInterfaceInfoPo = new SysDepartInterfaceInfoPo();
BeanUtils.copyProperties(sysDepartInterfaceInfo,sysDepartInterfaceInfoPo);
return sysDepartInterfaceInfoPo;
}
public List<SysDepartInterfaceInfoPo> ossList() {
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
sysDepartInterfaceInfoDo.setInterfaceType("oss_upload");
List<SysDepartInterfaceInfoPo> list = sysDepartInterfaceInfoDomainService.queryList(sysDepartInterfaceInfoDo);
return list;
}
/**
* 分页列表查询(根据组织查询)
* @param sysDepartInterfaceInfoDo
* @return
*/
public List<SysDepartInterfaceInfoPo> queryListByOrg(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//默认根据传入的组织ID查询 如果未查到数据则查询一级组织数据
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPos = null;
if (ObjectUtil.isNull(sysDepartInterfaceInfoDo.getOrganizationId())){
Long organizationId = loginUser.getUserPo().getOrganizationId();
if (organizationId != null && organizationId != 1){
sysDepartInterfaceInfoDo.setOrganizationId(organizationId);
}
}
sysDepartInterfaceInfoPos = sysDepartInterfaceInfoDomainService.queryList(sysDepartInterfaceInfoDo);
if (CollUtil.isNotEmpty(sysDepartInterfaceInfoPos)){
return sysDepartInterfaceInfoPos;
}
//一级组织ID
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
sysDepartInterfaceInfoDo.setOrganizationId(null);
sysDepartInterfaceInfoDo.setTopOrganizationId(topOrganizationId);
sysDepartInterfaceInfoPos = sysDepartInterfaceInfoDomainService.queryList(sysDepartInterfaceInfoDo);
if (CollUtil.isEmpty(sysDepartInterfaceInfoPos)){
throw new ServiceException("配置信息未找到");
}
return sysDepartInterfaceInfoPos;
}
/**
* 分页列表查询(根据组织查询)
* @param sysDepartInterfaceInfoDo
* @return
*/
public List<SysDepartInterfaceInfoPo> listByOrgByFeign(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//默认根据传入的组织ID查询 如果未查到数据则查询一级组织数据
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPos = null;
if (ObjectUtil.isNull(sysDepartInterfaceInfoDo.getOrganizationId())){
Long organizationId = loginUser.getUserPo().getOrganizationId();
if (organizationId != null && organizationId != 1){
sysDepartInterfaceInfoDo.setOrganizationId(organizationId);
}
}
sysDepartInterfaceInfoPos = sysDepartInterfaceInfoDomainService.queryList(sysDepartInterfaceInfoDo);
if (CollUtil.isNotEmpty(sysDepartInterfaceInfoPos)){
return sysDepartInterfaceInfoPos;
}else {
throw new ServiceException("配置信息未找到");
}
}
}
@@ -0,0 +1,65 @@
package com.linke.thirdParty.application.server;
import com.linke.thirdParty.domain.thridCall.repository.po.ThridCallPO;
import com.linke.thirdParty.domain.thridCall.repository.todo.ThridCallDO;
import com.linke.thirdParty.domain.thridCall.service.ThridCallDomainService;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 三方回调ApplicationService
*
* @author gen
* @date 2024-04-28
*/
@Service
@Slf4j
public class ThridCallApplicationService {
@Autowired
private ThridCallDomainService thridCallDomainService;
/**
* 分页查询三方回调列表
*/
public List<ThridCallPO> queryList(ThridCallDO thridCallDO) {
return thridCallDomainService.queryList(thridCallDO);
}
/**
* 新增三方回调
*/
public Boolean insert(ThridCallDO thridCallDO) {
return thridCallDomainService.insert(thridCallDO);
}
/**
* 修改三方回调
*/
public Boolean update(ThridCallDO thridCallDO) {
return thridCallDomainService.update(thridCallDO);
}
/**
* 批量删除三方回调
*/
public boolean delete(Long[] thridCallIds) {
return thridCallDomainService.delete(thridCallIds);
}
/**
* 获取三方回调详细信息
*/
public ThridCallPO getInfo(Long thridCallId)
{
return thridCallDomainService.getInfo(thridCallId);
}
}
@@ -0,0 +1,59 @@
package com.linke.thirdParty.application.server.common;
import com.alibaba.fastjson2.JSONObject;
import com.linke.thirdParty.infrastructure.feign.SystemServiceFeign;
import com.mhd.common.core.constant.CacheConstants;
import com.mhd.common.core.domain.po.UserConfigSwitchPo;
import com.mhd.common.core.domain.po.UserPo;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.redis.service.RedisService;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 公共 应用服务层
* <p>
* 本层可以综合应用各种业务间的组合
* <p>
* 2023-02-20
*
* @author 王子豪
*/
@Service
@Slf4j
public class CommonApplicationService {
@Autowired
private SystemServiceFeign systemServiceFeign;
@Resource
private RedisService redisService;
/**
* 获取用户所在组织的开关配置信息
* @return
*/
public UserConfigSwitchPo getUserConfigSwitch() {
//获取登录人信息
UserConfigSwitchPo userConfigSwitchPo;
LoginUser loginUser = SecurityUtils.getLoginUser();
UserPo userPo = loginUser.getUserPo();
Long organizationId = userPo.getOrganizationId();
userConfigSwitchPo = redisService.getCacheObject(CacheConstants.USER_COMFIG_SWITCH_KEY + organizationId);
if(null == userConfigSwitchPo || userConfigSwitchPo.getUserConfigSwitchId() == null){
//查询数据库,并且存到redis中
AjaxResult ajaxResult = systemServiceFeign.getUserConfigSwitchInfo();
if("200".equals(String.valueOf(ajaxResult.get("code")))){
userConfigSwitchPo = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), UserConfigSwitchPo.class);
if(null != userConfigSwitchPo){
//存入redis中
redisService.setCacheObject(CacheConstants.USER_COMFIG_SWITCH_KEY + organizationId ,userConfigSwitchPo);
}
}
}
return userConfigSwitchPo;
}
}
@@ -0,0 +1,86 @@
package com.linke.thirdParty.application.server.userAuthEsign;
import com.linke.thirdParty.domain.userAuthEsign.repository.po.UserAuthEsignPO;
import com.linke.thirdParty.domain.userAuthEsign.repository.todo.UserAuthEsignDO;
import com.linke.thirdParty.domain.userAuthEsign.service.UserAuthEsignDomainService;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* e签宝用户印章授权ApplicationService
*
* @author gen
* @date 2024-12-03
*/
@Service
@Slf4j
public class UserAuthEsignApplicationService {
@Autowired
private UserAuthEsignDomainService userAuthEsignDomainService;
/**
* 分页查询e签宝用户印章授权列表
*/
public List<UserAuthEsignPO> queryList(UserAuthEsignDO userAuthEsignDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
userAuthEsignDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return userAuthEsignDomainService.queryList(userAuthEsignDO);
}
/**
* 新增e签宝用户印章授权
*/
public Boolean insert(UserAuthEsignDO userAuthEsignDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
userAuthEsignDO.setUserId(loginUser.getUserPo().getUserId());
userAuthEsignDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
userAuthEsignDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
userAuthEsignDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
userAuthEsignDO.setCreateByName(loginUser.getUserPo().getUserName());
userAuthEsignDO.setCreateBy(loginUser.getUserPo().getUserId());
userAuthEsignDO.setCreateTime(new Date());
}
}
return userAuthEsignDomainService.insert(userAuthEsignDO);
}
/**
* 修改e签宝用户印章授权
*/
public Boolean update(UserAuthEsignDO userAuthEsignDO) {
return userAuthEsignDomainService.update(userAuthEsignDO);
}
/**
* 批量删除e签宝用户印章授权
*/
public boolean delete(Long[] userAuthEsignIds) {
return userAuthEsignDomainService.delete(userAuthEsignIds);
}
/**
* 获取e签宝用户印章授权详细信息
*/
public UserAuthEsignPO getInfo(Long userAuthEsignId)
{
return userAuthEsignDomainService.getInfo(userAuthEsignId);
}
}
@@ -0,0 +1,69 @@
package com.linke.thirdParty.domain.departInterfaceInfo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 三方接口配置信息对象 sys_depart_interface_info
*
* @author mhd
* @date 2023-03-27
*/
@Data
public class SysDepartInterfaceInfo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 三方信息ID */
@ApiModelProperty(name = "三方信息ID")
@TableId(type = IdType.AUTO)
private Long sysDepartInterfaceInfoId;
/** 接口类型(短信、推送、支付宝等) */
@ApiModelProperty(name = "接口类型(短信、推送、支付宝等)")
private String interfaceType;
/** 接口参数 */
@ApiModelProperty(name = "接口参数")
private String interfaceTypeKey;
/** 接口参数值 */
@ApiModelProperty(name = "接口参数值")
private String interfaceTypeValue;
/** 接口类型名称 */
@ApiModelProperty(name = "接口类型名称")
private String interfaceTypeName;
/** 接口类型描述 */
@ApiModelProperty(name = "接口类型描述")
private String interfaceTypeDescription;
@ApiModelProperty(name = "租户名称")
private String tenantsName;
/** 删除标记:0-无状态,1-正常,2-已删除 */
@ApiModelProperty(name = "删除标记:0-无状态,1-正常,2-已删除")
private Integer delFlag;
/** 更新次数 */
@ApiModelProperty(name = "更新次数")
private Long updateCount;
/** 一级组织表ID */
@ApiModelProperty(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织ID")
@Excel(name = "组织ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
}
@@ -0,0 +1,47 @@
package com.linke.thirdParty.domain.departInterfaceInfo.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linke.thirdParty.domain.departInterfaceInfo.entity.SysDepartInterfaceInfo;
import com.linke.thirdParty.domain.departInterfaceInfo.repository.todo.SysDepartInterfaceInfoDo;
import com.mhd.common.core.domain.po.thirdparty.SysDepartInterfaceInfoPo;
import java.util.List;
/**
* @Description: 三方接口信息
* @Author: Alex
* @Date: 2020-03-03 10:11:17
* @Version: V1.0
*/
public interface ISysDepartInterfaceInfoInterface extends IService<SysDepartInterfaceInfo> {
List<SysDepartInterfaceInfoPo> queryList(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo);
Boolean save(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo);
Boolean update(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo);
int delete(Long[] ids);
/**
* @Description
* @Author Alex
* @Date 2020/3/3 10:32
*/
public List<SysDepartInterfaceInfo> queryListByInterfaceTypeSysOrgCode(String interfaceType, String sysOrgCode);
/**
* @Description
* @Author Alex
* @Date 2020/3/3 10:32
*/
public List<SysDepartInterfaceInfo> queryListByInterfaceType(String interfaceType);
public SysDepartInterfaceInfo queryListByInterfaceTypeAndKey(String interfaceType, String interfaceTypeKey);
List<SysDepartInterfaceInfoPo> getDeptInterfaceInfoList(String sysOrgCode);
void saveSysDeptInterfaceInfo(String sysOrgCode, List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPos, Integer netTransportPlate, Integer environment);
SysDepartInterfaceInfo queryById(Long id);
}
@@ -0,0 +1,64 @@
package com.linke.thirdParty.domain.departInterfaceInfo.repository.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linke.thirdParty.domain.departInterfaceInfo.entity.SysDepartInterfaceInfo;
import com.linke.thirdParty.domain.departInterfaceInfo.repository.todo.SysDepartInterfaceInfoDo;
import com.mhd.common.core.domain.po.thirdparty.SysDepartInterfaceInfoPo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* @Description: 三方接口信息
* @Author: Alex
* @Date: 2020-03-03 10:11:17
* @Version: V1.0
*/
public interface SysDepartInterfaceInfoMapper extends BaseMapper<SysDepartInterfaceInfo> {
public List<SysDepartInterfaceInfo> selectByMainId(@Param("mainId") String mainId);
/**
* @功能:三方接口信息 分页查询
* @param sysDepartInterfaceInfoDo
* @Date: 2020-02-15 09:56:11
* @return
*/
public List<SysDepartInterfaceInfoPo> queryList(@Param("sysDepartInterfaceInfoDo") SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo);
/**
* @Description 根据接口类型查询三方接口信息
* @Author Alex
* @Date 2020/2/15 14:15
*/
@Select("SELECT * FROM sys_depart_interface_info WHERE interface_type = #{interfaceType} and sys_org_code = #{sysOrgCode} ")
public List<SysDepartInterfaceInfo> queryListByInterfaceTypeSysOrgCode(String interfaceType, String sysOrgCode);
/**
* @Description 根据接口类型查询三方接口信息
* @Author Alex
* @Date 2020/2/15 14:15
*/
@Select("SELECT * FROM sys_depart_interface_info WHERE interface_type = #{interfaceType} and del_flag = 1")
public List<SysDepartInterfaceInfo> queryListByInterfaceType(String interfaceType);
@Select("select a.interface_type_key,a.interface_type_value from sys_depart_interface_info a where del_flag = 1")
List<SysDepartInterfaceInfo> queryAllList();
@Select("select * from sys_depart_interface_info a where del_flag = 1")
List<SysDepartInterfaceInfo> queryAllInfoList();
@Select("SELECT * FROM sys_depart_interface_info WHERE interface_type = #{interfaceType} and interface_type_key = #{interfaceTypeKey} ")
public SysDepartInterfaceInfo queryListByInterfaceTypeAndKey(@Param("interfaceType") String interfaceType, @Param("interfaceTypeKey") String interfaceTypeKey);
List<SysDepartInterfaceInfoPo> queryListBySysOrgCode(String sysOrgCode);
/***
* @Author:
* @Description: 有则更新 无则插入 (未用)
* @Date: 2022-01-27 10:44
* @Param sysDepartInterfaceInfoVO:
* @return: int
**/
int saveOrUpdate(@Param(value = "sysDepartInterfaceInfoVO") SysDepartInterfaceInfoPo sysDepartInterfaceInfoPo);
@Select("SELECT * FROM sys_depart_interface_info WHERE interface_type_key = #{isAllowedTon} ")
SysDepartInterfaceInfo queryListByInter(@Param("isAllowedTon") String isAllowedTon);
}
@@ -0,0 +1,173 @@
package com.linke.thirdParty.domain.departInterfaceInfo.repository.persistence;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linke.thirdParty.domain.departInterfaceInfo.entity.SysDepartInterfaceInfo;
import com.linke.thirdParty.domain.departInterfaceInfo.repository.facade.ISysDepartInterfaceInfoInterface;
import com.linke.thirdParty.domain.departInterfaceInfo.repository.mapper.SysDepartInterfaceInfoMapper;
import com.linke.thirdParty.domain.departInterfaceInfo.repository.todo.SysDepartInterfaceInfoDo;
import com.linke.thirdParty.infrastructure.feign.ProductServiceFeign;
import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.domain.po.SysTenantsPo;
import com.mhd.common.core.domain.po.thirdparty.SysDepartInterfaceInfoPo;
import com.mhd.common.core.exception.ServiceException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 三方接口配置信息Service业务层处理
*
* @author mhd
* @date 2023-03-27
*/
@Service
public class SysDepartInterfaceInfoImpl extends ServiceImpl<SysDepartInterfaceInfoMapper, SysDepartInterfaceInfo> implements ISysDepartInterfaceInfoInterface
{
@Resource
private SysDepartInterfaceInfoMapper sysDepartInterfaceInfoMapper;
@Autowired
private ProductServiceFeign productServiceFeign;
@Override
public List<SysDepartInterfaceInfoPo> queryList(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo) {
return sysDepartInterfaceInfoMapper.queryList(sysDepartInterfaceInfoDo);
}
/**
* 新增
*/
@Override
public Boolean save(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo) {
SysDepartInterfaceInfo sysDepartInterfaceInfo = new SysDepartInterfaceInfo();
BeanUtils.copyProperties(sysDepartInterfaceInfoDo, sysDepartInterfaceInfo);
//刷新一级组织信息
refreshTopOrg(sysDepartInterfaceInfoDo);
sysDepartInterfaceInfo.setCreateTime(new Date());
sysDepartInterfaceInfo.setDelFlag(1);
return this.save(sysDepartInterfaceInfo);
}
/**
* 修改
*/
@Override
public Boolean update(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo) {
SysDepartInterfaceInfo sysDepartInterfaceInfo = new SysDepartInterfaceInfo();
SysDepartInterfaceInfo sysDepartInterfaceInfo1 = sysDepartInterfaceInfoMapper.selectById(sysDepartInterfaceInfoDo.getSysDepartInterfaceInfoId());
BeanUtils.copyProperties(sysDepartInterfaceInfoDo, sysDepartInterfaceInfo);
if (ObjectUtil.isNotNull(sysDepartInterfaceInfoDo.getOrganizationId()) && ObjectUtil.notEqual(sysDepartInterfaceInfoDo.getOrganizationId(), sysDepartInterfaceInfo1.getOrganizationId())){
//刷新一级组织信息
refreshTopOrg(sysDepartInterfaceInfoDo);
}
sysDepartInterfaceInfo.setUpdateTime(new Date());
sysDepartInterfaceInfo.setUpdateCount(sysDepartInterfaceInfo1.getUpdateCount()+1);
boolean b = this.updateById(sysDepartInterfaceInfo);
return b;
}
/**
* 刷新一级组织信息
*/
public void refreshTopOrg(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo) {
if (ObjectUtil.isNull(sysDepartInterfaceInfoDo.getOrganizationId())){
throw new ServiceException("缺少必要参数");
}
//根据组织获取一级组织信息
R<SysTenantsPo> sysTenantsPoR = productServiceFeign.getTenantsByOrgan(sysDepartInterfaceInfoDo.getOrganizationId());
if (R.SUCCESS == sysTenantsPoR.getCode()) {
SysTenantsPo sysTenantsPo = sysTenantsPoR.getData();
if (null != sysTenantsPo) {
sysDepartInterfaceInfoDo.setTenantsName(sysTenantsPo.getTenantsName());
sysDepartInterfaceInfoDo.setTopOrganizationId(sysTenantsPo.getTopOrganizationId());
}
} else {
throw new ServiceException("获取租户信息失败");
}
}
/**
* 删除
*/
@Override
public int delete(Long[] ids) {
List<SysDepartInterfaceInfo> list = new ArrayList<>();
for (int i = 0; i < ids.length; i++) {
SysDepartInterfaceInfo sysDepartInterfaceInfo = new SysDepartInterfaceInfo();
sysDepartInterfaceInfo.setDelFlag(2);
sysDepartInterfaceInfo.setSysDepartInterfaceInfoId(ids[i]);
list.add(sysDepartInterfaceInfo);
this.updateBatchById(list);
}
return ids.length;
}
/**
* @Description 根据接口类型查询三方接口信息
* @Author Alex
* @Date 2020/2/15 14:21
*/
@Override
public List<SysDepartInterfaceInfo> queryListByInterfaceTypeSysOrgCode(String interfaceType,String sysOrgCode) {
return sysDepartInterfaceInfoMapper.queryListByInterfaceTypeSysOrgCode(interfaceType,sysOrgCode);
}
@Override
public List<SysDepartInterfaceInfo> queryListByInterfaceType(String interfaceType) {
return sysDepartInterfaceInfoMapper.queryListByInterfaceType(interfaceType);
}
@Override
public SysDepartInterfaceInfo queryListByInterfaceTypeAndKey(String interfaceType,String interfaceTypeKey) {
return sysDepartInterfaceInfoMapper.queryListByInterfaceTypeAndKey(interfaceType,interfaceTypeKey);
}
@Override
public List<SysDepartInterfaceInfoPo> getDeptInterfaceInfoList(String sysOrgCode) {
return sysDepartInterfaceInfoMapper.queryListBySysOrgCode(sysOrgCode);
}
@Override
@Transactional
public void saveSysDeptInterfaceInfo(
String sysOrgCode,
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPos,
Integer netTransportPlate,
Integer environment) {
QueryWrapper<SysDepartInterfaceInfo> wrapper = new QueryWrapper<>();
wrapper.eq("sys_org_code",sysOrgCode);
wrapper.eq("interface_type","networkFreight");
sysDepartInterfaceInfoMapper.delete(wrapper);
for (SysDepartInterfaceInfoPo sysDepartInterfaceInfoVO : sysDepartInterfaceInfoPos) {
sysDepartInterfaceInfoVO.setSysDepartInterfaceInfoId(Long.getLong(String.valueOf(IdWorker.getId())));
sysDepartInterfaceInfoVO.setCreateTime(new Date());
sysDepartInterfaceInfoVO.setUpdateTime(new Date());
sysDepartInterfaceInfoVO.setInterfaceType("networkFreight");
SysDepartInterfaceInfo sysDepartInterfaceInfo = new SysDepartInterfaceInfo();
BeanUtils.copyProperties(sysDepartInterfaceInfoVO,sysDepartInterfaceInfo);
sysDepartInterfaceInfoMapper.insert(sysDepartInterfaceInfo);
}
/*QueryWrapper<TaxactionEntity> taxactionEntityQueryWrapper = new QueryWrapper<>();
taxactionEntityQueryWrapper.eq("sys_org_code",sysOrgCode);
TaxactionEntity taxactionEntity = taxationMapper.selectOne(taxactionEntityQueryWrapper);
taxactionEntity.setEnvironment(environment);
taxactionEntity.setNetTransportPlate(map.get(netTransportPlate));
taxationMapper.updateById(taxactionEntity);*/
}
@Override
public SysDepartInterfaceInfo queryById(Long id) {
return sysDepartInterfaceInfoMapper.selectById(id);
}
}
@@ -0,0 +1,69 @@
package com.linke.thirdParty.domain.departInterfaceInfo.repository.todo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 三方接口配置信息对象 sys_depart_interface_info
*
* @author mhd
* @date 2023-03-27
*/
@Data
public class SysDepartInterfaceInfoDo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 三方信息ID */
@ApiModelProperty(name = "三方信息ID")
@TableId(type = IdType.AUTO)
private Long sysDepartInterfaceInfoId;
/** 接口类型(短信、推送、支付宝等) */
@ApiModelProperty(name = "接口类型(短信、推送、支付宝等)")
private String interfaceType;
/** 接口参数 */
@ApiModelProperty(name = "接口参数")
private String interfaceTypeKey;
/** 接口参数值 */
@ApiModelProperty(name = "接口参数值")
private String interfaceTypeValue;
/** 接口类型名称 */
@ApiModelProperty(name = "接口类型名称")
private String interfaceTypeName;
@ApiModelProperty(name = "接口类型描述")
private String interfaceTypeDescription;
@ApiModelProperty(name = "租户名称")
private String tenantsName;
/** 删除标记:0-无状态,1-正常,2-已删除 */
@ApiModelProperty(name = "删除标记:0-无状态,1-正常,2-已删除")
private Integer delFlag;
/** 更新次数 */
@ApiModelProperty(name = "更新次数")
private Long updateCount;
/** 一级组织表ID */
@ApiModelProperty(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织ID")
@Excel(name = "组织ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
}
@@ -0,0 +1,88 @@
package com.linke.thirdParty.domain.departInterfaceInfo.service;
import com.linke.thirdParty.domain.departInterfaceInfo.entity.SysDepartInterfaceInfo;
import com.linke.thirdParty.domain.departInterfaceInfo.repository.facade.ISysDepartInterfaceInfoInterface;
import com.linke.thirdParty.domain.departInterfaceInfo.repository.todo.SysDepartInterfaceInfoDo;
import com.mhd.common.core.domain.po.thirdparty.SysDepartInterfaceInfoPo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Description: 三方接口信息
* @Author: Alex
* @Date: 2020-03-03 10:11:17
* @Version: V1.0
*/
@Service
@Slf4j
public class SysDepartInterfaceInfoDomainService {
@Autowired
private ISysDepartInterfaceInfoInterface sysDepartInterfaceInfoInterface;
public List<SysDepartInterfaceInfoPo> queryList(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo) {
return sysDepartInterfaceInfoInterface.queryList(sysDepartInterfaceInfoDo);
}
/**
* 新增
*/
public Boolean save(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo) {
return sysDepartInterfaceInfoInterface.save(sysDepartInterfaceInfoDo);
}
/**
* 修改
*/
public Boolean update(SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo) {
return sysDepartInterfaceInfoInterface.update(sysDepartInterfaceInfoDo);
}
/**
* 删除
*/
public int delete(Long[] ids) {
return sysDepartInterfaceInfoInterface.delete(ids);
}
/**
* @Description 根据接口类型查询三方接口信息
* @Author Alex
* @Date 2020/2/15 14:21
*/
public List<SysDepartInterfaceInfo> queryListByInterfaceTypeSysOrgCode(String interfaceType, String sysOrgCode) {
return sysDepartInterfaceInfoInterface.queryListByInterfaceTypeSysOrgCode(interfaceType,sysOrgCode);
}
public List<SysDepartInterfaceInfo> queryListByInterfaceType(String interfaceType) {
log.info("无缓存dictCache的时候调用这里!");
return sysDepartInterfaceInfoInterface.queryListByInterfaceType(interfaceType);
}
public SysDepartInterfaceInfo queryListByInterfaceTypeAndKey(String interfaceType, String interfaceTypeKey) {
log.info("无缓存dictCache的时候调用这里!");
return sysDepartInterfaceInfoInterface.queryListByInterfaceTypeAndKey(interfaceType,interfaceTypeKey);
}
public List<SysDepartInterfaceInfoPo> getDeptInterfaceInfoList(String sysOrgCode) {
return sysDepartInterfaceInfoInterface.getDeptInterfaceInfoList(sysOrgCode);
}
public void saveSysDeptInterfaceInfo(
String sysOrgCode,
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPos,
Integer netTransportPlate,
Integer environment) {
sysDepartInterfaceInfoInterface.saveSysDeptInterfaceInfo(sysOrgCode,sysDepartInterfaceInfoPos,netTransportPlate,environment);
}
public SysDepartInterfaceInfo queryById(Long id) {
return sysDepartInterfaceInfoInterface.queryById(id);
}
}
@@ -0,0 +1,43 @@
package com.linke.thirdParty.domain.sms.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class SysSendsmsNum extends BaseVOEntity {
/**
* 短信id
*/
@ApiModelProperty("短信id")
@TableId(type = IdType.AUTO)
private Long sysSendsmsNumId;
/**
* 用户表id
*/
@ApiModelProperty("用户表id")
private Long userId;
/**
* 手机号
*/
@ApiModelProperty("手机号")
private String phone;
/**
* ip地址
*/
@ApiModelProperty("ip地址")
private String ip;
/**
* 验证码
*/
@ApiModelProperty("验证码")
private String captcha;
}
@@ -0,0 +1,39 @@
package com.linke.thirdParty.domain.sms.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linke.thirdParty.domain.sms.entity.SysSendsmsNum;
import com.linke.thirdParty.domain.sms.repository.po.SysSendsmsNumPo;
import com.linke.thirdParty.domain.sms.repository.todo.SysSendsmsNumDo;
import java.util.List;
import java.util.Map;
/**
* @description 发送短信记录表
* @author xiaohan
* @date 2023-03-29
*/
public interface SysSendsmsNumInterface extends IService<SysSendsmsNum> {
/**
* 查询列表
* @param sysSendsmsNumDo
* @return
*/
List<SysSendsmsNumPo> queryList(SysSendsmsNumDo sysSendsmsNumDo);
/**
* 新增
*/
public Object save(SysSendsmsNumDo sysSendsmsNumDo);
/**
* 删除
*/
public Object delete(Long[] ids);
/**
* 更新
*/
public Object update(SysSendsmsNumDo sysSendsmsNumDo);
}
@@ -0,0 +1,45 @@
package com.linke.thirdParty.domain.sms.repository.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linke.thirdParty.domain.sms.entity.SysSendsmsNum;
import com.linke.thirdParty.domain.sms.repository.po.SysSendsmsNumPo;
import com.linke.thirdParty.domain.sms.repository.todo.SysSendsmsNumDo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* @description 发送短信记录表
* @author xiaohan
* @date 2023-03-29
*/
public interface SysSendsmsNumMapper extends BaseMapper<SysSendsmsNum> {
/**
* 刪除
* @author xiaohan
* @date 2023/03/29
**/
int delete(@Param("id")int id);
/**
* 更新
* @author xiaohan
* @date 2023/03/29
**/
int update(@Param("sysSendsmsNum")SysSendsmsNum sysSendsmsNum);
List<SysSendsmsNumPo> queryList(@Param("sysSendsmsNumDo")SysSendsmsNumDo sysSendsmsNumDo);
@Select(" select * from sys_sendsms_num where phone = #{phone} and del_flag = 1 order by create_time desc limit 1")
SysSendsmsNum queryLastSmsNoticeByPhone(@Param("phone")String phone);
@Select(" select * from sys_sendsms_num where phone = #{phone} and del_flag = 1 and to_days(create_time) = to_days(now()) order by create_time desc ")
List<SysSendsmsNum> queryTodaySmsNoticeByPhone(@Param("phone")String phone);
@Select(" select * from sys_sendsms_num where ip = #{ip} and del_flag = 0 and to_days(create_time) = to_days(now()) order by create_time desc ")
List<SysSendsmsNum> queryTodaySmsNoticeByIP(@Param("ip")String ip);
}
@@ -0,0 +1,81 @@
package com.linke.thirdParty.domain.sms.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linke.thirdParty.domain.sms.entity.SysSendsmsNum;
import com.linke.thirdParty.domain.sms.repository.facade.SysSendsmsNumInterface;
import com.linke.thirdParty.domain.sms.repository.mapper.SysSendsmsNumMapper;
import com.linke.thirdParty.domain.sms.repository.po.SysSendsmsNumPo;
import com.linke.thirdParty.domain.sms.repository.todo.SysSendsmsNumDo;
import com.mhd.common.core.utils.bean.BeanUtils;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @description 发送短信记录表
* @author xiaohan
* @date 2023-03-29
*/
@Service
public class SysSendsmsNumServiceImpl extends ServiceImpl<SysSendsmsNumMapper,SysSendsmsNum> implements SysSendsmsNumInterface {
@Resource
private SysSendsmsNumMapper sysSendsmsNumMapper;
@Override
public List<SysSendsmsNumPo> queryList(SysSendsmsNumDo sysSendsmsNumDo) {
return sysSendsmsNumMapper.queryList(sysSendsmsNumDo);
}
@Override
public Object save(SysSendsmsNumDo sysSendsmsNumDo) {
SysSendsmsNum sysSendsmsNum = new SysSendsmsNum();
BeanUtils.copyProperties(sysSendsmsNumDo,sysSendsmsNum);
sysSendsmsNum.setDelFlag(1);
sysSendsmsNum.setCreateTime(new Date());
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
sysSendsmsNum.setCreateBy(loginUser.getUserPo().getUserId());
}else {
sysSendsmsNum.setCreateBy(1l);
}
boolean save = this.save(sysSendsmsNum);
return save;
}
@Override
public Object delete(Long[] ids) {
List<SysSendsmsNum> list = new ArrayList<>();
for (int i = 0; i < ids.length; i++) {
SysSendsmsNum sysSendsmsNum = new SysSendsmsNum();
sysSendsmsNum.setDelFlag(2);
sysSendsmsNum.setUserId(ids[i]);
list.add(sysSendsmsNum);
this.updateBatchById(list);
}
return ids.length;
}
@Override
public Object update(SysSendsmsNumDo sysSendsmsNumDo) {
SysSendsmsNum sysSendsmsNum = new SysSendsmsNum();
BeanUtils.copyProperties(sysSendsmsNumDo,sysSendsmsNum);
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
sysSendsmsNum.setUpdateBy(loginUser.getUserPo().getUserId());
}else {
sysSendsmsNum.setUpdateBy(1l);
}
sysSendsmsNum.setUpdateTime(new Date());
boolean b = this.updateById(sysSendsmsNum);
return b;
}
}
@@ -0,0 +1,43 @@
package com.linke.thirdParty.domain.sms.repository.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class SysSendsmsNumPo extends BaseVOEntity {
/**
* 短信id
*/
@ApiModelProperty("短信id")
@TableId(type = IdType.AUTO)
private Long sysSendsmsNumId;
/**
* 用户表id
*/
@ApiModelProperty("用户表id")
private Long userId;
/**
* 手机号
*/
@ApiModelProperty("手机号")
private String phone;
/**
* ip地址
*/
@ApiModelProperty("ip地址")
private String ip;
/**
* 验证码
*/
@ApiModelProperty("验证码")
private String captcha;
}
@@ -0,0 +1,45 @@
package com.linke.thirdParty.domain.sms.repository.todo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class SysSendsmsNumDo extends BaseVOEntity {
private static final long serialVersionUID = 1L;
/**
* 短信id
*/
@ApiModelProperty("短信id")
@TableId(type = IdType.AUTO)
private Long sysSendsmsNumId;
/**
* 用户表id
*/
@ApiModelProperty("用户表id")
private Long userId;
/**
* 手机号
*/
@ApiModelProperty("手机号")
private String phone;
/**
* ip地址
*/
@ApiModelProperty("ip地址")
private String ip;
/**
* 验证码
*/
@ApiModelProperty("验证码")
private String captcha;
}
@@ -0,0 +1,41 @@
package com.linke.thirdParty.domain.sms.service;
import com.linke.thirdParty.domain.sms.repository.facade.SysSendsmsNumInterface;
import com.linke.thirdParty.domain.sms.repository.po.SysSendsmsNumPo;
import com.linke.thirdParty.domain.sms.repository.todo.SysSendsmsNumDo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @description 发送短信记录表
* @author xiaohan
* @date 2023-03-29
*/
@Service
public class SysSendsmsNumDomainService{
@Resource
private SysSendsmsNumInterface sysSendsmsNumInterface;
public List<SysSendsmsNumPo> queryList(SysSendsmsNumDo sysSendsmsNumDo) {
return sysSendsmsNumInterface.queryList(sysSendsmsNumDo);
}
public Object save(SysSendsmsNumDo sysSendsmsNumDo) {
return sysSendsmsNumInterface.save(sysSendsmsNumDo);
}
public Object delete(Long[] ids) {
return sysSendsmsNumInterface.delete(ids);
}
public Object update(SysSendsmsNumDo sysSendsmsNumDo) {
return sysSendsmsNumInterface.update(sysSendsmsNumDo);
}
}
@@ -0,0 +1,42 @@
package com.linke.thirdParty.domain.thridCall.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 三方回调对象 thrid_call
*
* @author gen
* @date 2024-04-28
*/
@Data
public class ThridCall extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("三方回调id")
@TableId(type = IdType.AUTO)
private Long thridCallId;
@ApiModelProperty("回调类型:1-支付宝支付回调,2-支付宝转账,3-其他")
@Excel(name = "回调类型:1-支付宝支付回调,2-支付宝转账,3-其他")
private Long callType;
@ApiModelProperty("回调方法")
@Excel(name = "回调方法")
private String callMethod;
@ApiModelProperty("回调参数")
@Excel(name = "回调参数")
private String callParam;
}
@@ -0,0 +1,43 @@
package com.linke.thirdParty.domain.thridCall.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linke.thirdParty.domain.thridCall.entity.ThridCall;
import com.linke.thirdParty.domain.thridCall.repository.po.ThridCallPO;
import com.linke.thirdParty.domain.thridCall.repository.todo.ThridCallDO;
import java.util.List;
/**
* 三方回调Service接口
*
* @author gen
* @date 2024-04-28
*/
public interface IThridCallService extends IService<ThridCall>
{
/**
* 分页查询三方回调列表
*/
public List<ThridCallPO> queryList(ThridCallDO thridCallDO);
/**
* 新增三方回调
*/
public Boolean insert(ThridCallDO thridCallDO);
/**
* 修改三方回调
*/
public Boolean update(ThridCallDO thridCallDO);
/**
* 批量删除三方回调
*/
public Boolean delete(Long[] thridCallIds);
/**
* 查询三方回调
*/
public ThridCallPO getInfo(Long thridCallId);
}
@@ -0,0 +1,22 @@
package com.linke.thirdParty.domain.thridCall.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linke.thirdParty.domain.thridCall.entity.ThridCall;
import com.linke.thirdParty.domain.thridCall.repository.po.ThridCallPO;
import com.linke.thirdParty.domain.thridCall.repository.todo.ThridCallDO;
import org.apache.ibatis.annotations.Param;
/**
* 三方回调Mapper接口
*
* @author gen
* @date 2024-04-28
*/
public interface ThridCallMapper extends BaseMapper<ThridCall>
{
/**
* 查询三方回调列表
*/
public List<ThridCallPO> queryList(ThridCallDO thridCallDO);
}
@@ -0,0 +1,81 @@
package com.linke.thirdParty.domain.thridCall.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linke.thirdParty.domain.thridCall.entity.ThridCall;
import com.linke.thirdParty.domain.thridCall.repository.facade.IThridCallService;
import com.linke.thirdParty.domain.thridCall.repository.mapper.ThridCallMapper;
import com.linke.thirdParty.domain.thridCall.repository.po.ThridCallPO;
import com.linke.thirdParty.domain.thridCall.repository.todo.ThridCallDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 三方回调Service业务层处理
*
* @author gen
* @date 2024-04-28
*/
@Service
public class ThridCallImpl extends ServiceImpl<ThridCallMapper, ThridCall> implements IThridCallService{
@Autowired
private ThridCallMapper thridCallMapper;
/**
* 查询三方回调列表
*/
@Override
public List<ThridCallPO> queryList(ThridCallDO thridCallDO)
{
return thridCallMapper.queryList(thridCallDO);
}
/**
* 新增三方回调
*/
@Override
public Boolean insert(ThridCallDO thridCallDO) {
ThridCall thridCall = new ThridCall();
BeanUtils.copyProperties(thridCallDO,thridCall);
return this.save(thridCall);
}
/**
* 修改三方回调
*/
@Override
public Boolean update(ThridCallDO thridCallDO) {
ThridCall thridCall = new ThridCall();
BeanUtils.copyProperties(thridCallDO,thridCall);
return this.updateById(thridCall);
}
/**
* 批量删除三方回调
*/
@Override
public Boolean delete(Long[] thridCallIds ) {
List<ThridCall> list = new ArrayList<>();
for (Long id : thridCallIds) {
ThridCall thridCall = new ThridCall();
thridCall.setThridCallId(id);
thridCall.setDelFlag(2);
list.add(thridCall);
}
return this.updateBatchById(list);
}
/**
* 修改三方回调
*/
@Override
public ThridCallPO getInfo(Long thridCallId) {
ThridCall thridCall = this.getById(thridCallId);
ThridCallPO thridCallPO = new ThridCallPO();
BeanUtils.copyProperties(thridCall,thridCallPO);
return thridCallPO;
}
}
@@ -0,0 +1,42 @@
package com.linke.thirdParty.domain.thridCall.repository.po;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import com.mhd.common.core.web.domain.BaseVOEntity;
/**
* 三方回调对象 thrid_call
*
* @author gen
* @date 2024-04-28
*/
@Data
@ApiModel(value = "三方回调对象", description = "三方回调响应对象")
public class ThridCallPO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("三方回调id")
private Long thridCallId;
@ApiModelProperty("回调类型:1-支付宝支付回调,2-支付宝转账,3-其他")
@Excel(name = "回调类型:1-支付宝支付回调,2-支付宝转账,3-其他")
private Long callType;
@ApiModelProperty("回调方法")
@Excel(name = "回调方法")
private String callMethod;
@ApiModelProperty("回调参数")
@Excel(name = "回调参数")
private String callParam;
}
@@ -0,0 +1,45 @@
package com.linke.thirdParty.domain.thridCall.repository.todo;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
/**
* 三方回调对象 thrid_call
*
* @author gen
* @date 2024-04-28
*/
@Data
public class ThridCallDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("三方回调id")
private Long thridCallId;
@ApiModelProperty("回调类型:1-支付宝支付回调,2-支付宝转账,3-其他")
@Excel(name = "回调类型:1-支付宝支付回调,2-支付宝转账,3-其他")
private Long callType;
@ApiModelProperty("回调方法")
@Excel(name = "回调方法")
private String callMethod;
@ApiModelProperty("回调参数")
@Excel(name = "回调参数")
private String callParam;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
}
@@ -0,0 +1,64 @@
package com.linke.thirdParty.domain.thridCall.service;
import com.linke.thirdParty.domain.thridCall.repository.facade.IThridCallService;
import com.linke.thirdParty.domain.thridCall.repository.po.ThridCallPO;
import com.linke.thirdParty.domain.thridCall.repository.todo.ThridCallDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 三方回调
*
* @author gen
* @date 2024-04-28
*/
@Service
@Slf4j
public class ThridCallDomainService {
@Autowired
private IThridCallService thridCallService;
/**
* 分页查询三方回调列表
*/
public List<ThridCallPO> queryList(ThridCallDO thridCallDO) {
return thridCallService.queryList(thridCallDO);
}
/**
* 新增三方回调
*/
public Boolean insert(ThridCallDO thridCallDO) {
return thridCallService.insert(thridCallDO);
}
/**
* 修改三方回调
*/
public Boolean update(ThridCallDO thridCallDO) {
return thridCallService.update(thridCallDO);
}
/**
* 批量删除三方回调
*/
public Boolean delete(Long[] thridCallIds) {
return thridCallService.delete(thridCallIds);
}
/**
* 获取三方回调详细信息
*/
public ThridCallPO getInfo(Long thridCallId)
{
return thridCallService.getInfo(thridCallId);
}
}
@@ -0,0 +1,96 @@
package com.linke.thirdParty.domain.tuanyou.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Description: 司机团油油卡管理表
* @Author: Alex
* @Date: 2022-06-06 15:10:20
* @Version: V1.0
*/
@Data
@TableName("tms_driver_oil")
public class TmsDriverOil implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ID_WORKER_STR)
private String id;
/**
* 团油油卡信息
*/
@ApiModelProperty(value = "团油油卡信息")
@Excel(name = "团油油卡信息", width = 15)
private String oilInfo;
@ApiModelProperty(value = "司机DriverID")
private String driverId;
@ApiModelProperty(value = "油卡编号")
private String oilCardNo;
@ApiModelProperty(value = "用户手机号")
private String userPhone;
/**
* 团油油卡余额
*/
@ApiModelProperty(value = "团油油卡余额")
@Excel(name = "团油油卡余额", width = 15)
private BigDecimal oilMonery;
/**
* 开卡状态:0-未开卡,1-成功,2-失败
*/
@ApiModelProperty(value = "开卡状态:0-未开卡,1-成功,2-失败")
@Excel(name = "开卡状态:0-未开卡,1-成功,2-失败", width = 15)
private Integer oilStatic;
/**
* 1:显示 0:不显示
*/
@ApiModelProperty(value = "1:显示 0:不显示")
@Excel(name = "1:显示 0:不显示", width = 15)
private Integer status;
/**
* 0:不删除 1:删除
*/
@ApiModelProperty(value = "0:不删除 1:删除")
@Excel(name = "0:不删除 1:删除", width = 15)
private Integer isDeleted;
/**
* 创建日期
*/
@ApiModelProperty(value = "创建日期")
@Excel(name = "创建日期", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
* 创建人
*/
@ApiModelProperty(value = "创建人")
@Excel(name = "创建人", width = 15)
private String createBy;
/**
* 更新人
*/
@ApiModelProperty(value = "更新人")
@Excel(name = "更新人", width = 15)
private String updateBy;
/**
* 更新日期
*/
@ApiModelProperty(value = "更新日期")
@Excel(name = "更新日期", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
}
@@ -0,0 +1,100 @@
package com.linke.thirdParty.domain.tuanyou.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @Description: 团油日志表
* @Author: jeecg-boot
* @Date: 2023-02-07
* @Version: V1.0
*/
@Data
@TableName("tms_tuanyou_log")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "tms_tuanyou_log对象", description = "团油日志表")
public class TmsTuanyouLog {
/**
* id
*/
@TableId(type = IdType.ID_WORKER_STR)
@ApiModelProperty(value = "id")
private String id;
/**
* 创建人
*/
@Excel(name = "创建人", width = 15)
@ApiModelProperty(value = "创建人")
private String createBy;
/**
* 创建日期
*/
@Excel(name = "创建日期", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private Date createTime;
/**
* 更新人
*/
@Excel(name = "更新人", width = 15)
@ApiModelProperty(value = "更新人")
private String updateBy;
/**
* 更新日期
*/
@Excel(name = "更新日期", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private Date updateTime;
/**
* 所属部门
*/
@Excel(name = "所属部门", width = 15)
@ApiModelProperty(value = "所属部门")
private String sysOrgCode;
/**
* 请求方法
*/
@Excel(name = "请求方法", width = 15)
@ApiModelProperty(value = "请求方法")
private String method;
/**
* 数据源id
*/
@Excel(name = "数据源id", width = 15)
@ApiModelProperty(value = "数据源id")
private String orderId;
/**
* 请求报文
*/
@Excel(name = "请求报文", width = 15)
@ApiModelProperty(value = "请求报文")
private String requestBody;
/**
* 响应报文
*/
@Excel(name = "响应报文", width = 15)
@ApiModelProperty(value = "响应报文")
private Object responseBody;
/**
* 删除标识
*/
@Excel(name = "删除标识", width = 15)
@ApiModelProperty(value = "删除标识")
private Integer isDelete;
}
@@ -0,0 +1,9 @@
package com.linke.thirdParty.domain.tuanyou.facade;
import com.linke.thirdParty.interfaces.vo.tuanyou.TmsDriverOilVO;
public interface INewLinkService {
public TmsDriverOilVO queryOilByDriverId(String id);
}
@@ -0,0 +1,55 @@
package com.linke.thirdParty.domain.tuanyou.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.linke.thirdParty.domain.tuanyou.entity.TmsDriverOil;
import com.linke.thirdParty.interfaces.dto.tuanyou.TmsDriverOilDTO;
import com.linke.thirdParty.interfaces.vo.tuanyou.TmsDriverOilVO;
import com.linke.thirdParty.interfaces.vo.tuanyou.TmsDriverVO;
import com.linke.thirdParty.interfaces.vo.tuanyou.TmsExpenseRecordVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* @Description: 司机团油油卡管理表
* @Author: Alex
* @Date: 2022-06-06 15:10:20
* @Version: V1.0
*/
public interface TmsDriverOilMapper extends BaseMapper<TmsDriverOil> {
// /**
// * @功能:司机团油油卡管理表 分页查询
// * @param tmsDriverOilDTO
// * @Date: 2022-06-06 15:10:20
// * @return
// */
// public List<TmsDriverOilVO> queryList(Page<TmsDriverOilVO> page, @Param("tmsDriverOilDTO") TmsDriverOilDTO tmsDriverOilDTO);
//
// public List<TmsDriverVO> queryByIds(List<String> id);
//
// public List<TmsDriverVO> queryByIdsId(List<String> id);
//
// public TmsDriverOilVO queryOilById(@Param("id") String id);
//
// public TmsDriverVO queryById(@Param("id") String id);
//
// public TmsDriverVO queryByIdId(@Param("id") String id);
public TmsDriverOilVO queryOilByDriverId(@Param("id") String id);
// void insertOrderOil(@Param("tmsDriverOilDTO") TmsDriverOilDTO tmsDriverOilDTO);
//
// void updateQueryById(@Param("id") String id);
//
// void updateQueryByIdFalse(@Param("id") String id);
// TmsExpenseRecordVO orderTmsDriverOilRecord(@Param("id") String id);
//
// @Select("select * from tms_driver_oil where user_phone = #{phone} and oil_card_no = #{userId}")
// public TmsDriverOil queryByPhoneAndUserId(String phone,String userId);
}
@@ -0,0 +1,22 @@
package com.linke.thirdParty.domain.tuanyou.persistence;
import com.linke.thirdParty.domain.tuanyou.facade.INewLinkService;
import com.linke.thirdParty.domain.tuanyou.mapper.TmsDriverOilMapper;
import com.linke.thirdParty.interfaces.vo.tuanyou.TmsDriverOilVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
@Slf4j
public class NewLinkServiceImpl implements INewLinkService {
@Resource
private TmsDriverOilMapper tmsDriverOilMapper;
@Override
public TmsDriverOilVO queryOilByDriverId(String id) {
return tmsDriverOilMapper.queryOilByDriverId(id);
}
}
@@ -0,0 +1,19 @@
package com.linke.thirdParty.domain.tuanyou.service;
import com.linke.thirdParty.domain.tuanyou.facade.INewLinkService;
import com.linke.thirdParty.interfaces.vo.tuanyou.TmsDriverOilVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class NewLinkDomainService {
@Autowired
private INewLinkService newLinkService;
public TmsDriverOilVO queryOilByDriverId(String driverId) {
return newLinkService.queryOilByDriverId(driverId);
}
}
@@ -0,0 +1,58 @@
package com.linke.thirdParty.domain.userAuthEsign.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* e签宝用户印章授权对象 user_auth_esign
*
* @author gen
* @date 2024-12-03
*/
@Data
public class UserAuthEsign extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("e签宝用户印章授权id")
@TableId(type = IdType.AUTO)
private Long userAuthEsignId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("用户id")
@Excel(name = "用户id")
private Long userId;
@ApiModelProperty("授权书签署url短链(有效期180天)")
@Excel(name = "授权书签署url短链", readConverterExp = "有=效期180天")
private String authorizationsignshorturl;
@ApiModelProperty("授权书签署url长链(永久有效)")
@Excel(name = "授权书签署url长链", readConverterExp = "永=久有效")
private String authorizationsignurl;
@ApiModelProperty("授权业务流程编号列表 JSON串")
@Excel(name = "授权业务流程编号列表 JSON串")
private String sealauthbizids;
}
@@ -0,0 +1,43 @@
package com.linke.thirdParty.domain.userAuthEsign.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linke.thirdParty.domain.userAuthEsign.entity.UserAuthEsign;
import com.linke.thirdParty.domain.userAuthEsign.repository.po.UserAuthEsignPO;
import com.linke.thirdParty.domain.userAuthEsign.repository.todo.UserAuthEsignDO;
import java.util.List;
/**
* e签宝用户印章授权Service接口
*
* @author gen
* @date 2024-12-03
*/
public interface IUserAuthEsignService extends IService<UserAuthEsign>
{
/**
* 分页查询e签宝用户印章授权列表
*/
public List<UserAuthEsignPO> queryList(UserAuthEsignDO userAuthEsignDO);
/**
* 新增e签宝用户印章授权
*/
public Boolean insert(UserAuthEsignDO userAuthEsignDO);
/**
* 修改e签宝用户印章授权
*/
public Boolean update(UserAuthEsignDO userAuthEsignDO);
/**
* 批量删除e签宝用户印章授权
*/
public Boolean delete(Long[] userAuthEsignIds);
/**
* 查询e签宝用户印章授权
*/
public UserAuthEsignPO getInfo(Long userAuthEsignId);
}
@@ -0,0 +1,22 @@
package com.linke.thirdParty.domain.userAuthEsign.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linke.thirdParty.domain.userAuthEsign.entity.UserAuthEsign;
import com.linke.thirdParty.domain.userAuthEsign.repository.po.UserAuthEsignPO;
import com.linke.thirdParty.domain.userAuthEsign.repository.todo.UserAuthEsignDO;
import org.apache.ibatis.annotations.Param;
/**
* e签宝用户印章授权Mapper接口
*
* @author gen
* @date 2024-12-03
*/
public interface UserAuthEsignMapper extends BaseMapper<UserAuthEsign>
{
/**
* 查询e签宝用户印章授权列表
*/
public List<UserAuthEsignPO> queryList(UserAuthEsignDO userAuthEsignDO);
}
@@ -0,0 +1,81 @@
package com.linke.thirdParty.domain.userAuthEsign.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linke.thirdParty.domain.userAuthEsign.entity.UserAuthEsign;
import com.linke.thirdParty.domain.userAuthEsign.repository.facade.IUserAuthEsignService;
import com.linke.thirdParty.domain.userAuthEsign.repository.mapper.UserAuthEsignMapper;
import com.linke.thirdParty.domain.userAuthEsign.repository.po.UserAuthEsignPO;
import com.linke.thirdParty.domain.userAuthEsign.repository.todo.UserAuthEsignDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* e签宝用户印章授权Service业务层处理
*
* @author gen
* @date 2024-12-03
*/
@Service
public class UserAuthEsignImpl extends ServiceImpl<UserAuthEsignMapper, UserAuthEsign> implements IUserAuthEsignService{
@Autowired
private UserAuthEsignMapper userAuthEsignMapper;
/**
* 查询e签宝用户印章授权列表
*/
@Override
public List<UserAuthEsignPO> queryList(UserAuthEsignDO userAuthEsignDO)
{
return userAuthEsignMapper.queryList(userAuthEsignDO);
}
/**
* 新增e签宝用户印章授权
*/
@Override
public Boolean insert(UserAuthEsignDO userAuthEsignDO) {
UserAuthEsign userAuthEsign = new UserAuthEsign();
BeanUtils.copyProperties(userAuthEsignDO,userAuthEsign);
return this.save(userAuthEsign);
}
/**
* 修改e签宝用户印章授权
*/
@Override
public Boolean update(UserAuthEsignDO userAuthEsignDO) {
UserAuthEsign userAuthEsign = new UserAuthEsign();
BeanUtils.copyProperties(userAuthEsignDO,userAuthEsign);
return this.updateById(userAuthEsign);
}
/**
* 批量删除e签宝用户印章授权
*/
@Override
public Boolean delete(Long[] userAuthEsignIds ) {
List<UserAuthEsign> list = new ArrayList<>();
for (Long id : userAuthEsignIds) {
UserAuthEsign userAuthEsign = new UserAuthEsign();
userAuthEsign.setUserAuthEsignId(id);
userAuthEsign.setDelFlag(2);
list.add(userAuthEsign);
}
return this.updateBatchById(list);
}
/**
* 修改e签宝用户印章授权
*/
@Override
public UserAuthEsignPO getInfo(Long userAuthEsignId) {
UserAuthEsign userAuthEsign = this.getById(userAuthEsignId);
UserAuthEsignPO userAuthEsignPO = new UserAuthEsignPO();
BeanUtils.copyProperties(userAuthEsign,userAuthEsignPO);
return userAuthEsignPO;
}
}
@@ -0,0 +1,58 @@
package com.linke.thirdParty.domain.userAuthEsign.repository.po;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import com.mhd.common.core.web.domain.BaseVOEntity;
/**
* e签宝用户印章授权对象 user_auth_esign
*
* @author gen
* @date 2024-12-03
*/
@Data
@ApiModel(value = "e签宝用户印章授权对象", description = "e签宝用户印章授权响应对象")
public class UserAuthEsignPO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("e签宝用户印章授权id")
private Long userAuthEsignId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("用户id")
@Excel(name = "用户id")
private Long userId;
@ApiModelProperty("授权书签署url短链(有效期180天)")
@Excel(name = "授权书签署url短链", readConverterExp = "有=效期180天")
private String authorizationsignshorturl;
@ApiModelProperty("授权书签署url长链(永久有效)")
@Excel(name = "授权书签署url长链", readConverterExp = "永=久有效")
private String authorizationsignurl;
@ApiModelProperty("授权业务流程编号列表 JSON串")
@Excel(name = "授权业务流程编号列表 JSON串")
private String sealauthbizids;
}
@@ -0,0 +1,61 @@
package com.linke.thirdParty.domain.userAuthEsign.repository.todo;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
/**
* e签宝用户印章授权对象 user_auth_esign
*
* @author gen
* @date 2024-12-03
*/
@Data
public class UserAuthEsignDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("e签宝用户印章授权id")
private Long userAuthEsignId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("用户id")
@Excel(name = "用户id")
private Long userId;
@ApiModelProperty("授权书签署url短链(有效期180天)")
@Excel(name = "授权书签署url短链", readConverterExp = "有=效期180天")
private String authorizationsignshorturl;
@ApiModelProperty("授权书签署url长链(永久有效)")
@Excel(name = "授权书签署url长链", readConverterExp = "永=久有效")
private String authorizationsignurl;
@ApiModelProperty("授权业务流程编号列表 JSON串")
@Excel(name = "授权业务流程编号列表 JSON串")
private String sealauthbizids;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
}
@@ -0,0 +1,64 @@
package com.linke.thirdParty.domain.userAuthEsign.service;
import com.linke.thirdParty.domain.userAuthEsign.repository.facade.IUserAuthEsignService;
import com.linke.thirdParty.domain.userAuthEsign.repository.po.UserAuthEsignPO;
import com.linke.thirdParty.domain.userAuthEsign.repository.todo.UserAuthEsignDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* e签宝用户印章授权
*
* @author gen
* @date 2024-12-03
*/
@Service
@Slf4j
public class UserAuthEsignDomainService {
@Autowired
private IUserAuthEsignService userAuthEsignService;
/**
* 分页查询e签宝用户印章授权列表
*/
public List<UserAuthEsignPO> queryList(UserAuthEsignDO userAuthEsignDO) {
return userAuthEsignService.queryList(userAuthEsignDO);
}
/**
* 新增e签宝用户印章授权
*/
public Boolean insert(UserAuthEsignDO userAuthEsignDO) {
return userAuthEsignService.insert(userAuthEsignDO);
}
/**
* 修改e签宝用户印章授权
*/
public Boolean update(UserAuthEsignDO userAuthEsignDO) {
return userAuthEsignService.update(userAuthEsignDO);
}
/**
* 批量删除e签宝用户印章授权
*/
public Boolean delete(Long[] userAuthEsignIds) {
return userAuthEsignService.delete(userAuthEsignIds);
}
/**
* 获取e签宝用户印章授权详细信息
*/
public UserAuthEsignPO getInfo(Long userAuthEsignId)
{
return userAuthEsignService.getInfo(userAuthEsignId);
}
}
@@ -0,0 +1,13 @@
package com.linke.thirdParty.infrastructure.config;
public class ESTConfig {
// 应用ID
public static final String EsignAppId = "7439029318";
// 应用密钥
public static final String EsignAppSecret = "bf5808f9f15f3ea34577a901fb643bd5";
// e签宝接口调用域名(模拟环境)
public static final String EsignHost = "https://smlopenapi.esign.cn";
// e签宝接口调用域名(正式环境)
// public static final String EsignHost = "https://openapi.esign.cn";
}
@@ -0,0 +1,24 @@
package com.linke.thirdParty.infrastructure.config;
/**
* esignSDK-core信息类
* @author 澄泓
* @date 2022/2/22 13:59
* @version
*/
public class EsignCoreSdkInfo {
private static final String SdkVersion="Esign-Sdk-Core1.0";
private static final String SupportedVersion="JDK1.7 MORE THAN";
private static final String Info="sdk-esign-api核心工具包,主要处理e签宝公有云产品接口调用时的签名计算以及网络请求,通过EsignHttpHelper.signAndBuildSignAndJsonHeader构造签名鉴权+json数据格式的请求头,通过HttpHelper.doCommHttp方法入参发起网络请求。让开发者无需关注具体的请求签名算法,专注于接口业务的json参数构造";
public static String getSdkVersion() {
return SdkVersion;
}
public static String getInfo() {
return Info;
}
public static String getSupportedVersion() {
return SupportedVersion;
}
}
@@ -0,0 +1,371 @@
/*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.linke.thirdParty.infrastructure.config;
import com.mhd.common.core.exception.EsignDemoException;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.message.BasicNameValuePair;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.Collator;
import java.text.MessageFormat;
import java.util.*;
/**
* @description 请求数据通用处理类
* @author 澄泓
* @date 2020年10月22日 下午14:25:31
* @since JDK1.7
*/
public class EsignEncryption {
/**
* 不允许外部创建实例
*/
private EsignEncryption(){}
/**
* 拼接待签名字符串
* @param httpMethod
* @param url
* @return
*/
public static String appendSignDataString(String httpMethod, String contentMd5,String accept,String contentType,String headers,String date, String url) throws EsignDemoException {
StringBuffer sb = new StringBuffer();
sb.append(httpMethod).append("\n").append(accept).append("\n").append(contentMd5).append("\n")
.append(contentType).append("\n");
if ("".equals(date) || date == null) {
sb.append("\n");
} else {
sb.append(date).append("\n");
}
if ("".equals(headers) || headers == null) {
sb.append(url);
} else {
sb.append(headers).append("\n").append(url);
}
return new String(sb);
}
/***
* Content-MD5的计算方法
* @param str 待计算的消息
* @return MD5计算后摘要值的Base64编码(ContentMD5)
* @throws EsignDemoException 加密过程中的异常信息
*/
public static String doContentMD5(String str) throws EsignDemoException {
byte[] md5Bytes = null;
MessageDigest md5 = null;
String contentMD5 = null;
try {
md5 = MessageDigest.getInstance("MD5");
// 计算md5函数
md5.update(str.getBytes("UTF-8"));
// 获取文件MD5的二进制数组(128位)
md5Bytes = md5.digest();
// 把MD5摘要后的二进制数组md5Bytes使用Base64进行编码(而不是对32位的16进制字符串进行编码)
contentMD5 = Base64.encodeBase64String(md5Bytes);
} catch (NoSuchAlgorithmException e) {
EsignDemoException ex = new EsignDemoException("不支持此算法",e);
ex.initCause(e);
throw ex;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return contentMD5;
}
/***
* 计算请求签名值-HmacSHA256摘要
* @param message 待签名字符串
* @param secret 密钥APP KEY
* @return reqSignature HmacSHA256计算后摘要值的Base64编码
* @throws EsignDemoException 加密过程中的异常信息
*/
public static String doSignatureBase64(String message, String secret) throws EsignDemoException {
String algorithm = "HmacSHA256";
Mac hmacSha256;
String digestBase64 = null;
try {
hmacSha256 = Mac.getInstance(algorithm);
byte[] keyBytes = secret.getBytes("UTF-8");
byte[] messageBytes = message.getBytes("UTF-8");
hmacSha256.init(new SecretKeySpec(keyBytes, 0, keyBytes.length, algorithm));
// 使用HmacSHA256对二进制数据消息Bytes计算摘要
byte[] digestBytes = hmacSha256.doFinal(messageBytes);
// 把摘要后的结果digestBytes使用Base64进行编码
digestBase64 = Base64.encodeBase64String(digestBytes);
} catch (NoSuchAlgorithmException e) {
EsignDemoException ex = new EsignDemoException("不支持此算法",e);
ex.initCause(e);
throw ex;
} catch (InvalidKeyException e) {
EsignDemoException ex = new EsignDemoException("无效的密钥规范",e);
ex.initCause(e);
throw ex;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return digestBase64;
}
/**
* 获取时间戳
* @return
*/
public static String timeStamp() {
long timeStamp = System.currentTimeMillis();
return String.valueOf(timeStamp);
}
/**
* byte字节数组转换成字符串
* @param b
* @return
*/
public static String byteArrayToHexString(byte[] b) {
StringBuilder hs = new StringBuilder();
String stmp;
for (int n = 0; b != null && n < b.length; n++) {
stmp = Integer.toHexString(b[n] & 0XFF);
if (stmp.length() == 1)
hs.append('0');
hs.append(stmp);
}
return hs.toString().toLowerCase();
}
/**
* hash散列加密算法
* @return
*/
public static String Hmac_SHA256(String message,String key) throws EsignDemoException {
byte[] rawHmac=null;
try {
SecretKeySpec sk = new SecretKeySpec(key.getBytes(), "HmacSHA256");
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(sk);
rawHmac = mac.doFinal(message.getBytes());
}catch (InvalidKeyException e){
EsignDemoException ex = new EsignDemoException("无效的密钥规范",e);
ex.initCause(e);
throw ex;
} catch (NoSuchAlgorithmException e) {
EsignDemoException ex = new EsignDemoException("不支持此算法",e);
ex.initCause(e);
throw ex;
}catch (Exception e){
EsignDemoException ex = new EsignDemoException("hash散列加密算法报错",e);
ex.initCause(e);
throw ex;
}finally {
return byteArrayToHexString(rawHmac);
}
}
/**
* MD5加密32位
*/
public static String MD5Digest(String text) throws EsignDemoException {
byte[] digest=null;
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(text.getBytes());
digest = md5.digest();
}catch (NoSuchAlgorithmException e){
EsignDemoException ex = new EsignDemoException("不支持此算法",e);
ex.initCause(e);
throw ex;
}finally {
return byteArrayToHexString(digest);
}
}
public static void formDataSort(List<BasicNameValuePair> param) {
Collections.sort(param, new Comparator<BasicNameValuePair>() {
@Override
public int compare(BasicNameValuePair o1, BasicNameValuePair o2) {
Comparator<Object> com = Collator.getInstance(Locale.CHINA);
return com.compare(o1.getName(), o2.getName());
}
});
}
/***
* 字符串是否为空(含空格校验)
* @param str
* @return
*/
public static boolean isBlank(String str) {
if (null == str || 0 == str.length()) {
return true;
}
int strLen = str.length();
for (int i = 0; i < strLen; i++) {
if (!Character.isWhitespace(str.charAt(i))) {
return false;
}
}
return true;
}
/***
* 对请求URL中的Query参数按照字段名的 ASCII 码从小到大排序(字典排序)
*
* @param apiUrl
* @return 排序后的API接口地址
* @throws Exception
*/
public static String sortApiUrl(String apiUrl) throws EsignDemoException {
if (!apiUrl.contains("?")) {
return apiUrl;
}
int queryIndex = apiUrl.indexOf("?");
String apiUrlPath =apiUrl.substring(0,queryIndex+1);
String apiUrlQuery = apiUrl.substring(queryIndex+1);
//apiUrlQuery为空时返回
if(isBlank(apiUrlQuery)){
return apiUrl.substring(0,apiUrl.length()-1);
}
// 请求URL中Query参数转成Map
Map<Object, Object> queryParamsMap = new HashMap<Object, Object>();
String[] params = apiUrlQuery.split("&");
for (String str : params) {
int index = str.indexOf("=");
String key = str.substring(0, index);
String value = str.substring(index + 1);
if (queryParamsMap.containsKey(key)) {
String msg = MessageFormat.format("请求URL中的Query参数的{0}重复", key);
throw new EsignDemoException(msg);
}
queryParamsMap.put(key, value);
}
ArrayList<String> queryMapKeys = new ArrayList<String>();
for (Map.Entry<Object, Object> entry : queryParamsMap.entrySet()) {
queryMapKeys.add((String) entry.getKey());
}
// 按照字段名的 ASCII 码从小到大排序(字典排序)
Collections.sort(queryMapKeys, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return (o1.compareToIgnoreCase(o2) == 0 ? -o1.compareTo(o2) : o1.compareToIgnoreCase(o2));
}
});
StringBuffer queryString = new StringBuffer();
// 构造Query参数键值对值对的格式
for (int i = 0; i < queryMapKeys.size(); i++) {
String key = queryMapKeys.get(i);
String value = (String) queryParamsMap.get(key);
queryString.append(key);
queryString.append("=");
queryString.append(value);
queryString.append("&");
}
if (queryString.length() > 0) {
queryString = queryString.deleteCharAt(queryString.length() - 1);
}
// Query参数排序后的接口请求地址
StringBuffer sortApiUrl = new StringBuffer();
sortApiUrl.append(apiUrlPath);
sortApiUrl.append(queryString.toString());
return sortApiUrl.toString();
}
/**
*获取query
* @param apiUrl
* @return
* @throws EsignDemoException
*/
public static ArrayList<BasicNameValuePair> getQuery(String apiUrl) throws EsignDemoException {
ArrayList<BasicNameValuePair> BasicNameValuePairList = new ArrayList<>();
if (!apiUrl.contains("?")) {
return BasicNameValuePairList;
}
int queryIndex = apiUrl.indexOf("\\?");
String apiUrlQuery = apiUrl.substring(queryIndex,apiUrl.length());
// 请求URL中Query参数转成Map
Map<Object, Object> queryParamsMap = new HashMap<Object, Object>();
String[] params = apiUrlQuery.split("&");
for (String str : params) {
int index = str.indexOf("=");
String key = str.substring(0, index);
String value = str.substring(index + 1);
if (queryParamsMap.containsKey(key)) {
String msg = MessageFormat.format("请求URL中的Query参数的{0}重复", key);
throw new EsignDemoException(msg);
}
BasicNameValuePairList.add(new BasicNameValuePair(key,value));
queryParamsMap.put(key, value);
}
return BasicNameValuePairList;
}
/**
*
*/
public static boolean callBackCheck(String timestamp,String requestQuery,String body,String key,String signature){
String algorithm="HmacSHA256";
String encoding="UTF-8";
Mac mac = null;
try {
String data = timestamp + requestQuery + body;
mac = Mac.getInstance(algorithm);
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(encoding), algorithm);
mac.init(secretKey);
mac.update(data.getBytes(encoding));
} catch (NoSuchAlgorithmException | InvalidKeyException | UnsupportedEncodingException e) {
e.printStackTrace();
System.out.println("获取Signature签名信息异常:" + e.getMessage());
return false;
}
return byte2hex(mac.doFinal()).equalsIgnoreCase(signature);
}
/***
* 将byte[]转成16进制字符串
*
* @param data
*
* @return 16进制字符串
*/
public static String byte2hex(byte[] data) {
StringBuilder hash = new StringBuilder();
String stmp;
for (int n = 0; data != null && n < data.length; n++) {
stmp = Integer.toHexString(data[n] & 0XFF);
if (stmp.length() == 1)
hash.append('0');
hash.append(stmp);
}
return hash.toString();
}
}
@@ -0,0 +1,483 @@
/*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.linke.thirdParty.infrastructure.config;
import com.linke.thirdParty.infrastructure.dict.EsignRequestType;
import com.mhd.common.core.domain.po.EsignHttpResponse;
import com.mhd.common.core.exception.EsignDemoException;
import org.apache.http.*;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.*;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.UnknownHostException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @description Http请求 辅助类
* @author 澄泓
* @since JDK1.7
*/
public class EsignHttpCfgHelper {
private static Logger LOGGER = LoggerFactory.getLogger(EsignHttpCfgHelper.class);
/**
* 超时时间,默认15000毫秒
*/
private static int MAX_TIMEOUT = 15000;
/**
* 请求池最大连接数,默认100个
*/
private static int MAX_TOTAL=100;
/**
* 单域名最大的连接数,默认50个
*/
private static int ROUTE_MAX_TOTAL=50;
/**
* 请求失败重试次数,默认3次
*/
private static int MAX_RETRY = 3;
/**
* 是否需要域名校验,默认不需要校验
*/
private static boolean SSL_VERIFY=false;
/**
* 正向代理IP
*/
private static String PROXY_IP;
/**
* 正向代理端口,默认8888
*/
private static int PROXY_PORT=8888;
/**
* 代理协议,默认http
*/
private static String PROXY_AGREEMENT="http";
/**
* 是否开启代理,默认false
*/
private static boolean OPEN_PROXY=false;
/**
* 代理服务器用户名
*/
private static String PROXY_USERNAME="";
/**
* 代理服务器密码
*/
private static String PROXY_PASSWORD="";
private static PoolingHttpClientConnectionManager connMgr; //连接池
private static HttpRequestRetryHandler retryHandler; //重试机制
private static CloseableHttpClient httpClient=null;
public static int getMaxTimeout() {
return MAX_TIMEOUT;
}
public static void setMaxTimeout(int maxTimeout) {
MAX_TIMEOUT = maxTimeout;
}
public static int getMaxTotal() {
return MAX_TOTAL;
}
public static void setMaxTotal(int maxTotal) {
MAX_TOTAL = maxTotal;
}
public static int getRouteMaxTotal() {
return ROUTE_MAX_TOTAL;
}
public static void setRouteMaxTotal(int routeMaxTotal) {
ROUTE_MAX_TOTAL = routeMaxTotal;
}
public static int getMaxRetry() {
return MAX_RETRY;
}
public static void setMaxRetry(int maxRetry) {
MAX_RETRY = maxRetry;
}
public static boolean isSslVerify() {
return SSL_VERIFY;
}
public static void setSslVerify(boolean sslVerify) {
SSL_VERIFY = sslVerify;
}
public static String getProxyIp() {
return PROXY_IP;
}
public static void setProxyIp(String proxyIp) {
PROXY_IP = proxyIp;
}
public static int getProxyPort() {
return PROXY_PORT;
}
public static void setProxyPort(int proxyPort) {
PROXY_PORT = proxyPort;
}
public static String getProxyAgreement() {
return PROXY_AGREEMENT;
}
public static void setProxyAgreement(String proxyAgreement) {
PROXY_AGREEMENT = proxyAgreement;
}
public static boolean getOpenProxy() {
return OPEN_PROXY;
}
public static void setOpenProxy(boolean openProxy) {
OPEN_PROXY = openProxy;
}
public static String getProxyUsername() {
return PROXY_USERNAME;
}
public static void setProxyUserame(String proxyUsername) {
PROXY_USERNAME = proxyUsername;
}
public static String getProxyPassword() {
return PROXY_PASSWORD;
}
public static void setProxyPassword(String proxyPassword) {
PROXY_PASSWORD = proxyPassword;
}
/**
* 不允许外部创建实例
*/
private EsignHttpCfgHelper() {
}
//------------------------------公有方法start--------------------------------------------
/**
* @description 发起HTTP / HTTPS 请求
*
* @param reqType
* {@link EsignRequestType} 请求类型 GET、 POST 、 DELETE 、 PUT
* @param httpUrl
* {@link String} 请求目标地址
* @param headers
* {@link Map} 请求头
* @param param
* {@link Object} 参数
* @return
* @throws EsignDemoException
* @author 澄泓
*/
public static EsignHttpResponse sendHttp(EsignRequestType reqType, String httpUrl, Map<String, String> headers, Object param, boolean debug)
throws EsignDemoException {
HttpRequestBase reqBase=null;
if(httpUrl.startsWith("http")){
reqBase=reqType.getHttpType(httpUrl);
}else{
throw new EsignDemoException("请求url地址格式错误");
}
if(debug){
LOGGER.info("请求头:{}",headers+"\n");
LOGGER.info("请求参数\n{}", param+"\n");
LOGGER.info("请求地址\n:{}\n请求方式\n:{}",reqBase.getURI(),reqType+"\n");
}
//请求方法不是GET或者DELETE时传入body体,否则不传入。
String[] methods = {"DELETE", "GET"};
if(param instanceof String&&Arrays.binarySearch(methods, reqType.name())<0){//POST或者PUT请求
((HttpEntityEnclosingRequest) reqBase).setEntity(
new StringEntity(String.valueOf(param), ContentType.create("application/json", "UTF-8")));
}
//参数时字节流数组
else if(param instanceof byte[]) {
reqBase=reqType.getHttpType(httpUrl);
byte[] paramBytes = (byte[])param;
((HttpEntityEnclosingRequest) reqBase).setEntity(new ByteArrayEntity(paramBytes));
}
//参数是form表单时
else if(param instanceof List){
((HttpEntityEnclosingRequest) reqBase).setEntity(new UrlEncodedFormEntity((Iterable<? extends NameValuePair>) param));
}
httpClient = getHttpClient();
config(reqBase);
//设置请求头
if(headers != null &&headers.size()>0) {
for(Map.Entry<String, String> entry :headers.entrySet()) {
reqBase.setHeader(entry.getKey(), entry.getValue());
}
}
//响应对象
CloseableHttpResponse res = null;
//响应内容
String resCtx = null;
int status;
EsignHttpResponse esignHttpResponse = new EsignHttpResponse();
try {
//执行请求
res = httpClient.execute(reqBase);
status=res.getStatusLine().getStatusCode();
//获取请求响应对象和响应entity
HttpEntity httpEntity = res.getEntity();
if(httpEntity != null) {
resCtx = EntityUtils.toString(httpEntity,"utf-8");
}
if(debug) {
LOGGER.info("响应\n{}", resCtx + "\n");
LOGGER.info("----------------------------end------------------------");
}
} catch (NoHttpResponseException e) {
throw new EsignDemoException("服务器丢失了",e);
} catch (SSLHandshakeException e){
String msg = MessageFormat.format("SSL握手异常", e);
EsignDemoException ex = new EsignDemoException(msg, e);
throw ex;
} catch (UnknownHostException e){
EsignDemoException ex = new EsignDemoException("服务器找不到", e);
ex.initCause(e);
throw ex;
} catch(ConnectTimeoutException e){
EsignDemoException ex = new EsignDemoException("连接超时", e);
ex.initCause(e);
throw ex;
} catch(SSLException e){
EsignDemoException ex = new EsignDemoException("SSL异常",e);
ex.initCause(e);
throw ex;
} catch (ClientProtocolException e) {
EsignDemoException ex = new EsignDemoException("请求头异常",e);
ex.initCause(e);
throw ex;
} catch (IOException e) {
EsignDemoException ex = new EsignDemoException("网络请求失败",e);
ex.initCause(e);
throw ex;
} finally {
if(res != null) {
try {
res.close();
} catch (IOException e) {
EsignDemoException ex = new EsignDemoException("--->>关闭请求响应失败",e);
ex.initCause(e);
throw ex;
}
}
}
esignHttpResponse.setStatus(status);
esignHttpResponse.setBody(resCtx);
return esignHttpResponse;
}
//------------------------------公有方法end----------------------------------------------
//------------------------------私有方法start--------------------------------------------
/**
* @description 请求头和超时时间配置
*
* @param httpReqBase
* @author 澄泓
*/
private static void config(HttpRequestBase httpReqBase) {
// 配置请求的超时设置
RequestConfig.Builder builder = RequestConfig.custom()
.setConnectionRequestTimeout(MAX_TIMEOUT)
.setConnectTimeout(MAX_TIMEOUT)
.setSocketTimeout(MAX_TIMEOUT);
if(OPEN_PROXY){
HttpHost proxy=new HttpHost(PROXY_IP,PROXY_PORT,PROXY_AGREEMENT);
builder.setProxy(proxy);
}
RequestConfig requestConfig = builder.build();
httpReqBase.setConfig(requestConfig);
}
/**
* @description 连接池配置
*
* @return
* @author 澄泓
*/
private static void cfgPoolMgr() throws EsignDemoException {
ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory();
LayeredConnectionSocketFactory sslsf = SSLConnectionSocketFactory.getSocketFactory();
if(!SSL_VERIFY){
sslsf=sslConnectionSocketFactory();
}
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", plainsf)
.register("https", sslsf)
.build();
//连接池管理器
connMgr = new PoolingHttpClientConnectionManager(registry);
//请求池最大连接数
connMgr.setMaxTotal(MAX_TOTAL);
//但域名最大的连接数
connMgr.setDefaultMaxPerRoute(ROUTE_MAX_TOTAL);
}
/**
* @description 设置重试机制
*
* @author 澄泓
*/
private static void cfgRetryHandler() {
retryHandler = new HttpRequestRetryHandler() {
@Override
public boolean retryRequest(IOException e, int excCount, HttpContext ctx) {
//超过最大重试次数,就放弃
if(excCount > MAX_RETRY) {
return false;
}
//服务器丢掉了链接,就重试
if(e instanceof NoHttpResponseException) {
return true;
}
//不重试SSL握手异常
if(e instanceof SSLHandshakeException) {
return false;
}
//中断
if(e instanceof InterruptedIOException) {
return false;
}
//目标服务器不可达
if(e instanceof UnknownHostException) {
return false;
}
//连接超时
//SSL异常
if(e instanceof SSLException) {
return false;
}
HttpClientContext clientCtx = HttpClientContext.adapt(ctx);
HttpRequest req = clientCtx.getRequest();
//如果是幂等请求,就再次尝试
if(!(req instanceof HttpEntityEnclosingRequest)) {
return true;
}
return false;
}
};
}
/**
* 忽略域名校验
*/
private static SSLConnectionSocketFactory sslConnectionSocketFactory() throws EsignDemoException {
try {
SSLContext ctx = SSLContext.getInstance("TLS"); // 创建一个上下文(此处指定的协议类型似乎不是重点)
X509TrustManager tm = new X509TrustManager() { // 创建一个跳过SSL证书的策略
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
}
};
ctx.init(null, new TrustManager[] { tm }, null); // 使用上面的策略初始化上下文
return new SSLConnectionSocketFactory(ctx, new String[] { "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2" }, null, NoopHostnameVerifier.INSTANCE);
}catch (Exception e){
EsignDemoException ex = new EsignDemoException("忽略域名校验失败",e);
ex.initCause(e);
throw ex;
}
}
/**
* @description 获取单例HttpClient
*
* @return
* @author 澄泓
*/
private static synchronized CloseableHttpClient getHttpClient() throws EsignDemoException {
if(httpClient==null) {
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(PROXY_IP,PROXY_PORT),new UsernamePasswordCredentials(PROXY_USERNAME, PROXY_PASSWORD));
cfgPoolMgr();
cfgRetryHandler();
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
httpClient = httpClientBuilder.setDefaultCredentialsProvider(credsProvider).setConnectionManager(connMgr).setRetryHandler(retryHandler).build();
}
return httpClient;
}
//------------------------------私有方法end----------------------------------------------
}
@@ -0,0 +1,173 @@
package com.linke.thirdParty.infrastructure.config;
import com.linke.thirdParty.infrastructure.dict.EsignHeaderConstant;
import com.linke.thirdParty.infrastructure.dict.EsignRequestType;
import com.mhd.common.core.domain.po.EsignHttpResponse;
import com.mhd.common.core.exception.EsignDemoException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
/**
* @description Http 请求 辅助类
* @author 澄泓
* @since JDK1.7
*/
public class EsignHttpHelper {
private static final Logger LOGGER = LoggerFactory.getLogger(EsignHttpHelper.class);
/**
* 不允许外部创建实例
*/
private EsignHttpHelper() {
}
/**
* @description 发送常规HTTP 请求
*
* @param reqType 请求方式
* @param url 请求路径
* @param paramStr 请求参数
* @return
* @throws EsignDemoException
* @author 澄泓
*/
public static EsignHttpResponse doCommHttp(String host, String url, EsignRequestType reqType, Object paramStr , Map<String,String> httpHeader, boolean debug) throws EsignDemoException {
return EsignHttpCfgHelper.sendHttp(reqType, host+url,httpHeader, paramStr, debug);
}
/**
* @description 发送文件流上传 HTTP 请求
*
* @param reqType 请求方式
* @param uploadUrl 请求路径
* @param param 请求参数
* @param fileContentMd5 文件fileContentMd5
* @param contentType 文件MIME类型
* @return
* @throws EsignDemoException
* @author 澄泓
*/
public static EsignHttpResponse doUploadHttp(String uploadUrl, EsignRequestType reqType, byte[] param, String fileContentMd5,
String contentType, boolean debug) throws EsignDemoException {
Map<String, String> uploadHeader = buildUploadHeader(fileContentMd5, contentType);
if(debug){
LOGGER.info("----------------------------start------------------------");
LOGGER.info("fileContentMd5:{}",fileContentMd5);
LOGGER.info("contentType:{}",contentType);
}
return EsignHttpCfgHelper.sendHttp(reqType,uploadUrl, uploadHeader, param,debug);
}
/**
* @description 构建一个签名鉴权+json数据的esign请求头
* @return
* @author 澄泓
*/
public static Map<String, String> buildSignAndJsonHeader(String projectId,String contentMD5,String accept,String contentType,String authMode) {
Map<String, String> header = new HashMap<>();
header.put("X-Tsign-Open-App-Id", projectId);
header.put("X-Tsign-Open-Version-Sdk",EsignCoreSdkInfo.getSdkVersion());
header.put("X-Tsign-Open-Ca-Timestamp", EsignEncryption.timeStamp());
header.put("Accept",accept);
header.put("Content-MD5",contentMD5);
header.put("Content-Type", contentType);
header.put("X-Tsign-Open-Auth-Mode", authMode);
return header;
}
/**
* 签名计算并且构建一个签名鉴权+json数据的esign请求头
* @param httpMethod
* * The name of a supported {@linkplain java.nio.charset.Charset
* * charset}
* @return
*/
public static Map<String,String> signAndBuildSignAndJsonHeader(String projectId, String secret,String paramStr,String httpMethod,String url,boolean debug) throws EsignDemoException {
String contentMD5="";
//统一转大写处理
httpMethod = httpMethod.toUpperCase();
if("GET".equals(httpMethod)||"DELETE".equals(httpMethod)){
paramStr=null;
contentMD5="";
} else if("PUT".equals(httpMethod)||"POST".equals(httpMethod)){
//对body体做md5摘要
contentMD5=EsignEncryption.doContentMD5(paramStr);
}else{
throw new EsignDemoException(String.format("不支持的请求方法%s",httpMethod));
}
//构造一个初步的请求头
Map<String, String> esignHeaderMap = buildSignAndJsonHeader(projectId, contentMD5, EsignHeaderConstant.ACCEPT.VALUE(), EsignHeaderConstant.CONTENTTYPE_JSON.VALUE(), EsignHeaderConstant.AUTHMODE.VALUE());
//排序
url=EsignEncryption.sortApiUrl(url);
//传入生成的bodyMd5,加上其他请求头部信息拼接成字符串
String message = EsignEncryption.appendSignDataString(httpMethod, esignHeaderMap.get("Content-MD5"),esignHeaderMap.get("Accept"),esignHeaderMap.get("Content-Type"),esignHeaderMap.get("Headers"),esignHeaderMap.get("Date"), url);
//整体做sha256签名
String reqSignature = EsignEncryption.doSignatureBase64(message, secret);
//请求头添加签名值
esignHeaderMap.put("X-Tsign-Open-Ca-Signature",reqSignature);
if(debug){
LOGGER.info("----------------------------start------------------------");
LOGGER.info("待计算body值:{}", paramStr+"\n");
LOGGER.info("MD5值:{}",contentMD5+"\n");
LOGGER.info("待签名字符串:{}",message+"\n");
LOGGER.info("签名值:{}",reqSignature+"\n");
}
return esignHeaderMap;
}
/**
* @description 构建一个Token鉴权+jsons数据的esign请求头
* @return
* @author 澄泓
*/
public static Map<String, String> buildTokenAndJsonHeader(String appid,String token) {
Map<String, String> esignHeader = new HashMap<>();
esignHeader.put("X-Tsign-Open-Version-Sdk",EsignCoreSdkInfo.getSdkVersion());
esignHeader.put("Content-Type", EsignHeaderConstant.CONTENTTYPE_JSON.VALUE());
esignHeader.put("X-Tsign-Open-App-Id", appid);
esignHeader.put("X-Tsign-Open-Token", token);
return esignHeader;
}
/**
* @description 构建一个form表单数据的esign请求头
* @return
* @author 澄泓
*/
public static Map<String, String> buildFormDataHeader(String appid) {
Map<String, String> esignHeader = new HashMap<>();
esignHeader.put("X-Tsign-Open-Version-Sdk",EsignCoreSdkInfo.getSdkVersion());
esignHeader.put("X-Tsign-Open-Authorization-Version","v2");
esignHeader.put("Content-Type", EsignHeaderConstant.CONTENTTYPE_FORMDATA.VALUE());
esignHeader.put("X-Tsign-Open-App-Id", appid);
return esignHeader;
}
/**
* @description 创建文件流上传 请求头
*
* @param fileContentMd5
* @param contentType
* @return
* @author 澄泓
*/
public static Map<String, String> buildUploadHeader(String fileContentMd5, String contentType) {
Map<String, String> header = new HashMap<>();
header.put("Content-MD5", fileContentMd5);
header.put("Content-Type", contentType);
return header;
}
// ------------------------------私有方法end----------------------------------------------
}
@@ -0,0 +1,52 @@
package com.linke.thirdParty.infrastructure.dict;
/**
* Created by jingzhu.zr on 2017/8/15.
*/
public enum AuthErrorCodeEnum {
OPERATIONERROR("30500000", "请核实入参格式是否正确"),
PARAMERROR("30500101", "请检查参数"),
FORMARTERROR("30500116", "请核实入参是否存在空格"),
BALANCE("30503107", "请核实是否有购买认证服务套餐,或登录e签宝官网核实账单记录"),
THREECHECK("30501002", "三要素匹配失败"),
;
private String key;
private String value;
AuthErrorCodeEnum(String key, String value) {
this.key = key;
this.value = value;
}
public static String findByKey(String key) {
if (OPERATIONERROR.key.equals(key)) {
return OPERATIONERROR.value;
}else if( PARAMERROR.key.equals(key)) {
return PARAMERROR.value;
}else if( FORMARTERROR.key.equals(key)) {
return FORMARTERROR.value;
}else if( BALANCE.key.equals(key)) {
return BALANCE.value;
}else if( THREECHECK.key.equals(key)) {
return THREECHECK.value;
}else {
return "";
}
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
@@ -0,0 +1,67 @@
package com.linke.thirdParty.infrastructure.dict;
/**
* Created by jingzhu.zr on 2017/8/15.
*/
public enum ErrorCodeEnum {
TWO("1002", "参数不正确"),
THREE("1003", "车辆调用数量已达上限"),
FOUR("1004", "接口调用次数已达上限"),
FIVE("1005", "该 API 账号未授权指定所属行政区划数据范围"),
SIX("1006", "无结果"),
TEN("1010", "用户名或密码不正确"),
ELEVEN("1011", "IP 不在白名单列表"),
THIRTEEN("1013", "账号已过有效期"),
FOURTEEN("1014", "无接口权限"),
SIXTEEN("1016", "令牌失效"),
;
private String key;
private String value;
ErrorCodeEnum(String key, String value) {
this.key = key;
this.value = value;
}
public static String findByKey(String key) {
if (TWO.key.equals(key)) {
return TWO.value;
}else if( THREE.key.equals(key)) {
return THREE.value;
}else if( FOUR.key.equals(key)) {
return FOUR.value;
}else if( FIVE.key.equals(key)) {
return FIVE.value;
}else if( SIX.key.equals(key)) {
return SIX.value;
}else if( TEN.key.equals(key)) {
return TEN.value;
}else if( ELEVEN.key.equals(key)) {
return ELEVEN.value;
}else if( THIRTEEN.key.equals(key)) {
return THIRTEEN.value;
}else if( FOURTEEN.key.equals(key)) {
return FOURTEEN.value;
}else if( SIXTEEN.key.equals(key)) {
return SIXTEEN.value;
}else {
return "";
}
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
@@ -0,0 +1,26 @@
package com.linke.thirdParty.infrastructure.dict;
/**
* @description 头部信息常量
* @author 澄泓
* @date 2020/10/22 15:05
* @version JDK1.7
*/
public enum EsignHeaderConstant {
ACCEPT("*/*"),
DATE(""),
HEADERS( ""),
CONTENTTYPE_FORMDATA("application/x-www-form-urlencoded"),
CONTENTTYPE_JSON("application/json; charset=UTF-8"),
CONTENTTYPE_PDF("application/pdf"),
CONTENTTYPE_STREAM("application/octet-stream"),
AUTHMODE("Signature");
private String value;
private EsignHeaderConstant(String value) {
this.value=value;
}
public String VALUE(){
return this.value;
}
}
@@ -0,0 +1,39 @@
package com.linke.thirdParty.infrastructure.dict;
import org.apache.http.client.methods.*;
/**
* @description 请求类型
* @author 澄泓
* @since JDK1.7
*/
public enum EsignRequestType {
POST{
@Override
public HttpRequestBase getHttpType(String url) {
return new HttpPost(url);
}
},
GET{
@Override
public HttpRequestBase getHttpType(String url) {
return new HttpGet(url);
}
},
DELETE{
@Override
public HttpRequestBase getHttpType(String url) {
return new HttpDelete(url);
}
},
PUT{
@Override
public HttpRequestBase getHttpType(String url) {
return new HttpPut(url);
}
},
;
public abstract HttpRequestBase getHttpType(String url);
}
@@ -0,0 +1,28 @@
package com.linke.thirdParty.infrastructure.feign;
import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.domain.po.SysTenantsPo;
import com.mhd.common.core.web.domain.AjaxResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient("mhd-product-service")
public interface ProductServiceFeign {
/**
* 根据applicationName查询定时任务集合
*/
@GetMapping(value = "/elasticJob/elasticJobList/{applicationName}")
public AjaxResult elasticJobList(@PathVariable("applicationName") String applicationName);
/**
* 根据组织id查询租户信息
* @param organizationId
* @return
*/
@GetMapping("/tenants/getTenantsByOrgan")
public R<SysTenantsPo> getTenantsByOrgan(@RequestParam("organizationId") Long organizationId);
}
@@ -0,0 +1,133 @@
package com.linke.thirdParty.infrastructure.feign;
import com.mhd.common.core.domain.dto.BasicAgreementDTO;
import com.mhd.common.core.domain.dto.NoticeMessageLoggingDto;
import com.mhd.common.core.domain.dto.SysProvinceCityCountyDTO;
import com.mhd.common.core.domain.dto.WebSocketDTO;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.system.api.domain.SysDictData;
import com.mhd.system.api.feign.FeignAutoConfiguration;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(value = "mhd-system", configuration = FeignAutoConfiguration.class)
public interface SystemServiceFeign {
@GetMapping("/dict/data/{dictCode}")
public AjaxResult getTopOrganization(@PathVariable("dictCode") Long dictCode);
@PostMapping("/dict/data/findDatalist")
public AjaxResult findDatalist(@RequestBody SysDictData sysDictData);
@GetMapping("/dict/data/type/{dictType}")
public AjaxResult selectListByDictType(@PathVariable("dictType") String dictType);
/**
* 查询省市县三级
* @param sysProvinceDTO
* @return
*/
@PostMapping("/basicApi/selectAreaChildrenList")
public TableDataInfo selectAreaChildrenList(@RequestBody SysProvinceCityCountyDTO sysProvinceDTO);
/**
* 根据县级编码,查询省市县信息
* @param sysProvinceDTO
* @return
*/
@PostMapping("/basicApi/findAreaInfo")
public AjaxResult selectFindAreaInfoList(@RequestBody SysProvinceCityCountyDTO sysProvinceDTO);
/**
* 根据市区编码查询市区信息
* @param sysProvinceDTO
* @return
*/
@PostMapping("/basicApi/findAreaInfoByCityCode")
public AjaxResult findAreaInfoByCityCode(@RequestBody SysProvinceCityCountyDTO sysProvinceDTO);
/**
* 根据省份编码查询省份信息
* @param sysProvinceDTO
* @return
*/
@PostMapping("/basicApi/findAreaInfoByProvince")
public AjaxResult findAreaInfoByProvince(@RequestBody SysProvinceCityCountyDTO sysProvinceDTO);
@ApiOperation("根据code查询分类字典信息")
@GetMapping(value = "/basicApi/getMultistageDictInfoByCode/{multistageDictCode}")
public AjaxResult getMultistageDictInfoByCode(@PathVariable(value = "multistageDictCode",required = true) String multistageDictCode);
@ApiOperation("根据code查询多级分类字典集合")
@GetMapping(value = "/basicApi/getSysMultistageDictList/{code}")
public AjaxResult getSysMultistageDictList(@PathVariable(value = "code") String code);
@ApiOperation("根据topCode查询多级分类字典集合(同一父级字典下所有)")
@GetMapping(value = "/basicApi/getTopMultistageDictList/{topCode}")
public AjaxResult getTopMultistageDictList(@PathVariable(value = "topCode") String topCode);
/**
* 新增消息通知 单条
* @param noticeMessageLoggingDto
* @return
*/
@PostMapping("/messageManageApi/addMessageLogging")
public AjaxResult addMessageLogging(@RequestBody NoticeMessageLoggingDto noticeMessageLoggingDto);
/**
* 新增消息通知 批量
* @param noticeMessageLoggingDto
* @return
*/
@PostMapping("/messageManageApi/addMessageLoggingList")
public AjaxResult addMessageLoggingList(@RequestBody NoticeMessageLoggingDto noticeMessageLoggingDto);
/**
* 根据协议code和租户查询系统协议
*/
@GetMapping("/basicApi/findAgreementByCodeAndOrg")
public AjaxResult findAgreementByCodeAndOrg(BasicAgreementDTO basicAgreementDTO);
/**
* 群发消息
*/
@PostMapping("/webSocketApi/bulkSend")
public AjaxResult bulkSend(@RequestBody WebSocketDTO webSocketDTO);
/**
* 单个消息
*/
@PostMapping("/webSocketApi/oneSend")
public AjaxResult oneSend(@RequestBody WebSocketDTO webSocketDTO);
/**
* 根据货单id查询地址簿列表
*/
@GetMapping("/addressBookApi/selectAddressBookListByManifestId/{manifestId}")
public AjaxResult selectAddressBookListByManifestId(@PathVariable("manifestId") Long manifestId);
/**
* 根据货单id查询地址簿列表
*/
@GetMapping("/addressBookApi/selectCommonRouteByCommonRouteId/{commonRouteId}")
public AjaxResult selectCommonRouteByCommonRouteId(@PathVariable("commonRouteId") Long commonRouteId);
/**
* 获取地址簿详细信息
*/
@GetMapping("/addressBookApi/getInfo/{addressBookId}")
public AjaxResult getInfo(@PathVariable("addressBookId") Long addressBookId);
/**
* 获取用户所在组织的开关配置信息
* @return
*/
@GetMapping("/userConfigSwitchApi/getUserConfigSwitchInfo")
public AjaxResult getUserConfigSwitchInfo();
}
@@ -0,0 +1,14 @@
package com.linke.thirdParty.infrastructure.feign;
import com.mhd.common.core.web.domain.AjaxResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@FeignClient("mhd-userCenter-service")
public interface UserServiceFeign {
//人脸认证回调
@GetMapping("/userApi/notifyUrl/{userId}")
public AjaxResult notifyUrl(@PathVariable("userId") Long userId);
}
@@ -0,0 +1,131 @@
package com.linke.thirdParty.infrastructure.utils;
import cn.hutool.core.io.FileUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.http.MediaType;
import org.springframework.http.MediaTypeFactory;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Decoder;
import java.io.*;
import java.util.Optional;
@Slf4j
public class Base64Util implements MultipartFile {
private final byte[] imgContent;
private final String header;
public Base64Util(byte[] imgContent, String header) {
this.imgContent = imgContent;
this.header = header.split(";")[0];
}
@Override
public String getName() {
// TODO - implementation depends on your requirements
return System.currentTimeMillis() + Math.random() + "." + header.split("/")[1];
}
@Override
public String getOriginalFilename() {
// TODO - implementation depends on your requirements
return System.currentTimeMillis() + (int) Math.random() * 10000 + "." + header.split("/")[1];
}
@Override
public String getContentType() {
// TODO - implementation depends on your requirements
return header.split(":")[1];
}
@Override
public boolean isEmpty() {
return imgContent == null || imgContent.length == 0;
}
@Override
public long getSize() {
return imgContent.length;
}
@Override
public byte[] getBytes() throws IOException {
return imgContent;
}
@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(imgContent);
}
@Override
public void transferTo(File dest) throws IOException, IllegalStateException {
try (FileOutputStream fileOutputStream = new FileOutputStream(dest)){
fileOutputStream.write(imgContent);
}
}
/**
* base64转MultipartFile文件
*
* @param base64
* @return
*/
public static MultipartFile base64ToMultipart(String base64) {
try {
String[] baseStr = base64.split(",");
BASE64Decoder decoder = new BASE64Decoder();
byte[] b = new byte[0];
b = decoder.decodeBuffer(baseStr[1]);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {
b[i] += 256;
}
}
return new Base64Util(b, baseStr[0]);
} catch (IOException e) {
return null;
}
}
/**
* base64转InputStream
*
* @param fileName 上传到ftp的文件名
* @param base64str 需上传文件的base64流
* @return
*/
public static InputStream base64ToInputStream(String fileName, String base64str) {
try {
//根据文件名后缀类型,匹配base64的头部信息
Optional<MediaType> mediaType = MediaTypeFactory.getMediaType(fileName);
String type = mediaType.orElse(MediaType.APPLICATION_OCTET_STREAM).toString();
String head = "data:" + type + ";base64,";
base64str = head + base64str;
//base64转文件流
MultipartFile multipartFile = Base64Util.base64ToMultipart(base64str);
String originalFilename = multipartFile.getOriginalFilename();
// 文件扩展名
String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")).trim();
String uuid = DigestUtils.md5Hex(System.currentTimeMillis() + "");
//将文件写入服务器
File localFile = File.createTempFile(uuid, suffix);
multipartFile.transferTo(localFile);
if (!FileUtil.exist(localFile)) {
log.info("文件不存在");
}
InputStream os = new FileInputStream(localFile);
return os;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}
@@ -0,0 +1,29 @@
package com.linke.thirdParty.infrastructure.utils;
import org.springframework.util.DigestUtils;
/**
* TODO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-07 15:21:48
*/
public class EncryptionUtils {
/**
* @description: 根据时间戳和 Appid、secretKey 进⾏ MD5 签名
* @param bzCode
* @param appId
* @param secretKey
* @return: java.lang.String
* @author: LianZhijian
* @time: 2023-02-07 15:22:14
*/
public static String toMd5(String bzCode, String appId, String secretKey) {
StringBuffer strBuffer = new StringBuffer(bzCode).reverse();
StringBuffer stringBufferSecret = new StringBuffer(secretKey).reverse();
strBuffer.append(stringBufferSecret);
return DigestUtils.md5DigestAsHex(strBuffer.append(appId).toString().getBytes());
}
}
@@ -0,0 +1,80 @@
package com.linke.thirdParty.infrastructure.utils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
/**
* TODO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-07 15:38:09
*/
public class HttpUtils {
/**
* @description: post请求方法
* @param url
* @param param
* @return: java.lang.String
* @author: LianZhijian
* @time: 2023-02-07 15:38:30
*/
public static String sendPost(String appKey, String sign, String time, String url, String param) {
PrintWriter printWriter = null;
BufferedReader bufferedReader = null;
StringBuffer result=new StringBuffer();
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setRequestProperty("content-type","application/json");
conn.setRequestProperty("app-id",appKey);//能链企服分配的appId
conn.setRequestProperty("biz-code",time);//时间戳毫秒
conn.setRequestProperty("pencil",sign);//签名
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
printWriter = new PrintWriter(conn.getOutputStream());
// 发送请求参数
printWriter.print(param);
// flush输出流的缓冲
printWriter.flush();
// 定义BufferedReader输入流来读取URL的响应
bufferedReader = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String line;
while ((line = bufferedReader.readLine()) != null) {
result.append(line);
}
} catch (Exception e) {
e.printStackTrace();
}
//使用finally块来关闭输出流、输入流
finally {
try {
if (printWriter != null) {
printWriter.close();
}
if (bufferedReader != null) {
bufferedReader.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
return result.toString();
}
}
@@ -0,0 +1,65 @@
package com.linke.thirdParty.interfaces.assembler.userAuthEsign;
import cn.hutool.core.util.ObjectUtil;
import com.linke.thirdParty.domain.userAuthEsign.repository.todo.UserAuthEsignDO;
import com.linke.thirdParty.interfaces.dto.userAuthEsign.UserAuthEsignDTO;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.bean.BeanUtils;
import com.mhd.common.core.utils.IgnoreNullUtil;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
* e签宝用户印章授权Assembler
*
* @author gen
* @date 2024-12-03
*/
@Component
public class UserAuthEsignAssembler {
/**
* 转换实体
*/
public UserAuthEsignDO toDO(UserAuthEsignDTO userAuthEsignDTO) {
UserAuthEsignDO userAuthEsignDO = new UserAuthEsignDO();
// 拷贝
BeanUtils.copyProperties(userAuthEsignDTO, userAuthEsignDO, IgnoreNullUtil.getNullPropertyNames(userAuthEsignDTO));
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
String userName = loginUser.getUsername();
// 获取登录人id
Long userId = loginUser.getUserid();
if(userAuthEsignDTO.getUserAuthEsignId() != null){
if(userId != null){
userAuthEsignDO.setUpdateBy(userId);
}else {
userAuthEsignDO.setUpdateBy(new Long("0"));
}
userAuthEsignDO.setUpdateByName(userName);
userAuthEsignDO.setUpdateTime(new Date());
}else {
if(userId != null){
userAuthEsignDO.setCreateBy(userId);
userAuthEsignDO.setUpdateBy(userId);
}else {
userAuthEsignDO.setCreateBy(new Long("0"));
userAuthEsignDO.setUpdateBy(new Long("0"));
}
userAuthEsignDO.setCreateByName(userName);
userAuthEsignDO.setUpdateByName(userName);
userAuthEsignDO.setCreateTime(new Date());
userAuthEsignDO.setUpdateTime(new Date());
userAuthEsignDO.setDelFlag(1);
}
return userAuthEsignDO;
}
}
@@ -0,0 +1,45 @@
package com.linke.thirdParty.interfaces.dto.thridCall;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
/**
* 三方回调对象 thrid_call
*
* @author gen
* @date 2024-04-28
*/
@Data
public class ThridCallDTO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("三方回调id")
private Long thridCallId;
@ApiModelProperty("回调类型:1-支付宝支付回调,2-支付宝转账,3-其他")
@Excel(name = "回调类型:1-支付宝支付回调,2-支付宝转账,3-其他")
private Long callType;
@ApiModelProperty("回调方法")
@Excel(name = "回调方法")
private String callMethod;
@ApiModelProperty("回调参数")
@Excel(name = "回调参数")
private String callParam;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
}
@@ -0,0 +1,24 @@
package com.linke.thirdParty.interfaces.dto.tuanyou;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* TODO 新增员工DTO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-07 17:04:36
*/
@Data
public class AddStaffDTO {
@ApiModelProperty(value = "员⼯基础信息")
private StaffDTO staff;
@ApiModelProperty(value = "定期额度")
private StaffQuotaRuleDTO staffQuotaRule;
@ApiModelProperty(value = "是否发短信 1-发 0-不发(默认不发送短信)")
private Integer needSms;
}
@@ -0,0 +1,40 @@
package com.linke.thirdParty.interfaces.dto.tuanyou;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* TODO 修改⽤⼾可⽤额度DTO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-08 10:03:15
*/
@Data
public class AvailableAmountDTO {
@ApiModelProperty(required = true, value = "全局唯⼀ID")
private String uuid;
@ApiModelProperty(required = true, value = "⽤⼾ID")
private Integer userId;
/**
* adjustmentType 为 1-按⾦额调整,及将员⼯可⽤余额根据⽅向
* (direction)增加或减少传⼊的 adjustmentAmount 相等的值,当
* adjustmentType 为 2-调整余额⾄,及将当前员⼯余额 调整为传⼊的
* adjustmentAmount 相等的值,此时direction参数⽆效
* 调整⾦额需⼤于0,调整后的⽤⼾的可⽤额度如果⼩于0会提⽰扣减失败异
* 常
**/
@ApiModelProperty(required = true, value = "调整类型,1.按⾦额调整,2.调整余额 ⾄")
private Integer adjustmentType;
@ApiModelProperty(required = true, value = "调整⾦额(单位:元,保留两位⼩数)")
private BigDecimal adjustmentAmount;
@ApiModelProperty(required = true, value = "调整⽅向,out:扣除,in:增加(调整 类型为 1 时,不为空)")
private String direction;
}
@@ -0,0 +1,21 @@
package com.linke.thirdParty.interfaces.dto.tuanyou;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* TODO 获取员⼯详情(根据⽤⼾Id或⼿机号)DTO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-09 9:30:15
*/
@Data
public class GetAccountInfoDTO {
@ApiModelProperty(value = "用户id")
private Integer userId;
@ApiModelProperty(value = "手机号")
private String phone;
}
@@ -0,0 +1,32 @@
package com.linke.thirdParty.interfaces.dto.tuanyou;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* TODO 员⼯基础信息DTO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-07 17:07:00
*/
@Data
public class StaffDTO {
@ApiModelProperty(required = true, value = "⼯号")
private String jobNumber;
@ApiModelProperty(required = true, value = "⼿机号码")
private String phone;
@ApiModelProperty(required = true, value = "员⼯姓名")
private String userName;
/**
* 部⻔ID⼤于0会将员⼯添加到该部⻔下,如部⻔不存在则会抛出异常,
* 状态码1000209,部⻔ID等于0时新增员⼯不会向部⻔中添加,添加在
* 企业下⾯
**/
@ApiModelProperty(value = "部⻔ID 默认:0")
private String deptId;
}
@@ -0,0 +1,34 @@
package com.linke.thirdParty.interfaces.dto.tuanyou;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* TODO 定期额度DTO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-07 17:09:22
*/
@Data
public class StaffQuotaRuleDTO {
/**
* 当前 activate 传 1 时,inheritFlag 、quotaAmount、 refreshCycle 均
* 为必须
**/
@ApiModelProperty(value = "定期额度开启 和关闭标识: 0-关闭 1-开启 默认值为0")
private Integer activate;
@ApiModelProperty(value = "周期结束剩定 期额度余额是 否计⼊累计额 度:0-不继承 1-继承")
private Integer inheritFlag;
@ApiModelProperty(value = "定期额度⾦额 (分)")
private Integer quotaAmount;
@ApiModelProperty(value = "定期额度有效 周期:2- ⽉")
private Integer refreshCycle;
}
@@ -0,0 +1,84 @@
package com.linke.thirdParty.interfaces.dto.tuanyou;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: 司机团油油卡管理表
* @Author: Alex
* @Date: 2022-06-06 15:10:20
* @Version: V1.0
*/
@Data
public class TmsDriverOilDTO implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ID_WORKER_STR)
private String id;
@ApiModelProperty(value = "司机DriverID")
private String driverId;
@ApiModelProperty(value = "油卡编号")
private String oilCardNo;
@ApiModelProperty(value = "团油油卡信息")
private String oilInfo;
@ApiModelProperty(value = "团油油卡余额")
private String oilMonery;
@ApiModelProperty(value = "用户手机号")
private String userPhone;
@ApiModelProperty(value = "开卡状态:0-未开卡,1-成功,2-失败")
private Integer oilStatic;
@ApiModelProperty(value = "1:显示 0:不显示")
private Integer status;
@ApiModelProperty(value = "0:不删除 1:删除")
private Integer isDeleted;
@ApiModelProperty(value = "创建日期")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String createTime;
@ApiModelProperty(value = "创建人")
private String createBy;
@ApiModelProperty(value = "更新人")
private String updateBy;
@ApiModelProperty(value = "更新日期")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
@ApiModelProperty(value = "司机个人姓名")
private String driverInfoName;
@ApiModelProperty(value = "司机个人手机号")
private Integer driverInfoNamePhone;
@ApiModelProperty(value = "油卡")
private String oilCardAlias;
@ApiModelProperty(value = "车牌号")
private String plateNumber;
@ApiModelProperty(value = "司机ids")
private String ids;
@ApiModelProperty(value = "外协标识 注释:外协还是自有 枚举:0 自有;1 外协")
private Integer outsideFlag;
@ApiModelProperty(value = "账户类型 注释:外协还是自有 枚举:20 自有充值卡;80 自有共享卡;70 外协卡")
private Integer accountType;
@ApiModelProperty(value = "操作人")
private String operator;
@ApiModelProperty(value = "操作人ip")
private String operatorIp;
@ApiModelProperty(value = "司机和车辆信息集")
private String driverAndCarInfoList;
@ApiModelProperty(value = "账户编号 用来选择不同的能源账户,车队多能源类型必填 (非必填 、 多级公司必传,否则会创建在主公司下)")
private String accountNo;
}
@@ -0,0 +1,85 @@
package com.linke.thirdParty.interfaces.dto.tuanyou;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* TODO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-07 18:58:16
*/
@Data
public class TmsTuanyouLogDTO {
/**
* 创建人
*/
@Excel(name = "创建人", width = 15)
@ApiModelProperty(value = "创建人")
private String createBy;
/**
* 创建日期
*/
@Excel(name = "创建日期", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private Date createTime;
/**
* 更新人
*/
@Excel(name = "更新人", width = 15)
@ApiModelProperty(value = "更新人")
private String updateBy;
/**
* 更新日期
*/
@Excel(name = "更新日期", width = 20, dateFormat = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private Date updateTime;
/**
* 所属部门
*/
@Excel(name = "所属部门", width = 15)
@ApiModelProperty(value = "所属部门")
private String sysOrgCode;
/**
* 请求方法
*/
@Excel(name = "请求方法", width = 15)
@ApiModelProperty(value = "请求方法")
private String method;
/**
* 数据源id
*/
@Excel(name = "数据源id", width = 15)
@ApiModelProperty(value = "数据源id")
private String orderId;
/**
* 请求报文
*/
@Excel(name = "请求报文", width = 15)
@ApiModelProperty(value = "请求报文")
private String requestBody;
/**
* 响应报文
*/
@Excel(name = "响应报文", width = 15)
@ApiModelProperty(value = "响应报文")
private Object responseBody;
/**
* 删除标识
*/
@Excel(name = "删除标识", width = 15)
@ApiModelProperty(value = "删除标识")
private Integer isDelete;
}
@@ -0,0 +1,21 @@
package com.linke.thirdParty.interfaces.dto.tuanyou;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* TODO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-08 10:32:00
*/
@Data
public class UpdateMobileDTO {
@ApiModelProperty(required = true, value = "⽤⼾ID")
private Integer userId;
@ApiModelProperty(required = true, value = "新⼿机号")
private String newMobile;
}
@@ -0,0 +1,61 @@
package com.linke.thirdParty.interfaces.dto.userAuthEsign;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
/**
* e签宝用户印章授权对象 user_auth_esign
*
* @author gen
* @date 2024-12-03
*/
@Data
public class UserAuthEsignDTO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("e签宝用户印章授权id")
private Long userAuthEsignId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("用户id")
@Excel(name = "用户id")
private Long userId;
@ApiModelProperty("授权书签署url短链(有效期180天)")
@Excel(name = "授权书签署url短链", readConverterExp = "有=效期180天")
private String authorizationsignshorturl;
@ApiModelProperty("授权书签署url长链(永久有效)")
@Excel(name = "授权书签署url长链", readConverterExp = "永=久有效")
private String authorizationsignurl;
@ApiModelProperty("授权业务流程编号列表 JSON串")
@Excel(name = "授权业务流程编号列表 JSON串")
private String sealauthbizids;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
}
@@ -0,0 +1,91 @@
package com.linke.thirdParty.interfaces.facade;
import com.aliyun.oss.ServiceException;
import com.linke.thirdParty.application.server.AlipayApplicationService;
import com.mhd.common.core.domain.po.AplipayTransferPO;
import com.mhd.common.core.domain.thirdparty.AlipayPrepayDTO;
import com.mhd.common.core.domain.thirdparty.AplipayTransferDTO;
import com.mhd.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@RestController
@RequestMapping("/alipayApi")
@Api(tags = "支付宝支付")
@Slf4j
public class AlipayApi {
@Autowired
private AlipayApplicationService alipayApplicationService;
/**
* APP下单
*/
@ApiOperation(value = "APP下单", notes = "APP下单")
@PostMapping(value = "/alipayPrepay")
public AjaxResult alipayPrepay(@RequestBody AlipayPrepayDTO alipayPrepayDTO) {
try {
String orderStr = alipayApplicationService.alipayPrepay(alipayPrepayDTO);
return AjaxResult.success("操作成功",orderStr);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 支付宝转账
*/
@ApiOperation(value = "支付宝转账", notes = "支付宝转账")
@PostMapping(value = "/alipayTransfer")
public AjaxResult alipayTransfer(@RequestBody AplipayTransferDTO aplipayTransferDTO) {
try {
AplipayTransferPO aplipayTransferPO = alipayApplicationService.alipayTransfer(aplipayTransferDTO);
return AjaxResult.success("操作成功",aplipayTransferPO);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 支付回调
*/
@ApiOperation(value = "支付回调", notes = "支付回调")
@PostMapping(value = "/payCall")
public AjaxResult payCall(HttpServletRequest request) {
try {
alipayApplicationService.payCall(request);
return AjaxResult.success("操作成功");
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
}
@@ -0,0 +1,106 @@
package com.linke.thirdParty.interfaces.facade;
import com.aliyun.oss.ServiceException;
import com.linke.thirdParty.application.server.AmapApplicationService;
import com.mhd.common.core.domain.thirdparty.AmapDTO;
import com.mhd.common.core.domain.po.thirdparty.RegeocodesAddressPo;
import com.mhd.common.core.domain.thirdparty.AmapPoiKeywordDTO;
import com.mhd.common.core.domain.thirdparty.AmapPoiLocationDTO;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@Api(tags = "高德地图")
@RestController
@RequestMapping("/Amap")
@Slf4j
public class AmapApi extends BaseController {
@Autowired
private AmapApplicationService amapApplicationService;
private Lock lock = new ReentrantLock(true); // 设置公平锁
@ApiOperation(value = "获取距离", notes = "获取距离")
@PostMapping(value = "/queryDistance")
public AjaxResult queryDistance(@RequestBody AmapDTO amapDTO) {
try {
lock.lock();
String distance = amapApplicationService.queryDistance(amapDTO);
return AjaxResult.success("操作成功",distance);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getErrorMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
} finally {
lock.unlock();
}
}
@ApiOperation(value = "逆地理编码", notes = "逆地理编码")
@RequestMapping(value = "/regeo",method = {RequestMethod.POST,RequestMethod.GET})
public AjaxResult regeo(@RequestParam(name="lnglat") String lnglat) {
try {
lock.lock();
List<RegeocodesAddressPo> regeocodesAddressPos= amapApplicationService.regeo(lnglat);
return AjaxResult.success("操作成功",regeocodesAddressPos);
} catch (Exception e) {
log.error(e.getMessage(),e);
return AjaxResult.error(500, "操作失败" + e.getMessage());
}finally {
lock.unlock();
}
}
@ApiOperation(value = "地理编码", notes = "地理编码")
@RequestMapping(value = "/geo",method = {RequestMethod.POST,RequestMethod.GET})
public AjaxResult geo(@RequestParam(name="address") String address) {
String lnglat = amapApplicationService.geo(address);
return AjaxResult.success("操作成功",lnglat);
}
@ApiOperation(value = "逆地理编码(返回数据不做处理)", notes = "逆地理编码")
@RequestMapping(value = "/regeos",method = {RequestMethod.POST,RequestMethod.GET})
public AjaxResult regeos(@RequestParam(name="lnglat") String lnglat) {
try {
lock.lock();
return AjaxResult.success("操作成功",amapApplicationService.regeos(lnglat));
} catch (Exception e) {
log.error(e.getMessage(),e);
return AjaxResult.error(500, "操作失败" + e.getMessage());
}finally {
lock.unlock();
}
}
@ApiOperation(value = "地理编码(返回数据不做处理)", notes = "地理编码")
@RequestMapping(value = "/geos",method = {RequestMethod.POST,RequestMethod.GET})
public AjaxResult geos(@RequestParam(name="address") String address) {
return AjaxResult.success("操作成功",amapApplicationService.geos(address));
}
@ApiOperation(value = "搜索POI(关键字搜索)", notes = "搜索POI")
@RequestMapping(value = "/poiByKeyword",method = {RequestMethod.POST,RequestMethod.GET})
public AjaxResult poiByKeyword(AmapPoiKeywordDTO amapPoiDTO) {
return AjaxResult.success("操作成功",amapApplicationService.poiByKeyword(amapPoiDTO));
}
@ApiOperation(value = "搜索POI(关键字搜索)", notes = "搜索POI")
@RequestMapping(value = "/poiByLocation",method = {RequestMethod.POST,RequestMethod.GET})
public AjaxResult poiByLocation(AmapPoiLocationDTO amapPoiDTO) {
return AjaxResult.success("操作成功",amapApplicationService.poiByLocation(amapPoiDTO));
}
}
@@ -0,0 +1,52 @@
package com.linke.thirdParty.interfaces.facade;
import com.aliyun.oss.ServiceException;
import com.linke.thirdParty.application.server.BaiduNlpApplicationService;
import com.mhd.common.core.domain.po.thirdparty.BWElectronicInvoicePO;
import com.mhd.common.core.domain.po.thirdparty.BaiduNlpAddressPO;
import com.mhd.common.core.domain.thirdparty.BWElectronicInvoiceDTO;
import com.mhd.common.core.domain.thirdparty.BaiduNlpAddressDTO;
import com.mhd.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/baiduNlp")
@Api(tags = "百度智能云-百度自然语言处理")
@Slf4j
public class BaiduNlpApi {
@Autowired
private BaiduNlpApplicationService baiduNlpApplicationService;
/**
* 自然语言-地址识别
* @param address 地址文本
* @return 识别后地址信息
*/
@ApiOperation(value = "自然语言-地址识别", notes = "自然语言-地址识别")
@PostMapping(value = "/addressRecognition")
public AjaxResult addressRecognition(@RequestBody BaiduNlpAddressDTO baiduNlpAddressDTO) {
try {
BaiduNlpAddressPO baiduNlpAddressPO = baiduNlpApplicationService.addressRecognition(baiduNlpAddressDTO);
return AjaxResult.success(baiduNlpAddressPO == null ? new BaiduNlpAddressPO() : baiduNlpAddressPO);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("识别失败");
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("识别失败");
return AjaxResult.error(500, e.getMessage());
}
}
}
@@ -0,0 +1,97 @@
// This file is auto-generated, don't edit it. Thanks.
package com.linke.thirdParty.interfaces.facade;
import cn.hutool.core.collection.CollectionUtil;
import com.aliyun.auth.credentials.Credential;
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
import com.aliyun.core.http.HttpClient;
import com.aliyun.core.http.HttpMethod;
import com.aliyun.core.http.ProxyOptions;
import com.aliyun.httpcomponent.httpclient.ApacheAsyncHttpClientBuilder;
import com.aliyun.sdk.service.imm20200930.models.*;
import com.aliyun.sdk.service.imm20200930.*;
import com.google.gson.Gson;
import darabonba.core.RequestConfiguration;
import darabonba.core.client.ClientOverrideConfiguration;
import darabonba.core.utils.CommonUtil;
import darabonba.core.TeaPair;
//import javax.net.ssl.KeyManager;
//import javax.net.ssl.X509TrustManager;
import java.net.InetSocketAddress;
import java.time.Duration;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.io.*;
public class CreateFileCompressionTask {
public static void main(String[] args) throws Exception {
// HttpClient Configuration
/*HttpClient httpClient = new ApacheAsyncHttpClientBuilder()
.connectionTimeout(Duration.ofSeconds(10)) // Set the connection timeout time, the default is 10 seconds
.responseTimeout(Duration.ofSeconds(10)) // Set the response timeout time, the default is 20 seconds
.maxConnections(128) // Set the connection pool size
.maxIdleTimeOut(Duration.ofSeconds(50)) // Set the connection pool timeout, the default is 30 seconds
// Configure the proxy
.proxy(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("<your-proxy-hostname>", 9001))
.setCredentials("<your-proxy-username>", "<your-proxy-password>"))
// If it is an https connection, you need to configure the certificate, or ignore the certificate(.ignoreSSL(true))
.x509TrustManagers(new X509TrustManager[]{})
.keyManagers(new KeyManager[]{})
.ignoreSSL(false)
.build();*/
// Configure Credentials authentication information, including ak, secret, token
StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()
// Please ensure that the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set.
.accessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
// .accessKeyId("LTAI5tPZNumxUmymf5EQYQXJ")
.accessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"))
// .accessKeySecret("bgBG8HA4VWxV8Z8g4GNAYyPMAM8q6S")
//.securityToken(System.getenv("ALIBABA_CLOUD_SECURITY_TOKEN")) // use STS token
.build());
// Configure the Client
AsyncClient client = AsyncClient.builder()
.region("cn-beijing") // Region ID
//.httpClient(httpClient) // Use the configured HttpClient, otherwise use the default HttpClient (Apache HttpClient)
.credentialsProvider(provider)
//.serviceConfiguration(Configuration.create()) // Service-level configuration
// Client-level configuration rewrite, can set Endpoint, Http request parameters, etc.
.overrideConfiguration(
ClientOverrideConfiguration.create()
// Endpoint 请参考 https://api.aliyun.com/product/imm
.setEndpointOverride("oss-cn-beijing.aliyuncs.com")
//.setConnectTimeout(Duration.ofSeconds(30))
)
.build();
// Parameter settings for API request
CreateFileCompressionTaskRequest createFileCompressionTaskRequest = CreateFileCompressionTaskRequest.builder()
.projectName("mhd_szwl")
.targetURI("oss://szwl-mhd/test-target-mhd.zip")
.compressedFormat("zip")
.sourceManifestURI("oss://szwl-mhd/1722242055144data.pdf,oss://szwl-mhd/1722242054591data.pdf")
// Request-level configuration rewrite, can set Http request parameters, etc.
// .requestConfiguration(RequestConfiguration.create().setHttpHeaders(new HttpHeaders()))
.build();
// Asynchronously get the return value of the API request
CompletableFuture<CreateFileCompressionTaskResponse> response = client.createFileCompressionTask(createFileCompressionTaskRequest);
// Synchronously get the return value of the API request
CreateFileCompressionTaskResponse resp = response.get();
System.out.println(new Gson().toJson(resp));
// Asynchronous processing of return values
/*response.thenAccept(resp -> {
System.out.println(new Gson().toJson(resp));
}).exceptionally(throwable -> { // Handling exceptions
System.out.println(throwable.getMessage());
return null;
});*/
// Finally, close the client
client.close();
}
}
@@ -0,0 +1,151 @@
package com.linke.thirdParty.interfaces.facade;
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse;
import com.aliyun.dingtalkworkflow_1_0.models.QuerySchemaByProcessCodeResponse;
import com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceResponse;
import com.aliyun.oss.ServiceException;
import com.dingtalk.api.response.OapiV2UserGetResponse;
import com.dingtalk.api.response.OapiV2UserGetuserinfoResponse;
import com.linke.thirdParty.application.server.AlipayApplicationService;
import com.linke.thirdParty.application.server.DingtalkService;
import com.mhd.common.core.domain.thirdparty.AlipayPrepayDTO;
import com.mhd.common.core.domain.thirdparty.dingtalk.Oauth2AccessTokenDTO;
import com.mhd.common.core.domain.thirdparty.dingtalk.SchemasProcessCodesDTO;
import com.mhd.common.core.domain.thirdparty.dingtalk.UserGetuserinfoDTO;
import com.mhd.common.core.domain.thirdparty.dingtalk.WorkflowProcessInstancesDTO;
import com.mhd.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/dingtalkApi")
@Api(tags = "钉钉应用")
@Slf4j
public class DingtalkApi {
@Autowired
private DingtalkService dingtalkService;
/**
* 获取企业accessToken(企业内部应用)
*/
@ApiOperation(value = "获取企业accessToken(企业内部应用)", notes = "获取企业accessToken(企业内部应用)")
@PostMapping(value = "/oauth2/accessToken")
public AjaxResult oauth2AccessToken() {
try {
String orderStr = dingtalkService.oauth2AccessToken();
return AjaxResult.success("操作成功",orderStr);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 通过免登码获取用户userid(v2)
*/
@ApiOperation(value = "通过免登码获取用户userid(v2)", notes = "通过免登码获取用户userid(v2)")
@PostMapping(value = "/v2/user/getuserinfo")
public AjaxResult getuserinfo(@RequestBody UserGetuserinfoDTO userGetuserinfoDTO) {
try {
String orderStr = dingtalkService.getuserinfo(userGetuserinfoDTO);
return AjaxResult.success("操作成功",orderStr);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 通过 processCode 获取表单 schema 信息
*/
@ApiOperation(value = "通过 processCode 获取表单 schema 信息", notes = "通过 processCode 获取表单 schema 信息")
@PostMapping(value = "/workflow/forms/schemas/processCodes")
public AjaxResult schemasProcessCodes(@RequestBody SchemasProcessCodesDTO schemasProcessCodesDTO) {
try {
QuerySchemaByProcessCodeResponse orderStr = dingtalkService.schemasProcessCodes(schemasProcessCodesDTO);
return AjaxResult.success("操作成功",orderStr);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 创建审批实例
*/
@ApiOperation(value = "创建审批实例", notes = "创建审批实例")
@PostMapping(value = "/workflow/processInstances")
public AjaxResult workflowProcessInstances(@RequestBody WorkflowProcessInstancesDTO workflowProcessInstancesDTO) {
try {
StartProcessInstanceResponse orderStr = dingtalkService.workflowProcessInstances(workflowProcessInstancesDTO);
return AjaxResult.success("操作成功",orderStr);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 获取单个审批实例详情
*/
@ApiOperation(value = "获取单个审批实例详情", notes = "获取单个审批实例详情")
@GetMapping(value = "/workflow/processInstancesById")
public AjaxResult workflowProcessInstancesById(@RequestParam(value="processInstanceId") String processInstanceId) {
try {
GetProcessInstanceResponse orderStr = dingtalkService.workflowProcessInstancesById(processInstanceId);
return AjaxResult.success("操作成功",orderStr);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 查询用户详情
*/
@ApiOperation(value = "查询用户详情", notes = "查询用户详情")
@GetMapping(value = "/v2/user/get")
public AjaxResult userGet(@RequestParam(value="userId") String userId) {
try {
OapiV2UserGetResponse orderStr = dingtalkService.userGet(userId);
return AjaxResult.success("操作成功",orderStr);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
}
@@ -0,0 +1,499 @@
package com.linke.thirdParty.interfaces.facade;
import com.aliyun.oss.ServiceException;
import com.linke.thirdParty.application.server.ESignApplicationService;
import com.mhd.common.core.domain.po.thirdparty.*;
import com.mhd.common.core.domain.thirdparty.*;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @Description E签宝
* @Author Alex
* @Date 2020/3/10 16:35
*/
@RestController
@RequestMapping("/esign")
@Api(tags = "E签宝")
@Slf4j
public class ESignApi extends BaseController {
@Autowired
private ESignApplicationService eSignApplicationService;
/**
* @Description
* @Author Alex
* @Date 2020/3/10 16:37
*/
@ApiOperation(value = "获取E签宝最新token", notes = "获取E签宝最新token")
@GetMapping(value = "/getToken")
public AjaxResult getToken() {
try {
String code = eSignApplicationService.getToken();
if ("0".equals(code)) {
return AjaxResult.success("token获取成功");
} else {
return AjaxResult.success("token获取失败");
}
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getErrorMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//-------身份证OCR start
/**
* @Description
* @Author zyp
* @Date 2020/3/11 15:37
*/
@ApiOperation(value = "身份证OCR", notes = "身份证OCR")
@PostMapping(value = "/idOCR")
public AjaxResult idOCR(@RequestBody IDOCRDTO idOCRDTO) {
try {
IDOCRPo idocrPo = eSignApplicationService.idOCR(idOCRDTO);
return AjaxResult.success("操作成功", idocrPo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//-----人脸识别核身
/**
* @Description
* @Author zyp
* @Date 2020/3/12 14:37
*/
@ApiOperation(value = "人脸识别核身", notes = "人脸识别核身")
@PostMapping(value = "/faceSwiping")
public AjaxResult faceSwiping(@RequestBody SysIDOCRDTO sysIDOCRDTO) {
try {
SysFacePo sysFacePo = eSignApplicationService.faceSwiping(sysIDOCRDTO);
return AjaxResult.success("操作成功", sysFacePo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
/***
* @Author: zyp
* @Description: 认证结束后异步通知地址 -- http://221.229.219.58:8080/jeecg-boot/esign/notifyUrl
* @Description: 认证结束后异步通知地址 -- http://192.168.3.113:8080/jeecg-boot/esign/notifyUrl
* @Date: 2020/3/13 14:22
* @return: void
**/
@ApiOperation(value = "刷脸认证结束后异步通知地址", notes = "刷脸认证结束后异步通知地址")
@PostMapping(value = "/notifyUrl")
public AjaxResult notifyUrl(@RequestBody NotifyDTO notifyDTO) {
eSignApplicationService.notifyUrl(notifyDTO);
return AjaxResult.success();
}
/**
* 人脸识别核身状态查询
* @param flowId 流程id
* @return
*/
@ApiOperation(value = "人脸识别核身状态查询", notes = "人脸识别核身状态查询")
@GetMapping(value = "/queryFaceSwiping")
public AjaxResult queryFaceSwiping(@RequestParam() String flowId) {
try {
SysQueryFaceSwipingPo sysQueryFaceSwipingPo = eSignApplicationService.queryFaceSwiping(flowId);
return AjaxResult.success("操作成功", sysQueryFaceSwipingPo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//---人脸核身 end
//-----营业执照OCR
@ApiOperation(value = "营业执照OCR", notes = "营业执照OCR")
@PostMapping(value = "/license")
public AjaxResult license(@RequestBody LicenseOCRDTO licenseOCRDTO) {
try {
SysLicensePo sysLicensePo = eSignApplicationService.license(licenseOCRDTO);
return AjaxResult.success("操作成功", sysLicensePo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//-----驾驶证OCR
/**
* @Description
* @Author zyp
* @Date 2020/3/12 16:37
*/
@ApiOperation(value = "驾驶证OCR", notes = "驾驶证OCR")
@PostMapping(value = "/drivinglicence")
public AjaxResult drivinglicence(@RequestBody DrivinglicenceOCRDTO drivinglicenceOCRDTO) {
try {
DrivinglicenceOCRPo drivinglicenceOCRPo = eSignApplicationService.drivinglicence(drivinglicenceOCRDTO);
return AjaxResult.success("操作成功", drivinglicenceOCRPo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//-----行驶证OCR
/**
* @Description
* @Author zyp
* @Date 2020/3/12 16:37
*/
@ApiOperation(value = "行驶证OCR", notes = "行驶证OCR")
@PostMapping(value = "/drivingPermit")
public AjaxResult drivingPermit(@RequestBody DrivingPermitOCRDTO drivingPermitOCRDTO) {
try {
DrivingPermitPo drivinglicenceOCRPo = eSignApplicationService.drivingPermit(drivingPermitOCRDTO);
return AjaxResult.success("操作成功", drivinglicenceOCRPo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//-----发起银行卡4要素核身认证
/**
* @Description
* @Author zyp
* @Date 2020/3/16 15:37
*/
@ApiOperation(value = "发起银行卡4要素核身认证", notes = "发起银行卡4要素核身认证")
@GetMapping(value = "/bankCard4Factors")
public AjaxResult bankCard4Factors(SysBankCard4FactorsDTO sysBankCard4FactorsDTO) {
try {
BankCard4FactorsPo bankCard4FactorsPo = eSignApplicationService.bankCard4Factors(sysBankCard4FactorsDTO);
return AjaxResult.success("操作成功", bankCard4FactorsPo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//----发起银行卡4要素核身认证
//-----查询打款银行信息
/**
* @Description
* @Author zyp
* @Date 2020/3/17 15:37
*/
@ApiOperation(value = "查询打款银行信息", notes = "查询打款银行信息")
@GetMapping(value = "/subbranch")
public AjaxResult subbranch(SubbranchDTO subbranchDTO) {
try {
List<CorporateInformationPo> list = eSignApplicationService.subbranch(subbranchDTO);
return AjaxResult.success("操作成功", list);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//----查询打款银行信息 end
//-----查询打款进度 start
/**
* @Description
* @Author zyp
* @Date 2020/3/16 15:37
*/
@ApiOperation(value = "查询打款进度", notes = "查询打款进度")
@GetMapping(value = "/transferProcess")
public AjaxResult transferProcess(QueryFaceSwipingDTO queryFaceSwipingDTO) {
try {
TransferProcessPo transferProcessPo = eSignApplicationService.transferProcess(queryFaceSwipingDTO);
return AjaxResult.success("操作成功", transferProcessPo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//----查询打款进度 end
//---------创建个人签署账户 end
@ApiOperation(value = "创建个人签署账户", notes = "创建个人签署账户")
@PostMapping(value = "/personalAddAccount")
public AjaxResult addPersonalAccount(@RequestBody PersonalSignatureDTO personalSignatureDTO) {
try {
PersonalSignaturePo personalSignaturePo = eSignApplicationService.personBean(personalSignatureDTO);
return AjaxResult.success("操作成功", personalSignaturePo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//---------创建企业签署账户 end
@ApiOperation(value = "创建企业签署账户", notes = "创建企业签署账户")
@PostMapping(value = "/addAccount")
public AjaxResult addAccount(@RequestBody OrganizeBeanDTO organizeBeanDTO) {
try {
OrganizeBeanPo organizeBeanPo = eSignApplicationService.organizeBean(organizeBeanDTO);
return AjaxResult.success("操作成功", organizeBeanPo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//---------创建个人模板印章 end
@ApiOperation(value = "创建个人模板印章", notes = "创建个人模板印章")
@GetMapping(value = "/esginAddTemplateSeal/{accountId}")
public AjaxResult esginAddTemplateSeal(@PathVariable("accountId") String accountId) {
try {
EsginTemplateSealPo esginTemplateSealPo = eSignApplicationService.esginAddTemplateSeal(accountId);
return AjaxResult.success("操作成功", esginTemplateSealPo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//---------创建企业模板印章 end
@ApiOperation(value = "创建企业模板印章", notes = "创建企业模板印章")
@PostMapping(value = "/addTemplateSealEnterprise")
public AjaxResult addTemplateSealEnterprise(@RequestBody AddTemplateSealEnterpriseDTO addTemplateSealEnterpriseDTO) {
try {
EsginTemplateSealPo esginTemplateSealPo = eSignApplicationService.addTemplateSealEnterprise(addTemplateSealEnterpriseDTO);
return AjaxResult.success("操作成功", esginTemplateSealPo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//---------注销签署账户 end
@ApiOperation(value = "注销签署账户", notes = "注销签署账户")
@GetMapping(value = "/deleteAccount/{accountId}")
public AjaxResult deleteAccount(@PathVariable(name = "accountId") String accountId) {
try {
VerifyRandomAmountPo verifyRandomAmountPo = eSignApplicationService.deleteAccount(accountId);
return AjaxResult.success("操作成功", verifyRandomAmountPo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
@ApiOperation(value = "根据证件号获取签署账户信息", notes = "根据证件号获取签署账户信息")
@GetMapping(value = "/getAccountInfoByIdNo")
public AjaxResult getAccountInfoByIdNo(@RequestParam(name = "idNo", defaultValue = "") String idNo) {
try {
VerifyRandomAmountPo verifyRandomAmountPo = eSignApplicationService.getAccountInfoByIdNo(idNo);
return AjaxResult.success("操作成功", verifyRandomAmountPo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//-----银行卡OCR
/**
* @Description
* @Author zyp
* @Date 2020/3/12 16:37
*/
@ApiOperation(value = "银行卡OCR", notes = "银行卡OCR")
@GetMapping(value = "/BankCard")
public AjaxResult BankCard(BankCardOCRDTO bankCardOCRDTO) {
try {
BankCardPo bankCardPo = eSignApplicationService.BankCard(bankCardOCRDTO);
return AjaxResult.success("操作成功", bankCardPo);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//-----签订电子协议
/**
* @Description
* @Author zyp
* @Date 2020/3/12 16:37
*/
@ApiOperation(value = "签订电子协议", notes = "签订电子协议")
@PostMapping(value = "/commissionContract")
public AjaxResult commissionContract(@RequestBody Map<String, Object> txtFields) {
try {
String url = eSignApplicationService.commissionContract(txtFields);
return AjaxResult.success("操作成功", url);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//-----个人三要素校验
/**
* @Description
* @Author zyp
* @Date 2020/3/12 16:37
*/
@ApiOperation(value = "个人三要素校验", notes = "个人三要素校验")
@PostMapping(value = "/persionAuth")
public AjaxResult persionAuth(@RequestBody PersionAuthDTO persionAuthDTO) {
try {
String flowId = eSignApplicationService.persionAuth(persionAuthDTO);
return AjaxResult.success("操作成功!",flowId);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//-----企业核身认证(三要素)
/**
* @Description
* @Author zyp
* @Date 2020/3/12 16:37
*/
@ApiOperation(value = "企业核身认证(三要素)", notes = "企业核身认证(三要素)")
@PostMapping(value = "/organizationAuth")
public AjaxResult organizationAuth(@RequestBody OrganizationAuthDTO organizationAuthDTO) {
try {
String flowId = eSignApplicationService.organizationAuth(organizationAuthDTO);
return AjaxResult.success("操作成功!",flowId);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
}
@@ -0,0 +1,199 @@
package com.linke.thirdParty.interfaces.facade;
import com.aliyun.oss.ServiceException;
import com.linke.thirdParty.application.server.ESignSaasApplicationService;
import com.mhd.common.core.domain.thirdparty.esignsaas.*;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/esignSaas")
@Api(tags = "E签宝saas版")
@Slf4j
public class EsignSaasApi extends BaseController {
@Autowired
private ESignSaasApplicationService eSignSaasApplicationService;
/**
* 创建个人账号
*/
@ApiOperation(value = "创建个人签署账户", notes = "创建个人签署账户")
@PostMapping(value = "/personalAddAccount")
public AjaxResult addPersonalAccount(@RequestBody EsignSaasPersonalSignatureDTO signatureDTO) {
try {
String result = eSignSaasApplicationService.personBean(signatureDTO);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 创建企业账号
*/
@ApiOperation(value = "创建企业账号", notes = "创建企业账号")
@PostMapping(value = "/addAccount")
public AjaxResult addAccount(@RequestBody EsignSaasOrganizationSignatureDTO signatureDTO) {
try {
String result = eSignSaasApplicationService.addAccount(signatureDTO);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 个人认证
*/
/**
* 企业认证
*/
/**
* 获取个人认证状态
*/
/**
* 获取企业认证状态
*/
/**
* 创建个人印章
*/
@ApiOperation(value = "创建个人印章", notes = "创建个人印章")
@PostMapping(value = "/creatPersonSeal/{accountId}")
public AjaxResult creatPersonSeal(@PathVariable String accountId, @RequestBody EsignSaasPersonalSealDTO sealDTO) {
try {
String result = eSignSaasApplicationService.creatPersonSeal(accountId, sealDTO);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 创建机构印章
*/
@ApiOperation(value = "创建机构印章", notes = "创建机构印章")
@PostMapping(value = "/creatOrganizationSeal/{accountId}")
public AjaxResult creatOrganizationSeal(@PathVariable String accountId, @RequestBody EsignSaasOrganizationSealDTO sealDTO) {
try {
String result = eSignSaasApplicationService.creatOrganizationSeal(accountId, sealDTO);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 填充模板返回文件id
*/
@ApiOperation(value = "填充模板返回文件id", notes = "填充模板返回文件id")
@PostMapping(value = "/filltemplate")
public AjaxResult filltemplate(@RequestBody EsignSaasFillTemplateDTO templateDTO) {
try {
String result = eSignSaasApplicationService.filltemplate(templateDTO);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 一键发起合同签订
*/
@ApiOperation(value = "一键发起合同签订", notes = "一键发起合同签订")
@PostMapping(value = "/signContract")
public AjaxResult signContract(@RequestBody EsignSaasSignContractDTO signatureDTO) {
try {
String result = eSignSaasApplicationService.signContract(signatureDTO);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 下载已签署文件
*/
@ApiOperation(value = "下载已签署文件", notes = "下载已签署文件")
@GetMapping(value = "/downloadSignContract/{signFlowId}")
public AjaxResult downloadSignContract(@PathVariable String signFlowId) {
try {
String result = eSignSaasApplicationService.downloadSignContract(signFlowId);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 设置静默签署授权
*/
@ApiOperation(value = "设置静默签署授权", notes = "设置静默签署授权")
@GetMapping(value = "/signAuth/{accountId}")
public AjaxResult signAuth(@PathVariable String accountId) {
try {
String result = eSignSaasApplicationService.signAuth(accountId);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
}
@@ -0,0 +1,245 @@
package com.linke.thirdParty.interfaces.facade;
import cn.hutool.json.JSONObject;
import com.aliyun.oss.ServiceException;
import com.linke.thirdParty.application.server.ESignSaasApplicationService;
import com.linke.thirdParty.application.server.ESignSaasApplicationV3Service;
import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.domain.po.thirdparty.EsginMemberPo;
import com.mhd.common.core.domain.po.thirdparty.EsginOwnSealPo;
import com.mhd.common.core.domain.thirdparty.esignsaas.*;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/esignSaasV3")
@Api(tags = "E签宝saas版")
@Slf4j
public class EsignSaasV3Api extends BaseController {
@Autowired
private ESignSaasApplicationV3Service eSignSaasApplicationService;
/**
* 填充模板返回文件id
*/
@ApiOperation(value = "填充模板返回文件id", notes = "填充模板返回文件id")
@PostMapping(value = "/filltemplate")
public AjaxResult filltemplate(@RequestBody EsignSaasFillTemplateDTO templateDTO) {
try {
String result = eSignSaasApplicationService.filltemplate(templateDTO);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 基于文件发起签署
*/
@ApiOperation(value = "基于文件发起签署", notes = "基于文件发起签署")
@PostMapping(value = "/signContractByFile")
public AjaxResult signContractByFile(@RequestBody EsignSaasSignContractV3DTO signatureDTO) {
try {
String result = eSignSaasApplicationService.signContractByFile(signatureDTO);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 获取签署页面链接
*/
@ApiOperation(value = "获取签署页面链接", notes = "获取签署页面链接")
@PostMapping(value = "/getSignByFlowId")
public AjaxResult getSignByFlowId(@RequestBody EsignSaasGetSignByFlowIdDTO signatureDTO) {
try {
String result = eSignSaasApplicationService.getSignByFlowId(signatureDTO);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 下载已签署文件
*/
@ApiOperation(value = "下载签署文件", notes = "下载签署文件")
@PostMapping(value = "/downloadSignContract")
public R<String> downloadSignContract(@RequestBody Map<String, String> mapResult) {
try {
String result = eSignSaasApplicationService.getSignUrl(mapResult.get("signFlowId"), mapResult.get("docFileId"), Integer.parseInt(mapResult.get("type")));
return R.ok(result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return R.fail(e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return R.fail(e.getMessage());
}
}
/**
* E签宝回调接口-签署完成
*/
@ApiOperation("E签宝回调接口-签署完成")
@PostMapping("/feelContractCallBank")
public AjaxResult feelContractCallBank(@RequestBody JSONObject jsonObject)
{
boolean result = eSignSaasApplicationService.feelContractCallBank(jsonObject);
return AjaxResult.success(result);
}
@ApiOperation(value = "查询E签宝签署详情", notes = "查询E签宝签署详情")
@PostMapping(value = "/getSignDetailByFlowId")
public AjaxResult getSignDetailByFlowId(@RequestBody EsignSaasGetSignByFlowIdDTO signatureDTO) {
try {
String result = eSignSaasApplicationService.getSignDetailByFlowId(signatureDTO);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 跨企业印章授权
* 纯调用E签宝接口,返回原始参数信息 不保存授权信息
* @param sealAuthV3DTO
* @return
*/
@ApiOperation(value = "跨企业印章授权", notes = "跨企业印章授权")
@PostMapping(value = "/sealAuthorization")
public AjaxResult sealAuthorization(@RequestBody @Validated EsignSaasSealAuthV3DTO sealAuthV3DTO) {
try {
String result = eSignSaasApplicationService.sealAuthorization(sealAuthV3DTO);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
/**
* 用户使用跨企业印章授权
* 对系统内部用户使用,保存授权信息,返回授权链接信息等
* @param sealAuthV3DTO
* @return
*/
@ApiOperation(value = "用户使用跨企业印章授权", notes = "用户使用跨企业印章授权")
@PostMapping(value = "/sealAuthorizationForUser")
public AjaxResult sealAuthorizationForUser(@RequestBody @Validated EsignSaasSealAuthV3DTO sealAuthV3DTO) {
try {
String result = eSignSaasApplicationService.sealAuthorizationForUser(sealAuthV3DTO);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
@ApiOperation(value = "获取机构认证&授权页面链接", notes = "获取机构认证&授权页面链接")
@PostMapping(value = "/obtainAuthorization")
public AjaxResult obtainAuthorization(@RequestBody EsignObtainAuthorizationV3DTO esignObtainAuthorizationV3DTO) {
try {
Map<String,String> result = eSignSaasApplicationService.obtainAuthorization(esignObtainAuthorizationV3DTO);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
@ApiOperation(value = "查询内部印章", notes = "查询内部印章")
@GetMapping(value = "/searchInternally")
public AjaxResult searchInternally(@RequestParam(value = "pageNum") String pageNum,@RequestParam(value = "creditCode") String creditCode) {
try {
String result = eSignSaasApplicationService.searchInternally(pageNum,creditCode);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
@ApiOperation(value = "查询企业成员列表", notes = "查询企业成员列表")
@GetMapping(value = "/searchMemberList")
public AjaxResult searchMemberList(@RequestParam(value = "pageNum") String pageNum,@RequestParam(value = "creditCode") String creditCode) {
try {
String result = eSignSaasApplicationService.searchMemberList(pageNum,creditCode);
return AjaxResult.success("操作成功", result);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getMessage());
}
}
}
@@ -0,0 +1,75 @@
package com.linke.thirdParty.interfaces.facade;
import com.aliyun.oss.ServiceException;
import com.linke.thirdParty.application.server.JPushApplicationService;
import com.mhd.common.core.domain.thirdparty.AuroraPushDTO;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 发送短信
*/
@RestController
@RequestMapping("/jiguang")
@Api(tags = "极光推送")
@Slf4j
public class JPushApi extends BaseController {
@Autowired
private JPushApplicationService jPushApplicationService;
/**
* 极光消息推送
*
* @param
* @returnResult
*/
@ApiOperation(value = "极光消息推送", notes = "极光消息推送")
@PostMapping(value = "/auroraPush")
public AjaxResult auroraPush(@RequestBody AuroraPushDTO auroraPushDTO) {
try {
Integer result = jPushApplicationService.auroraPush(auroraPushDTO);
if (result.toString().equals("1")){
return AjaxResult.success("推送成功");
}else {
return AjaxResult.success("推送失败");
}
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getErrorMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
/**
* 消息推送(合并版)
*
* @param auroraPushDTO
* @return
*/
@ApiOperation(value = "极光消息推送(合并版)", notes = "极光消息推送(合并版)")
@PostMapping(value = "/auroraPushT")
public AjaxResult auroraPushT(@RequestBody AuroraPushDTO auroraPushDTO) {
try {
jPushApplicationService.auroraPushT(auroraPushDTO);
return AjaxResult.success("推送成功");
} catch (Exception e) {
log.error(e.getMessage(), e);
return AjaxResult.error(500, "消息推送失败" + e.getMessage());
}
}
}
@@ -0,0 +1,301 @@
package com.linke.thirdParty.interfaces.facade;
import cn.hutool.core.util.StrUtil;
import com.aliyun.oss.ServiceException;
import com.linke.thirdParty.application.server.OssUploadApplicationService;
import com.linke.thirdParty.infrastructure.utils.Base64Util;
import com.mhd.common.core.domain.thirdparty.esignsaas.EsignSaasSignContractCallDTO;
import com.mhd.common.core.oss.configure.OSSClientPrivateUtil;
import com.mhd.common.core.oss.configure.OSSClientUtil;
import com.mhd.common.core.oss.entity.OssSimpleUpload;
import com.mhd.common.core.utils.uuid.UUID;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Decoder;
import java.awt.*;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* @Description 阿里云oss文件处理接口
* @Author Alex
* @Date 2023/5/4 13:52
*/
@Slf4j
@RestController
@RequestMapping("/ossApi")
@CrossOrigin
public class OssApi extends BaseController {
@Autowired
private OssUploadApplicationService ossUploadApplicationService;
/**
* 文件转存直OSS
*/
@PostMapping(value = "/uploadingOss")
public AjaxResult uploadingOss(@RequestBody() List<String> urlList) throws IOException {
for (String s : urlList) {
try {
// 线上地址
// String onlineUrl = "http://example.com/somefile.txt";
URL url = new URL(s);
URLConnection connection = url.openConnection();
// 打开连接获取输入流
InputStream inputStream = connection.getInputStream();
Random random = new Random(10000);
String name = random.nextInt(10000) + System.currentTimeMillis() + "data";
String s1 = ossUploadApplicationService.simpleUpload(inputStream,"pdf", name);
System.out.println("地址为"+s+"的转存的地址为"+s1);
}catch (IOException ioException){
throw ioException;
}
}
return AjaxResult.success();
}
@PostMapping(value = "/uploadingOssUrl")
public AjaxResult uploadingOssUrl(@RequestBody String outUrl){
try {
String url = ossUploadApplicationService.getOutUrl(outUrl);
log.info("地址为"+outUrl+"的转存的地址为"+url);
return AjaxResult.success("操作成功",url);
}catch (Exception e){
log.error("地址" + outUrl +"转换失败" + e.getMessage());
return AjaxResult.error("操作失败");
}
}
/**
* 压缩文件
*/
@PostMapping(value = "/compressedFile")
public AjaxResult compressedFile(@RequestBody() List<String> urlList) throws IOException {
for (String s : urlList) {
try {
// 线上地址
// String onlineUrl = "http://example.com/somefile.txt";
URL url = new URL(s);
URLConnection connection = url.openConnection();
// 打开连接获取输入流
InputStream inputStream = connection.getInputStream();
Random random = new Random(10000);
String name = random.nextInt(10000) + System.currentTimeMillis() + "data";
String s1 = ossUploadApplicationService.simpleUpload(inputStream,"pdf", name);
System.out.println("地址为"+s+"的转存的地址为"+s1);
}catch (IOException ioException){
throw ioException;
}
}
return AjaxResult.success();
}
/**
* 文件上传到oss
*/
@PostMapping(value = "/upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public AjaxResult upload(@RequestPart("file") MultipartFile file) {
File fileUpload = null;
if (!file.isEmpty()) {
String originalFileName = file.getOriginalFilename();
// 若须要防止生成的临时文件重复,能够在文件名后添加随机码
try {
// 获取文件后缀
String prefix = originalFileName.substring(originalFileName.lastIndexOf("."));
fileUpload = OSSClientUtil.compress(file, prefix);
String[] filename = originalFileName.split("\\.");
file.transferTo(fileUpload);
} catch (Exception e) {
e.printStackTrace();
}
}
return AjaxResult.success(ossUploadApplicationService.uploadOssPrivate(fileUpload));
}
/**
* 文件上传到oss(base64)
*/
@PostMapping("/uploadByBase64")
public AjaxResult uploadByBase64(@RequestParam("base64") String base64) {
File fileUpload = null;
if (StrUtil.isNotEmpty(base64)) {
try {
MultipartFile file = Base64Util.base64ToMultipart(base64);
String originalFileName = file.getOriginalFilename();
// 若须要防止生成的临时文件重复,能够在文件名后添加随机码
// 获取文件后缀
String prefix = originalFileName.substring(originalFileName.lastIndexOf("."));
fileUpload = OSSClientUtil.compress(file, prefix);
String[] filename = originalFileName.split("\\.");
file.transferTo(fileUpload);
} catch (Exception e) {
e.printStackTrace();
}
}
return AjaxResult.success(ossUploadApplicationService.uploadOssPrivate(fileUpload));
}
/**
* 文件上传到oss(base64)批量
*/
@PostMapping("/uploadBatchByBase64")
public AjaxResult<?> uploadBatchByBase64(@RequestBody List<String> base64) {
List<String> fileUrls = new ArrayList<>();
for (String s : base64) {
File fileUpload = null;
if (StrUtil.isNotEmpty(s)) {
try {
MultipartFile file = Base64Util.base64ToMultipart(s);
String originalFileName = file.getOriginalFilename();
// 若须要防止生成的临时文件重复,能够在文件名后添加随机码
// 获取文件后缀
String prefix = originalFileName.substring(originalFileName.lastIndexOf("."));
fileUpload = OSSClientUtil.compress(file, prefix);
String[] filename = originalFileName.split("\\.");
file.transferTo(fileUpload);
} catch (Exception e) {
e.printStackTrace();
}
}
String fileUrl = ossUploadApplicationService.uploadOssPrivate(fileUpload);
fileUrls.add(fileUrl);
}
return AjaxResult.success(fileUrls);
}
/**
* 文件上传到oss
*/
@PostMapping("/uplodeAgain")
public AjaxResult uplodeAgain(@RequestBody EsignSaasSignContractCallDTO esignSaasSignContractCallDTO) {
MultipartFile file = OSSClientPrivateUtil.urlTransferMultipartFile(esignSaasSignContractCallDTO.getFileUrl());
File fileUpload = null;
if (!file.isEmpty()) {
String originalFileName = file.getOriginalFilename();
// 若须要防止生成的临时文件重复,能够在文件名后添加随机码
try {
// 获取文件后缀
String prefix = ".pdf";
String[] filename = originalFileName.split("\\.");
fileUpload = File.createTempFile(filename[0], prefix);
file.transferTo(fileUpload);
} catch (Exception e) {
e.printStackTrace();
}
}
return AjaxResult.success("上传成功!",ossUploadApplicationService.uploadOssPrivate(fileUpload));
}
/**
* @Description 文件批量上传到oss
* @Author Alex
* @Date 2023/4/27 15:51
*/
@PostMapping("/batchUpload")
public AjaxResult batchUpload(@RequestParam("files") List<MultipartFile> files) {
if (files == null || files.size() == 0) {
return AjaxResult.error("上传文件不能为空");
}
List<String> fileUrls = new ArrayList<>();
for (MultipartFile multipartFile : files) {
File fileUpload = null;
if (!files.isEmpty()) {
String originalFileName = multipartFile.getOriginalFilename();
// 若须要防止生成的临时文件重复,能够在文件名后添加随机码
try {
// 获取文件后缀
String prefix = originalFileName.substring(originalFileName.lastIndexOf("."));
String name = UUID.randomUUID().toString();
fileUpload = OSSClientUtil.compress(multipartFile, prefix);
// fileUpload = File.createTempFile(name, prefix);
multipartFile.transferTo(fileUpload);
} catch (Exception e) {
e.printStackTrace();
}
}
String fileUrl = ossUploadApplicationService.uploadOssPrivate(fileUpload);
fileUrls.add(fileUrl);
}
return AjaxResult.success(fileUrls);
}
@ApiOperation(value = "获取加密后url地址", notes = "获取加密后url地址")
@GetMapping(value = "/getFileUrlsPrivate")
public AjaxResult getFileUrlsPrivate(@RequestParam(name = "fileUrl", defaultValue = "") String fileUrl) {
try {
fileUrl = ossUploadApplicationService.getFileUrlsPrivate(fileUrl);
return AjaxResult.success("操作成功", fileUrl);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
@ApiOperation(value = "删除文件", notes = "从阿里云对象存储中删除,防止垃圾文件堆积浪费存储空间")
@PostMapping(value = "/batchDeleteFile")
public AjaxResult batchDeleteFile(@RequestParam(name = "fileUrl", defaultValue = "") String fileUrl) {
try {
ossUploadApplicationService.batchDeleteFile(fileUrl);
return AjaxResult.success("操作成功");
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
/**
* 解析地址
*/
@ApiOperation("解析地址")
@GetMapping(value = "/analysisUrl")
public AjaxResult analysisUrl(String url)
{
return AjaxResult.success("操作成功!",ossUploadApplicationService.analysisUrl(url));
}
/**
* 进行文件上传
*/
@ApiOperation("进行文件上传")
@PostMapping(value = "/simpleUpload")
public AjaxResult simpleUpload(@RequestBody OssSimpleUpload ossSimpleUpload)
{
return AjaxResult.success("操作成功!",ossUploadApplicationService.simpleUpload(ossSimpleUpload.getInputStream(), ossSimpleUpload.getSuffix(), ossSimpleUpload.getDir()));
}
}
@@ -0,0 +1,83 @@
package com.linke.thirdParty.interfaces.facade;
import com.aliyun.oss.ServiceException;
import com.linke.thirdParty.application.server.SmsApplicationService;
import com.mhd.common.core.domain.thirdparty.SmsDTO;
import com.mhd.common.core.domain.thirdparty.SmsMessageDTO;
import com.mhd.common.core.utils.sms.Result;
import com.mhd.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* 发送短信
*/
@RestController
@RequestMapping("/sms")
@Api(tags = "短信")
@Slf4j
public class SmsApi {
@Autowired
private SmsApplicationService smsApplicationService;
/**
* 验证码发送
*
* @param
* @returnResult
*/
@ApiOperation(value = "验证码发送", notes = "验证码发送")
@PostMapping(value = "/verifyCode")
public AjaxResult sms(@RequestBody SmsDTO smsDTO, HttpServletRequest request) {
try {
Result result = smsApplicationService.sendMsg(smsDTO, request);
if ("200".equals(result.getCode().toString())) {
return AjaxResult.success("发送成功");
} else {
return AjaxResult.success("发送失败");
}
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getErrorMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
/**
* 消息发送
*
* @param
* @returnResult
*/
@ApiOperation(value = "消息发送", notes = "消息发送")
@PostMapping(value = "/sendMessage")
public AjaxResult sendMessage(@RequestBody SmsMessageDTO smsMessageDTO) {
try {
Result result = smsApplicationService.sendMessage(smsMessageDTO);
if ("200".equals(result.getCode().toString())) {
return AjaxResult.success("发送成功");
} else {
return AjaxResult.success("发送失败");
}
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getErrorMessage());
return AjaxResult.error(500, e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
}
@@ -0,0 +1,166 @@
package com.linke.thirdParty.interfaces.facade;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.linke.thirdParty.application.server.SysDepartInterfaceInfoApplicationService;
import com.mhd.common.core.constant.CacheConstants;
import com.mhd.common.core.domain.entity.OrgProductConfig;
import com.mhd.common.core.domain.po.thirdparty.SysDepartInterfaceInfoPo;
import com.linke.thirdParty.domain.departInterfaceInfo.repository.todo.SysDepartInterfaceInfoDo;
import com.mhd.common.core.domain.thirdparty.SysDepartInterfaceInfoDTO;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Description: 三方接口信息
* @Author: Alex
* @Date: 2020-03-03 10:11:17
* @Version: V1.0
*/
@RestController
@RequestMapping("/sysDepartInterfaceInfo")
@CrossOrigin
public class SysDepartInterfaceInfoApi extends BaseController
{
@Autowired
private SysDepartInterfaceInfoApplicationService sysDepartInterfaceInfoApplicationService;
/**
* 分页列表查询(根据一级组织查询)
*
* @param sysDepartInterfaceInfoDTO
* @return
*/
@GetMapping(value = "/list")
public TableDataInfo list(SysDepartInterfaceInfoDTO sysDepartInterfaceInfoDTO) {
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
BeanUtils.copyProperties(sysDepartInterfaceInfoDTO,sysDepartInterfaceInfoDo);
startPage();
List<SysDepartInterfaceInfoPo> list = sysDepartInterfaceInfoApplicationService.queryList(sysDepartInterfaceInfoDo);
return getDataTable(list);
}
/**
* 分页列表查询(根据组织查询)
*
* @param sysDepartInterfaceInfoDTO
* @return
*/
@GetMapping(value = "/listByOrg")
public TableDataInfo listByOrg(SysDepartInterfaceInfoDTO sysDepartInterfaceInfoDTO) {
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
BeanUtils.copyProperties(sysDepartInterfaceInfoDTO,sysDepartInterfaceInfoDo);
startPage();
List<SysDepartInterfaceInfoPo> list = sysDepartInterfaceInfoApplicationService.queryListByOrg(sysDepartInterfaceInfoDo);
return getDataTable(list);
}
/**
* 分页列表查询(根据组织查询) - feign
*
* @param sysDepartInterfaceInfoDTO
* @return
*/
@PostMapping(value = "/listByOrgByFeign")
public AjaxResult listByOrgByFeign(@RequestBody SysDepartInterfaceInfoDTO sysDepartInterfaceInfoDTO) {
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
BeanUtils.copyProperties(sysDepartInterfaceInfoDTO,sysDepartInterfaceInfoDo);
List<SysDepartInterfaceInfoPo> sysDepartInterfaceInfoPos = sysDepartInterfaceInfoApplicationService.listByOrgByFeign(sysDepartInterfaceInfoDo);
return AjaxResult.success(sysDepartInterfaceInfoPos);
}
@GetMapping(value = "/ossList")
public TableDataInfo ossList() {
List<SysDepartInterfaceInfoPo> list = sysDepartInterfaceInfoApplicationService.ossList();
return getDataTable(list);
}
/**
* 三方接口信息-新增/修改
*
* @param sysDepartInterfaceInfoDTO
* @return
*/
@PostMapping(value = "/addOrEdit")
public AjaxResult addOrEdit(@RequestBody SysDepartInterfaceInfoDTO sysDepartInterfaceInfoDTO) {
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
BeanUtils.copyProperties(sysDepartInterfaceInfoDTO,sysDepartInterfaceInfoDo);
if (sysDepartInterfaceInfoDo.getSysDepartInterfaceInfoId() == null){
return toAjax(sysDepartInterfaceInfoApplicationService.save(sysDepartInterfaceInfoDo));
}else {
return toAjax(sysDepartInterfaceInfoApplicationService.update(sysDepartInterfaceInfoDo));
}
}
/**
* 三方接口信息-删除
* @return
*/
@DeleteMapping(value = "/delete/{sysDepartInterfaceInfoIds}")
public AjaxResult delete(@PathVariable(name = "sysDepartInterfaceInfoIds") Long[] sysDepartInterfaceInfoIds) {
sysDepartInterfaceInfoApplicationService.delete(sysDepartInterfaceInfoIds);
return toAjax(sysDepartInterfaceInfoApplicationService.delete(sysDepartInterfaceInfoIds));
}
/**
* 通过id查询
*
* @param id
* @return
*/
@GetMapping(value = "/queryById/{id}")
public AjaxResult queryById(@PathVariable(name="id",required=true) Long id) {
return AjaxResult.success(sysDepartInterfaceInfoApplicationService.queryById(id));
}
/**
* @Description 查询当前组织所有三方接口信息
* @Author Alex
* @Date 2023/4/28 11:24
*/
@GetMapping(value = "/querylist")
public List<SysDepartInterfaceInfoPo> querylist(SysDepartInterfaceInfoDTO sysDepartInterfaceInfoDTO) {
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
BeanUtils.copyProperties(sysDepartInterfaceInfoDTO,sysDepartInterfaceInfoDo);
List<SysDepartInterfaceInfoPo> list = sysDepartInterfaceInfoApplicationService.queryList(sysDepartInterfaceInfoDo);
return list;
}
/**
* @Description 查询当前组织所有三方接口信息
* @Author Alex
* @Date 2023/4/28 11:24
*/
@PostMapping(value = "/queryListByFeign")
public List<SysDepartInterfaceInfoPo> queryListByFeign(@RequestBody SysDepartInterfaceInfoDTO sysDepartInterfaceInfoDTO) {
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
BeanUtils.copyProperties(sysDepartInterfaceInfoDTO, sysDepartInterfaceInfoDo);
return sysDepartInterfaceInfoApplicationService.queryList(sysDepartInterfaceInfoDo);
}
/**
* @Description 查询当前组织所有三方接口信息 post请求
* @Author Alex
* @Date 2023/4/28 11:24
*/
@PostMapping(value = "/querylistByPost")
public List<SysDepartInterfaceInfoPo> querylistByPost(@RequestBody SysDepartInterfaceInfoDTO sysDepartInterfaceInfoDTO) {
SysDepartInterfaceInfoDo sysDepartInterfaceInfoDo = new SysDepartInterfaceInfoDo();
BeanUtils.copyProperties(sysDepartInterfaceInfoDTO,sysDepartInterfaceInfoDo);
List<SysDepartInterfaceInfoPo> list = sysDepartInterfaceInfoApplicationService.queryList(sysDepartInterfaceInfoDo);
return list;
}
}
@@ -0,0 +1,98 @@
package com.linke.thirdParty.interfaces.facade;
import java.util.List;
import com.linke.thirdParty.application.server.ThridCallApplicationService;
import io.swagger.annotations.ApiOperation;
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.DeleteMapping;
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.RestController;
import com.linke.thirdParty.interfaces.dto.thridCall.ThridCallDTO;
import com.linke.thirdParty.domain.thridCall.repository.todo.ThridCallDO;
import com.linke.thirdParty.domain.thridCall.repository.po.ThridCallPO;
import javax.annotation.Resource;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 三方回调Api
*
* @author gen
* @date 2024-04-28
*/
@RestController
@RequestMapping("/thridCallApi")
public class ThridCallApi extends BaseController{
@Autowired
private ThridCallApplicationService thridCallApplicationService;
/**
* 分页查询三方回调列表
*/
@ApiOperation("查询三方回调列表")
@GetMapping("/list")
public TableDataInfo list(ThridCallDTO thridCallDTO)
{
//转换实体
ThridCallDO thridCallDO = new ThridCallDO();
BeanUtils.copyProperties(thridCallDTO, thridCallDO);
startPage();
List<ThridCallPO> list = thridCallApplicationService.queryList(thridCallDO);
return getDataTable(list);
}
/**
* 编辑三方回调
*/
@ApiOperation("编辑三方回调")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody ThridCallDTO thridCallDTO)
{
//转换实体
ThridCallDO thridCallDO = new ThridCallDO();
BeanUtils.copyProperties(thridCallDTO, thridCallDO);
if(thridCallDTO.getThridCallId() != null){
return toAjax(thridCallApplicationService.update(thridCallDO));
}else {
return toAjax(thridCallApplicationService.insert(thridCallDO));
}
}
/**
* 批量删除三方回调
*/
@ApiOperation("批量删除三方回调")
@DeleteMapping("/deleteByIds/{thridCallIds}")
public AjaxResult delete(@PathVariable Long[] thridCallIds)
{
return toAjax(thridCallApplicationService.delete(thridCallIds));
}
/**
* 获取三方回调详细信息
*/
@ApiOperation("获取三方回调")
@GetMapping(value = "/getInfo/{thridCallId}")
public AjaxResult getInfo(@PathVariable("thridCallId") Long thridCallId)
{
return AjaxResult.success(thridCallApplicationService.getInfo(thridCallId));
}
}
@@ -0,0 +1,367 @@
package com.linke.thirdParty.interfaces.facade;
import com.aliyun.oss.ServiceException;
import com.linke.thirdParty.application.server.IZhiYunApplicationService;
import com.mhd.common.core.domain.po.TransTimeManageV3Po;
import com.mhd.common.core.domain.po.thirdparty.*;
import com.mhd.common.core.domain.thirdparty.*;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Description 智云
* @Author zyp
* @Date 2020/3/31 09:35
*/
@RestController
@RequestMapping("/openapi")
@Api(tags="中交兴路")
@Slf4j
public class ZYApi extends BaseController {
@Autowired
private IZhiYunApplicationService iZhiYunApplicationService;
//登录失败递归次数
final private static int recursionCount = 3;
/**
* @Description 获取最新token
* @Author Alex
* @Date 2020/3/9 21:07
*/
@ApiOperation(value = "获取最新token", notes = "获取最新token")
@GetMapping(value = "/login")
public AjaxResult login() {
try {
String staus = iZhiYunApplicationService.login(new OpenApiConfigDTO());
return AjaxResult.success("操作成功","结果码:"+staus);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500,"操作失败:"+e.getMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500,"操作失败"+e.getMessage());
}
}
//-----车辆轨迹查询 start
/**
* @Description
* @Author zyp
* @Date 2020/3/18 10:37
*/
@ApiOperation(value = "车辆轨迹查询(车牌号)", notes = "车辆轨迹查询(车牌号)")
@GetMapping(value = "/vHisTrack24")
public AjaxResult vHisTrack24(VHisTrack24HisTrack24DTO vHisTrack24HisTrack24DTO) {
try {
List<VHisTrack24Po> vHisTrack24PoList = iZhiYunApplicationService.vHisTrack72(vHisTrack24HisTrack24DTO,recursionCount);
return AjaxResult.success(vHisTrack24PoList);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500 ,"操作失败:"+e.getMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500 ,"操作失败"+e.getMessage());
}
}
//-----车辆轨迹查询 start
/**
* @Description
* @Author zyp
* @Date 2020/3/18 10:37
*/
@ApiOperation(value = "车辆轨迹查询(车牌号)", notes = "车辆轨迹查询(车牌号)")
@PostMapping(value = "/vHisTrack24s")
public AjaxResult vHisTrack24s(@RequestBody VHisTrack24HisTrack24DTO vHisTrack24HisTrack24DTO) {
try {
List<VHisTrack24Po> vHisTrack24PoList = iZhiYunApplicationService.vHisTrack72(vHisTrack24HisTrack24DTO,recursionCount);
return AjaxResult.success(vHisTrack24PoList);
} catch (ServiceException e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500 ,"操作失败:"+e.getMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500 ,"操作失败"+e.getMessage());
}
}
//----车辆轨迹查询 end
/**
* @Description
* @Author zyp
* @Date 2020/3/18 10:37
*/
@ApiOperation(value = "获取车辆最新位置(车牌号)", notes = "获取车辆最新位置(车牌号)")
@GetMapping(value = "/transTimeManageV3")
public AjaxResult transTimeManageV3(TransTimeManageV3DTO transTimeManageV3DTO) {
try {
TransTimeManageV3Po transTimeManageV3 = iZhiYunApplicationService.transTimeManageV3(transTimeManageV3DTO, recursionCount);
return AjaxResult.success(transTimeManageV3);
} catch (ServiceException e) {
e.printStackTrace();
log.error("e:" + e.getMessage());
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败:" + e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
log.error("e:" + e.getMessage());
return AjaxResult.error(500, "操作失败" + e.getMessage());
}
}
//-----道路运输证验证 start
/**
* @Description
* @Author zyp
* @Date 2020/3/18 10:37
*/
@ApiOperation(value = "道路运输证验证", notes = "道路运输证验证")
@GetMapping(value = "/checkRTCNo")
public AjaxResult<CheckRTCNoPo> checkRTCNo(CheckRTCNoDTO checkRTCNoDTO) {
try {
CheckRTCNoPo checkRTCNoPo = iZhiYunApplicationService.checkRTCNo(checkRTCNoDTO,recursionCount);
return AjaxResult.success(checkRTCNoPo);
} catch (ServiceException e) {
e.printStackTrace();
return AjaxResult.error(500 ,e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500 ,"操作失败"+e.getMessage());
}
}
//----道路运输证验证 end
//-----车辆入网验证 start
/**
* @Description
* @Author zyp
* @Date 2020/3/18 10:37
*/
@ApiOperation(value = "车辆入网验证", notes = "车辆入网验证")
@PostMapping(value = "/checkTruckExist")
public AjaxResult checkTruckExist(@RequestBody CheckTruckExistDTO checkTruckExistDTO) {
try {
CheckTruckExistPo checkTruckExistPo = iZhiYunApplicationService.checkTruckExist(checkTruckExistDTO,recursionCount);
return AjaxResult.success(checkTruckExistPo);
} catch (ServiceException e) {
e.printStackTrace();
return AjaxResult.error(500 ,e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500 ,"操作失败"+e.getMessage());
}
}
//----车辆入网验证 end
//-----自定义区域注册接口 start
/**
* @Description
* @Author zyp
* @Date 2020/3/18 10:37
*/
@ApiOperation(value = "自定义区域注册接口", notes = "自定义区域注册接口")
@GetMapping(value = "/areaReg")
public AjaxResult areaReg(AreaRegDTO areaRegDTO) {
try {
AreaRegPo areaRegPo = iZhiYunApplicationService.areaReg(areaRegDTO);
return AjaxResult.success(areaRegPo);
} catch (ServiceException e) {
e.printStackTrace();
return AjaxResult.error(500,e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500 , "操作失败"+e.getMessage());
}
}
//----自定义区域注册接口 end
//-----车辆订阅接口 start
/**
* @Description
* @Author zyp
* @Date 2020/3/18 10:37
*/
@ApiOperation(value = "自定义区域注册接口", notes = "自定义区域注册接口")
@GetMapping(value = "/vnoReg")
public AjaxResult vnoReg(VnoRegDTO vnoRegDTO) {
try {
VnoRegPo vnoRegVO = iZhiYunApplicationService.vnoReg(vnoRegDTO,recursionCount);
return AjaxResult.success(vnoRegVO);
} catch (ServiceException e) {
e.printStackTrace();
return AjaxResult.error(500 , e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500 ,"操作失败"+e.getMessage());
}
}
//----车辆订阅接口 end
//-----删除车辆订阅接口 start
/**
* @Description
* @Author zyp
* @Date 2020/3/18 10:37
*/
@ApiOperation(value = "删除车辆订阅接口", notes = "删除车辆订阅接口")
@GetMapping(value = "/vnoDel")
public AjaxResult vnoDel(VnoDelDTO vnoDelDTO) {
try {
VnoDelPo vnoDelPo = iZhiYunApplicationService.vnoDel(vnoDelDTO,recursionCount);
return AjaxResult.success(vnoDelPo);
} catch (ServiceException e) {
e.printStackTrace();
return AjaxResult.error(500 , e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500 , "操作失败"+e.getMessage());
}
}
//----删除车辆订阅接口 end
//-----车辆驶出事件通知接口 start
/**
* @Description
* @Author zyp
* @Date 2020/3/18 10:37
*/
/*@ApiOperation(value = "车辆驶出事件通知接口", notes = "车辆驶出事件通知接口")
@PostMapping(value = "/areamsg")
public String areaMsg(AreaMsgDTO areaMsgDTO) {
String status = iZhiYunApplicationService.areaMsg(areaMsgDTO);
Map<String, String> map = new HashMap<>();
map.put("result",System.currentTimeMillis()+"");
map.put("status",status);//1006无结果
return JSONUtils.toJSONString(map);
}*/
//----车辆驶出事件通知接口 end
@ApiOperation(value = "企业道路运输经营许可证验证", notes = "企业道路运输经营许可证验证使用本接口,因企业名称不方便收集,")
@GetMapping(value = "/enterpriseRoadLicense")
public AjaxResult enterpriseRoadLicense(EnterpriseRoadLicenseDTO enterpriseRoadLicenseDTO) {
try {
CheckTruckExistPo checkTruckExistVO = iZhiYunApplicationService.enterpriseRoadLicense(enterpriseRoadLicenseDTO,recursionCount);
return AjaxResult.success(checkTruckExistVO);
} catch (ServiceException e) {
e.printStackTrace();
return AjaxResult.error(500 , e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500 , "操作失败"+e.getMessage());
}
}
//-----道路运输证OCR识别 start
/**
* @Description
* @Author zyp
* @Date 2020/3/18 10:37
*/
@ApiOperation(value = "道路运输证OCR识别", notes = "道路运输证OCR识别")
@GetMapping(value = "/rtcNoOCR")
public AjaxResult rtcNoOCR(RTCNoOCRDTO rtcNoOCRDTO) {
try {
RTCNoOCRPo rtcNoOCRVO = iZhiYunApplicationService.rtcNoOCR(rtcNoOCRDTO, recursionCount);
return AjaxResult.success(rtcNoOCRVO);
} catch (ServiceException e) {
e.printStackTrace();
return AjaxResult.error(500 , e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500 , "操作失败"+e.getMessage());
}
}
//----道路运输证OCR识别 end
@ApiOperation(value = "企业道路运输经营许可证验证 V3", notes = "企业道路运输经营许可证验证 V3")
@PostMapping(value = "/enterpriseRoadLicenseV3")
public AjaxResult enterpriseRoadLicenseV3(@RequestBody EnterpriseRoadLicenseDTO enterpriseRoadLicenseDTO) {
try {
CheckTruckExistPo checkTruckExistVO = iZhiYunApplicationService.enterpriseRoadLicenseV3(enterpriseRoadLicenseDTO,recursionCount);
return AjaxResult.success(checkTruckExistVO);
} catch (ServiceException e) {
e.printStackTrace();
return AjaxResult.error(500 , e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500 , "操作失败"+e.getMessage());
}
}
@ApiOperation(value = "人员从业资格证核验 V3", notes = "人员从业资格证核验 V3")
@PostMapping(value = "/queryQualificationInfoV3")
public AjaxResult queryQualificationInfoV3(@RequestBody QueryQualificationInfoDTO queryQualificationInfo) {
try {
CheckTruckExistPo checkTruckExistPo = iZhiYunApplicationService.queryQualificationInfoV3(queryQualificationInfo,recursionCount);
return AjaxResult.success(checkTruckExistPo);
} catch (ServiceException e) {
e.printStackTrace();
return AjaxResult.error(500 ,e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500 , "操作失败"+e.getMessage());
}
}
@ApiOperation(value = "车辆道路运输证核验 V3", notes = "车辆道路运输证核验 V3")
@PostMapping(value = "/vehicleRoadLicenseV3")
public AjaxResult vehicleRoadLicenseV3(@RequestBody CheckRTCNoDTO checkRTCNoDTO) {
try {
CheckRTCNoPo checkRTCNoPo = iZhiYunApplicationService.vehicleRoadLicenseV3(checkRTCNoDTO,recursionCount);
return AjaxResult.success(checkRTCNoPo);
} catch (ServiceException e) {
e.printStackTrace();
return AjaxResult.error(500 , e.getErrorMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println("e:" + e.getMessage());
return AjaxResult.error(500 ,"操作失败"+e.getMessage());
}
}
@ApiOperation(value = "获取智运token", notes = "获取智运token")
@GetMapping(value = "/getTrajectoryToken")
public AjaxResult getTrajectoryToken() {
//TODO 后期考虑加密传输
try {
return AjaxResult.success("操作成功",iZhiYunApplicationService.getTrajectoryToken());
} catch (Exception e) {
e.printStackTrace();
log.error("获取token失败");
return AjaxResult.error(500 ,"操作失败"+e.getMessage());
}
}
}
@@ -0,0 +1,215 @@
package com.linke.thirdParty.interfaces.facade.tuanyou;
import cn.hutool.core.util.ObjectUtil;
import com.aliyun.oss.ServiceException;
import com.linke.thirdParty.application.server.NewLinkApplicationService;
import com.linke.thirdParty.interfaces.vo.tuanyou.GetSecretCodeVO;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* TODO 能链企服-对接接⼝⽂档
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-07 15:46:39
*/
@RestController
@RequestMapping("/newlink")
@Api(tags = "能链企服")
@Slf4j
public class NewLinkApi {
@Autowired
private NewLinkApplicationService newLinkApplicationService;
// /**
// * @description:获取当前企业及⼦企业信息
// * @param
// * @return: org.jeecg.common.api.vo.Result<?>
// * @author: LianZhijian
// * @time: 2023-02-07 16:18:36
// */
// @ApiOperation(value = "获取当前企业及⼦企业信息", notes = "获取当前企业及⼦企业信息")
// @PostMapping(value = "/getAllEnterprise")
// public Result<?> getAllEnterprise() {
// Result<AllEnterpriseVO> result = new Result<>();
// try {
// AllEnterpriseVO allEnterpriseVO = newLinkService.getAllEnterprise();
// result.setResult(allEnterpriseVO);
// } catch (ServiceException e) {
// log.error(e.getErrorMessage());
// result.error500(e.getErrorMessage());
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// result.error500("操作失败"+e.getMessage());
// }
// return result;
// }
//
// /**
// * @description:新增员⼯
// * @param addStaffDTO
// * @return: org.jeecg.common.api.vo.Result<?>
// * @author: LianZhijian
// * @time: 2023-02-08 10:01:44
// */
// @ApiOperation(value = "新增员⼯", notes = "新增员⼯")
// @PostMapping(value = "/addStaff")
// public Result<?> addStaff(AddStaffDTO addStaffDTO) {
// Result<AddStaffVO> result = new Result<>();
// try {
// AddStaffVO addStaffVO = newLinkService.addStaff(addStaffDTO);
// result.setResult(addStaffVO);
// } catch (ServiceException e) {
// log.error(e.getErrorMessage());
// result.error500(e.getErrorMessage());
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// result.error500("操作失败"+e.getMessage());
// }
// return result;
// }
//
// /**
// * @description:修改⽤⼾可⽤额度
// * @param availableAmountDTO
// * @return: org.jeecg.common.api.vo.Result<?>
// * @author: LianZhijian
// * @time: 2023-02-08 10:18:31
// */
// @ApiOperation(value = "修改⽤⼾可⽤额度", notes = "修改⽤⼾可⽤额度")
// @PostMapping(value = "/availableAmount")
// public Result<?> availableAmount(AvailableAmountDTO availableAmountDTO) {
// Result<AvailableAmountVO> result = new Result<>();
// try {
// AvailableAmountVO availableAmountVO = newLinkService.availableAmount(availableAmountDTO);
// result.setResult(availableAmountVO);
// } catch (ServiceException e) {
// log.error(e.getErrorMessage());
// result.error500(e.getErrorMessage());
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// result.error500("操作失败"+e.getMessage());
// }
// return result;
// }
//
// /**
// * @description:修改员⼯⼿机号(根据⽤⼾Id)
// * @param updateMobileDTO
// * @return: org.jeecg.common.api.vo.Result<?>
// * @author: LianZhijian
// * @time: 2023-02-08 10:33:17
// */
// @ApiOperation(value = "修改员⼯⼿机号(根据⽤⼾Id", notes = "修改员⼯⼿机号(根据⽤⼾Id)")
// @PostMapping(value = "/updateMobile")
// public Result<?> updateMobile(UpdateMobileDTO updateMobileDTO) {
// Result<AvailableAmountVO> result = new Result<>();
// try {
// AvailableAmountVO availableAmountVO = newLinkService.updateMobile(updateMobileDTO);
// result.setResult(availableAmountVO);
// } catch (ServiceException e) {
// log.error(e.getErrorMessage());
// result.error500(e.getErrorMessage());
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// result.error500("操作失败"+e.getMessage());
// }
// return result;
// }
//
// /**
// * @description:获取员⼯详情(根据⽤⼾Id或⼿机号)
// * @param getAccountInfoDTO
// * @return: org.jeecg.common.api.vo.Result<?>
// * @author: LianZhijian
// * @time: 2023-02-09 9:43:01
// */
// @ApiOperation(value = "获取员⼯详情(根据⽤⼾Id或⼿机号)", notes = "获取员⼯详情(根据⽤⼾Id或⼿机号)")
// @PostMapping(value = "/getAccountInfo")
// public Result<?> getAccountInfo(GetAccountInfoDTO getAccountInfoDTO) {
// Result<GetAccountInfoVO> result = new Result<>();
// try {
// GetAccountInfoVO getAccountInfoVO = newLinkService.getAccountInfo(getAccountInfoDTO);
// result.setResult(getAccountInfoVO);
// } catch (ServiceException e) {
// log.error(e.getErrorMessage());
// result.error500(e.getErrorMessage());
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// result.error500("操作失败"+e.getMessage());
// }
// return result;
// }
/**
* @description:获取加油网站页面url---获取授权码
*/
@ApiOperation(value = "获取加油网站页面url---获取授权码", notes = "获取加油网站页面url---获取授权码")
@GetMapping(value = "/getSecretCode")
public AjaxResult getSecretCode() {
try {
//获取登录人
LoginUser sysUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(sysUser)) {
return AjaxResult.error("登录信息为空");
}
GetSecretCodeVO getSecretCodeVO = newLinkApplicationService.getSecretCode(sysUser.getUserid().toString());
return AjaxResult.success(getSecretCodeVO);
} catch (ServiceException e) {
log.error(e.getErrorMessage());
return AjaxResult.error(e.getErrorMessage());
} catch (Exception e) {
log.error(e.getMessage(), e);
return AjaxResult.error("操作失败" + e.getMessage());
}
}
// /**
// * @description:获取加油订单消费记录(回调接口)
// */
// @ApiOperation(value = "获取加油订单消费记录(回调接口)", notes = "获取加油订单消费记录(回调接口)")
// @PostMapping(value = "/getOilExpenseRecordInfo")
// public Result<JSONObject> getOilExpenseRecordInfo(@RequestBody JSONObject jsonObject){
// Result<JSONObject> result = new Result<>();
// try {
// newLinkService.getOilExpenseRecordInfo(jsonObject);
// result.setCode(CommonConstant.SC_OK_200);
// result.setSuccess(true);
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// result.error500("操作失败"+e.getMessage());
// }
// return result;
// }
//
// /**
// * @description:⽀付推送
// * @param jsonObject
// * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
// * @author: LianZhijian
// * @time: 2023-02-28 10:13:37
// */
// @ApiOperation(value = "⽀付推送", notes = "⽀付推送")
// @PostMapping(value = "/getOilExpenseRecordPayInfo")
// public Result<JSONObject> getOilExpenseRecordPayInfo(@RequestBody JSONObject jsonObject){
// Result<JSONObject> result = new Result<>();
// try {
// newLinkService.getOilExpenseRecordPayInfo(jsonObject);
// result.setCode(CommonConstant.SC_OK_200);
// result.setSuccess(true);
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// result.error500("操作失败"+e.getMessage());
// }
// return result;
// }
}
@@ -0,0 +1,99 @@
package com.linke.thirdParty.interfaces.facade.userAuthEsign;
import java.util.List;
import com.linke.thirdParty.application.server.userAuthEsign.UserAuthEsignApplicationService;
import io.swagger.annotations.ApiOperation;
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.DeleteMapping;
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.RestController;
import com.linke.thirdParty.interfaces.dto.userAuthEsign.UserAuthEsignDTO;
import com.linke.thirdParty.domain.userAuthEsign.repository.todo.UserAuthEsignDO;
import com.linke.thirdParty.domain.userAuthEsign.repository.po.UserAuthEsignPO;
import com.linke.thirdParty.interfaces.assembler.userAuthEsign.UserAuthEsignAssembler;
import javax.annotation.Resource;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* e签宝用户印章授权Api
*
* @author gen
* @date 2024-12-03
*/
@RestController
@RequestMapping("/userAuthEsignApi")
public class UserAuthEsignApi extends BaseController{
@Autowired
private UserAuthEsignApplicationService userAuthEsignApplicationService;
@Resource
private UserAuthEsignAssembler userAuthEsignAssembler;
/**
* 分页查询e签宝用户印章授权列表
*/
@ApiOperation("查询e签宝用户印章授权列表")
@GetMapping("/list")
public TableDataInfo list(UserAuthEsignDTO userAuthEsignDTO)
{
//转换实体
UserAuthEsignDO userAuthEsignDO = userAuthEsignAssembler.toDO(userAuthEsignDTO);
startPage();
List<UserAuthEsignPO> list = userAuthEsignApplicationService.queryList(userAuthEsignDO);
return getDataTable(list);
}
/**
* 保存e签宝用户印章授权
*/
@ApiOperation("保存e签宝用户印章授权")
@PostMapping("/save")
public AjaxResult save(@RequestBody UserAuthEsignDTO userAuthEsignDTO)
{
//转换实体
UserAuthEsignDO userAuthEsignDO = userAuthEsignAssembler.toDO(userAuthEsignDTO);
if(userAuthEsignDTO.getUserAuthEsignId() != null){
return toAjax(userAuthEsignApplicationService.update(userAuthEsignDO));
}else {
return toAjax(userAuthEsignApplicationService.insert(userAuthEsignDO));
}
}
/**
* 批量删除e签宝用户印章授权
*/
@ApiOperation("批量删除e签宝用户印章授权")
@DeleteMapping("/deleteByIds/{userAuthEsignIds}")
public AjaxResult delete(@PathVariable Long[] userAuthEsignIds)
{
return toAjax(userAuthEsignApplicationService.delete(userAuthEsignIds));
}
/**
* 获取e签宝用户印章授权详细信息
*/
@ApiOperation("获取e签宝用户印章授权")
@GetMapping(value = "/getInfo/{userAuthEsignId}")
public AjaxResult getInfo(@PathVariable("userAuthEsignId") Long userAuthEsignId)
{
return AjaxResult.success(userAuthEsignApplicationService.getInfo(userAuthEsignId));
}
}
@@ -0,0 +1,25 @@
package com.linke.thirdParty.interfaces.vo.tuanyou;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* TODO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-09 9:41:08
*/
@Data
public class AccountDepartmentVO {
@ApiModelProperty(value = "部⻔id")
private Integer id;
@ApiModelProperty(value = "部⻔名称")
private String name;
@ApiModelProperty(value = "部⻔状态 USING:有效,CLOSE:关闭")
private String state;
}
@@ -0,0 +1,26 @@
package com.linke.thirdParty.interfaces.vo.tuanyou;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* TODO 新增员⼯VO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-07 17:12:44
*/
@Data
public class AddStaffVO {
@ApiModelProperty(value = "响应码")
private Integer code;
@ApiModelProperty(value = "返回数据")
private CreateStaffRespVO data;
@ApiModelProperty(value = "响应信息")
private String msg;
}
@@ -0,0 +1,28 @@
package com.linke.thirdParty.interfaces.vo.tuanyou;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* TODO 获取当前企业及⼦企业信息VO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-07 16:06:18
*/
@Data
public class AllEnterpriseVO {
@ApiModelProperty(value = "响应码")
private Integer code;
@ApiModelProperty(value = "返回数据")
private List<EnterpriseDetailVO> data;
@ApiModelProperty(value = "响应信息")
private String msg;
}
@@ -0,0 +1,24 @@
package com.linke.thirdParty.interfaces.vo.tuanyou;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* TODO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-08 10:15:45
*/
@Data
public class AvailableAmountVO {
@ApiModelProperty(value = "响应码")
private Integer code;
@ApiModelProperty(value = "返回数据,此接⼝可忽略")
private String data;
@ApiModelProperty(value = "响应信息")
private String msg;
}
@@ -0,0 +1,18 @@
package com.linke.thirdParty.interfaces.vo.tuanyou;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* TODO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-07 17:14:02
*/
@Data
public class CreateStaffRespVO {
@ApiModelProperty(value = "number")
private Integer userId;
}
@@ -0,0 +1,39 @@
package com.linke.thirdParty.interfaces.vo.tuanyou;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* TODO 当前企业及⼦企业信息VO
*
* @author LianZhijian
* @version 1.0
* @date 2023-02-07 16:46:55
*/
@Data
public class EnterpriseDetailVO {
@ApiModelProperty(value = "企业名称")
private String enterpriseName;
@ApiModelProperty(value = "状态:SUCCESS:认证成功;WAIT:等待认证;FALF:认证失败;NOCERT:未认证成功")
private String state;
@ApiModelProperty(value = "企业ID")
private Integer enterpriseId;
@ApiModelProperty(value = "社会信⽤代码")
private String socialCreditCode;
@ApiModelProperty(value = "法⼈姓名")
private String legalPerson;
@ApiModelProperty(value = "营业执照")
private String licenseUrl;
@ApiModelProperty(value = "⽗企业ID")
private Integer parentId;
@ApiModelProperty(value = "当前企业的appId")
private String settledAppId;
}

Some files were not shown because too many files have changed in this diff Show More