Blame view

WorkstationDictMapper.xml 8.28 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
<?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.WorkstationDictMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.laowu.model.WorkstationDictDO">
        <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="workstation_name" property="workstationName" />
        <result column="province" property="province" />
        <result column="city" property="city" />
        <result column="county" property="county" />
        <result column="comment" property="comment" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, workstation_name, province, city, county, administer_id, comment
    </sql>

    <select id="stations" resultType="com.laowu.vo.station.StationsVO">
        SELECT
            t.id,
            t.workstation_name,
            t.province,
            t.city,
            t.county,
            t.`comment`
        FROM
            workstation_dict t
        WHERE
            t.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="workstationName != null and workstationName != ''">
                and t.workstation_name LIKE  concat('%', #{workstationName}, '%')
            </if>
    </select>

    <select id="stationAccount" parameterType="string" resultType="com.laowu.vo.station.StationAccountVO">
        SELECT
            t1.id,
            GROUP_CONCAT( t3.workstation_name ) as stationName,
            t1.user_name,
            t1.account,
            t1.telephone,
            t1.`password`
        FROM
            administer t1
            LEFT JOIN workstation_administers t2 ON t1.id = t2.administer_id
            LEFT JOIN workstation_dict t3 ON t2.workstation_id = t3.id
64
            left join role_administer_mapping t4 on t1.id = t4.administer_id
65 66 67 68
        WHERE
            t1.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
69 70
            and t4.role_id != 1
        <if test=" workingstationName!= null and workingstationName != ''">
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
                AND t3.workstation_name LIKE  concat('%', #{workingstationName}, '%')
            </if>
        GROUP BY
            t1.id
    </select>

    <select id="provinces" resultType="string">
        SELECT DISTINCT
            province
        FROM
            workstation_dict t
        WHERE
            t.delete_date IS NULL
    </select>


87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
    <select id="homepage" parameterType="long" resultType="com.laowu.vo.team.HomepageVO">
      SELECT
            t1.workstation_name,
            t1.province,
            t1.city,
            t1.county,
            IFNULL( t4.ct1, 0 ) AS memberCnt,
            IFNULL( t5.ct2, 0 ) AS leaderCnt,
            IFNULL( t6.ct3, 0 ) AS teamCnt,
            IFNULL( t7.ct4, 0 ) AS companyCnt,
            IFNULL( t8.ct5, 0 ) AS requireCnt
        FROM
            workstation_dict t1
            LEFT JOIN (
            SELECT
                t1.id,
                count( DISTINCT t3.member_id ) AS ct1
            FROM
                workstation_dict t1
                LEFT JOIN team_dict t2 ON t1.id = t2.station_id
                LEFT JOIN member_team_mapping t3 ON t2.id = t3.team_id
            WHERE
                t1.id = #{stationId}
                AND t1.delete_date IS NULL
                AND t2.delete_date IS NULL
                AND t3.delete_date IS NULL
            ) t4 ON t1.id = t4.id
            LEFT JOIN (
            SELECT
                t1.id,
                count( DISTINCT t2.member_id ) AS ct2
118 119
            FROM
                workstation_dict t1
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
                LEFT JOIN team_dict t2 ON t1.id = t2.station_id
            WHERE
                t1.id = #{stationId}
                AND t1.delete_date IS NULL
                AND t2.delete_date IS NULL
            ) t5 ON t1.id = t5.id
            LEFT JOIN (
            SELECT
                t1.id,
                count(*) AS ct3
            FROM
                workstation_dict t1
                LEFT JOIN team_dict t2 ON t1.id = t2.station_id
            WHERE
                t1.id = #{stationId}
                AND t1.delete_date IS NULL
                AND t2.delete_date IS NULL
            GROUP BY
                t2.station_id
            ) t6 ON t1.id = t6.id
            LEFT JOIN (
            SELECT
                t5.id,
                count(*) AS ct4
            FROM
                (
146 147
                SELECT
                    t1.id,
148
                    t4.company_name
149 150
                FROM
                    workstation_dict t1
151 152 153
                    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
154 155 156 157 158
                WHERE
                    t1.id = #{stationId}
                    AND t1.delete_date IS NULL
                    AND t2.delete_date IS NULL
                    AND t3.delete_date IS NULL
159 160 161
                    AND t4.delete_date IS NULL
                    and t4.id is not null
                    UNION
162 163
                SELECT
                    t1.id,
164
                    t4.company_name
165 166
                FROM
                    workstation_dict t1
167 168 169
                    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
170 171 172 173
                WHERE
                    t1.id = #{stationId}
                    AND t1.delete_date IS NULL
                    AND t2.delete_date IS NULL
174 175
                    AND t3.delete_date IS NULL
                    AND t4.delete_date IS NULL
176
                    and t4.id is not null
177 178 179 180 181 182 183 184
                ) t5
            ) t7 ON t1.id = t7.id
            LEFT JOIN (
            SELECT
                t5.id,
                sum( t5.require_counts ) AS ct5
            FROM
                (
185 186
                SELECT
                    t1.id,
187
                    t3.require_counts
188 189
                FROM
                    workstation_dict t1
190 191
                    LEFT JOIN workstation_alone_mapping t2 ON t1.id = t2.station_id
                    LEFT JOIN position_alone_info t3 ON t2.alone_id = t3.id
192 193 194 195
                WHERE
                    t1.id = #{stationId}
                    AND t1.delete_date IS NULL
                    AND t2.delete_date IS NULL
196
                    AND t3.delete_date IS NULL UNION
197
                SELECT
198
                    t1.id,
199
                    sum(t4.require_counts) as require_counts
200
                FROM
201 202 203 204 205 206 207 208 209 210
                    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 position_item_info t4 ON t3.id = t4.position_require_id
                WHERE
                    t1.id = #{stationId}
                    AND t1.delete_date IS NULL
                    AND t2.delete_date IS NULL
                    AND t3.delete_date IS NULL
                    AND t4.delete_date IS NULL
211
                group by t1.id
212 213 214 215
                ) t5
            ) t8 ON t1.id = t8.id
        WHERE
            t1.id = #{stationId}
216 217
    </select>

218 219 220 221 222 223 224 225 226 227 228 229 230
    <select id="administerProvinceStations" resultType="com.laowu.model.WorkstationDictDO">
        SELECT
            t.id,
            t.workstation_name
        FROM
            workstation_dict t
            LEFT JOIN workstation_administers t2 ON t.id = t2.workstation_id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            and t2.administer_id = #{administerId}
            and t.province = #{province}
    </select>
231
</mapper>