巡检任务带巡检项增删改查
parent
f05df6f9cb
commit
f3f189749d
|
|
@ -0,0 +1,54 @@
|
|||
package com.gunshi.project.xyt.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.project.xyt.entity.so.InspectTaskPageSo;
|
||||
import com.gunshi.project.xyt.model.InspectTask;
|
||||
import com.gunshi.project.xyt.service.InspectTaskService;
|
||||
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.*;
|
||||
/**
|
||||
* 描述: 巡检任务
|
||||
* author: xusan
|
||||
* date: 2024-08-29 14:21:15
|
||||
*/
|
||||
@Tag(name = "巡检任务")
|
||||
@RestController
|
||||
@RequestMapping(value="/inspectTask")
|
||||
public class InspectTaskController {
|
||||
|
||||
@Autowired
|
||||
private InspectTaskService service;
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<InspectTask> insert(@Validated(Insert.class) @RequestBody InspectTask dto) {
|
||||
return R.ok(service.saveData(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<InspectTask> update(@Validated(Update.class) @RequestBody InspectTask dto) {
|
||||
return R.ok(service.updateData(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@GetMapping("/del/{id}")
|
||||
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Long id) {
|
||||
return R.ok(service.delData(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页")
|
||||
@PostMapping("/page")
|
||||
public R<Page<InspectTask>> page(@RequestBody @Validated InspectTaskPageSo page) {
|
||||
return R.ok(service.pageQuery(page));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.gunshi.project.xyt.controller;
|
||||
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.project.xyt.model.InspectTaskDetail;
|
||||
import com.gunshi.project.xyt.service.InspectTaskDetailService;
|
||||
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.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* 描述: 巡查信息
|
||||
* author: xusan
|
||||
* date: 2024-08-29 14:21:45
|
||||
*/
|
||||
@Tag(name = "巡查信息")
|
||||
@RestController
|
||||
@RequestMapping(value="/inspectTaskDetail")
|
||||
public class InspectTaskDetailController {
|
||||
|
||||
@Autowired
|
||||
private InspectTaskDetailService service;
|
||||
|
||||
|
||||
@Operation(summary = "编辑详情")
|
||||
@GetMapping("/getByTaskId")
|
||||
public R<List<InspectTaskDetail>> getByTaskId(@Schema(name = "taskId",description = "任务id") @RequestParam(name = "taskId") Long taskId) {
|
||||
return R.ok(service.getByTaskId(taskId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.gunshi.project.xyt.entity.so;
|
||||
|
||||
import com.gunshi.db.dto.DateTimeRangeSo;
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Created by wanyan on 2024/3/19
|
||||
*
|
||||
* @author wanyan
|
||||
* @version 1.0
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "分页查询对象")
|
||||
public class InspectTaskPageSo {
|
||||
|
||||
@NotNull(message = "分页参数不能为空")
|
||||
@Schema(description = "分页参数")
|
||||
private PageSo pageSo;
|
||||
|
||||
@Schema(description="状态(1未完成 2进行中 3已完成)")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description="任务类型(1日常巡查 2特别检查 3汛前巡检)")
|
||||
private Integer taskType;
|
||||
|
||||
@Schema(description = "时间范围")
|
||||
private DateTimeRangeSo dateTimeRangeSo;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.InspectTaskDetail;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 描述: 巡查信息
|
||||
* author: xusan
|
||||
* date: 2024-08-29 14:21:45
|
||||
*/
|
||||
@Mapper
|
||||
public interface InspectTaskDetailMapper extends BaseMapper<InspectTaskDetail> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.InspectTask;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 描述: 巡检任务
|
||||
* author: xusan
|
||||
* date: 2024-08-29 14:21:15
|
||||
*/
|
||||
@Mapper
|
||||
public interface InspectTaskMapper extends BaseMapper<InspectTask> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
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.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.gunshi.core.dateformat.DateFormatString;
|
||||
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;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: 巡检任务
|
||||
* author: xusan
|
||||
* date: 2024-08-29 14:21:14
|
||||
*/
|
||||
@Schema(description="巡检任务")
|
||||
@Data
|
||||
@TableName("public.inspect_task")
|
||||
public class InspectTask 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;
|
||||
|
||||
/**
|
||||
* 任务类型(1日常巡查 2特别检查 3汛前巡检)
|
||||
*/
|
||||
@TableField(value="task_type")
|
||||
@Schema(description="任务类型(1日常巡查 2特别检查 3汛前巡检)")
|
||||
private Integer taskType;
|
||||
|
||||
/**
|
||||
* 任务标题
|
||||
*/
|
||||
@TableField(value="task_title")
|
||||
@Schema(description="任务标题")
|
||||
@Size(max = 100,message = "任务标题最大长度要小于 100")
|
||||
private String taskTitle;
|
||||
|
||||
/**
|
||||
* 巡查人id
|
||||
*/
|
||||
@TableField(value="inspect_user_id")
|
||||
@Schema(description="巡查人id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long inspectUserId;
|
||||
|
||||
/**
|
||||
* 巡查人
|
||||
*/
|
||||
@TableField(value="inspect_user_name")
|
||||
@Schema(description="巡查人")
|
||||
@Size(max = 100,message = "巡查人最大长度要小于 100")
|
||||
private String inspectUserName;
|
||||
|
||||
/**
|
||||
* 任务内容
|
||||
*/
|
||||
@TableField(value="task_content")
|
||||
@Schema(description="任务内容")
|
||||
@Size(max = 500,message = "任务内容最大长度要小于 500")
|
||||
private String taskContent;
|
||||
|
||||
/**
|
||||
* 开始日期
|
||||
*/
|
||||
@TableField(value="start_date")
|
||||
@Schema(description="开始日期")
|
||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD, timezone = "GMT+8")
|
||||
private Date startDate;
|
||||
|
||||
/**
|
||||
* 结束日期
|
||||
*/
|
||||
@TableField(value="end_date")
|
||||
@Schema(description="结束日期")
|
||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD, timezone = "GMT+8")
|
||||
private Date endDate;
|
||||
|
||||
/**
|
||||
* 接收时间
|
||||
*/
|
||||
@TableField(value="receive_time")
|
||||
@Schema(description="接收时间")
|
||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||
private Date receiveTime;
|
||||
|
||||
/**
|
||||
* 完成时间
|
||||
*/
|
||||
@TableField(value="finish_time")
|
||||
@Schema(description="完成时间")
|
||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||
private Date finishTime;
|
||||
|
||||
/**
|
||||
* 状态(1未完成 2进行中 3已完成)
|
||||
*/
|
||||
@TableField(value="status")
|
||||
@Schema(description="状态(1未完成 2进行中 3已完成)")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@TableField(value="create_user_id")
|
||||
@Schema(description="创建人id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(value="create_user_name")
|
||||
@Schema(description="创建人")
|
||||
@Size(max = 100,message = "创建人最大长度要小于 100")
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value="create_time")
|
||||
@Schema(description="创建时间")
|
||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description="问题数量")
|
||||
private Integer problemNum = 0;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description="待处理数量")
|
||||
private Integer handleNum = 0;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description="巡检项")
|
||||
private List<InspectTaskDetail> items;
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
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.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.gunshi.core.dateformat.DateFormatString;
|
||||
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;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 描述: 巡查信息
|
||||
* author: xusan
|
||||
* date: 2024-08-29 15:21:24
|
||||
*/
|
||||
@Schema(description="巡查信息")
|
||||
@Data
|
||||
@TableName("public.inspect_task_detail")
|
||||
public class InspectTaskDetail implements Serializable {
|
||||
|
||||
public final static String thisTableName = "InspectTaskDetail";
|
||||
|
||||
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="task_id")
|
||||
@Schema(description="任务id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long taskId;
|
||||
|
||||
/**
|
||||
* 巡查点id
|
||||
*/
|
||||
@TableField(value="point_id")
|
||||
@Schema(description="巡查点id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long pointId;
|
||||
|
||||
/**
|
||||
* 巡查项id
|
||||
*/
|
||||
@TableField(value="item_id")
|
||||
@Schema(description="巡查项id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long itemId;
|
||||
|
||||
/**
|
||||
* 是否正常(0否 1是)
|
||||
*/
|
||||
@TableField(value="is_normal")
|
||||
@Schema(description="是否正常(0否 1是)")
|
||||
private Integer isNormal;
|
||||
|
||||
/**
|
||||
* 巡查问题描述
|
||||
*/
|
||||
@TableField(value="problem_desc")
|
||||
@Schema(description="巡查问题描述")
|
||||
@Size(max = 500,message = "巡查问题描述最大长度要小于 500")
|
||||
private String problemDesc;
|
||||
|
||||
/**
|
||||
* 是否处理(0否 1是)
|
||||
*/
|
||||
@TableField(value="is_handle")
|
||||
@Schema(description="是否处理(0否 1是)")
|
||||
private Integer isHandle;
|
||||
|
||||
/**
|
||||
* 处理人id
|
||||
*/
|
||||
@TableField(value="handle_user_id")
|
||||
@Schema(description="处理人id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long handleUserId;
|
||||
|
||||
/**
|
||||
* 处理人
|
||||
*/
|
||||
@TableField(value="handle_user_name")
|
||||
@Schema(description="处理人")
|
||||
@Size(max = 100,message = "处理人最大长度要小于 100")
|
||||
private String handleUserName;
|
||||
|
||||
/**
|
||||
* 处理描述
|
||||
*/
|
||||
@TableField(value="handle_desc")
|
||||
@Schema(description="处理描述")
|
||||
@Size(max = 500,message = "处理描述最大长度要小于 500")
|
||||
private String handleDesc;
|
||||
|
||||
/**
|
||||
* 处理时间
|
||||
*/
|
||||
@TableField(value="handle_time")
|
||||
@Schema(description="处理时间")
|
||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||
private Date handleTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.gunshi.project.xyt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.xyt.mapper.InspectTaskDetailMapper;
|
||||
import com.gunshi.project.xyt.model.InspectTaskDetail;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: 巡查信息
|
||||
* author: xusan
|
||||
* date: 2024-08-29 14:21:45
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class InspectTaskDetailService extends ServiceImpl<InspectTaskDetailMapper, InspectTaskDetail>
|
||||
{
|
||||
|
||||
public void saveDetail(List<InspectTaskDetail> items, Long taskId) {
|
||||
items.stream().forEach(o->{
|
||||
o.setId(IdWorker.getId());
|
||||
o.setTaskId(taskId);
|
||||
});
|
||||
this.saveBatch(items);
|
||||
}
|
||||
|
||||
public void updateDetail(List<InspectTaskDetail> items, Long taskId) {
|
||||
delDetail(taskId);
|
||||
saveDetail(items,taskId);
|
||||
}
|
||||
|
||||
public void delDetail(Long taskId) {
|
||||
this.remove(new QueryWrapper<InspectTaskDetail>().eq("task_id",taskId));
|
||||
}
|
||||
|
||||
public List<InspectTaskDetail> getByTaskId(Long taskId) {
|
||||
return this.list(new QueryWrapper<InspectTaskDetail>().eq("task_id",taskId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue