CompanyDictMapper.xml 3.99 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.laowu.mapper.CompanyDictMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.laowu.model.CompanyDictDO">
        <id column="id" property="id"/>
        <result column="create_date" property="createDate"/>
        <result column="update_date" property="updateDate"/>
        <result column="delete_date" property="deleteDate"/>
        <result column="company_name" property="companyName"/>
        <result column="company_code" property="companyCode"/>
        <result column="account" property="account"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, company_name, place_id, position_id, company_code, account, desc
    </sql>

    <select id="company" resultType="com.laowu.vo.company.CompanyVO">
        SELECT
        t.id,
        t3.id as business_id,
        t.company_name,
        t3.business,
        t.company_code,
        t.company_desc,
        t.province,
        t.city,
        t.county,
        t.company_origin
        FROM
        company_dict t
        LEFT JOIN business_dict t3 ON t.business_id = t3.id
        WHERE
        t.delete_date IS NULL
        AND t3.delete_date IS NULL
        <if test="province != null and province != ''">
            and t.province = #{province}
        </if>
        <if test="city != null and city != ''">
            and t.city = #{city}
        </if>
        <if test="county != null and county != ''">
            and t.county = #{county}
        </if>
        <if test="companyName != null and companyName != ''">
            AND t.company_name LIKE concat('%', #{companyName}, '%')
        </if>
    </select>

    <select id="stationCompanyCount" parameterType="long" resultType="integer">
        SELECT
            count(distinct(t4.id))
        FROM
            workstation_dict t1
            LEFT JOIN workstation_alone_mapping t2 ON t1.id = t2.station_id
            LEFT JOIN position_alone_info t3 ON t2.alone_id = t3.id
            LEFT JOIN company_dict t4 ON t3.company_id = t4.id
        WHERE
            t1.id = 1
            AND t1.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
            AND t4.delete_date IS NULL UNION
        SELECT
            t1.id,
            t4.company_name
        FROM
            workstation_dict t1
            LEFT JOIN workstation_require_mapping t2 ON t1.id = t2.station_id
            LEFT JOIN position_require_item t3 ON t2.require_id = t3.id
            LEFT JOIN company_dict t4 ON t3.company_id = t4.id
        WHERE
            t1.id = 1
            AND t1.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
            AND t4.delete_date IS NULL
    </select>


    <select id="stationCompany" resultType="com.laowu.vo.company.CompanyVO">
        SELECT
        t2.id,
        t2.business_id,
        t2.company_name,
        t3.business,
        t2.company_code,
        t2.company_desc,
        t2.province,
        t2.city,
        t2.county
        FROM
        company_relate_work t
        LEFT JOIN company_dict t2 ON t.company_id = t2.id
        LEFT JOIN business_dict t3 ON t2.business_id = t3.id
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
        AND t3.delete_date IS NULL
        and t.station_id = #{stationId}
        <if test="province != null and province != ''">
            and t2.province = #{province}
        </if>
        <if test="city != null and city != ''">
            and t2.city = #{city}
        </if>
        <if test="county != null and county != ''">
            and t2.county = #{county}
        </if>
        <if test="companyName != null and companyName != ''">
            AND t2.company_name LIKE concat('%', #{companyName}, '%')
        </if>
    </select>

</mapper>