云账房

This commit is contained in:
lvleigang 2025-04-02 14:57:23 +08:00
parent 29113c35f1
commit aecbb8e577
8 changed files with 417 additions and 45 deletions

View File

@ -37,8 +37,12 @@
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>httest</id> <!--开发环境-->
<properties>
<profile.active>httest</profile.active>
</properties>
</profile>
</profiles>
<build>
<finalName>kangarooDataCenterV3</finalName>

View File

@ -6,15 +6,15 @@ logging:
encodings: UTF-8
file:
# 日志保存路径
path: /home/webservice/zt/log
path: D:\yongansystem\serverV3\log\zs
spring:
datasource:
dynamic:
datasource:
master:
url: jdbc:mysql://ufidahz.com.cn:9014/businesscenter_ht?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true
url: jdbc:mysql://127.0.0.1:3307/businesscenter?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true
username: root
password: 62e4295b615a30dbf3b8ee96f41c820b
password: bd993088e8a7c3dc5f44441617f9b4bf
driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置
savefile:
# 文件保存路径
@ -39,7 +39,7 @@ cbs8:
OA:
data_source_code: yc_oa
zt:
url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface
url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface
zx:
# 测试用这个 这个是银行给的
privateKey: MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgtzMo2o6THK3yLIm+83Ch/560+02l2hjjBSFGieWY/Z6gCgYIKoEcz1UBgi2hRANCAATKhwZX4P3XI8vYTKeCOLMVbanUNbaXjrIEZynshwdOzRVgzRQSiPNWo6OBBkAPvqE+2RS+5ABpS82DSlKl81z0

View File

@ -0,0 +1,46 @@
#######################dev环境#######################
logging:
#日志级别 指定目录级别
level:
root: INFO
encodings: UTF-8
file:
# 日志保存路径
path: D:\yongansystem\serverV3\log\test
spring:
datasource:
dynamic:
datasource:
master:
url: jdbc:mysql://127.0.0.1:3307/businesscenter_test?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true
username: root
password: bd993088e8a7c3dc5f44441617f9b4bf
driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置
savefile:
# 文件保存路径
path: /home/webservice/zt/file
# path: D:\webservice\file
# pluginpath: D:\webservice\plugin
pluginpath: /home/webservice/zt/plugin
# tomcatpath: D:\apache-tomcat-9.0.69\webapps\kangarooDataCenter\WEB-INF\classes\
tomcatpath: /home/webservice/zt/tomcatV3/webapps/kangarooDataCenterV3/WEB-INF/classes/
cbs8:
appId: 1P4AGrpz
appSecret: 2c2369ae5dc04382844bbe3a5abf39e1bea9cd3a
url: https://cbs8-openapi-reprd.csuat.cmburl.cn
# 测试用这个 这个是银行给的,和下面的公钥不是一对密钥
ya_private_key: 83BA7EC821D35F4CB31FF9A51C1EFA520FC52AF828C2337F88E91CF119B07F44
# 这个私钥到时候上传到cbs和下面到是同一对
#ya_private_key: e1eacfdee9b8d4184437d5a2071e17ce31befc3d93395f9f05709ed562e8dc46
ya_public_key: 044fa399d2223760f17b81b863cb482b009294c4516f8a605dea1475ec09e720eaa98468715e5ad509a592a0b426061551c5a3df236966c23253a7d894eac0dcde
cbs_public_key: 0469146F06BF3B01236E84632441E826
#电子回单下载临时存放位置
elec_path: /Users/xiangerlin/Downloads/
OA:
data_source_code: yc_oa
zt:
url: http://127.0.0.1:10087/kangarooDataCenterV3/entranceController/externalCallInterface
zx:
# 测试用这个 这个是银行给的
privateKey: MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgtzMo2o6THK3yLIm+83Ch/560+02l2hjjBSFGieWY/Z6gCgYIKoEcz1UBgi2hRANCAATKhwZX4P3XI8vYTKeCOLMVbanUNbaXjrIEZynshwdOzRVgzRQSiPNWo6OBBkAPvqE+2RS+5ABpS82DSlKl81z0
publicKey: MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEyocGV+D91yPL2EyngjizFW2p1DW2l46yBGcp7IcHTs0VYM0UEojzVqOjgQZAD76hPtkUvuQAaUvNg0pSpfNc9A==

