<?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.stylefeng.guns.modular.system.dao.TDispatchMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TDispatch">
|
<id column="id" property="id" />
|
<result column="insertTime" property="insertTime" />
|
<result column="name" property="name" />
|
<result column="companyId" property="companyId" />
|
<result column="franchiseeId" property="franchiseeId" />
|
<result column="phone" property="phone" />
|
<result column="account" property="account" />
|
<result column="password" property="password" />
|
<result column="insertUserId" property="insertUserId" />
|
<result column="insertUserRole" property="insertUserRole" />
|
<result column="state" property="state" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, insertTime, name, companyId, franchiseeId, phone, account, password, insertUserId, insertUserRole, state
|
</sql>
|
|
<!--根据条件查询调度列表-->
|
<select id="getDispatchList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
|
SELECT * FROM (SELECT c1.name as companyName,c2.name as franchiseeName,dd.* FROM t_dispatch as dd
|
LEFT JOIN (select * from t_company where type = 2 and flag != 3) as c1 on c1.id = dd.companyId
|
LEFT JOIN (select * from t_company where type = 3 and flag != 3) as c2 on c2.id = dd.franchiseeId) as o
|
<where>
|
o.state != 3
|
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
|
AND (o.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
|
</if>
|
<if test="name != null and name != ''">
|
and o.name LIKE CONCAT('%',#{name},'%')
|
</if>
|
<if test="companyName != null and companyName != ''">
|
and o.companyName LIKE CONCAT('%',#{companyName},'%')
|
</if>
|
<if test="franchiseeName != null and franchiseeName != ''">
|
and o.franchiseeName LIKE CONCAT('%',#{franchiseeName},'%')
|
</if>
|
<if test="account != null and account != ''">
|
and o.account LIKE CONCAT('%',#{account},'%')
|
</if>
|
<if test="state != null and state != ''">
|
and o.state = #{state}
|
</if>
|
<if test="roleType != null and roleType != '' and roleType == 2">
|
and (o.companyId = #{nowUserId} or FIND_IN_SET(o.franchiseeId,(SELECT GROUP_CONCAT(id) as ids FROM t_company where superiorId = #{nowUserId} GROUP BY superiorId)))
|
</if>
|
<if test="roleType != null and roleType != '' and roleType == 3">
|
and o.franchiseeId = #{nowUserId}
|
</if>
|
</where>
|
order by o.id desc
|
</select>
|
|
</mapper>
|