|
@@ -44,11 +44,12 @@ public class FileServiceImpl {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 上传文件
|
|
* 上传文件
|
|
|
|
+ *
|
|
* @param context
|
|
* @param context
|
|
* @param filename
|
|
* @param filename
|
|
* @param path
|
|
* @param path
|
|
*/
|
|
*/
|
|
- private void writeFile(String context, String filename,String path) {
|
|
|
|
|
|
+ private void writeFile(String context, String filename, String path) {
|
|
try {
|
|
try {
|
|
IOUtils.write(context, new FileOutputStream(path + filename), "UTF-8");
|
|
IOUtils.write(context, new FileOutputStream(path + filename), "UTF-8");
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
@@ -58,46 +59,48 @@ public class FileServiceImpl {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 保存xml文件和json文件
|
|
* 保存xml文件和json文件
|
|
|
|
+ *
|
|
* @param reportInfo
|
|
* @param reportInfo
|
|
* @param xmlContext
|
|
* @param xmlContext
|
|
* @param jsonContext
|
|
* @param jsonContext
|
|
* @param fileName
|
|
* @param fileName
|
|
*/
|
|
*/
|
|
- public void saveAndWriteFile(ReportInfo reportInfo,String xmlContext,String jsonContext,String fileName){
|
|
|
|
|
|
+ public void saveAndWriteFile(ReportInfo reportInfo, String xmlContext, String jsonContext, String fileName) {
|
|
//根据HeadInfId查询是否存在
|
|
//根据HeadInfId查询是否存在
|
|
ReportFileEntity reportFileEntity = new ReportFileEntity();
|
|
ReportFileEntity reportFileEntity = new ReportFileEntity();
|
|
- if (reportInfo.getHeadInfId()!=null){
|
|
|
|
|
|
+ if (reportInfo.getHeadInfId() != null) {
|
|
QueryWrapper<ReportFileEntity> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<ReportFileEntity> queryWrapper = new QueryWrapper<>();
|
|
- queryWrapper.eq("head_inf_id",reportInfo.getHeadInfId());
|
|
|
|
|
|
+ queryWrapper.eq("head_inf_id", reportInfo.getHeadInfId());
|
|
ReportFileEntity reportFileEntityResult = reportFileService.getOne(queryWrapper);
|
|
ReportFileEntity reportFileEntityResult = reportFileService.getOne(queryWrapper);
|
|
- reportFileEntity.setId(reportFileEntityResult.getId());
|
|
|
|
|
|
+ if (reportFileEntityResult != null) {
|
|
|
|
+ reportFileEntity.setId(reportFileEntityResult.getId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
reportFileEntity.setHeadInfId(reportInfo.getHeadInfId());
|
|
reportFileEntity.setHeadInfId(reportInfo.getHeadInfId());
|
|
reportFileEntity.setRptNo(reportInfo.getRptNo());
|
|
reportFileEntity.setRptNo(reportInfo.getRptNo());
|
|
reportFileEntity.setBusinessId(reportInfo.getBusinessId());
|
|
reportFileEntity.setBusinessId(reportInfo.getBusinessId());
|
|
reportFileEntity.setBusinessNum(reportInfo.getBusinessNum());
|
|
reportFileEntity.setBusinessNum(reportInfo.getBusinessNum());
|
|
- String dateName = DateUtils.format(new Date(),DateUtils.YYYYMMDD);
|
|
|
|
- reportFileEntity.setFileNameXml(dateName+ File.separator+fileName+".xml");
|
|
|
|
- reportFileEntity.setFileNameTxt(dateName+File.separator+fileName+".txt");
|
|
|
|
|
|
+ String dateName = DateUtils.format(new Date(), DateUtils.YYYYMMDD);
|
|
|
|
+ reportFileEntity.setFileNameXml(dateName + File.separator + fileName + ".xml");
|
|
|
|
+ reportFileEntity.setFileNameTxt(dateName + File.separator + fileName + ".txt");
|
|
//保存文件信息表
|
|
//保存文件信息表
|
|
reportFileService.saveOrUpdate(reportFileEntity);
|
|
reportFileService.saveOrUpdate(reportFileEntity);
|
|
//上传文件到服务器的目录
|
|
//上传文件到服务器的目录
|
|
//xml文件
|
|
//xml文件
|
|
- xmlTargetPath = xmlTargetPath+File.separator+dateName+File.separator;
|
|
|
|
|
|
+ xmlTargetPath = xmlTargetPath + File.separator + dateName + File.separator;
|
|
File file = new File(xmlTargetPath);
|
|
File file = new File(xmlTargetPath);
|
|
- if (!file.exists()){
|
|
|
|
|
|
+ if (!file.exists()) {
|
|
file.mkdirs();
|
|
file.mkdirs();
|
|
}
|
|
}
|
|
- jsonTargetPath = jsonTargetPath+File.separator+dateName+File.separator;
|
|
|
|
|
|
+ jsonTargetPath = jsonTargetPath + File.separator + dateName + File.separator;
|
|
File targetPathFile = new File(jsonTargetPath);
|
|
File targetPathFile = new File(jsonTargetPath);
|
|
- if (!targetPathFile.exists()){
|
|
|
|
|
|
+ if (!targetPathFile.exists()) {
|
|
targetPathFile.mkdirs();
|
|
targetPathFile.mkdirs();
|
|
}
|
|
}
|
|
- writeFile(xmlContext,fileName+".xml",xmlTargetPath);
|
|
|
|
|
|
+ writeFile(xmlContext, fileName + ".xml", xmlTargetPath);
|
|
//json文件
|
|
//json文件
|
|
- writeFile(jsonContext,fileName+".txt",jsonTargetPath);
|
|
|
|
|
|
+ writeFile(jsonContext, fileName + ".txt", jsonTargetPath);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
}
|
|
}
|