<?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.basic.info.modular.unitInfo.mapper.UnitInfoMapper">

    <select id="selectMyMapsPage" resultType="java.util.Map">

        SELECT
            id,dwmc,fddbr,tydwbm,dwlx from
            biz_unit_info
        order by create_time desc

    </select>
    <select id="getTreeList" resultType="com.unis.basic.info.modular.unitInfo.vo.UnitInfoVO">
        select t1.*, t2.DICT_LABEL dictLabel
        from biz_unit_info t1
                 left join dev_dict t2 on t1.dwlx = t2.id

    </select>


    <select id="selectMyPage" resultType="com.unis.basic.info.modular.unitInfo.vo.UnitInfoVO">
        select t1.*, t2.DICT_LABEL dictLabel
        from biz_unit_info t1
        left join dev_dict t2 on t1.dwlx = t2.id
        <where>
            t1.delete_flag='NOT_DELETE'
            <if test="dwmc!=null and dwmc!=''">
               and t1.dwmc like concat("%",#{dwmc},"%")
            </if>
            <if test="fddbr!=null and fddbr!=''">
               and t1.fddbr like concat("%",#{fddbr},"%")
            </if>
        </where>

        order by t1.create_time desc

    </select>


    <select id="selectMyPage" resultType="com.unis.basic.info.modular.unitInfo.vo.UnitInfoVO">
        select t1.*, t2.DICT_LABEL dictLabel
        from biz_unit_info t1
        left join dev_dict t2 on t1.dwlx = t2.id
        <where>
            t1.delete_flag='NOT_DELETE'
            <if test="dwmc!=null and dwmc!=''">
                and t1.dwmc like concat("%",#{dwmc},"%")
            </if>
            <if test="fddbr!=null and fddbr!=''">
                and t1.fddbr like concat("%",#{fddbr},"%")
            </if>
        </where>

        order by t1.create_time desc

    </select>

    <select id="getDwGjjDate" parameterType="java.lang.String" resultType="java.util.Map">
        SELECT
            id,
            dwdm,
            tydwbm,
            dwmc,
            dwlx,
            DATE_FORMAT(
                    ifnull(zcrq, NOW()),
                    '%Y-%m-%d'
                ) zcrq,
            zczb,
            zcze,
            fddbr,
            frsfzh,
            frlxfs,
            qylxr,
            bgdh,
            CONCAT(
                    zcdz_province,
                    zcdz_city,
                    zcdz_area
                ) zcdz,
            dzyx,
            qygfwzdz,
            czhm,
            yzbm,
            xzqhdm,
            sjdwmc,
            sjdwdm,
            kqs,
            cfs,
            ygs,
            jd,
            wd,
            dwzt,
            czbz,
            DATE_FORMAT(
                    update_time,
                    '%Y-%m-%d %H:%i:%s'
                ) zhgxsj
        FROM
            biz_unit_info
        where id = #{id}
    </select>
</mapper>