diff --git a/dataSources/b1c693bb-c902-4317-813d-e43d26930706/storage_v2/_src_/schema/MR_PAY.7hIViA.meta b/dataSources/b1c693bb-c902-4317-813d-e43d26930706/storage_v2/_src_/schema/MR_PAY.7hIViA.meta new file mode 100644 index 0000000..ca27b04 --- /dev/null +++ b/dataSources/b1c693bb-c902-4317-813d-e43d26930706/storage_v2/_src_/schema/MR_PAY.7hIViA.meta @@ -0,0 +1,2 @@ +#n:MR_PAY +! [1615811112000, 0, null, null, -2147483648, -2147483648] diff --git a/dataSources/b1c693bb-c902-4317-813d-e43d26930706/storage_v2/_src_/schema/PUBLIC.aaZQjQ.meta b/dataSources/b1c693bb-c902-4317-813d-e43d26930706/storage_v2/_src_/schema/PUBLIC.aaZQjQ.meta new file mode 100644 index 0000000..4a3ed40 --- /dev/null +++ b/dataSources/b1c693bb-c902-4317-813d-e43d26930706/storage_v2/_src_/schema/PUBLIC.aaZQjQ.meta @@ -0,0 +1,2 @@ +#n:PUBLIC +! [1615811144000, 0, null, null, -2147483648, -2147483648] diff --git a/dataSources/b1c693bb-c902-4317-813d-e43d26930706/storage_v2/_src_/schema/SYS.rUIBAA.meta b/dataSources/b1c693bb-c902-4317-813d-e43d26930706/storage_v2/_src_/schema/SYS.rUIBAA.meta new file mode 100644 index 0000000..1dad96c --- /dev/null +++ b/dataSources/b1c693bb-c902-4317-813d-e43d26930706/storage_v2/_src_/schema/SYS.rUIBAA.meta @@ -0,0 +1,2 @@ +#n:SYS +! [null, 0, null, null, -2147483648, -2147483648] diff --git a/dataSources/b1c693bb-c902-4317-813d-e43d26930706/storage_v2/_src_/schema/SYSTEM.L2avkg.meta b/dataSources/b1c693bb-c902-4317-813d-e43d26930706/storage_v2/_src_/schema/SYSTEM.L2avkg.meta new file mode 100644 index 0000000..d47d5a6 --- /dev/null +++ b/dataSources/b1c693bb-c902-4317-813d-e43d26930706/storage_v2/_src_/schema/SYSTEM.L2avkg.meta @@ -0,0 +1,2 @@ +#n:SYSTEM +! [null, 0, null, null, -2147483648, -2147483648] diff --git a/pom.xml b/pom.xml index 46bca35..85110d8 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,11 @@ 1.8 + + io.minio + minio + 8.0.0 + org.apache.poi poi-ooxml @@ -73,7 +78,7 @@ cn.hutool hutool-all - 5.5.8 + 5.5.9 org.springframework.boot diff --git a/src/main/java/ctg/tool/DataFactory.java b/src/main/java/ctg/tool/DataFactory.java index e4dea75..3d9e9c1 100644 --- a/src/main/java/ctg/tool/DataFactory.java +++ b/src/main/java/ctg/tool/DataFactory.java @@ -1,6 +1,9 @@ package ctg.tool; +import cn.hutool.core.lang.Dict; +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; @@ -38,12 +41,62 @@ public class DataFactory { String[] amounts = newAmounts(totalCount,totalAmount.multiply(new BigDecimal("100.00")).toBigInteger().intValue(),1); for(int i=0;i card = newCmbCard(); + list.add(RequestDiskRow.builder().acctName(card.getValue()).acctNo(card.getKey()).amount(amounts[i]).refId(newRefId()).build()); + break; + } + /** 工行测试数据 */ + case 1: { + Pair card = newIcbcCard(); + list.add(RequestDiskRow.builder().acctName(card.getValue()).acctNo(card.getKey()).amount(amounts[i]).refId(newRefId()).build()); + break; + } + /** 假数据 */ + default: { + list.add(RequestDiskRow.builder().acctName(newCardName()).acctNo(newCardNo()).amount(amounts[i]).refId(newRefId()).build()); + break; + } + } } return list; } + /** + * 生成工行 & 招行测试用的卡号 + 姓名 + * @return + */ + public static final Pair newCmbCard(){ + return cmbCards.get(RandomUtil.randomInt(0,cmbCards.size())); + } + + public static final Pair newIcbcCard(){ + return icbcCards.get(RandomUtil.randomInt(0,icbcCards.size())); + } + + public static final ArrayList> 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> cmbCards = new ArrayList(){{ + add(new Pair("6225880280120198","喵星人")); + add(new Pair<>("6214831150131511","吴极客")); + }}; public static final String newCardNo() { int index = random.nextInt(cards.length - 1); diff --git a/src/main/java/ctg/util/CardUtil.java b/src/main/java/ctg/util/CardUtil.java deleted file mode 100644 index 93a9014..0000000 --- a/src/main/java/ctg/util/CardUtil.java +++ /dev/null @@ -1,124 +0,0 @@ -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/test/java/hro/MixedTest.java b/src/test/java/hro/MixedTest.java index b3cfe8f..41ceb60 100644 --- a/src/test/java/hro/MixedTest.java +++ b/src/test/java/hro/MixedTest.java @@ -56,14 +56,15 @@ public class MixedTest { public void WholeLinkTest() throws Exception { DiskInfo disk = diskApplySimpleTest(); log.info("disk:{}",disk); - ThreadUtil.sleep(1000); + log.info("等待60秒后查询结果..."); + ThreadUtil.sleep(60000); diskResultSimpleTest(disk); log.info("disk:{}",disk); } @SneakyThrows - public void diskResultSimpleTest(DiskInfo disk) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { + public void diskResultSimpleTest(DiskInfo disk) { 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(); @@ -81,6 +82,11 @@ public class MixedTest { 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); diff --git a/src/test/java/icbc/A.java b/src/test/java/icbc/A.java new file mode 100644 index 0000000..b029379 --- /dev/null +++ b/src/test/java/icbc/A.java @@ -0,0 +1,23 @@ +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 rd; + + @Data + public static class B{ + private String field_b; + } +} diff --git a/src/test/java/icbc/BeanToJson.java b/src/test/java/icbc/BeanToJson.java new file mode 100644 index 0000000..58e2504 --- /dev/null +++ b/src/test/java/icbc/BeanToJson.java @@ -0,0 +1,274 @@ +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 String toJson(T t) { + if (t == null) { + return "{}"; + } + return beanToJson(t); + } + + public static 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 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 String listToJson(List 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; + } + +} diff --git a/src/test/java/icbc/Father.java b/src/test/java/icbc/Father.java new file mode 100644 index 0000000..1a11e7f --- /dev/null +++ b/src/test/java/icbc/Father.java @@ -0,0 +1,70 @@ +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 childs; + + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public List getChilds() { + return this.childs; + } + + public void setChilds(List 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 rd = new ArrayList(); + + Child biz = new Child(); + + biz.setName("Child"); + rd.add(biz); + + response.setChilds(rd); + + System.out.println("map:" + BeanUtil.beanToMap(response)); + } +} diff --git a/src/test/java/icbc/IcbcTest.java b/src/test/java/icbc/IcbcTest.java index f753b1b..d55376d 100644 --- a/src/test/java/icbc/IcbcTest.java +++ b/src/test/java/icbc/IcbcTest.java @@ -1,6 +1,10 @@ package icbc; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.XmlUtil; +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; @@ -12,8 +16,7 @@ import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; +import java.util.*; /** * @Author: Alawn @@ -24,6 +27,7 @@ import java.util.Date; 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"; /** 企业私钥 */ @@ -35,6 +39,27 @@ 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 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() { @@ -59,28 +84,25 @@ public class IcbcTest { bizContent.setBusiType(""); bizContent.setSettleMode("2"); bizContent.setLanguage("zh_CN"); - bizContent.setTotalAmount(10900L); + bizContent.setTotalAmount(1L); bizContent.setInstrCount(1); bizContent.setfSeqNo(seqNo); request.setServiceUrl(baseURL + "/" + URI); request.setBizContent(bizContent); - rd.setAmount(10900L); + rd.setAmount(1L); rd.setPostscript("工资"); rd.setBusiCode(""); rd.setCurrency("CNY"); rd.setPurpose("工资"); rd.setSummary("工资"); rd.setSummaryEn("Salary"); - rd.setPayerAccount("0200080609200100843"); rd.setPayerCnname("榔右蝗呵如咪仔牌芝降化僵侦柱"); -// rd.setPayerEnname("Hello Kitty"); - rd.setPayeeAccount("6212260200197040005"); rd.setPayeeCnname("音偏漾"); - rd.setPayeeBankNo("43546"); - rd.setIoFlag("2"); +// rd.setPayeeBankNo("308584000013"); + rd.setIoFlag("1"); rd.setPayType("3"); rd.setPayeeCity(""); rd.setManagerCardNo(""); @@ -95,20 +117,18 @@ public class IcbcTest { ArrayList list = new ArrayList<>(); list.add(rd); bizContent.setRd(list); - - log.info("request:{}",JSONUtil.toJsonStr(request)); - + Map map = BeanUtil.beanToMap(request,true,true); + log.info("request:{}",XmlUtil.toStr(XmlUtil.mapToXml(map,"root"))); 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("msg_id:{}",response.getMsgId()); - log.info("return_code:{}",response.getReturnCode()); - log.info("return_msg:{}",response.getReturnMsg()); + log.info("response:{}", BeanUtil.beanToMap(response)); } } catch (Exception e) { e.printStackTrace(); @@ -119,19 +139,22 @@ public class IcbcTest { 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"); - 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"); + bizContent.setfSeqNo(seqNo); request.setServiceUrl(baseURL + "/" + URI); request.setBizContent(bizContent); + bizContent.setQryFSeqNo("202103050000000009"); log.info("request:{}",JSONUtil.toJsonStr(request)); @@ -140,15 +163,74 @@ public class IcbcTest { 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 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"); - log.info("msg_id:{}",response.getMsgId()); - log.info("return_code:{}",response.getReturnCode()); - log.info("return_msg:{}",response.getReturnMsg()); +// log.info("response:{}",XmlUtil.toStr(XmlUtil.beanToXml(response),true)); +// 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; + } + } diff --git a/src/test/java/minio/MinioTest.java b/src/test/java/minio/MinioTest.java new file mode 100644 index 0000000..b48ed48 --- /dev/null +++ b/src/test/java/minio/MinioTest.java @@ -0,0 +1,34 @@ +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()); + } + + } +} diff --git a/src/test/java/sql/SqlExplainer.java b/src/test/java/sql/SqlExplainer.java new file mode 100644 index 0000000..597458b --- /dev/null +++ b/src/test/java/sql/SqlExplainer.java @@ -0,0 +1,57 @@ +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 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(); + } +} diff --git a/src/test/java/tool/CardBinBuilder.java b/src/test/java/tool/CardBinBuilder.java index 88f9c63..d714d54 100644 --- a/src/test/java/tool/CardBinBuilder.java +++ b/src/test/java/tool/CardBinBuilder.java @@ -17,7 +17,7 @@ import java.util.List; public class CardBinBuilder { @Test - public void CardBin(){ + public void CardBinSql(){ ExcelReader reader = ExcelUtil.getReader("/tmp/2020年04月25日版跨行转账卡表总信息.xls"); // ExcelReader reader = ExcelUtil.getReader("/tmp/2020年04月25日版卡表.xls"); @@ -78,7 +78,8 @@ public class CardBinBuilder { 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(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()); @@ -94,6 +95,76 @@ public class CardBinBuilder { } + @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 readAll = reader.read(0,5,CardBin.class); + List> readAll = reader.read(4); + + + File sql = new File("/tmp/cardname.txt"); + + 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.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(); diff --git a/src/test/java/tool/MinioTool.java b/src/test/java/tool/MinioTool.java new file mode 100644 index 0000000..28508c0 --- /dev/null +++ b/src/test/java/tool/MinioTool.java @@ -0,0 +1,32 @@ +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()); + } + } +} diff --git a/src/test/resources/MybatisGenerator.xml b/src/test/resources/MybatisGenerator.xml new file mode 100644 index 0000000..cd69fb0 --- /dev/null +++ b/src/test/resources/MybatisGenerator.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
\ No newline at end of file diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml index 7d55648..38e321f 100644 --- a/src/test/resources/logback-test.xml +++ b/src/test/resources/logback-test.xml @@ -76,11 +76,11 @@ - + - +