package com.zy.asrs.service.impl;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.core.exception.CoolException;
|
import com.zy.asrs.entity.Task;
|
import com.zy.asrs.entity.WrkMast;
|
import com.zy.asrs.entity.WrkMastLog;
|
import com.zy.asrs.mapper.TaskLogMapper;
|
import com.zy.asrs.entity.TaskLog;
|
import com.zy.asrs.service.TaskLogService;
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
import com.zy.asrs.service.TaskService;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.Objects;
|
|
@Service("taskLogService")
|
public class TaskLogServiceImpl extends ServiceImpl<TaskLogMapper, TaskLog> implements TaskLogService {
|
|
@Autowired
|
private TaskService taskService;
|
|
/**
|
* @author Ryan
|
* @date 2025/9/23
|
* @description: 保存任务日志
|
* @version 1.0
|
*/
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public boolean save(Integer wrkNo) {
|
Task task = taskService.selectOne(new EntityWrapper<Task>().eq("wrk_no", wrkNo));
|
if (Objects.isNull(task)) {
|
throw new CoolException("数据错误:任务不存在!!");
|
}
|
TaskLog taskLog = new TaskLog();
|
BeanUtils.copyProperties(task, taskLog);
|
taskLog.setLogId(task.getId());
|
|
if (!this.insert(taskLog)) {
|
throw new CoolException("任务日志保存失败!!");
|
}
|
|
return false;
|
}
|
}
|