安全事故登记
parent
338c704529
commit
25af0f1205
|
|
@ -0,0 +1,63 @@
|
||||||
|
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.CommonDataPageSo;
|
||||||
|
import com.gunshi.project.xyt.model.SafetyAccidentReg;
|
||||||
|
import com.gunshi.project.xyt.service.SafetyAccidentRegService;
|
||||||
|
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/accident/reg")
|
||||||
|
public class SafetyAccidentRegController extends AbstractCommonFileController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SafetyAccidentRegService service;
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(summary = "新增")
|
||||||
|
@PostMapping("/insert")
|
||||||
|
public R<SafetyAccidentReg> insert(@Validated(Insert.class) @RequestBody SafetyAccidentReg dto) {
|
||||||
|
return R.ok(service.saveData(dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "修改")
|
||||||
|
@PostMapping("/update")
|
||||||
|
public R<SafetyAccidentReg> update(@Validated(Update.class) @RequestBody SafetyAccidentReg 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<SafetyAccidentReg>> page(@RequestBody CommonDataPageSo page) {
|
||||||
|
return R.ok(service.pageQuery(page));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGroupId() {
|
||||||
|
return "safetyAccidentReg";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -17,11 +17,11 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述: 安排隐患排查
|
* 描述: 安全隐患排查
|
||||||
* author: wanyan
|
* author: wanyan
|
||||||
* date: 2024-08-20 17:40:37
|
* date: 2024-08-20 17:40:37
|
||||||
*/
|
*/
|
||||||
@Tag(name = "安排隐患排查")
|
@Tag(name = "安全隐患排查")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value="/safety/hazard/invest")
|
@RequestMapping(value="/safety/hazard/invest")
|
||||||
public class SafetyHazardInvestController extends AbstractCommonFileController{
|
public class SafetyHazardInvestController extends AbstractCommonFileController{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.gunshi.project.xyt.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gunshi.project.xyt.model.SafetyAccidentReg;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述: 安全事故登记
|
||||||
|
* author: xusan
|
||||||
|
* date: 2024-08-21 15:44:55
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SafetyAccidentRegMapper extends BaseMapper<SafetyAccidentReg> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,137 @@
|
||||||
|
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.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述: 安全事故登记
|
||||||
|
* author: xusan
|
||||||
|
* date: 2024-08-21 15:44:54
|
||||||
|
*/
|
||||||
|
@Schema(description="安全事故登记")
|
||||||
|
@Data
|
||||||
|
@TableName("public.safety_accident_reg")
|
||||||
|
public class SafetyAccidentReg 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 = 200,message = "事故名称最大长度要小于 200")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事故发生时间
|
||||||
|
*/
|
||||||
|
@TableField(value="accident_date")
|
||||||
|
@Schema(description="事故发生时间")
|
||||||
|
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM, timezone = "GMT+8")
|
||||||
|
private Date accidentDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事故级别(1一般事故2较大事故3重大事故4特别重大事故)
|
||||||
|
*/
|
||||||
|
@TableField(value="accident_level")
|
||||||
|
@Schema(description="事故级别(1一般事故2较大事故3重大事故4特别重大事故)")
|
||||||
|
private Integer accidentLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事故情况描述
|
||||||
|
*/
|
||||||
|
@TableField(value="accident_desc")
|
||||||
|
@Schema(description="事故情况描述")
|
||||||
|
@Size(max = 500,message = "事故情况描述最大长度要小于 500")
|
||||||
|
private String accidentDesc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 直接经济损失(万元)
|
||||||
|
*/
|
||||||
|
@TableField(value="economic_losses")
|
||||||
|
@Schema(description="直接经济损失(万元)")
|
||||||
|
private BigDecimal economicLosses;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 死亡人数
|
||||||
|
*/
|
||||||
|
@TableField(value="dead_number")
|
||||||
|
@Schema(description="死亡人数")
|
||||||
|
private Integer deadNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 受伤人数
|
||||||
|
*/
|
||||||
|
@TableField(value="injure_number")
|
||||||
|
@Schema(description="受伤人数")
|
||||||
|
private Integer injureNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事故调查单位
|
||||||
|
*/
|
||||||
|
@TableField(value="invest_org")
|
||||||
|
@Schema(description="事故调查单位")
|
||||||
|
@Size(max = 200,message = "事故调查单位最大长度要小于 200")
|
||||||
|
private String investOrg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事故结案日期
|
||||||
|
*/
|
||||||
|
@TableField(value="close_case_date")
|
||||||
|
@Schema(description="事故结案日期")
|
||||||
|
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD, timezone = "GMT+8")
|
||||||
|
private Date closeCaseDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事故调查情况
|
||||||
|
*/
|
||||||
|
@TableField(value="invest_desc")
|
||||||
|
@Schema(description="事故调查情况")
|
||||||
|
@Size(max = 500,message = "事故调查情况最大长度要小于 500")
|
||||||
|
private String investDesc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理结果
|
||||||
|
*/
|
||||||
|
@TableField(value="handle_result")
|
||||||
|
@Schema(description="处理结果")
|
||||||
|
@Size(max = 500,message = "处理结果最大长度要小于 500")
|
||||||
|
private String handleResult;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "现场图片")
|
||||||
|
private List<FileAssociations> accidentPic;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "事故调查与处理资料")
|
||||||
|
private List<FileAssociations> accidentHandle;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
package com.gunshi.project.xyt.service;
|
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.IdWorker;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.gunshi.project.xyt.mapper.FileAssociationsMapper;
|
import com.gunshi.project.xyt.mapper.FileAssociationsMapper;
|
||||||
import com.gunshi.project.xyt.model.FileAssociations;
|
import com.gunshi.project.xyt.model.FileAssociations;
|
||||||
|
|
@ -147,4 +150,28 @@ public class FileAssociationsService extends ServiceImpl<FileAssociationsMapper,
|
||||||
return this.baseMapper.getFiles(tName,bId);
|
return this.baseMapper.getFiles(tName,bId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void save(List<FileAssociations> attachList,String businessId, String tableName,String type) {
|
||||||
|
if (attachList != null && !attachList.isEmpty()) {
|
||||||
|
for (FileAssociations attach : attachList) {
|
||||||
|
attach.setId(IdWorker.getId());
|
||||||
|
attach.setBusinessId(businessId);
|
||||||
|
attach.setTableName(tableName);
|
||||||
|
attach.setType(type);
|
||||||
|
}
|
||||||
|
this.saveBatch(attachList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeByBzIdAndType(String businessId, String tableName,String type) {
|
||||||
|
return this.remove(new QueryWrapper<FileAssociations>().eq("business_id", businessId).eq("table_name", tableName).eq("type",type));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FileAssociations> queryFileList(String businessId, String tableName,String type) {
|
||||||
|
LambdaQueryWrapper<FileAssociations> queryWrapper = Wrappers.lambdaQuery();
|
||||||
|
queryWrapper.eq(FileAssociations::getBusinessId,businessId)
|
||||||
|
.eq(FileAssociations::getTableName,tableName)
|
||||||
|
.eq(FileAssociations::getType,type);
|
||||||
|
return this.list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,109 @@
|
||||||
|
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.CommonDataPageSo;
|
||||||
|
import com.gunshi.project.xyt.mapper.SafetyAccidentRegMapper;
|
||||||
|
import com.gunshi.project.xyt.model.SafetyAccidentReg;
|
||||||
|
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 15:44:55
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class SafetyAccidentRegService extends ServiceImpl<SafetyAccidentRegMapper, SafetyAccidentReg>
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private FileAssociationsService fileService;
|
||||||
|
|
||||||
|
public Page<SafetyAccidentReg> pageQuery(CommonDataPageSo page) {
|
||||||
|
LambdaQueryWrapper<SafetyAccidentReg> query = Wrappers.lambdaQuery();
|
||||||
|
if (ObjectUtils.isNotNull(page.getName())) {
|
||||||
|
query.like(SafetyAccidentReg::getName, page.getName());
|
||||||
|
}
|
||||||
|
if (page.getDateSo() != null && page.getDateSo().getStart() != null) {
|
||||||
|
query.ge(SafetyAccidentReg::getAccidentDate, page.getDateSo().getStart());
|
||||||
|
}
|
||||||
|
if (page.getDateSo() != null && page.getDateSo().getEnd() != null) {
|
||||||
|
query.le(SafetyAccidentReg::getAccidentDate, page.getDateSo().getEnd());
|
||||||
|
}
|
||||||
|
query.orderByDesc(SafetyAccidentReg::getAccidentDate);
|
||||||
|
Page<SafetyAccidentReg> res = this.page(page.getPageSo().toPage(), query);
|
||||||
|
if (res.getRecords() != null) {
|
||||||
|
fillAttach(res.getRecords());
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillAttach(List<SafetyAccidentReg> ret) {
|
||||||
|
for (SafetyAccidentReg record : ret) {
|
||||||
|
record.setAccidentPic(fileService.queryFileList(record.getId().toString(),getGroupId(),getPicType()));
|
||||||
|
record.setAccidentHandle(fileService.queryFileList(record.getId().toString(),getGroupId(),getHandleType()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupId() {
|
||||||
|
return "safetyAccidentReg";
|
||||||
|
}
|
||||||
|
|
||||||
|
public SafetyAccidentReg saveData(SafetyAccidentReg dto) {
|
||||||
|
dto.setId(IdWorker.getId());
|
||||||
|
boolean result = this.save(dto);
|
||||||
|
if (result) {
|
||||||
|
fileService.save(dto.getAccidentPic(), dto.getId().toString(), getGroupId(),getPicType());
|
||||||
|
fileService.save(dto.getAccidentHandle(), dto.getId().toString(), getGroupId(),getHandleType());
|
||||||
|
}
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getHandleType() {
|
||||||
|
return "accidentHandle";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPicType() {
|
||||||
|
return "accidentPic";
|
||||||
|
}
|
||||||
|
|
||||||
|
public SafetyAccidentReg updateData(SafetyAccidentReg 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.getAccidentPic(), dto.getId().toString(), getGroupId(),getPicType());
|
||||||
|
fileService.removeByBzIdAndType(dto.getId().toString(),getGroupId(),getHandleType());
|
||||||
|
fileService.save(dto.getAccidentHandle(), dto.getId().toString(), getGroupId(),getHandleType());
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述: 安排隐患排查
|
* 描述: 安全隐患排查
|
||||||
* author: wanyan
|
* author: wanyan
|
||||||
* date: 2024-08-21 10:40:37
|
* date: 2024-08-21 10:40:37
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue