TCostManagementController.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. package com.ruoyi.web.controller.cost;
  2. import java.util.List;
  3. import com.ruoyi.anpin.domain.TCostManagement;
  4. import com.ruoyi.anpin.service.ITCostManagementService;
  5. import com.ruoyi.common.annotation.RepeatSubmit;
  6. import com.ruoyi.common.core.domain.model.LoginUser;
  7. import com.ruoyi.common.utils.ServletUtils;
  8. import com.ruoyi.common.utils.StringUtils;
  9. import com.ruoyi.common.utils.spring.SpringUtils;
  10. import com.ruoyi.framework.web.service.TokenService;
  11. import org.springframework.security.access.prepost.PreAuthorize;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.web.bind.annotation.*;
  14. import com.ruoyi.common.annotation.Log;
  15. import com.ruoyi.common.core.controller.BaseController;
  16. import com.ruoyi.common.core.domain.AjaxResult;
  17. import com.ruoyi.common.enums.BusinessType;
  18. import com.ruoyi.common.utils.poi.ExcelUtil;
  19. import com.ruoyi.common.core.page.TableDataInfo;
  20. /**
  21. * 费用管理Controller
  22. *
  23. * @author ruoyi
  24. * @date 2023-03-13
  25. */
  26. @RestController
  27. @RequestMapping("/anpin/management")
  28. public class TCostManagementController extends BaseController
  29. {
  30. @Autowired
  31. private ITCostManagementService tCostManagementService;
  32. /**
  33. * 查询费用管理列表
  34. */
  35. @PreAuthorize("@ss.hasPermi('anpin:management:list')")
  36. @GetMapping("/list")
  37. public TableDataInfo list(TCostManagement tCostManagement)
  38. {
  39. startPage();
  40. List<TCostManagement> list = tCostManagementService.selectTCostManagementList(tCostManagement);
  41. return getDataTable(list);
  42. }
  43. /**
  44. * 导出费用管理列表
  45. */
  46. @PreAuthorize("@ss.hasPermi('anpin:management:export')")
  47. @Log(title = "费用管理", businessType = BusinessType.EXPORT)
  48. @GetMapping("/export")
  49. public AjaxResult export(TCostManagement tCostManagement)
  50. {
  51. List<TCostManagement> list = tCostManagementService.selectTCostManagementList(tCostManagement);
  52. ExcelUtil<TCostManagement> util = new ExcelUtil<TCostManagement>(TCostManagement.class);
  53. return util.exportExcel(list, "费用管理");
  54. }
  55. /**
  56. * 获取费用管理详细信息
  57. */
  58. @PreAuthorize("@ss.hasPermi('anpin:management:query')")
  59. @GetMapping(value = "/{fId}")
  60. public AjaxResult getInfo(@PathVariable("fId") Long fId)
  61. {
  62. return AjaxResult.success(tCostManagementService.selectTCostManagementById(fId));
  63. }
  64. /**
  65. * 新增费用管理
  66. */
  67. @PreAuthorize("@ss.hasPermi('anpin:management:add')")
  68. @Log(title = "费用管理", businessType = BusinessType.INSERT)
  69. @PostMapping(value = "/managementAdd")
  70. @RepeatSubmit
  71. public AjaxResult managementAdd(@RequestParam("tCostManagement") String tCostManagement,
  72. @RequestParam("tCostManagementItem") String tCostManagementItem,
  73. @RequestParam("tEnclosure") String tEnclosure)
  74. {
  75. if (StringUtils.isNull(tCostManagement) || "{}".equals(tCostManagement)) {
  76. return AjaxResult.error("未找到主表数据,请确认");
  77. }
  78. // 获取当前的用户
  79. LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
  80. return tCostManagementService.insertTCostManagement(tCostManagement,tCostManagementItem,tEnclosure,loginUser);
  81. }
  82. /**
  83. * 修改费用管理
  84. */
  85. @PreAuthorize("@ss.hasPermi('anpin:management:edit')")
  86. @Log(title = "费用管理", businessType = BusinessType.UPDATE)
  87. @PutMapping
  88. public AjaxResult edit(@RequestBody TCostManagement tCostManagement)
  89. {
  90. return toAjax(tCostManagementService.updateTCostManagement(tCostManagement));
  91. }
  92. /**
  93. * 删除费用管理
  94. */
  95. @PreAuthorize("@ss.hasPermi('anpin:management:remove')")
  96. @Log(title = "费用管理", businessType = BusinessType.DELETE)
  97. @DeleteMapping("/{fIds}")
  98. public AjaxResult remove(@PathVariable Long[] fIds)
  99. {
  100. return toAjax(tCostManagementService.deleteTCostManagementByIds(fIds));
  101. }
  102. /**
  103. * 费用管理提交审批
  104. * @param tCostManagement
  105. * @param tCostManagementItem
  106. * @param tEnclosure
  107. * @return
  108. */
  109. @PreAuthorize("@ss.hasPermi('anpin:management:submitCostManagement')")
  110. @Log(title = "费用管理审批", businessType = BusinessType.INSERT)
  111. @PostMapping("/submitCostManagement")
  112. public AjaxResult submitCostManagement(@RequestParam("tCostManagement") String tCostManagement,
  113. @RequestParam("tCostManagementItem") String tCostManagementItem,
  114. @RequestParam("tEnclosure") String tEnclosure)
  115. {
  116. if (StringUtils.isEmpty(tCostManagement) || "{}".equals(tCostManagement)){
  117. return AjaxResult.error("主表数据不能为空");
  118. }
  119. if (StringUtils.isEmpty(tCostManagementItem)|| "[]".equals(tCostManagementItem)){
  120. return AjaxResult.error("明细表数据不能为空");
  121. }
  122. String billType = "FYGL";
  123. LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
  124. return tCostManagementService.submitCostManagement(tCostManagement,tCostManagementItem,tEnclosure,loginUser,billType);
  125. }
  126. }