<?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="org.springblade.modules.khsdPcs.mapper.KhsdPcsMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="khsdPcsResultMap" type="org.springblade.modules.khsdPcs.entity.KhsdPcsEntity">
        <result column="id" property="id"/>
        <result column="sjhm" property="sjhm"/>
        <result column="realName" property="realName"/>
        <result column="pcsdm" property="pcsdm"/>
        <result column="pcsmc" property="pcsmc"/>
        <result column="khxid" property="khxid"/>
        <result column="khfs" property="khfs"/>
        <result column="khcs" property="khcs"/>
        <result column="khyf" property="khyf"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>


    <select id="selectKhsdPcsPage" resultMap="khsdPcsResultMap">
        select * from jlrh_khsd_pcs where is_deleted = 0
    </select>


    <select id="exportKhsdPcs" resultType="org.springblade.modules.khsdPcs.excel.KhsdPcsExcel">
        SELECT * FROM jlrh_khsd_pcs ${ew.customSqlSegment}
    </select>

    <select id="getKhcs" resultType="integer">
        SELECT
            khcs
        FROM
            jlrh_khsd_pcs
        WHERE
            sjhm = #{params.sjhm}
          AND khyf = substring(#{params.yf}, 1, 7)
          <if test="null != params.pfxId and '' != params.pfxId">
          AND khxid :: text = #{params.pfxId} :: text
          </if>
    </select>

    <select id="getDetail" resultType="org.springblade.modules.khsdPcs.entity.KhsdPcsEntity">
        SELECT
            id,
            sjhm,
            khxid,
            khcs,
            khyf
        FROM
            jlrh_khsd_pcs
        WHERE
            sjhm = #{params.sjhm}
          AND khyf = #{params.yf}
        <if test="null != params.khxid and '' != params.khxid">
        AND khxid ::text = #{params.khxid}
        </if>
    </select>
</mapper>
