FileService.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. package com.uas.report.service;
  2. import java.util.List;
  3. import java.util.Map;
  4. import javax.servlet.http.HttpServletResponse;
  5. import org.springframework.web.multipart.MultipartFile;
  6. /**
  7. * 文件操作
  8. *
  9. * @author sunyj
  10. * @since 2016年11月2日 下午2:36:46
  11. */
  12. public interface FileService {
  13. /**
  14. * 自动对新部署的账套进行下载模板、解压、配置路径等操作
  15. *
  16. * @param userNames
  17. * 账套名称,多个账套以英文逗号隔开
  18. * @return 部署结果
  19. */
  20. public String autoDeploy(String userNames);
  21. /**
  22. * 上传文件
  23. *
  24. * @param userName
  25. * 账套名,文件上传至相应账套路径下
  26. * @param file
  27. * 上传的文件
  28. * @return 上传结果
  29. */
  30. public String upload(String userName, String fileType, MultipartFile file);
  31. /**
  32. * 获取账套下的模板路径
  33. *
  34. * @param userName
  35. * 账套名称
  36. * @param reportName
  37. * 模板名称
  38. * @return 模板路径
  39. */
  40. public String getJrxmlFilePath(String userName, String reportName);
  41. /**
  42. * 获取账套路径
  43. *
  44. * @param userName
  45. * 账套名称
  46. * @return 账套路径
  47. */
  48. public String getMasterPath(String userName);
  49. /**
  50. * 获取标准模板
  51. *
  52. * @return 标准模板数据
  53. */
  54. public byte[] getStandardJrxmls();
  55. /**
  56. * 获取账套下的所有资源
  57. *
  58. * @param userName
  59. * 账套名称
  60. * @return 账套下所有资源的压缩包路径
  61. */
  62. public String getZip(String userName);
  63. /**
  64. * 下载文件
  65. *
  66. * @param filePath
  67. * 文件路径
  68. * @param isAbsolutePath
  69. * 文件路径是否为绝对路径
  70. * @param response
  71. */
  72. public void download(String filePath, Boolean isAbsolutePath, HttpServletResponse response);
  73. /**
  74. * 账套下的某个文件(夹)
  75. *
  76. * @param userName
  77. * 账套名称
  78. * @param fileRelativePath
  79. * 文件(夹)在账套下的相对路径
  80. * @return 文件(夹)路径
  81. */
  82. public String delete(String userName, String fileRelativePath);
  83. /**
  84. * 递归删除文件(夹)
  85. *
  86. * @param filePath
  87. * 文件(夹)路径
  88. * @return 文件(夹)路径
  89. */
  90. public String delete(String filePath);
  91. /**
  92. * 列出本地资源根路径下指定路径的文件信息
  93. *
  94. * @param fileRelativePath
  95. * 指定的相对路径
  96. * @return 文件信息,包括name(String)、lastModified(String)、size(Long)、relativePath(
  97. * String)、isDirectory(Boolean)
  98. */
  99. public List<Map<String, Object>> listFiles(String fileRelativePath);
  100. /**
  101. * 判断文件是否有效(文件存在并且未过有效期,并且比模板新)
  102. *
  103. * @param filePath
  104. * 所指定的文件绝对路径
  105. * @param jrxmlFilePath
  106. * 文件对应的模板路径
  107. * @return 是否有效
  108. */
  109. public boolean isFileValid(String filePath, String jrxmlFilePath);
  110. /**
  111. * 根据报表名、账套名等生成文件名(文件名:reportName + hashCode)
  112. *
  113. * @param userName
  114. * 不为null;当前账套用户名
  115. * @param profile
  116. * 可为null;用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev
  117. * @param reportName
  118. * 不为null;需要预览的报表的名称,不带任何后缀(如预览采购单,即为"Purchase")
  119. * @param whereCondition
  120. * 可为null;where之后的条件(包括where)
  121. * @param otherParameters
  122. * 可为null;若模板已指定需要的参数,则不可为null;其他参数,区别于whereCondition,
  123. * 报表某些字段的值取决于这些参数; JSON格式,数据为键值对
  124. * @param exportFileType
  125. * 导出为文件时,文件的格式(pdf、xls、xls_with_only_data等)
  126. * @return 生成的文件名(不含后缀名)
  127. */
  128. public String generateFileName(String userName, String profile, String reportName, String whereCondition,
  129. String otherParameters, String exportFileType);
  130. /**
  131. * 获取给定的pdf文件的页数
  132. *
  133. * @param pdfFilePath
  134. * 给定的pdf文件绝对路径
  135. * @return pdf文件的页数
  136. */
  137. public int getPageSize(String pdfFilePath);
  138. /**
  139. * 利用给定的pdf文件在同级目录下生成多个分页的pdf文件(一页对应一个文件)
  140. *
  141. * @param pdfFilePath
  142. * 给定的pdf文件绝对路径
  143. */
  144. public void createPagedPdfFiles(String pdfFilePath);
  145. }