Newer
Older
casic-metering-biz-xichang / casic-metering-dao / src / main / resources / mapper / equipment / BizEquipmentStandardInfoMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.casic.missiles.mapper.equipment.BizEquipmentStandardInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.casic.missiles.model.equipment.BizEquipmentStandardInfo">
        <id column="id" property="id" />
        <result column="standard_no" property="standardNo" />
        <result column="standard_name" property="standardName" />
        <result column="storage_location" property="storageLocation" />
        <result column="major" property="major" />
        <result column="build_standard_id" property="buildStandardId" />
        <result column="standard_cert_no" property="standardCertNo" />
        <result column="last_review_date" property="lastReviewDate" />
        <result column="dept_id" property="deptId" />
        <result column="dept_name" property="deptName" />
        <result column="director_id" property="directorId" />
        <result column="director_name" property="directorName" />
        <result column="manage_status" property="manageStatus" />
        <result column="build_standard_report_file" property="buildStandardReportFile" />
        <result column="exam_table_file" property="examTableFile" />
        <result column="standard_cert_file" property="standardCertFile" />
        <result column="temperature" property="temperature" />
        <result column="humidity" property="humidity" />
        <result column="voltage" property="voltage" />
        <result column="power_frequency" property="powerFrequency" />
        <result column="surround_environment" property="surroundEnvironment" />
        <result column="electric_field" property="electricField" />
        <result column="create_user_id" property="createUserId" />
        <result column="create_user_name" property="createUserName" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, standard_no, standard_name, storage_location, major, build_standard_id, standard_cert_no, last_review_date, dept_id, dept_name, director_id, director_name, manage_status, build_standard_report_file, exam_table_file, standard_cert_file, temperature, humidity, voltage, power_frequency, surround_environment, electric_field, create_user_id, create_user_name, create_time, update_time
    </sql>

    <select id="selectListPage" resultMap="BaseResultMap">
        SELECT *
        FROM biz_equipment_standard_info
        WHERE 1=1
        <if test="request.standardName != null and request.standardName !=''">
            and standard_name like concat('%',#{request.standardName},'%')
        </if>
        <if test="request.storageLocation != null and request.storageLocation !=''">
            and storage_location = #{request.storageLocation}
        </if>
        <if test="request.deptId != null and request.deptId !=''">
            and dept_id = #{request.deptId}
        </if>
        <if test="request.standardNoList != null">
            and standard_no in
            <foreach collection="standardNoList" item="no" index="index" open="(" close=")" separator=",">
                #{no}
            </foreach>
        </if>
        ORDER BY create_time DESC
    </select>

    <select id="selectByNo" resultMap="BaseResultMap">
        SELECT *
        FROM biz_equipment_standard_info
        WHERE standard_no = #{standardNo}
        LIMIT 1
    </select>

    <delete id="deleteByNo">
        DELETE
        FROM biz_equipment_standard_info
        WHERE standard_no = #{standardNo}
    </delete>

    <select id="selectExpireListPage" resultMap="BaseResultMap">
        SELECT *
        FROM biz_equipment_standard_info besi
        JOIN biz_equipment_standard_certificate besc ON besc.id = (
            SELECT esc.id FROM biz_equipment_standard_certificate esc WHERE esc.standard_id = besi.id
            ORDER BY esc.certificate_expire_date DESC LIMIT 1
        )
        WHERE 1=1
        <if test="request.standardName != null and request.standardName !=''">
            and besi.standard_name like concat('%',#{request.standardName},'%')
        </if>
        <if test="request.storageLocation != null and request.storageLocation !=''">
            and besi.storage_location = #{request.storageLocation}
        </if>
        <if test="request.deptId != null and request.deptId !=''">
            and besi.dept_id = #{request.deptId}
        </if>
        <if test="request.standardNoList != null">
            and besi.standard_no in
            <foreach collection="standardNoList" item="no" index="index" open="(" close=")" separator=",">
                #{no}
            </foreach>
        </if>
        ORDER BY besi.create_time DESC
    </select>
</mapper>