PartController.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package com.hssx.cloudmodel.controller;
  2. import com.hssx.cloudmodel.entity.Part;
  3. import com.hssx.cloudmodel.entity.vo.UserVO;
  4. import com.hssx.cloudmodel.service.PartService;
  5. import com.hssx.cloudmodel.util.HttpRespMsg;
  6. import io.swagger.annotations.ApiOperation;
  7. import org.apache.poi.ss.usermodel.Cell;
  8. import org.apache.poi.xssf.usermodel.XSSFCell;
  9. import org.apache.poi.xssf.usermodel.XSSFRow;
  10. import org.apache.poi.xssf.usermodel.XSSFSheet;
  11. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Controller;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RequestParam;
  16. import org.springframework.web.bind.annotation.ResponseBody;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import org.springframework.web.multipart.MultipartFile;
  19. import javax.servlet.http.HttpServletResponse;
  20. import java.io.File;
  21. import java.io.FileOutputStream;
  22. import java.io.InputStream;
  23. import java.io.OutputStream;
  24. import java.text.SimpleDateFormat;
  25. import java.util.ArrayList;
  26. import java.util.Date;
  27. import java.util.List;
  28. /**
  29. * @author 吴涛涛
  30. * @since 2019-08-13
  31. */
  32. @Controller
  33. @RequestMapping("/part")
  34. public class PartController {
  35. @Autowired
  36. PartService partService;
  37. /**
  38. * 批量零件 Excel 导入
  39. * file excel文件 token 用户身份凭证 mouldId 模具id
  40. *
  41. * @param file
  42. * @throws Exception
  43. */
  44. @ApiOperation("零件的excel导入")
  45. @RequestMapping(value = "/importAppLogin")
  46. @ResponseBody
  47. public HttpRespMsg importAppLogin(
  48. @RequestParam(value = "file", required = false) MultipartFile file,
  49. UserVO userVO) {
  50. HttpRespMsg msg = new HttpRespMsg();
  51. msg = partService.importPartExcel(file, userVO);
  52. return msg;
  53. }
  54. /**
  55. * 单个零件添加
  56. * file excel文件 token 用户身份凭证 mouldId 模具id
  57. * @throws Exception
  58. */
  59. @ApiOperation("零件的excel导入")
  60. @RequestMapping(value = "/importAppLogin")
  61. @ResponseBody
  62. public HttpRespMsg addOrUpdate(
  63. Part part,
  64. UserVO userVO) {
  65. HttpRespMsg msg = new HttpRespMsg();
  66. msg = partService.add(part,
  67. userVO);
  68. return msg;
  69. }
  70. }