123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- <?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.bizmatics.persistence.mapper.SiteMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.bizmatics.model.Site">
- <id column="id" property="id"/>
- <result column="site_name" property="siteName"/>
- <result column="site_address" property="siteAddress"/>
- <result column="company_code" property="companyCode"/>
- <result column="user_name" property="userName"/>
- <result column="phone" property="phone"/>
- <result column="station_area_id" property="stationAreaId"/>
- <result column="route_id" property="routeId"/>
- <result column="longitude" property="longitude"/>
- <result column="latitude" property="latitude"/>
- <result column="region" property="region"/>
- <result column="create_time" property="createTime"/>
- <result column="creator" property="creator"/>
- <result column="enable" property="enable"/>
- <result column="grouping_id" property="groupingId"/>
- <result column="tenant_id" property="tenantId"/>
- </resultMap>
- <select id="selectCount" resultType="java.lang.Integer">
- select count(*)
- from (
- select us.id
- from user_site as us
- inner join device_status as ds
- on us.site_Id = ds.site_id
- <where>
- <if test="userId != null and userId != 0">
- and us.user_id = #{userId}
- </if>
- <if test="siteId != null and siteId != 0">
- and us.site_id = #{siteId}
- </if>
- <if test="siteStatus != null">
- and ds.device_status = #{siteStatus}
- </if>
- </where>
- group by us.site_id
- ) as t
- </select>
- <select id="list" resultType="com.bizmatics.model.Site">
- select s.id,s.site_name,s.site_address,s.company_code,s.user_name,s.phone,s.station_area_id,s.route_id,
- s.installed_capacity,s.rheological_change,s.longitude,s.latitude,s.region,s.create_time,s.creator,s.enable
- from user_site as us
- inner join site as s
- on us.site_id = s.id
- <where>
- s.enable=1
- and s.tenant_id=#{tenantId}
- <if test="userId != null and userId != 0">
- and us.user_id = #{userId}
- </if>
- <if test="name != null and name != ''">
- and s.site_name LIKE CONCAT(CONCAT('%', #{name}), '%')
- </if>
- </where>
- </select>
- <select id="list2" resultType="com.bizmatics.model.SiteTwo">
- SELECT
- a.*, b.device_status
- FROM
- (
- SELECT
- s.id,
- s.site_name,
- s.site_address,
- s.company_code,
- s.user_name,
- s.phone,
- s.station_area_id,
- s.route_id,
- s.installed_capacity,
- s.rheological_change,
- s.longitude,
- s.latitude,
- s.region,
- s.create_time,
- s.creator,
- s. ENABLE
- FROM
- user_site AS us
- INNER JOIN site AS s ON us.site_id = s.id
- <where>
- s.enable=1
- <if test="userId != null and userId != 0">
- and us.user_id = #{userId}
- </if>
- <if test="name != null and name != ''">
- and s.site_name LIKE CONCAT(CONCAT('%', #{name}), '%')
- </if>
- </where>) AS a
- LEFT JOIN device_status AS b ON a.id = b.site_id
- GROUP BY
- a.id
- ORDER BY
- a.id
- </select>
- <select id="getDeviceListOne" resultType="com.bizmatics.model.Device">
- SELECT
- a.*, b.device_status
- FROM
- device AS a
- JOIN device_status AS b ON a.device_code = b.device_code
- <where>
- <if test="siteId != null and siteId != 0">
- a.site_id = #{siteId}
- </if>
- </where>
- </select>
- <select id="Sitelist" resultType="com.bizmatics.model.SiteList">
- select
- a.user_id,
- b.id,
- b.grouping_id,
- b.site_name,
- c.grouping_name
- from user_site as a
- join site as b on a.site_id = b.id
- left join site_grouping as c on b.grouping_id = c.id
- <where>
- b.enable=1
- <if test="userId != null and userId != 0">
- and a.user_id = #{userId}
- </if>
- <if test="name != null and name != ''">
- and b.site_name like CONCAT(CONCAT('%', #{name}), '%')
- </if>
- order by b.id desc
- </where>
- </select>
- <select id="GroupingList" resultType="com.bizmatics.model.GroupingList">
- select
- a.id,
- a.grouping_name
- from site_grouping as a
- left join site as b on a.id = b.grouping_id
- <where>
- <if test="name != null and name != ''">
- and b.site_name like CONCAT(CONCAT('%', #{name}), '%')
- </if>
- <if test="creator != null and creator != ''">
- and a.creator = #{creator}
- </if>
- group by a.id
- order by a.id desc
- </where>
- </select>
- <select id="SiteGroupinglist" resultType="com.bizmatics.model.SiteList">
- select
- a.user_id,
- b.id,
- b.grouping_id,
- b.site_name,
- c.grouping_name
- from user_site as a
- join site as b on a.site_id = b.id
- left join site_grouping as c on b.grouping_id = c.id
- <where>
- b.enable=1
- and b.grouping_id=0
- <if test="userId != null and userId != 0">
- and a.user_id = #{userId}
- </if>
- <if test="name != null and name != ''">
- and b.site_name like CONCAT(CONCAT('%', #{name}), '%')
- </if>
- order by b.id desc
- </where>
- </select>
- <select id="idList" resultType="com.bizmatics.model.Site">
- select s.id
- from user_site as us
- inner join site as s
- on us.site_id = s.id
- <where>
- <if test="userId != null and userId != 0">
- and us.user_id = #{userId}
- </if>
- <if test="name != null and name != ''">
- and s.site_name LIKE CONCAT(CONCAT('%', #{name}), '%')
- </if>
- </where>
- </select>
- <select id="templateQuery" resultType="com.bizmatics.model.TemplateData">
- select
- a.id,
- a.site_name,
- a.site_address,
- a.company_code,
- a.user_name,
- a.phone,
- a.station_area_id,
- a.route_id,
- a.installed_capacity,
- a.rheological_change,
- a.longitude,
- a.latitude,
- a.region,
- a.grouping_id,
- b.id as site_dynamic_properties_id,
- b.fault_status,
- b.real_time_load,
- b.total_electricity,
- b.power_factor,
- b.site_id,
- b.site_type,
- b.user_company,
- b.operation_time,
- b.service_deadline,
- b.power_supply_type,
- b.voltage_level,
- b.demolition_standard_coal,
- b.demolition_standard_coal1,
- b.site_picture_one,
- b.site_picture_two,
- b.site_picture_three,
- a.spare_user_name,
- a.spare_phone
- from
- site AS a
- left join site_dynamic_properties as b on a.id = b.site_id
- <where>
- a.enable=1
- <if test="id != null and id != 0">
- and a.id = #{id}
- </if>
- </where>
- </select>
- <select id="list1" resultType="com.bizmatics.model.Site">
- select *
- from site
- <where>
- enable=1
- <if test="id != null and id != 0">
- and id = #{id}
- </if>
- </where>
- </select>
- <select id="SiteDynamicPropertieslist" resultType="com.bizmatics.model.SiteDynamicProperties">
- select *
- from site_dynamic_properties
- <where>
- <if test="siteId != null and siteId != 0">
- and site_id = #{siteId}
- </if>
- </where>
- </select>
- <select id="deviceAnalogVariableList" resultType="com.bizmatics.model.DeviceAnalogVariableList">
- SELECT
- a.*
- FROM
- device_analog_variable_list AS a
- left JOIN device AS b ON a.communication_equipment = b.id
- <where>
- a.status = 1
- <if test="dataArea != null and dataArea != 0">
- AND a.data_area = #{dataArea}
- </if>
- <if test="siteId != null and siteId != 0">
- AND b.site_id = #{siteId}
- </if>
- </where>
- </select>
- </mapper>
|