2024-08-29 13:49:35 +08:00
|
|
|
package com.gunshi.project.xyt.service;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
2024-09-04 16:36:00 +08:00
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
2024-08-29 13:49:35 +08:00
|
|
|
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.dto.InspectItemDto;
|
|
|
|
|
import com.gunshi.project.xyt.entity.so.AttCctvBasePage;
|
|
|
|
|
import com.gunshi.project.xyt.mapper.InspectItemMapper;
|
2024-09-04 16:36:00 +08:00
|
|
|
import com.gunshi.project.xyt.mapper.InspectTaskDetailMapper;
|
2024-08-29 13:49:35 +08:00
|
|
|
import com.gunshi.project.xyt.model.InspectItem;
|
2024-09-04 16:36:00 +08:00
|
|
|
import com.gunshi.project.xyt.model.InspectTaskDetail;
|
2024-08-29 13:49:35 +08:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2024-09-04 16:36:00 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2024-08-29 13:49:35 +08:00
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
2024-09-04 16:36:00 +08:00
|
|
|
import java.util.Objects;
|
|
|
|
|
|
2024-08-29 13:49:35 +08:00
|
|
|
/**
|
|
|
|
|
* 描述: 巡检项
|
|
|
|
|
* author: xusan
|
|
|
|
|
* date: 2024-08-29 09:58:10
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public class InspectItemService extends ServiceImpl<InspectItemMapper, InspectItem>
|
|
|
|
|
{
|
2024-09-04 16:36:00 +08:00
|
|
|
@Autowired
|
|
|
|
|
private InspectTaskDetailMapper taskDetailMapper;
|
2024-08-29 13:49:35 +08:00
|
|
|
|
|
|
|
|
public Page<InspectItem> pageQuery(AttCctvBasePage page) {
|
|
|
|
|
LambdaQueryWrapper<InspectItem> query = Wrappers.lambdaQuery();
|
|
|
|
|
if (ObjectUtils.isNotNull(page.getMenuId())) {
|
|
|
|
|
query.eq(InspectItem::getPointId, page.getMenuId());
|
|
|
|
|
}
|
|
|
|
|
query.orderByAsc(InspectItem::getStatus).orderByAsc(InspectItem::getOrderIndex);
|
|
|
|
|
Page<InspectItem> res = this.page(page.getPageSo().toPage(), query);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String startStop(InspectItemDto dto) {
|
|
|
|
|
Integer status = dto.getStatus();
|
|
|
|
|
InspectItem item = super.getById(dto.getId());
|
|
|
|
|
if (item == null) {
|
|
|
|
|
throw new IllegalArgumentException("当前数据不存在");
|
|
|
|
|
}
|
|
|
|
|
item.setStatus(status);
|
|
|
|
|
boolean flag = super.updateById(item);
|
|
|
|
|
if (flag) {
|
|
|
|
|
return status == 0 ? "启用成功" : "禁用成功";
|
|
|
|
|
}
|
|
|
|
|
return status == 0 ? "启用失败" : "禁用失败";
|
|
|
|
|
}
|
2024-09-04 16:36:00 +08:00
|
|
|
|
|
|
|
|
public Boolean delData(Long id) {
|
|
|
|
|
if (Objects.isNull(this.getById(id))) {
|
|
|
|
|
throw new IllegalArgumentException("当前数据不存在");
|
|
|
|
|
}
|
|
|
|
|
Long count = taskDetailMapper.selectCount(new QueryWrapper<InspectTaskDetail>().eq("item_id", id));
|
|
|
|
|
if(count > 0){
|
|
|
|
|
throw new IllegalArgumentException("该巡检项已被巡检任务使用,不可删除");
|
|
|
|
|
}
|
|
|
|
|
return this.removeById(id);
|
|
|
|
|
}
|
2024-08-29 13:49:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|