TProgressController.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package com.ruoyi.web.controller.rc;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletResponse;
  4. import com.ruoyi.common.core.domain.entity.SysDept;
  5. import com.ruoyi.common.utils.StringUtils;
  6. import com.ruoyi.rc.domain.TOpenItem;
  7. import com.ruoyi.system.service.ISysDeptService;
  8. import org.springframework.security.access.prepost.PreAuthorize;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.GetMapping;
  11. import org.springframework.web.bind.annotation.PostMapping;
  12. import org.springframework.web.bind.annotation.PutMapping;
  13. import org.springframework.web.bind.annotation.DeleteMapping;
  14. import org.springframework.web.bind.annotation.PathVariable;
  15. import org.springframework.web.bind.annotation.RequestBody;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import com.ruoyi.common.annotation.Log;
  19. import com.ruoyi.common.core.controller.BaseController;
  20. import com.ruoyi.common.core.domain.AjaxResult;
  21. import com.ruoyi.common.enums.BusinessType;
  22. import com.ruoyi.rc.domain.TProgress;
  23. import com.ruoyi.rc.service.ITProgressService;
  24. import com.ruoyi.common.utils.poi.ExcelUtil;
  25. import com.ruoyi.common.core.page.TableDataInfo;
  26. /**
  27. * 进度Controller
  28. *
  29. * @author ruoyi
  30. * @date 2024-07-19
  31. */
  32. @RestController
  33. @RequestMapping("/rc/progress")
  34. public class TProgressController extends BaseController
  35. {
  36. @Autowired
  37. private ITProgressService tProgressService;
  38. @Autowired
  39. private ISysDeptService deptService;
  40. /**
  41. * 查询进度列表
  42. */
  43. @PreAuthorize("@ss.hasPermi('rc:progress:list')")
  44. @GetMapping("/list")
  45. public TableDataInfo list(TProgress tProgress)
  46. {
  47. startPage();
  48. List<TProgress> list = tProgressService.selectTProgressList(tProgress);
  49. for (TProgress obj : list) {
  50. String deptId = obj.getDeptId();
  51. if (StringUtils.isNotEmpty(deptId)) {
  52. if (deptId.indexOf(",") != -1) {
  53. StringBuffer sb = new StringBuffer();
  54. String[] ids = deptId.split(",");
  55. for (String id : ids) {
  56. SysDept sysDept = deptService.selectDeptById(Long.parseLong(id));
  57. sb.append(sysDept.getDeptName()).append(" / ");
  58. }
  59. obj.setDeptName(sb.toString().substring(0, sb.length() - 3));
  60. } else {
  61. obj.setDeptName(deptService.selectDeptById(Long.parseLong(deptId)).getDeptName());
  62. }
  63. }
  64. }
  65. return getDataTable(list);
  66. }
  67. /**
  68. * 导出进度列表
  69. */
  70. @PreAuthorize("@ss.hasPermi('rc:progress:export')")
  71. @Log(title = "进度", businessType = BusinessType.EXPORT)
  72. @PostMapping("/export")
  73. public void export(HttpServletResponse response, TProgress tProgress)
  74. {
  75. List<TProgress> list = tProgressService.selectTProgressList(tProgress);
  76. ExcelUtil<TProgress> util = new ExcelUtil<TProgress>(TProgress.class);
  77. util.exportExcel(response, list, "进度数据");
  78. }
  79. /**
  80. * 获取进度详细信息
  81. */
  82. @PreAuthorize("@ss.hasPermi('rc:progress:query')")
  83. @GetMapping(value = "/{id}")
  84. public AjaxResult getInfo(@PathVariable("id") Long id)
  85. {
  86. return success(tProgressService.selectTProgressById(id));
  87. }
  88. /**
  89. * 新增进度
  90. */
  91. @PreAuthorize("@ss.hasPermi('rc:progress:add')")
  92. @Log(title = "进度", businessType = BusinessType.INSERT)
  93. @PostMapping
  94. public AjaxResult add(@RequestBody TProgress tProgress)
  95. {
  96. tProgress.setDeptId(getLoginUser().getDeptId().toString());
  97. return toAjax(tProgressService.insertTProgress(tProgress));
  98. }
  99. /**
  100. * 修改进度
  101. */
  102. @PreAuthorize("@ss.hasPermi('rc:progress:edit')")
  103. @Log(title = "进度", businessType = BusinessType.UPDATE)
  104. @PutMapping
  105. public AjaxResult edit(@RequestBody TProgress tProgress)
  106. {
  107. return toAjax(tProgressService.updateTProgress(tProgress));
  108. }
  109. /**
  110. * 删除进度
  111. */
  112. @PreAuthorize("@ss.hasPermi('rc:progress:remove')")
  113. @Log(title = "进度", businessType = BusinessType.DELETE)
  114. @DeleteMapping("/{ids}")
  115. public AjaxResult remove(@PathVariable Long[] ids)
  116. {
  117. return toAjax(tProgressService.deleteTProgressByIds(ids));
  118. }
  119. }