Browse Source

# 解决日常维护定时任务未传任务表单进入工作流bug

zhongwei
haungxing 1 year ago
parent
commit
fa9429dbd5
  1. 32
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java

32
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java

@ -12,6 +12,8 @@ import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.mapper.OperMaintenancePlanMapper;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.hnac.hzims.operational.maintenance.template.service.TemplateService;
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskEntityVo;
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
@ -21,6 +23,7 @@ import org.apache.commons.lang.StringUtils;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*;
import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
@ -106,9 +109,6 @@ public class MaintenanceTaskCreateTask {
taskEntity.setEmCode(emCode);
this.fillTask(taskEntity,planEntity);
}
// emCodeList.forEach(emCode -> {
//
// });
}
else {
this.fillTask(taskEntity,planEntity);
@ -154,14 +154,19 @@ public class MaintenanceTaskCreateTask {
taskService.save(taskEntity);
//生成工作流实例
String processInstanceId = this.startProcessInstance(planEntity.getProcDefId(), taskEntity);
if(Func.isNotEmpty(processInstanceId)) {
taskEntity.setProcessInstanceId(processInstanceId);
taskService.updateById(taskEntity);
this.pushTaskMessage(taskEntity);
}
else {
if(ObjectUtil.isNotEmpty(taskService.getById(taskEntity.getId()))) {
taskService.removeById(taskEntity.getId());
}
}
planEntity.setCreateTaskTime(DateUtil.now());
planMapper.updateById(planEntity);
taskEntity = taskService.getById(taskEntity.getId());
//taskEntity.setMessageTemplateId(1646694238095732738L);
this.pushTaskMessage(taskEntity);
}
/**
@ -170,19 +175,20 @@ public class MaintenanceTaskCreateTask {
* @author xiashandong
**/
private String startProcessInstance(String processDefinitionKey, OperMaintenanceTaskEntity taskEntity) {
if(Func.isEmpty(taskEntity.getDisposer())) {
return null;
}
OperMaintenanceTaskEntityVo vo = BeanUtil.copy(taskEntity,OperMaintenanceTaskEntityVo.class);
Map<String,Object> params = new HashMap<String, Object>() {{
put("taskId", taskEntity.getId());
String userId = taskEntity.getDisposer();
List<String> userIdList = Stream.of(userId.split(",")).collect(Collectors.toList());
String taskUsers = userIdList.stream().filter(o -> StringUtils.isNotBlank(o)).map(s -> {
return "taskUser_".concat(s);
}).collect(Collectors.joining(","));
String taskUsers = userIdList.stream().filter(o -> StringUtils.isNotBlank(o)).map(s -> "taskUser_".concat(s)).collect(Collectors.joining(","));
put("initUserIds", taskUsers);
put("operMaintenanceTaskEntityVo",vo);
}};
return flowClient.startProcessInstanceContainNameByKey(processDefinitionKey,"maintenance:task:" + taskEntity.getId(),taskEntity.getTitle(), params)
.getData()
.getProcessInstanceId();
R<BladeFlow> flowResult = flowClient.startProcessInstanceContainNameByKey(processDefinitionKey, "maintenance:task:" + taskEntity.getId(), taskEntity.getTitle(), params);
return Optional.ofNullable(flowResult).filter(r -> r.isSuccess()).map(R::getData).map(BladeFlow::getProcessInstanceId).orElse(null);
}
/** @Author hx

Loading…
Cancel
Save