|
|
|
@ -11,6 +11,7 @@ import com.hnac.hzims.operational.maintenance.entity.OperMaintenancePlanEntity;
|
|
|
|
|
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.service.MaintenanceService; |
|
|
|
|
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; |
|
|
|
@ -27,8 +28,12 @@ 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; |
|
|
|
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager; |
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
import org.springframework.transaction.TransactionDefinition; |
|
|
|
|
import org.springframework.transaction.TransactionStatus; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.transaction.support.DefaultTransactionDefinition; |
|
|
|
|
|
|
|
|
|
import java.time.Instant; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
@ -58,6 +63,11 @@ public class MaintenanceTaskCreateTask {
|
|
|
|
|
private final BladeLogger logger; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final DataSourceTransactionManager dataSourceTransactionManager; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final MaintenanceService maintenanceService; |
|
|
|
|
|
|
|
|
|
private final List<TemplateService> templateService; |
|
|
|
|
|
|
|
|
|
@Value("${hzims.operation.task.templateCode.maintenance.taskDispose}") |
|
|
|
@ -107,11 +117,11 @@ public class MaintenanceTaskCreateTask {
|
|
|
|
|
List<String> emCodeList = Arrays.asList(planEntity.getEmCode().split(",")); |
|
|
|
|
for(String emCode : emCodeList){ |
|
|
|
|
taskEntity.setEmCode(emCode); |
|
|
|
|
this.fillTask(taskEntity,planEntity); |
|
|
|
|
maintenanceService.fillTask(taskEntity,planEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
this.fillTask(taskEntity,planEntity); |
|
|
|
|
maintenanceService.fillTask(taskEntity,planEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -121,6 +131,9 @@ public class MaintenanceTaskCreateTask {
|
|
|
|
|
* @param planEntity |
|
|
|
|
*/ |
|
|
|
|
private void fillTask(OperMaintenanceTaskEntity taskEntity,OperMaintenancePlanEntity planEntity) { |
|
|
|
|
DefaultTransactionDefinition defaultTransactionDefinition = new DefaultTransactionDefinition(); |
|
|
|
|
defaultTransactionDefinition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); |
|
|
|
|
TransactionStatus transaction = dataSourceTransactionManager.getTransaction(defaultTransactionDefinition); |
|
|
|
|
taskEntity.setId(null); |
|
|
|
|
taskEntity.setCreateTime(DateUtil.now()); |
|
|
|
|
taskEntity.setUpdateTime(DateUtil.now()); |
|
|
|
@ -152,6 +165,7 @@ public class MaintenanceTaskCreateTask {
|
|
|
|
|
} |
|
|
|
|
// BeanUtil.copyProperties(planEntity, taskEntity);
|
|
|
|
|
taskService.save(taskEntity); |
|
|
|
|
dataSourceTransactionManager.commit(transaction); |
|
|
|
|
//生成工作流实例
|
|
|
|
|
String processInstanceId = this.startProcessInstance(planEntity.getProcDefId(), taskEntity); |
|
|
|
|
if(Func.isNotEmpty(processInstanceId)) { |
|
|
|
@ -186,7 +200,7 @@ public class MaintenanceTaskCreateTask {
|
|
|
|
|
put("initUserIds", taskUsers); |
|
|
|
|
put("operMaintenanceTaskEntityVo",vo); |
|
|
|
|
}}; |
|
|
|
|
R<BladeFlow> flowResult = flowClient.startProcessInstanceContainNameByKey(processDefinitionKey, "maintenance:task:" + taskEntity.getId(), taskEntity.getTitle(), params); |
|
|
|
|
R<BladeFlow> flowResult = flowClient.startProcessInstanceContainNameByKey(processDefinitionKey, String.valueOf(taskEntity.getId()), taskEntity.getTitle(), params); |
|
|
|
|
return Optional.ofNullable(flowResult).filter(r -> r.isSuccess()).map(R::getData).map(BladeFlow::getProcessInstanceId).orElse(null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|