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

224 lines
12 KiB
XML
Raw Normal View History

2025-01-19 11:30:15 +08:00
<?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.TicketMapper">
<sql id="searchWhereCondition">
2025-02-13 14:11:41 +08:00
<if test="request.areaIds!=null">
AND u.area_id IN
<foreach collection="request.areaIds" item="areaId" open="(" separator="," close=")">
#{areaId}
</foreach>
</if>
2025-01-27 16:08:17 +08:00
<if test="request.title!=null and request.title!=''">
2025-02-12 20:30:31 +08:00
AND (t.title LIKE CONCAT('%', #{request.title}, '%') OR t.no LIKE CONCAT('%', #{request.title}, '%'))
2025-01-19 11:30:15 +08:00
</if>
2025-01-27 16:08:17 +08:00
<if test="request.deviceNo!=null and request.deviceNo!=''">
2025-01-19 11:30:15 +08:00
AND t.device_no LIKE CONCAT('%', #{request.deviceNo}, '%')
</if>
2025-01-27 16:08:17 +08:00
<if test="request.component!=null and request.component!=''">
2025-02-13 14:11:41 +08:00
AND t.component=#{request.component}
2025-01-19 11:30:15 +08:00
</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 &lt; #{request.endTime}
</if>
</sql>
2025-01-25 23:11:05 +08:00
<sql id="adminSearchWhereCondition">
<where>
2025-02-14 17:00:34 +08:00
t.state!=4
2025-02-28 22:31:37 +08:00
<if test="!request.ticketManager">
AND FIND_IN_SET(#{userId},t.handle)>0
</if>
2025-01-25 23:11:05 +08:00
<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.component!=null and request.component!=''">
AND t.component=#{request.component}
</if>
<if test="request.handleUserName!=null and request.handleUserName!=''">
2025-02-19 15:37:49 +08:00
AND t.handle_name LIKE CONCAT('%', #{request.handleUserName}, '%')
2025-01-25 23:11:05 +08:00
</if>
<if test="request.companyId!=null">
AND u.company_id=#{request.companyId}
</if>
<if test="request.areaId!=null">
AND u.area_id=#{request.areaId}
</if>
<if test="request.question!=null and request.question!=''">
AND t.question=#{request.question}
</if>
2025-02-19 15:37:49 +08:00
<if test="request.warrantyStatus!=null">
AND d.warranty_state=#{request.warrantyStatus}
2025-01-25 23:11:05 +08:00
</if>
<if test="request.startTime!=null">
AND t.create_time>=#{request.startTime}
</if>
<if test="request.endTime!=null">
AND t.create_time &lt;= #{request.endTime}
</if>
2025-02-19 15:37:49 +08:00
<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.createUserName!=null and request.createUserName!=''">
AND d.customer_name LIKE CONCAT('%', #{request.createUserName}, '%')
</if>
2025-01-25 23:11:05 +08:00
</where>
</sql>
2025-01-19 11:30:15 +08:00
<select id="searchMy" resultType="com.nflg.mobilebroken.common.pojo.vo.TicketVO">
2025-02-18 22:54:48 +08:00
SELECT t.*,IF(u.is_primary,a1.area_name,a2.`name`) AS 'areaName',IF(tf.id IS NULL, false, true) AS 'followed'
,u.`name` AS 'createBy',t.handle
2025-01-19 11:30:15 +08:00
FROM ticket t
2025-02-06 13:19:24 +08:00
LEFT JOIN app_user u ON t.user_id=u.id
2025-02-17 20:51:37 +08:00
LEFT JOIN t_base_area a1 ON u.area_id=a1.id
LEFT JOIN app_area a2 ON u.area_id=a2.id
2025-02-09 23:49:05 +08:00
LEFT JOIN ticket_follow tf ON t.id=tf.ticket_id AND tf.user_id=#{userId} AND tf.from=0
2025-02-15 16:46:29 +08:00
WHERE t.user_id=#{userId} AND t.state!=4
2025-01-19 11:30:15 +08:00
<include refid="searchWhereCondition"/>
2025-02-19 15:37:49 +08:00
ORDER BY t.id DESC
2025-01-19 11:30:15 +08:00
</select>
2025-01-25 23:11:05 +08:00
2025-01-19 11:30:15 +08:00
<select id="searchFollow" resultType="com.nflg.mobilebroken.common.pojo.vo.TicketVO">
2025-02-17 20:51:37 +08:00
SELECT t.*,IF(u.is_primary,a1.area_name,a2.`name`) AS 'areaName',true AS 'followed',u.`name` AS 'createBy',true AS 'followed',t.handle
2025-01-19 11:30:15 +08:00
FROM ticket t
2025-02-06 13:19:24 +08:00
LEFT JOIN app_user u ON t.user_id=u.id
2025-02-17 20:51:37 +08:00
LEFT JOIN t_base_area a1 ON u.area_id=a1.id
LEFT JOIN app_area a2 ON u.area_id=a2.id
2025-02-26 20:22:19 +08:00
INNER JOIN ticket_follow tf ON t.id=tf.ticket_id AND tf.from=0
2025-02-15 16:46:29 +08:00
WHERE tf.user_id=#{userId} AND t.state!=4
2025-01-19 11:30:15 +08:00
<include refid="searchWhereCondition"/>
2025-02-19 15:37:49 +08:00
ORDER BY t.id DESC
2025-01-19 11:30:15 +08:00
</select>
2025-01-25 23:11:05 +08:00
2025-01-19 11:30:15 +08:00
<select id="searchArea" resultType="com.nflg.mobilebroken.common.pojo.vo.TicketVO">
2025-02-18 22:54:48 +08:00
SELECT t.*,IF(u.is_primary,a1.area_name,a2.`name`) AS 'areaName',IF(tf.id IS NULL, false, true) AS 'followed'
,u.`name` AS 'createBy',t.handle
2025-01-19 11:30:15 +08:00
FROM ticket t
2025-02-17 20:51:37 +08:00
LEFT JOIN app_user u ON t.user_id=u.id
LEFT JOIN t_base_area a1 ON u.area_id=a1.id
LEFT JOIN app_area a2 ON u.area_id=a2.id
2025-02-26 20:22:19 +08:00
LEFT JOIN ticket_follow tf ON t.id=tf.ticket_id AND tf.user_id=#{userId} AND tf.from=0
2025-02-15 16:46:29 +08:00
WHERE t.state!=4 AND u.company_id IN
2025-02-03 16:01:20 +08:00
<foreach collection="companyIds" item="companyId" open="(" separator="," close=")">
#{companyId}
</foreach>
2025-01-19 11:30:15 +08:00
<include refid="searchWhereCondition"/>
2025-02-19 15:37:49 +08:00
ORDER BY t.id DESC
2025-01-19 11:30:15 +08:00
</select>
2025-01-25 23:11:05 +08:00
2025-02-05 13:14:52 +08:00
<select id="searchFromAdmin" resultType="com.nflg.mobilebroken.common.pojo.vo.AdminTicketVO">
2025-02-17 20:51:37 +08:00
SELECT t.id,t.`no`,t.title,t.state,t.urgency,t.component,t.question,t.solution,IF(u.is_primary,a1.area_name,a2.`name`) AS 'areaName'
2025-02-13 14:11:41 +08:00
,d.customer_name AS 'companyName',u.company_id AS 'companyId',u.`name` AS 'createBy',t.device_no AS 'deviceNo',t.use_time AS 'useTime'
2025-02-19 15:37:49 +08:00
,t.create_time AS 'createTime',t.update_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.solve_time AS 'closeTime',u.name AS 'primaryUserName',auh.user_name AS 'currentHandle',dt.cqm_person_name AS 'cqms'
,t.handle_name AS 'handle'
2025-01-25 23:11:05 +08:00
FROM ticket t
LEFT JOIN app_user u ON t.user_id=u.id
2025-01-27 22:34:35 +08:00
LEFT JOIN t_base_customer c ON u.company_id=c.id
2025-02-17 20:51:37 +08:00
LEFT JOIN t_base_area a1 ON u.area_id=a1.id
LEFT JOIN app_area a2 ON u.area_id=a2.id
2025-02-05 13:14:52 +08:00
LEFT JOIN device d ON t.device_no=d.device_no AND d.data_valid_state=1
2025-02-19 15:37:49 +08:00
LEFT JOIN t_base_device_type dt ON d.device_type=dt.device_type
2025-02-05 13:14:52 +08:00
LEFT JOIN dictionary_item di ON d.warranty_state=di.id
2025-02-11 22:42:46 +08:00
LEFT JOIN ticket_follow tf ON t.id=tf.ticket_id AND tf.user_id=#{userId} AND tf.from=1
2025-02-19 15:37:49 +08:00
LEFT JOIN admin_user auc ON t.cqm=auc.id
LEFT JOIN admin_user auh ON t.current_handle=auh.id
2025-01-25 23:11:05 +08:00
<include refid="adminSearchWhereCondition"/>
2025-02-19 15:37:49 +08:00
ORDER BY t.id DESC
2025-01-25 23:11:05 +08:00
</select>
2025-02-15 21:50:04 +08:00
<!-- <select id="completeTicket">-->
<!-- UPDATE ticket-->
<!-- SET state=2,update_time=NOW()-->
<!-- WHERE state=1 AND FIND_IN_SET(#{userId},handle)>0 AND id IN-->
<!-- <foreach collection="ids" item="id" open="(" separator="," close=")">-->
<!-- #{id}-->
<!-- </foreach>-->
<!-- </select>-->
2025-01-25 23:11:05 +08:00
<select id="searchAllFromAdmin" resultType="com.nflg.mobilebroken.common.pojo.vo.AdminTicketVO">
2025-02-17 20:51:37 +08:00
SELECT t.id,t.`no`,t.title,t.state,t.urgency,t.component,t.question,t.solution,IF(u.is_primary,a1.area_name,a2.`name`) AS 'areaName'
2025-02-13 14:11:41 +08:00
,d.customer_name AS 'companyName',u.company_id AS 'companyId',u.`name` AS 'createBy',t.device_no AS 'deviceNo',t.use_time AS 'useTime'
2025-02-19 15:37:49 +08:00
,t.create_time AS 'createTime',t.update_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.solve_time AS 'closeTime',u.name AS 'primaryUserName',auh.user_name AS 'currentHandle',dt.cqm_person_name AS 'cqms'
,t.handle_name AS 'handle'
2025-01-25 23:11:05 +08:00
FROM ticket t
LEFT JOIN app_user u ON t.user_id=u.id
2025-01-27 22:34:35 +08:00
LEFT JOIN t_base_customer c ON u.company_id=c.id
2025-02-17 20:51:37 +08:00
LEFT JOIN t_base_area a1 ON u.area_id=a1.id
LEFT JOIN app_area a2 ON u.area_id=a2.id
2025-02-05 13:14:52 +08:00
LEFT JOIN device d ON t.device_no=d.device_no AND d.data_valid_state=1
2025-02-19 15:37:49 +08:00
LEFT JOIN t_base_device_type dt ON d.device_type=dt.device_type
2025-02-05 13:14:52 +08:00
LEFT JOIN dictionary_item di ON d.warranty_state=di.id
2025-02-19 15:37:49 +08:00
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
2025-01-25 23:11:05 +08:00
<include refid="adminSearchWhereCondition"/>
2025-02-19 15:37:49 +08:00
ORDER BY t.id DESC
2025-01-25 23:11:05 +08:00
</select>
2025-02-05 13:14:52 +08:00
<select id="searchFromAdminAndFollow" resultType="com.nflg.mobilebroken.common.pojo.vo.AdminTicketVO">
2025-02-17 20:51:37 +08:00
SELECT t.id,t.`no`,t.title,t.state,t.urgency,t.component,t.question,t.solution,IF(u.is_primary,a1.area_name,a2.`name`) AS 'areaName'
2025-02-13 14:11:41 +08:00
,d.customer_name AS 'companyName',u.company_id AS 'companyId',u.`name` AS 'createBy',t.device_no AS 'deviceNo',t.use_time AS 'useTime'
2025-02-19 15:37:49 +08:00
,t.create_time AS 'createTime',t.update_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.solve_time AS 'closeTime',u.name AS 'primaryUserName',auh.user_name AS 'currentHandle',dt.cqm_person_name AS 'cqms'
,t.handle_name AS 'handle'
2025-01-25 23:11:05 +08:00
FROM ticket t
LEFT JOIN app_user u ON t.user_id=u.id
2025-01-27 22:34:35 +08:00
LEFT JOIN t_base_customer c ON u.company_id=c.id
2025-02-17 20:51:37 +08:00
LEFT JOIN t_base_area a1 ON u.area_id=a1.id
LEFT JOIN app_area a2 ON u.area_id=a2.id
2025-02-09 23:49:05 +08:00
INNER JOIN ticket_follow tf ON t.id=tf.ticket_id AND tf.user_id=#{userId} AND tf.from=1
2025-02-05 13:14:52 +08:00
LEFT JOIN device d ON t.device_no=d.device_no AND d.data_valid_state=1
2025-02-19 15:37:49 +08:00
LEFT JOIN t_base_device_type dt ON d.device_type=dt.device_type
2025-02-05 13:14:52 +08:00
LEFT JOIN dictionary_item di ON d.warranty_state=di.id
2025-02-19 15:37:49 +08:00
LEFT JOIN admin_user auc ON t.cqm=auc.id
LEFT JOIN admin_user auh ON t.current_handle=auh.id
2025-01-25 23:11:05 +08:00
<include refid="adminSearchWhereCondition"/>
2025-02-19 15:37:49 +08:00
ORDER BY t.id DESC
2025-01-25 23:11:05 +08:00
</select>
<select id="searchAllFromAdminAndFollow" resultType="com.nflg.mobilebroken.common.pojo.vo.AdminTicketVO">
2025-02-17 20:51:37 +08:00
SELECT t.id,t.`no`,t.title,t.state,t.urgency,t.component,t.question,t.solution,IF(u.is_primary,a1.area_name,a2.`name`) AS 'areaName'
2025-02-13 14:11:41 +08:00
,d.customer_name AS 'companyName',u.company_id AS 'companyId',u.`name` AS 'createBy',t.device_no AS 'deviceNo',t.use_time AS 'useTime'
2025-02-19 15:37:49 +08:00
,t.create_time AS 'createTime',t.update_time AS 'completeTime',di.name AS 'warrantyStatusDesc',IF(tf.id IS NULL, false, true) AS 'followed'
,auc.user_name AS 'cqm',t.solve_time AS 'closeTime',u.name AS 'primaryUserName',auh.user_name AS 'currentHandle'
,dt.cqm_person_name AS 'cqms',t.handle_name AS 'handle'
2025-01-25 23:11:05 +08:00
FROM ticket t
LEFT JOIN app_user u ON t.user_id=u.id
2025-01-27 22:34:35 +08:00
LEFT JOIN t_base_customer c ON u.company_id=c.id
2025-02-17 20:51:37 +08:00
LEFT JOIN t_base_area a1 ON u.area_id=a1.id
LEFT JOIN app_area a2 ON u.area_id=a2.id
2025-02-09 23:49:05 +08:00
INNER JOIN ticket_follow tf ON t.id=tf.ticket_id AND tf.user_id=#{userId} AND tf.from=1
2025-02-05 13:14:52 +08:00
LEFT JOIN device d ON t.device_no=d.device_no AND d.data_valid_state=1
2025-02-19 15:37:49 +08:00
LEFT JOIN t_base_device_type dt ON d.device_type=dt.device_type
2025-02-05 13:14:52 +08:00
LEFT JOIN dictionary_item di ON d.warranty_state=di.id
2025-02-19 15:37:49 +08:00
LEFT JOIN admin_user auc ON t.cqm=auc.id
LEFT JOIN admin_user auh ON t.current_handle=auh.id
2025-01-25 23:11:05 +08:00
<include refid="adminSearchWhereCondition"/>
2025-02-19 15:37:49 +08:00
ORDER BY t.id DESC
2025-01-25 23:11:05 +08:00
</select>
2025-03-02 10:00:30 +08:00
<select id="getAdminFavorites" resultType="com.nflg.mobilebroken.common.pojo.vo.TicketVO">
SELECT t.id,t.no,t.title
FROM ticket_follow tf
INNER JOIN ticket t ON tf.ticket_id=t.id
WHERE tf.`from`=1 AND tf.favorites_id=#{favoritesId}
</select>
2025-01-19 11:30:15 +08:00
</mapper>