From fa9429dbd5520f45c0055a100a95a0129f08d63a Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 19 Jul 2023 16:41:31 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E8=A7=A3=E5=86=B3=E6=97=A5=E5=B8=B8?= =?UTF-8?q?=E7=BB=B4=E6=8A=A4=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=9C=AA?= =?UTF-8?q?=E4=BC=A0=E4=BB=BB=E5=8A=A1=E8=A1=A8=E5=8D=95=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduled/MaintenanceTaskCreateTask.java | 36 +++++++++++++--------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java index de904ef..1e55809 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java +++ b/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); - taskEntity.setProcessInstanceId(processInstanceId); - taskService.updateById(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 params = new HashMap() {{ put("taskId", taskEntity.getId()); String userId = taskEntity.getDisposer(); List 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 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