巡检点,巡检项
parent
585e3f026a
commit
be3e8e4afa
|
|
@ -0,0 +1,69 @@
|
|||
package com.gunshi.project.xyt.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.project.xyt.entity.dto.InspectItemDto;
|
||||
import com.gunshi.project.xyt.entity.so.AttCctvBasePage;
|
||||
import com.gunshi.project.xyt.model.InspectItem;
|
||||
import com.gunshi.project.xyt.service.InspectItemService;
|
||||
import com.gunshi.project.xyt.validate.markers.Insert;
|
||||
import com.gunshi.project.xyt.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
/**
|
||||
* 描述: 巡检项
|
||||
* author: xusan
|
||||
* date: 2024-08-29 09:58:10
|
||||
*/
|
||||
@Tag(name = "巡检项")
|
||||
@RestController
|
||||
@RequestMapping(value="/inspectItem")
|
||||
public class InspectItemController {
|
||||
|
||||
@Autowired
|
||||
private InspectItemService service;
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<InspectItem> insert(@Validated(Insert.class) @RequestBody InspectItem dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
dto.setStatus(0);
|
||||
boolean result = service.save(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<InspectItem> update(@Validated(Update.class) @RequestBody InspectItem dto) {
|
||||
boolean result = service.updateById(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@GetMapping("/del/{id}")
|
||||
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||
return R.ok(service.removeById(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "启停")
|
||||
@PostMapping("/startStop")
|
||||
public R<String> startStop(@RequestBody InspectItemDto dto) {
|
||||
return R.ok(service.startStop(dto));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "分页")
|
||||
@PostMapping("/page")
|
||||
public R<Page<InspectItem>> page(@RequestBody @Validated AttCctvBasePage page) {
|
||||
return R.ok(service.pageQuery(page));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.gunshi.project.xyt.controller;
|
||||
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.project.xyt.model.InspectPoint;
|
||||
import com.gunshi.project.xyt.service.InspectPointService;
|
||||
import com.gunshi.project.xyt.validate.markers.Insert;
|
||||
import com.gunshi.project.xyt.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 描述: 巡检点
|
||||
* author: xusan
|
||||
* date: 2024-08-29 09:57:47
|
||||
*/
|
||||
@Tag(name = "巡检点")
|
||||
@RestController
|
||||
@RequestMapping(value="/inspect/point")
|
||||
public class InspectPointController {
|
||||
|
||||
@Autowired
|
||||
private InspectPointService service;
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<InspectPoint> insert(@Validated(Insert.class) @RequestBody InspectPoint dto) {
|
||||
return R.ok(service.saveData(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<InspectPoint> update(@Validated(Update.class) @RequestBody InspectPoint dto) {
|
||||
return R.ok(service.updateData(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@GetMapping("/del/{id}")
|
||||
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||
return R.ok(service.delData(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "列表")
|
||||
@PostMapping("/list")
|
||||
public R<List<InspectPoint>> list() {
|
||||
return R.ok(service.lambdaQuery().orderByAsc(InspectPoint::getOrderIndex).list());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.gunshi.project.xyt.entity.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户启停参数
|
||||
* Created by wanyan on 2024/1/22
|
||||
*
|
||||
* @author wanyan
|
||||
* @version 1.0
|
||||
*/
|
||||
@Data
|
||||
public class InspectItemDto {
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "状态(0启用 1停用)")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.InspectItem;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 描述: 巡检项
|
||||
* author: xusan
|
||||
* date: 2024-08-29 09:58:10
|
||||
*/
|
||||
@Mapper
|
||||
public interface InspectItemMapper extends BaseMapper<InspectItem> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.InspectPoint;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 描述: 巡检点
|
||||
* author: xusan
|
||||
* date: 2024-08-29 09:57:48
|
||||
*/
|
||||
@Mapper
|
||||
public interface InspectPointMapper extends BaseMapper<InspectPoint> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
package com.gunshi.project.xyt.model;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.gunshi.project.xyt.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述: 巡检项
|
||||
* author: xusan
|
||||
* date: 2024-08-29 09:58:09
|
||||
*/
|
||||
@Schema(description="巡检项")
|
||||
@Data
|
||||
@TableName("public.inspect_item")
|
||||
public class InspectItem implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@Schema(description="主键")
|
||||
@NotNull(message = "主键不能为空",groups = {Update.class})
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 巡检点id
|
||||
*/
|
||||
@TableField(value="point_id")
|
||||
@Schema(description="巡检点id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long pointId;
|
||||
|
||||
/**
|
||||
* 巡检项描述
|
||||
*/
|
||||
@TableField(value="item_desc")
|
||||
@Schema(description="巡检项描述")
|
||||
@Size(max = 500,message = "巡检项描述最大长度要小于 500")
|
||||
private String itemDesc;
|
||||
|
||||
/**
|
||||
* 问题描述
|
||||
*/
|
||||
@TableField(value="problem_desc")
|
||||
@Schema(description="问题描述")
|
||||
@Size(max = 500,message = "问题描述最大长度要小于 500")
|
||||
private String problemDesc;
|
||||
|
||||
/**
|
||||
* 处理建议
|
||||
*/
|
||||
@TableField(value="handle_suggestion")
|
||||
@Schema(description="处理建议")
|
||||
@Size(max = 500,message = "处理建议最大长度要小于 500")
|
||||
private String handleSuggestion;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
@TableField(value="order_index")
|
||||
@Schema(description="排序号")
|
||||
private Integer orderIndex;
|
||||
|
||||
/**
|
||||
* 状态(0启用 1停用)
|
||||
*/
|
||||
@TableField(value="status")
|
||||
@Schema(description="状态(0启用 1停用)")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.gunshi.project.xyt.model;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.gunshi.project.xyt.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述: 巡检点
|
||||
* author: xusan
|
||||
* date: 2024-08-29 09:57:47
|
||||
*/
|
||||
@Schema(description="巡检点")
|
||||
@Data
|
||||
@TableName("public.inspect_point")
|
||||
public class InspectPoint implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@Schema(description="主键")
|
||||
@NotNull(message = "主键不能为空",groups = {Update.class})
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField(value="name")
|
||||
@Schema(description="名称")
|
||||
@Size(max = 255,message = "名称最大长度要小于 255")
|
||||
@NotBlank(message = "名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField(value="order_index")
|
||||
@Schema(description="排序")
|
||||
private Integer orderIndex;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package com.gunshi.project.xyt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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;
|
||||
import com.gunshi.project.xyt.model.InspectItem;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 描述: 巡检项
|
||||
* author: xusan
|
||||
* date: 2024-08-29 09:58:10
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class InspectItemService extends ServiceImpl<InspectItemMapper, InspectItem>
|
||||
{
|
||||
|
||||
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 ? "启用失败" : "禁用失败";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.gunshi.project.xyt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.xyt.mapper.InspectItemMapper;
|
||||
import com.gunshi.project.xyt.mapper.InspectPointMapper;
|
||||
import com.gunshi.project.xyt.model.InspectItem;
|
||||
import com.gunshi.project.xyt.model.InspectPoint;
|
||||
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.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 描述: 巡检点
|
||||
* author: xusan
|
||||
* date: 2024-08-29 09:57:48
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class InspectPointService extends ServiceImpl<InspectPointMapper, InspectPoint>
|
||||
{
|
||||
@Autowired
|
||||
private InspectItemMapper inspectItemMapper;
|
||||
|
||||
public InspectPoint saveData(InspectPoint dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
QueryWrapper<InspectPoint> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderBy(true, false, "order_index");
|
||||
InspectPoint lastOne = super.getOne(queryWrapper, false);
|
||||
int order = 0;
|
||||
if (lastOne == null) {
|
||||
order = 1;
|
||||
} else {
|
||||
order = lastOne.getOrderIndex() + 1;
|
||||
}
|
||||
dto.setOrderIndex(order);
|
||||
this.save(dto);
|
||||
return dto;
|
||||
}
|
||||
|
||||
public InspectPoint updateData(InspectPoint dto) {
|
||||
if (Objects.isNull(this.getById(dto.getId()))) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
this.updateById(dto);
|
||||
return dto;
|
||||
}
|
||||
|
||||
public Boolean delData(Serializable id) {
|
||||
if (Objects.isNull(this.getById(id))) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
//判断是否关联巡检项
|
||||
LambdaQueryWrapper<InspectItem> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(InspectItem::getPointId,id);
|
||||
if(inspectItemMapper.selectCount(wrapper) > 0){
|
||||
throw new IllegalArgumentException("请先删除关联的巡检项");
|
||||
}
|
||||
return this.removeById(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue