MYgxxMapper.xml 5.4 KB
<?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.hotent.lpg.manage.dao.MYgxxDao">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hotent.lpg.common.model.WYgxx">
        <id column="ID_" property="id" />
        <result column="REF_ID_" property="refId" />
        <result column="F_ssqyID" property="fSsqyid" />
        <result column="F_ssczID" property="fSsczid" />
        <result column="F_xm" property="fXm" />
        <result column="F_sjh" property="fSjh" />
        <result column="F_rzsj" property="fRzsj" />
        <result column="F_sfzh" property="fSfzh" />
        <result column="F_sslx" property="fSslx" />
        <result column="F_mm" property="fMm" />
        <result column="F_xb" property="fXb" />
        <result column="F_zt" property="fZt" />
        <result column="F_cjr" property="fCjr" />
        <result column="F_cjsj" property="fCjsj" />
        <result column="F_gxr" property="fGxr" />
        <result column="F_gxsj" property="fGxsj" />
        <result column="F_ssqymc" property="fSsqymc" />
        <result column="F_ssczmc" property="fSsczmc" />
        <result column="F_form_data_rev_" property="fFormDataRev" />
        <result column="F_jsmc" property="fJsmc" />
        <result column="F_jscode" property="fJscode" />
        <result column="F_htzzcode" property="fHtzzcode" />
        <result column="F_userID" property="fUserid" />
        <result column="F_zxzsbh" property="fZxzsbh" />
        <result column="F_zxzsyxqx" property="fZxzsyxqx" />
        <result column="F_zxzstp" property="fZxzstp" />
        <result column="F_sfztp" property="fSfztp" />
        <result column="F_bz" property="fBz" />
        <result column="F_ewm" property="fEwm" />
        <result column="F_ygbh" property="fYgbh" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        ID_,
        REF_ID_,
        F_ssqyID,
        F_ssczID,
        F_xm,
        F_sjh,
        F_rzsj,
        F_sfzh,
        F_sslx,
        F_mm,
        F_xb,
        F_zt,
        F_cjr,
        F_cjsj,
        F_gxr,
        F_gxsj,
        F_ssqymc,
        F_ssczmc,
        F_form_data_rev_,
        F_jsmc,
        F_jscode,
        F_htzzcode,
        F_userID,
        F_zxzsbh,
        F_zxzsyxqx,
        F_zxzstp,
        F_sfztp,
        F_bz,
        F_ewm,
        F_ygbh
    </sql>

    <select id="selectPage" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from
        w_ygxx
        ${ew.customSqlSegment}
    </select>

    <select id="selectList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from
        w_ygxx
        ${ew.customSqlSegment}
    </select>

    <select id="selectById" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from
        w_ygxx
        where
        ID_ = #{id}
    </select>

    <select id="pageList" resultMap="BaseResultMap">
        select
        w_ygxx.*
        from w_ygxx
        <where>
            <if test="query.name != null and query.name != ''">
                and w_ygxx.f_xm like concat('%',#{query.name},'%')
            </if>
            <if test="query.phone != null and query.phone != ''">
                and w_ygxx.F_sjh like concat('%',#{query.phone},'%')
            </if>
            <if test="query.state != null and query.state != ''">
                and w_ygxx.F_zt = #{query.state}
            </if>
            <if test="list != null and list.size() > 0">
                and ( w_ygxx.F_ssqyID in
                <foreach collection="list" open="(" close=")" item="orgId" separator=",">
                    #{orgId}
                </foreach>
                or w_ygxx.F_ssczID in
                <foreach collection="list" open="(" close=")" item="orgId" separator=",">
                    #{orgId}
                </foreach>
                )
            </if>
            <if test="query.lx != null and query.lx != ''">
                <if test="query.lx == '1'.toString()">
                    and w_ygxx.F_ssqyID = #{query.orgId}
                    <if test="query.flag != null and query.flag">
                        and w_ygxx.f_sslx = '企业员工'
                    </if>
                </if>
                <if test="query.lx == '2'.toString()">
                    and w_ygxx.F_ssczID = #{query.orgId}
                </if>
            </if>
        </where>
        order by w_ygxx.F_ssqyID,w_ygxx.F_ssczID,w_ygxx.F_userID desc
    </select>

    <select id="listByOrgIdAndUserId" resultMap="BaseResultMap">
        select * from w_ygxx
        where f_userID = #{userId} and ((F_ssqyID = #{orgId}  and  F_sslx = '企业员工') OR (F_ssczID = #{orgId}))
    </select>

    <select id="countByCzId" resultType="java.lang.Integer">
        select
            count(*)
        <if test="type == null or type == ''">
            from w_ygxx where F_ssczID = #{czId}
        </if>
        <if test="type != null and type != ''">
            <if test="type == '1'.toString()">
                from ( select count(*) as sl from w_ygxx where F_ssczID = #{czId}  group by F_userID ) temp1
            </if>
        </if>
    </select>

    <select id="userIdByCzId" resultType="java.lang.String">
        select distinct  f_userID from w_ygxx where F_ssczID = #{czId}
    </select>
</mapper>