311 lines
18 KiB
XML
311 lines
18 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.GongfuTicketMapper">
|
|
|
|
<sql id="searchWhereCondition">
|
|
<if test="request.areaIds!=null">
|
|
AND u.area_id IN
|
|
<foreach collection="request.areaIds" item="areaId" open="(" separator="," close=")">
|
|
#{areaId}
|
|
</foreach>
|
|
</if>
|
|
<if test="request.title!=null and request.title!=''">
|
|
AND (t.title LIKE CONCAT('%', #{request.title}, '%') OR t.no LIKE CONCAT('%', #{request.title}, '%'))
|
|
</if>
|
|
<if test="request.deviceNo!=null and request.deviceNo!=''">
|
|
AND t.device_no LIKE CONCAT('%', #{request.deviceNo}, '%')
|
|
</if>
|
|
<if test="request.componentId!=null">
|
|
AND t.component_id=#{request.componentId}
|
|
</if>
|
|
<if test="request.state!=null">
|
|
AND t.state=#{request.state}
|
|
</if>
|
|
<if test="request.startTime!=null">
|
|
AND t.create_time>=#{request.startTime}
|
|
</if>
|
|
<if test="request.endTime!=null">
|
|
AND t.create_time < #{request.endTime}
|
|
</if>
|
|
<if test="request.pendingComments==true">
|
|
AND te.id IS NULL
|
|
</if>
|
|
<if test="request.pendingComments==false">
|
|
AND te.id IS NOT NULL
|
|
</if>
|
|
</sql>
|
|
|
|
<sql id="adminSearchWhereCondition">
|
|
<where>
|
|
t.state!=4
|
|
<if test="!request.ticketManager">
|
|
AND (FIND_IN_SET(#{userId},t.handle)>0 OR (t.user_platform='admin' AND t.user_id=#{userId}))
|
|
</if>
|
|
<if test="request.state!=null">
|
|
AND t.state=#{request.state}
|
|
</if>
|
|
<if test="request.urgency!=null">
|
|
AND t.urgency=#{request.urgency}
|
|
</if>
|
|
<if test="request.componentId!=null">
|
|
AND t.component_id=#{request.componentId}
|
|
</if>
|
|
<if test="request.handleUserName!=null and request.handleUserName!=''">
|
|
AND t.handle_name LIKE CONCAT('%', #{request.handleUserName}, '%')
|
|
</if>
|
|
<if test="request.agentCode!=null and request.agentCode!=''">
|
|
AND d.agent_code=#{request.agentCode}
|
|
</if>
|
|
<if test="request.areaCode!=null and request.areaCode!=''">
|
|
AND u.is_primary AND FIND_IN_SET(#{request.areaCode},fun_getPrimaryUserAreaCode(u.company_id))>0
|
|
</if>
|
|
<if test="request.question!=null and request.question!=''">
|
|
AND t.question=#{request.question}
|
|
</if>
|
|
<if test="request.warrantyStatus!=null">
|
|
AND d.warranty_state=#{request.warrantyStatus}
|
|
</if>
|
|
<if test="request.startTime!=null">
|
|
AND t.create_time>=#{request.startTime}
|
|
</if>
|
|
<if test="request.endTime!=null">
|
|
AND t.create_time <= #{request.endTime}
|
|
</if>
|
|
<if test="request.title!=null and request.title!=''">
|
|
AND (t.title LIKE CONCAT('%', #{request.title}, '%') OR t.no LIKE CONCAT('%', #{request.title}, '%'))
|
|
</if>
|
|
<if test="request.no!=null and request.no!=''">
|
|
AND (t.title LIKE CONCAT('%', #{request.no}, '%') OR t.no LIKE CONCAT('%', #{request.no}, '%'))
|
|
</if>
|
|
<if test="request.deviceNo!=null and request.deviceNo!=''">
|
|
AND t.device_no LIKE CONCAT('%', #{request.deviceNo}, '%')
|
|
</if>
|
|
<if test="request.createUserName!=null and request.createUserName!=''">
|
|
AND d.customer_name LIKE CONCAT('%', #{request.createUserName}, '%')
|
|
</if>
|
|
<if test="request.key!=null and request.key!=''">
|
|
AND (t.title LIKE CONCAT('%', #{request.key}, '%')
|
|
or t.device_no LIKE CONCAT('%', #{request.key}, '%')
|
|
or d.model_no LIKE CONCAT('%', #{request.key}, '%')
|
|
or t.description LIKE CONCAT('%', #{request.key},'%')
|
|
or p.part_name LIKE CONCAT('%', #{request.key}, '%')
|
|
)
|
|
</if>
|
|
</where>
|
|
</sql>
|
|
|
|
<select id="searchMy" resultType="com.nflg.mobilebroken.common.pojo.vo.TicketVO">
|
|
SELECT IF(u.is_primary,fun_getPrimaryUserArea(u.company_id),a2.`name`) AS 'areaName',IF(tf.id IS NULL, false, true) AS 'followed'
|
|
,IF(t.user_platform='admin',au.user_name,u.`name`) AS 'createBy',IF(LENGTH(l.language_value)>0,l.language_value,p.part_name) AS 'component',t.*
|
|
FROM gongfu_ticket t
|
|
LEFT JOIN app_user u ON t.user_id=u.id
|
|
LEFT JOIN admin_user au ON t.user_id=au.id
|
|
LEFT JOIN app_area a2 ON u.area_id=a2.id
|
|
LEFT JOIN gongfu_ticket_follow tf ON t.id=tf.ticket_id AND tf.user_id=#{userId} AND tf.from=IF(#{from}='app',0,1)
|
|
LEFT JOIN gongfu_ticket_evaluate te ON t.id=te.ticket_id AND t.state=2
|
|
LEFT JOIN gongfu_device_part p ON t.component_id=p.id
|
|
LEFT JOIN gongfu_device_part_language_data l ON p.id=l.source_id AND l.language_code=#{language}
|
|
WHERE t.user_id=#{userId} AND t.user_platform=#{from} AND t.state!=4
|
|
<include refid="searchWhereCondition"/>
|
|
ORDER BY t.id DESC
|
|
</select>
|
|
|
|
<select id="searchFollow" resultType="com.nflg.mobilebroken.common.pojo.vo.TicketVO">
|
|
SELECT IF(u.is_primary,fun_getPrimaryUserArea(u.company_id),a2.`name`) AS 'areaName',true AS 'followed'
|
|
,IF(t.user_platform='admin',au.user_name,u.`name`) AS 'createBy',true AS 'followed',t.handle,IF(LENGTH(l.language_value)>0
|
|
,l.language_value,p.part_name) AS 'component',t.*
|
|
FROM gongfu_ticket t
|
|
LEFT JOIN app_user u ON t.user_id=u.id
|
|
LEFT JOIN admin_user au ON t.user_id=au.id
|
|
LEFT JOIN app_area a2 ON u.area_id=a2.id
|
|
INNER JOIN gongfu_ticket_follow tf ON t.id=tf.ticket_id AND tf.from=IF(#{from}='app',0,1)
|
|
LEFT JOIN gongfu_ticket_evaluate te ON t.id=te.ticket_id AND t.state=2
|
|
LEFT JOIN gongfu_device_part p ON t.component_id=p.id
|
|
LEFT JOIN gongfu_device_part_language_data l ON p.id=l.source_id AND l.language_code=#{language}
|
|
WHERE tf.user_id=#{userId} AND t.user_platform=#{from} AND t.state!=4
|
|
<include refid="searchWhereCondition"/>
|
|
ORDER BY t.id DESC
|
|
</select>
|
|
|
|
<select id="searchArea" resultType="com.nflg.mobilebroken.common.pojo.vo.TicketVO">
|
|
SELECT IF(u.is_primary,fun_getPrimaryUserArea(u.company_id),a2.`name`) AS 'areaName'
|
|
,IF(tf.id IS NULL, false, true) AS 'followed',IF(t.user_platform='admin',au.user_name,u.`name`) AS 'createBy',IF(LENGTH(l.language_value)>0
|
|
,l.language_value,p.part_name) AS 'component',t.*
|
|
FROM gongfu_ticket t
|
|
LEFT JOIN app_user u ON t.user_id=u.id
|
|
LEFT JOIN admin_user au ON t.user_id=au.id
|
|
LEFT JOIN app_area a2 ON u.area_id=a2.id
|
|
LEFT JOIN ticket_follow tf ON t.id=tf.ticket_id AND tf.user_id=#{userId} AND tf.from=IF(#{from}='app',0,1)
|
|
LEFT JOIN ticket_evaluate te ON t.id=te.ticket_id AND t.state=2
|
|
LEFT JOIN gongfu_device_part p ON t.component_id=p.id
|
|
LEFT JOIN gongfu_device_part_language_data l ON p.id=l.source_id AND l.language_code=#{language}
|
|
LEFT JOIN v_device vd ON t.device_no=vd.device_no
|
|
WHERE t.state!=4
|
|
<if test="isPrimary==false">
|
|
AND FIND_IN_SET(#{companyId},u.company_id) AND vd.service_agent_code=#{companyCode}
|
|
</if>
|
|
<if test="isPrimary==true">
|
|
AND (u.id=#{userId} OR FIND_IN_SET(u.company_id,#{companyId}))
|
|
</if>
|
|
<if test="isPrimary==null">
|
|
AND t.user_platform='admin'
|
|
</if>
|
|
<include refid="searchWhereCondition"/>
|
|
ORDER BY t.id DESC
|
|
</select>
|
|
|
|
<select id="searchFromAdmin" resultType="com.nflg.mobilebroken.common.pojo.vo.AdminTicketVO">
|
|
SELECT t.id,t.`no`,t.title,t.state,t.urgency,p.part_name AS 'component',t.question,t.reason
|
|
,a1.area_name AS 'areaName','' AS 'agentAreaName',d.customer_name AS 'customerName',d.agent_name AS 'agentName'
|
|
,IF(t.user_platform='admin',au.user_name,u.`name`) AS 'createBy',t.device_no AS 'deviceNo',t.use_time AS 'useTime'
|
|
,t.create_time AS 'createTime',t.solve_time AS 'completeTime',di.name AS 'warrantyStatusDesc',d.device_type AS 'deviceType'
|
|
,d.model_no AS 'equipmentModel',d.shipment_date AS 'shipmentDate',IF(tf.id IS NULL, false, true) AS 'followed'
|
|
,auc.user_name AS 'cqm',t.update_time AS 'closeTime',auh.user_name AS 'currentHandle',dt2.cqm_person_name AS 'cqms'
|
|
,t.handle_name AS 'handle',t.description,t.throughput,t.accident_level
|
|
FROM gongfu_ticket t
|
|
LEFT JOIN app_user u ON t.user_id=u.id
|
|
LEFT JOIN admin_user au ON t.user_id=au.id
|
|
LEFT JOIN t_base_area a1 ON u.area_id=a1.id
|
|
LEFT JOIN gongfu_device d ON t.device_no=d.device_no and d.data_valid_state=1
|
|
LEFT JOIN gongfu_device_type dt1 ON dt1.parent_id=0 AND d.product_line=dt1.device_type
|
|
LEFT JOIN gongfu_device_type dt2 ON dt2.parent_id=dt1.id AND d.device_type=dt2.device_type
|
|
LEFT JOIN dictionary_item di ON d.warranty_state=di.id
|
|
LEFT JOIN ticket_follow tf ON t.id=tf.ticket_id AND tf.user_id=#{userId} AND tf.from=1
|
|
LEFT JOIN admin_user auc ON t.cqm=auc.id
|
|
LEFT JOIN admin_user auh ON t.current_handle=auh.id
|
|
LEFT JOIN gongfu_device_part p ON t.component_id=p.id
|
|
<include refid="adminSearchWhereCondition"/>
|
|
ORDER BY t.state,t.id DESC
|
|
</select>
|
|
|
|
<select id="searchAllFromAdmin" resultType="com.nflg.mobilebroken.common.pojo.vo.AdminTicketVO">
|
|
SELECT t.id,t.`no`,t.title,t.state,t.urgency,p.part_name AS 'component',t.question,t.reason
|
|
,a1.area_name AS 'areaName','' AS 'agentAreaName',d.customer_name AS 'customerName',d.agent_name AS 'agentName'
|
|
,IF(t.user_platform='admin',au.user_name,u.`name`) AS 'createBy',t.device_no AS 'deviceNo',t.use_time AS 'useTime'
|
|
,t.create_time AS 'createTime',t.solve_time AS 'completeTime',di.name AS 'warrantyStatusDesc',d.device_type AS 'deviceType'
|
|
,d.model_no AS 'equipmentModel',d.shipment_date AS 'shipmentDate',IF(tf.id IS NULL, false, true) AS 'followed'
|
|
,auc.user_name AS 'cqm',t.update_time AS 'closeTime',auh.user_name AS 'currentHandle',dt2.cqm_person_name AS 'cqms'
|
|
,t.handle_name AS 'handle',t.description,t.throughput
|
|
FROM gongfu_ticket t
|
|
LEFT JOIN app_user u ON t.user_id=u.id
|
|
LEFT JOIN admin_user au ON t.user_id=au.id
|
|
LEFT JOIN t_base_area a1 ON u.area_id=a1.id
|
|
LEFT JOIN gongfu_device d ON t.device_no=d.device_no and d.data_valid_state=1
|
|
LEFT JOIN gongfu_device_type dt1 ON dt1.parent_id=0 AND d.product_line=dt1.device_type
|
|
LEFT JOIN gongfu_device_type dt2 ON dt2.parent_id=dt1.id AND d.device_type=dt2.device_type
|
|
LEFT JOIN dictionary_item di ON d.warranty_state=di.id
|
|
LEFT JOIN ticket_follow tf ON t.id=tf.ticket_id AND tf.user_id=#{userId} AND tf.from=1
|
|
LEFT JOIN admin_user auc ON t.cqm=auc.id
|
|
LEFT JOIN admin_user auh ON t.current_handle=auh.id
|
|
LEFT JOIN gongfu_device_part p ON t.component_id=p.id
|
|
<include refid="adminSearchWhereCondition"/>
|
|
ORDER BY t.state,t.id DESC
|
|
</select>
|
|
|
|
<select id="searchFromAdminAndFollow" resultType="com.nflg.mobilebroken.common.pojo.vo.AdminTicketVO">
|
|
SELECT t.id,t.`no`,t.title,t.state,t.urgency,p.part_name AS 'component',t.question,t.reason
|
|
,a1.area_name AS 'areaName','' AS 'agentAreaName',d.customer_name AS 'customerName',d.agent_name AS 'agentName'
|
|
,IF(t.user_platform='admin',au.user_name,u.`name`) AS 'createBy',t.device_no AS 'deviceNo',t.use_time AS 'useTime'
|
|
,t.create_time AS 'createTime',t.solve_time AS 'completeTime',di.name AS 'warrantyStatusDesc',d.device_type AS 'deviceType'
|
|
,d.model_no AS 'equipmentModel',d.shipment_date AS 'shipmentDate',true AS 'followed',auc.user_name AS 'cqm'
|
|
,t.update_time AS 'closeTime',auh.user_name AS 'currentHandle',dt2.cqm_person_name AS 'cqms'
|
|
,t.handle_name AS 'handle',t.description,t.throughput
|
|
FROM gongfu_ticket t
|
|
LEFT JOIN app_user u ON t.user_id=u.id
|
|
LEFT JOIN admin_user au ON t.user_id=au.id
|
|
LEFT JOIN t_base_area a1 ON u.area_id=a1.id
|
|
INNER JOIN ticket_follow tf ON t.id=tf.ticket_id AND tf.user_id=#{userId} AND tf.from=1
|
|
LEFT JOIN gongfu_device d ON t.device_no=d.device_no and d.data_valid_state=1
|
|
LEFT JOIN gongfu_device_type dt1 ON dt1.parent_id=0 AND d.product_line=dt1.device_type
|
|
LEFT JOIN gongfu_device_type dt2 ON dt2.parent_id=dt1.id AND d.device_type=dt2.device_type
|
|
LEFT JOIN dictionary_item di ON d.warranty_state=di.id
|
|
LEFT JOIN admin_user auc ON t.cqm=auc.id
|
|
LEFT JOIN admin_user auh ON t.current_handle=auh.id
|
|
LEFT JOIN gongfu_device_part p ON t.component_id=p.id
|
|
<include refid="adminSearchWhereCondition"/>
|
|
ORDER BY t.state,t.id DESC
|
|
</select>
|
|
|
|
<select id="searchAllFromAdminAndFollow" resultType="com.nflg.mobilebroken.common.pojo.vo.AdminTicketVO">
|
|
SELECT t.id,t.`no`,t.title,t.state,t.urgency,p.part_name AS 'component',t.question,t.reason
|
|
,a1.area_name AS 'areaName','' AS 'agentAreaName',d.customer_name AS 'customerName',d.agent_name AS 'agentName'
|
|
,IF(t.user_platform='admin',au.user_name,u.`name`) AS 'createBy',t.device_no AS 'deviceNo',t.use_time AS 'useTime'
|
|
,t.create_time AS 'createTime',t.solve_time AS 'completeTime',di.name AS 'warrantyStatusDesc',true AS 'followed'
|
|
,auc.user_name AS 'cqm',t.update_time AS 'closeTime',auh.user_name AS 'currentHandle'
|
|
,dt2.cqm_person_name AS 'cqms',t.handle_name AS 'handle',t.description,t.throughput
|
|
FROM gongfu_ticket t
|
|
LEFT JOIN app_user u ON t.user_id=u.id
|
|
LEFT JOIN admin_user au ON t.user_id=au.id
|
|
LEFT JOIN t_base_area a1 ON u.area_id=a1.id
|
|
INNER JOIN ticket_follow tf ON t.id=tf.ticket_id AND tf.user_id=#{userId} AND tf.from=1
|
|
LEFT JOIN gongfu_device d ON t.device_no=d.device_no and d.data_valid_state=1
|
|
LEFT JOIN gongfu_device_type dt1 ON dt1.parent_id=0 AND d.product_line=dt1.device_type
|
|
LEFT JOIN gongfu_device_type dt2 ON dt2.parent_id=dt1.id AND d.device_type=dt2.device_type
|
|
LEFT JOIN dictionary_item di ON d.warranty_state=di.id
|
|
LEFT JOIN admin_user auc ON t.cqm=auc.id
|
|
LEFT JOIN admin_user auh ON t.current_handle=auh.id
|
|
LEFT JOIN gongfu_device_part p ON t.component_id=p.id
|
|
<include refid="adminSearchWhereCondition"/>
|
|
ORDER BY t.state,t.id DESC
|
|
</select>
|
|
|
|
<select id="getAdminFavorites" resultType="com.nflg.mobilebroken.common.pojo.vo.TicketVO">
|
|
SELECT t.id, t.no, t.title
|
|
FROM ticket_follow tf
|
|
INNER JOIN gongfu_ticket t ON tf.ticket_id = t.id
|
|
WHERE tf.`from` = 1
|
|
AND tf.user_id = #{userId} AND tf.from=IF(#{from}='app',0,1)
|
|
AND tf.favorites_id = #{favoritesId}
|
|
and tf.ticket_type=1
|
|
ORDER BY t.state,t.id DESC
|
|
</select>
|
|
|
|
<select id="searchByFavouritesId" resultType="com.nflg.mobilebroken.common.pojo.vo.AdminTicketVO">
|
|
SELECT t.id,t.`no`,t.title,t.state,t.urgency,p.part_name AS 'component',t.question,t.reason
|
|
,a1.area_name AS 'areaName','' AS 'agentAreaName',d.customer_name AS 'customerName',d.agent_name AS 'agentName'
|
|
,IF(t.user_platform='admin',au.user_name,u.`name`) AS 'createBy',t.device_no AS 'deviceNo',t.use_time AS 'useTime'
|
|
,t.create_time AS 'createTime',t.solve_time AS 'completeTime',di.name AS 'warrantyStatusDesc',d.device_type AS 'deviceType'
|
|
,d.model_no AS 'equipmentModel',d.shipment_date AS 'shipmentDate',true AS 'followed',auc.user_name AS 'cqm'
|
|
,t.update_time AS 'closeTime',auh.user_name AS 'currentHandle',dt2.cqm_person_name AS 'cqms'
|
|
,t.handle_name AS 'handle',t.description,t.throughput
|
|
FROM gongfu_ticket t
|
|
LEFT JOIN app_user u ON t.user_id=u.id
|
|
LEFT JOIN admin_user au ON t.user_id=au.id
|
|
LEFT JOIN t_base_area a1 ON u.area_id=a1.id
|
|
INNER JOIN ticket_follow tf ON t.id=tf.ticket_id AND tf.user_id=#{userId} AND tf.from=1
|
|
<if test="favouritesId>0">
|
|
AND tf.favorites_id=#{favouritesId}
|
|
</if>
|
|
LEFT JOIN gongfu_device d ON t.device_no=d.device_no and d.data_valid_state=1
|
|
LEFT JOIN gongfu_device_type dt1 ON dt1.parent_id=0 AND d.product_line=dt1.device_type
|
|
LEFT JOIN gongfu_device_type dt2 ON dt2.parent_id=dt1.id AND d.device_type=dt2.device_type
|
|
LEFT JOIN dictionary_item di ON d.warranty_state=di.id
|
|
LEFT JOIN admin_user auc ON t.cqm=auc.id
|
|
LEFT JOIN admin_user auh ON t.current_handle=auh.id
|
|
LEFT JOIN gongfu_device_part p ON t.component_id=p.id
|
|
ORDER BY t.state,t.id DESC
|
|
</select>
|
|
|
|
<select id="getEquipmentFailureRanking" resultType="com.nflg.mobilebroken.common.pojo.vo.EquipmentFailureRankingVO">
|
|
SELECT device_no,COUNT(1) num
|
|
FROM gongfu_ticket
|
|
WHERE state!=4 and create_time>=#{startDate} and create_time < #{endDate}
|
|
<if test="deviceNo!=null and deviceNo!=''">
|
|
AND device_no = #{deviceNo}
|
|
</if>
|
|
GROUP BY device_no
|
|
ORDER BY num DESC,device_no
|
|
LIMIT #{num}
|
|
</select>
|
|
|
|
<select id="companyStatistics" resultType="com.nflg.mobilebroken.common.pojo.vo.CompanyStatisticsVO">
|
|
SELECT d.agent_name as name,COUNT(1) as num
|
|
FROM gongfu_ticket t
|
|
INNER JOIN v_gongfu_device d ON t.device_no=d.device_no
|
|
where t.create_time >= #{startDate} and t.create_time < #{endDate}
|
|
GROUP BY d.agent_name
|
|
ORDER BY COUNT(1) DESC
|
|
LIMIT #{num}
|
|
</select>
|
|
</mapper>
|