81 lines
2.9 KiB
Java
81 lines
2.9 KiB
Java
|
|
package com.gunshi.project.xyt.service;
|
||
|
|
|
||
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||
|
|
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;
|
||
|
|
|
||
|
|
import java.util.Date;
|
||
|
|
import java.util.Objects;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 描述: 巡检任务
|
||
|
|
* 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());
|
||
|
|
dto.setStatus(1);
|
||
|
|
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) {
|
||
|
|
LambdaQueryWrapper<InspectTask> query = Wrappers.lambdaQuery();
|
||
|
|
if (ObjectUtils.isNotNull(page.getStatus())) {
|
||
|
|
query.eq(InspectTask::getStatus, page.getStatus());
|
||
|
|
}
|
||
|
|
if (ObjectUtils.isNotNull(page.getTaskType())) {
|
||
|
|
query.eq(InspectTask::getTaskType, page.getTaskType());
|
||
|
|
}
|
||
|
|
if(page.getDateTimeRangeSo() != null && page.getDateTimeRangeSo().getStart() != null){
|
||
|
|
query.ge(InspectTask::getCreateTime,page.getDateTimeRangeSo().getStart());
|
||
|
|
}
|
||
|
|
if(page.getDateTimeRangeSo() != null && page.getDateTimeRangeSo().getEnd() != null){
|
||
|
|
query.le(InspectTask::getCreateTime,page.getDateTimeRangeSo().getEnd());
|
||
|
|
}
|
||
|
|
query.orderByDesc(InspectTask::getCreateTime);
|
||
|
|
Page<InspectTask> res = this.page(page.getPageSo().toPage(), query);
|
||
|
|
return res;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|