BillLuggageController.java 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package com.huimv.receive.controller;
  2. import com.huimv.receive.common.utils.PdfUtil;
  3. import com.huimv.receive.common.utils.Result;
  4. import com.huimv.receive.common.utils.ResultCode;
  5. import com.huimv.receive.service.IBillLuggageService;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.web.bind.annotation.*;
  8. import org.springframework.web.multipart.MultipartFile;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11. import java.io.IOException;
  12. import java.util.HashMap;
  13. import java.util.Map;
  14. /**
  15. * <p>
  16. * 前端控制器
  17. * </p>
  18. *
  19. * @author author
  20. * @since 2023-07-24
  21. */
  22. @RestController
  23. @RequestMapping("/bill-luggage")
  24. @CrossOrigin
  25. public class BillLuggageController {
  26. @Autowired
  27. private IBillLuggageService billLuggageService;
  28. @PostMapping("/addLuggage")
  29. public Result addLuggage(HttpServletRequest httpServletRequest,
  30. @RequestParam("farmId") String farmId,
  31. @RequestParam("userName") String userName,
  32. @RequestParam("phone") String phone,
  33. @RequestParam("luggageDate") String luggageDate,
  34. @RequestParam("luggageLocation") String luggageLocation,
  35. @RequestParam("luggageLocationId") String luggageLocationId,
  36. @RequestParam("luggageNum") Integer luggageNum,
  37. @RequestParam(value = "img1",required = false) MultipartFile img,
  38. @RequestParam(value = "img2",required = false) MultipartFile img2,
  39. @RequestParam(value = "img3",required = false) MultipartFile img3,
  40. @RequestParam(value = "img4",required = false) MultipartFile img4,
  41. @RequestParam(value = "img5",required = false) MultipartFile img5) throws IOException {
  42. return billLuggageService.addLuggage(httpServletRequest,farmId,userName,phone,luggageDate,luggageLocation,luggageLocationId,luggageNum,img,img2,img3,img4,img5);
  43. }
  44. @PostMapping("/listPersonalLuggage")
  45. public Result listPersonalLuggage(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap){
  46. return billLuggageService.listPersonalLuggage(httpServletRequest,paramsMap);
  47. }
  48. @PostMapping("/getDetail")
  49. public Result getDetail(@RequestBody Map<String, String> paramsMap){
  50. return new Result(ResultCode.SUCCESS,billLuggageService.getById(paramsMap.get("id")));
  51. }
  52. @PostMapping("/listLuggage")
  53. public Result listLuggage(HttpServletRequest httpServletRequest,@RequestBody Map<String, String> paramsMap){
  54. return billLuggageService.listLuggage(httpServletRequest, paramsMap);
  55. }
  56. @PostMapping("/selectLuggage")
  57. public Result selectLuggage(HttpServletRequest httpServletRequest,@RequestBody Map<String, String> paramsMap){
  58. return billLuggageService.selectLuggage(httpServletRequest, paramsMap);
  59. }
  60. @PostMapping("/delete")
  61. public Result delete(HttpServletRequest httpServletRequest,@RequestBody Map<String, String> paramsMap){
  62. String ids = paramsMap.get("ids");
  63. String[] split = ids.split(",");
  64. for (String s : split) {
  65. billLuggageService.removeById(s);
  66. }
  67. return new Result(10000,"删除成功!",true);
  68. }
  69. @GetMapping("/printLuggage")
  70. public void printLuggage(HttpServletResponse response, @RequestParam(name = "ids") String ids) throws Exception {
  71. Map<String, String> map = new HashMap<>();
  72. map.put("ids", ids);
  73. billLuggageService.printLuggage(response, map);
  74. String path = "/opt/huatong/luggage.xls";
  75. PdfUtil.returnPdfStream3(response, path, "行李详情列表");
  76. }
  77. }