mobilebroken/nflg-mobilebroken-repository/src/main/resources/mapper/GongfuDispatchMapper.xml

80 lines
3.7 KiB
XML

<?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.nflg.mobilebroken.repository.mapper.GongfuDispatchMapper">
<select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.DispatchVO">
SELECT da.*,dv.customer_name,bc.agency_company_name as agent_name,af.reason as "delayReason",af2.id as
"applyforId",if(da.create_by_id =#{userId} or da.handler_user_id = #{userId},1,0) AS usort
FROM gongfu_dispatch da
LEFT JOIN v_gongfu_device dv ON da.device_no=dv.device_no
LEFT JOIN t_base_customer bc ON dv.agent_code=bc.agency_company_code
left join v_dispatch_applyfor af on da.id=af.ticket_id
left join gongfu_dispatch_applyfor af2 on da.id=af2.ticket_id and af2.audit_state=0
<where>
<if test="request.deviceNo!=null and request.deviceNo!=''">
AND da.device_no=#{request.deviceNo}
</if>
<if test="request.handlerUserName!=null and request.handlerUserName!=''">
AND da.handler_user_name LIKE CONCAT('%',#{request.handlerUserName},'%')
</if>
<if test="request.customerName!=null and request.customerName!=''">
AND dv.customer_name LIKE CONCAT('%',#{request.customerName},'%')
</if>
<if test="request.state!=null">
AND da.state=#{request.state}
</if>
<if test="request.category!=null">
AND da.category= #{request.category}
</if>
<if test="request.createUserName!=null and request.createUserName!=''">
AND da.create_by LIKE CONCAT('%',#{request.createUserName},'%')
</if>
<if test="request.startDate!=null">
AND da.plan_start_date >= #{request.startDate}
</if>
<if test="request.endDate!=null">
AND da.plan_end_date &gt;= #{request.endDate}
</if>
<if test="request.key!=null and request.key!=''">
AND (da.device_no like concat('%',#{request.key},'%')
or da.handler_user_name like concat('%',#{request.key},'%')
or da.title like concat('%',#{request.key},'%')
or dv.customer_name like concat('%',#{request.key},'%')
)
</if>
</where>
ORDER BY usort DESC,da.state,da.plan_start_date DESC,da.id DESC
</select>
<select id="getInfo" resultType="com.nflg.mobilebroken.common.pojo.vo.DispatchVO">
SELECT da.*,dv.customer_name,bc.agency_company_name as agent_name,af.reason as "delayReason"
FROM gongfu_dispatch da
LEFT JOIN v_gongfu_device dv ON da.device_no=dv.device_no
LEFT JOIN t_base_customer bc ON dv.agent_code=bc.agency_company_code
left join v_dispatch_applyfor af on da.id=af.ticket_id
where da.id = #{id}
</select>
<select id="getForBI" resultType="com.nflg.mobilebroken.repository.entity.GongfuDispatch">
SELECT gd.*
FROM gongfu_dispatch gd
LEFT JOIN admin_user au ON gd.handler_user_id = au.id
WHERE gd.handler_user_type=1 and gd.state in
<foreach collection="states" close=")" open="(" item="state" separator=",">
#{state}
</foreach>
<if test="deptId!=null">
and au.department_id=#{deptId}
</if>
<if test="startDate!=null">
and gd.plan_start_date >= #{startDate}
</if>
<if test="endDate!=null">
and gd.plan_end_date &lt;= #{endDate}
</if>
<if test="userName!=null and userName!=''">
and au.user_name LIKE CONCAT('%',#{userName},'%')
</if>
</select>
</mapper>