commit d0bd9ef5467cdfc55d1d0baaa604151c6a81ba65 Author: Alawn Date: Mon Mar 1 18:17:06 2021 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7dc28eb --- /dev/null +++ b/.gitignore @@ -0,0 +1,327 @@ + +# Created by https://www.gitignore.io/api/java,vim,macos,linux,windows,intellij+all,microsoftoffice,maven,TortoiseGit,visualstudiocode,eclipse +# Edit at https://www.gitignore.io/?templates=java,vim,macos,linux,windows,intellij+all,microsoftoffice,maven,TortoiseGit,visualstudiocode,eclipse + +### Eclipse ### +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +### Eclipse Patch ### +# Eclipse Core +.project + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Annotation Processing +.apt_generated + +.sts4-cache/ + +### Intellij+all ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij+all Patch ### +# Ignores the whole .idea folder and all .iml files +# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 + +.idea/ + +# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 + +*.iml +modules.xml +.idea/misc.xml +*.ipr + +# Sonarlint plugin +.idea/sonarlint + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar +.flattened-pom.xml + +### MicrosoftOffice ### + +# Word temporary +~$*.doc* + +# Word Auto Backup File +Backup of *.doc* + +# Excel temporary +~$*.xls* + +# Excel Backup File +*.xlk + +# PowerPoint temporary +~$*.ppt* + +# Visio autosave temporary files +*.~vsd* + +### TortoiseGit ### +# Project-level settings +/.tgitconfig + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist + +# Auto-generated tag files +tags + +# Persistent undo +[._]*.un~ + +# Coc configuration directory +.vim + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.gitignore.io/api/java,vim,macos,linux,windows,intellij+all,microsoftoffice,maven,TortoiseGit,visualstudiocode,eclipse +n \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a86690d --- /dev/null +++ b/pom.xml @@ -0,0 +1,156 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.4.3-SNAPSHOT + + + com.murong.ecp + ctg-tester + 0.0.1-SNAPSHOT + ctg-tester + Ctg Tester + + 1.8 + + + + net.lingala.zip4j + zip4j + 2.6.4 + + + com.baomidou + mybatis-plus-boot-starter + 3.4.2 + + + + com.oracle + ojdbc8 + 12.2.0.1 + + + org.apache.httpcomponents + httpclient + 4.5.3 + + + org.apache.httpcomponents + httpcore + 4.4.6 + + + org.apache.httpcomponents + httpmime + 4.5.2 + + + alawn.cn + rhro_sfk + 1.0 + + + + com.alibaba + fastjson + 1.2.75 + + + + + + + + + cn.hutool + hutool-all + 5.5.8 + + + org.springframework.boot + spring-boot-starter + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + org.apache.commons + commons-lang3 + 3.11 + + + junit + junit + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + + alawn.cn + alawn.cn + https://alawn.cn:1024/repository/maven-releases/ + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + diff --git a/src/main/java/ctg/annotation/Api.java b/src/main/java/ctg/annotation/Api.java new file mode 100644 index 0000000..da245ba --- /dev/null +++ b/src/main/java/ctg/annotation/Api.java @@ -0,0 +1,19 @@ +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; +} diff --git a/src/main/java/ctg/annotation/ApiItem.java b/src/main/java/ctg/annotation/ApiItem.java new file mode 100644 index 0000000..68b6167 --- /dev/null +++ b/src/main/java/ctg/annotation/ApiItem.java @@ -0,0 +1,17 @@ +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; +} diff --git a/src/main/java/ctg/annotation/ApiNode.java b/src/main/java/ctg/annotation/ApiNode.java new file mode 100644 index 0000000..326d51a --- /dev/null +++ b/src/main/java/ctg/annotation/ApiNode.java @@ -0,0 +1,18 @@ +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; +} diff --git a/src/main/java/ctg/constant/CtgContants.java b/src/main/java/ctg/constant/CtgContants.java new file mode 100644 index 0000000..510ea14 --- /dev/null +++ b/src/main/java/ctg/constant/CtgContants.java @@ -0,0 +1,11 @@ +package ctg.constant; + +/** + * @Author: Alawn + * @Description: + * @Date: Create in 11:04 上午 2021/2/7 + */ +public class CtgContants { + + +} diff --git a/src/main/java/ctg/constant/PropConstants.java b/src/main/java/ctg/constant/PropConstants.java new file mode 100644 index 0000000..69ae41b --- /dev/null +++ b/src/main/java/ctg/constant/PropConstants.java @@ -0,0 +1,18 @@ +package ctg.constant; + +import cn.hutool.setting.Setting; +import lombok.Data; + +/** + * @Author: Alawn + * @Description: + * @Date: Create in 下午5:05 2021/2/24 + */ + +@Data +public class PropConstants { + private static final Setting setting = new Setting("prop.setting"); + public static String baseURL = setting.getStr("baseURL"); + public static String secretKey = setting.getStr("secretKey"); + public static String zipPassword = setting.getStr("zipPassword"); +} diff --git a/src/main/java/ctg/entity/RequestDiskHeader.java b/src/main/java/ctg/entity/RequestDiskHeader.java new file mode 100644 index 0000000..cb9a1c6 --- /dev/null +++ b/src/main/java/ctg/entity/RequestDiskHeader.java @@ -0,0 +1,43 @@ +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(); + } +} + diff --git a/src/main/java/ctg/entity/RequestDiskRow.java b/src/main/java/ctg/entity/RequestDiskRow.java new file mode 100644 index 0000000..33e920a --- /dev/null +++ b/src/main/java/ctg/entity/RequestDiskRow.java @@ -0,0 +1,40 @@ +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 bankCity = ""; + @Builder.Default + private String bankName = ""; + @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(bankCity).append(deliStr) + .append(bankName).append(deliStr) + .append(remark).append("\n"); + return sb.toString(); + } +} diff --git a/src/main/java/ctg/entity/api/Api.java b/src/main/java/ctg/entity/api/Api.java new file mode 100644 index 0000000..1e94dd2 --- /dev/null +++ b/src/main/java/ctg/entity/api/Api.java @@ -0,0 +1,49 @@ +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 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|:|-]",""); + } +} + diff --git a/src/main/java/ctg/entity/api/ApiResponse.java b/src/main/java/ctg/entity/api/ApiResponse.java new file mode 100644 index 0000000..d0b1930 --- /dev/null +++ b/src/main/java/ctg/entity/api/ApiResponse.java @@ -0,0 +1,23 @@ +package ctg.entity.api; + +import ctg.annotation.ApiItem; + +/** + * @Author: Alawn + * @Description: + * @Date: Create in 下午2:44 2021/2/24 + */ +public class ApiResponse { + + @ApiItem + private String requestId; + @ApiItem + private String respCode; + @ApiItem + private String respMessage; + @ApiItem + private String respTime; + + private T body; +} + diff --git a/src/main/java/ctg/entity/api/ApiWrapper.java b/src/main/java/ctg/entity/api/ApiWrapper.java new file mode 100644 index 0000000..a64097f --- /dev/null +++ b/src/main/java/ctg/entity/api/ApiWrapper.java @@ -0,0 +1,97 @@ +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(""); + } + 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(""); + } + 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(""); + } + } + else { + sb.append("<").append(field.getName()).append(">").append((String)item).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(""); + sb.append(iterate(this)); + sb.append(""); + 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; + + } +} diff --git a/src/main/java/ctg/entity/api/DiskApplyRequest.java b/src/main/java/ctg/entity/api/DiskApplyRequest.java new file mode 100644 index 0000000..74bae48 --- /dev/null +++ b/src/main/java/ctg/entity/api/DiskApplyRequest.java @@ -0,0 +1,46 @@ +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; +} diff --git a/src/main/java/ctg/entity/api/DiskApplyResponse.java b/src/main/java/ctg/entity/api/DiskApplyResponse.java new file mode 100644 index 0000000..ab1b839 --- /dev/null +++ b/src/main/java/ctg/entity/api/DiskApplyResponse.java @@ -0,0 +1,9 @@ +package ctg.entity.api; + +/** + * @Author: Alawn + * @Description: + * @Date: Create in 1:40 下午 2021/2/7 + */ +public class DiskApplyResponse { +} diff --git a/src/main/java/ctg/entity/api/DiskResultRequest.java b/src/main/java/ctg/entity/api/DiskResultRequest.java new file mode 100644 index 0000000..0df6bf2 --- /dev/null +++ b/src/main/java/ctg/entity/api/DiskResultRequest.java @@ -0,0 +1,24 @@ +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; +} diff --git a/src/main/java/ctg/entity/api/DiskResultResponse.java b/src/main/java/ctg/entity/api/DiskResultResponse.java new file mode 100644 index 0000000..d0384b1 --- /dev/null +++ b/src/main/java/ctg/entity/api/DiskResultResponse.java @@ -0,0 +1,24 @@ +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 ; +} diff --git a/src/main/java/ctg/entity/api/ResponseHead.java b/src/main/java/ctg/entity/api/ResponseHead.java new file mode 100644 index 0000000..e04e8c4 --- /dev/null +++ b/src/main/java/ctg/entity/api/ResponseHead.java @@ -0,0 +1,22 @@ +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; +} diff --git a/src/main/java/ctg/enums/ApiFormat.java b/src/main/java/ctg/enums/ApiFormat.java new file mode 100644 index 0000000..bb9f600 --- /dev/null +++ b/src/main/java/ctg/enums/ApiFormat.java @@ -0,0 +1,11 @@ +package ctg.enums; + +/** + * @Author: Alawn + * @Description: + * @Date: Create in 2:41 下午 2021/2/9 + */ +public enum ApiFormat { + Xml, + Json; +} diff --git a/src/main/java/ctg/enums/ApiType.java b/src/main/java/ctg/enums/ApiType.java new file mode 100644 index 0000000..7de8d38 --- /dev/null +++ b/src/main/java/ctg/enums/ApiType.java @@ -0,0 +1,11 @@ +package ctg.enums; + +/** + * @Author: Alawn + * @Description: + * @Date: Create in 2:41 下午 2021/2/9 + */ +public enum ApiType { + Xml, + Json; +} diff --git a/src/main/java/ctg/tool/DataFactory.java b/src/main/java/ctg/tool/DataFactory.java new file mode 100644 index 0000000..e4dea75 --- /dev/null +++ b/src/main/java/ctg/tool/DataFactory.java @@ -0,0 +1,292 @@ +package ctg.tool; + +import cn.hutool.core.util.IdUtil; +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 newSimpleRows(int totalCount, BigDecimal totalAmount) + { + if(totalCount <=0) { + return null; + } + + ArrayList list = new ArrayList(totalCount); + + String[] amounts = newAmounts(totalCount,totalAmount.multiply(new BigDecimal("100.00")).toBigInteger().intValue(),1); + + for(int i=0;i 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 newTitleId() throws SQLException { + String titleId = ""; + + List 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"}; + + private final static String[] Surname = {"赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈", "褚", "卫", "蒋", "沈", "韩", "杨", "朱", "秦", "尤", "许", + "何", "吕", "施", "张", "孔", "曹", "严", "华", "金", "魏", "陶", "姜", "戚", "谢", "邹", "喻", "柏", "水", "窦", "章", "云", "苏", "潘", "葛", "奚", "范", "彭", "郎", + "鲁", "韦", "昌", "马", "苗", "凤", "花", "方", "俞", "任", "袁", "柳", "酆", "鲍", "史", "唐", "费", "廉", "岑", "薛", "雷", "贺", "倪", "汤", "滕", "殷", + "罗", "毕", "郝", "邬", "安", "常", "乐", "于", "时", "傅", "皮", "卞", "齐", "康", "伍", "余", "元", "卜", "顾", "孟", "平", "黄", "和", + "穆", "萧", "尹", "姚", "邵", "湛", "汪", "祁", "毛", "禹", "狄", "米", "贝", "明", "臧", "计", "伏", "成", "戴", "谈", "宋", "茅", "庞", "熊", "纪", "舒", + "屈", "项", "祝", "董", "梁", "杜", "阮", "蓝", "闵", "席", "季"}; + private final static String girl = "秀娟英华慧巧美娜静淑惠珠翠雅芝玉萍红娥玲芬芳燕彩春菊兰凤洁梅琳素云莲真环雪荣爱妹霞香月莺媛艳瑞凡佳嘉琼勤珍贞莉桂娣叶璧璐娅琦晶妍茜秋珊莎锦黛青倩婷姣婉娴瑾颖露瑶怡婵雁蓓纨仪荷丹蓉眉君琴蕊薇菁梦岚苑婕馨瑗琰韵融园艺咏卿聪澜纯毓悦昭冰爽琬茗羽希宁欣飘育滢馥筠柔竹霭凝晓欢霄枫芸菲寒伊亚宜可姬舒影荔枝思丽 "; + private final static String boy = "伟刚勇毅俊峰强军平保东文辉力明永健世广志义兴良海山仁波宁贵福生龙元全国胜学祥才发武新利清飞彬富顺信子杰涛昌成康星光天达安岩中茂进林有坚和彪博诚先敬震振壮会思群豪心邦承乐绍功松善厚庆磊民友裕河哲江超浩亮政谦亨奇固之轮翰朗伯宏言若鸣朋斌梁栋维启克伦翔旭鹏泽晨辰士以建家致树炎德行时泰盛雄琛钧冠策腾楠榕风航弘"; + + + private static final String newCardName() + { + 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[] newAmounts(int count, BigDecimal totalAmount) + { + String[] amounts = new String[count]; + + + return amounts; + } + + + /** + * 生成金额集合 + * @param num 总笔数 + * @param totalMoney 总金额(以分为单位) + * @param minMoney 最小金额 + * @return + */ + private static String[] newAmounts(int num,long totalMoney,long minMoney){ + String[] amounts = new String[num]; + long[] each = new long[num]; + for(int i=0;i 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()); + } +} + diff --git a/src/main/java/ctg/tool/FastDFS.java b/src/main/java/ctg/tool/FastDFS.java new file mode 100644 index 0000000..0065962 --- /dev/null +++ b/src/main/java/ctg/tool/FastDFS.java @@ -0,0 +1,58 @@ +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 url = "http://192.168.17.4:8094"; + 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) + { + + } + + +} diff --git a/src/main/java/ctg/util/CardUtil.java b/src/main/java/ctg/util/CardUtil.java new file mode 100644 index 0000000..93a9014 --- /dev/null +++ b/src/main/java/ctg/util/CardUtil.java @@ -0,0 +1,124 @@ +package ctg.util; + +import java.util.Random; + +/** + * @Author: Alawn + * @Description: + * @Date: Create in 3:22 下午 2021/2/7 + */ +public class CardUtil { + + public final static String getCardNo() { + Random random = new Random(); + int index = random.nextInt(cards.length - 1); + return cards[index]; + } + + + 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"}; + + + + +} diff --git a/src/main/java/ctg/util/NameUtil.java b/src/main/java/ctg/util/NameUtil.java new file mode 100644 index 0000000..6c7daf5 --- /dev/null +++ b/src/main/java/ctg/util/NameUtil.java @@ -0,0 +1,49 @@ +package ctg.util; + +import java.util.Random; + +/** + * @Author: Alawn + * @Description: + * @Date: Create in 3:18 下午 2021/2/7 + */ +public class NameUtil { + + public final static String getName() { + Random random = new Random(); + String[] Surname = {"赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈", "褚", "卫", "蒋", "沈", "韩", "杨", "朱", "秦", "尤", "许", + "何", "吕", "施", "张", "孔", "曹", "严", "华", "金", "魏", "陶", "姜", "戚", "谢", "邹", "喻", "柏", "水", "窦", "章", "云", "苏", "潘", "葛", "奚", "范", "彭", "郎", + "鲁", "韦", "昌", "马", "苗", "凤", "花", "方", "俞", "任", "袁", "柳", "酆", "鲍", "史", "唐", "费", "廉", "岑", "薛", "雷", "贺", "倪", "汤", "滕", "殷", + "罗", "毕", "郝", "邬", "安", "常", "乐", "于", "时", "傅", "皮", "卞", "齐", "康", "伍", "余", "元", "卜", "顾", "孟", "平", "黄", "和", + "穆", "萧", "尹", "姚", "邵", "湛", "汪", "祁", "毛", "禹", "狄", "米", "贝", "明", "臧", "计", "伏", "成", "戴", "谈", "宋", "茅", "庞", "熊", "纪", "舒", + "屈", "项", "祝", "董", "梁", "杜", "阮", "蓝", "闵", "席", "季"}; + String girl = "秀娟英华慧巧美娜静淑惠珠翠雅芝玉萍红娥玲芬芳燕彩春菊兰凤洁梅琳素云莲真环雪荣爱妹霞香月莺媛艳瑞凡佳嘉琼勤珍贞莉桂娣叶璧璐娅琦晶妍茜秋珊莎锦黛青倩婷姣婉娴瑾颖露瑶怡婵雁蓓纨仪荷丹蓉眉君琴蕊薇菁梦岚苑婕馨瑗琰韵融园艺咏卿聪澜纯毓悦昭冰爽琬茗羽希宁欣飘育滢馥筠柔竹霭凝晓欢霄枫芸菲寒伊亚宜可姬舒影荔枝思丽 "; + String boy = "伟刚勇毅俊峰强军平保东文辉力明永健世广志义兴良海山仁波宁贵福生龙元全国胜学祥才发武新利清飞彬富顺信子杰涛昌成康星光天达安岩中茂进林有坚和彪博诚先敬震振壮会思群豪心邦承乐绍功松善厚庆磊民友裕河哲江超浩亮政谦亨奇固之轮翰朗伯宏言若鸣朋斌梁栋维启克伦翔旭鹏泽晨辰士以建家致树炎德行时泰盛雄琛钧冠策腾楠榕风航弘"; + 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; + } +} diff --git a/src/test/java/entity/CardBin.java b/src/test/java/entity/CardBin.java new file mode 100644 index 0000000..8a91fb5 --- /dev/null +++ b/src/test/java/entity/CardBin.java @@ -0,0 +1,56 @@ +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; +} diff --git a/src/test/java/entity/DiskInfo.java b/src/test/java/entity/DiskInfo.java new file mode 100644 index 0000000..6aea985 --- /dev/null +++ b/src/test/java/entity/DiskInfo.java @@ -0,0 +1,33 @@ +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 ; +} diff --git a/src/test/java/hro/DiskApplyRequestTest.java b/src/test/java/hro/DiskApplyRequestTest.java new file mode 100644 index 0000000..95aa4d2 --- /dev/null +++ b/src/test/java/hro/DiskApplyRequestTest.java @@ -0,0 +1,110 @@ +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.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.math.BigDecimal; +import java.sql.SQLException; +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.newCustomerId()) + .titleId(DataFactory.newTitleId()) + .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 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); + } +} + diff --git a/src/test/java/hro/DiskApplyTest.java b/src/test/java/hro/DiskApplyTest.java new file mode 100644 index 0000000..44558d2 --- /dev/null +++ b/src/test/java/hro/DiskApplyTest.java @@ -0,0 +1,38 @@ +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.newCustomerId()) + .titleId(DataFactory.newTitleId()) + .diskDesc("代发工资").build(); + + Api request = new Api<>("diskApply",body); + + log.info("request:{}",XmlUtil.format(request.toData()) ); + } + +} diff --git a/src/test/java/hro/DiskResultTest.java b/src/test/java/hro/DiskResultTest.java new file mode 100644 index 0000000..6adcf76 --- /dev/null +++ b/src/test/java/hro/DiskResultTest.java @@ -0,0 +1,75 @@ +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 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 + + } + } + + +} diff --git a/src/test/java/hro/MixedTest.java b/src/test/java/hro/MixedTest.java new file mode 100644 index 0000000..b3cfe8f --- /dev/null +++ b/src/test/java/hro/MixedTest.java @@ -0,0 +1,146 @@ +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.lang.reflect.InvocationTargetException; +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); + ThreadUtil.sleep(1000); + diskResultSimpleTest(disk); + log.info("disk:{}",disk); + + } + + @SneakyThrows + public void diskResultSimpleTest(DiskInfo disk) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { + DiskResultRequest request = DiskResultRequest.builder().applyDate(disk.getApplyDate()).diskNo(disk.getDiskNo()).build(); + Api 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)); + } + else { + throw new Exception(respMessage); + } + } + + public DiskInfo diskApplySimpleTest() throws Exception { + DiskApplyRequest request = DiskApplyRequest.builder() + .applyDate(DateUtil.format(new Date(),"YYYYMMdd")) + .customerId(DataFactory.newCustomerId()) + .titleId(DataFactory.newTitleId()) + .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 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(); + } +} diff --git a/src/test/java/icbc/IcbcTest.java b/src/test/java/icbc/IcbcTest.java new file mode 100644 index 0000000..597d0a0 --- /dev/null +++ b/src/test/java/icbc/IcbcTest.java @@ -0,0 +1,77 @@ +package icbc; + +import cn.hutool.core.date.CalendarUtil; +import cn.hutool.core.date.DateUtil; +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 lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Test; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * @Author: Alawn + * @Description: + * @Date: Create in 上午9:48 2021/2/26 + */ +@Slf4j +public class IcbcTest { + + @Test + public void PayerTest() + { + /** APP ID */ + String appId = "10000000000000201052"; + + /** 企业私钥 */ + 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"; +// String privateKey = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCDK7oPvqatEGy/WrNeHpj7z1/pF9h9ndmwd1LMD8Gq8X5cpAoxowtxD3lWoS/lLsfLFctp4Ki/twfC7EVyYuf6DuRbVmoCceqCX3Y564EL8l4il1gNfNfkhscH6V+BipCpLjuJ6LgFVuZYEUrcs4Wo5XLyUSrqXd6Q97/DjqAZxKjSixqpMJiAe+4uKwp4x2aWQC58sCMCVTBF11SdDgMokyExWkT2lBrpsGdQWLoBuecohyVA6BNeSYGyu8nqw3UUNVMeEMRIkMjyuwwE6wXxQC66CIxwozpiqPgPmdfxwWshI9yfMc+4NyuFJGs28k93SHb0U0ewH7xbcdBkZf6RAgMBAAECggEAPetxXKdaFQ5Q14/gZki5XP1KwEUCbGIMdjINwsiZWrG/PcouCbp21zs/wzY53s1TgTnbmTJ1VnL3Vfuk2Nd5vGA1SiyjxF20HzEjJTpX46TY7SlWZp+NZpJ89+4hqIwZt9NcRcC2xcZ83AvltAOGz/Dobx0DzjjbrMFXI+B7EU5HXWX5Cnx5jZizlU5v86EiGQgZCBfPjFMJTgsABYf3qlH6q0hkermA9lEIie/7dZSZMH9ojWH4R/sYJfHOUljJ0ZPFVFrn9TfPs5xNDUeuhlU7MXom2DrTTr3fXrpcamHAIP0CVG3xC3nuWWqhDha0kx/iekMS4jvl3hnE3YjucQKBgQDNsZr9AQBgCDcLYKepdjj0HZdbFYe3rPs5zgjErc0GJNtbY0UaoACS33m+lSWr8NdZwibJ0ZxughJR2ASo6o6V0YOkF5Zsqn9dQ20Vj2/oq3CN42Z4JvfLG+bnjooaHnnTKK91iR5/qImFLwv7sup7960goTDuKz8ND6tovxTOLQKBgQCjQEWqjLHneYQ4bERBikFpB0AoAxUxAK2RJDQHPuZRn3ABNU2TxHmiNOD7cF2I71zqN+yuo/G5P/uS2LA5t3PvAS1Ni9FAMLNrLTC2vM3n+VyHUjL2I6QbYYabyC+yqiTTnjdKQL8reXssprv+NcsmNRI1i/Yk4UbctWPtAFFUdQKBgAdTUe+8v2SsJjmzgYUZfsHC5AcMZz71XCUc31cR0YFsgptol6dxF1QjvVQ6P5M2CpVZwsPhQS72VuyvQss5P0a6pXOMm4DXOZ36rsHbz+J7aJDFDnss+Bo1ri2E+AoiF7ibdFQ9Q+bL+8nQeR7Hqm4rzfChjPqOc7plWndqhrUpAoGAYUKYftyl3TeLa6YtIDMDd1Rnh68WgARcY/2CtdJmm7h2nXGpT2Ed6mLAq2ytfTjGTZCWBRINoIWbF0jb7Pb8LiewWuPy/eBF9JOO00A3GH56/vAdBoIDcoCvFr60lChEGoPHgwiCHJ+an+aSWAiqiI/T0m0Zb617b2DuMLQgwEUCgYBRQYw3w16SKzHsG6LRyOBU2vbO7vqUjX2glr4Etzs6tzU+bZVu8Z1simB3oDotHKBmpU6vzx1gGI3Sanx1Bm5DCcFy3Cy/qCGCfUrrIjLLoiFRjz/ODRpnnKMH/3CL+8d0WBnHmYbBU4P47I4BmytvPGChKyv1u/FGT80NdRH9zg=="; + + /** 企业公钥,该密钥需同步至银行内管系统 */ + String publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAi/WWFWCikIy+lqHm1RUEkDrYQEjm92eYtQulCsqvsRtHZjUxEcW5IZB2we6oX/+ScabrQY7My5zT9ugxQZSGUtvxTdqgcUKwO/Z69Ttj1bIk6I41wP68gGMWgo8Vvv162WD27U1HOqe4hOA6mzC5XsOr/kWgLJyW4GbgLr81LGnhrh7skQmDF5FxGxrBKW/WosEZ4+8z3wMP1QZKXXv8TkZdBuZAsCQ74MUu4vPGyuY3qSyRPt+EBagcnd0IZa/pGzoFMC3gJVt6r7itOZLCl7zM05ZYQcOWwNVct9HK2/l8zGPvGqpKHpC5sjhYvRHGhIwxeijDosixIF1r5vJDxQIDAQAB"; + + /** API网关公钥 */ + String apiPublicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwFgHD4kzEVPdOj03ctKM7KV+16bWZ5BMNgvEeuEQwfQYkRVwI9HFOGkwNTMn5hiJXHnlXYCX+zp5r6R52MY0O7BsTCLT7aHaxsANsvI9ABGx3OaTVlPB59M6GPbJh0uXvio0m1r/lTW3Z60RU6Q3oid/rNhP3CiNgg0W6O3AGqwIDAQAB"; + + String baseURL = "https://apipcs3.dccnet.com.cn/api"; +// String baseURL = "http://127.0.0.1:8888/api"; + String URI = "mybank/enterprise/salary/financialoffice/mesfinstrqry/V1"; + DefaultIcbcClient client = new DefaultIcbcClient(appId, IcbcConstants.SIGN_TYPE_RSA2, privateKey, apiPublicKey); + try { + MybankEnterpriseSalaryFinancialofficeMesfinstrqryRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrqryRequestBizV1 bizContent = + new MybankEnterpriseSalaryFinancialofficeMesfinstrqryRequestV1.MybankEnterpriseSalaryFinancialofficeMesfinstrqryRequestBizV1(); + MybankEnterpriseSalaryFinancialofficeMesfinstrqryRequestV1 request = new MybankEnterpriseSalaryFinancialofficeMesfinstrqryRequestV1(); + bizContent.setTransCode("QPAYPER"); + String date = new SimpleDateFormat("yyyyMMdd").format(new Date()); + String time = new SimpleDateFormat("HHmmss").format(new Date()); + bizContent.setTranDate(date); + bizContent.setTranTime(time); + bizContent.setLanguage("zh_CN"); + bizContent.setfSeqNo("QPAYPER1226445574"); + request.setServiceUrl(baseURL + "/" + URI); + request.setBizContent(bizContent); + + log.info("request:{}",JSONUtil.toJsonStr(request)); + + MybankEnterpriseSalaryFinancialofficeMesfinstrqryResponseV1 response = client.execute(request); + + if (response.isSuccess()) { + // 业务成功处理 + System.out.println("success"); + } else { + // 失败 + System.out.println("error"); + log.info("msg_id:{}",response.getMsgId()); + log.info("return_code:{}",response.getReturnCode()); + log.info("return_msg:{}",response.getReturnMsg()); + } + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/test/java/tool/CardBinBuilder.java b/src/test/java/tool/CardBinBuilder.java new file mode 100644 index 0000000..0870b3e --- /dev/null +++ b/src/test/java/tool/CardBinBuilder.java @@ -0,0 +1,139 @@ +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 CardBin(){ + +// ExcelReader reader = ExcelUtil.getReader("/tmp/2020年04月25日版跨行转账卡表总信息.xls"); + ExcelReader reader = ExcelUtil.getReader("/tmp/2020年04月25日版卡表.xls"); + +// List readAll = reader.read(0,5,CardBin.class); + List> readAll = reader.read(4); + + + File sql = new File("/tmp/init_cardbin.sql"); + + for(int i = 0; i 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.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)); + + + + } + + 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()); + } + +} diff --git a/src/test/resources/db.setting b/src/test/resources/db.setting new file mode 100644 index 0000000..bb1ce29 --- /dev/null +++ b/src/test/resources/db.setting @@ -0,0 +1,15 @@ +## db.setting文件 + +url = jdbc:oracle:thin:@172.17.30.91:1521:mrdb +user = mr_pay +pass = mr_pay + +## 可选配置 +# 是否在日志中显示执行的SQL +showSql = true +# 是否格式化显示的SQL +formatSql = false +# 是否显示SQL参数 +showParams = true +# 打印SQL的日志等级,默认debug,可以是info、warn、error +sqlLevel = info \ No newline at end of file diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml new file mode 100644 index 0000000..7d55648 --- /dev/null +++ b/src/test/resources/logback-test.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + %red(%d{yyyy-MM-dd HH:mm:ss}) %highlight(%-5level) %cyan(%logger{36}) [%04line] - %msg%n + + + + + + ${logBase}/${all}.log + + ${logBase}/${all}-%d{yyyy-MM-dd}.log.%i + 30 + + 100MB + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%X{TRACE_ID}] %-5level %logger{36} - %msg%n + + + + + ${logBase}/${error}.log + + ERROR + + + ${logBase}/${error}-%d{yyyy-MM-dd}.log.%i + 30 + + 50MB + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%X{TRACE_ID}] %-5level %logger{36} - %msg%n + + + + + ${logBase}/${trace}.log + + + WRAN + + + ${logBase}/${trace}-%d{yyyy-MM-dd}.log.%i + 30 + + 50MB + + + + %d [%thread] [%X{TRACE_ID}] %msg%n + + + + 512 + + + + + + + + + + + + + + + + diff --git a/src/test/resources/prop.setting b/src/test/resources/prop.setting new file mode 100644 index 0000000..d790895 --- /dev/null +++ b/src/test/resources/prop.setting @@ -0,0 +1,3 @@ +baseURL= http://172.17.20.91:9998/api +secretKey = HelloWorld +zipPassword = 1234567