<?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.unis.base.server.dao.CcsbtzjsmxDao'>


    <select id="selectForHz" resultType="com.unis.base.server.entity.CcsbtzjsmxDO">
        select
            sbyqmc as sbmc,
            kddm as sskddm,
            szdwmc as sskdmc,
            date_format(rkrq,'%Y') as sbnf,
            ssfl as sblx,
            sbfl as sbyjlb,
            sbyqmc as sbejlb,
            sbsl as grsl,
            cast(cgjg * sbsl as DECIMAL(30, 3)) as jrje
        from depot_qh.d_sbxxsjy
        <where>
            <if test="sskddm != null and sskddm != ''">
                and kddm = #{sskddm}
            </if>
            <if test="sbnf != null and sbnf != ''">
                and date_format(rkrq,'%Y') = #{sbnf}
            </if>
            <if test="sskdmc != null and sskdmc != ''">
                and szdwmc = #{sskdmc}
            </if>
            <if test="sskdmcList != null and sskdmcList.size() > 0">
                and szdwmc in
                <foreach collection="sskdmcList" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
    <select id="selectTyshxydmByOrgCode" resultType="java.lang.String">
        select
            tyshxydm
        from base.tz_slqy
        where qyjgdm = #{orgCode}
    </select>
    <select id="selectQyjbByOrgCode" resultType="com.unis.base.common.vo.OrganizationInfo">
        select
            so.org_code as orgCode,
            so.org_name as orgName,
            so.org_level as orgLevel,
            so.parent_code as parentOrgCode,
            (select config_name from usercenter.bas_para_config where config_code = so.org_level) as orgLevelName,
            (select so1.org_name from usercenter.sys_orgainze so1 where so1.org_code = so.parent_code) as parentOrgName
        from usercenter.sys_orgainze so
        <where>
            so.state_code = 1
            <if test="orgCode != null and orgCode != ''">
                and so.org_code = #{orgCode}
            </if>
        </where>
    </select>
    <select id="findByParentCodeAndStateCode" resultType="com.unis.user.common.vo.org.OrgainzeVO">
        select
            *
        from
            usercenter.sys_orgainze
        where
            parent_code = #{orgCode} and state_code = 1
            and org_level in
            <foreach collection="orgLevel.split(',')" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        order by org_code asc
    </select>
    <select id="findByOrgCodeAndStateCode" resultType="com.unis.user.common.vo.org.OrgainzeVO">
        select
            *
        from
            usercenter.sys_orgainze
        where
            org_code = #{orgCode}
            and state_code = 1
    </select>
</mapper>
