128 lines
6.6 KiB
XML
128 lines
6.6 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.DeviceMapper">
|
|
|
|
<select id="getByDeviceNo" resultType="com.nflg.mobilebroken.common.pojo.vo.DeviceInfoVO">
|
|
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
|
|
,c.area_name
|
|
FROM device d
|
|
LEFT JOIN 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
|
|
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.Device">
|
|
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
|
|
<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>
|
|
|
|
<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 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 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>
|
|
|
|
<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 device_component_detail dcd
|
|
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}
|
|
</select>
|
|
|
|
<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>
|
|
</mapper>
|