MouldFileController.java 7.6 KB

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