<?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.dxhy.manage.dao.OperationsToolsDao">

    <select id="getSysDeptInfo" resultType="com.dxhy.manage.entity.SysDeptEntity">
        select *
        from sys_dept
        where taxno = #{taxno}
    </select>


    <update id="updateCreateDateByUuid">
        update ${table}
        set create_date=now()
        where uuid = #{uuid}
    </update>

    <select id="getBlocList" resultType="com.dxhy.manage.entity.SysDeptEntity">
        select *
        from sys_dept
        where is_model = '1'
          and org_type = '1'
    </select>

    <select id="getTaxNoList" resultType="com.dxhy.manage.entity.SysDeptEntity">
        select *
        from sys_dept
        where org_type = '5'
          and parent_id = #{blocId}
    </select>

    <select id="getAllTables" resultType="java.lang.String">
        select major_into_where_table
        from sys_dept
        where company = #{blocId}
          and org_type = '5'
        group by major_into_where_table
    </select>

    <select id="getTaxnoes" resultType="java.lang.String">
        SELECT taxno
        FROM sys_dept
        WHERE company = #{blocId}
          AND major_into_where_table = #{table}
          AND org_type = '5'
    </select>

    <update id="updateCreateDateByTaxNo">
        update ${table} set create_date=now() where new_gf_tax_no in
        <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
            #{item}
        </foreach>
        <if test='map.invoiceType!="99" and map.invoiceType!=null'>
            and invoice_type=#{map.invoiceType}
        </if>
        and  <![CDATA[create_date <= #{map.endDate}]]> and <![CDATA[create_date >= #{map.beginDate}]]>
    </update>


    <select id="getMajorIntoWhereDb" resultType="java.lang.String">
        select major_into_where_db
        from sys_dept
        where company = #{company}
          and org_type = '1'
        limit 1
    </select>
</mapper>
