| | |
| | | import com.ycl.common.constant.ProcessConstants; |
| | | import com.ycl.common.core.domain.AjaxResult; |
| | | import com.ycl.common.core.domain.entity.SysDept; |
| | | import com.ycl.common.core.domain.entity.SysDictData; |
| | | import com.ycl.common.core.domain.entity.SysRole; |
| | | import com.ycl.common.core.domain.entity.SysUser; |
| | | import com.ycl.common.enums.FlowComment; |
| | |
| | | import com.ycl.flow.FindNextNodeUtil; |
| | | import com.ycl.flow.FlowableUtils; |
| | | import com.ycl.mapper.ProcessCodingMapper; |
| | | import com.ycl.service.FlowLogService; |
| | | import com.ycl.service.ProcessLogService; |
| | | import com.ycl.service.IFlowTaskService; |
| | | import com.ycl.service.ISysDeployFormService; |
| | | import com.ycl.service.ISysFormService; |
| | | import com.ycl.service.common.TaskCommonService; |
| | | import com.ycl.system.service.ISysDeptService; |
| | | import com.ycl.system.service.ISysRoleService; |
| | | import com.ycl.system.service.ISysUserService; |
| | | import com.ycl.system.service.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.InputStream; |
| | | import java.lang.reflect.Field; |
| | | import java.nio.charset.StandardCharsets; |
| | |
| | | private final ISysUserService sysUserService; |
| | | private final ISysRoleService sysRoleService; |
| | | private final ISysDeptService sysDeptService; |
| | | private final ISysDictTypeService sysDictDService; |
| | | private final ISysDeployFormService sysInstanceFormService; |
| | | private final ISysFormService sysFormService; |
| | | private final TaskCommonService taskCommonService; |
| | | private final ProcessCodingMapper processCodingMapper; |
| | | private final FlowLogService flowLogService; |
| | | private final ProcessLogService processLogService; |
| | | |
| | | /** |
| | | * 完成审核任务 |
| | |
| | | if (Objects.isNull(task)) { |
| | | return AjaxResult.error("任务不存在"); |
| | | } |
| | | |
| | | Map<String, Object> processVariables = new HashMap<>(); |
| | | //查出字典中需要注入的字段信息 |
| | | List<String> dictList = sysDictDService.selectDictDataByType("flow_variables").stream().map(SysDictData::getDictValue).collect(Collectors.toList()); |
| | | Map<String, Object> newV = new HashMap<>(2); |
| | | if (!org.springframework.util.CollectionUtils.isEmpty(variables)) { |
| | | for (String key : variables.keySet()) { |
| | | newV.put(task.getTaskDefinitionKey() + "&" + key, variables.get(key)); |
| | | //字典里有就放入流程变量中 |
| | | if (!CollectionUtils.isEmpty(dictList) && dictList.contains(key)) { |
| | | processVariables.put(key,variables.get(key)); |
| | | } |
| | | } |
| | | } |
| | | //添加流程变量 |
| | | if(!processVariables.isEmpty()) taskService.setVariables(taskId,processVariables); |
| | | taskService.addComment(taskId, task.getProcessInstanceId(), FlowComment.SUBMIT.getType(), "完成提交"); |
| | | // 判断当前任务是不是转办过的 |
| | | Boolean delegation = flowLogService.taskDelegation(task.getProcessInstanceId(), task.getId()); |
| | | if (delegation) { |
| | | if (DelegationState.PENDING.equals(task.getDelegationState())) { |
| | | taskService.resolveTask(taskId, newV); |
| | | } else { |
| | | // 先让当前用户认领这个任务 |
| | | taskService.claim(taskId, SecurityUtils.getUserId() + ""); |
| | | taskService.complete(taskId, newV); |
| | | } |
| | | // 先让当前用户认领这个任务 |
| | | taskService.claim(taskId, SecurityUtils.getUserId() + ""); |
| | | taskService.complete(taskId, newV); |
| | | |
| | | return AjaxResult.success("提交成功"); |
| | | } |
| | | |
| | |
| | | flowTask.setDuration(histIns.getDurationInMillis() == null || histIns.getDurationInMillis() == 0 ? null : getDate(histIns.getDurationInMillis())); |
| | | //扩展 判断是否超时 |
| | | ProcessCoding processCoding = processCodingMap.get(histIns.getTaskId()); |
| | | if(processCoding!=null){ |
| | | if (processCoding != null) { |
| | | //通过耗时判断是否是代办节点 |
| | | //如果任务是代办节点 |
| | | if (flowTask.getDuration() == null) { |
| | | if(RED.equals(processCoding.getStatus()) || YELLOW.equals(processCoding.getStatus())){ |
| | | if (RED.equals(processCoding.getStatus()) || YELLOW.equals(processCoding.getStatus())) { |
| | | flowTask.setOvertime(processCoding.getStatus()); |
| | | } |
| | | }else { |
| | | } else { |
| | | //如果任务节点属于历史节点 |
| | | if(RED.equals(processCoding.getStatus())){ |
| | | if (RED.equals(processCoding.getStatus())) { |
| | | flowTask.setOvertime(processCoding.getStatus()); |
| | | }; |
| | | } |
| | | ; |
| | | } |
| | | } |
| | | // 获取意见评论内容 |
| | |
| | | List<JSONObject> oldFields = JSON.parseObject(JSON.toJSONString(formJson.get(ProcessConstants.WIDGET_LIST)), new TypeReference<List<JSONObject>>() { |
| | | }); |
| | | |
| | | // 设置已填写的表单为禁用状态 |
| | | for (JSONObject oldField : oldFields) { |
| | | JSONObject options = oldField.getJSONObject("options"); |
| | | options.put("disabled", true); |
| | | if(CollectionUtils.isNotEmpty(oldFields)) { |
| | | // 设置已填写的表单为禁用状态 |
| | | for (JSONObject oldField : oldFields) { |
| | | JSONObject options = oldField.getJSONObject("options"); |
| | | options.put("disabled", true); |
| | | } |
| | | formJson.put(ProcessConstants.WIDGET_LIST, oldFields); |
| | | newP.put(ProcessConstants.TASK_FORM_KEY, formJson); |
| | | newP.remove(formDetailVO.getBeforeNodeDefId() + "&" + ProcessConstants.TASK_FORM_KEY); |
| | | formDetailVO.setFormJsonObj(newP); |
| | | } |
| | | // TODO 暂时只处理用户任务上的表单 |
| | | // if (StringUtils.isNotBlank(task.getFormKey())) { |
| | |
| | | // } |
| | | // oldFields.addAll(newFields); |
| | | // } |
| | | formJson.put(ProcessConstants.WIDGET_LIST, oldFields); |
| | | newP.put(ProcessConstants.TASK_FORM_KEY, formJson); |
| | | newP.remove(formDetailVO.getBeforeNodeDefId() + "&" + ProcessConstants.TASK_FORM_KEY); |
| | | formDetailVO.setFormJsonObj(newP); |
| | | |
| | | } |
| | | } |
| | | return beforeNodes; |