Commit d2f94560 authored by 陈宏杰's avatar 陈宏杰

结果校验

parent 6d8e6f7e
......@@ -875,29 +875,32 @@ public class BaiHangFileReportService {
}
@Async
public void singleFileDataCheck(String type,String singleFileName,String fieldNames) throws Exception{
public void singleFileDataCheck(String type,String singleFileName,String checkFieldNames) throws Exception{
log.info("{}文件数据校验开始...",singleFileName);
List<String> checkResult = new ArrayList();
File subFile = null;
Boolean noError = null;
StringBuffer sBuffer = null;
List<String> fileNameList = Arrays.asList(singleFileName);
for (String fileName : fileNameList) {
subFile = new File(HOST_PATH + fileName.replace("-R.cry",".txt"));
List<String> dataList = FileUtils.readLines(subFile, "utf-8");
List<String> fieldNameList = Arrays.asList(fieldNames.split(","));
for (String dataInfo : dataList) {
Boolean noError = Boolean.TRUE;
sBuffer = new StringBuffer(fileName).append(",");
String dataStr = null;
BufferedReader bis = null;
try {
List<String> checkFieldNameList = Arrays.asList(checkFieldNames.split(","));
bis = new BufferedReader(new FileReader(HOST_PATH + singleFileName.replace("-R.cry",".txt")));
while(null != (dataStr = bis.readLine())) {
if (StringUtils.isBlank(dataStr) || StringUtils.equals(dataStr,"#applyInfo") || StringUtils.equals(dataStr,"#singleLoanAccountInfo") || StringUtils.equals(dataStr,"#singleLoanRepayInfo")) {
} else {
sBuffer = new StringBuffer(singleFileName).append(",");
noError = Boolean.TRUE;
if ("A1".equalsIgnoreCase(type) || "A1Refuse".equalsIgnoreCase(type)) {
ApplyLoanInfoZhuDai applyLoanInfoZhuDai = JSONObject.parseObject(dataInfo, ApplyLoanInfoZhuDai.class);
ApplyLoanInfoZhuDai applyLoanInfoZhuDai = JSONUtil.toBean(dataStr, ApplyLoanInfoZhuDai.class);
log.info("数据 {} 正在校验...",applyLoanInfoZhuDai.getApplyId());
sBuffer.append(applyLoanInfoZhuDai.getApplyId()).append(",");
for (String fieldName : fieldNameList) {
Field declaredField = ApplyLoanInfoZhuDai.class.getDeclaredField(fieldName);
Object property = BeanUtil.getProperty(applyLoanInfoZhuDai, fieldName);
if (Objects.isNull(property) || Objects.isNull(declaredField)) {
for (String checkFieldName : checkFieldNameList) {
Field declaredField = ApplyLoanInfoZhuDai.class.getDeclaredField(checkFieldName);
Object property = BeanUtil.getProperty(applyLoanInfoZhuDai, checkFieldName);
if (Objects.isNull(property) || Objects.isNull(declaredField) || StringUtils.isBlank(property.toString())) {
noError = Boolean.FALSE;
sBuffer.append(fieldName).append(",");
sBuffer.append(checkFieldName).append(",");
}
}
}
......@@ -910,6 +913,11 @@ public class BaiHangFileReportService {
File file = new File(HOST_PATH + type + "_fileDataCheck_" + DateUtils.formatDate(new Date(),"yyyyMMddHHmmsss") + ".txt");
FileUtils.writeLines(file,checkResult,Boolean.TRUE);
}
} catch (Exception e) {
log.error("{}文件数据校验异常",singleFileName,e);
} finally {
IoUtil.close(bis);
}
log.info("{}文件数据校验结束",singleFileName);
}
......
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