View File

@ -2,23 +2,34 @@ package com.hzya.frame;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.seeyon.util.YzfSignUtil;
import com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity;
import com.hzya.frame.util.AESUtil;
import com.hzya.frame.web.entity.BaseResult;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.TrustAllStrategy;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.net.ssl.SSLContext;
import java.io.IOException;
import java.lang.reflect.Method;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -36,7 +47,7 @@ public class temButtom {
@Test
public void test01() {
String a = AESUtil.encrypt("hzya@1314");
String a = AESUtil.encrypt("hzya1314");
System.out.println(a);
String b = AESUtil.decrypt("62e4295b615a30dbf3b8ee96f41c820b");
System.out.println(b);
@ -50,32 +61,31 @@ public class temButtom {
// task7803207f54ff047d6008dcce31c2628f 新增成功!
// 2024-10-24 2024-10-24
String phone ="19357235324";
String taskid ="task8b0c7ca72439bc9b0c1c89e8866c8275";
String phone = "19357235324";
String taskid = "task8b0c7ca72439bc9b0c1c89e8866c8275";
//token
Map<String, String> headers = new HashMap<>();
String token ="https://oapi.dingtalk.com/gettoken?appkey=dingxewtjaserj292ggu&appsecret=DuRw6EEEvhGXfr6Q8wN_x4025qKjrffIGCXF9KeCKKIID-LVSsR6_8KWMei6sug1";
String body = sendGet(token,headers);
String token = "https://oapi.dingtalk.com/gettoken?appkey=dingxewtjaserj292ggu&appsecret=DuRw6EEEvhGXfr6Q8wN_x4025qKjrffIGCXF9KeCKKIID-LVSsR6_8KWMei6sug1";
String body = sendGet(token, headers);
JSONObject tokenobject = JSONObject.parseObject(body);
//钉钉id
headers = new HashMap<>();
//https://oapi.dingtalk.com/user/get_by_mobile?access_token=9abd3996cb103ba48dd8c69fea5473e7&mobile=15700100840
String ddid ="https://oapi.dingtalk.com/user/get_by_mobile?access_token="+tokenobject.get("access_token")+"&mobile="+phone;
String ddidbody = sendGet(ddid,headers);
String ddid = "https://oapi.dingtalk.com/user/get_by_mobile?access_token=" + tokenobject.get("access_token") + "&mobile=" + phone;
String ddidbody = sendGet(ddid, headers);
JSONObject ddidobject = JSONObject.parseObject(ddidbody);
//人员id
headers = new HashMap<>();
//https://oapi.dingtalk.com/user/get?userid=111336474727636213&access_token=3d21a6614fb037a98542a537336e8149
String userid ="https://oapi.dingtalk.com/user/get?userid="+ddidobject.get("userid")+"&access_token="+tokenobject.get("access_token");
String useridbody = sendGet(userid,headers);
String userid = "https://oapi.dingtalk.com/user/get?userid=" + ddidobject.get("userid") + "&access_token=" + tokenobject.get("access_token");
String useridbody = sendGet(userid, headers);
JSONObject useridobject = JSONObject.parseObject(useridbody);
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPut httpPut = new HttpPut("https://api.dingtalk.com/v1.0/todo/users/"+useridobject.get("unionid")+"/tasks/"+taskid);
HttpPut httpPut = new HttpPut("https://api.dingtalk.com/v1.0/todo/users/" + useridobject.get("unionid") + "/tasks/" + taskid);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000).setConnectionRequestTimeout(35000).setSocketTimeout(60000).build();
httpPut.setConfig(requestConfig);
httpPut.setHeader("Content-type", "application/json");
@ -122,7 +132,7 @@ public class temButtom {
response = closeableHttpClient.execute(get);
HttpEntity entity = response.getEntity();
body.append(EntityUtils.toString(entity,"UTF-8"));
body.append(EntityUtils.toString(entity, "UTF-8"));
} catch (Exception e) {
body.append(e.getMessage());
} finally {
@ -143,4 +153,140 @@ public class temButtom {
}
@Test
public void test0111() {
//请求token
String accessToken = getToken();
//请求分页查询全量进项发票
String data = getdata(accessToken);
}
private String getdata(String accessToken) {
String url = "http://oapi.nanofintax.com/api/invoice_receive/fp/v1/query?accessToken="+accessToken;
JSONObject dayabody = new JSONObject();
dayabody.put("accessKey","6X3B526P5HqE6ums");
long timestamp = System.currentTimeMillis();
dayabody.put("timestamp",timestamp);
JSONObject queryParams = new JSONObject();
queryParams.put("page",1);
queryParams.put("size",50);
dayabody.put("queryParams",queryParams);
Map<String, Object> parametersMap = new HashMap<>();
parametersMap.put("accessKey","6X3B526P5HqE6ums");
parametersMap.put("timestamp",timestamp);
String a = YzfSignUtil.signRequest(parametersMap,"34e5fc32ac894a2ba2ade8c3852c7a0a");
dayabody.put("sign",a);
StringBuilder body = new StringBuilder();
SSLContext sslContext = null;
try {
sslContext = new SSLContextBuilder()
.loadTrustMaterial(null, TrustAllStrategy.INSTANCE)
.build();
} catch (Exception e) {
}
CloseableHttpClient closeableHttpClient = HttpClients.custom()
.setSSLContext(sslContext)
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.build();
HttpPost post = new HttpPost(url);
CloseableHttpResponse response = null;
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(6000).build();
post.setConfig(requestConfig);//设置请求参数超时时间
post.setHeader("Content-Type", "application/json; charset=utf-8");
try {
if (dayabody.toJSONString() != null && !"".equals(dayabody.toJSONString())) {
ByteArrayEntity entity = new ByteArrayEntity(dayabody.toJSONString().getBytes("UTF-8"));
entity.setContentType("application/json");
post.setEntity(entity);
}
response = closeableHttpClient.execute(post);
HttpEntity entity = response.getEntity();
body.append(EntityUtils.toString(entity, "UTF-8"));
} catch (Exception e) {
body.append(e.getMessage());
} finally {
try {
// 关闭响应对象
if (response != null) {
response.close();
}
// 关闭响应对象
if (closeableHttpClient != null) {
closeableHttpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println("body"+body);
return body.toString();
}
private String getToken() {
String url = "http://oapi.nanofintax.com/api/getToken";
String bodys = "{\"accessKey\":\"6X3B526P5HqE6ums\",\"accessSecret\":\"34e5fc32ac894a2ba2ade8c3852c7a0a\"}";
StringBuilder body = new StringBuilder();
SSLContext sslContext = null;
try {
sslContext = new SSLContextBuilder()
.loadTrustMaterial(null, TrustAllStrategy.INSTANCE)
.build();
} catch (Exception e) {
}
CloseableHttpClient closeableHttpClient = HttpClients.custom()
.setSSLContext(sslContext)
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.build();
HttpPost post = new HttpPost(url);
CloseableHttpResponse response = null;
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(6000).build();
post.setConfig(requestConfig);//设置请求参数超时时间
post.setHeader("Content-Type", "application/json; charset=utf-8");
try {
if (bodys != null && !"".equals(bodys)) {
ByteArrayEntity entity = new ByteArrayEntity(bodys.getBytes("UTF-8"));
entity.setContentType("application/json");
post.setEntity(entity);
}
response = closeableHttpClient.execute(post);
HttpEntity entity = response.getEntity();
body.append(EntityUtils.toString(entity, "UTF-8"));
} catch (Exception e) {
body.append(e.getMessage());
} finally {
try {
// 关闭响应对象
if (response != null) {
response.close();
}
// 关闭响应对象
if (closeableHttpClient != null) {
closeableHttpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println("body"+body);
String accessToken = JSONObject.parseObject(body.toString()).getJSONObject("result").getString("accessToken");
return accessToken;
}
}

View File

@ -0,0 +1,81 @@
package com.hzya.frame.seeyon.util;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @ClassName YzfObjectUtil
* @Description
* @Author llg
* Date 2025/4/2 2:12 下午
*/
public class YzfObjectUtil {
/**
* 是否为包装类型
*
* @param clazz
* @return 是否为包装类型
*/
public static boolean isPrimitiveWrapper(Class<?> clazz) {
if (null == clazz) {
return false;
}
return BasicType.wrapperPrimitiveMap.containsKey(clazz);
}
/**
* 是否为基本类型包括包装类和原始类
*
* @param clazz
* @return 是否为基本类型
*/
public static boolean isBasicType(Class<?> clazz) {
if (null == clazz) {
return false;
}
return (clazz.isPrimitive() || isPrimitiveWrapper(clazz));
}
/**
* @param clazz
* @return 是否为简单值类型
* 判断是否是基本数据类型String类型other CharSequenceNumberDate
*/
public static boolean isSimpleTypeOrString(Class<?> clazz) {
if(clazz == null) {
return false;
}
return isBasicType(clazz) || clazz.isEnum() || CharSequence.class.isAssignableFrom(clazz)
|| Number.class.isAssignableFrom(clazz) || Date.class.isAssignableFrom(clazz);
}
enum BasicType {
BYTE, SHORT, INT, INTEGER, LONG, DOUBLE, FLOAT, BOOLEAN, CHAR, CHARACTER, STRING;
/**
* 包装类型为Key原始类型为Value例如 Integer.class = int.class.
*/
public static final Map<Class<?>, Class<?>> wrapperPrimitiveMap = new ConcurrentHashMap<>(8);
/**
* 原始类型为Key包装类型为Value例如 int.class = Integer.class.
*/
public static final Map<Class<?>, Class<?>> primitiveWrapperMap = new ConcurrentHashMap<>(8);
static {
wrapperPrimitiveMap.put(Boolean.class, boolean.class);
wrapperPrimitiveMap.put(Byte.class, byte.class);
wrapperPrimitiveMap.put(Character.class, char.class);
wrapperPrimitiveMap.put(Double.class, double.class);
wrapperPrimitiveMap.put(Float.class, float.class);
wrapperPrimitiveMap.put(Integer.class, int.class);
wrapperPrimitiveMap.put(Long.class, long.class);
wrapperPrimitiveMap.put(Short.class, short.class);
for (Map.Entry<Class<?>, Class<?>> entry : wrapperPrimitiveMap.entrySet()) {
primitiveWrapperMap.put(entry.getValue(), entry.getKey());
}
}
}
}

View File

@ -0,0 +1,50 @@
package com.hzya.frame.seeyon.util;
import java.security.MessageDigest;
/**
* @ClassName YzfSHA256Util
* @Description
* @Author llg
* Date 2025/4/2 2:11 下午
*/
public class YzfSHA256Util {
/**
  * 利用java原生的摘要实现SHA256加密
  * @param str 加密后的报文
  * @return
*/
public static String getSHA256StrJava(String str, String charsetName) {
MessageDigest messageDigest;
String encodeStr = "";
try {
messageDigest = MessageDigest.getInstance("SHA-256");
messageDigest.update(str.getBytes(charsetName));
encodeStr = byte2Hex(messageDigest.digest());
} catch (Exception e) {
e.printStackTrace();
}
return encodeStr;
}
/**
  * 将byte转为16进制
  * @param bytes
  * @return
*/
private static String byte2Hex(byte[] bytes) {
StringBuffer stringBuffer = new StringBuffer();
String temp = null;
for (int i = 0; i < bytes.length; i++) {
temp = Integer.toHexString(bytes[i] & 0xFF);
if (temp.length() == 1) {
//1得到一位的进行补0操作
stringBuffer.append("0");
}
stringBuffer.append(temp);
}
return stringBuffer.toString();
}
}

View File

@ -0,0 +1,45 @@
package com.hzya.frame.seeyon.util;
import org.apache.commons.lang.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
/**
* @ClassName YzfSignUtil
* @Description
* @Author llg
* Date 2025/4/2 2:14 下午
*/
public class YzfSignUtil {
private static final String CHARSET = "utf-8";
public static String signRequest(Map<String, Object> parametersMap, String secretkey) {
ArrayList<String> list = new ArrayList<>();
for (Map.Entry<String, Object> entry : parametersMap.entrySet()) {
String key = entry.getKey();
Object val = entry.getValue();
if (StringUtils.isBlank(key) || val == null) {
continue;
}
if (YzfObjectUtil.isSimpleTypeOrString(val.getClass())) {
if (null != val && !"".equals(val)) {
list.add(key + "=" + val + "&");
}
}
}
int size = list.size();
String[] arrayToSort = list.toArray(new String[size]);
Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < size; i++) {
sb.append(arrayToSort[i]);
}
String result = sb.toString();
result += secretkey;
result = YzfSHA256Util.getSHA256StrJava(result, CHARSET);
return result;
}
}

54
pom.xml
View File

@ -471,33 +471,33 @@
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${basedir}/../base-service/src/main/webapp/WEB-INF/lib</directory>
<targetPath>WEB-INF/lib/</targetPath>
<filtering>false</filtering>
<includes>
<!-- 匹配所有jar包 -->
<include>**/*.jar</include>
</includes>
</resource>
<resource>
<directory>${basedir}/../fw-bip/src/main/webapp/WEB-INF/lib</directory>
<targetPath>WEB-INF/lib/</targetPath>
<filtering>false</filtering>
<includes>
<!-- 匹配所有jar包 -->
<include>**/*.jar</include>
</includes>
</resource>
<resource>
<directory>${basedir}/../fw-ningbobank/src/main/webapp/WEB-INF/lib</directory>
<targetPath>WEB-INF/lib/</targetPath>
<filtering>false</filtering>
<includes>
<!-- 匹配所有jar包 -->
<include>**/*.jar</include>
</includes>
</resource>
<!-- <resource>-->
<!-- <directory>${basedir}/../base-service/src/main/webapp/WEB-INF/lib</directory>-->
<!-- <targetPath>WEB-INF/lib/</targetPath>-->
<!-- <filtering>false</filtering>-->
<!-- <includes>-->
<!-- &lt;!&ndash; 匹配所有jar包 &ndash;&gt;-->
<!-- <include>**/*.jar</include>-->
<!-- </includes>-->
<!-- </resource>-->
<!-- <resource>-->
<!-- <directory>${basedir}/../fw-bip/src/main/webapp/WEB-INF/lib</directory>-->
<!-- <targetPath>WEB-INF/lib/</targetPath>-->
<!-- <filtering>false</filtering>-->
<!-- <includes>-->
<!-- &lt;!&ndash; 匹配所有jar包 &ndash;&gt;-->
<!-- <include>**/*.jar</include>-->
<!-- </includes>-->
<!-- </resource>-->
<!-- <resource>-->
<!-- <directory>${basedir}/../fw-ningbobank/src/main/webapp/WEB-INF/lib</directory>-->
<!-- <targetPath>WEB-INF/lib/</targetPath>-->
<!-- <filtering>false</filtering>-->
<!-- <includes>-->
<!-- &lt;!&ndash; 匹配所有jar包 &ndash;&gt;-->
<!-- <include>**/*.jar</include>-->
<!-- </includes>-->
<!-- </resource>-->
</webResources>
</configuration>
</plugin>