Parcourir la source

修复BUG

master
梁超 il y a 5 jours
Parent
révision
007470165a

+ 2
- 2
gly-base-core/src/main/java/cn/com/taiji/core/entity/bdsq/FundsDetail.java Voir le fichier

@@ -50,9 +50,9 @@ public class FundsDetail extends StringPropertyUUIDEntity {
@Column(name="card_type")
private String cardType;//卡类型
@Column(name="pre_balance")
private Integer preBalance;//交易前金额
private Long preBalance;//交易前金额
@Column(name="post_balance")
private Integer postBalance;//交易后余额
private Long postBalance;//交易后余额
@Column(name="obu_id")
private String obuId;//obu编号
@Column(name="poundage")

+ 2
- 2
gly-base-core/src/main/java/cn/com/taiji/core/entity/bdsq/FundsDetailFailed.java Voir le fichier

@@ -50,9 +50,9 @@ public class FundsDetailFailed extends StringPropertyUUIDEntity {
@Column(name="card_type")
private String cardType;//卡类型
@Column(name="pre_balance")
private Integer preBalance;//交易前金额
private Long preBalance;//交易前金额
@Column(name="post_balance")
private Integer postBalance;//交易后余额
private Long postBalance;//交易后余额
@Column(name="obu_id")
private String obuId;//obu编号
@Column(name="poundage")

+ 23
- 8
zhywpt-dps-bdsq/src/main/java/cn/com/taiji/bdsq/manager/funds/FundsFileDownloadManagerImpl.java Voir le fichier

@@ -22,6 +22,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
@@ -32,7 +33,7 @@ import static cn.com.taiji.bdsq.model.MyFinals.UNDER_LINE;
import static cn.com.taiji.core.entity.dict.bdsq.ParseStatus.FAILED;
import static cn.com.taiji.core.entity.dict.bdsq.ParseStatus.SUCCESS;
import static cn.com.taiji.core.entity.dict.bdsq.ReturnStatus.NEW;
import static org.apache.commons.compress.utils.CharsetNames.UTF_8;
import static cn.hutool.core.util.CharsetUtil.GBK;

@Service
public class FundsFileDownloadManagerImpl extends AbstractManager implements FundsFileDownloadManager {
@@ -59,13 +60,15 @@ public class FundsFileDownloadManagerImpl extends AbstractManager implements Fun
ChannelSftp ftpClient = connectFtp(config);
String fileListName = config.getSourcePath() + LEFT_SLASH + config.getAgencyId() + UNDER_LINE + day + UNDER_LINE + "FileList.txt";
logger.info("fileListName:{}", fileListName);
List<String> rows = FileCopyTools.copyToLines(ftpClient.get(fileListName), UTF_8);
InputStream is = readFtpFile(ftpClient, fileListName);
if (is == null) continue;
List<String> rows = FileCopyTools.copyToLines(is, GBK);
String sumFileName = config.getSourcePath() + LEFT_SLASH + getFileName(rows, "_ZTTX_Entrust_Sum.txt");
logger.info("sumFileName:{}", sumFileName);
String detailFileName = config.getSourcePath() + LEFT_SLASH + getFileName(rows, "_ZTTX_Entrust_Detail.txt");
logger.info("detailFileName:{}", detailFileName);
List<String> sumFile = FileCopyTools.copyToLines(ftpClient.get(sumFileName), UTF_8, true, 2, 0);
List<String> detailFile = FileCopyTools.copyToLines(ftpClient.get(detailFileName), UTF_8, true, 2, 0);
List<String> sumFile = FileCopyTools.copyToLines(ftpClient.get(sumFileName), GBK, true, 2, 0);
List<String> detailFile = FileCopyTools.copyToLines(ftpClient.get(detailFileName), GBK, true, 2, 0);
List<FundsDetail> details = Lists.newArrayList();
FundsSum sum = fundsSumRepo.findById(config.getAgencyId() + UNDER_LINE + day).orElse(null);
if (sum == null) {
@@ -120,8 +123,20 @@ public class FundsFileDownloadManagerImpl extends AbstractManager implements Fun
return FtpClientUtil.sftpConnection(config.getSourceHost(), Integer.parseInt(config.getSourcePort()), config.getSourceLoginname(), config.getSourcePassword());
}

private InputStream readFtpFile(ChannelSftp ftpClient, String fileListName) throws SftpException {
try {
return ftpClient.get(fileListName);
} catch (SftpException e) {
if (e.getMessage().contains("No such file"))
return null;
else{
logger.error("FTP异常:", e);
throw e;
}
}
}

private FundsSum handleSum(FundsSum sum, String row, String agencyId, String handleDate) throws ServiceHandleException {
logger.info("data row:{}", row);
logger.info("渠道编号:{}", agencyId);
String[] data = row.split("\t");
if (data.length < 6)
@@ -135,7 +150,7 @@ public class FundsFileDownloadManagerImpl extends AbstractManager implements Fun
String statisDate = data[1];
if (!hasText(statisDate))
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("流水合计文件处理时间为空,处理失败。data:" + row);
if (!statisDate.replace("-","").equals(handleDate))//statisDate格式yyyy-MM-dd,handleDate格式yyyyMMdd
if (!statisDate.replace("-", "").equals(handleDate))//statisDate格式yyyy-MM-dd,handleDate格式yyyyMMdd
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("配置信息与文件中的处理时间不一致,处理失败。data:" + row);
sum.setHandleDate(handleDate);
String batchNo = data[2];
@@ -244,12 +259,12 @@ public class FundsFileDownloadManagerImpl extends AbstractManager implements Fun
String preBalance = data[15];
if (!hasText(preBalance))
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("交易前金额为空,处理失败。data:" + row);
detail.setPreBalance(Integer.parseInt(preBalance));
detail.setPreBalance(Long.parseLong(preBalance));
// 交易后金额
String postBalance = data[16];
if (!hasText(postBalance))
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("交易后金额为空,处理失败。data:" + row);
detail.setPostBalance(Integer.parseInt(postBalance));
detail.setPostBalance(Long.parseLong(postBalance));
// 本次交易金额
String feeStr = data[17];
if (!hasText(feeStr))

Chargement…
Annuler
Enregistrer