Commit 886187e4 authored by Java-范 志勇's avatar Java-范 志勇

修改代码

parent d899d4ff
......@@ -25,7 +25,7 @@ import cn.gq.financial.utils.BillParsers;
@Component
public class RepayHandler {
static int ITEM_SIZE = 10000;
static int ITEM_SIZE = 30000;
@Autowired
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
......@@ -58,7 +58,7 @@ public class RepayHandler {
List<Bill> bills) {
if (bills.size()<ITEM_SIZE) {
count = new CountDownLatch(1);
threadPoolTaskExecutor.execute(new RepayHandlerAsync(bills,clazz,paycenterService,bizRepayDetailService,count, repayDetailMapper,financialRepayDetailService));
threadPoolTaskExecutor.execute(new RepayHandlerAsync(bills,clazz,paycenterService,bizRepayDetailService,count));
}else{
int group = bills.size()/ITEM_SIZE;
int cnt = group;
......@@ -69,11 +69,11 @@ public class RepayHandler {
int i = 0;
for (i = 0; i < group; i++) {
List<Bill> subList = bills.subList(i*ITEM_SIZE, (i+1)*ITEM_SIZE);
threadPoolTaskExecutor.execute(new RepayHandlerAsync(subList,clazz,paycenterService,bizRepayDetailService,count, repayDetailMapper,financialRepayDetailService));
threadPoolTaskExecutor.execute(new RepayHandlerAsync(subList,clazz,paycenterService,bizRepayDetailService,count));
}
if(bills.size()%ITEM_SIZE != 0 ){
List<Bill> subList = bills.subList(i*ITEM_SIZE, bills.size());
threadPoolTaskExecutor.execute(new RepayHandlerAsync(subList,clazz,paycenterService,bizRepayDetailService,count, repayDetailMapper,financialRepayDetailService));
threadPoolTaskExecutor.execute(new RepayHandlerAsync(subList,clazz,paycenterService,bizRepayDetailService,count));
}
}
}
......
......@@ -36,23 +36,16 @@ public class RepayHandlerAsync implements Runnable {
private CountDownLatch count;
private FinancialRepayDetailMapper repayDetailMapper;
private FinancialRepayDetailService financialRepayDetailService;
public RepayHandlerAsync(List<Bill> bills, Class<? extends Bill> clazz, PaycenterService paycenterService,BizRepayDetailService bizRepayDetailService,
CountDownLatch count, FinancialRepayDetailMapper repayDetailMapper,FinancialRepayDetailService financialRepayDetailService) {
CountDownLatch count) {
super();
this.bills = bills;
this.clazz = clazz;
this.paycenterService = paycenterService;
this.bizRepayDetailService = bizRepayDetailService;
this.count = count;
this.repayDetailMapper = repayDetailMapper;
this.financialRepayDetailService = financialRepayDetailService;
}
public void handler() {
try{
LOGGER.info("##Thread-->{}开始处理账单##",Thread.currentThread().getName());
......@@ -102,6 +95,8 @@ public class RepayHandlerAsync implements Runnable {
for (RepayDetailFinancial detail : list) {
detail.setPayAccount(bill.getPayAccount());
detail.setMonth(bill.getMonth());
// 设置交易时间
detail.setRepaidAt(bill.getTrandingDate());
if(1== detail.getActivityRelief().compareTo(BigDecimal.ZERO)){
detail.setActivityRelief(detail.getActivityRelief().multiply(Constants.MINUS_ONE));
}
......
......@@ -16,46 +16,47 @@ import java.util.Set;
*/
public class TotalAmountCheck {
static String [] lost = {
"1470995273554",
"1470995273550",
"1470995273567"
};
static Set<String> lostSet = new HashSet<>();
static String payAprroach="微信";
static String payAccount = "微信-白条账户";
static Integer month = 9;
static String SRC_BILL_PATH ="E:\\WX_BILL_BAITIAO";
static Class<? extends Bill> clazz = null;
static {
for (String lostId :lost){
lostSet.add(lostId);
}
switch (payAprroach) {
case "微信":
clazz = WXBill.class;
break;
case "易宝":
clazz = YeepayBill.class;
break;
case "联动":
clazz = UMPayBill.class;
break;
}
}
public static void main(String args[]) throws Exception {
List<Bill> bills = RepayHandler.getBillsFromFile(SRC_BILL_PATH, clazz, payAccount, month);
BigDecimal total = new BigDecimal(0);
for (int i = 0; i < bills.size(); i++) {
if(!lostSet.contains(bills.get(i).getOrderId())) {
total = total.add(bills.get(i).getIncome());
}else {
System.out.println(bills.get(i).getOrderId().concat("--").concat(bills.get(i).getIncome().toString()));
}
}
System.out.println(total);
}
static String[] lost = {
"1470995273554",
"1470995273550",
"1470995273567"
};
static Set<String> lostSet = new HashSet<>();
static String payAprroach = "微信";
static String payAccount = "微信-白条账户";
static Integer month = 9;
static String SRC_BILL_PATH = "E:\\WX_BILL_BAITIAO";
static Class<? extends Bill> clazz = null;
static {
for (String lostId : lost) {
lostSet.add(lostId);
}
switch (payAprroach) {
case "微信":
clazz = WXBill.class;
break;
case "易宝":
clazz = YeepayBill.class;
break;
case "联动":
clazz = UMPayBill.class;
break;
}
}
public static void main(String args[]) throws Exception {
List<Bill> bills = RepayHandler.getBillsFromFile(SRC_BILL_PATH, clazz, payAccount, month);
BigDecimal total = new BigDecimal(0);
for (int i = 0; i < bills.size(); i++) {
if (!lostSet.contains(bills.get(i).getOrderId())) {
total = total.add(bills.get(i).getIncome());
} else {
System.out.println(bills.get(i).getOrderId().concat("--").concat(bills.get(i).getIncome().toString()));
}
}
System.out.println(total);
}
}
package cn.gq.financial.model.bill;
import java.math.BigDecimal;
import java.util.Date;
/**
* 第三方支付平台对账单的要素集合,具体平台的账单继承本类
* @author Administrator
*
* @author Administrator
*/
public abstract class Bill {
protected Integer month;
protected Date trandingDate;
protected String payAccount;// 支付账户
protected String orderId; // 商户订单号
protected BigDecimal income = BigDecimal.ZERO; // 收入
......@@ -20,7 +23,7 @@ public abstract class Bill {
protected BigDecimal cost = BigDecimal.ZERO;
protected BigDecimal poundage = BigDecimal.ZERO;
public Integer getMonth() {
return month;
}
......@@ -68,7 +71,12 @@ public abstract class Bill {
public void setPayAccount(String payAccount) {
this.payAccount = payAccount;
}
public Date getTrandingDate() {
return trandingDate;
}
public void setTrandingDate(Date trandingDate) {
this.trandingDate = trandingDate;
}
}
......@@ -13,20 +13,10 @@ public class UMPayBill extends Bill {
public static String TRANS_FAIL = "-1";
private Date trandingDate;
private String phoneNo;
private String transStatus; //交易状态,TRANS_SUCCESS,TRANS_FAIL
public Date getTrandingDate() {
return trandingDate;
}
public void setTrandingDate(Date trandingDate) {
this.trandingDate = trandingDate;
}
public String getPhoneNo() {
return phoneNo;
}
......
......@@ -10,8 +10,6 @@ import java.util.Date;
*/
public class WXBill extends Bill {
private Date trandingDate;
private String wxOrderId;
private String pubWXAccount;
......@@ -28,14 +26,6 @@ public class WXBill extends Bill {
this.rate = rate;
}
public Date getTrandingDate() {
return trandingDate;
}
public void setTrandingDate(Date trandingDate) {
this.trandingDate = trandingDate;
}
public String getWxOrderId() {
return wxOrderId;
}
......
......@@ -12,22 +12,12 @@ public class YeepayBill extends Bill {
public static String REPAY="收款";
public static String PAY = "委托结算";
private Date tradingDate; //交易时间
private String accountType; //账户类型
private String bizType; //业务类型
private String remak ; //备注信息
public Date getTradingDate() {
return tradingDate;
}
public void setTradingDate(Date tradingDate) {
this.tradingDate = tradingDate;
}
public String getAccountType() {
return accountType;
}
......
......@@ -79,7 +79,7 @@ public class BillParsers {
String[] split = line.split(",");
bill.setOrderId(split[3].trim());
bill.setIncome(new BigDecimal(split[6]).divide(BigDecimal.TEN).divide(BigDecimal.TEN));
bill.setTrandingDate(DateUtils.parseDate(split[4], PARSE_PATTERN_2));
bill.setTrandingDate(DateUtils.parseDate(split[5], PARSE_PATTERN_2));
bill.setOrderId(split[3].trim());
bill.setPhoneNo(split[2].trim());
bill.setTransStatus(split[11].trim());
......@@ -104,7 +104,7 @@ public class BillParsers {
while (StringUtils.isNoneBlank(line = reader.readLine())) {
if (line.startsWith("总交易单数")) break; //账单条目结束
String[] split = line.split(",");
if ("SUCCESS".equals(split[9])) {
if (split.length > 9 && "SUCCESS".equals(split[9])) {
WXBill bill = createWXBill(split);
bills.add(bill);
}
......@@ -142,7 +142,8 @@ public class BillParsers {
BigDecimal rate = new BigDecimal(str).divide(BigDecimal.TEN).divide(BigDecimal.TEN);
bill.setRate(rate);
}
// 设置交易时间
bill.setTrandingDate(DateUtils.parseDate(split[0], PARSE_PATTERN_1));
return bill;
}
......@@ -151,7 +152,7 @@ public class BillParsers {
if (contents == null || contents.length == 0) {
throw new IllegalArgumentException("Invalid contents: " + StringUtils.join(contents, ","));
}
yeepayBill.setTradingDate(DateUtils.parseDate(contents[1], "yyyy-MM-dd HH:mm:ss.SSS"));
yeepayBill.setTrandingDate(DateUtils.parseDate(contents[1], "yyyy-MM-dd HH:mm:ss.SSS"));
yeepayBill.setAccountType(contents[2]);
yeepayBill.setBizType(contents[3]);
if (StringUtils.isNotBlank(contents[4])) {
......@@ -174,15 +175,10 @@ public class BillParsers {
String lineContent = reader.readLine();
String[] split;
List<YeepayBill> bills = new ArrayList<>();
int flag = 0;
while (StringUtils.isNotBlank(lineContent)) {
if (flag > 0) {
split = StringUtils.splitPreserveAllTokens(lineContent, ",");
YeepayBill bill = setYeePayBillProps(split);
bills.add(bill);
}
lineContent = reader.readLine();
flag++;
while (StringUtils.isNotBlank(reader.readLine())) {
split = StringUtils.splitPreserveAllTokens(lineContent, ",");
YeepayBill bill = setYeePayBillProps(split);
bills.add(bill);
}
return bills;
}
......@@ -212,7 +208,7 @@ public class BillParsers {
private static YeepayBill createYeepayBill(Row row) {
YeepayBill bill = new YeepayBill();
bill.setTradingDate(row.getCell(1).getDateCellValue());
bill.setTrandingDate(row.getCell(1).getDateCellValue());
bill.setAccountType(row.getCell(2).getStringCellValue());
bill.setBizType(row.getCell(3).getStringCellValue());
if (StringUtils.isNotBlank(row.getCell(4).getStringCellValue())) {
......
......@@ -4,6 +4,6 @@
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<mappers>
<mapper resource="cn/gq/financial/db/local/mapping/MallDataSourceMapper.xml"/>
<mapper resource="cn/gq/financial/db/local/mapping/LocalDataSourceMapper.xml"/>
</mappers>
</configuration>
\ No newline at end of file
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