package cn.iocoder.yudao.module.mes.dal.mysql.safety; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.hazard.SafetyHazardPageReqVO; import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyHazardDO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.util.List; /** * 安全生产 - 隐患 Mapper * * @author 超级管理员 */ @Mapper public interface SafetyHazardMapper extends BaseMapperX { default PageResult selectPage(SafetyHazardPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .likeIfPresent(SafetyHazardDO::getCode, reqVO.getCode()) .likeIfPresent(SafetyHazardDO::getTitle, reqVO.getTitle()) .eqIfPresent(SafetyHazardDO::getLevel, reqVO.getLevel()) .eqIfPresent(SafetyHazardDO::getSource, reqVO.getSource()) .eqIfPresent(SafetyHazardDO::getStatus, reqVO.getStatus()) .likeIfPresent(SafetyHazardDO::getAssignee, reqVO.getAssignee()) .likeIfPresent(SafetyHazardDO::getLocation, reqVO.getLocation()) .geIfPresent(SafetyHazardDO::getReportTime, reqVO.getReportTimeStart()) .leIfPresent(SafetyHazardDO::getReportTime, reqVO.getReportTimeEnd()) .orderByDesc(SafetyHazardDO::getReportTime) .orderByDesc(SafetyHazardDO::getId)); } /** 超过整改期限且未闭环的隐患 */ default List selectOverdue(java.time.LocalDate today) { return selectList(new LambdaQueryWrapperX() .lt(SafetyHazardDO::getRectifyDeadline, today) .notIn(SafetyHazardDO::getStatus, "CLOSED") .orderByAsc(SafetyHazardDO::getRectifyDeadline)); } /** 生成隐患编号:HZ + yyyyMMdd + 4 位流水 */ @Select("SELECT CONCAT(#{prefix}, LPAD(COUNT(*) + 1, 4, '0')) FROM safety_hazard WHERE code LIKE CONCAT(#{prefix}, '%')") String selectNextCode(@Param("prefix") String prefix); }