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