¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.flowable.controller; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.parser.Feature; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.flowable.bpmn.model.BpmnModel; |
| | | import org.flowable.engine.HistoryService; |
| | | import org.flowable.engine.ProcessEngine; |
| | | import org.flowable.engine.ProcessEngineConfiguration; |
| | | import org.flowable.engine.RepositoryService; |
| | | import org.flowable.engine.history.HistoricActivityInstance; |
| | | import org.flowable.image.ProcessDiagramGenerator; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.TranslateDictTextUtils; |
| | | import org.jeecg.modules.flowable.apithird.business.dto.FlowMyBusinessDto; |
| | | import org.jeecg.modules.flowable.apithird.business.service.impl.FlowMyBusinessServiceImpl; |
| | | import org.jeecg.modules.flowable.domain.dto.FlowTaskDto; |
| | | import org.jeecg.modules.flowable.domain.vo.FlowHistoricalVo; |
| | | import org.jeecg.modules.flowable.domain.vo.FlowMy; |
| | | import org.jeecg.modules.flowable.domain.vo.WorkTaskDataVo; |
| | | import org.jeecg.modules.flowable.service.IFlowTaskService; |
| | | import org.jeecg.modules.flowable.service.IHisWorkTaskService; |
| | | import org.jeecg.modules.flowable.service.IWorkTaskServiceVo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | @Api(tags = "工使µéç¨ä¸å¡æ¥å£") |
| | | @RestController |
| | | @RequestMapping("assign/flow") |
| | | @Slf4j |
| | | public class AssignStreamFlowController { |
| | | @Autowired |
| | | FlowMyBusinessServiceImpl flowMyBusinessService; |
| | | @Autowired |
| | | IFlowTaskService flowTaskService; |
| | | @Autowired |
| | | IWorkTaskServiceVo workTaskServicevo; |
| | | @Autowired |
| | | IHisWorkTaskService hisWorkTaskService; |
| | | @Autowired |
| | | private RepositoryService repositoryService; |
| | | @Autowired |
| | | private HistoryService historyService; |
| | | @Autowired |
| | | private ProcessEngine processEngine; |
| | | @Autowired |
| | | private ObjectMapper objectMapper; |
| | | @Autowired |
| | | private TranslateDictTextUtils translateDictTextUtils; |
| | | |
| | | @ApiOperation(value = "è·åæ»å°è´¦", response = FlowTaskDto.class) |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<FlowMyBusinessDto>> queryPageList(FlowMyBusinessDto flowMyBusinessDto, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | Page page = new Page(pageNo, pageSize); |
| | | IPage<FlowMyBusinessDto> pageList = flowMyBusinessService.getPageList(page, flowMyBusinessDto); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | @ApiOperation(value = "éè¿ä¼ å
¥TaskIds夿æ¯å¦å¨åä¸èç¹") |
| | | @GetMapping(value = "/isSameNode") |
| | | public Result isSameNode(@RequestParam(name = "taskIds") String taskIds) { |
| | | return flowTaskService.isSameNode(taskIds); |
| | | } |
| | | |
| | | @ApiOperation(value = "è·åå¾
åå表", response = FlowTaskDto.class) |
| | | @GetMapping(value = "/todoList") |
| | | public Result todoList(@ApiParam(value = "å½å页ç ", required = true) @RequestParam (name="pageNum", defaultValue="1") Integer pageNum, |
| | | @ApiParam(value = "æ¯é¡µæ¡æ°", required = true) @RequestParam (name="pageSize", defaultValue="10") Integer pageSize) { |
| | | return flowTaskService.todoList(pageNum, pageSize); |
| | | } |
| | | @ApiOperation(value = "è·åæ¬èº«å¾
å", response = FlowTaskDto.class) |
| | | @GetMapping(value = "/toTaskBySelf") |
| | | public Result<IPage<WorkTaskDataVo>> toTaskBySelf(FlowMy flowMy, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | Page page = new Page(pageNo, pageSize); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | flowMy.setUsername(user.getUsername()); |
| | | return Result.OK(workTaskServicevo.toTaskBySelf(flowMy,page)); |
| | | } |
| | | |
| | | @ApiOperation(value = "è·åå·²åä»»å¡", response = FlowTaskDto.class) |
| | | @GetMapping(value = "/finishedList") |
| | | public Result<?> finishedList(@ApiParam(value = "å½å页ç ", required = true) @RequestParam Integer pageNo, |
| | | @ApiParam(value = "æ¯é¡µæ¡æ°", required = true) @RequestParam Integer pageSize, |
| | | FlowMyBusinessDto flowMyBusinessDto) { |
| | | return flowTaskService.finishedList(pageNo, pageSize,flowMyBusinessDto); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "è·å工使µåå²ä»»å¡", response = FlowTaskDto.class) |
| | | @GetMapping(value = "/queryHisTaskList") |
| | | public Result<?> queryHisTaskList(@RequestParam(name = "procInstId") String procInstId) { |
| | | List<FlowHistoricalVo> flowHistoricalVos = hisWorkTaskService.queryHisTaskByProcInstId(procInstId); |
| | | if(CollectionUtil.isEmpty(flowHistoricalVos)) { |
| | | return Result.OK(Collections.emptyList()); |
| | | } |
| | | List<JSONObject> items = new ArrayList<>(); |
| | | try { |
| | | for(FlowHistoricalVo vo : flowHistoricalVos) { |
| | | String json = objectMapper.writeValueAsString(vo); |
| | | JSONObject item = JSONObject.parseObject(json, Feature.OrderedField); |
| | | translateDictTextUtils.translateField("assignee", vo.getAssignee(), item, "sys_user,realname,username"); |
| | | items.add(item); |
| | | } |
| | | return Result.OK(items); |
| | | }catch (Exception e) { |
| | | return Result.error("æ°æ®è½¬è¯å¤±è´¥ï¼"); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "审æ¹ä»»å¡-æ¥çæµç¨å¾") |
| | | @GetMapping("/diagramView") |
| | | public void showImages(@RequestParam(name = "processDefinitionId") String processDefinitionId, |
| | | @RequestParam(name = "processInstanceId") String processInstanceId, |
| | | @RequestParam(name = "TaskDefinitionKey") String TaskDefinitionKey, |
| | | HttpServletResponse response) throws IOException { |
| | | BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); |
| | | List<HistoricActivityInstance> historyProcess = historyService.createHistoricActivityInstanceQuery() |
| | | .processInstanceId(processInstanceId) |
| | | .finished() |
| | | .list(); |
| | | |
| | | List<String> activityIds = new ArrayList<>(); |
| | | List<String> flows = new ArrayList<>(); |
| | | |
| | | for (HistoricActivityInstance hi : historyProcess) { |
| | | String activityType = hi.getActivityType(); |
| | | if (activityType.equals("sequenceFlow") || activityType.equals("exclusiveGateway")) { |
| | | flows.add(hi.getActivityId()); |
| | | } else if (activityType.equals("userTask") || activityType.equals("startEvent")) { |
| | | activityIds.add(hi.getActivityId()); |
| | | } |
| | | } |
| | | activityIds.add(TaskDefinitionKey); |
| | | ProcessEngineConfiguration engConf = processEngine.getProcessEngineConfiguration(); |
| | | ProcessDiagramGenerator processDiagramGenerator = engConf.getProcessDiagramGenerator(); |
| | | |
| | | InputStream in = processDiagramGenerator.generateDiagram(bpmnModel, "png", activityIds, flows, |
| | | engConf.getActivityFontName(), engConf.getLabelFontName(), engConf.getAnnotationFontName(), |
| | | engConf.getClassLoader(), 1.0, true); |
| | | |
| | | OutputStream out = response.getOutputStream(); |
| | | byte[] buf = new byte[1024]; |
| | | int length = 0; |
| | | while ((length = in.read(buf)) != -1) { |
| | | out.write(buf, 0, length); |
| | | } |
| | | in.close(); |
| | | out.close(); |
| | | } |
| | | } |