fix(flow) update VariablesSubmitDate

approve-sys
bob 2 years ago
parent 017bb8f0c4
commit f87d8f01de

@ -95,7 +95,7 @@ public class FlowTaskController {
@ApiOperation(value = "修改任务完成时间", response = FlowTaskDto.class) @ApiOperation(value = "修改任务完成时间", response = FlowTaskDto.class)
@PostMapping(value = "/updateTaskFinishDate") @PostMapping(value = "/updateTaskFinishDate")
public AjaxResult updateTaskFinishDate(@RequestBody UpdateVariablesSubmitDateVo vo) { public AjaxResult updateTaskFinishDate(@RequestBody UpdateVariablesSubmitDateVo vo) {
return flowTaskService.updateVariablesSubmitDate(vo); return flowTaskService.updateTaskFinishDate(vo);
} }
@ApiOperation(value = "审批任务") @ApiOperation(value = "审批任务")

@ -12,6 +12,8 @@ public class UpdateVariablesSubmitDateVo {
@ApiModelProperty("任务id") @ApiModelProperty("任务id")
private String taskId; private String taskId;
@ApiModelProperty("任务顺序编号")
private String taskIndex;
@ApiModelProperty("提交时间") @ApiModelProperty("提交时间")
private String finishDate; private String finishDate;

@ -167,7 +167,7 @@ public interface IFlowTaskService {
AjaxResult processVariables(String taskId); AjaxResult processVariables(String taskId);
AjaxResult updateVariablesSubmitDate(String processInstanceId,String submitDate); AjaxResult updateVariablesSubmitDate(String processInstanceId,String submitDate);
AjaxResult updateVariablesSubmitDate(UpdateVariablesSubmitDateVo vo); AjaxResult updateTaskFinishDate(UpdateVariablesSubmitDateVo vo);
/** /**
* *

@ -2,8 +2,10 @@ package com.ruoyi.flowable.service.impl;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -237,11 +239,9 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
} catch (FlowableException e) { } catch (FlowableException e) {
throw new CustomException("无法取消或开始活动"); throw new CustomException("无法取消或开始活动");
} }
runtimeService.updateBusinessStatus(flowTaskVo.getInstanceId(), FlowStatus.REJECT.getValue()); runtimeService.updateBusinessStatus(flowTaskVo.getInstanceId(), FlowStatus.REJECT.getValue());
} }
/** /**
* 退 * 退
* *
@ -998,23 +998,37 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
return AjaxResult.success(); return AjaxResult.success();
} }
@Override @Override
public AjaxResult updateVariablesSubmitDate(UpdateVariablesSubmitDateVo vo) { public AjaxResult updateTaskFinishDate(UpdateVariablesSubmitDateVo vo) {
if (StringUtils.isBlank(vo.getProcessInstanceId()) || StringUtils.isBlank(vo.getFinishDate())) { if (StringUtils.isBlank(vo.getProcessInstanceId()) || StringUtils.isBlank(vo.getFinishDate())) {
return AjaxResult.error("更新提交时间失败,参数无效"); return AjaxResult.error("更新提交时间失败,参数无效");
} }
Execution execution = runtimeService.createExecutionQuery().processInstanceId(vo.getProcessInstanceId()).variableExists("submitDate").singleResult(); HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().processInstanceId(vo.getProcessInstanceId()).taskId(vo.getTaskId()).singleResult();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(vo.getProcessInstanceId()).includeProcessVariables().singleResult(); if (Objects.isNull(historicTaskInstance)) {
if (Objects.isNull(execution)) { return AjaxResult.error("更新提交时间失败,此任务不存在");
}
String executionId = historicTaskInstance.getExecutionId();
if (Objects.isNull(executionId)) {
return AjaxResult.error("更新提交时间失败,查询错误"); return AjaxResult.error("更新提交时间失败,查询错误");
} }
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(vo.getProcessInstanceId()).includeProcessVariables().singleResult();
Map<String, Object> variables = processInstance.getProcessVariables(); Map<String, Object> variables = processInstance.getProcessVariables();
Map<String, Object> map = (Map<String , Object>)MapUtils.getMap(variables, USER_MODIFY_TASK_FINISH_TIME_VARIABLE_KEY,new HashMap<>()); Map<String, Object> map = (Map<String , Object>)MapUtils.getMap(variables, USER_MODIFY_TASK_FINISH_TIME_VARIABLE_KEY,new HashMap<>());
map.put(vo.getTaskId(), DateUtil.parse(vo.getFinishDate(), DatePattern.NORM_DATETIME_FORMATTER)); DateTime submitDate = DateUtil.parse(vo.getFinishDate(), DatePattern.NORM_DATETIME_FORMATTER);
runtimeService.setVariable(execution.getId(),USER_MODIFY_TASK_FINISH_TIME_VARIABLE_KEY,map); map.put(vo.getTaskId(),submitDate);
runtimeService.setVariable(vo.getProcessInstanceId(), USER_MODIFY_TASK_FINISH_TIME_VARIABLE_KEY,map);
updateSubmitDate(vo.getProcessInstanceId(), historicTaskInstance.getName(), submitDate);
return AjaxResult.success(); return AjaxResult.success();
} }
public void updateSubmitDate( String processInstanceId,String taskName, DateTime submitDate) {
if (ObjectUtil.notEqual("提交汇报",taskName)) {
return;
}
runtimeService.setVariable(processInstanceId,"submitDate",submitDate);
}
/** /**
* *
* *

Loading…
Cancel
Save