维修养护
parent
882f6a07d7
commit
83a667d7ec
|
|
@ -0,0 +1,67 @@
|
|||
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.MaintainPageSo;
|
||||
import com.gunshi.project.xyt.model.MaintainService;
|
||||
import com.gunshi.project.xyt.service.MaintainServiceService;
|
||||
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-27 15:15:14
|
||||
*/
|
||||
@Tag(name = "维修养护")
|
||||
@RestController
|
||||
@RequestMapping(value="/maintain/service")
|
||||
public class MaintainServiceController extends AbstractCommonFileController{
|
||||
|
||||
@Autowired
|
||||
private MaintainServiceService service;
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<MaintainService> insert(@Validated(Insert.class) @RequestBody MaintainService dto) {
|
||||
return R.ok(service.saveData(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<MaintainService> update(@Validated(Update.class) @RequestBody MaintainService 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<MaintainService>> list() {
|
||||
return R.ok(service.lambdaQuery().list());
|
||||
}
|
||||
|
||||
@Operation(summary = "分页")
|
||||
@PostMapping("/page")
|
||||
public R<Page<MaintainService>> page(@RequestBody MaintainPageSo page) {
|
||||
return R.ok(service.pageQuery(page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupId() {
|
||||
return "maintainService";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
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 MaintainPageSo {
|
||||
|
||||
@NotNull(message = "分页参数不能为空")
|
||||
@Schema(description = "分页参数")
|
||||
private PageSo pageSo;
|
||||
|
||||
@Schema(description="管护类型(1溢洪道淸障 2除草除杂 3设备养护 4环境清洁 5危险提示 6其他)")
|
||||
private Integer maintainType;
|
||||
|
||||
@Schema(description = "时间范围")
|
||||
private DateTimeRangeSo dateTimeSo;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.MaintainService;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 描述: 维修养护
|
||||
* author: xusan
|
||||
* date: 2024-08-27 15:15:14
|
||||
*/
|
||||
@Mapper
|
||||
public interface MaintainServiceMapper extends BaseMapper<MaintainService> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
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-27 15:15:13
|
||||
*/
|
||||
@Schema(description="维修养护")
|
||||
@Data
|
||||
@TableName("public.maintain_service")
|
||||
public class MaintainService 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="report_time")
|
||||
@Schema(description="上报时间")
|
||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||
private Date reportTime;
|
||||
|
||||
/**
|
||||
* 管护类型(1溢洪道淸障 2除草除杂 3设备养护 4环境清洁 5危险提示 6其他)
|
||||
*/
|
||||
@TableField(value="maintain_type")
|
||||
@Schema(description="管护类型(1溢洪道淸障 2除草除杂 3设备养护 4环境清洁 5危险提示 6其他)")
|
||||
private Integer maintainType;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@TableField(value="maintain_content")
|
||||
@Schema(description="内容")
|
||||
@Size(max = 500,message = "内容最大长度要小于 500")
|
||||
private String maintainContent;
|
||||
|
||||
/**
|
||||
* 上报人id
|
||||
*/
|
||||
@TableField(value="report_user_id")
|
||||
@Schema(description="上报人id")
|
||||
private Long reportUserId;
|
||||
|
||||
/**
|
||||
* 上报人
|
||||
*/
|
||||
@TableField(value="report_user_name")
|
||||
@Schema(description="上报人")
|
||||
@Size(max = 50,message = "上报人最大长度要小于 50")
|
||||
private String reportUserName;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "现场图片")
|
||||
private List<FileAssociations> pics;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "现场视频")
|
||||
private List<FileAssociations> videos;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
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.MaintainPageSo;
|
||||
import com.gunshi.project.xyt.mapper.MaintainServiceMapper;
|
||||
import com.gunshi.project.xyt.model.MaintainService;
|
||||
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.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 描述: 维修养护
|
||||
* author: xusan
|
||||
* date: 2024-08-27 15:15:14
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class MaintainServiceService extends ServiceImpl<MaintainServiceMapper, MaintainService>
|
||||
{
|
||||
@Autowired
|
||||
private FileAssociationsService fileService;
|
||||
|
||||
public MaintainService saveData(MaintainService dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
boolean result = this.save(dto);
|
||||
if (result) {
|
||||
fileService.save(dto.getPics(), dto.getId().toString(), getGroupId(),getPicType());
|
||||
fileService.save(dto.getVideos(), dto.getId().toString(), getGroupId(),getVideoType());
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
private String getVideoType() {
|
||||
return "mainVideo";
|
||||
}
|
||||
|
||||
private String getPicType() {
|
||||
return "mainPic";
|
||||
}
|
||||
|
||||
public MaintainService updateData(MaintainService dto) {
|
||||
if (Objects.isNull(this.getById(dto.getId()))) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
boolean result = this.updateById(dto);
|
||||
if (result) {
|
||||
fileService.removeByBzIdAndType(dto.getId().toString(),getGroupId(),getPicType());
|
||||
fileService.save(dto.getPics(), dto.getId().toString(), getGroupId(),getPicType());
|
||||
fileService.removeByBzIdAndType(dto.getId().toString(),getGroupId(),getVideoType());
|
||||
fileService.save(dto.getVideos(), dto.getId().toString(), getGroupId(),getVideoType());
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
public Boolean delData(Serializable id) {
|
||||
if (Objects.isNull(this.getById(id))) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
boolean data = this.removeById(id);
|
||||
if (data) {
|
||||
fileService.deleteFile(getGroupId(), id.toString());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return "maintainService";
|
||||
}
|
||||
|
||||
public Page<MaintainService> pageQuery(MaintainPageSo page) {
|
||||
LambdaQueryWrapper<MaintainService> query = Wrappers.lambdaQuery();
|
||||
if (ObjectUtils.isNotNull(page.getMaintainType())) {
|
||||
query.eq(MaintainService::getMaintainType, page.getMaintainType());
|
||||
}
|
||||
if (page.getDateTimeSo() != null && page.getDateTimeSo().getStart() != null) {
|
||||
query.ge(MaintainService::getReportTime, page.getDateTimeSo().getStart());
|
||||
}
|
||||
if (page.getDateTimeSo() != null && page.getDateTimeSo().getEnd() != null) {
|
||||
query.le(MaintainService::getReportTime, page.getDateTimeSo().getEnd());
|
||||
}
|
||||
query.orderByDesc(MaintainService::getReportTime);
|
||||
Page<MaintainService> res = this.page(page.getPageSo().toPage(), query);
|
||||
if (res.getRecords() != null) {
|
||||
fillAttach(res.getRecords());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private void fillAttach(List<MaintainService> ret) {
|
||||
for (MaintainService record : ret) {
|
||||
record.setPics(fileService.queryFileList(record.getId().toString(),getGroupId(),getPicType()));
|
||||
record.setVideos(fileService.queryFileList(record.getId().toString(),getGroupId(),getVideoType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue