|
@@ -2,12 +2,17 @@ package com.kexun.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.kexun.constant.ReportConsts;
|
|
|
+import com.kexun.entity.CrHeadInfEntity;
|
|
|
+import com.kexun.entity.ReportFileEntity;
|
|
|
import com.kexun.entity.ReportInfo;
|
|
|
import com.kexun.enums.ReportStatusEnum;
|
|
|
import com.kexun.model.ReportStruct;
|
|
|
import com.kexun.model.Request;
|
|
|
+import com.kexun.service.CrHeadInfService;
|
|
|
+import com.kexun.service.ReportFileService;
|
|
|
import com.kexun.service.ReportInfoService;
|
|
|
import com.kexun.service.XmlFileHandlerService;
|
|
|
+import com.kexun.utils.DateUtils;
|
|
|
import lombok.extern.log4j.Log4j;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.dom4j.*;
|
|
@@ -41,6 +46,12 @@ public class XmlFileHandlerServiceImpl implements XmlFileHandlerService {
|
|
|
@Autowired
|
|
|
ReportInfoService reportInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ CrHeadInfService crHeadInfService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ReportFileService reportFileService;
|
|
|
+
|
|
|
/**
|
|
|
* 读取指定目录下报文文件
|
|
|
*/
|
|
@@ -55,6 +66,7 @@ public class XmlFileHandlerServiceImpl implements XmlFileHandlerService {
|
|
|
File[] fileLists = files.listFiles();
|
|
|
if (fileLists != null) {
|
|
|
//创建目录文件路径
|
|
|
+ String dateName = DateUtils.format(new Date(), DateUtils.YYYYMMDD);
|
|
|
for (File fileList : fileLists) {
|
|
|
//只处理xml文件
|
|
|
if (fileList.isFile() && fileList.getName().endsWith(".xml")) {
|
|
@@ -70,7 +82,11 @@ public class XmlFileHandlerServiceImpl implements XmlFileHandlerService {
|
|
|
reportStruct = JSON.parseObject(xmlJson, ReportStruct.class);
|
|
|
saveReportInfo(reportStruct);
|
|
|
//将该目录下的文件进行移动,移动到指定的备份目录
|
|
|
- File targetFile = new File(xmlBackPath+name);
|
|
|
+ File fileDir = new File(xmlBackPath + dateName);
|
|
|
+ if (!fileDir.exists()){
|
|
|
+ fileDir.mkdirs();
|
|
|
+ }
|
|
|
+ File targetFile = new File(xmlBackPath+dateName+File.separator+name);
|
|
|
try {
|
|
|
FileUtils.moveFile(file,targetFile);
|
|
|
} catch (IOException e) {
|
|
@@ -142,7 +158,16 @@ public class XmlFileHandlerServiceImpl implements XmlFileHandlerService {
|
|
|
}
|
|
|
//文件名
|
|
|
reportInfo.setFileName(reportStruct.getFileName());
|
|
|
+ //保存cr_head_inf报文头信息
|
|
|
+ CrHeadInfEntity crHeadInfEntity = new CrHeadInfEntity();
|
|
|
+ crHeadInfEntity.setName(reportInfo.getCustomerName());
|
|
|
+ Long headInfoId = crHeadInfService.saveUpdateHeadInfo(crHeadInfEntity);
|
|
|
+ //报文文件信息
|
|
|
+ ReportFileEntity reportFileEntity = new ReportFileEntity();
|
|
|
+ reportFileEntity.setHeadInfId(headInfoId);
|
|
|
+ reportFileService.saveOrUpdate(reportFileEntity);
|
|
|
//保存报文信息
|
|
|
+ reportInfo.setHeadInfId(headInfoId);
|
|
|
reportInfoService.saveReportInfo(reportInfo);
|
|
|
}
|
|
|
|