MouldFileController.java 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. package com.hssx.cloudmodel.controller;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.hssx.cloudmodel.entity.MouldFile;
  4. import com.hssx.cloudmodel.entity.ProjectFile;
  5. import com.hssx.cloudmodel.entity.User;
  6. import com.hssx.cloudmodel.entity.vo.UserVO;
  7. import com.hssx.cloudmodel.service.MouldFileService;
  8. import com.hssx.cloudmodel.service.MouldService;
  9. import com.hssx.cloudmodel.service.UserService;
  10. import com.hssx.cloudmodel.util.HttpRespMsg;
  11. import com.hssx.cloudmodel.util.PageUtil;
  12. import io.swagger.annotations.ApiOperation;
  13. import org.apache.commons.lang3.StringUtils;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.beans.factory.annotation.Value;
  16. import org.springframework.web.bind.annotation.*;
  17. import org.springframework.web.multipart.MultipartFile;
  18. import javax.servlet.ServletOutputStream;
  19. import javax.servlet.http.HttpServletRequest;
  20. import javax.servlet.http.HttpServletResponse;
  21. import java.io.*;
  22. import java.net.URLEncoder;
  23. import java.util.Map;
  24. import java.util.zip.ZipEntry;
  25. import java.util.zip.ZipOutputStream;
  26. /**
  27. * <p>
  28. * 前端控制器
  29. * </p>
  30. *
  31. * @author 吴涛涛
  32. * @since 2019-08-07
  33. */
  34. @RestController
  35. @RequestMapping("/mouldfile")
  36. public class MouldFileController {
  37. @Value("${upload.path}")
  38. private String path;
  39. @Value("${download.path}")
  40. private String downloadPath;
  41. @Autowired
  42. private MouldFileService mouldFileService;
  43. @Autowired
  44. private UserService userService;
  45. /**
  46. * 模具文档的上传
  47. * 参数: token 用户身份凭证,
  48. * mouldId 模具id ,
  49. * blongType 文档类型(0-模具文档 1-零件文档 2-试模验收 3-保养方案 4-模具更新 5-模具报废),
  50. * 注:blongType 为 1 时需要多传 partId 零件id
  51. * blongType 为3 以下的file和dwgType参数均不需要传递
  52. * file 文件信息,dwgType 图档类型0-2D,1-3D(上传零件文档和模具文档时传该参数)
  53. *
  54. * @return
  55. */
  56. @ApiOperation("模具文档的上传")
  57. @RequestMapping("/uploadFile")
  58. @ResponseBody
  59. public HttpRespMsg uploadFile(@RequestParam(required = false) MultipartFile file, @RequestParam(required = false) MultipartFile file2, @RequestParam(required = false) Integer blongType,
  60. HttpServletResponse response, HttpServletRequest request, UserVO userVO) throws Exception {
  61. // System.out.println("开始上传文件" + "file+" + file.getOriginalFilename());
  62. System.out.println("blongType" + blongType);
  63. if (null == blongType) {
  64. blongType = 0;
  65. }
  66. HttpRespMsg msg = new HttpRespMsg();
  67. msg = mouldFileService.addFile(userVO, blongType, file, file2, path);
  68. return msg;
  69. }
  70. /**
  71. * 零件文档的批量上传(文件命名规则:零件编号+2D/3D 如 LJ001+2D.dwg)
  72. * 参数: token 用户身份凭证,
  73. * mouldId 模具id ,files 多文件数组
  74. *
  75. * @return
  76. */
  77. @ApiOperation("零件文档的批量上传")
  78. @RequestMapping("/uploadPartFileList")
  79. @ResponseBody
  80. public HttpRespMsg uploadFile(@RequestParam("file") MultipartFile[] files, UserVO userVO) throws Exception {
  81. HttpRespMsg msg = new HttpRespMsg();
  82. msg = mouldFileService.addPartFile(userVO, path, files);
  83. return msg;
  84. }
  85. @ApiOperation("模具文档的审核")
  86. @RequestMapping("/check")
  87. @ResponseBody
  88. public HttpRespMsg check(@RequestParam Integer mouldFileId, @RequestParam Integer isPass,
  89. HttpServletResponse response, HttpServletRequest request, UserVO userVO) throws Exception {
  90. HttpRespMsg msg = new HttpRespMsg();
  91. msg = mouldFileService.check(mouldFileId, isPass, userVO);
  92. return msg;
  93. }
  94. /**
  95. * 模具文档的列表
  96. * 参数: token 用户身份凭证,mouldId 模具id, type文档类型:0-模具文档,1-零件文档
  97. *
  98. * @return
  99. */
  100. @ApiOperation("模具文档的列表")
  101. @RequestMapping("/list")
  102. @ResponseBody
  103. public HttpRespMsg list(@RequestParam Integer mouldId, @RequestParam Integer blongType, UserVO userVO) {
  104. HttpRespMsg msg = mouldFileService.getFileList(mouldId, blongType, userVO);
  105. return msg;
  106. }
  107. /**
  108. * 模具文档的列表
  109. * 参数: token 用户身份凭证,mouldId 模具id, type文档类型:0-模具文档,1-零件文档
  110. *
  111. * @return
  112. */
  113. @ApiOperation("模具所有类型的文档列表")
  114. @RequestMapping("/allList")
  115. @ResponseBody
  116. public HttpRespMsg allList(@RequestParam Integer mouldId, UserVO userVO) {
  117. HttpRespMsg msg = mouldFileService.getAllFileList(mouldId, userVO);
  118. return msg;
  119. }
  120. /**
  121. * 模具文档的下载
  122. * 参数: token 用户身份凭证,id 项目id
  123. *
  124. * @return
  125. */
  126. @ApiOperation("模具所有类型文档的下载")
  127. @RequestMapping("/dowloadFile")
  128. @ResponseBody
  129. public HttpRespMsg dowloadFile(MouldFile mouldFile, String token) {
  130. HttpRespMsg msg = mouldFileService.dowloadFile(mouldFile, token);
  131. return msg;
  132. }
  133. /**
  134. * 模具文档的删除
  135. * 参数: id 文档id
  136. *
  137. * @return
  138. */
  139. @ApiOperation("项目文档的删除")
  140. @RequestMapping("/delFile")
  141. @ResponseBody
  142. public HttpRespMsg delFile(MouldFile mouldFile) {
  143. HttpRespMsg msg = mouldFileService.delFile(mouldFile);
  144. return msg;
  145. }
  146. /**
  147. * 文档批量下载列表
  148. * 参数: token 用户身份凭证,pageSize ,pageNum,keyName(筛选搜索关键词)
  149. *
  150. * @return
  151. */
  152. @ApiOperation("文档批量下载列表")
  153. @RequestMapping("/fileList")
  154. @ResponseBody
  155. public HttpRespMsg fileList(UserVO userVO, PageUtil page) {
  156. HttpRespMsg msg = new HttpRespMsg();
  157. msg = mouldFileService.getListByUserAndProjectId(userVO, page);
  158. return msg;
  159. }
  160. /**
  161. * 文档勾选批量下载
  162. * 参数: ids 模具ids 如“1,2,3”
  163. *
  164. * @return
  165. */
  166. @ApiOperation("文档勾选批量下载")
  167. @RequestMapping(value = "/downloadfileList", method = RequestMethod.POST)
  168. @ResponseBody
  169. public HttpRespMsg downloadfileList(UserVO userVO, HttpServletRequest request, HttpServletResponse response) {
  170. HttpRespMsg msg = new HttpRespMsg();
  171. try {
  172. msg = mouldFileService.dowloadFileList(userVO, request, response, downloadPath, path);
  173. } catch (IOException e) {
  174. e.printStackTrace();
  175. }
  176. return msg;
  177. }
  178. /**
  179. * 文档下载日志的excel导出
  180. * 参数:startTime 开始时间,endTime 结束时间,mouldId 模具id
  181. *
  182. * @return
  183. */
  184. @ApiOperation("文档下载日志的excel导出")
  185. @RequestMapping(value = "/downloadFileListExcel", method = RequestMethod.POST)
  186. @ResponseBody
  187. public HttpRespMsg downloadFileListExcel(UserVO userVO, HttpServletResponse response) {
  188. HttpRespMsg msg = new HttpRespMsg();
  189. try {
  190. msg = mouldFileService.downloadFileListExcel(userVO, response);
  191. } catch (Exception e) {
  192. e.printStackTrace();
  193. }
  194. return msg;
  195. }
  196. }