2025-11-18 18:03:20 +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.GongfuDeviceMapper" >
<select id= "getByDeviceNo" resultType= "com.nflg.mobilebroken.common.pojo.vo.DeviceInfoVO" >
2025-11-19 17:50:18 +08:00
SELECT d.*, dc.id AS 'componentId',c.area_name
2025-11-18 18:03:20 +08:00
FROM gongfu_device d
LEFT JOIN gongfu_device_component dc ON d.model_no = dc.model_no AND dc.`enable` = 1
LEFT JOIN t_base_customer c ON c.agency_company_code=d.agent_code
WHERE d.device_no = #{deviceNo}
ORDER BY d.data_valid_state DESC,d.device_state DESC
LIMIT 1;
</select>
<sql id= "whr" >
<if test= "query.deviceNo!=null and query.deviceNo!=''" >
and a.device_no LIKE concat('%', #{query.deviceNo}, '%')
</if>
<if test= "query.customerName!=null and query.customerName!=''" >
and a.customer_name LIKE concat('%', #{query.customerName}, '%')
</if>
<if test= "query.agentName!=null and query.agentName!=''" >
and a.agent_name=#{query.agentName}
</if>
<if test= "query.modelNo!=null and query.modelNo!=''" >
and a.model_no LIKE concat('%', #{query.modelNo}, '%')
</if>
<if test= "query.warrantyState!=null and query.warrantyState!=''" >
and a.warranty_state=#{query.warrantyState}
</if>
<if test= "query.warrantyStartDate!=null and query.warrantyStartDate!=''" >
and a.start_warranty_date > = #{query.warrantyStartDate} and start_warranty_date < =
#{query.warrantyEndDate}
</if>
</sql>
<select id= "getList" resultType= "com.nflg.mobilebroken.repository.entity.GongfuDevice" >
2025-11-19 17:50:18 +08:00
select a.* ,b.area_code ,b.area_name
from gongfu_device a
2025-11-18 18:03:20 +08:00
left join t_base_customer b on a.agent_code=b.agency_company_code
where data_valid_state=1
<include refid= "whr" />
2025-11-19 17:50:18 +08:00
order by a.id desc
2025-11-18 18:03:20 +08:00
</select>
<update id= "batchDelByIds" >
update gongfu_device set data_valid_state=0 where id in
<foreach collection= "ids" open= "(" close= ")" item= "item" separator= "," >
#{item}
</foreach>
</update>
<select id= "searchDevice" resultType= "com.nflg.mobilebroken.common.pojo.vo.DeviceVO" >
SELECT d.device_no AS 'deviceNo',d.device_name AS 'deviceName',d.model_no AS 'modelNo'
,d.device_type AS 'deviceType',d.shipment_date AS 'shipmentDate',IFNULL(dit2.value,di2.value) AS 'warrantyState'
FROM gongfu_device d
INNER JOIN t_base_customer c ON d.agent_code=c.agency_company_code
INNER JOIN dictionary_item di ON di.id=d.device_state
LEFT JOIN dictionary_item di2 ON di2.id=d.warranty_state
LEFT JOIN dictionary_item_translate dit2 ON dit2.dictionary_item_id=d.warranty_state AND dit2.language_code=#{language}
WHERE d.data_valid_state=1 AND di.`code`='Normal'
<if test= "companyIds!=null" >
AND c.id IN
<foreach collection= "companyIds" open= "(" close= ")" item= "companyId" separator= "," >
#{companyId}
</foreach>
</if>
<if test= "request.deviceNo!=null and request.deviceNo!=''" >
and d.device_no LIKE concat('%', #{request.deviceNo}, '%')
</if>
<if test= "request.modelNo!=null and request.modelNo!=''" >
and d.model_no LIKE concat('%', #{request.modelNo}, '%')
</if>
<if test= "request.startTime!=null and request.startTime!=''" >
and d.shipment_date >= #{request.startTime}
</if>
<if test= "request.endTime!=null and request.endTime!=''" >
and d.shipment_date < = #{request.endTime}
</if>
<if test= "request.key!=null and request.key!=''" >
and (d.device_no LIKE concat('%', #{request.key}, '%') or d.model_no LIKE concat('%', #{request.key}, '%'))
</if>
</select>
<!-- 定时任务 - 质保未开始 -->
<update id= "taskWarrantyStateNotStarted" >
update gongfu_device set warranty_state=(select b.id from dictionary a
join dictionary_item b on a.id=b.dictionary_id
where a.code='deviceWarrantyState' and b.`code`='NotStarted') where start_warranty_date>now();
</update>
<!-- 定时任务 - 质保外 -->
<update id= "taskWarrantyStateNotOutsideWarranty" >
update gongfu_device set warranty_state=(select b.id from dictionary a
join dictionary_item b on a.id=b.dictionary_id
where a.code='deviceWarrantyState' and b.`code`='OutsideWarranty') where DATE_ADD(start_warranty_date, INTERVAL warranty_month MONTH) < now();
</update>
<!-- 定时任务 - 质保内 -->
<update id= "taskWarrantyStateNotOutsideWithinWarranty" >
update gongfu_device set warranty_state=(select b.id from dictionary a
join dictionary_item b on a.id=b.dictionary_id
where a.code='deviceWarrantyState' and b.`code`='WithinWarranty') where start_warranty_date < = now() and DATE_ADD(start_warranty_date, INTERVAL warranty_month MONTH) > = now() ;
</update>
<select id= "getComponents" resultType= "com.nflg.mobilebroken.common.pojo.vo.ComponentInfo" >
SELECT p.id, if(LENGTH(ld.language_value)>0,ld.language_value,p.part_name) AS 'name'
FROM gongfu_device_component_detail dcd
INNER JOIN gongfu_device_part p ON dcd.model_part_id = p.id
LEFT JOIN gongfu_device_part_language_data ld ON dcd.model_part_id = ld.source_id
WHERE p.enable=1 AND dcd.device_component_id=#{componentId} AND ld.language_code=#{language}
</select>
<select id= "getAgents" resultType= "com.nflg.mobilebroken.common.pojo.vo.DeviceAgentVO" >
SELECT DISTINCT agent_code,agent_name
FROM gongfu_device
WHERE LENGTH(agent_code)>0
</select>
2025-11-24 17:53:06 +08:00
<select id= "getCustomerNames" resultType= "java.lang.String" >
SELECT DISTINCT customer_name
FROM v_all_device
</select>
2025-11-18 18:03:20 +08:00
</mapper>