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

512 lines
24 KiB

<?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.techsor.datacenter.business.dao.ex.DeviceInfoMapperExt">
<insert id="batchInsert" parameterType="java.util.List">
INSERT INTO device_info (device_id, device_sn, type_id, wsclient_id, space_id,
device_name, remark, building_id, asset_id, flag, company_id,
created_by, created_timestamp, updated_by, updated_timestamp,
project_id, floor_id, monitoring_point_name, data_provider_id,
gateway_info_id, alarm_level, unit, data_mapping)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.deviceId,jdbcType=VARCHAR},
#{item.deviceSn,jdbcType=VARCHAR},
#{item.typeId,jdbcType=INTEGER},
#{item.wsclientId,jdbcType=INTEGER},
#{item.spaceId,jdbcType=BIGINT},
#{item.deviceName,jdbcType=VARCHAR},
#{item.remark,jdbcType=VARCHAR},
#{item.buildingId,jdbcType=BIGINT},
#{item.assetId,jdbcType=BIGINT},
#{item.flag,jdbcType=INTEGER},
#{item.companyId,jdbcType=BIGINT},
#{item.createdBy,jdbcType=BIGINT},
#{item.createdTimestamp,jdbcType=TIMESTAMP},
#{item.updatedBy,jdbcType=BIGINT},
#{item.updatedTimestamp,jdbcType=BIGINT},
#{item.projectId,jdbcType=BIGINT},
#{item.floorId,jdbcType=BIGINT},
#{item.monitoringPointName,jdbcType=VARCHAR},
#{item.dataProviderId,jdbcType=BIGINT},
#{item.gatewayInfoId,jdbcType=BIGINT},
#{item.alarmLevel,jdbcType=INTEGER},
#{item.unit,jdbcType=VARCHAR},
#{item.dataMapping,jdbcType=LONGVARCHAR}
)
</foreach>
</insert>
<select id="getListPage" resultType="com.techsor.datacenter.business.vo.device.DeviceVO">
select
basic_building.name as buildingName,basic_floor.name as floorName,basic_space.name as spaceName,
basic_monitoring_asset.symbol as assetSymbol,type.name as typeName,
device_info.id as id, device_info.device_id as deviceId, device_info.device_sn as deviceSn, device_info.type_id as typeId,type.device_category_id as categoryId,
device_info.device_name as deviceName, basic_monitoring_asset.equipment_id as assetId, device_info.company_id as companyId,
basic_space.space_id as spaceId, basic_building.building_id as buildingId, device_info.remark as remark, device_info.flag as flag,
device_info.project_id as projectId, basic_floor.floor_id as floorId, device_info.wsclient_id as wsclientId,
type.device_category_id,device_info.monitoring_point_name,device_info.monitoring_point_category_id,mpc.name monitoringPointCategoryName,
device_info.data_provider_id, data_provider.name dataProviderName, device_info.retain_alert,
device_info.gateway_info_id, data_provider_gateway_info.name gatewayInfoName, device_info.alarm_level,
device_info.unit,device_info.data_mapping,device_info.dashboard_decimal_places,
dashboard_device_group.id deviceGroupId, dashboard_device_group.name deviceGroupName
from
device_info
left join basic_project on device_info.project_id = basic_project.id
left join basic_monitoring_asset on device_info.asset_id = basic_monitoring_asset.equipment_id
left join basic_space on basic_monitoring_asset.space_id = basic_space.space_id
left join basic_floor on basic_space.floor_id = basic_floor.floor_id
left join basic_building on basic_floor.building_id = basic_building.building_id
left join monitoring_point_category mpc on mpc.id = device_info.monitoring_point_category_id
left join data_provider on data_provider.id = device_info.data_provider_id
left join data_provider_gateway_info on data_provider_gateway_info.id = device_info.gateway_info_id
left join type on device_info.type_id = type.id
left join device_category on type.device_category_id = device_category.id
left join device_alert_config dac on device_info.id=dac.device_config_id and dac.flag = 0
left join dashboard_device_group_relation on dashboard_device_group_relation.device_info_id = device_info.id
left join dashboard_device_group on dashboard_device_group_relation.device_group_id = dashboard_device_group.id
<if test="deviceVO.targetIdValue != null ">
left join target_id_check tic on dac.id = tic.alert_config_id
</if>
<where>
<if test="deviceVO.deviceId != null and deviceVO.deviceId != ''">
and device_info.device_id like concat('%', #{deviceVO.deviceId}, '%')
</if>
<if test="deviceVO.deviceSn != null and deviceVO.deviceSn != ''">
and device_info.device_sn like concat('%', #{deviceVO.deviceSn}, '%')
</if>
<if test="deviceVO.typeId != null and deviceVO.typeId != ''">
and device_info.type_id = #{deviceVO.typeId}
</if>
<if test="deviceVO.categoryId != null and deviceVO.categoryId != ''">
and device_category_id = #{deviceVO.categoryId}
</if>
<if test="deviceVO.deviceName != null and deviceVO.deviceName != ''">
and device_info.device_name like concat('%', #{deviceVO.deviceName}, '%')
</if>
<if test="deviceVO.assetSymbol != null ">
and basic_monitoring_asset.symbol like concat('%', #{deviceVO.assetSymbol}, '%')
</if>
<if test="deviceVO.spaceId != null ">
and basic_space.space_id = #{deviceVO.spaceId}
</if>
<if test="deviceVO.buildingId != null ">
and basic_building.building_id = #{deviceVO.buildingId}
</if>
<if test="deviceVO.projectId != null ">
and device_info.project_id = #{deviceVO.projectId}
</if>
<if test="deviceVO.floorId != null ">
and basic_floor.floor_id = #{deviceVO.floorId}
</if>
<if test="deviceVO.targetIdValue != null ">
and tic.target_id_value = #{deviceVO.targetIdValue}
</if>
<if test="deviceVO.deviceCategoryId != null ">
and type.device_category_id = #{deviceVO.deviceCategoryId}
</if>
<if test="deviceVO.companyIds != null and deviceVO.companyIds != ''">
and device_info.company_id in (#{deviceVO.companyIds})
</if>
<if test="deviceVO.companyIdList != null and deviceVO.companyIdList.size() > 0">
and device_info.company_id in
<foreach collection="deviceVO.companyIdList" item="companyId" open="(" separator="," close=")">
#{companyId}
</foreach>
</if>
<if test="deviceVO.bindBuildingIdList != null and deviceVO.bindBuildingIdList.size() > 0">
and basic_building.building_id in
<foreach collection="deviceVO.bindBuildingIdList" item="bindBuildingId" open="(" separator="," close=")">
#{bindBuildingId}
</foreach>
</if>
and device_info.flag = 0 and basic_monitoring_asset.flag = 0 and basic_space.flag = 0
</where>
<if test="deviceVO.orderBy != null">
order by ${deviceVO.orderBy} ${deviceVO.orderMode}
</if>
</select>
<select id="downloadAllDevicesInfo" resultType="com.techsor.datacenter.business.vo.device.DeviceInfoCsvVO">
select
basic_project.project_name as 'projectName',basic_building.name as 'buildingName',
basic_floor.name as 'floorName',basic_space.name as 'spaceName',basic_monitoring_asset.symbol as 'assetSymbol',
device_info.device_id as 'deviceId',device_info.device_sn as 'deviceSN',
type.name as 'typeName',device_info.device_name as 'deviceName',
basic_monitoring_asset.name as 'assetName',basic_building.address as 'address',
acbig.class_name classBig,acmedium.class_name classMedium,acsmall.class_name classSmall,
basic_monitoring_asset.manufacturer as 'maker',
basic_monitoring_asset.model as 'model',basic_monitoring_asset.manufacturing_date as 'manufacturingDate',
basic_monitoring_asset.specifications1 as 'specifications1',basic_monitoring_asset.specifications2 as 'specifications2',
basic_monitoring_asset.specifications3 as 'specifications3',basic_monitoring_asset.specifications4 as 'specifications4',
basic_monitoring_asset.specifications5 as 'specifications5',basic_monitoring_asset.specifications6 as 'specifications6',
basic_space.udf_space_id as 'udfSpaceId'
from
device_info
left join basic_project on device_info.project_id = basic_project.id
left join basic_monitoring_asset on device_info.asset_id = basic_monitoring_asset.equipment_id
left join basic_space on basic_monitoring_asset.space_id = basic_space.space_id
left join basic_floor on basic_space.floor_id = basic_floor.floor_id
left join basic_building on basic_floor.building_id = basic_building.building_id
LEFT JOIN basic_asset_class_big acbig ON basic_monitoring_asset.class_big_id = acbig.id
LEFT JOIN basic_asset_class_medium acmedium ON basic_monitoring_asset.class_medium_id = acmedium.id
LEFT JOIN basic_asset_class_small acsmall ON basic_monitoring_asset.class_small_id = acsmall.id
left join type on device_info.type_id = type.id
<where>
<if test="deviceVO.deviceId != null and deviceVO.deviceId != ''">
and device_info.device_id like concat('%', #{deviceVO.deviceId}, '%')
</if>
<if test="deviceVO.deviceSn != null and deviceVO.deviceSn != ''">
and device_info.device_sn like concat('%', #{deviceVO.deviceSn}, '%')
</if>
<if test="deviceVO.typeId != null and deviceVO.typeId != ''">
and device_info.type_id = #{deviceVO.typeId}
</if>
<if test="deviceVO.deviceName != null and deviceVO.deviceName != ''">
and device_info.device_name like concat('%', #{deviceVO.deviceName}, '%')
</if>
<if test="deviceVO.assetSymbol != null ">
and basic_monitoring_asset.symbol like concat('%', #{deviceVO.assetSymbol}, '%')
</if>
<if test="deviceVO.spaceId != null ">
and basic_space.space_id = #{deviceVO.spaceId}
</if>
<if test="deviceVO.buildingId != null ">
and basic_building.building_id = #{deviceVO.buildingId}
</if>
<if test="deviceVO.projectId != null ">
and device_info.project_id = #{deviceVO.projectId}
</if>
<if test="deviceVO.floorId != null ">
and basic_floor.floor_id = #{deviceVO.floorId}
</if>
<if test="deviceVO.companyIds != null and deviceVO.companyIds != ''">
and device_info.company_id in (#{deviceVO.companyIds})
</if>
<if test="deviceVO.companyIdList != null and deviceVO.companyIdList.size() > 0">
and device_info.company_id in
<foreach collection="deviceVO.companyIdList" item="companyId" open="(" separator="," close=")">
#{companyId}
</foreach>
</if>
<if test="deviceVO.deviceIdList != null and deviceVO.deviceIdList.size() > 0">
and device_info.device_id in
<foreach collection="deviceVO.deviceIdList" item="deviceId" open="(" separator="," close=")">
#{deviceId}
</foreach>
</if>
<if test="companyId != null ">
and device_info.company_id = #{companyId}
</if>
and device_info.flag = 0 and basic_monitoring_asset.flag = 0 and basic_space.flag = 0
</where>
</select>
<select id="downloadAllDeviceAlertInfo" resultType="com.techsor.datacenter.business.vo.device.DeviceAlertCsvVO">
SELECT
device_info.device_id as 'deviceId',
device_alert_config.alert_name as 'alertName',
device_alert_config.contents as 'alertConditions',
device_alert_config.type,
device_alert_config.target_id as 'roidTargetId',
device_alert_config.problem_report_category_id as 'roidTypeId',
device_alert_config.building_id as 'roidBuildingId'
FROM device_alert_config,device_info
<where>
<if test="deviceVO.deviceId != null and deviceVO.deviceId != ''">
and device_info.device_id like concat('%', #{deviceVO.deviceId}, '%')
</if>
<if test="deviceVO.deviceSn != null and deviceVO.deviceSn != ''">
and device_info.device_sn like concat('%', #{deviceVO.deviceSn}, '%')
</if>
<if test="deviceVO.typeId != null and deviceVO.typeId != ''">
and device_info.type_id = #{deviceVO.typeId}
</if>
<if test="deviceVO.deviceName != null and deviceVO.deviceName != ''">
and device_info.device_name like concat('%', #{deviceVO.deviceName}, '%')
</if>
<if test="deviceVO.assetSymbol != null ">
and basic_monitoring_asset.symbol like concat('%', #{deviceVO.assetSymbol}, '%')
</if>
<if test="deviceVO.spaceId != null ">
and device_info.space_id = #{deviceVO.spaceId}
</if>
<if test="deviceVO.buildingId != null ">
and device_info.building_id = #{deviceVO.buildingId}
</if>
<if test="deviceVO.projectId != null ">
and device_info.project_id = #{deviceVO.projectId}
</if>
<if test="deviceVO.floorId != null ">
and device_info.floor_id = #{deviceVO.floorId}
</if>
<if test="companyId != null ">
and device_info.company_id = #{companyId}
</if>
<if test="deviceVO.companyIdList != null and deviceVO.companyIdList.size() > 0">
and device_info.company_id in
<foreach collection="deviceVO.companyIdList" item="companyId" open="(" separator="," close=")">
#{companyId}
</foreach>
</if>
<if test="deviceVO.deviceIdList != null and deviceVO.deviceIdList.size() > 0">
and device_info.device_id in
<foreach collection="deviceVO.deviceIdList" item="deviceId" open="(" separator="," close=")">
#{deviceId}
</foreach>
</if>
and device_info.flag=0 and device_info.id=device_alert_config.device_config_id
</where>
</select>
<select id="countByIdList" resultType="java.lang.Integer" parameterType="java.lang.String">
Select count(1) from device_info where device_id in (${inIds}) and flag!=1
</select>
<select id="getInfo4QueryAssetInfo" resultType="com.techsor.datacenter.business.vo.asset.ApiDeviceInfoVO">
select
device_id,
device_sn,
device_name,
monitoring_point_name as monitorPointName,
type.unit typeUnit
from
device_info
left join type on device_info.type_id = type.id
<where>
<if test="assetId != null">
and device_info.asset_id = #{assetId}
</if>
and device_info.flag = 0
</where>
</select>
<select id="getAlarmDeviceInfo" resultType="com.techsor.datacenter.business.vo.device.ApiAlarmDeviceInfoVO">
select
device_info.device_id,
device_info.device_sn,
device_info.device_name,
type.unit typeUnit,
type.name deviceTypeName,
basic_monitoring_asset.symbol assetSymbol,
bfloor.name floorName,
bspace.name spaceName,
bbuilding.name buildingName,
acbig.class_name classBig,
acmedium.class_name classMedium,
acsmall.class_name classSmall
from
device_info
left join basic_monitoring_asset on basic_monitoring_asset.equipment_id = device_info.asset_id
left join type on device_info.type_id = type.id
left join basic_space bspace ON bspace.space_id = basic_monitoring_asset.space_id
left join basic_floor bfloor ON bfloor.floor_id = bspace.floor_id
left join basic_building bbuilding ON bfloor.building_id = bbuilding.building_id
LEFT JOIN basic_asset_class_big acbig ON basic_monitoring_asset.class_big_id = acbig.id
LEFT JOIN basic_asset_class_medium acmedium ON basic_monitoring_asset.class_medium_id = acmedium.id
LEFT JOIN basic_asset_class_small acsmall ON basic_monitoring_asset.class_small_id = acsmall.id
where device_info.flag = 0 AND device_info.company_id = #{companyId}
<if test="buildingName != null and buildingName != ''">
<!-- AND bbuilding.name LIKE CONCAT('%',#{buildingName},'%') -->
AND bbuilding.name = #{buildingName}
</if>
<if test="floorName != null and floorName != ''">
<!-- AND bfloor.name LIKE CONCAT('%',#{floorName},'%') -->
AND bfloor.name = #{floorName}
</if>
<if test="deviceIdList != null">
AND device_info.device_id IN
<foreach item="item" collection="deviceIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="deviceName != null and deviceName != ''">
AND device_info.device_name LIKE CONCAT('%',#{deviceName},'%')
</if>
<if test="deviceId != null and deviceId != ''">
AND device_info.device_id LIKE CONCAT('%',#{deviceId},'%')
</if>
<if test="assetSymbol != null and assetSymbol != ''">
AND basic_monitoring_asset.symbol LIKE CONCAT('%',#{assetSymbol},'%')
</if>
<if test="floorId != null ">
AND bfloor.floor_id = #{floorId}
</if>
<if test="buildingId != null ">
AND bbuilding.building_id = #{buildingId}
</if>
<if test="udfBuildingId != null">
AND bbuilding.udf_building_id = #{udfBuildingId}
</if>
</select>
<select id="getCancelAlarmDeviceInfo" resultType="com.techsor.datacenter.business.vo.device.ApiCancelAlarmDeviceInfoVO">
select
device_info.device_id,
device_info.device_sn,
device_info.device_name,
type.unit typeUnit,
type.name deviceTypeName,
basic_monitoring_asset.symbol assetSymbol,
bfloor.name floorName,
bspace.name spaceName,
bbuilding.name buildingName,
acbig.class_name classBig,
acmedium.class_name classMedium,
acsmall.class_name classSmall
from
device_info
left join basic_monitoring_asset on basic_monitoring_asset.equipment_id = device_info.asset_id
left join type on device_info.type_id = type.id
left join basic_space bspace ON bspace.space_id = basic_monitoring_asset.space_id
left join basic_floor bfloor ON bfloor.floor_id = bspace.floor_id
left join basic_building bbuilding ON bfloor.building_id = bbuilding.building_id
LEFT JOIN basic_asset_class_big acbig ON basic_monitoring_asset.class_big_id = acbig.id
LEFT JOIN basic_asset_class_medium acmedium ON basic_monitoring_asset.class_medium_id = acmedium.id
LEFT JOIN basic_asset_class_small acsmall ON basic_monitoring_asset.class_small_id = acsmall.id
where device_info.flag = 0 AND device_info.company_id = #{companyId}
<if test="buildingName != null and buildingName != ''">
<!-- AND bbuilding.name LIKE CONCAT('%',#{buildingName},'%') -->
AND bbuilding.name = #{buildingName}
</if>
<if test="floorName != null and floorName != ''">
<!-- AND bfloor.name LIKE CONCAT('%',#{floorName},'%') -->
AND bfloor.name = #{floorName}
</if>
<if test="deviceIdList != null">
AND device_info.device_id IN
<foreach item="item" collection="deviceIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="deviceName != null and deviceName != ''">
AND device_info.device_name LIKE CONCAT('%',#{deviceName},'%')
</if>
<if test="deviceId != null and deviceId != ''">
AND device_info.device_id LIKE CONCAT('%',#{deviceId},'%')
</if>
<if test="assetSymbol != null and assetSymbol != ''">
AND basic_monitoring_asset.symbol LIKE CONCAT('%',#{assetSymbol},'%')
</if>
<if test="floorId != null ">
AND bfloor.floor_id = #{floorId}
</if>
<if test="buildingId != null ">
AND bbuilding.building_id = #{buildingId}
</if>
<if test="udfBuildingId != null">
AND bbuilding.udf_building_id = #{udfBuildingId}
</if>
</select>
<select id="countBind" resultType="java.lang.Integer">
select
count(1)
from
device_info
left join basic_monitoring_asset on basic_monitoring_asset.equipment_id = device_info.asset_id
<if test="spaceIdList != null or floorIdList != null or buildingIdList != null" >
left join basic_space bspace ON bspace.space_id = basic_monitoring_asset.space_id
</if>
<if test="floorIdList != null or buildingIdList != null" >
left join basic_floor bfloor ON bfloor.floor_id = bspace.floor_id
</if>
<if test="buildingIdList != null" >
left join basic_building bbuilding ON bfloor.building_id = bbuilding.building_id
</if>
where device_info.flag != 1
<if test="spaceIdList != null">
AND bspace.space_id IN
<foreach item="item" collection="spaceIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="floorIdList != null">
AND bfloor.floor_id IN
<foreach item="item" collection="floorIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="buildingIdList != null">
AND bbuilding.building_id IN
<foreach item="item" collection="buildingIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<select id="getCompanyInfoByDeviceId" resultType="com.techsor.datacenter.business.vo.company.RoidInfo">
select
basic_company.bearer_token,
basic_company.third_api_host
from
device_info
inner join data_center_aeon_admin.basic_company on basic_company.id = device_info.company_id
where device_info.flag != 1 and basic_company.flag != 1 and device_info.device_id = #{deviceId}
</select>
<select id="getRiliDeviceInfo" resultType="com.techsor.datacenter.business.vo.device.ApiRiliDeviceInfoVO">
select
device_info.device_id,
device_info.device_sn,
type.unit typeUnit
from
device_info
left join type on device_info.type_id = type.id
where device_info.flag = 0 AND device_info.company_id = #{companyId}
<if test="deviceIdList != null">
AND device_info.device_id IN
<foreach item="item" collection="deviceIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<select id="selectAllDevice" resultType="com.techsor.datacenter.business.vo.device.DeviceVO">
select device_id from device_info where flag=0
</select>
<select id="getDeviceCategoryId" resultType="java.lang.Long">
select
device_category_id
from
type
inner join device_info on device_info.type_id = type.id
where device_info.device_id = #{deviceId} and device_info.flag != 1
</select>
<select id="getMonitoringPointCategory" resultType="com.techsor.datacenter.business.vo.device.MonitoringPointCategoryVO">
select
id,
`name`
from
monitoring_point_category
where flag != 1 and company_id = #{companyId}
</select>
</mapper>