fix: 任务日志
This commit is contained in:
@@ -39,4 +39,8 @@ public interface LogRecordConstants {
|
||||
String TASK_INFO = "任务信息";
|
||||
String TASK_INFO_OPERATE_TYPE = "操作任务状态";
|
||||
String TASK_INFO_OPERATE_SUCCESS = "{{#loginUserNickname}}对任务操作了{{#operateName}}";
|
||||
String TASK_INFO_ACS_OPERATE_SUCCESS = "ACS 操作任务 {{#operateName}}";
|
||||
String TASK_INFO_ACS_EXECUTE_SUCCESS = "ACS {{#operateName}}";
|
||||
String TASK_INFO_CREATE_BY_RPC = "{{#ownerService}} 创建了任务";
|
||||
String TASK_INFO_CALL_BY_RPC = "{{#ownerService}} 回调任务:{{#taskId}}";
|
||||
}
|
||||
|
||||
@@ -5,12 +5,16 @@ import cn.code.nl.module.task.dal.mysql.transporttask.TransportTaskMapper;
|
||||
import cn.code.nl.module.task.dto.TaskCallbackResultReqDTO;
|
||||
import cn.code.nl.module.task.enums.CallbackStatusEnum;
|
||||
import cn.code.nl.module.task.enums.TransportTaskStatusEnum;
|
||||
import com.mzt.logapi.context.LogRecordContext;
|
||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import static cn.code.nl.module.system.enums.LogRecordConstants.*;
|
||||
|
||||
/**
|
||||
* 业务回调结果处理服务实现
|
||||
*
|
||||
@@ -25,6 +29,10 @@ public class TransportTaskCallbackServiceImpl implements TransportTaskCallbackSe
|
||||
private TransportTaskMapper transportTaskMapper;
|
||||
|
||||
@Override
|
||||
@LogRecord(type = TASK_INFO,
|
||||
subType = TASK_INFO_OPERATE_TYPE,
|
||||
bizNo = "{{#reqDTO.taskId}}",
|
||||
success = TASK_INFO_CALL_BY_RPC)
|
||||
public void receiveCallbackResult(TaskCallbackResultReqDTO reqDTO) {
|
||||
// 1. 查询任务
|
||||
TransportTaskDO task = transportTaskMapper.selectById(reqDTO.getTaskId());
|
||||
@@ -62,6 +70,10 @@ public class TransportTaskCallbackServiceImpl implements TransportTaskCallbackSe
|
||||
}
|
||||
|
||||
transportTaskMapper.updateById(task);
|
||||
|
||||
LogRecordContext.putVariable("ownerService", task.getOwnerService());
|
||||
LogRecordContext.putVariable("taskId", task.getTaskId());
|
||||
|
||||
log.info("业务回调结果已处理, taskId={}, result={}, newStatus={}",
|
||||
reqDTO.getTaskId(), reqDTO.getResult(), task.getTaskStatus());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.code.nl.module.task.service.transporttask;
|
||||
|
||||
import cn.code.nl.framework.common.exception.ServiceException;
|
||||
import cn.code.nl.framework.execute.biz.vo.AcsApplyActionRespVO;
|
||||
import cn.code.nl.module.task.dal.dataobject.transporttask.TransportTaskDO;
|
||||
import cn.code.nl.module.task.dal.mysql.transporttask.TransportTaskMapper;
|
||||
@@ -11,14 +10,16 @@ import cn.code.nl.module.task.enums.TransportTaskStatusEnum;
|
||||
import cn.code.nl.module.task.manage.TransportTaskBusinessOperationManager;
|
||||
import cn.code.nl.module.task.manage.TransportTaskOperationManager;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.mzt.logapi.context.LogRecordContext;
|
||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import static cn.code.nl.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.code.nl.module.system.enums.LogRecordConstants.*;
|
||||
import static cn.code.nl.module.task.enums.ErrorCodeConstants.TRANSPORT_TASK_NOT_EXISTS_ID;
|
||||
|
||||
/**
|
||||
@@ -46,6 +47,10 @@ public class TransportTaskFeedbackServiceImpl implements TransportTaskFeedbackSe
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = TASK_INFO,
|
||||
subType = TASK_INFO_OPERATE_TYPE,
|
||||
bizNo = "{{#reqDTO.taskId}}",
|
||||
success = TASK_INFO_ACS_OPERATE_SUCCESS)
|
||||
public void receiveAcsFeedback(AcsFeedbackReqDTO reqDTO) {
|
||||
TransportTaskDO task = getTaskForFeedback(reqDTO);
|
||||
saveResultParam(task, reqDTO);
|
||||
@@ -58,10 +63,15 @@ public class TransportTaskFeedbackServiceImpl implements TransportTaskFeedbackSe
|
||||
return;
|
||||
}
|
||||
transportTaskOperationManager.dispatchOperation(task, type, reqDTO);
|
||||
LogRecordContext.putVariable("operateName", type.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = TASK_INFO,
|
||||
subType = TASK_INFO_OPERATE_TYPE,
|
||||
bizNo = "{{#reqDTO.taskId}}",
|
||||
success = TASK_INFO_ACS_EXECUTE_SUCCESS)
|
||||
public AcsApplyActionRespVO receiveAcsBusinessFeedback(AcsFeedbackReqDTO reqDTO) {
|
||||
TransportTaskDO task = getTaskForFeedback(reqDTO);
|
||||
if (isFinalTask(task, reqDTO)) {
|
||||
@@ -77,6 +87,7 @@ public class TransportTaskFeedbackServiceImpl implements TransportTaskFeedbackSe
|
||||
reqDTO.getTaskId(), reqDTO.getStatus());
|
||||
return buildResp(task);
|
||||
}
|
||||
LogRecordContext.putVariable("operateName", type.getName());
|
||||
return transportTaskBusinessOperationManager.dispatchOperation(task, type, reqDTO);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +37,7 @@ import java.util.List;
|
||||
|
||||
import static cn.code.nl.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.code.nl.module.system.enums.LogRecordConstants.*;
|
||||
import static cn.code.nl.module.task.enums.ErrorCodeConstants.TRANSPORT_TASK_ALREADY_FINAL;
|
||||
import static cn.code.nl.module.task.enums.ErrorCodeConstants.TRANSPORT_TASK_NOT_EXISTS;
|
||||
import static cn.code.nl.module.task.enums.ErrorCodeConstants.TRANSPORT_TASK_OPERATION_NOT_SUPPORTED;
|
||||
import static cn.code.nl.module.task.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 搬运任务 Service 实现类
|
||||
@@ -77,6 +75,10 @@ public class TransportTaskServiceImpl implements TransportTaskService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@LogRecord(type = TASK_INFO,
|
||||
subType = TASK_INFO_OPERATE_TYPE,
|
||||
bizNo = "{{_ret}}",
|
||||
success = TASK_INFO_CREATE_BY_RPC)
|
||||
public Long createTransportTaskByRpc(TransportTaskCreateReqDTO reqDTO) {
|
||||
TransportTaskDO task = BeanUtils.toBean(reqDTO, TransportTaskDO.class);
|
||||
CodeGenerateReqDTO codeGenerateReqDTO = new CodeGenerateReqDTO();
|
||||
@@ -91,6 +93,7 @@ public class TransportTaskServiceImpl implements TransportTaskService {
|
||||
task.setCreateMode("RPC");
|
||||
|
||||
transportTaskMapper.insert(task);
|
||||
LogRecordContext.putVariable("ownerService", task.getOwnerService());
|
||||
return task.getTaskId();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user