TDeptInfoController.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.rc.domain.TChap;
  6. import com.ruoyi.system.service.ISysDeptService;
  7. import org.springframework.security.access.prepost.PreAuthorize;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.PutMapping;
  12. import org.springframework.web.bind.annotation.DeleteMapping;
  13. import org.springframework.web.bind.annotation.PathVariable;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import com.ruoyi.common.annotation.Log;
  18. import com.ruoyi.common.core.controller.BaseController;
  19. import com.ruoyi.common.core.domain.AjaxResult;
  20. import com.ruoyi.common.enums.BusinessType;
  21. import com.ruoyi.rc.domain.TDeptInfo;
  22. import com.ruoyi.rc.service.ITDeptInfoService;
  23. import com.ruoyi.common.utils.poi.ExcelUtil;
  24. import com.ruoyi.common.core.page.TableDataInfo;
  25. import com.ruoyi.common.utils.StringUtils;
  26. /**
  27. * 装置信息Controller
  28. *
  29. * @author ruoyi
  30. * @date 2024-07-19
  31. */
  32. @RestController
  33. @RequestMapping("/rc/deptinfo")
  34. public class TDeptInfoController extends BaseController
  35. {
  36. @Autowired
  37. private ITDeptInfoService tDeptInfoService;
  38. @Autowired
  39. private ISysDeptService deptService;
  40. /**
  41. * 查询装置信息列表
  42. */
  43. @PreAuthorize("@ss.hasPermi('rc:deptinfo:list')")
  44. @GetMapping("/list")
  45. public TableDataInfo list(TDeptInfo tDeptInfo)
  46. {
  47. startPage();
  48. List<TDeptInfo> list = tDeptInfoService.selectTDeptInfoList(tDeptInfo);
  49. for (TDeptInfo 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:deptinfo:export')")
  71. @Log(title = "装置信息", businessType = BusinessType.EXPORT)
  72. @PostMapping("/export")
  73. public void export(HttpServletResponse response, TDeptInfo tDeptInfo)
  74. {
  75. List<TDeptInfo> list = tDeptInfoService.selectTDeptInfoList(tDeptInfo);
  76. ExcelUtil<TDeptInfo> util = new ExcelUtil<TDeptInfo>(TDeptInfo.class);
  77. util.exportExcel(response, list, "装置信息数据");
  78. }
  79. /**
  80. * 获取装置信息详细信息
  81. */
  82. @PreAuthorize("@ss.hasPermi('rc:deptinfo:query')")
  83. @GetMapping(value = "/{id}")
  84. public AjaxResult getInfo(@PathVariable("id") Long id)
  85. {
  86. return success(tDeptInfoService.selectTDeptInfoById(id));
  87. }
  88. /**
  89. * 新增装置信息
  90. */
  91. @PreAuthorize("@ss.hasPermi('rc:deptinfo:add')")
  92. @Log(title = "装置信息", businessType = BusinessType.INSERT)
  93. @PostMapping
  94. public AjaxResult add(@RequestBody TDeptInfo tDeptInfo)
  95. {
  96. if (StringUtils.isNull(tDeptInfo.getDeptId()) || "".equals(tDeptInfo.getDeptId())) {
  97. tDeptInfo.setDeptId(getLoginUser().getDeptId().toString());
  98. }
  99. return toAjax(tDeptInfoService.insertTDeptInfo(tDeptInfo));
  100. }
  101. /**
  102. * 修改装置信息
  103. */
  104. @PreAuthorize("@ss.hasPermi('rc:deptinfo:edit')")
  105. @Log(title = "装置信息", businessType = BusinessType.UPDATE)
  106. @PutMapping
  107. public AjaxResult edit(@RequestBody TDeptInfo tDeptInfo)
  108. {
  109. return toAjax(tDeptInfoService.updateTDeptInfo(tDeptInfo));
  110. }
  111. /**
  112. * 删除装置信息
  113. */
  114. @PreAuthorize("@ss.hasPermi('rc:deptinfo:remove')")
  115. @Log(title = "装置信息", businessType = BusinessType.DELETE)
  116. @DeleteMapping("/{ids}")
  117. public AjaxResult remove(@PathVariable Long[] ids)
  118. {
  119. return toAjax(tDeptInfoService.deleteTDeptInfoByIds(ids));
  120. }
  121. }