2024-08-29 16:46:53 +08:00
|
|
|
package com.gunshi.project.xyt.service;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.gunshi.project.xyt.entity.so.InspectTaskPageSo;
|
|
|
|
|
import com.gunshi.project.xyt.mapper.InspectTaskMapper;
|
|
|
|
|
import com.gunshi.project.xyt.model.InspectTask;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
2024-08-30 15:29:38 +08:00
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.Objects;
|
2024-08-29 16:46:53 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 描述: 巡检任务
|
|
|
|
|
* author: xusan
|
|
|
|
|
* date: 2024-08-29 14:21:15
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public class InspectTaskService extends ServiceImpl<InspectTaskMapper, InspectTask>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private InspectTaskDetailService inspectTaskDetailService;
|
|
|
|
|
|
|
|
|
|
public InspectTask saveData(InspectTask dto) {
|
|
|
|
|
dto.setId(IdWorker.getId());
|
2024-08-30 10:39:18 +08:00
|
|
|
dto.setStatus(0);
|
2024-08-29 16:46:53 +08:00
|
|
|
dto.setCreateTime(new Date());
|
|
|
|
|
this.save(dto);
|
|
|
|
|
inspectTaskDetailService.saveDetail(dto.getItems(),dto.getId());
|
|
|
|
|
return dto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public InspectTask updateData(InspectTask dto) {
|
|
|
|
|
if (Objects.isNull(this.getById(dto.getId()))) {
|
|
|
|
|
throw new IllegalArgumentException("当前数据不存在");
|
|
|
|
|
}
|
|
|
|
|
this.updateById(dto);
|
|
|
|
|
inspectTaskDetailService.updateDetail(dto.getItems(),dto.getId());
|
|
|
|
|
return dto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Boolean delData(Long id) {
|
|
|
|
|
if (Objects.isNull(this.getById(id))) {
|
|
|
|
|
throw new IllegalArgumentException("当前数据不存在");
|
|
|
|
|
}
|
|
|
|
|
inspectTaskDetailService.delDetail(id);
|
|
|
|
|
return this.removeById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Page<InspectTask> pageQuery(InspectTaskPageSo page) {
|
2024-08-30 10:39:18 +08:00
|
|
|
return this.baseMapper.pageQuery(page.getPageSo().toPage(),page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Boolean startInspect(Long id) {
|
|
|
|
|
InspectTask task = this.getById(id);
|
|
|
|
|
if (Objects.isNull(task)) {
|
|
|
|
|
throw new IllegalArgumentException("当前数据不存在");
|
2024-08-29 16:46:53 +08:00
|
|
|
}
|
2024-08-30 15:29:38 +08:00
|
|
|
task.setReceiveTime(new Date());
|
2024-08-30 10:39:18 +08:00
|
|
|
task.setStatus(1);
|
|
|
|
|
return this.updateById(task);
|
2024-08-29 16:46:53 +08:00
|
|
|
}
|
2024-08-30 13:36:20 +08:00
|
|
|
|
|
|
|
|
|
2024-08-29 16:46:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|