Commit 5da1e63e authored by Java-范 志勇's avatar Java-范 志勇

增加测试工具类

parent 33da69a0
package com.qg.finantial;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.CharUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
/**
* Created with IntelliJ IDEA
* User: zhiyong.fan
* Date: 2016/12/5
* Time: 17:07
* Desc: ${DESC}
*/
public class UMPayBaiTiaoValidator {
public static void main(String[] args) throws IOException {
//System.err.println("The init bill's total income is: " + getUMPayInitBillAmount());
// System.err.println("The init bill's total income is: " + getWeichatInitBillAmount());
System.err.println(getLostOrderInicialAmount());
}
public static BigDecimal getUMPayInitBillAmount() throws IOException {
String fileDirPath = "E:\\financial-system-data\\umpay\\baitiao";
File dir = new File(fileDirPath);
//bill.setIncome(new BigDecimal(split[6]).divide(BigDecimal.TEN).divide(BigDecimal.TEN));
BigDecimal total = BigDecimal.ZERO;
for (File file : dir.listFiles()) {
List<String> contents = Files.readAllLines(file.toPath());
for (String content : contents) {
if (content.startsWith("TRADEDETAIL-START"))
continue;
if (content.startsWith("TRADEDETAIL-END"))
break;
BigDecimal temp = new BigDecimal(content.split(",")[6]).divide(BigDecimal.TEN).divide(BigDecimal.TEN);
total = total.add(temp);
}
}
return total;
}
public static String getWeichatInitBillAmount() throws IOException {
String fileDirPath = "E:\\financial-system-data\\weichat\\baitiao";
File dir = new File(fileDirPath);
BigDecimal incomeTotal = BigDecimal.ZERO;
BigDecimal poundageTotal = BigDecimal.ZERO;
for (File file : dir.listFiles()) {
List<String> contents = Files.readAllLines(file.toPath());
for (String content : contents) {
if (content.startsWith("<xml>")) return "";
String[] split = content.split(",");
if (content.contains("交易时间"))
continue;
if (content.contains("总交易单数"))
break;
if (StringUtils.isNotBlank(split[12])) {
BigDecimal temp = new BigDecimal(split[12]);
incomeTotal = incomeTotal.add(temp);
}
if (StringUtils.isNotBlank(split[22])) {
BigDecimal temp = new BigDecimal(split[22]);
poundageTotal = poundageTotal.add(temp);
}
}
}
return incomeTotal.toPlainString() + "~~~" + poundageTotal.toPlainString();
}
public static Map<String, String> getLostOrderInicialAmount() throws IOException {
Map<String, String> inicialAmount = Maps.newHashMap();
String lostOrderFileDirPath = "C:\\Users\\Administrator\\Desktop\\lostIds.txt";
File lostOrderIdFile = new File(lostOrderFileDirPath);
List<String> lostOrderIds = Files.readAllLines(lostOrderIdFile.toPath());
String fileDirPath = "E:\\financial-system-data\\weichat\\baitiao";
File dir = new File(fileDirPath);
for (File file : dir.listFiles()) {
List<String> contents = Files.readAllLines(file.toPath());
for (String orderId : lostOrderIds) {
for (String content : contents) {
if (content.contains(orderId)) {
String[] split = content.split(",");
inicialAmount.put(orderId, split[12]);
}
}
}
}
return inicialAmount;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment