package com.ruoyi.web.controller.rc; import java.util.List; import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.rc.domain.TOpenItem; import com.ruoyi.system.service.ISysDeptService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.rc.domain.TProgress; import com.ruoyi.rc.service.ITProgressService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; /** * 进度Controller * * @author ruoyi * @date 2024-07-19 */ @RestController @RequestMapping("/rc/progress") public class TProgressController extends BaseController { @Autowired private ITProgressService tProgressService; @Autowired private ISysDeptService deptService; /** * 查询进度列表 */ @PreAuthorize("@ss.hasPermi('rc:progress:list')") @GetMapping("/list") public TableDataInfo list(TProgress tProgress) { startPage(); List list = tProgressService.selectTProgressList(tProgress); for (TProgress obj : list) { String deptId = obj.getDeptId(); if (StringUtils.isNotEmpty(deptId)) { if (deptId.indexOf(",") != -1) { StringBuffer sb = new StringBuffer(); String[] ids = deptId.split(","); for (String id : ids) { SysDept sysDept = deptService.selectDeptById(Long.parseLong(id)); sb.append(sysDept.getDeptName()).append(" / "); } obj.setDeptName(sb.toString().substring(0, sb.length() - 3)); } else { obj.setDeptName(deptService.selectDeptById(Long.parseLong(deptId)).getDeptName()); } } } return getDataTable(list); } /** * 导出进度列表 */ @PreAuthorize("@ss.hasPermi('rc:progress:export')") @Log(title = "进度", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, TProgress tProgress) { List list = tProgressService.selectTProgressList(tProgress); ExcelUtil util = new ExcelUtil(TProgress.class); util.exportExcel(response, list, "进度数据"); } /** * 获取进度详细信息 */ @PreAuthorize("@ss.hasPermi('rc:progress:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return success(tProgressService.selectTProgressById(id)); } /** * 新增进度 */ @PreAuthorize("@ss.hasPermi('rc:progress:add')") @Log(title = "进度", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody TProgress tProgress) { tProgress.setDeptId(getLoginUser().getDeptId().toString()); return toAjax(tProgressService.insertTProgress(tProgress)); } /** * 修改进度 */ @PreAuthorize("@ss.hasPermi('rc:progress:edit')") @Log(title = "进度", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody TProgress tProgress) { return toAjax(tProgressService.updateTProgress(tProgress)); } /** * 删除进度 */ @PreAuthorize("@ss.hasPermi('rc:progress:remove')") @Log(title = "进度", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(tProgressService.deleteTProgressByIds(ids)); } }