|
@@ -33,6 +33,11 @@ public class FileServiceImpl {
|
|
|
@Value("${report.file.jsonTargetPath}")
|
|
|
private String jsonTargetPath;
|
|
|
|
|
|
+ /**
|
|
|
+ * 上传文件
|
|
|
+ * @param context
|
|
|
+ * @param filename
|
|
|
+ */
|
|
|
private void writeFile(String context, String filename) {
|
|
|
try {
|
|
|
IOUtils.write(context, new FileOutputStream(jsonTargetPath + filename), "UTF-8");
|
|
@@ -42,56 +47,29 @@ public class FileServiceImpl {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 保存XML文件
|
|
|
+ * 保存xml文件和json文件
|
|
|
* @param reportInfo
|
|
|
- * @param context
|
|
|
+ * @param xmlContext
|
|
|
+ * @param jsonContext
|
|
|
* @param fileName
|
|
|
*/
|
|
|
- public void saveAndWriteXMLFile(ReportInfo reportInfo,String context,String fileName){
|
|
|
+ public void saveAndWriteFile(ReportInfo reportInfo,String xmlContext,String jsonContext,String fileName){
|
|
|
ReportFileEntity reportFileEntity = new ReportFileEntity();
|
|
|
reportFileEntity.setFileNameXml(fileName+".xml");
|
|
|
- saveAndWriteCommonFile(reportFileEntity,reportInfo,context,fileName);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存JSON文件
|
|
|
- * @param reportInfo
|
|
|
- * @param context
|
|
|
- * @param fileName
|
|
|
- */
|
|
|
- public void saveAndWriteJsonFile(ReportInfo reportInfo,String context,String fileName){
|
|
|
- ReportFileEntity reportFileEntity = new ReportFileEntity();
|
|
|
- reportFileEntity.setFileNameTxt(fileName+".txt");
|
|
|
- saveAndWriteCommonFile(reportFileEntity,reportInfo,context,fileName);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存模型文件
|
|
|
- * @param reportInfo
|
|
|
- * @param context
|
|
|
- * @param fileName
|
|
|
- */
|
|
|
- private void saveAndWriteModelFile(ReportInfo reportInfo,String context,String fileName){
|
|
|
- ReportFileEntity reportFileEntity = new ReportFileEntity();
|
|
|
- reportFileEntity.setFileNameModel(fileName+".txt");
|
|
|
- saveAndWriteCommonFile(reportFileEntity,reportInfo,context,fileName);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 保存文件信息到report_file表和上传文件到指定路径
|
|
|
- * @param reportInfo
|
|
|
- * @param context
|
|
|
- * @param fileName
|
|
|
- */
|
|
|
- private void saveAndWriteCommonFile(ReportFileEntity reportFileEntity,ReportInfo reportInfo,String context,String fileName){
|
|
|
reportFileEntity.setHeadInfId(reportInfo.getId());
|
|
|
reportFileEntity.setRptNo(reportInfo.getRptNo());
|
|
|
reportFileEntity.setBusinessId(reportInfo.getBusinessId());
|
|
|
reportFileEntity.setBusinessNum(reportInfo.getBusinessNum());
|
|
|
- reportFileEntity.setFileName(fileName);
|
|
|
+ reportFileEntity.setFileNameXml(fileName+".xml");
|
|
|
+ reportFileEntity.setFileNameTxt(fileName+".txt");
|
|
|
//保存文件信息表
|
|
|
- reportFileService.save(reportFileEntity);
|
|
|
+ reportFileService.saveOrUpdate(reportFileEntity);
|
|
|
//上传文件到服务器的目录
|
|
|
- writeFile(context,fileName);
|
|
|
+ writeFile(xmlContext,fileName+".xml");
|
|
|
+ writeFile(jsonContext,fileName+".txt");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|