PartController.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. * 参数: token 用户身份凭证, mouldId 模具id ,partNo 零件编号,partName 零件名称,partLife 零件寿命 单位:年
  57. * 修改:需多传 id 零件id
  58. *
  59. * @throws Exception
  60. */
  61. @ApiOperation("单个零件添加")
  62. @RequestMapping(value = "/addOrUpdate")
  63. @ResponseBody
  64. public HttpRespMsg addOrUpdate(Part part, UserVO userVO) {
  65. HttpRespMsg msg = new HttpRespMsg();
  66. msg = partService.add(part, userVO);
  67. return msg;
  68. }
  69. /**
  70. * 单个零件添加
  71. * 参数: token 用户身份凭证, mouldId 模具id
  72. *
  73. * @throws Exception
  74. */
  75. @ApiOperation("零件列表")
  76. @RequestMapping(value = "/list")
  77. @ResponseBody
  78. public HttpRespMsg list(Part part, UserVO userVO) {
  79. HttpRespMsg msg = new HttpRespMsg();
  80. msg = partService.getList(userVO);
  81. return msg;
  82. }
  83. }