EntranceBatchController.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. package com.ruoyi.web.controller.app;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletResponse;
  4. import org.springframework.security.access.prepost.PreAuthorize;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.validation.annotation.Validated;
  7. import org.springframework.web.bind.annotation.GetMapping;
  8. import org.springframework.web.bind.annotation.PostMapping;
  9. import org.springframework.web.bind.annotation.PutMapping;
  10. import org.springframework.web.bind.annotation.DeleteMapping;
  11. import org.springframework.web.bind.annotation.PathVariable;
  12. import org.springframework.web.bind.annotation.RequestBody;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RestController;
  15. import com.ruoyi.common.annotation.Log;
  16. import com.ruoyi.common.core.controller.BaseController;
  17. import com.ruoyi.common.core.domain.AjaxResult;
  18. import com.ruoyi.common.enums.BusinessType;
  19. import com.ruoyi.app.model.EntranceBatch;
  20. import com.ruoyi.app.service.IEntranceBatchService;
  21. import com.ruoyi.common.utils.poi.ExcelUtil;
  22. import com.ruoyi.common.core.page.TableDataInfo;
  23. /**
  24. * 入场批次Controller
  25. *
  26. * @author coede
  27. * @date 2025-03-19
  28. */
  29. @RestController
  30. @RequestMapping("/app/entranceBatch")
  31. public class EntranceBatchController extends BaseController
  32. {
  33. @Autowired
  34. private IEntranceBatchService entranceBatchService;
  35. /**
  36. * 查询入场批次列表
  37. */
  38. @PreAuthorize("@ss.hasPermi('app:entranceBatch:list')")
  39. @GetMapping("/list")
  40. public TableDataInfo list(EntranceBatch entranceBatch)
  41. {
  42. startPage();
  43. List<EntranceBatch> list = entranceBatchService.selectEntranceBatchList(entranceBatch);
  44. return getDataTable(list);
  45. }
  46. /**
  47. * 入场批次列表
  48. */
  49. @PreAuthorize("@ss.hasPermi('app:entranceBatch:page')")
  50. @GetMapping("/page")
  51. public TableDataInfo page(EntranceBatch entranceBatch)
  52. {
  53. //List<EntranceBatch> list = entranceBatchService.selectEntranceBatchList1(entranceBatch);
  54. List<EntranceBatch> list = entranceBatchService.selectEntranceBatchList2(entranceBatch);
  55. return getDataTable(list);
  56. }
  57. /**
  58. * 导出入场批次列表
  59. */
  60. @PreAuthorize("@ss.hasPermi('app:entranceBatch:export')")
  61. @Log(title = "入场批次", businessType = BusinessType.EXPORT)
  62. @PostMapping("/export")
  63. public void export(HttpServletResponse response, EntranceBatch entranceBatch)
  64. {
  65. List<EntranceBatch> list = entranceBatchService.selectEntranceBatchList(entranceBatch);
  66. ExcelUtil<EntranceBatch> util = new ExcelUtil<EntranceBatch>(EntranceBatch.class);
  67. util.exportExcel(response, list, "入场批次数据");
  68. }
  69. /**
  70. * 获取入场批次详细信息
  71. */
  72. @PreAuthorize("@ss.hasPermi('app:entranceBatch:query')")
  73. @GetMapping(value = "/{id}")
  74. public AjaxResult getInfo(@PathVariable("id") Long id)
  75. {
  76. return success(entranceBatchService.selectEntranceBatchById(id));
  77. }
  78. /**
  79. * 新增入场批次
  80. */
  81. @PreAuthorize("@ss.hasPermi('app:entranceBatch:add')")
  82. @Log(title = "入场批次", businessType = BusinessType.INSERT)
  83. @PostMapping
  84. public AjaxResult add(@Validated @RequestBody EntranceBatch entranceBatch)
  85. {
  86. if (entranceBatch.getAnimalCertNo()!=null && !entranceBatch.getAnimalCertNo().isEmpty()){
  87. if (!entranceBatchService.checkAnimalCertNoUnique(entranceBatch))
  88. {
  89. return error("新增入场批次失败,列表中存在重复的检疫证号");
  90. }
  91. }
  92. entranceBatch.setCreateBy(getUsername());
  93. return toAjax(entranceBatchService.insertEntranceBatch(entranceBatch));
  94. }
  95. /**
  96. * 修改入场批次
  97. */
  98. @PreAuthorize("@ss.hasPermi('app:entranceBatch:edit')")
  99. @Log(title = "入场批次", businessType = BusinessType.UPDATE)
  100. @PutMapping
  101. public AjaxResult edit(@Validated @RequestBody EntranceBatch entranceBatch)
  102. {
  103. if (entranceBatch.getAnimalCertNo()!=null && !entranceBatch.getAnimalCertNo().isEmpty()){
  104. if (!entranceBatchService.checkAnimalCertNoUnique(entranceBatch))
  105. {
  106. return error("修改入场批次失败,列表中存在重复的检疫证号");
  107. }
  108. }
  109. entranceBatch.setUpdateBy(getUsername());
  110. return toAjax(entranceBatchService.updateEntranceBatch(entranceBatch));
  111. }
  112. /**
  113. * 删除入场批次
  114. */
  115. @PreAuthorize("@ss.hasPermi('app:entranceBatch:remove')")
  116. @Log(title = "入场批次", businessType = BusinessType.DELETE)
  117. @DeleteMapping("/{ids}")
  118. public AjaxResult remove(@PathVariable Long[] ids)
  119. {
  120. return toAjax(entranceBatchService.deleteEntranceBatchByIds(ids));
  121. }
  122. }