SupplierMaterialController.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package com.malk.kuaikeli.controller;
  2. import com.alibaba.excel.EasyExcel;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.baomidou.mybatisplus.core.metadata.IPage;
  5. import com.malk.kuaikeli.entity.SupplierMaterial;
  6. import com.malk.kuaikeli.listener.SupplierMaterialDataListener;
  7. import com.malk.kuaikeli.mapper.SupplierMaterialMapper;
  8. import com.malk.kuaikeli.service.SupplierMaterialService;
  9. import com.malk.server.common.McR;
  10. import com.malk.server.common.Page;
  11. import com.malk.utils.PublicUtil;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.web.bind.annotation.*;
  14. import org.springframework.web.multipart.MultipartFile;
  15. import java.io.IOException;
  16. import java.util.List;
  17. import java.util.Map;
  18. /***
  19. * 供应商原材料
  20. */
  21. @RestController
  22. @RequestMapping("/suppliermaterial")
  23. public class SupplierMaterialController {
  24. @Autowired
  25. private SupplierMaterialService supplierMaterialService;
  26. @PostMapping("/upload")
  27. public McR upload(@RequestParam(value="file")MultipartFile file) throws IOException {
  28. if(file.isEmpty()||file.getSize()<1){
  29. return McR.errorParam("文件不存在!");
  30. }
  31. if(!file.getOriginalFilename().endsWith("xlsx")&&!file.getOriginalFilename().endsWith("xls")) {
  32. return McR.errorParam("文件格式错误!");
  33. }
  34. supplierMaterialService.uploadData(file);
  35. return McR.success();
  36. }
  37. @GetMapping("/sync")
  38. public McR sync(){
  39. supplierMaterialService.sync();
  40. return McR.success();
  41. }
  42. @PostMapping("/projectSupplierChange")
  43. public McR projectSupplierChange(@RequestBody JSONObject param) throws IOException {
  44. if(PublicUtil.isNull(param,"projectId","oldId","newId","newName")){
  45. return McR.errorNullPointer();
  46. }
  47. supplierMaterialService.projectSupplierChange(param.getString("projectId"),param.getString("oldId"),param.getString("newId"),param.getString("newName"));
  48. return McR.success();
  49. }
  50. @GetMapping("/getList")
  51. public McR selectList(@RequestParam(defaultValue = "1") Integer current,
  52. @RequestParam(defaultValue = "10") Integer size){
  53. return supplierMaterialService.getList(current,size);
  54. }
  55. }