feat(accident): 添加事件导出功能并优化事故数据管理

- 新增EventExportConvertor转换器和EventExportCO导出对象
- 实现根据eqType区分事故和事件的导出功能
- 优化AccidentRepositoryImpl数据访问层方法
- 更新DTO对象添加departmentId和reportUser字段
- 修改Excel导出样式配置和列宽设置
- 调整查询条件处理逻辑和数据权限控制
- 优化Mapper层SQL查询语句和数据过滤规则
master
fangjiakai 2026-01-08 10:02:10 +08:00
parent 835b51f034
commit e6cd88d54a
15 changed files with 345 additions and 112 deletions

View File

@ -6,10 +6,10 @@ import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.jjb.saas.framework.auth.model.SSOUser;
import com.jjb.saas.framework.auth.utils.AuthContext;
import com.jjb.saas.framework.event.producer.RemoteEventPublisher;
import com.zcloud.accident.api.AccidentServiceI;
import com.zcloud.accident.command.convertor.AccidentExportConvertor;
import com.zcloud.accident.command.convertor.EventExportConvertor;
import com.zcloud.accident.dto.AccidentAddCmd;
import com.zcloud.accident.dto.AccidentCountQry;
import com.zcloud.accident.dto.AccidentPageQry;
@ -17,13 +17,11 @@ import com.zcloud.accident.dto.AccidentUpdateCmd;
import com.zcloud.accident.dto.clientobject.AccidentCO;
import com.zcloud.accident.dto.clientobject.AccidentCountStatCO;
import com.zcloud.accident.dto.clientobject.AccidentExportCO;
import com.zcloud.accident.command.convertor.AccidentExportConvertor;
import com.zcloud.accident.dto.clientobject.EventExportCO;
import com.zcloud.accident.util.ExcelUtils;
import com.zcloud.gbscommon.event.user.ZcUserEvent;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.messaging.MessageChannel;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -47,19 +45,18 @@ import java.util.List;
public class AccidentController {
private final AccidentServiceI accidentService;
private final AccidentExportConvertor accidentExportConvertor;
private final RemoteEventPublisher remoteEventPublisher ;
private final EventExportConvertor eventExportConvertor;
@ApiOperation("新增")
@PostMapping("/save")
public SingleResponse<AccidentCO> add(@Validated @RequestBody AccidentAddCmd cmd) {
cmd.setDepartmentId(AuthContext.getOrgId());
return accidentService.add(cmd);
}
@ApiOperation("分页")
@PostMapping("/list")
public PageResponse<AccidentCO> page(@RequestBody AccidentPageQry qry) {
if(ObjectUtil.isNull(qry.getEqCorpinfoId())){
qry.setEqCorpinfoId(AuthContext.getTenantId());
}
return accidentService.listPage(qry);
}
@ -99,14 +96,26 @@ public class AccidentController {
@ApiOperation("导出Excel")
@GetMapping("/export")
public void export(AccidentPageQry qry, HttpServletResponse response) throws IOException {
if(ObjectUtil.isNull(qry.getEqCorpinfoId())){
qry.setEqCorpinfoId(AuthContext.getTenantId());
}
// 使用listAll方法获取所有符合条件的数据
List<AccidentCO> accidentCOList = accidentService.listAll(qry);
// 转换为导出CO
List<AccidentExportCO> exportCOList = accidentExportConvertor.convertToExportCOList(accidentCOList);
// 生成文件名
String fileName = "事故数据_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
// 调用工具类导出Excel
ExcelUtils.exportExcel(response, AccidentExportCO.class, fileName, exportCOList);
if(qry.getEqType() == 1){
// 转换为导出CO
List<EventExportCO> exportCOList = eventExportConvertor.convertToExportCOList(accidentCOList);
// 生成文件名
String fileName = "事件数据_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
// 调用工具类导出Excel
ExcelUtils.exportExcel(response, EventExportCO.class, fileName, exportCOList);
}else{
// 转换为导出CO
List<AccidentExportCO> exportCOList = accidentExportConvertor.convertToExportCOList(accidentCOList);
// 生成文件名
String fileName = "事故数据_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
// 调用工具类导出Excel
ExcelUtils.exportExcel(response, AccidentExportCO.class, fileName, exportCOList);
}
}
@ApiOperation("按照公司和事故类型统计个数")

View File

@ -0,0 +1,29 @@
package com.zcloud.accident.command.convertor;
import com.zcloud.accident.dto.clientobject.AccidentCO;
import com.zcloud.accident.dto.clientobject.AccidentExportCO;
import com.zcloud.accident.dto.clientobject.EventExportCO;
import org.mapstruct.Mapper;
import java.util.List;
/**
*
*/
@Mapper(componentModel = "spring")
public interface EventExportConvertor {
/**
* AccidentCOAccidentExportCO
* @param accidentCO AccidentCO
* @return AccidentExportCO
*/
EventExportCO convertToExportCO(AccidentCO accidentCO);
/**
* AccidentCOAccidentExportCO
* @param accidentCOList AccidentCO
* @return AccidentExportCO
*/
List<EventExportCO> convertToExportCOList(List<AccidentCO> accidentCOList);
}

View File

@ -49,7 +49,13 @@ public class AccidentQueryExe {
*/
public PageResponse<AccidentCO> execute(AccidentPageQry accidentPageQry) {
Map<String, Object> params = PageQueryHelper.toHashMap(accidentPageQry);
PageResponse<AccidentDO> pageResponse = accidentRepository.listPage(params);
String menuPerms = "";
if(accidentPageQry.getEqType() == 1){
menuPerms = "zcloud-event";
}else{
menuPerms = "zcloud-accident";
}
PageResponse<AccidentDO> pageResponse = accidentRepository.listPage(params,menuPerms);
List<AccidentCO> examCenterCOS = accidentCoConvertor.converDOsToCOs(pageResponse.getData());
return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
}
@ -62,7 +68,13 @@ public class AccidentQueryExe {
*/
public List<AccidentCO> listAll(AccidentPageQry accidentPageQry) {
Map<String, Object> params = PageQueryHelper.toHashMap(accidentPageQry);
List<AccidentDO> accidentDOs = accidentRepository.listAll(params);
String menuPerms = "";
if(accidentPageQry.getEqType() == 1){
menuPerms = "zcloud-event";
}else{
menuPerms = "zcloud-accident";
}
List<AccidentDO> accidentDOs = accidentRepository.listAll(params,menuPerms);
return accidentCoConvertor.converDOsToCOs(accidentDOs);
}
/**

View File

@ -24,9 +24,8 @@ import java.time.LocalDateTime;
@NoArgsConstructor
@AllArgsConstructor
public class AccidentAddCmd extends Command {
@ApiModelProperty(value = "主键", name = "id", required = true)
@NotNull(message = "主键不能为空")
private Long id;
@ApiModelProperty(value = "业务主键id", name = "id", required = true)
private String accidentId;
@ApiModelProperty(value = "事故案号", name = "incidentNumber", required = true)
@NotEmpty(message = "事故案号不能为空")
private String incidentNumber;
@ -42,7 +41,6 @@ public class AccidentAddCmd extends Command {
private String incidentLevel;
private String incidentLevelName;
@ApiModelProperty(value = "事故性质", name = "incidentNature", required = true)
@NotEmpty(message = "事故性质不能为空")
private String incidentNature;
@ApiModelProperty(value = "事故发生地点", name = "location", required = true)
@NotEmpty(message = "事故发生地点不能为空")
@ -52,16 +50,12 @@ public class AccidentAddCmd extends Command {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime incidentDate;
@ApiModelProperty(value = "直接经济损失(万元)", name = "directLoss", required = true)
@NotNull(message = "直接经济损失(万元)不能为空")
private BigDecimal directLoss;
@ApiModelProperty(value = "受伤人数", name = "injured", required = true)
@NotNull(message = "受伤人数不能为空")
private Integer injured;
@ApiModelProperty(value = "死亡人数", name = "fatalities", required = true)
@NotNull(message = "死亡人数不能为空")
private Integer fatalities;
@ApiModelProperty(value = "重伤人数", name = "seriouslyInjured", required = true)
@NotNull(message = "重伤人数不能为空")
private Integer seriouslyInjured;
@ApiModelProperty(value = "事故起因", name = "cause", required = true)
@NotEmpty(message = "事故起因不能为空")
@ -78,6 +72,9 @@ public class AccidentAddCmd extends Command {
@ApiModelProperty(value = "整改措施", name = "measures", required = true)
@NotEmpty(message = "整改措施不能为空")
private String measures;
@ApiModelProperty(value = "填报人", name = "reportUser", required = true)
@NotEmpty(message = "填报人不能为空")
private String reportUser;
@ApiModelProperty(value = "报出日期", name = "reportDate", required = true)
@NotNull(message = "报出日期不能为空")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ -85,5 +82,7 @@ public class AccidentAddCmd extends Command {
@ApiModelProperty(value = "1事件/2事故", name = "type", required = true)
@NotNull(message = "1事件/2事故不能为空")
private Integer type;
@ApiModelProperty(value = "部门id", name = "departmentId")
private Long departmentId;
}

View File

@ -40,13 +40,9 @@ public class AccidentPageQry extends PageQuery {
@ApiModelProperty(value = "事故级别", name = "likeIncidentLevel")
private String eqIncidentLevel;
@ApiModelProperty(value = "开始时间", name = "geIncidentDate")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate geIncidentDate;
private String geIncidentDate;
@ApiModelProperty(value = "结束时间", name = "leIncidentDate")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate leIncidentDate;
private String leIncidentDate;
@ApiModelProperty(value = "类型1事件2事故", name = "eqType")
private Integer eqType;
}

View File

@ -26,69 +26,47 @@ public class AccidentUpdateCmd extends Command {
@NotNull(message = "主键id不能为空")
private Long id;
@ApiModelProperty(value = "事故案号", name = "incidentNumber", required = true)
@NotEmpty(message = "事故案号不能为空")
private String incidentNumber;
@ApiModelProperty(value = "事故名称", name = "incidentName", required = true)
@NotEmpty(message = "事故名称不能为空")
private String incidentName;
@ApiModelProperty(value = "事故类型", name = "incidentType", required = true)
@NotEmpty(message = "事故类型不能为空")
private String incidentType;
@ApiModelProperty(value = "事故类型", name = "incidentTypeName", required = true)
@NotEmpty(message = "事故类型不能为空")
private String incidentTypeName;
@ApiModelProperty(value = "公司id", name = "corpinfoId", required = true)
@NotNull(message = "公司id不能为空")
private Long corpinfoId;
@ApiModelProperty(value = "事故级别", name = "incidentLevel", required = true)
@NotEmpty(message = "事故级别不能为空")
private String incidentLevel;
@ApiModelProperty(value = "事故级别", name = "incidentLevelName", required = true)
@NotEmpty(message = "事故级别不能为空")
private String incidentLevelName;
@ApiModelProperty(value = "事故性质", name = "incidentNature", required = true)
@NotEmpty(message = "事故性质不能为空")
private String incidentNature;
@ApiModelProperty(value = "事故发生地点", name = "location", required = true)
@NotEmpty(message = "事故发生地点不能为空")
private String location;
@ApiModelProperty(value = "事故发生时间", name = "incidentDate", required = true)
@NotNull(message = "事故发生时间不能为空")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime incidentDate;
@ApiModelProperty(value = "直接经济损失(万元)", name = "directLoss", required = true)
@NotNull(message = "直接经济损失(万元)不能为空")
private BigDecimal directLoss;
@ApiModelProperty(value = "受伤人数", name = "injured", required = true)
@NotNull(message = "受伤人数不能为空")
private Integer injured;
@ApiModelProperty(value = "死亡人数", name = "fatalities", required = true)
@NotNull(message = "死亡人数不能为空")
private Integer fatalities;
@ApiModelProperty(value = "重伤人数", name = "seriouslyInjured", required = true)
@NotNull(message = "重伤人数不能为空")
private Integer seriouslyInjured;
@ApiModelProperty(value = "事故起因", name = "cause", required = true)
@NotEmpty(message = "事故起因不能为空")
private String cause;
@ApiModelProperty(value = "事故概述", name = "summary", required = true)
@NotEmpty(message = "事故概述不能为空")
private String summary;
@ApiModelProperty(value = "原因分析及责任认定", name = "analysis", required = true)
@NotEmpty(message = "原因分析及责任认定不能为空")
private String analysis;
@ApiModelProperty(value = "考核建议", name = "suggestions", required = true)
@NotEmpty(message = "考核建议不能为空")
private String suggestions;
@ApiModelProperty(value = "整改措施", name = "measures", required = true)
@NotEmpty(message = "整改措施不能为空")
private String measures;
@ApiModelProperty(value = "填报人", name = "reportUser", required = true)
@NotEmpty(message = "填报人不能为空")
private String reportUser;
@ApiModelProperty(value = "报出日期", name = "reportDate", required = true)
@NotNull(message = "报出日期不能为空")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime reportDate;
@ApiModelProperty(value = "1事件/2事故", name = "type", required = true)
@NotNull(message = "1事件/2事故不能为空")
private Integer type;
}

View File

@ -6,6 +6,7 @@ import com.jjb.saas.framework.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@ -85,8 +86,11 @@ public class AccidentCO extends ClientObject {
//整改措施
@ApiModelProperty(value = "整改措施")
private String measures;
@ApiModelProperty(value = "填报人")
private String reportUser;
//报出日期
@ApiModelProperty(value = "报出日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime reportDate;
//1事件/2事故
@ApiModelProperty(value = "1事件/2事故")

View File

@ -2,6 +2,7 @@ package com.zcloud.accident.dto.clientobject;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -15,77 +16,90 @@ import java.time.LocalDateTime;
@Data
public class AccidentExportCO {
@ApiModelProperty(value = "所属公司")
@ExcelProperty(value = "所属公司", index = 0)
@ColumnWidth(20)
private String corpinfoName;
@ApiModelProperty(value = "事故案号")
@ExcelProperty(value = "事故案号", index = 0)
@ExcelProperty(value = "事故案号", index = 1)
@ColumnWidth(20)
private String incidentNumber;
@ApiModelProperty(value = "事故名称")
@ExcelProperty(value = "事故名称", index = 1)
@ExcelProperty(value = "事故名称", index = 2)
@ColumnWidth(20)
private String incidentName;
@ApiModelProperty(value = "事故类型")
@ExcelProperty(value = "事故类型", index = 2)
@ExcelProperty(value = "事故类型", index = 3)
@ColumnWidth(20)
private String incidentTypeName;
@ApiModelProperty(value = "公司")
@ExcelProperty(value = "公司", index = 3)
private String corpinfoName;
@ApiModelProperty(value = "事故级别")
@ExcelProperty(value = "事故级别", index = 4)
@ColumnWidth(20)
private String incidentLevelName;
@ApiModelProperty(value = "事故性质")
@ExcelProperty(value = "事故性质", index = 5)
private String incidentNature;
@ApiModelProperty(value = "事故发生地点")
@ExcelProperty(value = "事故发生地点", index = 6)
@ExcelProperty(value = "事故发生地点", index = 5)
@ColumnWidth(20)
private String location;
@ApiModelProperty(value = "事故发生时间")
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "事故发生时间", index = 7)
@ExcelProperty(value = "事故发生时间", index = 6)
@ColumnWidth(20)
private LocalDateTime incidentDate;
@ApiModelProperty(value = "直接经济损失(万元)")
@ExcelProperty(value = "直接经济损失(万元)", index = 8)
@ExcelProperty(value = "直接经济损失(万元)", index = 7)
@ColumnWidth(20)
private BigDecimal directLoss;
@ApiModelProperty(value = "受伤人数")
@ExcelProperty(value = "受伤人数", index = 9)
@ExcelProperty(value = "受伤人数", index = 8)
@ColumnWidth(20)
private Integer injured;
@ApiModelProperty(value = "死亡人数")
@ExcelProperty(value = "死亡人数", index = 10)
@ExcelProperty(value = "死亡人数", index = 9)
@ColumnWidth(20)
private Integer fatalities;
@ApiModelProperty(value = "重伤人数")
@ExcelProperty(value = "重伤人数", index = 11)
@ExcelProperty(value = "重伤人数", index = 10)
@ColumnWidth(20)
private Integer seriouslyInjured;
@ApiModelProperty(value = "事故起因")
@ExcelProperty(value = "事故起因", index = 12)
@ExcelProperty(value = "事故起因", index = 11)
@ColumnWidth(20)
private String cause;
@ApiModelProperty(value = "事故概述")
@ExcelProperty(value = "事故概述", index = 13)
@ExcelProperty(value = "事故概述", index = 12)
@ColumnWidth(20)
private String summary;
@ApiModelProperty(value = "原因分析及责任认定")
@ExcelProperty(value = "原因分析及责任认定", index = 14)
@ExcelProperty(value = "原因分析及责任认定", index = 13)
@ColumnWidth(20)
private String analysis;
@ApiModelProperty(value = "考核建议")
@ExcelProperty(value = "考核建议", index = 15)
@ExcelProperty(value = "考核建议", index = 14)
@ColumnWidth(20)
private String suggestions;
@ApiModelProperty(value = "整改措施")
@ExcelProperty(value = "整改措施", index = 16)
@ExcelProperty(value = "整改措施", index = 15)
@ColumnWidth(20)
private String measures;
@ApiModelProperty(value = "报出日期")
@ExcelProperty(value = "报出日期", index = 17)
@ExcelProperty(value = "报出日期", index = 16)
@ColumnWidth(20)
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
private LocalDateTime reportDate;

View File

@ -0,0 +1,107 @@
package com.zcloud.accident.dto.clientobject;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
*
* Excel
*/
@Data
public class EventExportCO {
@ApiModelProperty(value = "所属公司")
@ExcelProperty(value = "所属公司", index = 0)
@ColumnWidth(20)
private String corpinfoName;
@ApiModelProperty(value = "事件案号")
@ExcelProperty(value = "事件案号", index = 1)
@ColumnWidth(20)
private String incidentNumber;
@ApiModelProperty(value = "事件名称")
@ExcelProperty(value = "事件名称", index = 2)
@ColumnWidth(20)
private String incidentName;
@ApiModelProperty(value = "事件类型")
@ExcelProperty(value = "事件类型", index = 3)
@ColumnWidth(20)
private String incidentTypeName;
@ApiModelProperty(value = "事件级别")
@ExcelProperty(value = "事件级别", index = 4)
@ColumnWidth(20)
private String incidentLevelName;
@ApiModelProperty(value = "事件发生地点")
@ExcelProperty(value = "事件发生地点", index = 5)
@ColumnWidth(20)
private String location;
@ApiModelProperty(value = "事件发生时间")
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@ExcelProperty(value = "事件发生时间", index = 6)
@ColumnWidth(20)
private LocalDateTime incidentDate;
@ApiModelProperty(value = "直接经济损失(万元)")
@ExcelProperty(value = "直接经济损失(万元)", index = 7)
@ColumnWidth(20)
private BigDecimal directLoss;
@ApiModelProperty(value = "受伤人数")
@ExcelProperty(value = "受伤人数", index = 8)
@ColumnWidth(20)
private Integer injured;
@ApiModelProperty(value = "死亡人数")
@ExcelProperty(value = "死亡人数", index = 9)
@ColumnWidth(20)
private Integer fatalities;
@ApiModelProperty(value = "重伤人数")
@ExcelProperty(value = "重伤人数", index = 10)
@ColumnWidth(20)
private Integer seriouslyInjured;
@ApiModelProperty(value = "事件起因")
@ExcelProperty(value = "事件起因", index = 11)
@ColumnWidth(20)
private String cause;
@ApiModelProperty(value = "事件概述")
@ExcelProperty(value = "事件概述", index = 12)
@ColumnWidth(20)
private String summary;
@ApiModelProperty(value = "原因分析及责任认定")
@ExcelProperty(value = "原因分析及责任认定", index = 13)
@ColumnWidth(20)
private String analysis;
@ApiModelProperty(value = "考核建议")
@ExcelProperty(value = "考核建议", index = 14)
@ColumnWidth(20)
private String suggestions;
@ApiModelProperty(value = "整改措施")
@ExcelProperty(value = "整改措施", index = 15)
@ColumnWidth(20)
private String measures;
@ApiModelProperty(value = "报出日期")
@ExcelProperty(value = "报出日期", index = 16)
@ColumnWidth(20)
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
private LocalDateTime reportDate;
}

View File

@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@ -17,7 +18,7 @@ import java.time.LocalDateTime;
@Data
public class AccidentE extends BaseE {
//主键id
private Long id;
private String accidentId;
//事故案号
private String incidentNumber;
//事故名称
@ -54,9 +55,13 @@ public class AccidentE extends BaseE {
private String suggestions;
//整改措施
private String measures;
//填报人
private String reportUser;
//报出日期
private LocalDateTime reportDate;
//1事件/2事故
private Integer type;
//部门id
private Long departmentId;
}

View File

@ -8,6 +8,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
import java.sql.Date;
import java.time.LocalDateTime;
@ -86,6 +87,8 @@ public class AccidentDO extends BaseDO {
//整改措施
@ApiModelProperty(value = "整改措施")
private String measures;
@ApiModelProperty(value = "填报人")
private String reportUser;
//报出日期
@ApiModelProperty(value = "报出日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ -93,6 +96,8 @@ public class AccidentDO extends BaseDO {
//1事件/2事故
@ApiModelProperty(value = "1事件/2事故")
private Integer type;
@ApiModelProperty(value = "部门id")
private Long departmentId;
public AccidentDO(String accidentId) {
this.accidentId = accidentId;

View File

@ -1,19 +1,27 @@
package com.zcloud.accident.persistence.mapper;
import com.zcloud.accident.persistence.dataobject.AccidentDO;
import com.zcloud.accident.domain.model.AccidentCountStat;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jjb.saas.framework.datascope.annotation.DataScope;
import com.jjb.saas.framework.datascope.annotation.DataScopes;
import com.zcloud.accident.domain.model.AccidentCountStat;
import com.zcloud.accident.persistence.dataobject.AccidentDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* web-infrastructure
* @Author fangjiakai
* @Date 2025-10-29 14:28:43
*/
* web-infrastructure
*
* @Author fangjiakai
* @Date 2025-10-29 14:28:43
*/
@Mapper
@DataScopes({
@DataScope(method = "listPage", menuPerms = ""),
@DataScope(method = "list", menuPerms = "")})
public interface AccidentMapper extends BaseMapper<AccidentDO> {
/**
@ -23,6 +31,10 @@ public interface AccidentMapper extends BaseMapper<AccidentDO> {
* @param eqAccidentType
* @return corpinfoIdincidentTypecount
*/
List<AccidentCountStat> countByCorpinfoIdAndIncidentType(@Param("corpinfoIds") List<String> corpinfoIds,@Param("eqAccidentType") Integer eqAccidentType);
List<AccidentCountStat> countByCorpinfoIdAndIncidentType(@Param("corpinfoIds") List<String> corpinfoIds, @Param("eqAccidentType") Integer eqAccidentType);
IPage<AccidentDO> listPage(IPage<AccidentDO> iPage, @Param("params") Map<String, Object> params,String menuPerms);
List<AccidentDO> list(@Param("params") Map<String, Object> params, String menuPerms);
}

View File

@ -15,14 +15,16 @@ import java.util.Map;
* @Date 2025-10-29 14:28:45
*/
public interface AccidentRepository extends BaseRepository<AccidentDO> {
PageResponse<AccidentDO> listPage(Map<String,Object> params);
PageResponse<AccidentDO> listPage(Map<String,Object> params,String menuPerms);
/**
*
* @param params
*
* @param params
* @param menuPerms
* @return
*/
List<AccidentDO> listAll(Map<String,Object> params);
List<AccidentDO> listAll(Map<String,Object> params,String menuPerms);
/**
* corpinfoIdincidentType

View File

@ -1,52 +1,48 @@
package com.zcloud.accident.persistence.repository.impl;
import com.jjb.saas.framework.repository.common.PageHelper;
import com.zcloud.accident.persistence.dataobject.AccidentDO;
import com.zcloud.accident.domain.model.AccidentCountStat;
import com.zcloud.accident.persistence.mapper.AccidentMapper;
import com.zcloud.accident.persistence.repository.AccidentRepository;
import com.alibaba.cola.dto.PageResponse;
import com.zcloud.gbscommon.utils.PageQueryHelper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jjb.saas.framework.repository.common.PageHelper;
import com.jjb.saas.framework.repository.repo.impl.BaseRepositoryImpl;
import com.zcloud.accident.domain.model.AccidentCountStat;
import com.zcloud.accident.persistence.dataobject.AccidentDO;
import com.zcloud.accident.persistence.mapper.AccidentMapper;
import com.zcloud.accident.persistence.repository.AccidentRepository;
import com.zcloud.gbscommon.utils.PageQueryHelper;
import com.zcloud.gbscommon.utils.Query;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* web-infrastructure
* @Author fangjiakai
* @Date 2025-10-29 14:28:49
*/
* web-infrastructure
*
* @Author fangjiakai
* @Date 2025-10-29 14:28:49
*/
@Service
@RequiredArgsConstructor
public class AccidentRepositoryImpl extends BaseRepositoryImpl<AccidentMapper, AccidentDO> implements AccidentRepository {
private final AccidentMapper accidentMapper;
@Override
public PageResponse<AccidentDO> listPage(Map<String,Object> params) {
IPage<AccidentDO> iPage = new Query<AccidentDO>().getPage(params);
QueryWrapper<AccidentDO> queryWrapper = new QueryWrapper<>();
queryWrapper = PageQueryHelper.createPageQueryWrapper(queryWrapper, params);
queryWrapper.orderByDesc("create_time");
IPage<AccidentDO> result = accidentMapper.selectPage(iPage, queryWrapper);
public PageResponse<AccidentDO> listPage(Map<String, Object> params,String menuPerms) {
IPage<AccidentDO> iPage = new Query<AccidentDO>().getPage(params);
IPage<AccidentDO> result = accidentMapper.listPage(iPage, params,menuPerms);
return PageHelper.pageToResponse(result, result.getRecords());
}
@Override
public List<AccidentDO> listAll(Map<String,Object> params) {
QueryWrapper<AccidentDO> queryWrapper = new QueryWrapper<>();
queryWrapper = PageQueryHelper.createPageQueryWrapper(queryWrapper, params);
queryWrapper.orderByDesc("create_time");
return accidentMapper.selectList(queryWrapper);
public List<AccidentDO> listAll(Map<String, Object> params, String menuPerms) {
return accidentMapper.list(params, menuPerms);
}
@Override
public List<AccidentCountStat> countByCorpinfoIdAndIncidentType(List<String> corpinfoIds, Integer eqAccidentType) {
return accidentMapper.countByCorpinfoIdAndIncidentType(corpinfoIds,eqAccidentType);
return accidentMapper.countByCorpinfoIdAndIncidentType(corpinfoIds, eqAccidentType);
}
}

View File

@ -4,6 +4,70 @@
<mapper namespace="com.zcloud.accident.persistence.mapper.AccidentMapper">
<select id="listPage" resultType="com.zcloud.accident.persistence.dataobject.AccidentDO">
select * from accident
<where>
and delete_enum = 'FALSE'
<if test="params.eqCorpinfoId != null">
and tenant_id = #{params.eqCorpinfoId}
</if>
<if test="params.likeIncidentName != null and params.likeIncidentName != ''" >
and incident_name like concat('%',#{params.likeIncidentName},'%')
</if>
<if test="params.likeLocation != null and params.likeLocation != ''">
and location like concat('%',#{params.likeLocation},'%')
</if>
<if test="params.eqIncidentType != null and params.eqIncidentType != ''">
and incident_type = #{params.eqIncidentType}
</if>
<if test="params.eqIncidentLevel != null and params.eqIncidentLevel != ''">
and incident_level = #{params.eqIncidentLevel}
</if>
<if test="params.geIncidentDate != null and params.geIncidentDate != ''">
and incident_date &gt;= #{params.geIncidentDate}
</if>
<if test="params.leIncidentDate != null and params.leIncidentDate != ''">
and incident_date &lt;= #{params.leIncidentDate}
</if>
<if test="params.eqType != null">
and type = #{params.eqType}
</if>
</where>
order by create_time desc
</select>
<select id="list" resultType="com.zcloud.accident.persistence.dataobject.AccidentDO">
select * from accident
<where>
and delete_enum = 'FALSE'
<if test="params.eqCorpinfoId != null">
and tenant_id = #{params.eqCorpinfoId}
</if>
<if test="params.likeIncidentName != null and params.likeIncidentName != ''" >
and incident_name like concat('%',#{params.likeIncidentName},'%')
</if>
<if test="params.likeLocation != null and params.likeLocation != ''">
and location like concat('%',#{params.likeLocation},'%')
</if>
<if test="params.eqIncidentType != null and params.eqIncidentType != ''">
and incident_type = #{params.eqIncidentType}
</if>
<if test="params.eqIncidentLevel != null and params.eqIncidentLevel != ''">
and incident_level = #{params.eqIncidentLevel}
</if>
<if test="params.geIncidentDate != null and params.geIncidentDate != ''">
and incident_date &gt;= #{params.geIncidentDate}
</if>
<if test="params.leIncidentDate != null and params.leIncidentDate != ''">
and incident_date &lt;= #{params.leIncidentDate}
</if>
<if test="params.eqType != null">
and type = #{params.eqType}
</if>
</where>
order by create_time desc
</select>
<select id="countByCorpinfoIdAndIncidentType" resultType="com.zcloud.accident.domain.model.AccidentCountStat">
SELECT
corpinfo_id,
@ -11,6 +75,7 @@
COUNT(*) as count
from accident
<where>
and delete_enum = 'FALSE'
<if test="eqAccidentType != null ">
AND type = #{eqAccidentType}
</if>