package cn.com.goldenwater.dcproj.controller.mend.bpm; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import com.github.pagehelper.PageInfo; import com.workflow.bpm.api.bpmservices.BpmProcessInstService; import com.workflow.bpm.api.bpmservices.co.processinstance.ProcInstIdCO; import com.workflow.bpm.api.bpmservices.co.processinstance.ProcessHandleCO; import com.workflow.bpm.api.bpmservices.dto.ReqPostProcessHandleDTO; import com.workflow.bpm.api.bpmservices.dto.ResGetProcessDiagramDTO; import com.workflow.bpm.api.bpmservices.dto.ResGetProcessHandleDTO; import com.workflow.common.exception.BusinessException; import com.workflow.common.exception.impl.CommonErrorCode; import com.workflow.common.struct.head.Page; import com.workflow.common.struct.req.impl.APIRequestPage; import com.workflow.common.struct.res.Result; import com.workflow.common.struct.res.impl.APIResult; import com.workflow.common.struct.res.impl.APIResultPage; import com.workflow.common.util.convert.ConvertBeanUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; import java.util.List; import java.util.Objects; /** * @program parent * @Description * @Author admin * @Date 2019/7/10 **/ @Api(tags = "流程实例") @RestController @RequestMapping("/bis/insp/pblm/plist/") public class ProcessInstController extends BaseController { @Autowired private BpmProcessInstService bpmProcessInstService; //@RequiresPermissions("base.bpm.operation") @ApiOperation(value = "挂起流程") @GetMapping("/v1/workflow/suspendProcInst/{procInstId}") public Result post_suspendProcInst(@PathVariable String procInstId) { if (StringUtils.isEmpty(procInstId)) { throw new BusinessException(CommonErrorCode.ParamIsNull); } ProcInstIdCO procInstIdCO = new ProcInstIdCO(); procInstIdCO.setProcInstId(procInstId); return bpmProcessInstService.suspendProcInst(procInstIdCO); } //@RequiresPermissions("base.bpm.operation") @ApiOperation(value = "重启挂起的流程") @GetMapping("/v1/workflow/resumeProcInst/{procInstId}") public Result post_resumeProcInst(@PathVariable String procInstId) { if (StringUtils.isEmpty(procInstId)) { throw new BusinessException(CommonErrorCode.ParamIsNull); } ProcInstIdCO procInstIdCO = new ProcInstIdCO(); procInstIdCO.setProcInstId(procInstId); return bpmProcessInstService.resumeProcInst(procInstIdCO); } //@RequiresPermissions("base.bpm.operation") @ApiOperation(value = "撤销流程") @GetMapping("/v1/workflow/cancelProcInst/{procInstId}") public Result post_cancelProcInst(@PathVariable String procInstId) { if (StringUtils.isEmpty(procInstId)) { throw new BusinessException(CommonErrorCode.ParamIsNull); } ProcInstIdCO procInstIdCO = new ProcInstIdCO(); procInstIdCO.setProcInstId(procInstId); return bpmProcessInstService.cancelProcInst(procInstIdCO); } //@RequiresPermissions("base.bpm.operation") @ApiOperation(value = "查询流程图") @GetMapping("/v1/workflow/qryProcessDiagram/{procInstId}") public BaseResponse post_qryProcessDiagram(@PathVariable String procInstId) { ProcInstIdCO procInstIdCO = new ProcInstIdCO(); procInstIdCO.setProcInstId(procInstId); APIResult apiResult = bpmProcessInstService.qryProcessDiagram(procInstIdCO); ResGetProcessDiagramDTO resGetProcessDiagramDTO = new ResGetProcessDiagramDTO(); resGetProcessDiagramDTO.setBase64ImageStr(apiResult.getContent()); return buildSuccessResponse(resGetProcessDiagramDTO); } //@RequiresPermissions("base.bpm.operation") @ApiOperation(value = "查询经手流程") @RequestMapping(value = "/v1/workflow/qryHandleProcess", method = RequestMethod.GET) public BaseResponse> post_qryHandleProcess(ReqPostProcessHandleDTO reqPostProcessHandleDTO) { if (Objects.isNull(reqPostProcessHandleDTO)) { throw new BusinessException(CommonErrorCode.ParamIsNull); } ProcessHandleCO processHandleCO = new ProcessHandleCO(); Page page = new Page(); ConvertBeanUtils.copyPropertiesBySource(reqPostProcessHandleDTO, processHandleCO); ConvertBeanUtils.copyPropertiesBySource(reqPostProcessHandleDTO, page); APIRequestPage requestPage = new APIRequestPage<>(); requestPage.setContent(processHandleCO); if ("jc".equals(reqPostProcessHandleDTO.getQueryType())) { processHandleCO.setProcInstName("稽察整改-"); } if (0 != reqPostProcessHandleDTO.getPageNum()) { page.setPageNo(reqPostProcessHandleDTO.getPageNum()); } requestPage.setPage(page); PageInfo newPage = null; try { APIResultPage> listAPIResultPage = bpmProcessInstService.qryHandleProcess(requestPage, getCurrentPersId(), getCurrentOrgId()); listAPIResultPage.setPageClass(ResGetProcessHandleDTO.class); newPage = new PageInfo(); newPage.setList(listAPIResultPage.getContent()); newPage.setPageNum(listAPIResultPage.getPage().getPageNo()); newPage.setPageSize(listAPIResultPage.getPage().getPageSize()); newPage.setTotal(listAPIResultPage.getPage().getTotal()); return buildSuccessResponse(newPage); } catch (Exception e) { e.printStackTrace(); } newPage = new PageInfo<>(); newPage.setPageSize(10); newPage.setTotal(0); newPage.setPageNum(1); newPage.setList(new ArrayList<>()); return buildSuccessResponse(newPage); } }