Blame view

CompanyDictMapper.xml 4.05 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
        t.company_code,
涂亚平 committed
31
        t.company_property,
32 33 34 35 36
        t.company_desc,
        t.province,
        t.city,
        t.county,
        t.company_origin
涂亚平 committed
37
        FROM
38
        company_dict t
39
        LEFT JOIN business_dict t3 ON t.business_id = t3.id
涂亚平 committed
40
        WHERE
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 90
        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,
91
        t2.business_id,
92
        t2.company_name,
93
        t3.business,
94 95 96
        t2.company_code,
        t2.company_desc,
        t2.province,
涂亚平 committed
97
        t2.company_property,
98 99 100 101 102
        t2.city,
        t2.county
        FROM
        company_relate_work t
        LEFT JOIN company_dict t2 ON t.company_id = t2.id
103
        LEFT JOIN business_dict t3 ON t2.business_id = t3.id
104 105
        WHERE
        t.delete_date IS NULL
涂亚平 committed
106 107
        AND t2.delete_date IS NULL
        AND t3.delete_date IS NULL
108 109 110 111 112 113 114 115 116 117 118 119 120
        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
121 122 123
    </select>

</mapper>