<?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.thhy.materials.modules.biz.gpsdevice.mapper.GpsDeviceMapper">
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
t.gd_id as gdId,
|
t.company_id as companyId,
|
t.create_time as createTime,
|
t.create_user as createUser,
|
t.gd_imei as gdImei,
|
t.gd_name as gdName,
|
t.is_use as isUse,
|
t.remark as remark
|
</sql>
|
|
<sql id="condition_query">
|
<where>
|
<trim suffixOverrides=" AND ">
|
t.is_use = 1 AND
|
<if test="companyId!=null and companyId!=''">
|
t.company_id = #{companyId} AND
|
</if>
|
<if test="createTime!=null">
|
t.create_time = #{createTime} AND
|
</if>
|
<if test="createUser!=null and createUser!=''">
|
t.create_user = #{createUser} AND
|
</if>
|
<if test="gdImei!=null and gdImei!=''">
|
t.gd_imei = #{gdImei} AND
|
</if>
|
<if test="gdName!=null and gdName!=''">
|
t.gd_name LIKE concat('%',#{gdName},'%') AND
|
</if>
|
<if test="isUse!=null">
|
t.is_use = #{isUse} AND
|
</if>
|
<if test="remark!=null and remark!=''">
|
t.remark = #{remark} AND
|
</if>
|
</trim>
|
</where>
|
</sql>
|
|
<select id="queryById" resultType="com.thhy.materials.modules.biz.gpsdevice.entity.GpsDevice">
|
select <include refid="Base_Column_List" />
|
from t_gps_device t
|
where t.gd_id=#{gdId}
|
</select>
|
|
<select id="queryVersionById" resultType="integer">
|
select version from t_gps_device
|
where gd_id=#{gdId}
|
</select>
|
|
<!--查询列表-->
|
<select id="findList" resultType="com.thhy.materials.modules.biz.gpsdevice.entity.GpsDevice">
|
SELECT
|
<include refid="Base_Column_List" />
|
from t_gps_device t
|
<include refid="condition_query" />
|
</select>
|
|
<!--查询列表-->
|
<select id="findAll" resultType="com.thhy.materials.modules.biz.gpsdevice.entity.GpsDevice">
|
select a.gdId,case when a.count < 1 then a.gdName else CONCAT(a.gdName,'--上次使用过') end as gdName from
|
(
|
SELECT
|
t.gd_id as gdId,
|
t.create_time,
|
CONCAT(t.gd_name,':',t.gd_imei) as gdName,
|
<if test="carId !=null and carId !=''">
|
(select count(pipe_out_id) from t_pipe_out where car_id = #{carId} and gd_id = t.gd_id order by create_time desc limit 1) as count
|
</if>
|
<if test="carId ==null or carId ==''">
|
0 as count
|
</if>
|
from t_gps_device t
|
where t.is_use = 1 and t.company_id = #{companyId}
|
) a
|
order by a.count desc,a.create_time desc
|
</select>
|
|
<!--插入操作-->
|
<insert id="insert">
|
insert into t_gps_device
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="companyId != null">
|
company_id,
|
</if>
|
<if test="createTime != null">
|
create_time,
|
</if>
|
<if test="createUser != null">
|
create_user,
|
</if>
|
<if test="gdId != null">
|
gd_id,
|
</if>
|
<if test="gdImei != null">
|
gd_imei,
|
</if>
|
<if test="gdName != null">
|
gd_name,
|
</if>
|
<if test="isUse != null">
|
is_use,
|
</if>
|
<if test="remark != null">
|
remark,
|
</if>
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="companyId != null">
|
#{companyId},
|
</if>
|
<if test="createTime != null">
|
#{createTime},
|
</if>
|
<if test="createUser != null">
|
#{createUser},
|
</if>
|
<if test="gdId != null">
|
#{gdId},
|
</if>
|
<if test="gdImei != null">
|
#{gdImei},
|
</if>
|
<if test="gdName != null">
|
#{gdName},
|
</if>
|
<if test="isUse != null">
|
#{isUse},
|
</if>
|
<if test="remark != null">
|
#{remark},
|
</if>
|
</trim>
|
</insert>
|
|
|
<!--更新操作-->
|
<update id="update">
|
update t_gps_device
|
<set>
|
<if test="companyId != null">
|
company_id=#{companyId},
|
</if>
|
<if test="createTime != null">
|
create_time=#{createTime},
|
</if>
|
<if test="createUser != null">
|
create_user=#{createUser},
|
</if>
|
<if test="gdImei != null">
|
gd_imei=#{gdImei},
|
</if>
|
<if test="gdName != null">
|
gd_name=#{gdName},
|
</if>
|
<if test="isUse != null">
|
is_use=#{isUse},
|
</if>
|
<if test="remark != null">
|
remark=#{remark},
|
</if>
|
</set>
|
where gd_id=#{gdId}
|
</update>
|
|
<!--逻辑删除-->
|
<update id="deletelogic">
|
update t_gps_device
|
SET is_use = 0
|
where gd_id=#{gdId}
|
</update>
|
|
<!--根据ID删除-->
|
<delete id="deleteById">
|
delete from t_gps_device
|
where gd_id=#{gdId}
|
</delete>
|
|
<select id="queryOut" resultType="com.thhy.materials.modules.biz.gpsdevice.entity.PipeOutInfo">
|
select pipe_out_id as pipeOutId,gd_imei as gdImei,str_time as startTime,end_time as endTime
|
from t_pipe_out where pipe_out_id = #{pipeOutId}
|
</select>
|
|
</mapper>
|