You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

509 lines
19 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.shxy.xymanager_dao.dao.TerminalsDao">
<resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.Terminals">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="line_id" jdbcType="INTEGER" property="lineid"/>
<result column="tower_id" jdbcType="INTEGER" property="towerid"/>
<result column="cmdid" jdbcType="VARCHAR" property="cmdid"/>
<result column="org_id" jdbcType="SMALLINT" property="orgId"/>
<result column="equip_name" jdbcType="VARCHAR" property="equipName"/>
<result column="display_name" jdbcType="VARCHAR" property="displayName"/>
<result column="model" jdbcType="VARCHAR" property="model"/>
<result column="essential_info_version" jdbcType="VARCHAR" property="essentialInfoVersion"/>
<result column="has_pan" jdbcType="TINYINT" property="hasPan"/>
<result column="bs_manufacturer" jdbcType="VARCHAR" property="bsManufacturer"/>
<result column="bs_production_date" jdbcType="DATE" property="bsProductionDate"/>
<result column="bs_identifier" jdbcType="VARCHAR" property="bsIdentifier"/>
<result column="latitude" jdbcType="DOUBLE" property="latitude"/>
<result column="longitude" jdbcType="DOUBLE" property="longitude"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
</resultMap>
<resultMap id="TermAndStatusMap" type="com.shxy.xymanager_common.dto.TerminalsAndStatusDto">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="line_id" jdbcType="INTEGER" property="lineid"/>
<result column="tower_id" jdbcType="INTEGER" property="towerid"/>
<result column="cmdid" jdbcType="VARCHAR" property="cmdid"/>
<result column="org_id" jdbcType="SMALLINT" property="orgId"/>
<result column="equip_name" jdbcType="VARCHAR" property="equipName"/>
<result column="display_name" jdbcType="VARCHAR" property="displayName"/>
<result column="model" jdbcType="VARCHAR" property="model"/>
<result column="essential_info_version" jdbcType="VARCHAR" property="essentialInfoVersion"/>
<result column="has_pan" jdbcType="TINYINT" property="hasPan"/>
<result column="bs_manufacturer" jdbcType="VARCHAR" property="bsManufacturer"/>
<result column="bs_production_date" jdbcType="DATE" property="bsProductionDate"/>
<result column="bs_identifier" jdbcType="VARCHAR" property="bsIdentifier"/>
<result column="latitude" jdbcType="DOUBLE" property="latitude"/>
<result column="longitude" jdbcType="DOUBLE" property="longitude"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="signal_strength_4g" jdbcType="SMALLINT" property="signalStrength4g"/>
<result column="boot_time" jdbcType="INTEGER" property="bootTime"/>
<result column="battery_capacity" jdbcType="FLOAT" property="batteryCapacity"/>
<result column="battery_voltage" jdbcType="FLOAT" property="batteryVoltage"/>
<result column="last_heartbeat" jdbcType="INTEGER" property="lastHeartbeat"/>
</resultMap>
<resultMap id="ChannelAndTerm" type="com.shxy.xymanager_common.dto.ChannelAndTermDto">
<id column="term_id" jdbcType="INTEGER" property="termid"/>
<result column="line_id" jdbcType="INTEGER" property="lineid"/>
<result column="cmdid" jdbcType="VARCHAR" property="cmdid"/>
<result column="channel_id" jdbcType="INTEGER" property="channelid"/>
<result column="channel_name" jdbcType="VARCHAR" property="channelname"/>
<result column="display_name" jdbcType="VARCHAR" property="displayname"/>
</resultMap>
<sql id="Base_Column_List">
id, line_id,tower_id,cmdid, org_id, equip_name, display_name, model, essential_info_version, has_pan,
bs_manufacturer, bs_production_date, bs_identifier, latitude, longitude, create_time,
update_time
</sql>
<select id="selectAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminals
<if test="status != null">
where status = #{status}
</if>
</select>
<select id="selectById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminals
where status = #{status} and id = #{id}
</select>
<select id="selectByIdList" resultMap="ChannelAndTerm">
select
a.id as term_id,
a.line_id as line_id,
a.cmdid as cmdid,
a.display_name as display_name,
b.channel_id as channel_id,
c.channel_name as channel_name
from ((terminals a left join
terminal_channel_mapper b on a.id = b.term_id) left join
terminal_channels c on b.channel_id = c.id)
where a.status = #{status}
<if test="list != null and list.size>0">
and
<foreach collection="list" item="item" index="index" open="(" close=")" separator="or">
a.id = #{item.termid}
<if test="item.channelidlist != null and item.channelidlist.size>0">
and c.id in
<foreach collection="item.channelidlist" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
</foreach>
</if>
</select>
<select id="selectChannelAndTermList" resultMap="ChannelAndTerm">
select
a.id as term_id,
a.line_id as line_id,
a.cmdid as cmdid,
a.display_name as display_name,
b.channel_id as channel_id,
c.channel_name as channel_name
from ((terminals a left join
terminal_channel_mapper b on a.id = b.term_id) left join
terminal_channels c on b.channel_id = c.id)
where a.status = #{status}
</select>
<select id="selectTermAndStatusList" resultMap="TermAndStatusMap">
select
a.id as id,
a.line_id as line_id,
a.tower_id as tower_id,
a.cmdid as cmdid,
a.org_id as org_id,
a.equip_name as equip_name,
a.display_name as display_name,
a.model as model,
a.essential_info_version as essential_info_version,
a.has_pan as has_pan,
a.bs_manufacturer as bs_manufacturer,
a.bs_production_date as bs_production_date,
a.bs_identifier as bs_identifier,
a.latitude as latitude,
a.longitude as longitude,
a.status as status,
b.signal_strength_4g as signal_strength_4g,
b.boot_time as boot_time,
b.battery_capacity as battery_capacity,
b.battery_voltage as battery_voltage,
b.last_heartbeat as last_heartbeat
from
(terminals a left join terminal_status b on a.id = b.term_id )
<where>
true
<if test="status != null">
and a.status = #{status}
</if>
<if test="search != null">
and a.cmdid like "%"#{search}"%"
</if>
</where>
order by a.create_time desc
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminals
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByCmdid" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminals
where cmdid = #{cmdid} and status = #{status}
</select>
<select id="selectByToweridAndLineid" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminals
where status = #{status}
<if test="toweridlist != null and toweridlist.size > 0">
and tower_id in
<foreach collection="toweridlist" item="id" index="index" separator="," open="(" close=")">
#{id}
</foreach>
</if>
</select>
<select id="selectByTowerId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminals
where status = #{status}
<if test="towerid != null">
and tower_id = #{towerid}
</if>
</select>
<insert id="insertSelective" parameterType="com.shxy.xymanager_common.entity.Terminals">
insert into terminals
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="cmdid != null">
cmdid,
</if>
<if test="orgId != null">
org_id,
</if>
<if test="equipName != null">
equip_name,
</if>
<if test="displayName != null">
display_name,
</if>
<if test="model != null">
model,
</if>
<if test="essentialInfoVersion != null">
essential_info_version,
</if>
<if test="hasPan != null">
has_pan,
</if>
<if test="bsManufacturer != null">
bs_manufacturer,
</if>
<if test="bsProductionDate != null">
bs_production_date,
</if>
<if test="bsIdentifier != null">
bs_identifier,
</if>
<if test="latitude != null">
latitude,
</if>
<if test="longitude != null">
longitude,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="cmdid != null">
#{cmdid,jdbcType=VARCHAR},
</if>
<if test="orgId != null">
#{orgId,jdbcType=SMALLINT},
</if>
<if test="equipName != null">
#{equipName,jdbcType=VARCHAR},
</if>
<if test="displayName != null">
#{displayName,jdbcType=VARCHAR},
</if>
<if test="model != null">
#{model,jdbcType=VARCHAR},
</if>
<if test="essentialInfoVersion != null">
#{essentialInfoVersion,jdbcType=VARCHAR},
</if>
<if test="hasPan != null">
#{hasPan,jdbcType=TINYINT},
</if>
<if test="bsManufacturer != null">
#{bsManufacturer,jdbcType=VARCHAR},
</if>
<if test="bsProductionDate != null">
#{bsProductionDate,jdbcType=DATE},
</if>
<if test="bsIdentifier != null">
#{bsIdentifier,jdbcType=VARCHAR},
</if>
<if test="latitude != null">
#{latitude,jdbcType=DOUBLE},
</if>
<if test="longitude != null">
#{longitude,jdbcType=DOUBLE},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<insert id="insertList" useGeneratedKeys="true" keyProperty="item.id">
insert into terminals
<trim prefix="(" suffix=") values " suffixOverrides=",">
<if test="#{item.lineid} != null">
line_id,
</if>
<if test="#{item.towerid} != null">
tower_id,
</if>
<if test="#{item.cmdid} != null">
cmdid,
</if>
<if test="#{item.orgId} != null">
org_id,
</if>
<if test="#{item.equipName} != null">
equip_name,
</if>
<if test="#{item.displayName} != null">
display_name,
</if>
<if test="#{item.model} != null">
model,
</if>
<if test="#{item.essentialInfoVersion} != null">
essential_info_version,
</if>
<if test="#{item.hasPan} != null">
has_pan,
</if>
<if test="#{item.bsManufacturer} != null">
bs_manufacturer,
</if>
<if test="#{item.bsProductionDate} != null">
bs_production_date,
</if>
<if test="#{item.bsIdentifier} != null">
bs_identifier,
</if>
<if test="#{item.latitude} != null">
latitude,
</if>
<if test="#{item.longitude} != null">
longitude,
</if>
<if test="#{status} != null">
status,
</if>
<if test="#{createat} != null">
create_time,
</if>
<if test="#{updateat} != null">
update_time,
</if>
</trim>
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="#{item.lineid} != null">
#{item.lineid},
</if>
<if test="#{item.towerid} != null">
#{item.towerid},
</if>
<if test="#{item.cmdid} != null">
#{item.cmdid},
</if>
<if test="#{item.orgId} != null">
#{item.orgId},
</if>
<if test="#{item.equipName} != null">
#{item.equipName},
</if>
<if test="#{item.displayName} != null">
#{item.displayName},
</if>
<if test="#{item.model} != null">
#{item.model},
</if>
<if test="#{item.essentialInfoVersion} != null">
#{item.essentialInfoVersion},
</if>
<if test="#{item.hasPan} != null">
#{item.hasPan},
</if>
<if test="#{item.bsManufacturer} != null">
#{item.bsManufacturer},
</if>
<if test="#{item.bsProductionDate} != null">
#{item.bsProductionDate},
</if>
<if test="#{item.bsIdentifier} != null">
#{item.bsIdentifier},
</if>
<if test="#{item.latitude} != null">
#{item.latitude},
</if>
<if test="#{item.longitude} != null">
#{item.longitude},
</if>
<if test="#{status} != null">
#{status},
</if>
<if test="#{createat} != null">
#{createat},
</if>
<if test="#{updateat} != null">
#{updateat},
</if>
</trim>
</insert>
<update id="deleteById">
update terminals
set status = #{status},
update_time = #{updateat}
where id in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item.id}
</foreach>
</update>
<update id="updateByPrimaryKeySelective">
update terminals
<set>
<if test="data.lineid != null">
line_id = #{data.lineid},
</if>
<if test="data.towerid != null">
tower_id = #{data.towerid},
</if>
<if test="data.cmdid != null">
cmdid = #{data.cmdid},
</if>
<if test="data.orgId != null">
org_id = #{data.orgId,jdbcType=SMALLINT},
</if>
<if test="data.equipName != null">
equip_name = #{data.equipName,jdbcType=VARCHAR},
</if>
<if test="data.displayName != null">
display_name = #{data.displayName,jdbcType=VARCHAR},
</if>
<if test="data.model != null">
model = #{data.model,jdbcType=VARCHAR},
</if>
<if test="data.essentialInfoVersion != null">
essential_info_version = #{data.essentialInfoVersion,jdbcType=VARCHAR},
</if>
<if test="data.hasPan != null">
has_pan = #{data.hasPan,jdbcType=TINYINT},
</if>
<if test="data.bsManufacturer != null">
bs_manufacturer = #{data.bsManufacturer,jdbcType=VARCHAR},
</if>
<if test="data.bsProductionDate != null">
bs_production_date = #{data.bsProductionDate,jdbcType=DATE},
</if>
<if test="data.bsIdentifier != null">
bs_identifier = #{data.bsIdentifier,jdbcType=VARCHAR},
</if>
<if test="data.latitude != null">
latitude = #{data.latitude,jdbcType=DOUBLE},
</if>
<if test="data.longitude != null">
longitude = #{data.longitude,jdbcType=DOUBLE},
</if>
<if test="updateat != null">
update_time = #{updateat,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{data.id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.shxy.xymanager_common.entity.Terminals">
update terminals
set cmdid = #{cmdid,jdbcType=VARCHAR},
org_id = #{orgId,jdbcType=SMALLINT},
equip_name = #{equipName,jdbcType=VARCHAR},
display_name = #{displayName,jdbcType=VARCHAR},
model = #{model,jdbcType=VARCHAR},
essential_info_version = #{essentialInfoVersion,jdbcType=VARCHAR},
has_pan = #{hasPan,jdbcType=TINYINT},
bs_manufacturer = #{bsManufacturer,jdbcType=VARCHAR},
bs_production_date = #{bsProductionDate,jdbcType=DATE},
bs_identifier = #{bsIdentifier,jdbcType=VARCHAR},
latitude = #{latitude,jdbcType=DOUBLE},
longitude = #{longitude,jdbcType=DOUBLE},
update_time = #{updateat}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="getTerminalInfo" resultType="com.shxy.xymanager_common.dto.TerminalInfoDto">
select
ts.term_id termId, ts.battery_voltage batteryVoltage, ts.battery_capacity batteryCapacity, ts.floating_charge floatingCharge, ts.total_working_time totalWorkingTime,
ts.working_time workingTime, ts.connection_state connectionState, ts.ws_update_time wsUpdateTime,t.cmdid cmId
from terminal_status ts left join terminals t on ts.term_id = t.id
where ts.term_id = #{termId,jdbcType=INTEGER}
</select>
<select id="getCmdIdByTermId" resultType="java.lang.String">
select
cmdid
from terminals
where id = #{termId,jdbcType=INTEGER}
</select>
<select id="getUpdateTime" resultType="java.math.BigInteger">
select
ws_update_time wsUpdateTime
from terminal_status
where term_id = #{termId,jdbcType=INTEGER}
</select>
<update id="updateCmd" parameterType="com.shxy.xymanager_common.vo.TerminalIdUpdateVo">
update terminals
set cmdid = #{newCmdId,jdbcType=VARCHAR}
where cmdid = #{cmdId,jdbcType=VARCHAR}
</update>
</mapper>