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.DeviceMapper" >
<select id= "getByDeviceNo" resultType= "com.nflg.mobilebroken.common.pojo.vo.DeviceInfoVO" >
2025-04-01 18:49:42 +08:00
SELECT d.device_no AS 'deviceNo'
, d.model_no AS 'modelNo'
, d.device_type AS 'deviceType'
, d.device_type_sub AS 'deviceTypeSub'
, d.warranty_state AS 'warrantyState'
, d.shipment_date AS 'shipmentDate'
, d.start_warranty_date AS 'startWarrantyDate'
, d.warranty_month AS 'warrantyMonth'
, d.customer_name AS 'customerName'
, dc.id AS 'componentId'
, d.agent_name
2025-01-19 11:30:15 +08:00
FROM device d
2025-04-01 18:49:42 +08:00
LEFT JOIN device_component dc ON d.model_no = dc.model_no AND dc.`enable` = 1
WHERE d.device_no = #{deviceNo}
ORDER BY d.data_valid_state DESC,d.device_state
LIMIT 1;
2025-01-19 11:30:15 +08:00
</select>
2025-01-25 23:30:44 +08:00
<sql id= "whr" >
<if test= "query.deviceNo!=null and query.deviceNo!=''" >
2025-04-03 10:01:08 +08:00
and a.device_no LIKE concat('%', #{query.deviceNo}, '%')
2025-01-25 23:30:44 +08:00
</if>
<if test= "query.customerName!=null and query.customerName!=''" >
2025-04-03 10:01:08 +08:00
and a.customer_name LIKE concat('%', #{query.customerName}, '%')
2025-01-25 23:30:44 +08:00
</if>
<if test= "query.agentName!=null and query.agentName!=''" >
2025-02-20 22:30:39 +08:00
and a.agent_name=#{query.agentName}
2025-01-25 23:30:44 +08:00
</if>
<if test= "query.modelNo!=null and query.modelNo!=''" >
2025-04-03 10:01:08 +08:00
and a.model_no LIKE concat('%', #{query.modelNo}, '%')
2025-01-25 23:30:44 +08:00
</if>
<if test= "query.warrantyState!=null and query.warrantyState!=''" >
2025-02-20 22:30:39 +08:00
and a.warranty_state=#{query.warrantyState}
2025-01-25 23:30:44 +08:00
</if>
<if test= "query.warrantyStartDate!=null and query.warrantyStartDate!=''" >
2025-04-03 10:01:08 +08:00
and a.start_warranty_date > = #{query.warrantyStartDate} and start_warranty_date < =
#{query.warrantyEndDate}
2025-01-25 23:30:44 +08:00
</if>
</sql>
<select id= "getList" resultType= "com.nflg.mobilebroken.repository.entity.Device" >
2025-02-20 22:30:39 +08:00
select a.id, device_no, device_name, device_type, device_type_sub, model_no, customer_id, customer_name, device_state, agent_code, agent_name, shipment_date, warranty_state, start_warranty_date, warranty_month, data_valid_state, source_from, create_by, create_time, update_by, update_time, remark ,b.area_code ,b.area_name from device a
left join t_base_customer b on a.agent_code=b.agency_company_code
where data_valid_state=1
2025-01-25 23:30:44 +08:00
<include refid= "whr" />
</select>
<update id= "batchDelByIds" >
update device set data_valid_state=0 where id in
<foreach collection= "ids" open= "(" close= ")" item= "item" separator= "," >
#{item}
</foreach>
</update>
2025-02-12 15:39:20 +08:00
<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'
FROM device d
2025-02-13 14:11:41 +08:00
INNER JOIN t_base_customer c ON d.agent_code=c.agency_company_code
2025-03-07 15:42:29 +08:00
INNER JOIN dictionary_item di ON di.id=d.device_state
WHERE d.data_valid_state=1 AND di.`code`='Normal' AND c.id IN
2025-02-12 15:39:20 +08:00
<foreach collection= "companyIds" open= "(" close= ")" item= "companyId" separator= "," >
#{companyId}
</foreach>
2025-02-13 22:33:33 +08:00
<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>
2025-02-12 15:39:20 +08:00
</select>
2025-02-22 18:19:29 +08:00
<!-- 定时任务 - 质保未开始 -->
<update id= "taskWarrantyStateNotStarted" >
update 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 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 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>
2025-03-04 20:04:15 +08:00
<select id= "getComponents" resultType= "com.nflg.mobilebroken.common.pojo.vo.ComponentInfo" >
2025-04-25 11:00:06 +08:00
SELECT p.id, if(LENGTH(ld.language_value)>0,ld.language_value,p.part_name) AS 'name'
2025-03-04 20:04:15 +08:00
FROM device_component_detail dcd
2025-03-07 15:42:29 +08:00
INNER JOIN t_base_part p ON dcd.model_part_id = p.id
LEFT JOIN t_base_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}
2025-03-04 20:04:15 +08:00
</select>
2025-03-09 17:27:42 +08:00
<select id= "getAgents" resultType= "com.nflg.mobilebroken.common.pojo.vo.DeviceAgentVO" >
SELECT DISTINCT agent_code,agent_name
FROM device
WHERE LENGTH(agent_code)>0
</select>
2025-01-19 11:30:15 +08:00
</mapper>