| | |
| | | package com.zt.modules.workflow.service; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.zt.common.entity.BaseEntity; |
| | | import com.zt.common.entity.BusiEntity; |
| | | import com.zt.common.entity.FlowInfo; |
| | | import com.zt.common.service.BaseService; |
| | | import com.zt.common.utils.UUIDUtil; |
| | | import com.zt.core.context.UserContext; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 工作流服务 |
| | |
| | | // 已經存在該步驟了,不用繼續 |
| | | return; |
| | | } |
| | | |
| | | WfDefStep currentStep = workflowConfigService.get(currentStepId); |
| | | WfDefStep finallyStep = this.queryWfDefFinallyStep(currentStep.getWfDefId().toString()); |
| | | |
| | |
| | | throw new RuntimeException("没有符合(" + wfDef.getName() + ")流程的下一步(" + currentStep.getName() + ")执行人!"); |
| | | } |
| | | |
| | | String updateSql = currentStep.getUpdateSql(); |
| | | if (org.apache.commons.lang3.StringUtils.isNotBlank(updateSql)) { |
| | | updateSql = updateSql.replace("${bizId}", bizId.toString()); |
| | | updateSql = updateSql.replace("${bizId}", bizId.toString()); |
| | | updateSql = updateSql.replace("${nickName}", UserContext.getUser().getRealName()); |
| | | updateSql = updateSql.replace("${userId}", UserContext.getUser().getId().toString()); |
| | | baseDao.exeSql(updateSql); |
| | | WfDefStep prevStep = workflowConfigService.get(prevStepId); |
| | | if (prevStep!=null) { |
| | | String updateSql = prevStep.getUpdateSql(); |
| | | if (org.apache.commons.lang3.StringUtils.isNotBlank(updateSql)) { |
| | | updateSql = updateSql.replace("${bizId}", bizId.toString()); |
| | | updateSql = updateSql.replace("${bizId}", bizId.toString()); |
| | | updateSql = updateSql.replace("${nickName}", UserContext.getUser().getRealName()); |
| | | updateSql = updateSql.replace("${userId}", UserContext.getUser().getId().toString()); |
| | | baseDao.exeSql(updateSql); |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | taskParamDto.setUser(null); |
| | | taskParamDto.setGroupId2(null); |
| | |
| | | updateSql = updateSql.replace("${nickName}", UserContext.getUser().getRealName()); |
| | | updateSql = updateSql.replace("${userId}", UserContext.getUser().getId().toString()); |
| | | baseDao.exeSql(updateSql); |
| | | } |
| | | |
| | | WfDefStep prevStep = workflowConfigService.get(prevStepId); |
| | | if (prevStep!=null) { |
| | | updateSql = prevStep.getUpdateSql(); |
| | | if (org.apache.commons.lang3.StringUtils.isNotBlank(updateSql)) { |
| | | updateSql = updateSql.replace("${bizId}", bizId.toString()); |
| | | updateSql = updateSql.replace("${bizId}", bizId.toString()); |
| | | updateSql = updateSql.replace("${nickName}", UserContext.getUser().getRealName()); |
| | | updateSql = updateSql.replace("${userId}", UserContext.getUser().getId().toString()); |
| | | baseDao.exeSql(updateSql); |
| | | } |
| | | } |
| | | |
| | | if (!StringUtils.isBlank(currentStep.getNextFlows())) { |
| | |
| | | public void deleteFlowStep(String wfIdCode, String stepIdMark, Long bizId){ |
| | | baseDao.deleteFlowStep(wfIdCode,stepIdMark,bizId); |
| | | } |
| | | |
| | | public void getRunFlow(List<? extends BusiEntity> dataList, String flowCode) { |
| | | List<Long> ids = dataList.stream().map(f -> f.getId()).collect(Collectors.toList()); |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | params.put("bizIds", ids); |
| | | params.put("flowCode", flowCode); |
| | | List<FlowInfo> list = baseDao.getRunFlow(params); |
| | | for (BaseEntity item : dataList) { |
| | | List<FlowInfo> list2 = list.stream().filter(item2->item2.getBizId().equals(item.getId())).collect(Collectors.toList()); |
| | | if (list2.size()>0) { |
| | | item.setFlowInfo(list2.get(0)); |
| | | }else{ |
| | | item.setFlowInfo(new FlowInfo()); |
| | | } |
| | | } |
| | | } |
| | | } |