整合在線工做流html
https://blog.csdn.net/zhengyidi1357/article/details/80858865spring
關閉工做流模型建立編輯器,報錯與關閉工做流編輯器json
https://blog.csdn.net/u010924288/article/details/51933140canvas
@RequestMapping("/service") @RestController @Slf4j public class ModelEditorJsonRestResource implements ModelDataJsonConstants { @Autowired private RepositoryService repositoryService; @Autowired private ObjectMapper objectMapper; @RequestMapping(value="/model/{modelId}/json", method = RequestMethod.GET, produces = "application/json") public ObjectNode getEditorJson(@PathVariable String modelId) { ObjectNode modelNode = null; Model model = repositoryService.getModel(modelId); if (model != null) { try { if (StringUtils.isNotEmpty(model.getMetaInfo())) { modelNode = (ObjectNode) objectMapper.readTree(model.getMetaInfo()); } else { modelNode = objectMapper.createObjectNode(); modelNode.put(MODEL_NAME, model.getName()); } modelNode.put(MODEL_ID, model.getId()); ObjectNode editorJsonNode = (ObjectNode) objectMapper.readTree( new String(repositoryService.getModelEditorSource(model.getId()), "utf-8")); modelNode.set("model", editorJsonNode); } catch (Exception e) { log.error("Error creating model JSON", e); throw new ActivitiException("Error creating model JSON", e); } } //modify 將BitunHttpMessageConverter配置一條過濾信息,不用fastjson解析ObjectNode對象 return modelNode; } }
@RequestMapping("/service") @RestController public class ModelSaveRestResource implements ModelDataJsonConstants { protected static final Logger LOGGER = LoggerFactory.getLogger(ModelSaveRestResource.class); @Autowired private RepositoryService repositoryService; @Autowired private ObjectMapper objectMapper; @RequestMapping(value="/model/{modelId}/save", method = RequestMethod.PUT) @ResponseStatus(value = HttpStatus.OK) public void saveModel(@PathVariable String modelId, @RequestParam("name") String name, @RequestParam("json_xml") String json_xml, @RequestParam("svg_xml") String svg_xml, @RequestParam("description") String description) { try { Model model = repositoryService.getModel(modelId); ObjectNode modelJson = (ObjectNode) objectMapper.readTree(model.getMetaInfo()); modelJson.put(MODEL_NAME, name); modelJson.put(MODEL_DESCRIPTION, description); model.setMetaInfo(modelJson.toString()); model.setName(name); repositoryService.saveModel(model); repositoryService.addModelEditorSource(model.getId(), json_xml.getBytes("utf-8")); InputStream svgStream = new ByteArrayInputStream(svg_xml.getBytes("utf-8")); TranscoderInput input = new TranscoderInput(svgStream); PNGTranscoder transcoder = new PNGTranscoder(); // Setup output ByteArrayOutputStream outStream = new ByteArrayOutputStream(); TranscoderOutput output = new TranscoderOutput(outStream); // Do the transformation transcoder.transcode(input, output); final byte[] result = outStream.toByteArray(); repositoryService.addModelEditorSourceExtra(model.getId(), result); outStream.close(); } catch (Exception e) { LOGGER.error("Error saving model", e); throw new ActivitiException("Error saving model", e); } } }
/** * @author Tijs Rademakers */ @RequestMapping("/service") @RestController public class StencilsetRestResource { @RequestMapping(value="/editor/stencilset", method = RequestMethod.GET, produces = "application/json;charset=utf-8") public JSONObject getStencilset() { InputStream stencilsetStream = this.getClass().getClassLoader().getResourceAsStream("assets-boss/stencilset.json"); try { //這裏必需要通過一次對象轉換,否則fastjson解析字符串會出問題 JSONObject jsonObject = JSON.parseObject(IOUtils.toString(stencilsetStream, "utf-8")); return jsonObject; } catch (Exception e) { throw new ActivitiException("Error while loading stencil set", e); } } }
/** * @author xiongwei * @date 2018/10/31 17:01 */ @Slf4j @Controller @RequestMapping("/activiti/model") public class ActivitiModelController extends BossBaseController{ @Autowired ProcessEngine processEngine; @Autowired ObjectMapper objectMapper; @Autowired ModelEditorJsonRestResource modelEditorJsonRestResource; @Autowired private WorkflowService workflowService; /** * 新建一個空模型 */ @RequestMapping("/create") public void newModel(HttpServletResponse response) throws IOException { RepositoryService repositoryService = processEngine.getRepositoryService(); //初始化一個空模型 Model model = repositoryService.newModel(); //設置一些默認信息 String name = "new-process"; String description = ""; int revision = 1; String key = "process"; ObjectNode modelNode = objectMapper.createObjectNode(); modelNode.put(ModelDataJsonConstants.MODEL_NAME, name); modelNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description); modelNode.put(ModelDataJsonConstants.MODEL_REVISION, revision); model.setName(name); model.setKey(key); model.setMetaInfo(modelNode.toString()); repositoryService.saveModel(model); String id = model.getId(); //完善ModelEditorSource ObjectNode editorNode = objectMapper.createObjectNode(); editorNode.put("id", "canvas"); editorNode.put("resourceId", "canvas"); ObjectNode stencilSetNode = objectMapper.createObjectNode(); stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#"); editorNode.set("stencilset", stencilSetNode); repositoryService.addModelEditorSource(id,editorNode.toString().getBytes("utf-8")); response.sendRedirect("/assets-boss/modeler.html?modelId="+id); } /** * 獲取全部模型 */ @RequestMapping("/list") public String modelList(HttpServletRequest request, org.springframework.ui.Model model, BossPageVO bossPageVO){ commonModel(request,model); RepositoryService repositoryService = processEngine.getRepositoryService(); ModelQuery modelQuery = repositoryService.createModelQuery(); long count = modelQuery.count(); List<Model> models = modelQuery.orderByCreateTime().desc().listPage((bossPageVO.getPage() - 1) * bossPageVO.getLimit(),bossPageVO.getLimit()); BossResultPageVO result = new BossResultPageVO(); result.setPage(bossPageVO.getPage()); result.setLimit(bossPageVO.getLimit()); result.setCount(count); result.setData(models); model.addAttribute("list",result); return "activiti/model/list"; } /** * 發佈模型爲流程定義 */ @RequestMapping("/deploy") public Object deploy(HttpServletRequest request, org.springframework.ui.Model sModel, String modelId) throws Exception { commonModel(request,sModel); //獲取模型 RepositoryService repositoryService = processEngine.getRepositoryService(); Model modelData = repositoryService.getModel(modelId); byte[] bytes = repositoryService.getModelEditorSource(modelData.getId()); if (bytes == null) { return "模型數據爲空,請先設計流程併成功保存,再進行發佈。"; } JsonNode modelNode = new ObjectMapper().readTree(bytes); BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode); if(model.getProcesses().size()==0){ return "數據模型不符要求,請至少設計一條主線流程。"; } byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model); //發佈流程 String processName = modelData.getName() + ".bpmn20.xml"; Deployment deployment = repositoryService.createDeployment() .name(modelData.getName()) .addString(processName, new String(bpmnBytes, "UTF-8")) .deploy(); modelData.setDeploymentId(deployment.getId()); repositoryService.saveModel(modelData); sModel.addAttribute(SUCCESS,modelData.getName() + "部署成功"); return "activiti/model/list"; } /** * * @return */ @RequestMapping("/queryUnfinishedTask") public String queryUnfinishedTask(HttpServletRequest request,org.springframework.ui.Model model, QueryTaskVO queryTaskVO){ commonModel(request,model); BossResultPageVO<Task> list = workflowService.queryUnfinishedTasks(queryTaskVO); model.addAttribute("list",list); return "activiti/model/unFinishedTaskList"; } /** * 提交任務 */ @RequestMapping("/complete") public String complete(HttpServletRequest request,org.springframework.ui.Model model,ActivitiCompleteTaskBO activitiCompleteTaskBO) { commonModel(request,model); log.info("complete task the param={}", activitiCompleteTaskBO); workflowService.completeTask(activitiCompleteTaskBO); return "redirect:/activiti/model/queryUnfinishedTask"; } /** * 查詢流程圖 (中文亂碼狀況) * @param request * @param response * @param model * @param processDefinitionId * @return * @throws IOException */ @RequestMapping("/showView") public String showView(HttpServletRequest request,HttpServletResponse response,org.springframework.ui.Model model,String processDefinitionId) throws IOException { commonModel(request,model); RepositoryService repositoryService = processEngine.getRepositoryService(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionId(processDefinitionId) .singleResult(); InputStream inputStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getDiagramResourceName()); OutputStream out = response.getOutputStream(); for(int b = -1;(b=inputStream.read())!=-1;){ out.write(b); } out.close(); inputStream.close(); return null; } /** * 查詢高亮流程圖 * @param request * @param response * @param model * @param processInstanceId * @return */ @RequestMapping("/showActiveView") public String showActiveView(HttpServletRequest request,HttpServletResponse response,org.springframework.ui.Model model,String processInstanceId) throws IOException { commonModel(request,model); ProcessInstance pi = this.processEngine.getRuntimeService().createProcessInstanceQuery() .processInstanceId(processInstanceId).singleResult(); BpmnModel bpmnModel = this.processEngine.getRepositoryService().getBpmnModel(pi.getProcessDefinitionId()); List<String> activeIds = this.processEngine.getRuntimeService().getActiveActivityIds(pi.getId()); ProcessDiagramGenerator p = new DefaultProcessDiagramGenerator(); InputStream is = p.generateDiagram(bpmnModel,"png",activeIds, Collections.<String>emptyList(),"宋體","宋體","宋體",null,1.0); OutputStream os = response.getOutputStream(); byte[] buffer = new byte[1024]; int len = 0; while ((len = is.read(buffer)) != -1) { os.write(buffer, 0, len); } os.close(); is.close(); return null; } /** * 查詢全部已完成節點 * @param processInstanceId * @param response * @return * @throws Exception */ @RequestMapping("/showAllFinishView") public String showAllFinishView(String processInstanceId,HttpServletResponse response) throws IOException { ProcessInstance processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); if(processInstance == null){ throw new RuntimeException("獲取流程圖異常"); }else{ BpmnModel bpmnModel = processEngine.getRepositoryService().getBpmnModel(processInstance.getProcessDefinitionId()); List<HistoricActivityInstance> activityInstances = processEngine.getHistoryService().createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).orderByHistoricActivityInstanceStartTime().asc().list(); List<String> activityIds = new ArrayList<String>(); ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity)((RepositoryServiceImpl)processEngine.getRepositoryService()).getDeployedProcessDefinition(processInstance.getProcessDefinitionId()); //獲取流程走過的線 List<String> flowIds = getHighLightedFlows(processDefinition,activityInstances); for(HistoricActivityInstance hai:activityInstances){ //獲取流程走過的節點 activityIds.add(hai.getActivityId()); } InputStream inputStream = new DefaultProcessDiagramGenerator().generateDiagram(bpmnModel, "png", activityIds, flowIds,"宋體","宋體","宋體",null,1.0); OutputStream out = response.getOutputStream(); for(int b = -1;(b=inputStream.read())!=-1;){ out.write(b); } out.close(); inputStream.close(); } return null; } /** * 跳轉查看流程圖頁面 * @param model * @param processInstanceId * @return */ @RequestMapping("/redirectShowView") public String redirectShowView(org.springframework.ui.Model model,String processInstanceId){ model.addAttribute("processInstanceId",processInstanceId); return "activiti/model/currentView"; } /** * 查詢用戶已辦任務(整個流程實例已經結束) * @param request * @param model * @param queryTaskVO * @return */ @RequestMapping("/queryFinishedTask") public String queryFinishedTask(HttpServletRequest request,org.springframework.ui.Model model, QueryTaskVO queryTaskVO){ commonModel(request,model); BossResultPageVO<HistoricTaskInstance> list = workflowService.queryCompletedTask(queryTaskVO); model.addAttribute("list",list); return "activiti/model/finishedTaskList"; } /** * 查詢任務備註 * @param taskId * @return */ @ResponseBody @RequestMapping("/queryTaskComment") public List<Comment> queryTaskComment(String taskId){ return workflowService.queryTaskComment(taskId); } /** * 獲取流程走過的線 * @author xiongwei * @date 2018/10/31 16:48 */ private List<String> getHighLightedFlows(ProcessDefinitionEntity processDefinitionEntity,List<HistoricActivityInstance> haiList){ //用來保存高亮的線 flowId List<String> highFlows = new ArrayList<String>(); for (int i = 0; i < haiList.size() - 1; i++) { //對歷史流程節點進行遍歷 //獲得節點定義的詳細信息 ActivityImpl activityImpl = processDefinitionEntity.findActivity(haiList.get(i).getActivityId()); //用以保存後須要開始時間相同的節點 List<ActivityImpl> sameStartTimeNodes = new ArrayList<ActivityImpl>(); ActivityImpl sameActivityImpl1 = processDefinitionEntity.findActivity(haiList.get(i + 1).getActivityId()); //講後面第一個節點放在時間相同節點的集合裏 sameStartTimeNodes.add(sameActivityImpl1); for (int j = i + 1; j < haiList.size() - 1; j++) { //後續第一個節點 HistoricActivityInstance activityImpl1 = haiList.get(j); //後續第二個節點 HistoricActivityInstance activityImpl2 = haiList.get(j + 1); if(activityImpl1.getStartTime().equals(activityImpl2.getStartTime())){ //若是第一個節點和第二個節點開始時間相同保存 ActivityImpl sameActivityImpl2 = processDefinitionEntity.findActivity(activityImpl2.getActivityId()); sameStartTimeNodes.add(sameActivityImpl2); }else{ //不一樣就調查循環 break; } } //取出節點的全部出去的線 List<PvmTransition> pvmTransitions = activityImpl.getOutgoingTransitions(); for(PvmTransition pvmTransition : pvmTransitions){ //對全部的線進行遍歷 ActivityImpl pvmActivityImpl = (ActivityImpl) pvmTransition.getDestination(); //若是取出的線的目標節點存在時間相同的節點裏,保存該線的id,進行高亮顯示 if(sameStartTimeNodes.contains(pvmActivityImpl)){ highFlows.add(pvmTransition.getId()); } } } return highFlows; } }
/** * 工做流審覈結果全局監聽器 * @author xiongwei * @date 2018/10/31 17:02 */ @Slf4j public class AuditExecutionListener implements ExecutionListener { @Override public void notify(DelegateExecution delegateExecution) throws Exception { log.info("process event name={},the processBusinessKey={},processInstanceId={}" ,delegateExecution.getEventName(),delegateExecution.getProcessBusinessKey() ,delegateExecution.getProcessInstanceId()); //判斷是不是結束流程 if (delegateExecution.getEventName().equals(ExecutionListener.EVENTNAME_END)){ //獲取流程變量 int auditStatus = (int)delegateExecution.getVariable(ActivitiProcessVariableKey.AUDIT_STATUS.name()); //設置更新審覈記錄 AuditRecord auditRecord = new AuditRecord(); //判斷流程變量的值是否爲成功 auditRecord.setAuditStatus(auditStatus == AuditStatus.FAIL.getCode() ? AuditStatus.FAIL.getCode() : AuditStatus.SUCCESS.getCode()); auditRecord.setProcessInstanceId(delegateExecution.getProcessInstanceId()); auditRecord.setUpdateAt(new Date()); //獲取spring ioc容器 bean AuditRecordServiceImpl auditRecordService = SpringBeanUtil.getBean(AuditRecordServiceImpl.class); //執行更新,當監聽器執行失敗時,流程是會回滾的 auditRecordService.update(auditRecord); } } }
/** * @author xiongwei * @date 2018/11/1 10:39 */ @Slf4j @Service public class WorkflowServiceImpl implements WorkflowService { @Autowired ProcessEngine processEngine; @Autowired private TransactionTemplate transactionTemplate; @Autowired private AuditRecordService auditRecordService; /** * 開啓流程 * 入參:外部訂單號,開啓key */ @Override public ActivitiStartProcessRespBO startProcess(ActivitiStartProcessBO processBO){ ActivitiStartProcessRespBO respBO = new ActivitiStartProcessRespBO(); respBO.setActivitiProcessKey(processBO.getActivitiProcessKey()); respBO.setAuditStatus(AuditStatus.INIT.getCode()); //冪等校驗 AuditRecord auditRecord = auditRecordService.queryByOutOrderIdWithKey(processBO.getOutOrderId(),processBO.getActivitiProcessKey().name()); if (auditRecord != null){ respBO.setAuditStatus(auditRecord.getAuditStatus()); respBO.setProcessInstanceId(auditRecord.getProcessInstanceId()); return respBO; } //開啓事務 transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus transactionStatus) { //啓動流程 ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByKey(processBO.getActivitiProcessKey().name(),processBO.getOutOrderId().toString()); //流程實例Id String pId = processInstance.getProcessInstanceId(); //設置審覈記錄 AuditRecord record = setAuditRecord(processBO,pId); //往審覈記錄表插入一條處理數據 auditRecordService.create(record); respBO.setProcessInstanceId(pId); } }); //返回結果 return respBO; } /** * 查詢待辦任務 * @return */ @Override public BossResultPageVO<Task> queryUnfinishedTasks(QueryTaskVO param){ //獲取當前登陸用戶角色集合 Set<BossRoleVO> roles = BossAppContext.getCurrentUser().getRoles(); //獲取用戶全部角色ID List<String> roleIds = new ArrayList<>(roles.size()); //Long變成String roles.forEach(o ->{ roleIds.add(o.getId().toString()); }); //查詢全部類型審覈待辦任務 TaskQuery taskQuery = processEngine.getTaskService().createTaskQuery().taskCandidateGroupIn(roleIds); //判斷是否查詢特定待辦任務 if (param.getActivitProcessKey() != null){ //查詢特定審覈待辦任務 taskQuery.processDefinitionKey(param.getActivitProcessKey().name()); } //不爲空則查詢流程全部階段用戶任務 if (StringUtils.isNotBlank(param.getTaskKey())){ taskQuery.taskDefinitionKey(param.getTaskKey()); } //記錄條數 long count = taskQuery.count(); //查詢記錄 List<Task> tasks; if (count > 0){ tasks = taskQuery.orderByTaskCreateTime().desc().listPage(param.getStartPage(),param.getLimit()); }else { tasks = new ArrayList<>(); } //設置結果 BossResultPageVO<Task> result = new BossResultPageVO<Task>(); result.setPage(param.getPage() - 1); result.setLimit(param.getLimit()); result.setCount(count); result.setData(tasks); return result; } @Override public BossResultPageVO<AuditTaskVO> queryAuditTasks(QueryTaskVO param) { //獲取任務 BossResultPageVO<Task> data = queryUnfinishedTasks(param); //設置結果 BossResultPageVO<AuditTaskVO> result = new BossResultPageVO<AuditTaskVO>(); //結果複製 BeanUtils.copyProperties(data,result); List<AuditTaskVO> auditVOList = new ArrayList<>(); data.getData().forEach(o -> { //查詢審覈記錄 AuditRecord auditRecord = auditRecordService.queryByProcessInstanceIdWithBLOBs(o.getProcessInstanceId()); JSONObject jsonObject = JSONObject.parseObject(auditRecord.getAuditData()); AuditTaskVO vo = new AuditTaskVO(); vo.setTask(o); vo.setAuditData(jsonObject); auditVOList.add(vo); }); result.setData(auditVOList); return result; } /** * 查詢已完成任務 * @param queryTaskVO * @return */ @Override public BossResultPageVO<HistoricTaskInstance> queryCompletedTask(QueryTaskVO queryTaskVO){ log.info("query user completed task the param={}",queryTaskVO); //獲取用戶名 String username = BossAppContext.getCurrentUser().getUsername(); //僅僅查詢當前用戶辦過的任務 HistoricTaskInstanceQuery hisTaskInsQuery = processEngine.getHistoryService().createHistoricTaskInstanceQuery().taskAssignee(username); //不爲空則查詢特定流程任務 if (queryTaskVO.getActivitProcessKey() != null){ hisTaskInsQuery.processFinished().processDefinitionKey(queryTaskVO.getActivitProcessKey().name()); } //不爲空則查詢流程全部階段用戶任務 if (StringUtils.isNotBlank(queryTaskVO.getTaskKey())){ hisTaskInsQuery.taskDefinitionKey(queryTaskVO.getTaskKey()); } //統計記錄條數 long count = hisTaskInsQuery.count(); //查詢記錄 List<HistoricTaskInstance> tasks = hisTaskInsQuery.orderByTaskCreateTime().desc().listPage(queryTaskVO.getStartPage(),queryTaskVO.getLimit()); //設置返回對象 BossResultPageVO<HistoricTaskInstance> result = new BossResultPageVO<HistoricTaskInstance>(); result.setPage(queryTaskVO.getPage() - 1); result.setLimit(queryTaskVO.getLimit()); result.setCount(count); result.setData(tasks); log.info("query user completed task the param={}",queryTaskVO); return result; } /** * 完成任務 * @param activitiCompleteTaskBO */ @Override public void completeTask(ActivitiCompleteTaskBO activitiCompleteTaskBO){ log.info("user complete task the param={}",activitiCompleteTaskBO); String taskId = activitiCompleteTaskBO.getTaskId(); //設置流程變量 Map<String, Object> var = new HashMap(1); //設置審覈狀態 var.put(ActivitiProcessVariableKey.AUDIT_STATUS.name(),activitiCompleteTaskBO.getAuditStatus()); //獲取taskService TaskService taskService = processEngine.getTaskService(); //查詢任務判斷任務十分存在 Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); //判斷查詢結果 if (task == null){ throw new BossNotExistException("query task is not exist by taskId = " + taskId); } //判斷備註是否爲null if (activitiCompleteTaskBO.getRemark() == null){ activitiCompleteTaskBO.setRemark(activitiCompleteTaskBO.getAuditStatus().equals(AuditStatus.SUCCESS.getCode()) ? "贊成" : "不一樣意"); } //獲取當前系統登陸用戶 BossUserVO user = BossAppContext.getCurrentUser(); //開啓事務 transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus transactionStatus) { //簽收任務 taskService.claim(taskId, user.getUsername()); //設置當前用戶 Authentication.setAuthenticatedUserId(user.getUsername()); //設置備註 taskService.addComment(taskId,task.getProcessInstanceId(),activitiCompleteTaskBO.getRemark()); //完成任務 taskService.complete(taskId,var); } }); } @Override public List<Comment> queryTaskComment(String taskId) { return processEngine.getTaskService().getTaskComments(taskId); } @Override public ProcessInstance queryProcessInstanceById(String processInstance) { return processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstance).singleResult(); } /** * 保存用戶 * @param username 用戶名 */ @Override public void saveUser(String username){ log.info("save activiti user,the username = {}",username); IdentityService identityService=processEngine.getIdentityService(); User user = new UserEntity(username); identityService.saveUser(user); } /** * 刪除用戶 * @param username 用戶名 */ @Override public void delUser(String username){ IdentityService identityService=processEngine.getIdentityService(); identityService.deleteUser(username); } /** * 建立組 * @param roleNo */ @Override public void saveGroup(Long roleNo){ IdentityService identityService=processEngine.getIdentityService(); Group group = new GroupEntity(roleNo.toString()); identityService.saveGroup(group); } /** * 刪除組 * @param roleNo */ @Override public void delGroup(Long roleNo){ IdentityService identityService=processEngine.getIdentityService(); identityService.deleteGroup(roleNo.toString()); } /** * 建立用戶和組關聯 * @param username * @param roleNo */ @Override public void saveMembership(String username,Long roleNo){ log.info("create member ship,the userId={},groupId={}",username,roleNo); IdentityService identityService=processEngine.getIdentityService(); identityService.createMembership(username,roleNo.toString()); } /** * 刪除用戶和組關聯 * @param username * @param roleNo */ @Override public void delMembership(String username,Long roleNo){ IdentityService identityService=processEngine.getIdentityService(); identityService.deleteMembership(username,roleNo.toString()); } /** * 設置審覈記錄 * @param activitiStartProcessBO * @param pId * @return */ private AuditRecord setAuditRecord(ActivitiStartProcessBO activitiStartProcessBO,String pId){ AuditRecord record = new AuditRecord(); record.setOutOrderId(activitiStartProcessBO.getOutOrderId()); record.setProcessInstanceId(pId); record.setProcessInstanceKey(activitiStartProcessBO.getActivitiProcessKey().name()); record.setAuditStatus(AuditStatus.INIT.getCode()); record.setAuditData(activitiStartProcessBO.getAuditData()); record.setCallbackStatus(CallbackStatus.INIT.getCode()); Date now = new Date(); record.setCreateAt(now); record.setUpdateAt(now); return record; } }