gis地图接口
This commit is contained in:
@ -262,6 +262,154 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectDataList" resultType="com.fastbee.iot.domain.DeviceLog">
|
||||
select log_id,identity,device_id,device_name,serial_number,log_value,user_id,user_name,log_type,is_monitor,mode
|
||||
,create_by,create_time,tenant_id,tenant_name,remark
|
||||
from ${tableName}
|
||||
<where>
|
||||
<if test="identity != null and identity != ''">and identity = #{identity}</if>
|
||||
<if test="deviceId != null and deviceId !=0">and device_id = #{deviceId}</if>
|
||||
<if test="serialNumber != null and serialNumber !=''">and serial_number = #{serialNumber}</if>
|
||||
<if test="beginTime != null and beginTime!= ''"><!-- 开始时间检索 -->
|
||||
and date_format(create_time,'%y%m%d%H%i%s') >= date_format(#{beginTime},'%y%m%d%H%i%s')
|
||||
</if>
|
||||
<if test=" endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(create_time,'%y%m%d%H%i%s') <= date_format(#{endTime},'%y%m%d%H%i%s')
|
||||
</if>
|
||||
<if test="identitys != null and identitys != '' and identitys.size > 0">
|
||||
AND identity in
|
||||
<foreach item="identity" collection="identitys" open="(" separator="," close=")">
|
||||
#{identity}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
union
|
||||
select log_id,identity,device_id,device_name,serial_number,log_value,user_id,user_name,log_type,is_monitor,mode
|
||||
,create_by,create_time,tenant_id,tenant_name,remark
|
||||
from ${tableName2}
|
||||
<where>
|
||||
<if test="identity != null and identity != ''">and identity = #{identity}</if>
|
||||
<if test="deviceId != null and deviceId !=0">and device_id = #{deviceId}</if>
|
||||
<if test="serialNumber != null and serialNumber !=''">and serial_number = #{serialNumber}</if>
|
||||
<if test="beginTime != null and beginTime!= ''"><!-- 开始时间检索 -->
|
||||
and date_format(create_time,'%y%m%d%H%i%s') >= date_format(#{beginTime},'%y%m%d%H%i%s')
|
||||
</if>
|
||||
<if test=" endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(create_time,'%y%m%d%H%i%s') <= date_format(#{endTime},'%y%m%d%H%i%s')
|
||||
</if>
|
||||
<if test="identitys != null and identitys != '' and identitys.size > 0">
|
||||
AND identity in
|
||||
<foreach item="identity" collection="identitys" open="(" separator="," close=")">
|
||||
#{identity}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
|
||||
order by create_time desc
|
||||
</select>
|
||||
<update id="createTableByDate">
|
||||
CREATE TABLE `${tableName}`
|
||||
(
|
||||
`log_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '设备日志ID',
|
||||
`identity` varchar(64) NOT NULL COMMENT '标识符',
|
||||
`log_type` tinyint(1) NOT NULL COMMENT '类型(1=属性上报,2=调用功能,3=事件上报,4=设备升级,5=设备上线,6=设备离线)',
|
||||
`log_value` decimal(18, 3) default 0 comment '日志值',
|
||||
`device_id` bigint(20) DEFAULT NULL COMMENT '设备ID',
|
||||
`device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
|
||||
`serial_number` varchar(64) DEFAULT NULL COMMENT '设备编号',
|
||||
`is_monitor` tinyint(1) unsigned zerofill DEFAULT '0' COMMENT '是否监测数据(1=是,0=否)',
|
||||
`mode` tinyint(1) unsigned zerofill DEFAULT '0' COMMENT '模式(1=影子模式,2=在线模式,3=其他)',
|
||||
`user_id` bigint(20) DEFAULT NULL COMMENT '用户ID',
|
||||
`user_name` varchar(30) DEFAULT '' COMMENT '用户昵称',
|
||||
`tenant_id` bigint(20) DEFAULT NULL COMMENT '租户ID',
|
||||
`tenant_name` varchar(30) DEFAULT '' COMMENT '租户名称',
|
||||
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`remark` varchar(200) DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`log_id`) USING BTREE,
|
||||
KEY `iot_device_log_index_serial_number` (`serial_number`) USING BTREE,
|
||||
KEY `iot_device_log_index_tenant_id` (`tenant_id`) USING BTREE,
|
||||
KEY `iot_device_log_index_user_id` (`user_id`) USING BTREE,
|
||||
KEY `iot_device_log_index_identity_device_id` (`identity`, `device_id`) USING BTREE,
|
||||
KEY `iot_device_log_index_identity_createTime` (`identity`, `create_time`) USING BTREE
|
||||
) ENGINE = InnoDB
|
||||
AUTO_INCREMENT = 1
|
||||
DEFAULT CHARSET = utf8
|
||||
ROW_FORMAT = DYNAMIC COMMENT ='设备日志';
|
||||
</update>
|
||||
|
||||
<select id="selectDayData" resultType="java.util.Map">
|
||||
select create_time,
|
||||
avg(log_value ) as avgLogValue ,
|
||||
max(log_value ) as maxLogValue ,
|
||||
sum(log_value ) as sumLogValue ,
|
||||
min(log_value ) as minLogValue
|
||||
from ${tableName}
|
||||
<where>
|
||||
<if test="identity != null and identity != ''">and identity = #{identity}</if>
|
||||
<if test="deviceId != null and deviceId !=0">and device_id = #{deviceId}</if>
|
||||
<if test="serialNumber != null and serialNumber !=''">and serial_number = #{serialNumber}</if>
|
||||
<if test="beginTime != null and beginTime!= ''"><!-- 开始时间检索 -->
|
||||
and date_format(create_time,'%y%m%d%H%i%s') >= date_format(#{beginTime},'%y%m%d%H%i%s')
|
||||
</if>
|
||||
<if test=" endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(create_time,'%y%m%d%H%i%s') <= date_format(#{endTime},'%y%m%d%H%i%s')
|
||||
</if>
|
||||
</where>
|
||||
group by date_format(create_time,'%Y-%m-%d %H')
|
||||
union
|
||||
select create_time,
|
||||
avg(log_value ) as avgLogValue ,
|
||||
max(log_value ) as maxLogValue ,
|
||||
sum(log_value ) as sumLogValue ,
|
||||
min(log_value ) as minLogValue
|
||||
from ${tableName2}
|
||||
<where>
|
||||
<if test="identity != null and identity != ''">and identity = #{identity}</if>
|
||||
<if test="deviceId != null and deviceId !=0">and device_id = #{deviceId}</if>
|
||||
<if test="serialNumber != null and serialNumber !=''">and serial_number = #{serialNumber}</if>
|
||||
<if test="beginTime != null and beginTime!= ''"><!-- 开始时间检索 -->
|
||||
and date_format(create_time,'%y%m%d%H%i%s') >= date_format(#{beginTime},'%y%m%d%H%i%s')
|
||||
</if>
|
||||
<if test=" endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(create_time,'%y%m%d%H%i%s') <= date_format(#{endTime},'%y%m%d%H%i%s')
|
||||
</if>
|
||||
</where>
|
||||
group by date_format(create_time,'%Y-%m-%d %H')
|
||||
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<update id="createTable">
|
||||
CREATE TABLE ${tableName}
|
||||
(
|
||||
`log_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '设备监测信息ID',
|
||||
`identity` varchar(64) NOT NULL COMMENT '标识符',
|
||||
`model_name` varchar(255) DEFAULT NULL COMMENT '物模型名称',
|
||||
`log_type` tinyint(1) NOT NULL COMMENT '类型(1=属性上报,2=调用功能,3=事件上报,4=设备升级,5=设备上线,6=设备离线)',
|
||||
`log_value` varchar(64) NOT NULL COMMENT '日志值',
|
||||
`device_id` bigint(20) DEFAULT NULL COMMENT '设备ID',
|
||||
`device_name` varchar(64) DEFAULT NULL COMMENT '设备名称',
|
||||
`serial_number` varchar(64) DEFAULT NULL COMMENT '设备编号',
|
||||
`is_monitor` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0' COMMENT '是否监测数据(1=是,0=否)',
|
||||
`mode` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0' COMMENT '模式(1=影子模式,2=在线模式,3=其他)',
|
||||
`user_id` bigint(20) DEFAULT NULL COMMENT '用户ID',
|
||||
`user_name` varchar(30) DEFAULT '' COMMENT '用户昵称',
|
||||
`tenant_id` bigint(20) DEFAULT NULL COMMENT '租户ID',
|
||||
`tenant_name` varchar(30) DEFAULT '' COMMENT '租户名称',
|
||||
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`remark` varchar(200) DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`log_id`) USING BTREE,
|
||||
KEY `iot_device_log_index_serial_number` (`serial_number`) USING BTREE,
|
||||
KEY `iot_device_log_index_tenant_id` (`tenant_id`) USING BTREE,
|
||||
KEY `iot_device_log_index_user_id` (`user_id`) USING BTREE,
|
||||
KEY `iot_device_log_index_device_id` (`device_id`) USING BTREE,
|
||||
KEY `index_serialNumber_createTime` (`serial_number`,`create_time`) USING BTREE,
|
||||
KEY `index_isMonitor_serialNumber_createTime` (`serial_number`,`is_monitor`,`create_time`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='设备日志';
|
||||
|
||||
</update>
|
||||
|
||||
<select id="countThingsModelInvoke" resultType="com.fastbee.iot.model.ThingsModelLogCountVO">
|
||||
select identity identifier, min(model_name) modelName, count(identity) count
|
||||
|
@ -287,6 +287,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select product_id,product_name,device_id,device_name,serial_number,gw_dev_code,is_shadow,is_simulate,status,tenant_id, tenant_name,things_model_value from iot_device where serial_number = #{serialNumber}
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceListNotUser" parameterType="com.fastbee.iot.domain.Device" resultMap="DeviceResult">
|
||||
<include refid="selectDeviceShortVo"/>
|
||||
<where>
|
||||
<if test="deviceNameOrSerialNumber != null and deviceNameOrSerialNumber != ''">
|
||||
and (device_name like concat('%', #{deviceNameOrSerialNumber},'%') or
|
||||
serial_number like concat('%',
|
||||
#{deviceNameOrSerialNumber},'%'))
|
||||
</if>
|
||||
<if test="productId != null ">and product_id = #{productId}</if>
|
||||
<if test="status != null ">and status = #{status}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<update id="updateDeviceThingsModelValue" parameterType="com.fastbee.common.core.thingsModel.ThingsModelValuesInput">
|
||||
update iot_device set things_model_value=#{stringValue} where device_id = #{deviceId}
|
||||
</update>
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?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.fastbee.iot.mapper.TableMapper">
|
||||
<!--创建表的 SQL 语句-->
|
||||
<update id="createTable" parameterType="java.lang.String">
|
||||
CREATE TABLE IF NOT EXISTS `${tableName}`
|
||||
(
|
||||
`id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`group_id` int(0) NULL DEFAULT NULL COMMENT '组号',
|
||||
`username` varchar(20) NULL DEFAULT NULL COMMENT '用户名',
|
||||
`password` varchar(20) NULL DEFAULT NULL COMMENT '密码',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
AUTO_INCREMENT = 9
|
||||
CHARACTER SET = utf8mb4 COMMENT ='用于测试的用户表';
|
||||
</update>
|
||||
|
||||
<select id="getTableByName" resultType="java.lang.String">
|
||||
select table_name from information_schema.tables where TABLE_SCHEMA=(select database())
|
||||
and table_name = #{tableName}
|
||||
</select>
|
||||
|
||||
<select id="getTableNameList" resultType="java.lang.String">
|
||||
select table_name from information_schema.tables where TABLE_SCHEMA=(select database())
|
||||
and table_name in
|
||||
<foreach item="tableName" collection="array" open="(" separator="," close=")">
|
||||
#{tableName}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user