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

结果校验

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