Browse Source

日志维护定时任务派发

zhongwei
段飞宇 1 year ago
parent
commit
7a16c8cddf
  1. 20
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java
  2. 14
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/MaintenanceService.java
  3. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java

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

@ -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);
}

14
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/MaintenanceService.java

@ -1,8 +1,9 @@
package com.hnac.hzims.operational.maintenance.service;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenancePlanEntity;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import java.util.List;
@ -16,6 +17,7 @@ public interface MaintenanceService {
/**
* 日常维护生成任务
*
* @param ids
*/
@ -24,7 +26,17 @@ public interface MaintenanceService {
/**
* 日常维护待处理
*
* @param response
*/
void findPending(ProcessWorkFlowResponse response);
/**
* 通过计划生成任务
*
* @param taskEntity
* @param finalPlanEntity
*/
void fillTask(OperMaintenanceTaskEntity taskEntity, OperMaintenancePlanEntity finalPlanEntity);
}

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java

@ -291,7 +291,7 @@ public class MaintenanceServiceImpl implements MaintenanceService {
* @param taskEntity
* @param finalPlanEntity
*/
private void fillTask(OperMaintenanceTaskEntity taskEntity, OperMaintenancePlanEntity finalPlanEntity) {
public void fillTask(OperMaintenanceTaskEntity taskEntity, OperMaintenancePlanEntity finalPlanEntity) {
DefaultTransactionDefinition defaultTransactionDefinition = new DefaultTransactionDefinition();
defaultTransactionDefinition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
TransactionStatus transaction = dataSourceTransactionManager.getTransaction(defaultTransactionDefinition);

Loading…
Cancel
Save