安全鉴定台账
parent
febce56f5c
commit
338c704529
|
|
@ -0,0 +1,62 @@
|
|||
package com.gunshi.project.xyt.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import com.gunshi.project.xyt.model.SafetyIdentify;
|
||||
import com.gunshi.project.xyt.service.SafetyIdentifyService;
|
||||
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-21 14:45:44
|
||||
*/
|
||||
@Tag(name = "安全鉴定台账")
|
||||
@RestController
|
||||
@RequestMapping(value="/safety/identify")
|
||||
public class SafetyIdentifyController extends AbstractCommonFileController {
|
||||
|
||||
@Autowired
|
||||
private SafetyIdentifyService service;
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<SafetyIdentify> insert(@Validated(Insert.class) @RequestBody SafetyIdentify dto) {
|
||||
return R.ok(service.saveData(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<SafetyIdentify> update(@Validated(Update.class) @RequestBody SafetyIdentify 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("/page")
|
||||
public R<Page<SafetyIdentify>> page(@RequestBody PageSo page) {
|
||||
return R.ok(service.pageQuery(page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupId() {
|
||||
return "safetyIdentify";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.SafetyIdentify;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 描述: 安全鉴定台账
|
||||
* author: xusan
|
||||
* date: 2024-08-21 14:45:44
|
||||
*/
|
||||
@Mapper
|
||||
public interface SafetyIdentifyMapper extends BaseMapper<SafetyIdentify> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
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-21 14:45:43
|
||||
*/
|
||||
@Schema(description="安全鉴定台账")
|
||||
@Data
|
||||
@TableName("public.safety_identify")
|
||||
public class SafetyIdentify 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="identify_date")
|
||||
@Schema(description="鉴定日期")
|
||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD, timezone = "GMT+8")
|
||||
private Date identifyDate;
|
||||
|
||||
/**
|
||||
* 大坝安全评定类别(1一类坝 2二类坝 3三类坝)
|
||||
*/
|
||||
@TableField(value="identify_type")
|
||||
@Schema(description="大坝安全评定类别(1一类坝 2二类坝 3三类坝)")
|
||||
private Integer identifyType;
|
||||
|
||||
/**
|
||||
* 鉴定承担单位(1勘察设计2工程咨询3部门认定)
|
||||
*/
|
||||
@TableField(value="identify_org")
|
||||
@Schema(description="鉴定承担单位")
|
||||
@Size(max = 200,message = "鉴定承担单位最大长度要小于 200")
|
||||
private String identifyOrg;
|
||||
|
||||
/**
|
||||
* 承担单位类型(1甲级2乙级3丙级4其他)
|
||||
*/
|
||||
@TableField(value="identify_org_type")
|
||||
@Schema(description="承担单位类型(1勘察设计2工程咨询3部门认定)")
|
||||
private Integer identifyOrgType;
|
||||
|
||||
/**
|
||||
* 承担单位资质
|
||||
*/
|
||||
@TableField(value="identify_org_qua")
|
||||
@Schema(description="承担单位资质(1甲级2乙级3丙级4其他)")
|
||||
private Integer identifyOrgQua;
|
||||
|
||||
/**
|
||||
* 鉴定审定部门
|
||||
*/
|
||||
@TableField(value="identify_audit_org")
|
||||
@Schema(description="鉴定审定部门")
|
||||
@Size(max = 200,message = "鉴定审定部门最大长度要小于 200")
|
||||
private String identifyAuditOrg;
|
||||
|
||||
/**
|
||||
* 报告书印发日期
|
||||
*/
|
||||
@TableField(value="report_print_date")
|
||||
@Schema(description="报告书印发日期")
|
||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD, timezone = "GMT+8")
|
||||
private Date reportPrintDate;
|
||||
|
||||
/**
|
||||
* 报告书印发文号
|
||||
*/
|
||||
@TableField(value="report_print_number")
|
||||
@Schema(description="报告书印发文号")
|
||||
@Size(max = 100,message = "报告书印发文号最大长度要小于 100")
|
||||
private String reportPrintNumber;
|
||||
|
||||
/**
|
||||
* 工程存在主要问题
|
||||
*/
|
||||
@TableField(value="main_problem")
|
||||
@Schema(description="工程存在主要问题")
|
||||
@Size(max = 500,message = "工程存在主要问题最大长度要小于 500")
|
||||
private String mainProblem;
|
||||
|
||||
/**
|
||||
* 安全鉴定结论
|
||||
*/
|
||||
@TableField(value="identify_result")
|
||||
@Schema(description="安全鉴定结论")
|
||||
@Size(max = 500,message = "安全鉴定结论最大长度要小于 500")
|
||||
private String identifyResult;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "文件集合")
|
||||
private List<FileAssociations> files;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
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.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import com.gunshi.project.xyt.mapper.SafetyIdentifyMapper;
|
||||
import com.gunshi.project.xyt.model.SafetyIdentify;
|
||||
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-21 14:45:44
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SafetyIdentifyService extends ServiceImpl<SafetyIdentifyMapper, SafetyIdentify>
|
||||
{
|
||||
|
||||
@Autowired
|
||||
private FileAssociationsService fileService;
|
||||
|
||||
public Page<SafetyIdentify> pageQuery(PageSo page) {
|
||||
LambdaQueryWrapper<SafetyIdentify> query = Wrappers.lambdaQuery();
|
||||
query.orderByDesc(SafetyIdentify::getIdentifyDate);
|
||||
Page<SafetyIdentify> res = this.page(page.toPage(), query);
|
||||
if (res.getRecords() != null) {
|
||||
fillAttach(res.getRecords());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private void fillAttach(List<SafetyIdentify> ret) {
|
||||
for (SafetyIdentify record : ret) {
|
||||
record.setFiles(fileService.getFiles(getGroupId(), String.valueOf(record.getId())));
|
||||
}
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return "safetyIdentify";
|
||||
}
|
||||
|
||||
public SafetyIdentify saveData(SafetyIdentify dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
boolean result = this.save(dto);
|
||||
if (result) {
|
||||
fileService.saveFile(dto.getFiles(), getGroupId(), String.valueOf(dto.getId()));
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
public SafetyIdentify updateData(SafetyIdentify dto) {
|
||||
if (Objects.isNull(this.getById(dto.getId()))) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
boolean result = this.updateById(dto);
|
||||
if (result) {
|
||||
fileService.saveFile(dto.getFiles(), getGroupId(), String.valueOf(dto.getId()));
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue