Blame view

CompanyDictMapper.xml 3.99 KB
涂亚平 committed
1 2 3 4 5 6
<?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">
7 8 9 10 11 12 13
        <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"/>
涂亚平 committed
14 15 16 17 18 19 20 21 22 23 24 25
    </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
26
        t.id,
27
        t3.id as business_id,
28
        t.company_name,
29
        t3.business,
30 31 32 33 34 35
        t.company_code,
        t.company_desc,
        t.province,
        t.city,
        t.county,
        t.company_origin
涂亚平 committed
36
        FROM
37
        company_dict t
38
        LEFT JOIN business_dict t3 ON t.business_id = t3.id
涂亚平 committed
39
        WHERE
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
        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,
90
        t2.business_id,
91
        t2.company_name,
92
        t3.business,
93 94 95 96 97 98 99 100
        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
101
        LEFT JOIN business_dict t3 ON t2.business_id = t3.id
102 103
        WHERE
        t.delete_date IS NULL
涂亚平 committed
104 105
        AND t2.delete_date IS NULL
        AND t3.delete_date IS NULL
106 107 108 109 110 111 112 113 114 115 116 117 118
        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>
涂亚平 committed
119 120 121
    </select>

</mapper>