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 index ca27b04..62d0f6c 100644 --- 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 @@ -1,2 +1,2 @@ #n:MR_PAY -! [1615811112000, 0, null, null, -2147483648, -2147483648] +! [1623061791000, 0, null, null, -2147483648, -2147483648] diff --git a/pom.xml b/pom.xml index 85110d8..7a2998c 100644 --- a/pom.xml +++ b/pom.xml @@ -132,7 +132,7 @@ alawn.cn alawn.cn - https://alawn.cn:1024/repository/maven-releases/ + https://alawn.cn:2048/repository/maven-releases/ spring-milestones diff --git a/src/main/java/ctg/entity/RequestDiskRow.java b/src/main/java/ctg/entity/RequestDiskRow.java index 33e920a..b59c13c 100644 --- a/src/main/java/ctg/entity/RequestDiskRow.java +++ b/src/main/java/ctg/entity/RequestDiskRow.java @@ -19,10 +19,14 @@ public class RequestDiskRow { private String refId ; private String amount ; @Builder.Default + private String bankCode = ""; + @Builder.Default private String bankCity = ""; @Builder.Default private String bankName = ""; @Builder.Default + private String bankNo = ""; + @Builder.Default private String remark = ""; public String toLine() @@ -32,8 +36,10 @@ public class RequestDiskRow { .append(acctName).append(deliStr) .append(refId).append(deliStr) .append(amount).append(deliStr) + .append(bankCode).append(deliStr) .append(bankCity).append(deliStr) .append(bankName).append(deliStr) + .append(bankNo).append(deliStr) .append(remark).append("\n"); return sb.toString(); } diff --git a/src/main/java/ctg/tool/DataFactory.java b/src/main/java/ctg/tool/DataFactory.java index 3d9e9c1..b1a7b07 100644 --- a/src/main/java/ctg/tool/DataFactory.java +++ b/src/main/java/ctg/tool/DataFactory.java @@ -1,6 +1,5 @@ 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; @@ -48,19 +47,19 @@ public class DataFactory { { /** 招行测试数据 */ case 0: { - Pair card = newCmbCard(); - list.add(RequestDiskRow.builder().acctName(card.getValue()).acctNo(card.getKey()).amount(amounts[i]).refId(newRefId()).build()); + Pair card = pickCmbCardRandomly(); + list.add(RequestDiskRow.builder().acctName(card.getValue()).acctNo(card.getKey()).amount(amounts[i]).refId(pickRefIdRandomly()).build()); break; } /** 工行测试数据 */ case 1: { - Pair card = newIcbcCard(); - list.add(RequestDiskRow.builder().acctName(card.getValue()).acctNo(card.getKey()).amount(amounts[i]).refId(newRefId()).build()); + Pair card = pickIcbcCardRandomly(); + list.add(RequestDiskRow.builder().acctName(card.getValue()).acctNo(card.getKey()).amount(amounts[i]).refId(pickRefIdRandomly()).build()); break; } /** 假数据 */ default: { - list.add(RequestDiskRow.builder().acctName(newCardName()).acctNo(newCardNo()).amount(amounts[i]).refId(newRefId()).build()); + list.add(RequestDiskRow.builder().acctName(newCardName()).acctNo(pickCardNoRandomly()).amount(amounts[i]).refId(pickRefIdRandomly()).build()); break; } } @@ -73,11 +72,11 @@ public class DataFactory { * 生成工行 & 招行测试用的卡号 + 姓名 * @return */ - public static final Pair newCmbCard(){ + public static final Pair pickCmbCardRandomly(){ return cmbCards.get(RandomUtil.randomInt(0,cmbCards.size())); } - public static final Pair newIcbcCard(){ + public static final Pair pickIcbcCardRandomly(){ return icbcCards.get(RandomUtil.randomInt(0,icbcCards.size())); } @@ -98,12 +97,12 @@ public class DataFactory { add(new Pair<>("6214831150131511","吴极客")); }}; - public static final String newCardNo() { + public static final String pickCardNoRandomly() { int index = random.nextInt(cards.length - 1); return cards[index]; } - public static String newRefId() { + public static String pickRefIdRandomly() { return String.valueOf(IdUtil.getSnowflake(1,1).nextIdStr()); } @@ -117,9 +116,10 @@ public class DataFactory { return amount; } - public static String newPostscript() { return postscripts[random.nextInt(postscripts.length - 1)]; } + public static String pickPostscriptRandomly + () { return postscripts[random.nextInt(postscripts.length - 1)]; } - public static String newCustomerId() throws SQLException { + public static String pickCustomerIdRandomly() throws SQLException { String customerId = ""; List rs = Db.use().query("SELECT CUSTOMER_ID FROM CAPCUSINF WHERE ENABLED = 'Y'",new HashMap()); @@ -135,7 +135,7 @@ public class DataFactory { } - public static String newTitleId() throws SQLException { + public static String pickTitleIdRandomly() throws SQLException { String titleId = ""; List rs = null; diff --git a/src/test/java/entity/DiskInfo.java b/src/test/java/entity/DiskInfo.java index 6aea985..ce7ed7b 100644 --- a/src/test/java/entity/DiskInfo.java +++ b/src/test/java/entity/DiskInfo.java @@ -15,7 +15,6 @@ import lombok.NoArgsConstructor; @NoArgsConstructor @AllArgsConstructor public class DiskInfo { - private String applyDate ; private String diskNo ; private String diskSts ; @@ -30,4 +29,9 @@ public class DiskInfo { private String failAmount ; private String filePath ; private String md5 ; + + public DiskInfo(String applyDate,String diskNo) { + this.applyDate = applyDate; + this.diskNo = diskNo; + } } diff --git a/src/test/java/hro/DiskApplyRequestTest.java b/src/test/java/hro/DiskApplyRequestTest.java index 95aa4d2..ecc6735 100644 --- a/src/test/java/hro/DiskApplyRequestTest.java +++ b/src/test/java/hro/DiskApplyRequestTest.java @@ -14,10 +14,7 @@ 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; @@ -49,8 +46,8 @@ public class DiskApplyRequestTest { DiskApplyRequest request = DiskApplyRequest.builder() .applyDate(DateUtil.format(new Date(),"YYYYMMdd")) - .customerId(DataFactory.newCustomerId()) - .titleId(DataFactory.newTitleId()) + .customerId(DataFactory.pickCustomerIdRandomly()) + .titleId(DataFactory.pickTitleIdRandomly()) .diskDesc("代发工资").build(); File file = DiskTool.newSimpleDiskFile(request.getCustomerId(),request.getTitleId(),"代发工资",10,new BigDecimal(50000.00)); diff --git a/src/test/java/hro/DiskApplyTest.java b/src/test/java/hro/DiskApplyTest.java index 44558d2..c1acc0a 100644 --- a/src/test/java/hro/DiskApplyTest.java +++ b/src/test/java/hro/DiskApplyTest.java @@ -26,8 +26,8 @@ public class DiskApplyTest { DiskApplyRequest body = DiskApplyRequest.builder() .diskNo("lakjdfklasjdklfjaslkdf") .applyDate(DateUtil.format(new Date(),"YYYYMMdd")) - .customerId(DataFactory.newCustomerId()) - .titleId(DataFactory.newTitleId()) + .customerId(DataFactory.pickCustomerIdRandomly()) + .titleId(DataFactory.pickTitleIdRandomly()) .diskDesc("代发工资").build(); Api request = new Api<>("diskApply",body); diff --git a/src/test/java/hro/MixedTest.java b/src/test/java/hro/MixedTest.java index 41ceb60..4978b79 100644 --- a/src/test/java/hro/MixedTest.java +++ b/src/test/java/hro/MixedTest.java @@ -28,7 +28,6 @@ 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; @@ -96,8 +95,8 @@ public class MixedTest { public DiskInfo diskApplySimpleTest() throws Exception { DiskApplyRequest request = DiskApplyRequest.builder() .applyDate(DateUtil.format(new Date(),"YYYYMMdd")) - .customerId(DataFactory.newCustomerId()) - .titleId(DataFactory.newTitleId()) + .customerId(DataFactory.pickCustomerIdRandomly()) + .titleId(DataFactory.pickTitleIdRandomly()) .diskDesc("代发工资").build(); int totalCount = RandomUtil.randomInt(0,3000); diff --git a/src/test/java/hro/UatTest.java b/src/test/java/hro/UatTest.java new file mode 100644 index 0000000..5dc9e1e --- /dev/null +++ b/src/test/java/hro/UatTest.java @@ -0,0 +1,191 @@ +package hro; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.XmlUtil; +import cn.hutool.crypto.SecureUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.setting.Setting; +import ctg.constant.PropConstants; +import ctg.entity.api.Api; +import ctg.entity.api.DiskApplyRequest; +import ctg.entity.api.DiskResultRequest; +import ctg.tool.DataFactory; +import ctg.tool.DiskTool; +import ctg.tool.FastDFS; +import entity.DiskInfo; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import net.lingala.zip4j.ZipFile; +import net.lingala.zip4j.model.ZipParameters; +import net.lingala.zip4j.model.enums.AesKeyStrength; +import net.lingala.zip4j.model.enums.EncryptionMethod; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.w3c.dom.Document; + +import javax.xml.xpath.XPathConstants; +import java.io.File; +import java.io.FileNotFoundException; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @Author: Alawn + * @Description: + * @Date: Create in 下午4:10 2021/2/24 + */ +@Slf4j +public class UatTest { + private static String baseURL; + private static String secretKey; + private static String zipPassword; + + @BeforeAll + static void initProp() { + Setting setting = new Setting("prop.setting"); + baseURL = setting.getStr("baseURL"); + secretKey = setting.getStr("secretKey"); + zipPassword = setting.getStr("zipPassword"); + } + + + @Test + public void overAllTest() throws Exception { + DiskInfo disk; + try{ + /** 生成测试批次 */ + String customerId = DataFactory.pickCustomerIdRandomly(); + String titleId = DataFactory.pickTitleIdRandomly(); + int totalCount = RandomUtil.randomInt(0,3000); + BigDecimal totalAmount = RandomUtil.randomBigDecimal(new BigDecimal(1),new BigDecimal(1000000)); + File file = DiskTool.newSimpleDiskFile(customerId,titleId,"代发工资",totalCount,totalAmount); + disk = diskApply(customerId,titleId,file); + } + catch (Exception e) { + log.error(e.getMessage()); + return; + } + log.info("disk:{}",disk); + log.info("等待30秒后查询结果..."); + ThreadUtil.sleep(30000); + try { + diskResult(disk.getApplyDate(),disk.getDiskNo()); + } + catch (Exception e) { + log.error("error:{}",e.getMessage()); + return; + } + + log.info("disk:{}",disk); + } + + @Test + public void resultTest() throws Exception { + DiskInfo disk = null; + try { + disk = diskResult("20210607","3b07422666b44315ac62b8bc55b207c2"); + } + catch (Exception e) { + log.error("error:{}",e.getMessage()); + return; + } + log.info("disk:{}",disk); + } + + @SneakyThrows + public DiskInfo diskResult(String applyDate,String diskNo) { + DiskResultRequest request = DiskResultRequest.builder().applyDate(applyDate).diskNo(diskNo).build(); + DiskInfo disk = new DiskInfo(applyDate,diskNo); + Api api = new Api<>("diskResult",request); + String response = HttpUtil.createPost(PropConstants.baseURL).header("Signature",api.signature()).body(api.toData()).setConnectionTimeout(3000).timeout(3000).execute().body(); + + Document doc = XmlUtil.readXML(response); + String respCode = (String) XmlUtil.getByXPath("//root/head/respCode",doc, XPathConstants.STRING); + String respMessage = (String) XmlUtil.getByXPath("//root/head/respMessage",doc, XPathConstants.STRING); + log.info("[{}]:[{}]",respCode,respMessage); + if(respCode.equals("00")) { + disk.setDiskSts((String) XmlUtil.getByXPath("//root/body/diskSts",doc, XPathConstants.STRING)); + disk.setDiskMessage((String) XmlUtil.getByXPath("//root/body/diskMessage",doc, XPathConstants.STRING)); + disk.setLastDate((String) XmlUtil.getByXPath("//root/body/lastDate",doc, XPathConstants.STRING)); + disk.setLastTime((String) XmlUtil.getByXPath("//root/body/lastTime",doc, XPathConstants.STRING)); + disk.setTotalCount((String) XmlUtil.getByXPath("//root/body/totalCount",doc, XPathConstants.STRING)); + disk.setTotalAmount((String) XmlUtil.getByXPath("//root/body/totalAmount",doc, XPathConstants.STRING)); + disk.setFilePath((String) XmlUtil.getByXPath("//root/body/filePath",doc, XPathConstants.STRING)); + disk.setSuccAmount((String) XmlUtil.getByXPath("//root/body/succAmount",doc, XPathConstants.STRING)); + disk.setSuccCount((String) XmlUtil.getByXPath("//root/body/succCount",doc, XPathConstants.STRING)); + disk.setFailAmount((String) XmlUtil.getByXPath("//root/body/failAmount",doc, XPathConstants.STRING)); + disk.setFailCount((String) XmlUtil.getByXPath("//root/body/failCount",doc, XPathConstants.STRING)); + disk.setMd5((String) XmlUtil.getByXPath("//root/body/md5",doc, XPathConstants.STRING)); + return disk; + } + else { + throw new Exception(respMessage); + } + } + + public DiskInfo diskApply(String customerId,String titleId,File file) throws Exception { +// DiskApplyRequest request = DiskApplyRequest.builder() +// .applyDate(DateUtil.format(new Date(),"YYYYMMdd")) +// .customerId(DataFactory.newCustomerId()) +// .titleId(DataFactory.newTitleId()) +// .diskDesc("代发工资").build(); + DiskApplyRequest request = DiskApplyRequest.builder() + .applyDate(DateUtil.format(new Date(),"YYYYMMdd")) + .customerId(customerId) + .titleId(titleId) + .diskDesc("代发工资").build(); + + +// int totalCount = RandomUtil.randomInt(0,3000); +// BigDecimal totalAmount = RandomUtil.randomBigDecimal(new BigDecimal(1),new BigDecimal(1000000)); +// File file = DiskTool.newSimpleDiskFile(request.getCustomerId(),request.getTitleId(),"代发工资",totalCount,totalAmount); + request.setDiskNo(file.getName()); + + log.info("disk:{}", file.getAbsolutePath()); + + /** 文件压缩 */ + if(!file.exists() || !file.isFile()) { + throw new FileNotFoundException(); + } + + File disk = new File(file.getParent() + "/" + file.getName() + ".zip"); + + if ("".equals(zipPassword)) { + ZipParameters zipParameters = new ZipParameters(); + zipParameters.setEncryptFiles(true); + zipParameters.setEncryptionMethod(EncryptionMethod.AES); + zipParameters.setAesKeyStrength(AesKeyStrength.KEY_STRENGTH_256); + new ZipFile(disk, zipPassword.toCharArray()).addFile(file, zipParameters); + } + else { + new ZipFile(disk).addFile(file); + } + + /** 上传文件 */ + String fid = FastDFS.upload(disk); + log.info("fid:{}",fid); + request.setFilePath(fid); + request.setFileVersion(""); + request.setFilePath(fid); + request.setMd5(SecureUtil.md5(disk)); + + /** 送盘请求 */ + Api api = new Api<>("diskApply",request); + + log.info("diskApply.request:[{}]",api.toData()); + String response = HttpUtil.createPost(baseURL).header("Signature",api.signature()).body(api.toData()).setConnectionTimeout(3000).timeout(3000).execute().body(); + log.info("diskApply.response:[{}]",response); + + Document doc = XmlUtil.readXML(response); + + String respCode = (String) XmlUtil.getByXPath("//root/head/respCode",doc, XPathConstants.STRING); + String respMessage = (String) XmlUtil.getByXPath("//root/head/respMessage",doc, XPathConstants.STRING); + + if(!"00".equals(respCode)) { + throw new Exception(respMessage); + } + return DiskInfo.builder().diskNo(request.getDiskNo()).applyDate(request.getApplyDate()).build(); + } +}