Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a604f1400 | ||
|
|
7bda8ac460 | ||
|
|
b6a2334607 |
@@ -17,11 +17,6 @@
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>junitperf</artifactId>
|
||||
<version>2.0.7</version>
|
||||
</dependency>
|
||||
<!--工行SDK-->
|
||||
<dependency>
|
||||
<groupId>com.icbc</groupId>
|
||||
@@ -99,18 +94,11 @@
|
||||
<artifactId>rhro_sfk</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.75</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alibaba</groupId>-->
|
||||
<!-- <artifactId>druid</artifactId>-->
|
||||
<!-- <version>1.2.4</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package ctg.annotation;
|
||||
|
||||
import ctg.enums.ApiFormat;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 1:58 下午 2021/2/9
|
||||
*/
|
||||
|
||||
@Documented
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Api {
|
||||
String value() default "";
|
||||
ApiFormat format() default ApiFormat.Xml;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package ctg.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 1:58 下午 2021/2/9
|
||||
*/
|
||||
|
||||
@Documented
|
||||
@Target({ElementType.FIELD,ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ApiItem {
|
||||
String rewrite() default "";
|
||||
boolean required() default true;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package ctg.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 1:58 下午 2021/2/9
|
||||
*/
|
||||
|
||||
@Documented
|
||||
@Target({ElementType.TYPE,ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ApiNode {
|
||||
String value() default "";
|
||||
// String node() default "body";
|
||||
boolean flat() default false;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package ctg.entity;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 3:02 下午 2021/2/7
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class RequestDiskHeader {
|
||||
private final static String deliStr = "##";
|
||||
|
||||
/** 总笔数 */
|
||||
private String totalCount ;
|
||||
|
||||
/** 总金额 分为单位 */
|
||||
private String totalAmount;
|
||||
|
||||
/** 支付地抬头ID */
|
||||
private String titleId;
|
||||
|
||||
/** 客户ID */
|
||||
private String customerId;
|
||||
|
||||
/** 附言 */
|
||||
private String postscript;
|
||||
|
||||
public String toLine()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(totalCount).append(deliStr)
|
||||
.append(totalAmount).append(deliStr)
|
||||
.append(titleId).append(deliStr)
|
||||
.append(customerId).append(deliStr)
|
||||
.append(postscript).append("\n");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package ctg.entity;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 3:01 下午 2021/2/7
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class RequestDiskRow {
|
||||
private final static String deliStr = "##";
|
||||
|
||||
private String acctNo ;
|
||||
private String acctName ;
|
||||
private String refId ;
|
||||
private String amount ;
|
||||
@Builder.Default
|
||||
private String bankCode = "";
|
||||
@Builder.Default
|
||||
private String bankCity = "";
|
||||
@Builder.Default
|
||||
private String bankName = "";
|
||||
@Builder.Default
|
||||
private String bankNo = "";
|
||||
@Builder.Default
|
||||
private String remark = "";
|
||||
|
||||
public String toLine()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(acctNo).append(deliStr)
|
||||
.append(acctName).append(deliStr)
|
||||
.append(refId).append(deliStr)
|
||||
.append(amount).append(deliStr)
|
||||
.append(bankCode).append(deliStr)
|
||||
.append(bankCity).append(deliStr)
|
||||
.append(bankName).append(deliStr)
|
||||
.append(bankNo).append(deliStr)
|
||||
.append(remark).append("\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package ctg.entity.api;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import ctg.annotation.ApiItem;
|
||||
import ctg.annotation.ApiNode;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 下午2:44 2021/2/24
|
||||
*/
|
||||
|
||||
|
||||
@Data
|
||||
public class Api<T> extends ApiWrapper{
|
||||
|
||||
@ApiNode("head")
|
||||
private Head head;
|
||||
|
||||
@ApiNode("body")
|
||||
private T body;
|
||||
|
||||
public Api(String serviceName, T obj) {
|
||||
this.head = new Head();
|
||||
this.head.serviceName = serviceName;
|
||||
this.body = obj;
|
||||
}
|
||||
|
||||
@Data
|
||||
public class Head{
|
||||
|
||||
@ApiItem
|
||||
protected String version = "1.0";
|
||||
|
||||
@ApiItem
|
||||
protected String serviceName;
|
||||
|
||||
@ApiItem
|
||||
protected String requestId = IdUtil.simpleUUID();
|
||||
|
||||
@ApiItem
|
||||
protected String requestTime = DateUtil.now().replaceAll("[ |T|:|-]","");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package ctg.entity.api;
|
||||
|
||||
import ctg.annotation.ApiItem;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 下午2:44 2021/2/24
|
||||
*/
|
||||
public class ApiResponse<T> {
|
||||
|
||||
@ApiItem
|
||||
private String requestId;
|
||||
@ApiItem
|
||||
private String respCode;
|
||||
@ApiItem
|
||||
private String respMessage;
|
||||
@ApiItem
|
||||
private String respTime;
|
||||
|
||||
private T body;
|
||||
}
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
package ctg.entity.api;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import ctg.annotation.ApiItem;
|
||||
import ctg.annotation.ApiNode;
|
||||
import ctg.constant.PropConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 下午4:55 2021/2/22
|
||||
*/
|
||||
@Slf4j
|
||||
public class ApiWrapper implements Serializable {
|
||||
private String iterate(Object obj) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Class clazz = obj.getClass();
|
||||
|
||||
for(Field field : clazz.getDeclaredFields())
|
||||
{
|
||||
if(field.isAnnotationPresent(ApiNode.class)){
|
||||
ApiNode apiNode = field.getDeclaredAnnotation(ApiNode.class);
|
||||
String methodName = "get" + field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1, field.getName().length());
|
||||
Method method = clazz.getDeclaredMethod(methodName);
|
||||
sb.append("<").append(apiNode.value()).append(">");
|
||||
|
||||
Object node = method.invoke(obj);
|
||||
if(null == node) {
|
||||
throw new NullPointerException("object is null:[" + method.getName() + "]");
|
||||
}
|
||||
sb.append(iterate(node));
|
||||
sb.append("</").append(apiNode.value()).append(">");
|
||||
}
|
||||
else if(field.isAnnotationPresent(ApiItem.class))
|
||||
{
|
||||
ApiItem apiItem = field.getAnnotation(ApiItem.class);
|
||||
|
||||
if(!apiItem.rewrite().trim().isEmpty()) {
|
||||
String value = apiItem.rewrite();
|
||||
sb.append("<").append(field.getName()).append(">").append(value).append("</").append(field.getName()).append(">");
|
||||
}
|
||||
else
|
||||
{
|
||||
String methodName = "get" + field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1, field.getName().length());
|
||||
|
||||
Method method = clazz.getDeclaredMethod(methodName);
|
||||
|
||||
Object item = method.invoke(obj);
|
||||
|
||||
if(null == item || ((String)item).isEmpty()) {
|
||||
if(!apiItem.required()) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
sb.append("<").append(field.getName()).append(">").append("</").append(field.getName()).append(">");
|
||||
}
|
||||
}
|
||||
else {
|
||||
sb.append("<").append(field.getName()).append(">").append((String)item).append("</").append(field.getName()).append(">");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String toData() throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if(ObjectUtil.isNull(this)) {
|
||||
System.err.println("object is null:[" + "]");
|
||||
throw new NullPointerException("object is null:[" + "]");
|
||||
}
|
||||
|
||||
sb.append("<root>");
|
||||
sb.append(iterate(this));
|
||||
sb.append("</root>");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String signature() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
|
||||
String data = this.toData();
|
||||
String md5 = SecureUtil.md5(data);
|
||||
log.debug("md5 + secretKey:{}",(md5 + PropConstants.secretKey ));
|
||||
String signature = Base64.getEncoder().encodeToString(SecureUtil.sha256().digest(( md5 + PropConstants.secretKey).getBytes()));
|
||||
return signature;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package ctg.entity.api;
|
||||
|
||||
import ctg.annotation.ApiItem;
|
||||
import ctg.annotation.ApiNode;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 1:40 下午 2021/2/7
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class DiskApplyRequest{
|
||||
|
||||
@ApiItem
|
||||
private String applyDate;
|
||||
@ApiItem
|
||||
private String diskNo;
|
||||
@ApiItem
|
||||
private String diskDesc = "";
|
||||
@ApiItem
|
||||
private String filePath;
|
||||
@ApiItem(required = false)
|
||||
private String fileVersion;
|
||||
@ApiItem
|
||||
private String customerId;
|
||||
@ApiItem
|
||||
private String titleId;
|
||||
@ApiItem
|
||||
private String md5;
|
||||
|
||||
/**
|
||||
* 总金额
|
||||
*/
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/**
|
||||
* 总笔数数
|
||||
*/
|
||||
private int totalCount;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package ctg.entity.api;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 1:40 下午 2021/2/7
|
||||
*/
|
||||
public class DiskApplyResponse {
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package ctg.entity.api;
|
||||
|
||||
import ctg.annotation.Api;
|
||||
import ctg.annotation.ApiItem;
|
||||
import ctg.annotation.ApiNode;
|
||||
import ctg.enums.ApiFormat;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 1:40 下午 2021/2/7
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class DiskResultRequest{
|
||||
@ApiItem
|
||||
private String applyDate;
|
||||
|
||||
@ApiItem
|
||||
private String diskNo;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package ctg.entity.api;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 1:40 下午 2021/2/7
|
||||
*/
|
||||
@Data
|
||||
public class DiskResultResponse{
|
||||
private String diskSts ;
|
||||
private String diskMessage ;
|
||||
private String lastDate ;
|
||||
private String lastTime ;
|
||||
private String totalCount ;
|
||||
private String totalAmount ;
|
||||
private String succCount ;
|
||||
private String succAmount ;
|
||||
private String failCount ;
|
||||
private String failAmount ;
|
||||
private String filePath ;
|
||||
private String md5 ;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package ctg.entity.api;
|
||||
|
||||
import ctg.annotation.ApiItem;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 1:42 下午 2021/2/7
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class ResponseHead {
|
||||
@ApiItem
|
||||
private String requestId;
|
||||
@ApiItem
|
||||
private String respCode;
|
||||
@ApiItem
|
||||
private String respMessage;
|
||||
@ApiItem
|
||||
private String respTime;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package ctg.enums;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 2:41 下午 2021/2/9
|
||||
*/
|
||||
public enum ApiFormat {
|
||||
Xml,
|
||||
Json;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package ctg.enums;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 2:41 下午 2021/2/9
|
||||
*/
|
||||
public enum ApiType {
|
||||
Xml,
|
||||
Json;
|
||||
}
|
||||
@@ -1,465 +0,0 @@
|
||||
package ctg.tool;
|
||||
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.db.Db;
|
||||
import cn.hutool.db.Entity;
|
||||
import ctg.entity.RequestDiskRow;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 2:58 下午 2021/2/7
|
||||
*/
|
||||
public class DataFactory {
|
||||
private static Random random = new Random();
|
||||
|
||||
|
||||
/**
|
||||
* 生成批付文件中的行
|
||||
* @param totalCount 总比数
|
||||
* @param totalAmount 总金额
|
||||
* @return
|
||||
*/
|
||||
public static ArrayList<RequestDiskRow> newSimpleRows(int totalCount, BigDecimal totalAmount)
|
||||
{
|
||||
if(totalCount <=0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ArrayList list = new ArrayList(totalCount);
|
||||
|
||||
String[] amounts = randomAmounts(totalCount,totalAmount.multiply(new BigDecimal("100.00")).toBigInteger().intValue(),1);
|
||||
|
||||
for(int i=0;i<totalCount;i++) {
|
||||
|
||||
int rand = RandomUtil.randomInt(0,3);
|
||||
|
||||
switch (rand)
|
||||
{
|
||||
/** 招行测试数据 */
|
||||
case 0: {
|
||||
Pair<String,String> card = randomCmbCard();
|
||||
list.add(RequestDiskRow.builder().acctName(card.getValue()).acctNo(card.getKey()).amount(amounts[i]).refId(randomRefId()).build());
|
||||
break;
|
||||
}
|
||||
/** 工行测试数据 */
|
||||
case 1: {
|
||||
Pair<String,String> card = randomIcbcCard();
|
||||
list.add(RequestDiskRow.builder().acctName(card.getValue()).acctNo(card.getKey()).amount(amounts[i]).refId(randomRefId()).build());
|
||||
break;
|
||||
}
|
||||
/** 假数据 */
|
||||
default: {
|
||||
list.add(RequestDiskRow.builder().acctName(randomCardName()).acctNo(randomCardNo()).amount(amounts[i]).refId(randomRefId()).build());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成工行 & 招行测试用的卡号 + 姓名
|
||||
* @return
|
||||
*/
|
||||
public static final Pair<String,String> randomCmbCard(){
|
||||
return cmbCards.get(RandomUtil.randomInt(0,cmbCards.size()));
|
||||
}
|
||||
|
||||
public static final Pair<String,String> randomIcbcCard(){
|
||||
return icbcCards.get(RandomUtil.randomInt(0,icbcCards.size()));
|
||||
}
|
||||
|
||||
public static final ArrayList<Pair<String,String>> icbcCards = new ArrayList(){{
|
||||
add(new Pair<>("6212260200197040005", "音偏漾"));
|
||||
add(new Pair<>("6212260200183550975", "逾涛胞"));
|
||||
add(new Pair<>("6212260200109024410", "鹅襄"));
|
||||
add(new Pair<>("6212260200174584017", "音沐"));
|
||||
add(new Pair<>("6212253602021170727", "便昊瞻"));
|
||||
add(new Pair<>("6222000200129694436", "梳菩希"));
|
||||
add(new Pair<>("6222000200125079806", "粘含"));
|
||||
add(new Pair<>("6212250200012590947", "杉盒墅"));
|
||||
add(new Pair<>("6222000200129452678", "捐练祈"));
|
||||
}};
|
||||
|
||||
public static final ArrayList<Pair<String,String>> cmbCards = new ArrayList(){{
|
||||
add(new Pair("6225880280120198","喵星人"));
|
||||
add(new Pair<>("6214831150131511","吴极客"));
|
||||
}};
|
||||
|
||||
public static final String randomCardNo() {
|
||||
int index = random.nextInt(cards.length - 1);
|
||||
return cards[index];
|
||||
}
|
||||
|
||||
public static String randomRefId() {
|
||||
return String.valueOf(IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
}
|
||||
|
||||
public static String randomAmount()
|
||||
{
|
||||
return String.valueOf(random.nextInt(500000000));
|
||||
}
|
||||
|
||||
public static int newAmount(int remaining) {
|
||||
int amount = random.nextInt(remaining);
|
||||
return amount;
|
||||
}
|
||||
|
||||
public static String randomPostscript
|
||||
() { return postscripts[random.nextInt(postscripts.length - 1)]; }
|
||||
|
||||
public static String randomCustomerId() throws SQLException {
|
||||
String customerId = "";
|
||||
|
||||
List<Entity> rs = Db.use().query("SELECT CUSTOMER_ID FROM CAPCUSINF WHERE ENABLED = 'Y'",new HashMap());
|
||||
|
||||
if(rs.size() > 0){
|
||||
customerId = rs.get(random.nextInt(rs.size())).getStr("CUSTOMER_ID");
|
||||
// System.out.println("rs.customerId:" + customerId);
|
||||
}
|
||||
else{
|
||||
customerId = customers[random.nextInt(customers.length - 1)];
|
||||
}
|
||||
return customerId;
|
||||
}
|
||||
|
||||
|
||||
public static String randomTitleId() throws SQLException {
|
||||
String titleId = "";
|
||||
|
||||
List<Entity> rs = null;
|
||||
|
||||
rs = Db.use().query("SELECT TITLE_ID FROM CAPACCOUNTINF where ENABLED = 'Y'",new HashMap());
|
||||
|
||||
if(rs.size() > 0){
|
||||
titleId = rs.get(random.nextInt(rs.size())).getStr("TITLE_ID");
|
||||
// System.out.println("rs.titleId:" + titleId);
|
||||
}
|
||||
else{
|
||||
titleId = titles[random.nextInt(titles.length - 1)];
|
||||
}
|
||||
return titleId;
|
||||
|
||||
}
|
||||
|
||||
private final static String[] customers = new String[]{
|
||||
"000001",
|
||||
"000002",
|
||||
"000003"
|
||||
};
|
||||
|
||||
private final static String[] titles = new String[]{
|
||||
"300001",
|
||||
"300002",
|
||||
"300003"};
|
||||
|
||||
private final static String[] postscripts = new String[]{
|
||||
"工资","奖金","报销","劳务费","经济补偿金","伤残补助金","生育报销","待通知金","偶然所得","抚恤金"
|
||||
};
|
||||
private final static String[] cards = new String[]{
|
||||
"4386008704112464",
|
||||
"9843015318617529",
|
||||
"62249218592118649",
|
||||
"40551273730137710",
|
||||
"6221275304113991962",
|
||||
"6224985942356585978",
|
||||
"6222617585390942463",
|
||||
"5240941256854625",
|
||||
"62231052944366295",
|
||||
"62234048559304024",
|
||||
"4315028126508673",
|
||||
"4427297397639203",
|
||||
"9558882675887507",
|
||||
"62232701082437503",
|
||||
"1030006160414690703",
|
||||
"4427301436986912",
|
||||
"62231095539938853",
|
||||
"6223434670390454294",
|
||||
"6225108994727636757",
|
||||
"6225983081555081",
|
||||
"6222613322012417714",
|
||||
"6226172456450255",
|
||||
"62233687358441031",
|
||||
"6226316174364104",
|
||||
"6224923897136933",
|
||||
"6226600119012328",
|
||||
"6223418215508427",
|
||||
"6225109332436819977",
|
||||
"6223437230428951378",
|
||||
"9558823019328741",
|
||||
"6223235663599536467",
|
||||
"6224991977285935730",
|
||||
"6222611120223989188",
|
||||
"6223160199119843",
|
||||
"438589762527571059",
|
||||
"8705000079762333",
|
||||
"4315022988589673",
|
||||
"6223388632274957350",
|
||||
"1857208468827978",
|
||||
"4340617967353592",
|
||||
"6223453954334367143",
|
||||
"4720670431032979",
|
||||
"62231171877033142",
|
||||
"6225982603166013",
|
||||
"6225066170989849475",
|
||||
"6223050402788817",
|
||||
"4720670120116380",
|
||||
"9558823830960516",
|
||||
"6226225493164899",
|
||||
"6223192255856679",
|
||||
"6223226028305513",
|
||||
"6224912006906278",
|
||||
"6223076388587170564",
|
||||
"6223351184389919",
|
||||
"6226337696054767",
|
||||
"9843015897935524",
|
||||
"9558819262310154",
|
||||
"9558812017649679",
|
||||
"4682037086384012",
|
||||
"6223166359794895",
|
||||
"4792292557145411",
|
||||
"6226784910485121",
|
||||
"4041715461917672",
|
||||
"6222456773142925",
|
||||
"5201316696394945",
|
||||
"4258626630447434",
|
||||
"6222527272094104",
|
||||
"3568904165892531",
|
||||
"4357451316021878",
|
||||
"6226781502650419",
|
||||
"6226589163426346",
|
||||
"4357442124279584",
|
||||
"4062529276206864",
|
||||
"6223213200013172",
|
||||
"6226551501123878",
|
||||
"6225819947839337",
|
||||
"5149574241872345",
|
||||
"4009385020710446",
|
||||
"4249025751399254",
|
||||
"5201690689695660",
|
||||
"5525879870822154",
|
||||
"5201084453450736",
|
||||
"5324587644375606",
|
||||
"5201692373664713",
|
||||
"5124665122689565",
|
||||
"4062548950050927",
|
||||
"5528017546514890",
|
||||
"4041732088428249",
|
||||
"4041712855783471",
|
||||
"4062547100772125",
|
||||
"3568895778802083",
|
||||
"4984517333944614",
|
||||
"4026733053970669",
|
||||
"5402978091790527",
|
||||
"4357452873273548",
|
||||
"5522884610500790",
|
||||
"4367482505987361",
|
||||
"6222517213696554",
|
||||
"5588097736091856",
|
||||
"5274144695527717",
|
||||
"4910324530476626",
|
||||
"5488446170650258",
|
||||
"5488442740532084",
|
||||
"4518102560628993",
|
||||
"5456199852397627",
|
||||
"6227506407600097",
|
||||
"5459473118226681",
|
||||
"4910325480725128",
|
||||
"5482595130517811",
|
||||
"4033611707045883",
|
||||
"4391885884392088",
|
||||
"6227509163790508",
|
||||
"4580717818338450",
|
||||
"4391886976436544",
|
||||
"4381255936183772",
|
||||
"5201521665038304",
|
||||
"4270104709788926",
|
||||
"5583604870359000",
|
||||
"4518042709565666",
|
||||
"4367688821593655",
|
||||
"4381266120937766",
|
||||
"5240478346281634",
|
||||
"4270206095387120",
|
||||
"5525994470729186",
|
||||
"4910325008575443",
|
||||
"6223497736660958",
|
||||
"5488442745158430",
|
||||
"6225004011817424",
|
||||
"5378303173084014",
|
||||
"5309807403661304",
|
||||
"5183643423875827",
|
||||
"4518105242408932",
|
||||
"4392257527193282",
|
||||
"4270298264677928",
|
||||
"6225007398018128",
|
||||
"6223478363752094",
|
||||
"4910404668267763",
|
||||
"5289318464854014",
|
||||
"4518100090689865",
|
||||
"5459475410983794",
|
||||
"9988002446337274",
|
||||
"6226305549870036",
|
||||
"9558824121303242",
|
||||
"6223057225815347",
|
||||
"4386005612410287",
|
||||
"6226222287684224",
|
||||
"1030000726548105507",
|
||||
"6223165274910453",
|
||||
"6223234755426774575",
|
||||
"6226921993916990",
|
||||
"1857203180318356",
|
||||
"8880008609586525",
|
||||
"6227006170404166009",
|
||||
"6222803729013494452",
|
||||
"6225980984265685",
|
||||
"6223486817999005",
|
||||
"622292384950941472",
|
||||
"6226154433191350",
|
||||
"6226308609744927",
|
||||
"6223252686599965",
|
||||
"6226989235246864",
|
||||
"6226315364035805",
|
||||
"6226924354312957",
|
||||
"622331121493374784",
|
||||
"4427293742040759",
|
||||
"6225803180076799",
|
||||
"6223242736822750591",
|
||||
"9558809266517375",
|
||||
"4336700211358470",
|
||||
"6222615188715415091",
|
||||
"6223123335184501",
|
||||
"6224919916945650",
|
||||
"6223285936394507787",
|
||||
"9558828996633930",
|
||||
"4340612371147193",
|
||||
"8701003818530478",
|
||||
"6223410074092270",
|
||||
"4427299996820101",
|
||||
"6227005520984333778",
|
||||
"8705007731518151",
|
||||
"6223392026205400",
|
||||
"6222607337440160627",
|
||||
"4026583347903103",
|
||||
"6225800938955811",
|
||||
"8701007476924006",
|
||||
"6224925409053324",
|
||||
"6226307585993920",
|
||||
"5264109147096266",
|
||||
"6223399787696123",
|
||||
"6226602718801911",
|
||||
"438589583329019216",
|
||||
"6226904359022603",
|
||||
"4340616703135248",
|
||||
"4026581250647808",
|
||||
"4427295109773880",
|
||||
"6225099304110017543",
|
||||
"6223333453435649",
|
||||
"94005652586006708",
|
||||
"6226601557827409",
|
||||
"6224985974044573702",
|
||||
"6223438112672689962",
|
||||
"6226818020801824298",
|
||||
"6226920625022441",
|
||||
"6223450061115365578",
|
||||
"6226925495683222",
|
||||
"6223127247481301",
|
||||
"6224987917149806624",
|
||||
"6223351946631319",
|
||||
"62231096270216434",
|
||||
"6227002362389092029",
|
||||
"62230850883263402",
|
||||
"6226170530609870",
|
||||
"9558811049452169",
|
||||
"6225096515560436494",
|
||||
"6223169645545410",
|
||||
"6223129466891145",
|
||||
"1030001094519248767",
|
||||
"62234072298103885",
|
||||
"6223129638985536"
|
||||
};
|
||||
|
||||
private final static String[] Surname = {"赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈", "褚", "卫", "蒋", "沈", "韩", "杨", "朱", "秦", "尤", "许",
|
||||
"何", "吕", "施", "张", "孔", "曹", "严", "华", "金", "魏", "陶", "姜", "戚", "谢", "邹", "喻", "柏", "水", "窦", "章", "云", "苏", "潘", "葛", "奚", "范", "彭", "郎",
|
||||
"鲁", "韦", "昌", "马", "苗", "凤", "花", "方", "俞", "任", "袁", "柳", "酆", "鲍", "史", "唐", "费", "廉", "岑", "薛", "雷", "贺", "倪", "汤", "滕", "殷",
|
||||
"罗", "毕", "郝", "邬", "安", "常", "乐", "于", "时", "傅", "皮", "卞", "齐", "康", "伍", "余", "元", "卜", "顾", "孟", "平", "黄", "和",
|
||||
"穆", "萧", "尹", "姚", "邵", "湛", "汪", "祁", "毛", "禹", "狄", "米", "贝", "明", "臧", "计", "伏", "成", "戴", "谈", "宋", "茅", "庞", "熊", "纪", "舒",
|
||||
"屈", "项", "祝", "董", "梁", "杜", "阮", "蓝", "闵", "席", "季"};
|
||||
private final static String girl = "秀娟英华慧巧美娜静淑惠珠翠雅芝玉萍红娥玲芬芳燕彩春菊兰凤洁梅琳素云莲真环雪荣爱妹霞香月莺媛艳瑞凡佳嘉琼勤珍贞莉桂娣叶璧璐娅琦晶妍茜秋珊莎锦黛青倩婷姣婉娴瑾颖露瑶怡婵雁蓓纨仪荷丹蓉眉君琴蕊薇菁梦岚苑婕馨瑗琰韵融园艺咏卿聪澜纯毓悦昭冰爽琬茗羽希宁欣飘育滢馥筠柔竹霭凝晓欢霄枫芸菲寒伊亚宜可姬舒影荔枝思丽 ";
|
||||
private final static String boy = "伟刚勇毅俊峰强军平保东文辉力明永健世广志义兴良海山仁波宁贵福生龙元全国胜学祥才发武新利清飞彬富顺信子杰涛昌成康星光天达安岩中茂进林有坚和彪博诚先敬震振壮会思群豪心邦承乐绍功松善厚庆磊民友裕河哲江超浩亮政谦亨奇固之轮翰朗伯宏言若鸣朋斌梁栋维启克伦翔旭鹏泽晨辰士以建家致树炎德行时泰盛雄琛钧冠策腾楠榕风航弘";
|
||||
|
||||
|
||||
private static final String randomCardName()
|
||||
{
|
||||
int index = random.nextInt(Surname.length - 1);
|
||||
String name = Surname[index]; //获得一个随机的姓氏
|
||||
int i = random.nextInt(3);//可以根据这个数设置产生的男女比例
|
||||
if(i==2){
|
||||
int j = random.nextInt(girl.length()-2);
|
||||
if (j % 2 == 0) {
|
||||
// name = "女-" + name + girl.substring(j, j + 2);
|
||||
name = name + girl.substring(j, j + 2);
|
||||
} else {
|
||||
// name = "女-" + name + girl.substring(j, j + 1);
|
||||
name = name + girl.substring(j, j + 1);
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
int j = random.nextInt(girl.length()-2);
|
||||
if (j % 2 == 0) {
|
||||
// name = "男-" + name + boy.substring(j, j + 2);
|
||||
name = name + boy.substring(j, j + 2);
|
||||
} else {
|
||||
// name = "男-" + name + boy.substring(j, j + 1);
|
||||
name = name + boy.substring(j, j + 1);
|
||||
}
|
||||
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public static String[] randomAmounts(int count, BigDecimal totalAmount)
|
||||
{
|
||||
String[] amounts = new String[count];
|
||||
|
||||
|
||||
return amounts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成金额集合
|
||||
* @param num 总笔数
|
||||
* @param totalMoney 总金额(以分为单位)
|
||||
* @param minMoney 最小金额
|
||||
* @return
|
||||
*/
|
||||
private static String[] randomAmounts(int num, long totalMoney, long minMoney){
|
||||
String[] amounts = new String[num];
|
||||
long[] each = new long[num];
|
||||
for(int i=0;i<num-1;i++){
|
||||
//计算最大安全值,保证不会超出 。如果安全值越大,价格波动越大 .建议是平均值
|
||||
double maxSafeMoney = (totalMoney - (num-1-i) * minMoney) / (num-1-i);
|
||||
//随机算出最小值,保证不低于最小值
|
||||
each[i] = (long) (Math.random() * (maxSafeMoney - minMoney) + minMoney);
|
||||
amounts[i] = String.valueOf(each[i]);
|
||||
//计算当前剩下的钱
|
||||
totalMoney = totalMoney - each[i];
|
||||
}
|
||||
each[num-1] = totalMoney;
|
||||
amounts[num-1] = String.valueOf(each[num-1]);
|
||||
return amounts;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
package ctg.tool;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import ctg.entity.RequestDiskHeader;
|
||||
import ctg.entity.RequestDiskRow;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 2:54 下午 2021/2/7
|
||||
*/
|
||||
public class DiskTool {
|
||||
|
||||
/**
|
||||
* 生成送盘文件
|
||||
* @param totalCount 总比数
|
||||
* @param totalAmount 总金额(元为单位)
|
||||
* @return 送盘文件
|
||||
* @throws IOException
|
||||
*/
|
||||
public static File newSimpleDiskFile(String customerId, String titleId, String postscript, int totalCount, BigDecimal totalAmount) throws IOException {
|
||||
// File disk = File.createTempFile("SEND_",".txt",new File("/tmp"));
|
||||
File disk = new File("/tmp/" + IdUtil.simpleUUID());
|
||||
FileWriter writer = new FileWriter(disk);
|
||||
|
||||
|
||||
ArrayList<RequestDiskRow> list = DataFactory.newSimpleRows(totalCount,totalAmount);
|
||||
|
||||
/** head line */
|
||||
writer.write(RequestDiskHeader.builder()
|
||||
.customerId(customerId)
|
||||
.totalAmount(String.valueOf(totalAmount.multiply(new BigDecimal("100.00")).toBigInteger().intValue()))
|
||||
.totalCount(String.valueOf(totalCount))
|
||||
.postscript(postscript)
|
||||
.titleId(titleId).build().toLine());
|
||||
|
||||
/* body */
|
||||
for( RequestDiskRow row:list) {
|
||||
writer.write(row.toLine());
|
||||
}
|
||||
|
||||
writer.close();
|
||||
|
||||
return disk;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String aa = " ";
|
||||
// System.out.println("aa.isEmpty():" + aa.trim().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package ctg.tool;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ctg.hro.sfk.WageFileHandle;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 11:56 上午 2021/2/8
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
public class FastDFS {
|
||||
|
||||
private static WageFileHandle wageFileHandle = new WageFileHandle();
|
||||
|
||||
// private static String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0ZXN0IiwiaWF0IjoxNjExNjU5MTYzLCJleHAiOjE2MTQyNTExNjN9.57I2zXMW_rgYJpoJf984NyJ019rRdyuCkgH8fluLaIbspHWp7tUjz570pptiHXjhCiHjpA5bfRgVbSC7HL_FvQ";
|
||||
private static String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJtdXJvbmciLCJpYXQiOjE2MjU3MjI0OTUsImV4cCI6MTYyODMxNDQ5NX0.Qm3BzjxHWUdx5GPczYf8eRDZWbMcTGXs3VM5EnEm2fXm7BVW7FO6hsP8eSs-WVifJfmV-jhsgXMsMnY0q6qdng";
|
||||
// private static String url = "http://192.168.17.4:8094";
|
||||
private static String url = "http://172.17.11.90";
|
||||
private static String user = "test";
|
||||
private static String password="9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08";
|
||||
|
||||
public static String upload(File file) throws Exception {
|
||||
|
||||
if(file == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
WageFileHandle wageFileHandle = new WageFileHandle();
|
||||
|
||||
// token = wageFileHandle.getToken(url,user,password);
|
||||
|
||||
Map result = wageFileHandle.uploadFile(token,url,file);
|
||||
|
||||
if(result.get("code").toString().equals("0"))
|
||||
{
|
||||
JSONObject data = JSON.parseObject(result.get("data").toString());
|
||||
JSONObject json = JSON.parseObject(data.get("object").toString());
|
||||
return json.getString("id");
|
||||
}
|
||||
else{
|
||||
log.error("FastDFS is Exception:{}",result);
|
||||
throw new Exception("File is not upload");
|
||||
}
|
||||
}
|
||||
|
||||
public static void doanload(String fid)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 5:04 下午 2021/1/15
|
||||
*/
|
||||
@Data
|
||||
public class CardBin {
|
||||
|
||||
/* 银行 */
|
||||
private String bankName;
|
||||
|
||||
/* 银行类型 */
|
||||
private String bankType;
|
||||
|
||||
/* 银行类型(全) */
|
||||
private String bankTypeF;
|
||||
|
||||
private String cardName;
|
||||
|
||||
/* 适用范围 ATM */
|
||||
private Boolean atATM;
|
||||
|
||||
/* 适用范围 POS */
|
||||
private Boolean atPOS;
|
||||
|
||||
/* 磁道数 */
|
||||
private String trackCount;
|
||||
|
||||
/* 初始位置 */
|
||||
private String trackInitPos;
|
||||
|
||||
/* 长度 */
|
||||
private String trackLength;
|
||||
|
||||
private String cardInitPos;
|
||||
|
||||
private String cardLength;
|
||||
|
||||
private String cardMask;
|
||||
|
||||
private String cardReadTrack;
|
||||
|
||||
private String issueInitPos;
|
||||
|
||||
private String fillLength;
|
||||
|
||||
private String prefix;
|
||||
|
||||
private String issseReadTrack;
|
||||
|
||||
private String cardType;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 下午4:57 2021/2/24
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DiskInfo {
|
||||
private String applyDate ;
|
||||
private String diskNo ;
|
||||
private String diskSts ;
|
||||
private String diskMessage ;
|
||||
private String lastDate ;
|
||||
private String lastTime ;
|
||||
private String totalCount ;
|
||||
private String totalAmount ;
|
||||
private String succCount ;
|
||||
private String succAmount ;
|
||||
private String failCount ;
|
||||
private String failAmount ;
|
||||
private String filePath ;
|
||||
private String md5 ;
|
||||
|
||||
public DiskInfo(String applyDate,String diskNo) {
|
||||
this.applyDate = applyDate;
|
||||
this.diskNo = diskNo;
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
package hro;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.XmlUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import ctg.entity.api.Api;
|
||||
import ctg.entity.api.DiskApplyRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import ctg.tool.DataFactory;
|
||||
import ctg.tool.DiskTool;
|
||||
import ctg.tool.FastDFS;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
import net.lingala.zip4j.exception.ZipException;
|
||||
import net.lingala.zip4j.model.ZipParameters;
|
||||
import net.lingala.zip4j.model.enums.AesKeyStrength;
|
||||
import net.lingala.zip4j.model.enums.EncryptionMethod;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 10:45 上午 2021/2/7
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
public class DiskApplyRequestTest {
|
||||
|
||||
private final static String baseURL = "http://172.17.20.91:9998/api";
|
||||
// private final static String baseURL = "http://127.0.0.1:8888/api";
|
||||
private final static String secretKey = "HelloWorld";
|
||||
private final static String zipPassword = "1234567";
|
||||
|
||||
@Test
|
||||
public void simpleTest() throws Exception {
|
||||
|
||||
DiskApplyRequest request = DiskApplyRequest.builder()
|
||||
.applyDate(DateUtil.format(new Date(),"YYYYMMdd"))
|
||||
.customerId(DataFactory.randomCustomerId())
|
||||
.titleId(DataFactory.randomTitleId())
|
||||
.diskDesc("代发工资").build();
|
||||
|
||||
File file = DiskTool.newSimpleDiskFile(request.getCustomerId(),request.getTitleId(),"代发工资",10,new BigDecimal(50000.00));
|
||||
request.setDiskNo(file.getName());
|
||||
log.info("disk:{}", file.getAbsolutePath());
|
||||
|
||||
/** 文件压缩 */
|
||||
if(!file.exists() || !file.isFile()) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
|
||||
File disk = new File(file.getParent() + "/" + file.getName() + ".zip");
|
||||
|
||||
try {
|
||||
if ("".equals(zipPassword)) {
|
||||
ZipParameters zipParameters = new ZipParameters();
|
||||
zipParameters.setEncryptFiles(true);
|
||||
zipParameters.setEncryptionMethod(EncryptionMethod.AES);
|
||||
zipParameters.setAesKeyStrength(AesKeyStrength.KEY_STRENGTH_256);
|
||||
new ZipFile(disk, zipPassword.toCharArray()).addFile(file, zipParameters);
|
||||
}
|
||||
else {
|
||||
new ZipFile(disk).addFile(file);
|
||||
}
|
||||
}
|
||||
catch (ZipException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
|
||||
/** 上传文件 */
|
||||
String fid = FastDFS.upload(disk);
|
||||
log.debug("fid:{}",fid);
|
||||
request.setFilePath(fid);
|
||||
request.setFileVersion("");
|
||||
request.setFilePath(fid);
|
||||
request.setMd5(SecureUtil.md5(disk));
|
||||
|
||||
/** 送盘请求 */
|
||||
Api<DiskApplyRequest> api = new Api<>("diskApply",request);
|
||||
|
||||
log.info("request:{}",api.toData());
|
||||
log.debug("signature:{}",api.signature());
|
||||
|
||||
String response = HttpUtil.createPost(baseURL).header("Signature",api.signature()).body(api.toData()).setConnectionTimeout(3000).timeout(3000).execute().body();
|
||||
// String response = HttpUtil.createPost(baseURL).header("Signature","lkajsdfkljaslkdfjklasdjfk").body(api.toData()).setConnectionTimeout(3000).timeout(3000).execute().body();
|
||||
|
||||
log.info("response:{}",response);
|
||||
|
||||
Document doc = XmlUtil.readXML(response);
|
||||
|
||||
String respCode = (String) XmlUtil.getByXPath("//root/head/respCode",doc, XPathConstants.STRING);
|
||||
String respMessage = (String) XmlUtil.getByXPath("//root/head/respMessage",doc, XPathConstants.STRING);
|
||||
|
||||
log.info("[{}]:[{}]",respCode,respMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package hro;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.XmlUtil;
|
||||
import ctg.entity.api.*;
|
||||
import ctg.tool.DataFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 11:03 上午 2021/2/7
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
public class DiskApplyTest {
|
||||
@Test
|
||||
void test() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException, SQLException {
|
||||
String serviceName = "diskApply";
|
||||
|
||||
DiskApplyRequest body = DiskApplyRequest.builder()
|
||||
.diskNo("lakjdfklasjdklfjaslkdf")
|
||||
.applyDate(DateUtil.format(new Date(),"YYYYMMdd"))
|
||||
.customerId(DataFactory.randomCustomerId())
|
||||
.titleId(DataFactory.randomTitleId())
|
||||
.diskDesc("代发工资").build();
|
||||
|
||||
Api<DiskApplyRequest> request = new Api<>("diskApply",body);
|
||||
|
||||
log.info("request:{}",XmlUtil.format(request.toData()) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package hro;
|
||||
|
||||
import cn.hutool.core.util.XmlUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import ctg.constant.PropConstants;
|
||||
import ctg.entity.api.Api;
|
||||
import ctg.entity.api.DiskResultRequest;
|
||||
import entity.DiskInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 11:03 上午 2021/2/7
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
public class DiskResultTest {
|
||||
|
||||
@Test
|
||||
public void diskResultSimpleTest() throws Exception {
|
||||
String applyDate = "20200101";
|
||||
String diskNo = "jkljclkvjalksjdfkljalksdjf";
|
||||
|
||||
DiskResultRequest request = DiskResultRequest.builder().applyDate(applyDate).diskNo(diskNo).build();
|
||||
Api<DiskResultRequest> api = new Api<>("diskResult",request);
|
||||
String response = HttpUtil.createPost(PropConstants.baseURL).header("Signature",api.signature()).body(api.toData()).setConnectionTimeout(3000).timeout(3000).execute().body();
|
||||
|
||||
Document doc = XmlUtil.readXML(response);
|
||||
String respCode = (String) XmlUtil.getByXPath("//root/head/respCode",doc, XPathConstants.STRING);
|
||||
String respMessage = (String) XmlUtil.getByXPath("//root/head/respMessage",doc, XPathConstants.STRING);
|
||||
log.info("[{}]:[{}]",respCode,respMessage);
|
||||
if(respCode.equals("00"))
|
||||
{
|
||||
DiskInfo disk = new DiskInfo();
|
||||
disk.setDiskNo(diskNo);
|
||||
disk.setApplyDate(applyDate);
|
||||
disk.setDiskSts((String) XmlUtil.getByXPath("//root/body/diskSts",doc, XPathConstants.STRING));
|
||||
disk.setDiskMessage((String) XmlUtil.getByXPath("//root/body/diskMessage",doc, XPathConstants.STRING));
|
||||
disk.setLastDate((String) XmlUtil.getByXPath("//root/body/lastDate",doc, XPathConstants.STRING));
|
||||
disk.setLastTime((String) XmlUtil.getByXPath("//root/body/lastTime",doc, XPathConstants.STRING));
|
||||
disk.setTotalCount((String) XmlUtil.getByXPath("//root/body/totalCount",doc, XPathConstants.STRING));
|
||||
disk.setTotalAmount((String) XmlUtil.getByXPath("//root/body/totalAmount",doc, XPathConstants.STRING));
|
||||
disk.setFilePath((String) XmlUtil.getByXPath("//root/body/filePath",doc, XPathConstants.STRING));
|
||||
log.info("disk:{}",disk);
|
||||
}
|
||||
else {
|
||||
throw new Exception(respMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String keyFile = "~/Desktop/测试数据";
|
||||
FileInputStream fs = null;
|
||||
try {
|
||||
fs = new FileInputStream(keyFile);
|
||||
byte[] certBytes = new byte[fs.available()];
|
||||
fs.read(certBytes);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally { // 通过finally释放io
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
package hro;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.XmlUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.setting.Setting;
|
||||
import ctg.constant.PropConstants;
|
||||
import ctg.entity.api.Api;
|
||||
import ctg.entity.api.DiskApplyRequest;
|
||||
import ctg.entity.api.DiskResultRequest;
|
||||
import ctg.tool.DataFactory;
|
||||
import ctg.tool.DiskTool;
|
||||
import ctg.tool.FastDFS;
|
||||
import entity.DiskInfo;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
import net.lingala.zip4j.model.ZipParameters;
|
||||
import net.lingala.zip4j.model.enums.AesKeyStrength;
|
||||
import net.lingala.zip4j.model.enums.EncryptionMethod;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 下午4:10 2021/2/24
|
||||
*/
|
||||
@Slf4j
|
||||
public class MixedTest {
|
||||
private static String baseURL;
|
||||
private static String secretKey;
|
||||
private static String zipPassword;
|
||||
|
||||
@BeforeAll
|
||||
static void initProp() {
|
||||
Setting setting = new Setting("prop.setting");
|
||||
baseURL = setting.getStr("baseURL");
|
||||
secretKey = setting.getStr("secretKey");
|
||||
zipPassword = setting.getStr("zipPassword");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void WholeLinkTest() throws Exception {
|
||||
DiskInfo disk = diskApplySimpleTest();
|
||||
log.info("disk:{}",disk);
|
||||
log.info("等待60秒后查询结果...");
|
||||
ThreadUtil.sleep(60000);
|
||||
diskResultSimpleTest(disk);
|
||||
log.info("disk:{}",disk);
|
||||
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public void diskResultSimpleTest(DiskInfo disk) {
|
||||
DiskResultRequest request = DiskResultRequest.builder().applyDate(disk.getApplyDate()).diskNo(disk.getDiskNo()).build();
|
||||
Api<DiskResultRequest> api = new Api<>("diskResult",request);
|
||||
String response = HttpUtil.createPost(PropConstants.baseURL).header("Signature",api.signature()).body(api.toData()).setConnectionTimeout(3000).timeout(3000).execute().body();
|
||||
|
||||
Document doc = XmlUtil.readXML(response);
|
||||
String respCode = (String) XmlUtil.getByXPath("//root/head/respCode",doc, XPathConstants.STRING);
|
||||
String respMessage = (String) XmlUtil.getByXPath("//root/head/respMessage",doc, XPathConstants.STRING);
|
||||
log.info("[{}]:[{}]",respCode,respMessage);
|
||||
if(respCode.equals("00"))
|
||||
{
|
||||
disk.setDiskSts((String) XmlUtil.getByXPath("//root/body/diskSts",doc, XPathConstants.STRING));
|
||||
disk.setDiskMessage((String) XmlUtil.getByXPath("//root/body/diskMessage",doc, XPathConstants.STRING));
|
||||
disk.setLastDate((String) XmlUtil.getByXPath("//root/body/lastDate",doc, XPathConstants.STRING));
|
||||
disk.setLastTime((String) XmlUtil.getByXPath("//root/body/lastTime",doc, XPathConstants.STRING));
|
||||
disk.setTotalCount((String) XmlUtil.getByXPath("//root/body/totalCount",doc, XPathConstants.STRING));
|
||||
disk.setTotalAmount((String) XmlUtil.getByXPath("//root/body/totalAmount",doc, XPathConstants.STRING));
|
||||
disk.setFilePath((String) XmlUtil.getByXPath("//root/body/filePath",doc, XPathConstants.STRING));
|
||||
disk.setSuccAmount((String) XmlUtil.getByXPath("//root/body/succAmount",doc, XPathConstants.STRING));
|
||||
disk.setSuccCount((String) XmlUtil.getByXPath("//root/body/succCount",doc, XPathConstants.STRING));
|
||||
disk.setFailAmount((String) XmlUtil.getByXPath("//root/body/failAmount",doc, XPathConstants.STRING));
|
||||
disk.setFailCount((String) XmlUtil.getByXPath("//root/body/failCount",doc, XPathConstants.STRING));
|
||||
disk.setMd5((String) XmlUtil.getByXPath("//root/body/md5",doc, XPathConstants.STRING));
|
||||
}
|
||||
else {
|
||||
throw new Exception(respMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public DiskInfo diskApplySimpleTest() throws Exception {
|
||||
DiskApplyRequest request = DiskApplyRequest.builder()
|
||||
.applyDate(DateUtil.format(new Date(),"YYYYMMdd"))
|
||||
.customerId(DataFactory.randomCustomerId())
|
||||
.titleId(DataFactory.randomTitleId())
|
||||
.diskDesc("代发工资").build();
|
||||
|
||||
int totalCount = RandomUtil.randomInt(0,3000);
|
||||
BigDecimal totalAmount = RandomUtil.randomBigDecimal(new BigDecimal(1),new BigDecimal(1000000));
|
||||
|
||||
File file = DiskTool.newSimpleDiskFile(request.getCustomerId(),request.getTitleId(),"代发工资",totalCount,totalAmount);
|
||||
request.setDiskNo(file.getName());
|
||||
|
||||
log.info("disk:{}", file.getAbsolutePath());
|
||||
|
||||
/** 文件压缩 */
|
||||
if(!file.exists() || !file.isFile()) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
|
||||
File disk = new File(file.getParent() + "/" + file.getName() + ".zip");
|
||||
|
||||
if ("".equals(zipPassword)) {
|
||||
ZipParameters zipParameters = new ZipParameters();
|
||||
zipParameters.setEncryptFiles(true);
|
||||
zipParameters.setEncryptionMethod(EncryptionMethod.AES);
|
||||
zipParameters.setAesKeyStrength(AesKeyStrength.KEY_STRENGTH_256);
|
||||
new ZipFile(disk, zipPassword.toCharArray()).addFile(file, zipParameters);
|
||||
}
|
||||
else {
|
||||
new ZipFile(disk).addFile(file);
|
||||
}
|
||||
|
||||
/** 上传文件 */
|
||||
String fid = FastDFS.upload(disk);
|
||||
log.info("fid:{}",fid);
|
||||
request.setFilePath(fid);
|
||||
request.setFileVersion("");
|
||||
request.setFilePath(fid);
|
||||
request.setMd5(SecureUtil.md5(disk));
|
||||
|
||||
/** 送盘请求 */
|
||||
Api<DiskApplyRequest> api = new Api<>("diskApply",request);
|
||||
|
||||
log.info("request:{}",api.toData());
|
||||
String response = HttpUtil.createPost(baseURL).header("Signature",api.signature()).body(api.toData()).setConnectionTimeout(3000).timeout(3000).execute().body();
|
||||
log.info("response:{}",response);
|
||||
|
||||
Document doc = XmlUtil.readXML(response);
|
||||
|
||||
String respCode = (String) XmlUtil.getByXPath("//root/head/respCode",doc, XPathConstants.STRING);
|
||||
String respMessage = (String) XmlUtil.getByXPath("//root/head/respMessage",doc, XPathConstants.STRING);
|
||||
|
||||
log.info("diskApplySimpleTest[{}]:[{}]",respCode,respMessage);
|
||||
return DiskInfo.builder().diskNo(request.getDiskNo()).applyDate(request.getApplyDate()).build();
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package hro;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Sandbox {
|
||||
@Test
|
||||
public void sandbox()
|
||||
{
|
||||
// String json = "{code:\"AGW0000\"}";
|
||||
String json = "{msg:\"AGW0000\"}";
|
||||
// String code = JSONObject.parseObject(json).getString("code").substring(3);
|
||||
|
||||
// System.out.println("msg:" + JSONObject.parseObject(json).getJSONObject("msg"));
|
||||
System.out.println("msg:" + JSONObject.parseObject(json).getString("code"));
|
||||
// System.out.println("code:" + code);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
package hro;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.XmlUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.setting.Setting;
|
||||
import com.github.houbb.junitperf.core.annotation.JunitPerfConfig;
|
||||
import ctg.entity.api.Api;
|
||||
import ctg.entity.api.DiskApplyRequest;
|
||||
import ctg.entity.api.DiskResultRequest;
|
||||
import ctg.tool.DataFactory;
|
||||
import ctg.tool.DiskTool;
|
||||
import ctg.tool.FastDFS;
|
||||
import entity.DiskInfo;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
import net.lingala.zip4j.model.ZipParameters;
|
||||
import net.lingala.zip4j.model.enums.AesKeyStrength;
|
||||
import net.lingala.zip4j.model.enums.EncryptionMethod;
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.RepeatedTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 下午4:10 2021/2/24
|
||||
*/
|
||||
@Slf4j
|
||||
public class StressTest {
|
||||
private static String baseURL;
|
||||
private static String secretKey;
|
||||
private static String zipPassword;
|
||||
// private final static String propFile = "prop.setting.uat";
|
||||
// private final static String propFile = "prop.setting.sit";
|
||||
private final static String propFile = "prop.setting.stress";
|
||||
private final TimeInterval timer = DateUtil.timer();
|
||||
|
||||
@BeforeAll
|
||||
static void initProp() {
|
||||
Setting setting = new Setting(propFile);
|
||||
baseURL = setting.getStr("baseURL");
|
||||
secretKey = setting.getStr("secretKey");
|
||||
zipPassword = setting.getStr("zipPassword");
|
||||
}
|
||||
|
||||
/** 压测入口 */
|
||||
// @JunitPerfConfig(threads = 1, warmUp = 0 , duration = 3000 )
|
||||
@JunitPerfConfig(threads = 50, warmUp = 3000 , duration = 1000 * 60 * 30)
|
||||
public void stressTest() {
|
||||
String threadName = Thread.currentThread().getName();
|
||||
log.info("{} started",threadName);
|
||||
timer.start(threadName);
|
||||
DiskInfo disk;
|
||||
try{
|
||||
/** 生成测试批次 */
|
||||
String customerId = DataFactory.randomCustomerId();
|
||||
String titleId = DataFactory.randomTitleId();
|
||||
int totalCount = RandomUtil.randomInt(2000,10000);
|
||||
BigDecimal totalAmount = RandomUtil.randomBigDecimal(new BigDecimal(5000),new BigDecimal(1000000));
|
||||
/** 新建文件 */
|
||||
File file = DiskTool.newSimpleDiskFile(customerId,titleId,"代发工资",totalCount,totalAmount);
|
||||
disk = diskApply(customerId,titleId,file);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
DiskInfo result = null;
|
||||
|
||||
/* 批次为空(表示还在入库中),批次未终态(U:预计 0:成功 1:处理中) */
|
||||
while(result == null || StrUtil.equalsAny(result.getDiskSts(),"U","0","1")) {
|
||||
ThreadUtil.sleep(3000);
|
||||
result = diskResult(disk.getApplyDate(),disk.getDiskNo());
|
||||
}
|
||||
log.info("{} is completed, elapsed time:{}, disk:{}",threadName,timer.intervalSecond(threadName),result);
|
||||
}
|
||||
|
||||
/* 查询具体某一批次的结果 */
|
||||
@Test
|
||||
public void resultTest() throws Exception {
|
||||
DiskInfo disk = null;
|
||||
try {
|
||||
disk = diskResult("20210607","3b07422666b44315ac62b8bc55b207c2");
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("error:{}",e.getMessage());
|
||||
return;
|
||||
}
|
||||
log.info("disk:{}",disk);
|
||||
}
|
||||
|
||||
/* 结果查询 */
|
||||
@SneakyThrows
|
||||
public DiskInfo diskResult(String applyDate,String diskNo) {
|
||||
log.info("applyDate:{} diskNo:{}",applyDate,diskNo);
|
||||
DiskResultRequest request = DiskResultRequest.builder().applyDate(applyDate).diskNo(diskNo).build();
|
||||
DiskInfo disk = new DiskInfo(applyDate,diskNo);
|
||||
Api<DiskResultRequest> api = new Api<>("diskResult",request);
|
||||
String response = HttpUtil.createPost(baseURL).header("Signature",api.signature()).body(api.toData()).setConnectionTimeout(3000).timeout(3000).execute().body();
|
||||
|
||||
Document doc = XmlUtil.readXML(response);
|
||||
String respCode = (String) XmlUtil.getByXPath("//root/head/respCode",doc, XPathConstants.STRING);
|
||||
String respMessage = (String) XmlUtil.getByXPath("//root/head/respMessage",doc, XPathConstants.STRING);
|
||||
log.info("[{}]:[{}]",respCode,respMessage);
|
||||
if(respCode.equals("00")) {
|
||||
disk.setDiskSts((String) XmlUtil.getByXPath("//root/body/diskSts",doc, XPathConstants.STRING));
|
||||
disk.setDiskMessage((String) XmlUtil.getByXPath("//root/body/diskMessage",doc, XPathConstants.STRING));
|
||||
disk.setLastDate((String) XmlUtil.getByXPath("//root/body/lastDate",doc, XPathConstants.STRING));
|
||||
disk.setLastTime((String) XmlUtil.getByXPath("//root/body/lastTime",doc, XPathConstants.STRING));
|
||||
disk.setTotalCount((String) XmlUtil.getByXPath("//root/body/totalCount",doc, XPathConstants.STRING));
|
||||
disk.setTotalAmount((String) XmlUtil.getByXPath("//root/body/totalAmount",doc, XPathConstants.STRING));
|
||||
disk.setFilePath((String) XmlUtil.getByXPath("//root/body/filePath",doc, XPathConstants.STRING));
|
||||
disk.setSuccAmount((String) XmlUtil.getByXPath("//root/body/succAmount",doc, XPathConstants.STRING));
|
||||
disk.setSuccCount((String) XmlUtil.getByXPath("//root/body/succCount",doc, XPathConstants.STRING));
|
||||
disk.setFailAmount((String) XmlUtil.getByXPath("//root/body/failAmount",doc, XPathConstants.STRING));
|
||||
disk.setFailCount((String) XmlUtil.getByXPath("//root/body/failCount",doc, XPathConstants.STRING));
|
||||
disk.setMd5((String) XmlUtil.getByXPath("//root/body/md5",doc, XPathConstants.STRING));
|
||||
return disk;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* 送盘 */
|
||||
public DiskInfo diskApply(String customerId,String titleId,File file) throws Exception {
|
||||
DiskApplyRequest request = DiskApplyRequest.builder()
|
||||
.applyDate(DateUtil.format(new Date(),"YYYYMMdd"))
|
||||
.customerId(customerId)
|
||||
.titleId(titleId)
|
||||
.diskDesc("代发工资").build();
|
||||
|
||||
request.setDiskNo(file.getName());
|
||||
|
||||
log.info("disk:{}", file.getAbsolutePath());
|
||||
|
||||
/** 文件压缩 */
|
||||
if(!file.exists() || !file.isFile()) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
|
||||
File disk = new File(file.getParent() + "/" + file.getName() + ".zip");
|
||||
|
||||
if ("".equals(zipPassword)) {
|
||||
ZipParameters zipParameters = new ZipParameters();
|
||||
zipParameters.setEncryptFiles(true);
|
||||
zipParameters.setEncryptionMethod(EncryptionMethod.AES);
|
||||
zipParameters.setAesKeyStrength(AesKeyStrength.KEY_STRENGTH_256);
|
||||
new ZipFile(disk, zipPassword.toCharArray()).addFile(file, zipParameters);
|
||||
}
|
||||
else {
|
||||
new ZipFile(disk).addFile(file);
|
||||
}
|
||||
|
||||
/** 上传文件 */
|
||||
String fid = FastDFS.upload(disk);
|
||||
log.info("fid:{}",fid);
|
||||
request.setFilePath(fid);
|
||||
request.setFileVersion("");
|
||||
request.setFilePath(fid);
|
||||
request.setMd5(SecureUtil.md5(disk));
|
||||
|
||||
/** 送盘请求 */
|
||||
Api<DiskApplyRequest> api = new Api<>("diskApply",request);
|
||||
|
||||
log.info("diskApply.request:[{}]",api.toData());
|
||||
String response = HttpUtil.createPost(baseURL).header("Signature",api.signature()).body(api.toData()).setConnectionTimeout(3000).timeout(3000).execute().body();
|
||||
log.info("diskApply.response:[{}]",response);
|
||||
|
||||
Document doc = XmlUtil.readXML(response);
|
||||
|
||||
String respCode = (String) XmlUtil.getByXPath("//root/head/respCode",doc, XPathConstants.STRING);
|
||||
String respMessage = (String) XmlUtil.getByXPath("//root/head/respMessage",doc, XPathConstants.STRING);
|
||||
|
||||
if(!"00".equals(respCode)) {
|
||||
throw new Exception(respMessage);
|
||||
}
|
||||
return DiskInfo.builder().diskNo(request.getDiskNo()).applyDate(request.getApplyDate()).build();
|
||||
}
|
||||
|
||||
@JunitPerfConfig(threads = 100, duration = 6000)
|
||||
public void perfTest() {
|
||||
String threadName = Thread.currentThread().getName();
|
||||
timer.start(threadName);
|
||||
log.info("{} is started, start time:{}",threadName,DateUtil.now());
|
||||
ThreadUtil.safeSleep(3000);
|
||||
Assert.assertTrue(false);
|
||||
log.info("{} is end, elapsed time:{}",threadName,timer.intervalSecond(threadName));
|
||||
}
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
package hro;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.XmlUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.setting.Setting;
|
||||
import ctg.constant.PropConstants;
|
||||
import ctg.entity.api.Api;
|
||||
import ctg.entity.api.DiskApplyRequest;
|
||||
import ctg.entity.api.DiskResultRequest;
|
||||
import ctg.tool.DataFactory;
|
||||
import ctg.tool.DiskTool;
|
||||
import ctg.tool.FastDFS;
|
||||
import entity.DiskInfo;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
import net.lingala.zip4j.model.ZipParameters;
|
||||
import net.lingala.zip4j.model.enums.AesKeyStrength;
|
||||
import net.lingala.zip4j.model.enums.EncryptionMethod;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 下午4:10 2021/2/24
|
||||
*/
|
||||
@Slf4j
|
||||
public class UatTest {
|
||||
private static String baseURL;
|
||||
private static String secretKey;
|
||||
private static String zipPassword;
|
||||
|
||||
@BeforeAll
|
||||
static void initProp() {
|
||||
Setting setting = new Setting("prop.setting");
|
||||
baseURL = setting.getStr("baseURL");
|
||||
secretKey = setting.getStr("secretKey");
|
||||
zipPassword = setting.getStr("zipPassword");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void overAllTest() throws Exception {
|
||||
DiskInfo disk;
|
||||
try{
|
||||
/** 生成测试批次 */
|
||||
String customerId = DataFactory.randomCustomerId();
|
||||
String titleId = DataFactory.randomTitleId();
|
||||
int totalCount = RandomUtil.randomInt(0,3000);
|
||||
BigDecimal totalAmount = RandomUtil.randomBigDecimal(new BigDecimal(1),new BigDecimal(1000000));
|
||||
/** 新建文件 */
|
||||
File file = DiskTool.newSimpleDiskFile(customerId,titleId,"代发工资",totalCount,totalAmount);
|
||||
disk = diskApply(customerId,titleId,file);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return;
|
||||
}
|
||||
log.info("disk:{}",disk);
|
||||
log.info("等待30秒后查询结果...");
|
||||
ThreadUtil.sleep(30000);
|
||||
try {
|
||||
diskResult(disk.getApplyDate(),disk.getDiskNo());
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("error:{}",e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("disk:{}",disk);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resultTest() throws Exception {
|
||||
DiskInfo disk = null;
|
||||
try {
|
||||
disk = diskResult("20210607","3b07422666b44315ac62b8bc55b207c2");
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("error:{}",e.getMessage());
|
||||
return;
|
||||
}
|
||||
log.info("disk:{}",disk);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public DiskInfo diskResult(String applyDate,String diskNo) {
|
||||
DiskResultRequest request = DiskResultRequest.builder().applyDate(applyDate).diskNo(diskNo).build();
|
||||
DiskInfo disk = new DiskInfo(applyDate,diskNo);
|
||||
Api<DiskResultRequest> api = new Api<>("diskResult",request);
|
||||
String response = HttpUtil.createPost(PropConstants.baseURL).header("Signature",api.signature()).body(api.toData()).setConnectionTimeout(3000).timeout(3000).execute().body();
|
||||
|
||||
Document doc = XmlUtil.readXML(response);
|
||||
String respCode = (String) XmlUtil.getByXPath("//root/head/respCode",doc, XPathConstants.STRING);
|
||||
String respMessage = (String) XmlUtil.getByXPath("//root/head/respMessage",doc, XPathConstants.STRING);
|
||||
log.info("[{}]:[{}]",respCode,respMessage);
|
||||
if(respCode.equals("00")) {
|
||||
disk.setDiskSts((String) XmlUtil.getByXPath("//root/body/diskSts",doc, XPathConstants.STRING));
|
||||
disk.setDiskMessage((String) XmlUtil.getByXPath("//root/body/diskMessage",doc, XPathConstants.STRING));
|
||||
disk.setLastDate((String) XmlUtil.getByXPath("//root/body/lastDate",doc, XPathConstants.STRING));
|
||||
disk.setLastTime((String) XmlUtil.getByXPath("//root/body/lastTime",doc, XPathConstants.STRING));
|
||||
disk.setTotalCount((String) XmlUtil.getByXPath("//root/body/totalCount",doc, XPathConstants.STRING));
|
||||
disk.setTotalAmount((String) XmlUtil.getByXPath("//root/body/totalAmount",doc, XPathConstants.STRING));
|
||||
disk.setFilePath((String) XmlUtil.getByXPath("//root/body/filePath",doc, XPathConstants.STRING));
|
||||
disk.setSuccAmount((String) XmlUtil.getByXPath("//root/body/succAmount",doc, XPathConstants.STRING));
|
||||
disk.setSuccCount((String) XmlUtil.getByXPath("//root/body/succCount",doc, XPathConstants.STRING));
|
||||
disk.setFailAmount((String) XmlUtil.getByXPath("//root/body/failAmount",doc, XPathConstants.STRING));
|
||||
disk.setFailCount((String) XmlUtil.getByXPath("//root/body/failCount",doc, XPathConstants.STRING));
|
||||
disk.setMd5((String) XmlUtil.getByXPath("//root/body/md5",doc, XPathConstants.STRING));
|
||||
return disk;
|
||||
}
|
||||
else {
|
||||
throw new Exception(respMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public DiskInfo diskApply(String customerId,String titleId,File file) throws Exception {
|
||||
// DiskApplyRequest request = DiskApplyRequest.builder()
|
||||
// .applyDate(DateUtil.format(new Date(),"YYYYMMdd"))
|
||||
// .customerId(DataFactory.newCustomerId())
|
||||
// .titleId(DataFactory.newTitleId())
|
||||
// .diskDesc("代发工资").build();
|
||||
DiskApplyRequest request = DiskApplyRequest.builder()
|
||||
.applyDate(DateUtil.format(new Date(),"YYYYMMdd"))
|
||||
.customerId(customerId)
|
||||
.titleId(titleId)
|
||||
.diskDesc("代发工资").build();
|
||||
|
||||
|
||||
// int totalCount = RandomUtil.randomInt(0,3000);
|
||||
// BigDecimal totalAmount = RandomUtil.randomBigDecimal(new BigDecimal(1),new BigDecimal(1000000));
|
||||
// File file = DiskTool.newSimpleDiskFile(request.getCustomerId(),request.getTitleId(),"代发工资",totalCount,totalAmount);
|
||||
request.setDiskNo(file.getName());
|
||||
|
||||
log.info("disk:{}", file.getAbsolutePath());
|
||||
|
||||
/** 文件压缩 */
|
||||
if(!file.exists() || !file.isFile()) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
|
||||
File disk = new File(file.getParent() + "/" + file.getName() + ".zip");
|
||||
|
||||
if ("".equals(zipPassword)) {
|
||||
ZipParameters zipParameters = new ZipParameters();
|
||||
zipParameters.setEncryptFiles(true);
|
||||
zipParameters.setEncryptionMethod(EncryptionMethod.AES);
|
||||
zipParameters.setAesKeyStrength(AesKeyStrength.KEY_STRENGTH_256);
|
||||
new ZipFile(disk, zipPassword.toCharArray()).addFile(file, zipParameters);
|
||||
}
|
||||
else {
|
||||
new ZipFile(disk).addFile(file);
|
||||
}
|
||||
|
||||
/** 上传文件 */
|
||||
String fid = FastDFS.upload(disk);
|
||||
log.info("fid:{}",fid);
|
||||
request.setFilePath(fid);
|
||||
request.setFileVersion("");
|
||||
request.setFilePath(fid);
|
||||
request.setMd5(SecureUtil.md5(disk));
|
||||
|
||||
/** 送盘请求 */
|
||||
Api<DiskApplyRequest> api = new Api<>("diskApply",request);
|
||||
|
||||
log.info("diskApply.request:[{}]",api.toData());
|
||||
String response = HttpUtil.createPost(baseURL).header("Signature",api.signature()).body(api.toData()).setConnectionTimeout(3000).timeout(3000).execute().body();
|
||||
log.info("diskApply.response:[{}]",response);
|
||||
|
||||
Document doc = XmlUtil.readXML(response);
|
||||
|
||||
String respCode = (String) XmlUtil.getByXPath("//root/head/respCode",doc, XPathConstants.STRING);
|
||||
String respMessage = (String) XmlUtil.getByXPath("//root/head/respMessage",doc, XPathConstants.STRING);
|
||||
|
||||
if(!"00".equals(respCode)) {
|
||||
throw new Exception(respMessage);
|
||||
}
|
||||
return DiskInfo.builder().diskNo(request.getDiskNo()).applyDate(request.getApplyDate()).build();
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package icbc;
|
||||
|
||||
import com.icbc.api.internal.util.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 下午5:43 2021/3/5
|
||||
*/
|
||||
@Data
|
||||
public class A {
|
||||
private String field_a;
|
||||
|
||||
private List<A.B> rd;
|
||||
|
||||
@Data
|
||||
public static class B{
|
||||
private String field_b;
|
||||
}
|
||||
}
|
||||
@@ -1,274 +0,0 @@
|
||||
package icbc;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import static jdk.nashorn.internal.runtime.regexp.joni.Config.DEBUG;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 下午4:52 2021/3/5
|
||||
*/
|
||||
public class BeanToJson {
|
||||
|
||||
|
||||
//需要解决的问题
|
||||
//1.怎么获取字段名,怎么获取字段的值
|
||||
//2.怎么判断是基本类型,基本类型的值,不需要加隐含
|
||||
//3.怎么判断是常用的类型,如果是常用类型里面的集合话,需要递归判断
|
||||
//4.如何判断是自定义的bean对象 如果是自定义的bean对象,需要再次进行解析,
|
||||
//5.数组的话,需要遍历展示
|
||||
//6.将key按照ascii码升序排列
|
||||
|
||||
|
||||
//修改部分:原文存在bug.当类型为数组类型的时候,会出现问题, 以修正为需要的逻辑
|
||||
|
||||
public static <T> String toJson(T t) {
|
||||
if (t == null) {
|
||||
return "{}";
|
||||
}
|
||||
return beanToJson(t);
|
||||
}
|
||||
|
||||
public static <T> String beanToJson(T t) {
|
||||
//先获取所有字段名
|
||||
Field[] fields = t.getClass().getDeclaredFields();
|
||||
String[] keys = new String[fields.length];
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
keys[i] = fields[i].getName();
|
||||
}
|
||||
//获取按照Ascii排序之后的顺序
|
||||
keys = getUrlParam(keys);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("{");
|
||||
|
||||
|
||||
Map<String, Field> map = new HashMap<>();
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
for (Field field : fields) {
|
||||
if (field.getName().equals(keys[i])) {
|
||||
map.put(keys[i], field);
|
||||
// 当方法名满足键值得时候结束当前层循环
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String name : keys) {
|
||||
Field field = map.get(name);
|
||||
|
||||
field.setAccessible(true);
|
||||
Class<?> type = field.getType();
|
||||
|
||||
Object value = null;
|
||||
try {
|
||||
value = field.get(t);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 内部类的外部类引用(指针)字段
|
||||
if (name.contains("this$")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
String typeName = type.getName();
|
||||
if (typeName.equals("java.lang.String")) {
|
||||
try {
|
||||
sb.append("\"" + name + "\":");
|
||||
sb.append(stringToJson((String) field.get(t)));
|
||||
sb.append(",");
|
||||
} catch (Exception e) {
|
||||
if (DEBUG) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
} else if (typeName.equals("boolean") ||
|
||||
typeName.equals("java.lang.Boolean") ||
|
||||
typeName.equals("int") ||
|
||||
typeName.equals("java.lang.Integer") ||
|
||||
typeName.equals("float") ||
|
||||
typeName.equals("java.lang.Float") ||
|
||||
typeName.equals("double") ||
|
||||
typeName.equals("java.lang.Double") ||
|
||||
typeName.equals("long") ||
|
||||
typeName.equals("java.lang.Long")) {
|
||||
try {
|
||||
sb.append("\"" + name + "\":");
|
||||
sb.append(field.get(t));
|
||||
sb.append(",");
|
||||
} catch (Exception e) {
|
||||
if (DEBUG) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else if (typeName.equals("java.util.List") ||
|
||||
typeName.equals("java.util.ArrayList")) {
|
||||
try {
|
||||
List<?> objList = (List<?>) field.get(t);
|
||||
if (null != objList && objList.size() > 0) {
|
||||
sb.append("\"" + name + "\":");
|
||||
sb.append("[");
|
||||
String toJson = listToJson((List<?>) field.get(t));
|
||||
sb.append(toJson);
|
||||
sb.setCharAt(sb.length() - 1, ']');
|
||||
sb.append(",");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (DEBUG) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else if (value.getClass().isArray()) {
|
||||
|
||||
Object[] arr = (Object[]) value; // 装换成数组
|
||||
List list = Arrays.asList(arr);
|
||||
try {
|
||||
if (null != list && list.size() > 0) {
|
||||
sb.append("\"" + name + "\":");
|
||||
sb.append("[");
|
||||
String toJson = listToJson(list);
|
||||
sb.append(toJson);
|
||||
sb.setCharAt(sb.length() - 1, ']');
|
||||
sb.append(",");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (DEBUG) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
sb.append("\"" + name + "\":");
|
||||
sb.append("{");
|
||||
sb.append(beanToJson(field.get(t)));
|
||||
sb.setCharAt(sb.length() - 1, '}');
|
||||
sb.append(",");
|
||||
} catch (Exception e) {
|
||||
if (DEBUG) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (sb.length() == 1) {
|
||||
sb.append("}");
|
||||
}
|
||||
sb.setCharAt(sb.length() - 1, '}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 List 对象编码为 JSON格式
|
||||
*
|
||||
* @param objList 待封装的对象集合
|
||||
* @return String:封装后JSONArray String格式
|
||||
* @version 1.0
|
||||
*/
|
||||
private static <T> String listToJson(List<T> objList) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (T t : objList) {
|
||||
if (t instanceof String) {
|
||||
sb.append(stringToJson((String) t));
|
||||
sb.append(",");
|
||||
} else if (t instanceof Boolean ||
|
||||
t instanceof Integer ||
|
||||
t instanceof Float ||
|
||||
t instanceof Double) {
|
||||
sb.append(t);
|
||||
sb.append(",");
|
||||
} else {
|
||||
sb.append(beanToJson(t));
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 String 对象编码为 JSON格式,只需处理好特殊字符
|
||||
*
|
||||
* @param str String 对象
|
||||
* @return String:JSON格式
|
||||
* @version 1.0
|
||||
*/
|
||||
private static String stringToJson(final String str) {
|
||||
if (str == null || str.length() == 0) {
|
||||
return "\"\"";
|
||||
}
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append('\"');
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
final char c = str.charAt(i);
|
||||
|
||||
sb.append(c == '\"' ? "\\\"" : c == '\\' ? "\\\\"
|
||||
: c == '/' ? "\\/" : c == '\b' ? "\\b" : c == '\f' ? "\\f"
|
||||
: c == '\n' ? "\\n" : c == '\r' ? "\\r"
|
||||
: c == '\t' ? "\\t" : c + "");
|
||||
}
|
||||
sb.append('\"');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 对字符串数组进行排序
|
||||
*
|
||||
* @param keys
|
||||
* @return
|
||||
*/
|
||||
private static String[] getUrlParam(String[] keys) {
|
||||
|
||||
for (int i = 0; i < keys.length - 1; i++) {
|
||||
for (int j = 0; j < keys.length - i - 1; j++) {
|
||||
String pre = keys[j];
|
||||
String next = keys[j + 1];
|
||||
if (isMoreThan(pre, next)) {
|
||||
String temp = pre;
|
||||
keys[j] = next;
|
||||
keys[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较两个字符串的大小,按字母的ASCII码比较
|
||||
*
|
||||
* @param pre
|
||||
* @param next
|
||||
* @return
|
||||
*/
|
||||
private static boolean isMoreThan(String pre, String next) {
|
||||
if (null == pre || null == next || "".equals(pre) || "".equals(next)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char[] c_pre = pre.toCharArray();
|
||||
char[] c_next = next.toCharArray();
|
||||
|
||||
int minSize = Math.min(c_pre.length, c_next.length);
|
||||
|
||||
for (int i = 0; i < minSize; i++) {
|
||||
if ((int) c_pre[i] > (int) c_next[i]) {
|
||||
return true;
|
||||
} else if ((int) c_pre[i] < (int) c_next[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (c_pre.length > c_next.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package icbc;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 下午6:02 2021/3/5
|
||||
*/
|
||||
public class Father {
|
||||
|
||||
private String name;
|
||||
|
||||
private List<Child> childs;
|
||||
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Child> getChilds() {
|
||||
return this.childs;
|
||||
}
|
||||
|
||||
public void setChilds(List<Child> childs) {
|
||||
this.childs = childs;
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
public static class Child {
|
||||
private String name;
|
||||
|
||||
public Child() {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String iSeqNo) {
|
||||
this.name = iSeqNo;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Father response = new Father();
|
||||
response.setName("Father");
|
||||
|
||||
|
||||
List<Child> rd = new ArrayList();
|
||||
|
||||
Child biz = new Child();
|
||||
|
||||
biz.setName("Child");
|
||||
rd.add(biz);
|
||||
|
||||
response.setChilds(rd);
|
||||
|
||||
System.out.println("map:" + BeanUtil.beanToMap(response));
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,30 @@
|
||||
package icbc;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.io.FastByteArrayOutputStream;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.XmlUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONConverter;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.icbc.api.DefaultIcbcClient;
|
||||
import com.icbc.api.IcbcConstants;
|
||||
import com.icbc.api.internal.util.Charsets;
|
||||
import com.icbc.api.request.MybankEnterpriseSalaryFinancialofficeMesfinstrqryRequestV1;
|
||||
import com.icbc.api.request.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1;
|
||||
import com.icbc.api.response.MybankEnterpriseSalaryFinancialofficeMesfinstrqryResponseV1;
|
||||
import com.icbc.api.response.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitResponseV1;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.Base64Utils;
|
||||
import sun.misc.BASE64Decoder;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
@@ -45,7 +35,6 @@ import java.util.zip.ZipOutputStream;
|
||||
public class IcbcTest {
|
||||
|
||||
private static final String baseURL = "https://apipcs3.dccnet.com.cn/api";
|
||||
// private static final String baseURL = "http://localhost:8888/api";
|
||||
/** APP ID */
|
||||
private static final String appId = "10000000000000201052";
|
||||
/** 企业私钥 */
|
||||
@@ -57,27 +46,6 @@ public class IcbcTest {
|
||||
/** Client */
|
||||
private static DefaultIcbcClient client = new DefaultIcbcClient(appId, IcbcConstants.SIGN_TYPE_RSA2, privateKey, apiPublicKey);;
|
||||
|
||||
|
||||
@Test
|
||||
public void mapTest()
|
||||
{
|
||||
Father response = new Father();
|
||||
response.setName("Tom");
|
||||
|
||||
List<Father.Child> rd = new ArrayList();
|
||||
|
||||
Father.Child biz = new Father.Child();
|
||||
|
||||
biz.setName("001");
|
||||
rd.add(biz);
|
||||
|
||||
response.setChilds(rd);
|
||||
|
||||
|
||||
log.info("map:{}",BeanUtil.beanToMap(response));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void PayTest()
|
||||
{
|
||||
@@ -87,8 +55,6 @@ public class IcbcTest {
|
||||
new MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1();
|
||||
MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestBizV1 bizContent =
|
||||
new MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestBizV1();
|
||||
MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestRdV1 rd =
|
||||
new MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestRdV1();
|
||||
|
||||
String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||
String time = new SimpleDateFormat("HHmmss").format(new Date());
|
||||
@@ -104,107 +70,65 @@ public class IcbcTest {
|
||||
bizContent.setTotalAmount(1L);
|
||||
bizContent.setInstrCount(1);
|
||||
bizContent.setfSeqNo(seqNo);
|
||||
/** 0:不压缩 1:压缩 */
|
||||
// bizContent.setZipFlag("0");
|
||||
|
||||
rd.setAmount(1L);
|
||||
rd.setPostscript("工资");
|
||||
rd.setBusiCode("");
|
||||
rd.setCurrency("CNY");
|
||||
rd.setPurpose("工资");
|
||||
rd.setSummary("工资");
|
||||
rd.setSummaryEn("Salary");
|
||||
rd.setPayerAccount("0200080609200100843");
|
||||
rd.setPayerCnname("榔右蝗呵如咪仔牌芝降化僵侦柱");
|
||||
rd.setPayeeAccount("6212260200197040005");
|
||||
rd.setPayeeCnname("音偏漾");
|
||||
rd.setPayeeBankNo("308584000013");
|
||||
rd.setIoFlag("2");
|
||||
rd.setPayType("3");
|
||||
rd.setPayeeCity("");
|
||||
rd.setManagerCardNo("");
|
||||
rd.setManagerCardName("");
|
||||
rd.setRelatedRefNo("");
|
||||
rd.setRefNo(seqNo);
|
||||
rd.setRelatedRefNo("");
|
||||
rd.setiSeqNo(seqNo);
|
||||
rd.setOriVoucherName("");
|
||||
rd.setOriVoucherNo("");
|
||||
rd.setOriVoucherType("");
|
||||
ArrayList<MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestRdV1> list = new ArrayList<>();
|
||||
list.add(rd);
|
||||
|
||||
// for(int i = 1;i <= 3;i++) {
|
||||
MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestRdV1 rd =
|
||||
new MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestRdV1();
|
||||
rd.setAmount(1L);
|
||||
rd.setPostscript("第[" + 1 + "]笔工资");
|
||||
rd.setBusiCode("");
|
||||
rd.setCurrency("CNY");
|
||||
rd.setPurpose("工资");
|
||||
rd.setSummary("第[" + 1 + "]笔工资");
|
||||
rd.setSummaryEn("Salary");
|
||||
rd.setPayerAccount("0200080609200100843");
|
||||
rd.setPayerCnname("榔右蝗呵如咪仔牌芝降化僵侦柱");
|
||||
rd.setPayeeAccount("6212260200197040005");
|
||||
rd.setPayeeCnname("音偏漾");
|
||||
rd.setPayeeBankNo("308584000013");
|
||||
rd.setIoFlag("2");
|
||||
rd.setPayType("3");
|
||||
rd.setPayeeCity("");
|
||||
rd.setManagerCardNo("");
|
||||
rd.setManagerCardName("");
|
||||
rd.setRelatedRefNo("");
|
||||
String id = date + time + RandomUtil.randomNumbers(6);
|
||||
rd.setRefNo(id);
|
||||
rd.setRelatedRefNo("");
|
||||
rd.setiSeqNo(id);
|
||||
rd.setOriVoucherName("");
|
||||
rd.setOriVoucherNo("");
|
||||
rd.setOriVoucherType("");
|
||||
list.add(rd);
|
||||
// }
|
||||
// bizContent.setRd(list);
|
||||
// log.info("rd:{}",JSONUtil.toJsonStr(list));
|
||||
// String zip = IcbcTools.ZipandBase64(("rd:" + JSONUtil.toJsonStr(list)).getBytes());
|
||||
// String jsonStr = "\"rd\":" + JSONUtil.toJsonStr(list);
|
||||
// String jsonStr = JSONUtil.toJsonStr(list);
|
||||
// log.info("RD:" + JSONUtil.parseObj(bizContent).getJSONArray("rd").toStringPretty());
|
||||
// String jsonStr = "\"rd\":" + JSONUtil.toJsonPrettyStr(list);
|
||||
// jsonStr = jsonStr.replaceAll("\"(\\w+)\"\\s?:","$1 : ");
|
||||
// log.info("jsonStr:\n{}",jsonStr);
|
||||
// String zip = IcbcTools.gzip(jsonStr.getBytes());
|
||||
// log.info("compressed:{}",zip);
|
||||
//
|
||||
// log.info("decompressed:{}",new String(IcbcTools.ungzip(zip)));
|
||||
// String decryptStr = new String(IcbcTools.UnZipandUnbase64(zip));
|
||||
// log.info("decryptStr:\n{}",decryptStr);
|
||||
// String zip = Base64Utils.encodeToString(ZipUtil.gzip("rd:" + JSONUtil.toJsonStr(list),"UTF-8"));
|
||||
|
||||
String icbcStr =
|
||||
"H4sIAAAAAAAAAH1Uz2sTQRS+C/4PIWeFmd1suutRD968eBKRYbo7jUuzPzq7Wwjiwb8lhzYRi7Gp" +
|
||||
"NTGU0hrINqJr4jYItQdF9OJBQehBxJnN0rSb2cxpHt/3vnnvezNDjcKNwv2rVwrpejTb8hXYJloO" +
|
||||
"PBOZnFdk4U0W3SVrsHjtMtNEHllDtsNpItzTHxIjqBJkYJ9wkgQkAGRJyRJdXEN+zU04cyoMJBRh" +
|
||||
"XXcC2+cMLgI0TQWaBMtALWtS+bqqQQhkAEribN22sZXIx8PXG52T3gjFw3e/Xnw5+jjZHB+Kk8h5" +
|
||||
"Uha3sI0rXBZTI+1fUxRVVZLSAFySJdbq4qxU+k1vexD3Dv5uD7r9V53w+4d455moHHLRASgvSXIJ" +
|
||||
"lqAiCRsmFxre/fryT/u0NZic7G89j/Z/1Def3A7P6o320fGn8He4Jc7P79100EoVV4Sj8lgO0k2/" +
|
||||
"lk+Zyi8c9lSCw63WXkPMWMb2aup8CUiKzH2XYI4ZU3LaT/cfU60f9vuN9rfw7WhndBZFnXD38zh6" +
|
||||
"f9p5Otw7+NkdH29EUVZKDygltp7UdevOvSyMrXQ4EIBsEQF1HY915RhCR1OcQ5NmPJwzNbAsTJNz" +
|
||||
"4+aomQOziXFGGs0d4Xi+p1PTTa7PLMryKFlJXZ1HquwRGyifQajL/gNq4uoCAvsR9NUcPPl08kxy" +
|
||||
"qInWnYDl0/Pbs4gjPuISI+eCu5S9NdelznpuJ5RUAmaH6dgoO1xQnFEfT7cP/gMM28fScQUAAA==";
|
||||
|
||||
String zipStr =
|
||||
"UEsDBBQACAgIALxr4lIAAAAAAAAAAAAAAAABAAAAfn1UQW/TMBS+8yuqnkFykqZrOMKdCyeEkOUl" +
|
||||
"3ojWJpnTTKoQEgxWOrayTetWBh2jCI1NVKtURtvRjl+TuMlpfwEnDWULbn3y0/e9z37fezbRUndT" +
|
||||
"j2+l4vVssguXY+hw3rF1qIesNAvvseghXhbSt28QdWjjZWiYIYsD2+pTrDl5DDVUxCFHBCIAkign" +
|
||||
"eBYqwWLJiihJDYZhApGqmo5RDAmhBFCUHFBEIQtyWUXM3skpggAkADLcZNUwUCES98+PaaU3Omt6" +
|
||||
"Z13IAu9tk/7c8Nt7bn93VDvhZuNJdgIuIAMthvKIaLEHiizncnJ0QyDMSSKrd2ZSLOxtHNHTA6/6" +
|
||||
"mX4chputnr92Mfr6O/jSoL0m51b4uiGCNCdKGSEjyCKvfnytfvrpe/B61Tuv0XaNvhh4+2+Cw24w" +
|
||||
"eHc1rLj9I9qvXw3X/XbVHXRop+K9+saVm2qIbsKFPFrkddFmGVDVi6WpjLH2rCkYC0R+bdbdXy0u" +
|
||||
"ZR4ZS3EzMkCUpbAVosD3Zcz9a83FPpP1q+WgfuKVG/Rwx9sru/0PwW7Xb276q013cEkb68HBtrfW" +
|
||||
"8rb6wWmLdn7QWpuhCXXVIQQbanTV+w8eJVBUiBsnAJC4lUMs02ZlmhrP3hiO5viyxaY36bFTKCAS" +
|
||||
"nUp33vvHL/k4619IiaPkGaZdtFWiW9Fk/YsSNIIXYpP/A/LsqWtwKgETi/0ZREf56Tj7NdQlPhz9" +
|
||||
"SlP8MYkOV0yHZZPJHM2gcPVvEPhTbhH2+iyLmCvTaiB40WE26KYBky0F6QnzebR78gdQSwcI1cmO" +
|
||||
"600CAACJBQAAUEsBAhQAFAAICAgAvGviUtXJjutNAgAAiQUAAAEAAAAAAAAAAAAAAAAAAAAAAH5Q" +
|
||||
"SwUGAAAAAAEAAQAvAAAAfAIAAAAA";
|
||||
|
||||
String gzipStr =
|
||||
"H4sIAAAAAAAAAH1UQW/TMBS+8yuqnkFykqZrOMKdCyeEkOUl3ojWJpnTTKoQEgxWOrayTetWBh2j" +
|
||||
"CI1NVKtURtvRjl+TuMlpfwEnDWULbn3y0/e9z37fezbRUndTj2+l4vVssguXY+hw3rF1qIesNAvv" +
|
||||
"seghXhbSt28QdWjjZWiYIYsD2+pTrDl5DDVUxCFHBCIAkigneBYqwWLJiihJDYZhApGqmo5RDAmh" +
|
||||
"BFCUHFBEIQtyWUXM3skpggAkADLcZNUwUCES98+PaaU3Omt6Z13IAu9tk/7c8Nt7bn93VDvhZuNJ" +
|
||||
"dgIuIAMthvKIaLEHiizncnJ0QyDMSSKrd2ZSLOxtHNHTA6/6mX4chputnr92Mfr6O/jSoL0m51b4" +
|
||||
"uiGCNCdKGSEjyCKvfnytfvrpe/B61Tuv0XaNvhh4+2+Cw24weHc1rLj9I9qvXw3X/XbVHXRop+K9" +
|
||||
"+saVm2qIbsKFPFrkddFmGVDVi6WpjLH2rCkYC0R+bdbdXy0uZR4ZS3EzMkCUpbAVosD3Zcz9a83F" +
|
||||
"PpP1q+WgfuKVG/Rwx9sru/0PwW7Xb276q013cEkb68HBtrfW8rb6wWmLdn7QWpuhCXXVIQQbanTV" +
|
||||
"+w8eJVBUiBsnAJC4lUMs02ZlmhrP3hiO5viyxaY36bFTKCASnUp33vvHL/k4619IiaPkGaZdtFWi" +
|
||||
"W9Fk/YsSNIIXYpP/A/LsqWtwKgETi/0ZREf56Tj7NdQlPhz9SlP8MYkOV0yHZZPJHM2gcPVvEPhT" +
|
||||
"bhH2+iyLmCvTaiB40WE26KYBky0F6QnzebR78gfVyY7riQUAAA==";
|
||||
|
||||
String jzipStr = "UEsDBBQACAgIAGdu4lIAAAAAAAAAAAAAAAABAAAAfg==";
|
||||
|
||||
// bizContent.setZipFlag("0");
|
||||
// if(bizContent.getRd().size() >= 2) {
|
||||
bizContent.setZipFlag("1");
|
||||
// }
|
||||
|
||||
/** RD 转 Json串 */
|
||||
String json = JSONUtil.toJsonPrettyStr(list);
|
||||
// json = "rd:" + json;
|
||||
log.info("Json:\n{}",json);
|
||||
|
||||
/** 将Json用zip压缩 */
|
||||
String zipStr = "";
|
||||
// 用Zip压缩
|
||||
// zipStr = ZipTools.zip(json.getBytes(StandardCharsets.UTF_8));
|
||||
// 用GZip压缩
|
||||
// zipStr = ZipTools.gzip(json.getBytes(StandardCharsets.UTF_8));
|
||||
// 用JZip压缩
|
||||
zipStr = ZipTools.jzip(json.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// bizContent.setZipFlag("1");
|
||||
bizContent.setZip(zipStr);
|
||||
|
||||
request.setServiceUrl(baseURL + "/" + URI);
|
||||
request.setBizContent(bizContent);
|
||||
Map<String,Object> map = BeanUtil.beanToMap(request,true,true);
|
||||
|
||||
// log.info("request:{}",XmlUtil.toStr(XmlUtil.mapToXml(map,"root")));
|
||||
log.info("request:{}",JSONUtil.toJsonStr(request));
|
||||
|
||||
// String xml = JSONUtil.toXmlStr(JSONUtil.parseObj(request));
|
||||
// log.info("xml:{}",xml);
|
||||
log.info("request:\n{}",JSONUtil.toJsonPrettyStr(request));
|
||||
|
||||
MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitResponseV1 response = client.execute(request);
|
||||
|
||||
@@ -241,142 +165,68 @@ public class IcbcTest {
|
||||
bizContent.setfSeqNo(seqNo);
|
||||
request.setServiceUrl(baseURL + "/" + URI);
|
||||
request.setBizContent(bizContent);
|
||||
bizContent.setQryFSeqNo("202103050000000009");
|
||||
|
||||
// bizContent.setQryFSeqNo("20210709104459897471");
|
||||
bizContent.setQryFSeqNo("20210709103955492472");
|
||||
// bizContent.setQryFSeqNo("202103050000000009");
|
||||
|
||||
log.info("request:{}",JSONUtil.toJsonStr(request));
|
||||
|
||||
MybankEnterpriseSalaryFinancialofficeMesfinstrqryResponseV1 response = client.execute(request);
|
||||
|
||||
// Console.log("rs:{}",response);
|
||||
log.info("response:{}",JSONUtil.toJsonPrettyStr(response));
|
||||
if (response.isSuccess()) {
|
||||
// 业务成功处理
|
||||
System.out.println("success");
|
||||
// log.info("response:{}",XmlUtil.toStr(XmlUtil.beanToXml(response),true));
|
||||
// log.info("response:{}",BeanUtil.beanToMap(response));
|
||||
log.info("response:{}",BeanToJson.toJson(response));
|
||||
|
||||
// 业务成功处理
|
||||
if(StrUtil.equals(response.getZipFlag(),"1")) {
|
||||
String zipStr = ZipTools.unjzip(response.getZip());
|
||||
// Console.log("zipStr:{}",zipStr);
|
||||
// ArrayList arrayList = new ArrayList();
|
||||
JSONArray array = JSONUtil.parseArray(zipStr);
|
||||
response.setRd(JSONUtil.toList(array,MybankEnterpriseSalaryFinancialofficeMesfinstrqryResponseV1.MybankEnterpriseSalaryFinancialofficeMesfinstrqryResponseRdV1.class));
|
||||
response.setZip(null);
|
||||
// Console.log("array:" + array);
|
||||
}
|
||||
// else{
|
||||
//
|
||||
// }
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
BeanUtil.beanToMap(response,map,true,true);
|
||||
log.info("map:{}",map);
|
||||
|
||||
// log.info("map:{}",map);
|
||||
JSONConverter convert = new JSONConverter();
|
||||
// JSON json = convert.convert(response,null);
|
||||
JSON json = convert.convert(map,null);
|
||||
log.info("response:{}",JSONUtil.toXmlStr(json));
|
||||
} else {
|
||||
// 失败
|
||||
System.out.println("error");
|
||||
// log.info("response:{}",XmlUtil.toStr(XmlUtil.beanToXml(response),true));
|
||||
// log.info("response:{}",BeanUtil.beanToMap(response));
|
||||
log.info("response:{}",BeanUtil.beanToMap(response));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// public static void main(String[] args) throws Exception {
|
||||
//
|
||||
// int sum = 10;
|
||||
// int rand = (int)(Math.random() * (double)sum);
|
||||
//
|
||||
//
|
||||
// String[] cols = new String[]{"A", "B", "C", "D"};
|
||||
// int[] rates = new int[]{10, 10, 30, 50};
|
||||
// int[] lvl = new int[]{1, 1, 1, 1};
|
||||
// String[] rulno = new String[]{"NN", "DB", "jjc", "BOC"};
|
||||
// for (int i = 0; i < 30; ++i) {
|
||||
// String[] tmp = new IcbcTest().process(cols, rates, lvl, rulno);
|
||||
// System.out.println(String.valueOf(tmp[0]) + "|" + tmp[1] + "|" + tmp[2] + "|" + tmp[3]);
|
||||
// }
|
||||
//
|
||||
// System.out.println("sum:" + String.valueOf(sum));
|
||||
// System.out.println("rand:" + String.valueOf(rand));
|
||||
//
|
||||
// }
|
||||
// public static void hello() {
|
||||
// log.info("hello");
|
||||
// }
|
||||
// public void world() {
|
||||
// log.info("world");
|
||||
// }
|
||||
|
||||
private String[] process(String[] columns, int[] rates, int[] lvl, String[] rulno) throws Exception {
|
||||
int i;
|
||||
int sum = 0;
|
||||
String[] rulinf = new String[4];
|
||||
int max_lvl = lvl[0];
|
||||
for (int i2 = 0; i2 < rates.length; ++i2) {
|
||||
if (lvl[i2] != max_lvl) continue;
|
||||
sum += rates[i2];
|
||||
}
|
||||
int rand = (int)(Math.random() * (double)sum);
|
||||
sum = 0;
|
||||
for (i = 0; i < rates.length; ++i) {
|
||||
if (lvl[i] == max_lvl && (sum += rates[i]) > rand) break;
|
||||
}
|
||||
rulinf[0] = columns[i];
|
||||
rulinf[1] = String.valueOf(rates[i]);
|
||||
rulinf[2] = String.valueOf(lvl[i]);
|
||||
rulinf[3] = rulno[i];
|
||||
return rulinf;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
// String str =
|
||||
// "H4sIAAAAAAAAAH1Uz2sTQRS+C/4PIWeFmd1suutRD968eBKRYbo7jUuzPzq7Wwjiwb8lhzYRi7Gp\n" +
|
||||
// "NTGU0hrINqJr4jYItQdF9OJBQehBxJnN0rSb2cxpHt/3vnnvezNDjcKNwv2rVwrpejTb8hXYJloO\n" +
|
||||
// "PBOZnFdk4U0W3SVrsHjtMtNEHllDtsNpItzTHxIjqBJkYJ9wkgQkAGRJyRJdXEN+zU04cyoMJBRh\n" +
|
||||
// "XXcC2+cMLgI0TQWaBMtALWtS+bqqQQhkAEribN22sZXIx8PXG52T3gjFw3e/Xnw5+jjZHB+Kk8h5\n" +
|
||||
// "Uha3sI0rXBZTI+1fUxRVVZLSAFySJdbq4qxU+k1vexD3Dv5uD7r9V53w+4d455moHHLRASgvSXIJ\n" +
|
||||
// "lqAiCRsmFxre/fryT/u0NZic7G89j/Z/1Def3A7P6o320fGn8He4Jc7P79100EoVV4Sj8lgO0k2/\n" +
|
||||
// "lk+Zyi8c9lSCw63WXkPMWMb2aup8CUiKzH2XYI4ZU3LaT/cfU60f9vuN9rfw7WhndBZFnXD38zh6\n" +
|
||||
// "f9p5Otw7+NkdH29EUVZKDygltp7UdevOvSyMrXQ4EIBsEQF1HY915RhCR1OcQ5NmPJwzNbAsTJNz\n" +
|
||||
// "4+aomQOziXFGGs0d4Xi+p1PTTa7PLMryKFlJXZ1HquwRGyifQajL/gNq4uoCAvsR9NUcPPl08kxy\n" +
|
||||
// "qInWnYDl0/Pbs4gjPuISI+eCu5S9NdelznpuJ5RUAmaH6dgoO1xQnFEfT7cP/gMM28fScQUAAA== ";
|
||||
|
||||
// String base64 = "UEsDBBQACAgIANVU2VIAAAAAAAAAAAAAAAABAAAAfg==";
|
||||
// log.info("base64:{}",base64);
|
||||
// ByteArrayInputStream bais = new ByteArrayInputStream(Base64.getDecoder().decode(base64));
|
||||
// log.info("bais:{}",bais);
|
||||
// FastByteArrayOutputStream fb = IoUtil.read(bais,true);
|
||||
// String a = fb.toString(Charsets.UTF_8);
|
||||
// log.info("a:{}",a);
|
||||
String json = "[{\"summary\":\"工资\",\"refNo\":\"20210625104128751702\",\"payeeCnname\":\"音偏漾\",\"amount\":1,\"purpose\":\"工资\",\"payerCnname\":\"榔右蝗呵如咪仔牌芝降化僵侦柱\",\"postscript\":\"工资\",\"oriVoucherNo\":\"\",\"managerCardNo\":\"\",\"busiCode\":\"\",\"oriVoucherName\":\"\",\"managerCardName\":\"\",\"payeeCity\":\"\",\"payerAccount\":\"0200080609200100843\",\"payType\":\"3\",\"summaryEn\":\"Salary\",\"oriVoucherType\":\"\",\"ioFlag\":\"1\",\"iSeqNo\":\"20210625104128751702\",\"currency\":\"CNY\",\"payeeAccount\":\"6212260200197040005\",\"relatedRefNo\":\"\"},{\"summary\":\"工资\",\"refNo\":\"20210625104128751702\",\"payeeCnname\":\"音偏漾\",\"amount\":1,\"purpose\":\"工资\",\"payerCnname\":\"榔右蝗呵如咪仔牌芝降化僵侦柱\",\"postscript\":\"工资\",\"oriVoucherNo\":\"\",\"managerCardNo\":\"\",\"busiCode\":\"\",\"oriVoucherName\":\"\",\"managerCardName\":\"\",\"payeeCity\":\"\",\"payerAccount\":\"0200080609200100843\",\"payType\":\"3\",\"summaryEn\":\"Salary\",\"oriVoucherType\":\"\",\"ioFlag\":\"1\",\"iSeqNo\":\"20210625104128751702\",\"currency\":\"CNY\",\"payeeAccount\":\"6212260200197040005\",\"relatedRefNo\":\"\"}]";
|
||||
log.info(JSONArray.parse(json).toString());;
|
||||
log.info("json:{}",json);
|
||||
|
||||
byte[] bb = ZipUtil.gzip(json,"UTF-8");
|
||||
log.info("bb{}",bb);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ZipOutputStream zos = new ZipOutputStream(baos);
|
||||
zos.putNextEntry(new ZipEntry("-"));
|
||||
zos.write(json.getBytes());
|
||||
byte[] bs = baos.toByteArray();
|
||||
log.info("bs:{}",bs);
|
||||
String base64 = Base64.getEncoder().encodeToString(bs);
|
||||
log.info("base64:{}",base64);
|
||||
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
log.info("encoder:{}",encoder.encode(bs));
|
||||
String str2 = "UEsDBBQACAgIAFRS6VIAAAAAAAAAAAAAAAABAAAAfo1Su04CQRTt+QqytcXMLk87JVpSiDExhGJcRtzIzqyzu8XGWPhoNBiiIRgLQiWFoTGEWGj4GobHXzizQJgFjN5ic3PPmXMfe4qxuIjL8CtDc33bRizQtuPauNstwtK42+Cfb5P+nba1ZDF8mqeSowMdgjTIQgAzCWAAkadVooMCjHOEIBtL+rTd49f10fdA5SCb+sQTMFQf+syhbvhovb1UZUvVUafB671J64U/9Xnnhj+/D78a4/va5KE1fX3ktSa/7Q8HnVH7IyJCXc81meV4fyxLmXVEffMMs9nOKmYjgipiFsTK6+CJ71o5WsardUVwvsFvkhvg2UUtL9gEsB3TnB9TAzoAIANSICsSKNKEsUI/DJxQPlKfG2CPSKSAqtIMq+13ETmfrWuATFL8eBHQ2LzioomKWnS/iiqhfyLlAr74n61MnzFMzPAGufzx2oDKGVI61PWUPAbMpoEcNRl1chV5uHywMLQWQlex0g9QSwcIkEzkJm8BAAAaAwAAUEsBAhQAFAAICAgAVFLpUpBM5CZvAQAAGgMAAAEAAAAAAAAAAAAAAAAAAAAAAH5QSwUGAAAAAAEAAQAvAAAAngEAAAAA";
|
||||
String str = "UEsDBBQACAgIABVV+VIAAAAAAAAAAAAAAAABAAAAfn1SwW4TMRD9lz33YG92kyxXOHPhhKrKcnfdYJG1U3uNFCEOlFKpEJQCoaiCqqoEOaBwQFWgUqFfE282f4G962ySS32y3ryZN/Nmtp97PdwnBO1i9hQx7t3zGqAdtgNgHmx4Wy4cM4ZTYqKLiyv9cpj/vTUhQbo4IwkSZK9KtXQlelxapv7zvZgeWojLTMaC9jKDzieTbbgzn4xW4TX9SiN/+0V/Olp8/F1cDoqDy9nNv/zr8eLsRL+e6OG1SeGComdcxU+IQFm/RyrpddRVKpuUqmuVI6clEI5jrpjFgG/GbIMmiMwHmm9gR5YqTbHoI8IM5RHumr9FTcmYZn2018UdE4AG2zcsLhIryB3k/DLEpT5Nd5WQpLZoo0+HxUoIwmKbc//hYwNQ42qGYp7YMUBVdzmr7bH0y1IyWk7qAx+Clh9CEAA/sAQl6TK/rpfKjltTaUS91Xw80sOr4vyzfj/V4wP94cfsZjQ/HhRvzhdn7/TgVL+azm7H+cUvW4rJTKyVqxalvx3OT45m1z+tVRkWGUrMcVRqztA71r9aSdOHvt+0i4FRC9g7DA0Lp1UYbnkpZrhjm8ciqf1TjKJyYpq4eflyT/5KRBBcW2peuR13upV/IIKgEYVhFDZaQcstmCJJ9u9kVW4Strq6zSZreK0U3LwNlTpGba5r9AEIgrb3Yuc/UEsHCDuqhyIDAgAAqgMAAFBLAQIUABQACAgIABVV+VI7qociAwIAAKoDAAABAAAAAAAAAAAAAAAAAAAAAAB+UEsFBgAAAAABAAEALwAAADICAAAAAA==";
|
||||
|
||||
|
||||
Console.log("解压:\n{}",ZipTools.unjzip(str));
|
||||
// Console.log("解压:\n{}",ZipTools.unjzip(str2));
|
||||
|
||||
|
||||
|
||||
// ByteArrayInputStream bais = new ByteArrayInputStream(Base64.getDecoder().decode(json.getString(ZIP)));
|
||||
// InputStream is = new ZipInputStream(bais);
|
||||
// json.put(RD, JSONArray.parseArray(IOUtils.toString(is)));
|
||||
// is.close();
|
||||
// json.remove(ZIP);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// json.put(RD, JSONArray.parseArray(IOUtils.toString(is)));
|
||||
// is.close();
|
||||
// json.remove(ZIP);
|
||||
|
||||
|
||||
|
||||
// Long timestamp = System.currentTimeMillis();
|
||||
// DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// df.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||
// String dateStr = df.format(new Date(timestamp));
|
||||
//
|
||||
// System.out.println("dateStr:" + dateStr);
|
||||
// Console.log("解压后:\n{}",ZipTools.ungzip(str));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,273 +0,0 @@
|
||||
package icbc;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONConverter;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.icbc.api.DefaultIcbcClient;
|
||||
import com.icbc.api.IcbcConstants;
|
||||
import com.icbc.api.request.MybankEnterpriseSalaryFinancialofficeMesfinstrqryRequestV1;
|
||||
import com.icbc.api.request.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1;
|
||||
import com.icbc.api.response.MybankEnterpriseSalaryFinancialofficeMesfinstrqryResponseV1;
|
||||
import com.icbc.api.response.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitResponseV1;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 上午9:48 2021/2/26
|
||||
*/
|
||||
@Slf4j
|
||||
public class IcbcUatTest {
|
||||
|
||||
private static final String baseURL = "https://gw.open.icbc.com.cn/api";
|
||||
/** APP ID */
|
||||
private static final String appId = "10000000000003179768";
|
||||
/** 企业私钥 */
|
||||
private static final String privateKey = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCSCSE/9BBcKRWQqAURSEBViJmvk2JWn0UdbzxV3l+MMviWsBOBYpg98pjAgQn0dqHJDNEEI5JvwBSfa8ZVehOU82mR/EHwvAOR8KRdRyjfyWeDiG0JkShjKvX8j275Ryx7CugUxDVkLyVF/mwymveRM8elU9I7FyvN7a3KBGPgMU4QOOlS+cvA6pNBCCAGoDAmUcT7XdkQ28Zw+RCVm8Xdpc3y0tY1z+4TfzXpCbCKjaYayjS4GOg6ZLlAnAiqW9caWS4YrIlLXFVUiriGWkdITYgDDmeHgjyJo388goc262Q/6QpQEVlEht7/W7ITiyRSzX3KLjZhmoStnF3/cfItAgMBAAECggEBAIVf30U4lASH5VEzk0VAdrlnw+1OL18roYULhdBrA1rZZp7Be18M/Dx/p7ERaVUjUAl+MhuUnXaAuJUNapvAncfJNB8Hg/Xo0V3lqUgj6JnSqT7BR8yYDYncv8MGAPWcYmyR/nqQ5K52PJWbk5f4Xqj34JwHXRdoxzIRpErADbPAB02zDlAnpP/DSdgqhyTuscRIM1XyVH4ySJyKUH+qi/d1eK+nO60CHdqsT42RVHubN3bPNhWqpNvoKjfFuxfpvV4PeJhTzU6wrDDz6r24u1QM1R6kCEKfmnhTafGOQJdVv249iY4DWPGPk8PdAeJmK4KujsXtRQFFKAWl1mz/BmUCgYEA+eJreAxkjRZkPylaxLrEQtlKD0JO05jJOLsoWPOZ4fNQo29hbkgR3BtxDTDTWV8U6TLwR31pCywjrIaFGLb6Dlu6pq3PcBCWBRTGAG9JpxQuDjsmcwwbnC7LDvTo047xwsqSuqldLw+GC9XuNW3fqba0WEr+0j8FIcFDz4x7NP8CgYEAlZwTLuiXfVOlDUfOAGzW+biustFzrKnS0qBWJZTzEnHhwTrvcHS77qnH+yT0n8ff1bMIHDZv0UHhtvxxeB1prI0sa4YQTwTz9DFHCVIK9Etww4F+PaIR4ab0iY+pq+ZBYOArE2cpJ2bXRbpfO5RRW82ar7by0PYL4kE034MGvNMCgYEAxE1W16wEocFhZyz5nWqLG2jPgUU534g7K1H71EUqMhKO2pV5GMWNIjh8izw8DA1hxAC8Oa0PhDNcov/aNxwnPHhbHO2V9BdTgxJaqaTDW3nC5HMbNW3hksQ/yLQk4218BuZUdkbuaTXsvAeHZnm2JwDclC/2Fvxi761/s+BMOckCgYAPvqIiMKYosVHQaPsb/lhNZYs1FGfZBvJB6k/GmrtN+KAqhrpGGnLgtgtuub/oxM8gnTvARFZWLlnDuSNz4ZyKZT0Ef9Jdjobh7wGr0G+IsBvI52rSr6i0F67qfyz7AztkJ5NA8n1ZQTBsjSWSjpRVVfjufxFkvlAX2obm8tIVswKBgDb8Nx0UAH7uR5r6RcKwnaeN5tOhkyBNzEZpO+0L8ev4gLsWyfdRyWH2GJj/iidgLOYE4cX3XDaOh2WuFYrZtOmzwYi1AY3s3lcRjShsQP3TIyDfDF51X8FbXTMAVIT/STosP/jk+IglNAvxuBE8LdFmBijQeAabhZxhZX4V2Vhx";
|
||||
/** 企业公钥,该密钥需同步至银行内管系统 */
|
||||
private static final String publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkgkhP/QQXCkVkKgFEUhAVYiZr5NiVp9FHW88Vd5fjDL4lrATgWKYPfKYwIEJ9HahyQzRBCOSb8AUn2vGVXoTlPNpkfxB8LwDkfCkXUco38lng4htCZEoYyr1/I9u+UcsewroFMQ1ZC8lRf5sMpr3kTPHpVPSOxcrze2tygRj4DFOEDjpUvnLwOqTQQggBqAwJlHE+13ZENvGcPkQlZvF3aXN8tLWNc/uE3816Qmwio2mGso0uBjoOmS5QJwIqlvXGlkuGKyJS1xVVIq4hlpHSE2IAw5nh4I8iaN/PIKHNutkP+kKUBFZRIbe/1uyE4skUs19yi42YZqErZxd/3HyLQIDAQAB";
|
||||
/** API网关公钥 */
|
||||
//private static final String apiPublicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCGo5wMqHsnc83ZwL2G3vnzz8XHabrPqDtV3oe7epFcFAHK3FOTScy8V1pBq3dJ4hEwk86NDyiF/ebQ1XxJDkroGavRNkVNoRAbFRGg+Ibh8Zu6G6yagkpmVYymxFcWud1QrNlAqV6lptytPxTsmBOgqaOQDLwAeHT7DU9xtwUT8QIDAQAB";
|
||||
private static final String apiPublicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMpjaWjngB4E3ATh+G1DVAmQnIpiPEFAEDqRfNGAVvvH35yDetqewKi0l7OEceTMN1C6NPym3zStvSoQayjYV+eIcZERkx31KhtFu9clZKgRTyPjdKMIth/wBtPKjL/5+PYalLdomM4ONthrPgnkN4x4R0+D4+EBpXo8gNiAFsNwIDAQAB";
|
||||
// private static final String apiPublicKey =
|
||||
// "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCGo5wMqHsnc83ZwL2G3vnzz8XHa\n"
|
||||
// + "brPqDtV3oe7epFcFAHK3FOTScy8V1pBq3dJ4hEwk86NDyiF/ebQ1XxJDkroGavRNk\n"
|
||||
// + "VNoRAbFRGg+Ibh8Zu6G6yagkpmVYymxFcWud1QrNlAqV6lptytPxTsmBOgqaOQDLw\n"
|
||||
// + "AeHT7DU9xtwUT8QIDAQAB\n";
|
||||
|
||||
|
||||
/** Client */
|
||||
private static DefaultIcbcClient client = new DefaultIcbcClient(appId, IcbcConstants.SIGN_TYPE_RSA2, privateKey, apiPublicKey);;
|
||||
|
||||
@Test
|
||||
public void QueryTest()
|
||||
{
|
||||
String URI = "mybank/enterprise/salary/financialoffice/mesfinstrqry/V1";
|
||||
String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||
String time = new SimpleDateFormat("HHmmss").format(new Date());
|
||||
String seqNo = date + time + RandomUtil.randomNumbers(6);
|
||||
|
||||
|
||||
try {
|
||||
MybankEnterpriseSalaryFinancialofficeMesfinstrqryRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrqryRequestBizV1 bizContent =
|
||||
new MybankEnterpriseSalaryFinancialofficeMesfinstrqryRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrqryRequestBizV1();
|
||||
MybankEnterpriseSalaryFinancialofficeMesfinstrqryRequestV1 request = new MybankEnterpriseSalaryFinancialofficeMesfinstrqryRequestV1();
|
||||
bizContent.setTransCode("QPAYPER");
|
||||
bizContent.setTranDate(date);
|
||||
bizContent.setTranTime(time);
|
||||
bizContent.setLanguage("zh_CN");
|
||||
bizContent.setfSeqNo(seqNo);
|
||||
request.setServiceUrl(baseURL + "/" + URI);
|
||||
request.setBizContent(bizContent);
|
||||
bizContent.setQryFSeqNo("202103050000000009");
|
||||
|
||||
log.info("request:{}",JSONUtil.toJsonStr(request));
|
||||
|
||||
MybankEnterpriseSalaryFinancialofficeMesfinstrqryResponseV1 response = client.execute(request);
|
||||
|
||||
if (response.isSuccess()) {
|
||||
// 业务成功处理
|
||||
System.out.println("success");
|
||||
// log.info("response:{}",XmlUtil.toStr(XmlUtil.beanToXml(response),true));
|
||||
// log.info("response:{}",BeanUtil.beanToMap(response));
|
||||
log.info("response:{}",BeanToJson.toJson(response));
|
||||
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
BeanUtil.beanToMap(response,map,true,true);
|
||||
log.info("map:{}",map);
|
||||
|
||||
JSONConverter convert = new JSONConverter();
|
||||
// JSON json = convert.convert(response,null);
|
||||
JSON json = convert.convert(map,null);
|
||||
log.info("response:{}",JSONUtil.toXmlStr(json));
|
||||
} else {
|
||||
// 失败
|
||||
System.out.println("error");
|
||||
System.out.println("returnCode:" + response.getReturnCode());
|
||||
System.out.println("returnMsg:" + response.getReturnMsg());
|
||||
|
||||
log.info("response:{}",BeanToJson.toJson(response));
|
||||
// log.info("response:{}",XmlUtil.toStr(XmlUtil.beanToXml(response),true));
|
||||
// log.info("response:{}",BeanUtil.beanToMap(response));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void mapTest()
|
||||
{
|
||||
Father response = new Father();
|
||||
response.setName("Tom");
|
||||
|
||||
List<Father.Child> rd = new ArrayList();
|
||||
|
||||
Father.Child biz = new Father.Child();
|
||||
|
||||
biz.setName("001");
|
||||
rd.add(biz);
|
||||
|
||||
response.setChilds(rd);
|
||||
|
||||
|
||||
log.info("map:{}", BeanUtil.beanToMap(response));
|
||||
}
|
||||
|
||||
|
||||
// @Test
|
||||
// public void PayTest()
|
||||
// {
|
||||
// String URI = "mybank/enterprise/salary/financialoffice/mesfinstrsubmit/V1";
|
||||
// try {
|
||||
// MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1 request =
|
||||
// new MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1();
|
||||
// MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestBizV1 bizContent =
|
||||
// new MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestBizV1();
|
||||
// MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestRdV1 rd =
|
||||
// new MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestRdV1();
|
||||
//
|
||||
// String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||
// String time = new SimpleDateFormat("HHmmss").format(new Date());
|
||||
// String seqNo = date + time + RandomUtil.randomNumbers(6);
|
||||
//
|
||||
// bizContent.setTransCode("PAYPER");
|
||||
// bizContent.setTranDate(date);
|
||||
// bizContent.setTranTime(time);
|
||||
// bizContent.setSummaryTotal("");
|
||||
// bizContent.setBusiType("");
|
||||
// bizContent.setSettleMode("2");
|
||||
// bizContent.setLanguage("zh_CN");
|
||||
// bizContent.setTotalAmount(1L);
|
||||
// bizContent.setInstrCount(1);
|
||||
// bizContent.setfSeqNo(seqNo);
|
||||
// /** 0:不压缩 1:压缩 */
|
||||
//// bizContent.setZipFlag("0");
|
||||
//
|
||||
// rd.setAmount(1L);
|
||||
// rd.setPostscript("工资");
|
||||
// rd.setBusiCode("");
|
||||
// rd.setCurrency("CNY");
|
||||
// rd.setPurpose("工资");
|
||||
// rd.setSummary("工资");
|
||||
// rd.setSummaryEn("Salary");
|
||||
// rd.setPayerAccount("0200080609200100843");
|
||||
// rd.setPayerCnname("榔右蝗呵如咪仔牌芝降化僵侦柱");
|
||||
// rd.setPayeeAccount("6212260200197040005");
|
||||
// rd.setPayeeCnname("音偏漾");
|
||||
//// rd.setPayeeBankNo("308584000013");
|
||||
// rd.setIoFlag("1");
|
||||
// rd.setPayType("3");
|
||||
// rd.setPayeeCity("");
|
||||
// rd.setManagerCardNo("");
|
||||
// rd.setManagerCardName("");
|
||||
// rd.setRelatedRefNo("");
|
||||
// rd.setRefNo(seqNo);
|
||||
// rd.setRelatedRefNo("");
|
||||
// rd.setiSeqNo(seqNo);
|
||||
// rd.setOriVoucherName("");
|
||||
// rd.setOriVoucherNo("");
|
||||
// rd.setOriVoucherType("");
|
||||
// ArrayList<MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestRdV1> list = new ArrayList<>();
|
||||
// list.add(rd);
|
||||
//// list.add(rd);
|
||||
//// bizContent.setRd(list);
|
||||
//
|
||||
// log.info("rd:{}",JSONUtil.toJsonStr(list));
|
||||
//// String zip = IcbcTools.ZipandBase64(("rd:" + JSONUtil.toJsonStr(list)).getBytes());
|
||||
// String zip = IcbcTools.ZipandBase64(("\"rd\":" +JSONUtil.toJsonStr(list)).getBytes());
|
||||
//
|
||||
//
|
||||
// log.info("zip:{}",zip);
|
||||
// String decryptStr = new String(IcbcTools.UnZipandUnbase64(zip));
|
||||
// log.info("decryptStr:{}",decryptStr);
|
||||
//
|
||||
//// String zip = Base64Utils.encodeToString(ZipUtil.gzip("rd:" + JSONUtil.toJsonStr(list),"UTF-8"));
|
||||
//
|
||||
// /** 0:不压缩 1:压缩 */
|
||||
// bizContent.setZipFlag("1");
|
||||
// bizContent.setZip(zip);
|
||||
//
|
||||
// request.setServiceUrl(baseURL + "/" + URI);
|
||||
// request.setBizContent(bizContent);
|
||||
// Map<String,Object> map = BeanUtil.beanToMap(request,true,true);
|
||||
//
|
||||
//
|
||||
//// log.info("request:{}",XmlUtil.toStr(XmlUtil.mapToXml(map,"root")));
|
||||
// log.info("request:{}",JSONUtil.toJsonStr(request));
|
||||
//
|
||||
//// String xml = JSONUtil.toXmlStr(JSONUtil.parseObj(request));
|
||||
//// log.info("xml:{}",xml);
|
||||
//
|
||||
// MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitResponseV1 response = client.execute(request);
|
||||
//
|
||||
// if (response.isSuccess()) {
|
||||
// // 业务成功处理
|
||||
// System.out.println("success");
|
||||
// log.info("response:{}", BeanUtil.beanToMap(response,true,true));
|
||||
// } else {
|
||||
// // 失败
|
||||
// System.out.println("error");
|
||||
// log.info("response:{}", BeanUtil.beanToMap(response));
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
int sum = 10;
|
||||
int rand = (int)(Math.random() * (double)sum);
|
||||
|
||||
|
||||
String[] cols = new String[]{"A", "B", "C", "D"};
|
||||
int[] rates = new int[]{10, 10, 30, 50};
|
||||
int[] lvl = new int[]{1, 1, 1, 1};
|
||||
String[] rulno = new String[]{"NN", "DB", "jjc", "BOC"};
|
||||
for (int i = 0; i < 30; ++i) {
|
||||
String[] tmp = new IcbcUatTest().process(cols, rates, lvl, rulno);
|
||||
System.out.println(String.valueOf(tmp[0]) + "|" + tmp[1] + "|" + tmp[2] + "|" + tmp[3]);
|
||||
}
|
||||
|
||||
System.out.println("sum:" + String.valueOf(sum));
|
||||
System.out.println("rand:" + String.valueOf(rand));
|
||||
|
||||
}
|
||||
public static void hello() {
|
||||
log.info("hello");
|
||||
}
|
||||
public void world() {
|
||||
log.info("world");
|
||||
}
|
||||
|
||||
private String[] process(String[] columns, int[] rates, int[] lvl, String[] rulno) throws Exception {
|
||||
int i;
|
||||
int sum = 0;
|
||||
String[] rulinf = new String[4];
|
||||
int max_lvl = lvl[0];
|
||||
for (int i2 = 0; i2 < rates.length; ++i2) {
|
||||
if (lvl[i2] != max_lvl) continue;
|
||||
sum += rates[i2];
|
||||
}
|
||||
int rand = (int)(Math.random() * (double)sum);
|
||||
sum = 0;
|
||||
for (i = 0; i < rates.length; ++i) {
|
||||
if (lvl[i] == max_lvl && (sum += rates[i]) > rand) break;
|
||||
}
|
||||
rulinf[0] = columns[i];
|
||||
rulinf[1] = String.valueOf(rates[i]);
|
||||
rulinf[2] = String.valueOf(lvl[i]);
|
||||
rulinf[3] = rulno[i];
|
||||
return rulinf;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
package icbc;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.icbc.api.DefaultIcbcClient;
|
||||
import com.icbc.api.IcbcConstants;
|
||||
import com.icbc.api.request.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1;
|
||||
import com.icbc.api.response.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitResponseV1;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 上午9:48 2021/2/26
|
||||
*/
|
||||
@Slf4j
|
||||
public class IcbcZipTest {
|
||||
|
||||
// private static final String baseURL = "https://apipcs3.dccnet.com.cn/api";
|
||||
private static final String baseURL = "http://localhost:8888/api";
|
||||
/** APP ID */
|
||||
private static final String appId = "10000000000000201052";
|
||||
/** 企业私钥 */
|
||||
private static final String privateKey = "MIIEugIBADANBgkqhkiG9w0BAQEFAASCBKQwggSgAgEAAoIBAQCL9ZYVYKKQjL6WoebVFQSQOthASOb3Z5i1C6UKyq+xG0dmNTERxbkhkHbB7qhf/5JxputBjszLnNP26DFBlIZS2/FN2qBxQrA79nr1O2PVsiTojjXA/ryAYxaCjxW+/XrZYPbtTUc6p7iE4DqbMLlew6v+RaAsnJbgZuAuvzUsaeGuHuyRCYMXkXEbGsEpb9aiwRnj7zPfAw/VBkpde/xORl0G5kCwJDvgxS7i88bK5jepLJE+34QFqByd3Qhlr+kbOgUwLeAlW3qvuK05ksKXvMzTllhBw5bA1Vy30crb+XzMY+8aqkoekLmyOFi9EcaEjDF6KMOiyLEgXWvm8kPFAgMBAAECggEAG0V1QyEbTBNAp9VQR0DbLMdqj8wkxRx4kv574EhyR45LMU04DIB8fF/L5Cn+wQXpoR+nQ5TxrtMWMkw4HNE2Azs8H7F0Bd26vVRfzR0PbPpTWsUrEDoSvOmR30rGL/rwTx8nvkGKmZFI0QtoIAk0dZSnFNq4RTkV5Q/mqvUzBT4qAjl9gKkTpFmJxrfKFAzXVWs57NevKlgS1CwYy1O+Fh1iBXhxHEKuBzv/8EA/7D38kIUhsJJzJmav+/HPCiosdEdNAjTeH4cIWcC/oiegJOcI8nQLLNPhag5cP51Eg88DtDDIyLrylyP9IpFARFZRy5ITTBBdfaFtqv3biB0+QQKBgQDYLPOzFZvXnhgutflqdzwApTeDMhZgnUg/G/vdPqiqC/QkOS4god/G4QAT4WnXyf+55EkCwHvRd0LbWkJNmEkAuSCVwVGbjxfgFdJVeeEjsgbYPfI4kXw4D100EwVvL4AWB7hDVdXPi+4b7419L/9nMq295VHb9SLQBBR6kBpZjQKBgQClvjOwmSqga4mTOCdL9EJINn/wbHO/h6s8P/p9VHXfwOiSUPpExInvIIayHXsD4fMazpkEiUrOAOg79YFpIae6L5X7QCdG8dDG+C3DLrqYgwQPvQibUig2R6A033cn5A3MiuzsppB+ODYyVmfsjyUX9GmZqvplp1W0mQbbfRPZGQKBgFB5Y3teZvZ8jwoMij39ByRCXQkFA1mSE4wS0c8J/WXYL1mww6A4QoLZzdqYxnsjYoSEHD3fA/j1Sbk4v4f9UefoAt5c6hFb0oqD9RoG1i4gnvWvEdXHKxP/fDXfgt1iNG9/DjRa5s5tjAVwRx68WHrFXfJcRP36IqyHaEw8CuMdAoGAbCxAJjFBLeQhrTEIDL2FiQXw6GSQAuAz9SW4gZXfPML1x5EMVleDwssSvisZf4Y3mTZfjiNg7CSRbZik9o2dn5mxJINRXy8x2Lpfe7UC2ckgnHj+pgiv8AU9XWS/qwxfqTC+wxFO2uIrFR1pxG4EgqblSQLbW/8jo7QAUr5GdvkCfwf4zaSYiu4ic7Andc0MP3O7Cd9IZdoFil+QoGUx8SsZoGL3kxgjYxtGeOAfOeoDlRi8tl7+0fwi4KDA99e5EAcyBVlOlmIPlF9PjRFV2ipE4wjTGB/3OX4QdVf1t5J4AvOx27Y+Z1aFFZEDMQb5Uk5HyZvnflIIt2SdEYWHnQY";
|
||||
/** 企业公钥,该密钥需同步至银行内管系统 */
|
||||
private static final String publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAi/WWFWCikIy+lqHm1RUEkDrYQEjm92eYtQulCsqvsRtHZjUxEcW5IZB2we6oX/+ScabrQY7My5zT9ugxQZSGUtvxTdqgcUKwO/Z69Ttj1bIk6I41wP68gGMWgo8Vvv162WD27U1HOqe4hOA6mzC5XsOr/kWgLJyW4GbgLr81LGnhrh7skQmDF5FxGxrBKW/WosEZ4+8z3wMP1QZKXXv8TkZdBuZAsCQ74MUu4vPGyuY3qSyRPt+EBagcnd0IZa/pGzoFMC3gJVt6r7itOZLCl7zM05ZYQcOWwNVct9HK2/l8zGPvGqpKHpC5sjhYvRHGhIwxeijDosixIF1r5vJDxQIDAQAB";
|
||||
/** API网关公钥 */
|
||||
private static final String apiPublicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwFgHD4kzEVPdOj03ctKM7KV+16bWZ5BMNgvEeuEQwfQYkRVwI9HFOGkwNTMn5hiJXHnlXYCX+zp5r6R52MY0O7BsTCLT7aHaxsANsvI9ABGx3OaTVlPB59M6GPbJh0uXvio0m1r/lTW3Z60RU6Q3oid/rNhP3CiNgg0W6O3AGqwIDAQAB";
|
||||
/** Client */
|
||||
private static DefaultIcbcClient client = new DefaultIcbcClient(appId, IcbcConstants.SIGN_TYPE_RSA2, privateKey, apiPublicKey);;
|
||||
|
||||
|
||||
@Test
|
||||
public void PayTest()
|
||||
{
|
||||
String URI = "mybank/enterprise/salary/financialoffice/mesfinstrsubmit/V1";
|
||||
try {
|
||||
MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1 request =
|
||||
new MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1();
|
||||
MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestBizV1 bizContent =
|
||||
new MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestBizV1();
|
||||
MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestRdV1 rd =
|
||||
new MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestRdV1();
|
||||
|
||||
String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||
String time = new SimpleDateFormat("HHmmss").format(new Date());
|
||||
String seqNo = date + time + RandomUtil.randomNumbers(6);
|
||||
|
||||
bizContent.setTransCode("PAYPER");
|
||||
bizContent.setTranDate(date);
|
||||
bizContent.setTranTime(time);
|
||||
bizContent.setSummaryTotal("");
|
||||
bizContent.setBusiType("");
|
||||
bizContent.setSettleMode("2");
|
||||
bizContent.setLanguage("zh_CN");
|
||||
bizContent.setTotalAmount(1L);
|
||||
bizContent.setInstrCount(1);
|
||||
bizContent.setfSeqNo(seqNo);
|
||||
/** 0:不压缩 1:压缩 */
|
||||
bizContent.setZipFlag("1");
|
||||
|
||||
rd.setAmount(1L);
|
||||
rd.setPostscript("工资");
|
||||
rd.setBusiCode("");
|
||||
rd.setCurrency("CNY");
|
||||
rd.setPurpose("工资");
|
||||
rd.setSummary("工资");
|
||||
rd.setSummaryEn("Salary");
|
||||
rd.setPayerAccount("0200080609200100843");
|
||||
rd.setPayerCnname("榔右蝗呵如咪仔牌芝降化僵侦柱");
|
||||
rd.setPayeeAccount("6212260200197040005");
|
||||
rd.setPayeeCnname("音偏漾");
|
||||
// rd.setPayeeBankNo("308584000013");
|
||||
rd.setIoFlag("1");
|
||||
rd.setPayType("3");
|
||||
rd.setPayeeCity("");
|
||||
rd.setManagerCardNo("");
|
||||
rd.setManagerCardName("");
|
||||
rd.setRelatedRefNo("");
|
||||
rd.setRefNo(seqNo);
|
||||
rd.setRelatedRefNo("");
|
||||
rd.setiSeqNo(seqNo);
|
||||
rd.setOriVoucherName("");
|
||||
rd.setOriVoucherNo("");
|
||||
rd.setOriVoucherType("");
|
||||
ArrayList<MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestRdV1> list = new ArrayList<>();
|
||||
list.add(rd);
|
||||
bizContent.setRd(list);
|
||||
|
||||
String jsonStr = JSON.toJSONString(bizContent);
|
||||
log.info("jsonStr:{}",jsonStr);
|
||||
|
||||
JSONObject json = JSON.parseObject(jsonStr);
|
||||
JsonZipUtils.zip(json);
|
||||
log.info("json compressed:{}",json);
|
||||
JsonZipUtils.unzip(json);
|
||||
log.info("json decompressed:{}",json);
|
||||
|
||||
if( 1 == 1 )
|
||||
return;
|
||||
|
||||
|
||||
log.info("json zip:{}",json);
|
||||
|
||||
|
||||
request.setServiceUrl(baseURL + "/" + URI);
|
||||
request.setBizContent(JSONUtil.toBean(json.toJSONString(),MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitRequestBizV1.class));
|
||||
Map<String,Object> map = BeanUtil.beanToMap(request,true,true);
|
||||
log.info("request:{}",JSONUtil.toJsonStr(request));
|
||||
|
||||
MybankEnterpriseSalaryFinancialofficeMesfinstrsubmitResponseV1 response = client.execute(request);
|
||||
|
||||
if (response.isSuccess()) {
|
||||
// 业务成功处理
|
||||
System.out.println("success");
|
||||
log.info("response:{}", BeanUtil.beanToMap(response,true,true));
|
||||
} else {
|
||||
// 失败
|
||||
System.out.println("error");
|
||||
log.info("response:{}", BeanUtil.beanToMap(response));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package icbc;
|
||||
|
||||
|
||||
import cn.hutool.core.codec.Base64Encoder;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Base64;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class JsonZipUtils {
|
||||
|
||||
// public static final String ZIP_FLAG = "zip_flag";
|
||||
public static final String ZIP_FLAG = "zipFlag";
|
||||
public static final String ZIP = "zip";
|
||||
public static final String RD = "rd";
|
||||
|
||||
public static void zip(JSONObject json) throws IOException, JSONException {
|
||||
if ("1".equals(json.getString(ZIP_FLAG))) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ZipOutputStream zos = new ZipOutputStream(baos);
|
||||
zos.putNextEntry(new ZipEntry("~"));
|
||||
zos.write(json.getJSONArray(RD).toJSONString().getBytes());
|
||||
// json.put(ZIP, Base64.getEncoder().encodeToString(baos.toByteArray()));
|
||||
json.put(ZIP, Base64Encoder.encode(baos.toByteArray()));
|
||||
json.remove(RD);
|
||||
}
|
||||
}
|
||||
|
||||
public static void unzip(JSONObject json) throws IOException {
|
||||
if ("1".equals(json.getString(ZIP_FLAG))) {
|
||||
ByteArrayInputStream bais =
|
||||
new ByteArrayInputStream(Base64.getDecoder().decode(json.getString(ZIP)));
|
||||
InputStream is = new ZipInputStream(bais);
|
||||
json.put(RD, JSONArray.parseArray(IOUtils.toString(is)));
|
||||
is.close();
|
||||
json.remove(ZIP);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,23 +13,12 @@ import java.util.Base64;
|
||||
import java.util.zip.*;
|
||||
|
||||
@Slf4j
|
||||
public class IcbcTools {
|
||||
|
||||
public static String zip(byte[] src) throws IOException
|
||||
{
|
||||
if (src == null)
|
||||
return null;
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ZipOutputStream gzip = new ZipOutputStream(out);
|
||||
gzip.putNextEntry(new ZipEntry("~"));
|
||||
// GZIPOutputStream gzip = new GZIPOutputStream(out);
|
||||
gzip.write(src);
|
||||
gzip.close();
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
return encoder.encode(out.toByteArray());
|
||||
}
|
||||
public class ZipTools {
|
||||
|
||||
|
||||
/*
|
||||
* 工行银企直连开发手册中的加密方法(gzip)
|
||||
*/
|
||||
public static String gzip(byte[] src) throws IOException
|
||||
{
|
||||
if (src == null)
|
||||
@@ -42,12 +31,40 @@ public class IcbcTools {
|
||||
return encoder.encode(out.toByteArray());
|
||||
}
|
||||
|
||||
public static String jzip (byte[] src) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ZipOutputStream zos = new ZipOutputStream(baos);
|
||||
zos.putNextEntry(new ZipEntry("~"));
|
||||
zos.write(src);
|
||||
return Base64.getEncoder().encodeToString(baos.toByteArray());
|
||||
public static byte[] ungzip(String src) throws IOException
|
||||
{
|
||||
if (src == null || src.length() == 0)
|
||||
return null;
|
||||
BASE64Decoder decoder = new BASE64Decoder();
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(decoder.decodeBuffer(src));
|
||||
GZIPInputStream gzip = new GZIPInputStream(in);
|
||||
byte[] buffer = new byte[256];
|
||||
int bSize = 0;
|
||||
while ((bSize = gzip.read(buffer)) >= 0)
|
||||
{
|
||||
out.write(buffer, 0, bSize);
|
||||
}
|
||||
gzip.close();
|
||||
return out.toByteArray();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 工行后续邮件中提供的加密方法(zip)
|
||||
* */
|
||||
|
||||
public static String zip(byte[] src) throws IOException
|
||||
{
|
||||
if (src == null)
|
||||
return null;
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ZipOutputStream gzip = new ZipOutputStream(out);
|
||||
gzip.putNextEntry(new ZipEntry("~"));
|
||||
gzip.write(src);
|
||||
gzip.close();
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
return encoder.encode(out.toByteArray());
|
||||
}
|
||||
|
||||
public static byte[] unzip(String src) throws IOException {
|
||||
@@ -77,32 +94,30 @@ public class IcbcTools {
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 吴老师提供的Json方法
|
||||
*/
|
||||
public static String jzip (byte[] src) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ZipOutputStream zos = new ZipOutputStream(baos);
|
||||
zos.putNextEntry(new ZipEntry("~"));
|
||||
zos.write(src);
|
||||
zos.close();
|
||||
return Base64.getEncoder().encodeToString(baos.toByteArray());
|
||||
}
|
||||
public static String unjzip(String src) throws IOException {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.getDecoder().decode(src));
|
||||
InputStream is = new ZipInputStream(bais);
|
||||
String rs = IOUtils.toString(is);
|
||||
is.close();
|
||||
ZipInputStream zis = new ZipInputStream(bais);
|
||||
ZipEntry zipEntry = zis.getNextEntry();
|
||||
if(null == zipEntry) {
|
||||
throw new IOException();
|
||||
}
|
||||
String rs = IOUtils.toString(zis);
|
||||
zis.close();
|
||||
return rs;
|
||||
}
|
||||
|
||||
public static byte[] ungzip(String src) throws IOException
|
||||
{
|
||||
if (src == null || src.length() == 0)
|
||||
return null;
|
||||
BASE64Decoder decoder = new BASE64Decoder();
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(decoder.decodeBuffer(src));
|
||||
GZIPInputStream gzip = new GZIPInputStream(in);
|
||||
byte[] buffer = new byte[256];
|
||||
int bSize = 0;
|
||||
while ((bSize = gzip.read(buffer)) >= 0)
|
||||
{
|
||||
out.write(buffer, 0, bSize);
|
||||
}
|
||||
gzip.close();
|
||||
return out.toByteArray();
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
String jsonStr = "rd : [\n" +
|
||||
@@ -1,34 +0,0 @@
|
||||
package minio;
|
||||
|
||||
import io.minio.BucketExistsArgs;
|
||||
import io.minio.MakeBucketArgs;
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.errors.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 下午6:58 2021/3/11
|
||||
*/
|
||||
public class MinioTest {
|
||||
|
||||
@Test
|
||||
public void fileUpload() throws IOException, InvalidKeyException, InvalidResponseException, InsufficientDataException, NoSuchAlgorithmException, ServerException, InternalException, XmlParserException, ErrorResponseException {
|
||||
MinioClient minioClient = MinioClient.builder().credentials("Q3AM3UQ867SPQQA43P2F","zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG").endpoint("play.min.io").build();
|
||||
|
||||
boolean isExist = minioClient.bucketExists( BucketExistsArgs.builder().bucket("asiatrip").build());
|
||||
|
||||
if(isExist) {
|
||||
System.out.println("Bucket already exists.");
|
||||
} else {
|
||||
// 创建一个名为asiatrip的存储桶,用于存储照片的zip文件。
|
||||
minioClient.makeBucket(MakeBucketArgs.builder().bucket("asiatrip").build());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package sql;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.file.FileReader;
|
||||
import cn.hutool.core.io.file.FileWriter;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 下午6:34 2021/3/15
|
||||
*/
|
||||
public class SqlExplainer {
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void explainTest() throws IOException {
|
||||
File explainFile = new File("/tmp/explain.sql");
|
||||
FileOutputStream fio = new FileOutputStream(explainFile);
|
||||
File file = new File("/tmp/all.sql");
|
||||
|
||||
FileReader reader = new FileReader(file);
|
||||
|
||||
ArrayList<String> list = (ArrayList) reader.readLines();
|
||||
String sql = "";
|
||||
for(String s:list)
|
||||
{
|
||||
if(s.indexOf(":[[") > 0)
|
||||
{
|
||||
// System.sdjfkasdfout.println("s:" + s);
|
||||
String[] array = s.split(":");
|
||||
sql = sql + array[0].replaceAll("]","");
|
||||
|
||||
String [] arg = array[1].replace("[","").replace("]","").split(",");
|
||||
sql = String.format(sql + ";\n", arg);
|
||||
// System.out.println("arg:" + arg);
|
||||
// System.out.println("" + sql);
|
||||
// FileUtil.writeUtf8String(sql,explainFile);
|
||||
fio.write(sql.getBytes());
|
||||
fio.flush();
|
||||
sql = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = sql + s;
|
||||
}
|
||||
}
|
||||
fio.close();
|
||||
}
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
package tool;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import entity.CardBin;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 3:31 下午 2021/1/15
|
||||
*/
|
||||
public class CardBinBuilder {
|
||||
|
||||
@Test
|
||||
public void CardBinSql(){
|
||||
|
||||
ExcelReader reader = ExcelUtil.getReader("/tmp/2020年04月25日版跨行转账卡表总信息.xls");
|
||||
// ExcelReader reader = ExcelUtil.getReader("/tmp/2020年04月25日版卡表.xls");
|
||||
|
||||
|
||||
// List<CardBin> readAll = reader.read(0,5,CardBin.class);
|
||||
List<List<Object>> readAll = reader.read(4);
|
||||
|
||||
|
||||
File sql = new File("/tmp/init_cardbin.sql");
|
||||
|
||||
for(int i = 0; i<readAll.size();i++)
|
||||
{
|
||||
List<Object> col =readAll.get(i);
|
||||
CardBin bin = new CardBin();
|
||||
|
||||
String str = (String) col.get(0);
|
||||
String[] array = str.split("\n");
|
||||
|
||||
/* 银行名称 */
|
||||
bin.setBankName(array[0]);
|
||||
|
||||
/* 银行类型(全) */
|
||||
bin.setBankTypeF(array[1].replaceAll("[()]",""));
|
||||
|
||||
/* 银行类型 */
|
||||
bin.setBankType(array[1].replaceAll("[()]","").substring(0,4));
|
||||
|
||||
/* 卡名 */
|
||||
bin.setCardName((String) col.get(1));
|
||||
|
||||
/* 适用于ATM */
|
||||
if("√".equals(col.get(2))) {
|
||||
bin.setAtATM(true);
|
||||
}
|
||||
else {
|
||||
bin.setAtATM(false);
|
||||
}
|
||||
/* 适用于POS */
|
||||
if("√".equals(col.get(3))) {
|
||||
bin.setAtPOS(true);
|
||||
}
|
||||
else {
|
||||
bin.setAtPOS(false);
|
||||
}
|
||||
|
||||
|
||||
/* 磁道数 */
|
||||
bin.setTrackCount((String) col.get(4).toString().toString().split("\n")[0].trim());
|
||||
|
||||
/* 磁道初始位置 */
|
||||
bin.setTrackInitPos((String) col.get(5).toString().toString().split("\n")[0].trim());
|
||||
|
||||
/* 磁道长度 */
|
||||
bin.setTrackLength(col.get(6).toString().split("\n")[0].trim());
|
||||
bin.setCardInitPos(col.get(7).toString().split("\n")[0].trim());
|
||||
bin.setCardLength(col.get(8).toString().split("\n")[0].trim());
|
||||
bin.setCardMask(col.get(9).toString().trim());
|
||||
bin.setCardReadTrack(col.get(10).toString().split("\n")[0].trim());
|
||||
bin.setIssueInitPos(col.get(11).toString().split("\n")[0].trim());
|
||||
// bin.setFillLength(col.get(12).toString().trim());
|
||||
bin.setFillLength(String.valueOf(bin.getCardMask().replaceAll("x","").length()));
|
||||
bin.setPrefix(col.get(13).toString().trim());
|
||||
bin.setIssseReadTrack(col.get(14).toString().split("\n")[0].trim());
|
||||
bin.setCardType(col.get(15).toString().trim());
|
||||
FileUtil.appendUtf8String(buildSqlScript(bin),sql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// System.out.println(readAll.get(0).get(9));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cardName(){
|
||||
|
||||
ExcelReader reader = ExcelUtil.getReader("/Users/alawn/Documents/Work/MrTech/yc_易才/develop/银联20200425卡BIN/2020年04月25日版跨行转账卡表总信息.xls");
|
||||
// ExcelReader reader = ExcelUtil.getReader("/tmp/2020年04月25日版卡表.xls");
|
||||
|
||||
|
||||
// List<CardBin> readAll = reader.read(0,5,CardBin.class);
|
||||
List<List<Object>> readAll = reader.read(4);
|
||||
|
||||
|
||||
File sql = new File("/tmp/cardname.txt");
|
||||
|
||||
for(int i = 0; i<readAll.size();i++)
|
||||
{
|
||||
List<Object> col =readAll.get(i);
|
||||
CardBin bin = new CardBin();
|
||||
|
||||
String str = (String) col.get(0);
|
||||
String[] array = str.split("\n");
|
||||
|
||||
/* 银行名称 */
|
||||
bin.setBankName(array[0]);
|
||||
|
||||
/* 银行类型(全) */
|
||||
bin.setBankTypeF(array[1].replaceAll("[()]",""));
|
||||
|
||||
/* 银行类型 */
|
||||
bin.setBankType(array[1].replaceAll("[()]","").substring(0,4));
|
||||
|
||||
/* 卡名 */
|
||||
bin.setCardName((String) col.get(1));
|
||||
|
||||
/* 适用于ATM */
|
||||
if("√".equals(col.get(2))) {
|
||||
bin.setAtATM(true);
|
||||
}
|
||||
else {
|
||||
bin.setAtATM(false);
|
||||
}
|
||||
/* 适用于POS */
|
||||
if("√".equals(col.get(3))) {
|
||||
bin.setAtPOS(true);
|
||||
}
|
||||
else {
|
||||
bin.setAtPOS(false);
|
||||
}
|
||||
|
||||
|
||||
/* 磁道数 */
|
||||
bin.setTrackCount((String) col.get(4).toString().toString().split("\n")[0].trim());
|
||||
|
||||
/* 磁道初始位置 */
|
||||
bin.setTrackInitPos((String) col.get(5).toString().toString().split("\n")[0].trim());
|
||||
|
||||
/* 磁道长度 */
|
||||
bin.setTrackLength(col.get(6).toString().split("\n")[0].trim());
|
||||
bin.setCardInitPos(col.get(7).toString().split("\n")[0].trim());
|
||||
bin.setCardLength(col.get(8).toString().split("\n")[0].trim());
|
||||
bin.setCardMask(col.get(9).toString().trim());
|
||||
bin.setCardReadTrack(col.get(10).toString().split("\n")[0].trim());
|
||||
bin.setIssueInitPos(col.get(11).toString().split("\n")[0].trim());
|
||||
// bin.setFillLength(col.get(12).toString().trim());
|
||||
bin.setFillLength(String.valueOf(bin.getCardMask().replaceAll("x","").length()));
|
||||
bin.setPrefix(col.get(13).toString().trim());
|
||||
bin.setIssseReadTrack(col.get(14).toString().split("\n")[0].trim());
|
||||
bin.setCardType(col.get(15).toString().trim());
|
||||
FileUtil.appendUtf8String(bin.getBankType() + "|" + bin.getBankName() + "\n",sql);
|
||||
}
|
||||
}
|
||||
public String buildSqlScript(CardBin bin)
|
||||
{
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.append("insert into cmmtufit(FIT_TRK,FIT_OFS,FIT_CTT,FIT_LEN,CRD_TRK,CRD_OFS,CRD_LEN,CRD_FLG,EXP_DT_FLG,CRD_NM,INIT_MOD,BNK_TY,) values(");
|
||||
|
||||
String cardFlag = "";
|
||||
|
||||
if("借记卡".equals(bin.getCardType()))
|
||||
{
|
||||
cardFlag = "00";
|
||||
}
|
||||
else if("贷记卡".equals(bin.getCardType()))
|
||||
{
|
||||
cardFlag = "01";
|
||||
}
|
||||
else if("准贷记卡".equals(bin.getCardType()))
|
||||
{
|
||||
cardFlag = "02";
|
||||
}
|
||||
else if("预付费卡".equals(bin.getCardType()))
|
||||
{
|
||||
cardFlag = "03";
|
||||
}
|
||||
else
|
||||
{
|
||||
cardFlag = "04";
|
||||
}
|
||||
|
||||
|
||||
return String.format("insert into cmmtufit(FIT_TRK,FIT_OFS,FIT_CTT,FIT_LEN,CRD_TRK,CRD_OFS,CRD_LEN,CRD_FLG,EXP_DT_FLG,CRD_NM,INT_MOD,BNK_TYP) " +
|
||||
"values('%s','%s','%s','%s','%s','%s','%s','%s','22','%s','1','%s');\n",
|
||||
bin.getCardReadTrack(),
|
||||
bin.getCardInitPos(),
|
||||
bin.getCardMask().toUpperCase().replaceAll("X","F"),
|
||||
bin.getFillLength(),
|
||||
bin.getCardReadTrack(),
|
||||
bin.getCardInitPos(),
|
||||
bin.getCardLength(),
|
||||
cardFlag,
|
||||
bin.getCardName(),
|
||||
bin.getBankType());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package tool;
|
||||
|
||||
import io.minio.BucketExistsArgs;
|
||||
import io.minio.MakeBucketArgs;
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.errors.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 下午6:45 2021/3/11
|
||||
*/
|
||||
public class MinioTool {
|
||||
|
||||
public static void upload() throws IOException, InvalidKeyException, InvalidResponseException, InsufficientDataException, NoSuchAlgorithmException, ServerException, InternalException, XmlParserException, ErrorResponseException {
|
||||
|
||||
MinioClient minioClient = MinioClient.builder().credentials("Q3AM3UQ867SPQQA43P2F","zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG").endpoint("play.min.io").build();
|
||||
|
||||
boolean isExist = minioClient.bucketExists( BucketExistsArgs.builder().bucket("asiatrip").build());
|
||||
|
||||
if(isExist) {
|
||||
System.out.println("Bucket already exists.");
|
||||
} else {
|
||||
// 创建一个名为asiatrip的存储桶,用于存储照片的zip文件。
|
||||
minioClient.makeBucket(MakeBucketArgs.builder().bucket("asiatrip").build());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE generatorConfiguration
|
||||
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
|
||||
|
||||
<generatorConfiguration>
|
||||
<!--<classPathEntry location="/Program Files/IBM/SQLLIB/java/db2java.zip" />-->
|
||||
|
||||
<context id="Mybatis3Context" targetRuntime="MyBatis3">
|
||||
<property name="javaFileEncoding" value="UTF-8"/>
|
||||
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
|
||||
connectionURL="jdbc:mysql://localhost:3306/MyBatisCodeHelper?useLegacyDatetimeCode=false&serverTimezone=UTC&nullCatalogMeansCurrent=true"
|
||||
userId="root"
|
||||
password="">
|
||||
</jdbcConnection>
|
||||
|
||||
<javaTypeResolver>
|
||||
<property name="forceBigDecimals" value="false"/>
|
||||
</javaTypeResolver>
|
||||
|
||||
<javaModelGenerator targetPackage="model" targetProject="/Users/alawn/Documents/workspace/ctg-tester/src/main/java">
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
<property name="trimStrings" value="true"/>
|
||||
</javaModelGenerator>
|
||||
|
||||
<sqlMapGenerator targetPackage="mapperxml" targetProject="/Users/alawn/Documents/workspace/ctg-tester/src/main/resources">
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
</sqlMapGenerator>
|
||||
|
||||
<javaClientGenerator type="XMLMAPPER" targetPackage="mapper" targetProject="/Users/alawn/Documents/workspace/ctg-tester/src/main/java">
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
</javaClientGenerator>
|
||||
|
||||
<table tableName="Customer" domainObjectName="Customer" enableCountByExample="false"
|
||||
enableDeleteByExample="false" enableUpdateByExample="false" enableSelectByExample="false">
|
||||
</table>
|
||||
|
||||
</context>
|
||||
</generatorConfiguration>
|
||||
@@ -1,15 +0,0 @@
|
||||
## db.setting文件
|
||||
|
||||
url = jdbc:oracle:thin:@192.168.3.191:1521:bidb
|
||||
user = MURONG_UAT2
|
||||
pass = MURONG_UAT2
|
||||
|
||||
## 可选配置
|
||||
# 是否在日志中显示执行的SQL
|
||||
showSql = true
|
||||
# 是否格式化显示的SQL
|
||||
formatSql = true
|
||||
# 是否显示SQL参数
|
||||
showParams = true
|
||||
# 打印SQL的日志等级,默认debug,可以是info、warn、error
|
||||
sqlLevel = info
|
||||
@@ -80,8 +80,7 @@
|
||||
|
||||
|
||||
|
||||
<!-- <root level="INFO">-->
|
||||
<root level="ERROR">
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
<!-- <appender-ref ref="FILE" />-->
|
||||
<!-- <appender-ref ref="FILE-error" />-->
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
baseURL= http://172.17.20.91:9998/api
|
||||
secretKey = HelloWorld
|
||||
zipPassword = 1234567
|
||||
@@ -1,3 +0,0 @@
|
||||
baseURL= http://172.17.20.91:9998/api
|
||||
secretKey = HelloWorld
|
||||
zipPassword = 1234567
|
||||
@@ -1,4 +0,0 @@
|
||||
baseURL= http://192.168.8.41/api
|
||||
secretKey = HelloWorld
|
||||
zipPassword = 1234567
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
baseURL= http://192.168.8.41/api
|
||||
secretKey = HelloWorld
|
||||
zipPassword = 1234567
|
||||
Reference in New Issue
Block a user