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.standardNo != null and request.standardNo !=''">
            and standard_cert_no like concat('%',#{request.standardNo},'%')
        </if>
        <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.labCode !=null and request.labCode !=''">
            and lab_code = #{request.labCode}
        </if>
        <if test="request.groupCode != null and request.groupCode !=''">
            and group_code = #{request.groupCode}
        </if>
        <if test="request.majorType != null and request.majorType !=''">
            and major_type = #{request.majorType}
        </if>
        <if test="request.lastReviewDateStart != null and request.lastReviewDateStart !=''">
            and last_review_date &gt;= #{request.lastReviewDateStart}
        </if>
        <if test="request.lastReviewDateEnd != null and request.lastReviewDateEnd !=''">
            and last_review_date &lt;= #{request.lastReviewDateEnd}
        </if>
        <if test="request.nextReviewDateStart != null and request.nextReviewDateStart !=''">
            and next_review_date &gt;= #{request.nextReviewDateStart}
        </if>
        <if test="request.nextReviewDateEnd != null and request.nextReviewDateEnd !=''">
            and next_review_date &lt;= #{request.nextReviewDateEnd}
        </if>
        <if test="request.lastChangeDateStart != null and request.lastChangeDateStart !=''">
            and last_change_date &gt;= #{request.lastChangeDateStart}
        </if>
        <if test="request.lastChangeDateEnd != null and request.lastChangeDateEnd !=''">
            and last_change_date &lt;= #{request.lastChangeDateEnd}
        </if>
        <if test="request.inUseStatus != null and request.inUseStatus !=''">
            and manage_status = #{request.inUseStatus}
        </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>
    <select id="selectStandardNameByEquipmentId" resultType="com.casic.missiles.model.equipment.BizEquipmentStandardInfo">
        select besi.id,besi.standard_name
        from biz_equipment_standard_equipment_relation besqr
        join biz_equipment_standard_info besi
        on besqr.standard_id =  besi.id
        where besqr.equipment_id = #{id}
    </select>
    <select id="selectInfoAndTechnicalList"
            resultType="com.casic.missiles.model.equipment.BizEquipmentStandardInfo">
        SELECT besi.*,bestir.measure_item measureParam,bestir.measure_range measureRange,bestir.uncertainty
        FROM biz_equipment_standard_info besi LEFT JOIN biz_equipment_standard_technology_index_relation bestir
        ON besi.standard_no = bestir.standard_no
        WHERE 1=1
        <if test="request.standardNo != null and request.standardNo !=''">
            and besi.standard_cert_no like concat('%',#{request.standardNo},'%')
        </if>
        <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.labCode !=null and request.labCode !=''">
            and besi.lab_code = #{request.labCode}
        </if>
        <if test="request.groupCode != null and request.groupCode !=''">
            and besi.group_code = #{request.groupCode}
        </if>
        <if test="request.majorType != null and request.majorType !=''">
            and besi.major_type = #{request.majorType}
        </if>
        <if test="request.lastReviewDateStart != null and request.lastReviewDateStart !=''">
            and besi.last_review_date &gt;= #{request.lastReviewDateStart}
        </if>
        <if test="request.lastReviewDateEnd != null and request.lastReviewDateEnd !=''">
            and besi.last_review_date &lt;= #{request.lastReviewDateEnd}
        </if>
        <if test="request.nextReviewDateStart != null and request.nextReviewDateStart !=''">
            and besi.next_review_date &gt;= #{request.nextReviewDateStart}
        </if>
        <if test="request.nextReviewDateEnd != null and request.nextReviewDateEnd !=''">
            and besi.next_review_date &lt;= #{request.nextReviewDateEnd}
        </if>
        <if test="request.lastChangeDateStart != null and request.lastChangeDateStart !=''">
            and besi.last_change_date &gt;= #{request.lastChangeDateStart}
        </if>
        <if test="request.lastChangeDateEnd != null and request.lastChangeDateEnd !=''">
            and besi.last_change_date &lt;= #{request.lastChangeDateEnd}
        </if>
        <if test="request.inUseStatus != null and request.inUseStatus !=''">
            and besi.manage_status = #{request.inUseStatus}
        </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>
    </select>
    <select id="selectInfoAndTechnicalListByIds"
            resultType="com.casic.missiles.model.equipment.BizEquipmentStandardInfo">
        SELECT besi.*,bestir.measure_item measureParam,bestir.measure_range measureRange,bestir.uncertainty
        FROM biz_equipment_standard_info besi
        LEFT JOIN biz_equipment_standard_technology_index_relation bestir
        ON besi.standard_no = bestir.standard_no
        WHERE 1=1
        <if test="ids != null">
            and besi.id in
            <foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </if>
    </select>
</mapper>