package com.zc.business.controller; import java.io.IOException; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.exception.file.InvalidExtensionException; import com.ruoyi.common.utils.file.FileUploadUtils; import com.ruoyi.common.utils.file.MimeTypeUtils; import com.zc.business.domain.DcEvent; import com.zc.business.service.IDcEventService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; 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.zc.business.domain.DcEventProcess; import com.zc.business.service.IDcEventProcessService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; /** * 事件处理流程Controller * * @author ruoyi * @date 2024-01-03 */ @Api(tags = "事件处置流程") @RestController @RequestMapping("/system/process") public class DcEventProcessController extends BaseController { @Autowired private IDcEventProcessService dcEventProcessService; @Autowired private IDcEventService dcEventService; /** * 查询事件处理流程列表 */ @ApiOperation("查询事件处理流程列表") @GetMapping("/list") public List list(DcEventProcess dcEventProcess) { return dcEventProcessService.selectDcEventProcessList(dcEventProcess); } /** * 分页查询事件处理流程列表 */ @ApiOperation("分页查询事件处理流程列表") @GetMapping("/page") public TableDataInfo page(DcEventProcess dcEventProcess) { startPage(); List list = dcEventProcessService.selectDcEventProcessList(dcEventProcess); return getDataTable(list); } /** * 导出事件处理流程列表 */ @ApiOperation("导出事件处理流程列表") // @PreAuthorize("@ss.hasPermi('system:process:export')") @Log(title = "事件处理流程", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, DcEventProcess dcEventProcess) { List list = dcEventProcessService.selectDcEventProcessList(dcEventProcess); ExcelUtil util = new ExcelUtil<>(DcEventProcess.class); util.exportExcel(response, list, "事件处理流程数据"); } /** * 获取事件处理流程详细信息 */ @ApiOperation("获取事件处理流程详细信息") // @PreAuthorize("@ss.hasPermi('system:process:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return AjaxResult.success(dcEventProcessService.selectDcEventProcessById(id)); } /** * 新增事件处理流程 */ @ApiOperation("新增事件处理流程") // @PreAuthorize("@ss.hasPermi('system:process:add')") @Log(title = "事件处理流程", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody @Valid DcEventProcess dcEventProcess){ DcEvent dcEvent = dcEventService.selectDcEventById(dcEventProcess.getEventId()); if (dcEvent == null){ return AjaxResult.error("事件信息有误!"); } if (dcEvent.getEventState() == 2){ return AjaxResult.error("事件已结束,无法进行操作!"); } if (dcEventProcess.getProcessType() != null && dcEventProcess.getProcessType() == 1){ int status = dcEventProcessService.selectPreviousNodeStatus(dcEventProcess.getEventId(),dcEventProcess.getProcessId()); if (status < 1){ return AjaxResult.error("前置节点未点亮!"); } } return toAjax(dcEventProcessService.insertDcEventProcess(dcEventProcess)); } /** * 修改事件处理流程 */ @ApiOperation("修改事件处理流程") // @PreAuthorize("@ss.hasPermi('system:process:edit')") @Log(title = "事件处理流程", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody DcEventProcess dcEventProcess) { return toAjax(dcEventProcessService.updateDcEventProcess(dcEventProcess)); } /** * 删除事件处理流程 */ @ApiOperation("删除事件处理流程") // @PreAuthorize("@ss.hasPermi('system:process:remove')") @Log(title = "事件处理流程", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(dcEventProcessService.deleteDcEventProcessByIds(ids)); } /** * 根据事件id查询处理流程 */ @GetMapping("/eventProcessById/{id}") @ApiOperation("根据事件id查询处理流程") public TableDataInfo eventProcessById(@PathVariable String id){ return getDataTable(dcEventProcessService.selectDcEventProcessListById(id)); } }