123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689 |
- <?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.bz.smart_city.dao.MeterReadRecordMapper">
- <!--auto generated Code-->
- <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.MeterReadRecord">
- <result column="id" property="id" jdbcType="BIGINT"/>
- <result column="read_date" property="readDate" jdbcType="INTEGER"/>
- <result column="site_id" property="siteId" jdbcType="INTEGER"/>
- <result column="sys_id" property="sysId" jdbcType="INTEGER"/>
- <result column="province" property="province" jdbcType="INTEGER"/>
- <result column="city" property="city" jdbcType="INTEGER"/>
- <result column="region" property="region" jdbcType="INTEGER"/>
- <result column="community" property="communityId" jdbcType="VARCHAR"/>
- <result column="building_id" property="buildingId" jdbcType="INTEGER"/>
- <result column="location" property="location" jdbcType="VARCHAR"/>
- <result column="device_type_id" property="deviceTypeId" jdbcType="INTEGER"/>
- <result column="device_id" property="deviceId" jdbcType="BIGINT"/>
- <result column="device_no" property="deviceNo" jdbcType="VARCHAR"/>
- <result column="meter_no" property="meterNo" jdbcType="VARCHAR"/>
- <result column="meter_file_no" property="meterFileNo" jdbcType="VARCHAR"/>
- <result column="read_time" property="readTime" jdbcType="TIMESTAMP"/>
- <result column="read_status" property="readStatus" jdbcType="VARCHAR"/>
- <result column="read_data" property="readData" jdbcType="VARCHAR"/>
- <result column="last_valid" property="lastValid" jdbcType="VARCHAR"/>
- <result column="last_cost" property="lastCost" jdbcType="DECIMAL"/>
- <result column="status" property="status" jdbcType="INTEGER"/>
- <result column="date_create" property="dateCreate" jdbcType="TIMESTAMP"/>
- <result column="date_update" property="dateUpdate" jdbcType="TIMESTAMP"/>
- <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
- <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
- </resultMap>
- <!--auto generated Code-->
- <sql id="Base_Column_List">
- id,
- read_date,
- site_id,
- sys_id,
- province,
- city,
- region,
- community,
- building_id,
- location,
- device_type_id,
- device_id,
- device_no,
- meter_no,
- meter_file_no,
- read_time,
- read_status,
- read_data,
- last_valid,
- last_cost,
- status,
- date_create,
- date_update,
- create_by,
- update_by
- </sql>
- <!--auto generated Code-->
- <insert id="insert" useGeneratedKeys="true" keyProperty="meterReadRecord.id">
- INSERT INTO sc_meter_read_record (
- id,
- read_date,
- site_id,
- sys_id,
- province,
- city,
- region,
- community,
- building_id,
- location,
- device_type_id,
- device_id,
- device_no,
- meter_no,
- meter_file_no,
- read_time,
- read_status,
- read_data,
- last_valid,
- last_cost,
- status,
- date_create,
- date_update,
- create_by,
- update_by
- ) VALUES (
- #{meterReadRecord.id,jdbcType=BIGINT},
- #{meterReadRecord.readDate,jdbcType=INTEGER},
- #{meterReadRecord.siteId,jdbcType=INTEGER},
- #{meterReadRecord.sysId,jdbcType=INTEGER},
- #{meterReadRecord.province,jdbcType=INTEGER},
- #{meterReadRecord.city,jdbcType=INTEGER},
- #{meterReadRecord.region,jdbcType=INTEGER},
- #{meterReadRecord.communityId,jdbcType=VARCHAR},
- #{meterReadRecord.buildingId,jdbcType=INTEGER},
- #{meterReadRecord.location,jdbcType=VARCHAR},
- #{meterReadRecord.deviceTypeId,jdbcType=INTEGER},
- #{meterReadRecord.deviceId,jdbcType=BIGINT},
- #{meterReadRecord.deviceNo,jdbcType=VARCHAR},
- #{meterReadRecord.meterNo,jdbcType=VARCHAR},
- #{meterReadRecord.meterFileNo,jdbcType=VARCHAR},
- #{meterReadRecord.readTime,jdbcType=TIMESTAMP},
- #{meterReadRecord.readStatus,jdbcType=VARCHAR},
- #{meterReadRecord.readData,jdbcType=VARCHAR},
- #{meterReadRecord.lastValid,jdbcType=VARCHAR},
- #{meterReadRecord.lastCost,jdbcType=DECIMAL},
- #{meterReadRecord.status,jdbcType=INTEGER},
- #{meterReadRecord.dateCreate,jdbcType=TIMESTAMP},
- #{meterReadRecord.dateUpdate,jdbcType=TIMESTAMP},
- #{meterReadRecord.createBy,jdbcType=VARCHAR},
- #{meterReadRecord.updateBy,jdbcType=VARCHAR}
- )
- </insert>
- <!--auto generated Code-->
- <insert id="insertSelective" useGeneratedKeys="true" keyProperty="meterReadRecord.id">
- INSERT INTO sc_meter_read_record
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="meterReadRecord.id!=null"> id,</if>
- <if test="meterReadRecord.readDate!=null"> read_date,</if>
- <if test="meterReadRecord.siteId!=null"> site_id,</if>
- <if test="meterReadRecord.sysId!=null"> sys_id,</if>
- <if test="meterReadRecord.province!=null"> province,</if>
- <if test="meterReadRecord.city!=null"> city,</if>
- <if test="meterReadRecord.region!=null"> region,</if>
- <if test="meterReadRecord.communityId!=null"> community,</if>
- <if test="meterReadRecord.buildingId!=null"> building_id,</if>
- <if test="meterReadRecord.location!=null"> location,</if>
- <if test="meterReadRecord.deviceTypeId!=null"> device_type_id,</if>
- <if test="meterReadRecord.deviceId!=null"> device_id,</if>
- <if test="meterReadRecord.deviceNo!=null"> device_no,</if>
- <if test="meterReadRecord.meterNo!=null"> meter_no,</if>
- <if test="meterReadRecord.meterFileNo!=null"> meter_file_no,</if>
- <if test="meterReadRecord.readTime!=null"> read_time,</if>
- <if test="meterReadRecord.readStatus!=null"> read_status,</if>
- <if test="meterReadRecord.readData!=null"> read_data,</if>
- <if test="meterReadRecord.lastValid!=null"> last_valid,</if>
- <if test="meterReadRecord.lastCost!=null"> last_cost,</if>
- <if test="meterReadRecord.status!=null"> status,</if>
- <if test="meterReadRecord.dateCreate!=null"> date_create,</if>
- <if test="meterReadRecord.dateUpdate!=null"> date_update,</if>
- <if test="meterReadRecord.createBy!=null"> create_by,</if>
- <if test="meterReadRecord.updateBy!=null"> update_by,</if>
- </trim>
- VALUES
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="meterReadRecord.id!=null">#{meterReadRecord.id,jdbcType=BIGINT},
- </if>
- <if test="meterReadRecord.readDate!=null">#{meterReadRecord.readDate,jdbcType=INTEGER},
- </if>
- <if test="meterReadRecord.siteId!=null">#{meterReadRecord.siteId,jdbcType=INTEGER},
- </if>
- <if test="meterReadRecord.sysId!=null">#{meterReadRecord.sysId,jdbcType=INTEGER},
- </if>
- <if test="meterReadRecord.province!=null">#{meterReadRecord.province,jdbcType=INTEGER},
- </if>
- <if test="meterReadRecord.city!=null">#{meterReadRecord.city,jdbcType=INTEGER},
- </if>
- <if test="meterReadRecord.region!=null">#{meterReadRecord.region,jdbcType=INTEGER},
- </if>
- <if test="meterReadRecord.communityId!=null">#{meterReadRecord.communityId,jdbcType=VARCHAR},
- </if>
- <if test="meterReadRecord.buildingId!=null">#{meterReadRecord.buildingId,jdbcType=INTEGER},
- </if>
- <if test="meterReadRecord.location!=null">#{meterReadRecord.location,jdbcType=VARCHAR},
- </if>
- <if test="meterReadRecord.deviceTypeId!=null">#{meterReadRecord.deviceTypeId,jdbcType=INTEGER},
- </if>
- <if test="meterReadRecord.deviceId!=null">#{meterReadRecord.deviceId,jdbcType=BIGINT},
- </if>
- <if test="meterReadRecord.deviceNo!=null">#{meterReadRecord.deviceNo,jdbcType=VARCHAR},
- </if>
- <if test="meterReadRecord.meterNo!=null">#{meterReadRecord.meterNo,jdbcType=VARCHAR},
- </if>
- <if test="meterReadRecord.meterFileNo!=null">#{meterReadRecord.meterFileNo,jdbcType=VARCHAR},
- </if>
- <if test="meterReadRecord.readTime!=null">#{meterReadRecord.readTime,jdbcType=TIMESTAMP},
- </if>
- <if test="meterReadRecord.readStatus!=null">#{meterReadRecord.readStatus,jdbcType=VARCHAR},
- </if>
- <if test="meterReadRecord.readData!=null">#{meterReadRecord.readData,jdbcType=VARCHAR},
- </if>
- <if test="meterReadRecord.lastValid!=null">#{meterReadRecord.lastValid,jdbcType=VARCHAR},
- </if>
- <if test="meterReadRecord.lastCost!=null">#{meterReadRecord.lastCost,jdbcType=DECIMAL},
- </if>
- <if test="meterReadRecord.status!=null">#{meterReadRecord.status,jdbcType=INTEGER},
- </if>
- <if test="meterReadRecord.dateCreate!=null">#{meterReadRecord.dateCreate,jdbcType=TIMESTAMP},
- </if>
- <if test="meterReadRecord.dateUpdate!=null">#{meterReadRecord.dateUpdate,jdbcType=TIMESTAMP},
- </if>
- <if test="meterReadRecord.createBy!=null">#{meterReadRecord.createBy,jdbcType=VARCHAR},
- </if>
- <if test="meterReadRecord.updateBy!=null">#{meterReadRecord.updateBy,jdbcType=VARCHAR},
- </if>
- </trim>
- </insert>
- <!--auto generated Code-->
- <insert id="insertList">
- replace INTO sc_meter_read_record (
- id,
- read_date,
- site_id,
- sys_id,
- province,
- city,
- region,
- community,
- customer_id,
- building_id,
- location,
- device_type_id,
- device_id,
- device_no,
- meter_no,
- meter_file_no,
- read_time,
- read_status,
- read_data,
- last_valid,
- last_cost,
- status,
- date_create,
- date_update,
- create_by,
- update_by
- )VALUES
- <foreach collection="meterReadRecords" item="meterReadRecord" index="index" separator=",">
- (
- #{meterReadRecord.id,jdbcType=BIGINT},
- #{meterReadRecord.readDate,jdbcType=INTEGER},
- #{meterReadRecord.siteId,jdbcType=INTEGER},
- #{meterReadRecord.sysId,jdbcType=INTEGER},
- #{meterReadRecord.province,jdbcType=INTEGER},
- #{meterReadRecord.city,jdbcType=INTEGER},
- #{meterReadRecord.region,jdbcType=INTEGER},
- #{meterReadRecord.communityId,jdbcType=INTEGER},
- #{meterReadRecord.customerId,jdbcType=INTEGER},
- #{meterReadRecord.buildingId,jdbcType=INTEGER},
- #{meterReadRecord.location,jdbcType=VARCHAR},
- #{meterReadRecord.deviceTypeId,jdbcType=INTEGER},
- #{meterReadRecord.deviceId,jdbcType=BIGINT},
- #{meterReadRecord.deviceNo,jdbcType=VARCHAR},
- #{meterReadRecord.meterNo,jdbcType=VARCHAR},
- #{meterReadRecord.meterFileNo,jdbcType=VARCHAR},
- #{meterReadRecord.readTime,jdbcType=TIMESTAMP},
- #{meterReadRecord.readStatus,jdbcType=VARCHAR},
- #{meterReadRecord.readData,jdbcType=VARCHAR},
- #{meterReadRecord.lastValid, jdbcType=VARCHAR},
- #{meterReadRecord.lastCost,jdbcType=DECIMAL},
- #{meterReadRecord.status,jdbcType=INTEGER},
- #{meterReadRecord.dateCreate,jdbcType=TIMESTAMP},
- #{meterReadRecord.dateUpdate,jdbcType=TIMESTAMP},
- #{meterReadRecord.createBy,jdbcType=VARCHAR},
- #{meterReadRecord.updateBy,jdbcType=VARCHAR}
- )
- </foreach>
- </insert>
- <!--auto generated Code-->
- <update id="updateByPrimaryKeySelective">
- UPDATE sc_meter_read_record
- <set>
- <if test="meterReadRecord.readDate != null"> read_date= #{meterReadRecord.readDate,jdbcType=INTEGER},</if>
- <if test="meterReadRecord.siteId != null"> site_id= #{meterReadRecord.siteId,jdbcType=INTEGER},</if>
- <if test="meterReadRecord.sysId != null"> sys_id= #{meterReadRecord.sysId,jdbcType=INTEGER},</if>
- <if test="meterReadRecord.province != null"> province= #{meterReadRecord.province,jdbcType=INTEGER},</if>
- <if test="meterReadRecord.city != null"> city= #{meterReadRecord.city,jdbcType=INTEGER},</if>
- <if test="meterReadRecord.region != null"> region= #{meterReadRecord.region,jdbcType=INTEGER},</if>
- <if test="meterReadRecord.communityId != null"> community= #{meterReadRecord.communityId,jdbcType=VARCHAR},</if>
- <if test="meterReadRecord.buildingId != null"> building_id= #{meterReadRecord.buildingId,jdbcType=INTEGER},</if>
- <if test="meterReadRecord.location != null"> location= #{meterReadRecord.location,jdbcType=VARCHAR},</if>
- <if test="meterReadRecord.deviceTypeId != null"> device_type_id= #{meterReadRecord.deviceTypeId,jdbcType=INTEGER},</if>
- <if test="meterReadRecord.deviceId != null"> device_id= #{meterReadRecord.deviceId,jdbcType=BIGINT},</if>
- <if test="meterReadRecord.deviceNo != null"> device_no= #{meterReadRecord.deviceNo,jdbcType=VARCHAR},</if>
- <if test="meterReadRecord.meterNo != null"> meter_no= #{meterReadRecord.meterNo,jdbcType=VARCHAR},</if>
- <if test="meterReadRecord.meterFileNo != null"> meter_file_no= #{meterReadRecord.meterFileNo,jdbcType=VARCHAR},</if>
- <if test="meterReadRecord.readTime != null"> read_time= #{meterReadRecord.readTime,jdbcType=TIMESTAMP},</if>
- <if test="meterReadRecord.readStatus != null"> read_status= #{meterReadRecord.readStatus,jdbcType=VARCHAR},</if>
- <if test="meterReadRecord.readData != null"> read_data= #{meterReadRecord.readData,jdbcType=VARCHAR},</if>
- <if test="meterReadRecord.lastValid!=null"> last_valid = #{meterReadRecord.lastValid,jdbcType=VARCHAR},</if>
- <if test="meterReadRecord.lastCost!=null"> last_cost = #{meterReadRecord.lastCost,jdbcType=DECIMAL},</if>
- <if test="meterReadRecord.status != null"> status= #{meterReadRecord.status,jdbcType=INTEGER},</if>
- <if test="meterReadRecord.dateCreate != null"> date_create= #{meterReadRecord.dateCreate,jdbcType=TIMESTAMP},</if>
- <if test="meterReadRecord.dateUpdate != null"> date_update= #{meterReadRecord.dateUpdate,jdbcType=TIMESTAMP},</if>
- <if test="meterReadRecord.createBy != null"> create_by= #{meterReadRecord.createBy,jdbcType=VARCHAR},</if>
- <if test="meterReadRecord.updateBy != null"> update_by= #{meterReadRecord.updateBy,jdbcType=VARCHAR}</if>
- </set>
- WHERE id = #{meterReadRecord.id,jdbcType=BIGINT}
- </update>
- <select id="queryMeterReadRecord" resultType="com.bz.smart_city.entity.MeterReadRecord">
- select
- m.id as id,
- read_date,
- m.site_id as site_id,
- m.sys_id as sys_id,
- m.province as province,
- m.city as city,
- m.region as region,
- m.community as community,
- m.building_id as building_id,
- b.name as building_name,
- m.location as location,
- device_type_id,
- device_id,
- device_no,
- meter_no,
- meter_file_no,
- read_time,
- read_status,
- read_data,
- m.status as status
- from
- sc_meter_read_record m
- left join sc_building b on ( building_id = b.id)
- where 1=1
- <if test="param.siteId != null and param.siteId != 0"> and m.site_id = #{param.siteId}</if>
- <if test="param.buildingId != null and param.buildingId != 0"> and building_id = #{param.buildingId}</if>
- <if test = "param.deviceNo != null and param.deviceNo != ''"> and device_no like #{param.deviceNo}</if>
- <if test = 'param.readStatus != null and param.readStatus != "0"'> and read_status = #{param.readStatus,jdbcType=VARCHAR}</if>
- <if test = "param.location != null and param.location != ''"> and location like #{param.location}</if>
- <if test = "param.startDate != null and param.startDate != 0"> and read_date >= #{param.startDate}</if>
- <if test = "param.endDate != null and param.endDate != 0"> and read_date <![CDATA[ <= ]]> #{param.endDate}</if>
- and m.status = 1
- order by read_time desc
- </select>
- <!--
- <select id="statisticReadRecordsByProvince" resultType="com.bz.smart_city.entity.MeterRecordStat">
- SELECT
- '省' as level,
- a.province as item_id,
- a.NAME as item_name,
- CASE WHEN b.total IS NULL THEN 0 ELSE b.total END AS total
- FROM
- (
- SELECT
- DISTINCT
- province,
- a.NAME
- FROM
- sc_building
- LEFT JOIN sc_area a ON (province = a.id )
- WHERE
- 1 = 1
- and STATUS = 1
- <if test = "param.siteId != null and param.siteId != 0"> and site_id = #{param.siteId}</if>
- <if test='param.programItems != null and param.programItems.size() != 0' >
- and <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
- <if test = 'item.dimensionCode == "PROVINCE" '>
- province = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "CITY" '>
- city = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "REGION" '>
- region = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "COMMUNITY" '>
- community = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "BUILDING" '>
- id = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- ) a
- LEFT JOIN (
- SELECT
- province,
- count( 1 ) AS total
- FROM
- sc_meter_read_record
- WHERE
- 1 = 1
- AND STATUS = 1
- <if test="param.channelId != null and param.channelId != 0 "> and sys_id = #{param.channelId}</if>
- <if test = "param.siteId !=null and param.siteId != 0"> and site_id = #{param.siteId}</if>
- <if test='param.programItems != null and param.programItems.size() != 0' >
- and EXISTS (
- select 1 from
- (select
- distinct df.device_id
- FROM sc_device_dim_info df
- WHERE 1 = 1
- and <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
- (df.dimension_code = #{item.dimensionCode} and df.dimension_value = #{item.dimensionValue})
- </foreach> ) ud WHERE ud.device_id = device_id)
- </if>
-
- <if test = "param.deviceNo != null and param.deviceNo != ''"> and device_no like #{param.deviceNo}</if>
- <if test = 'param.readStatus != null and param.readStatus != "0"'> and read_status = #{param.readStatus,jdbcType=VARCHAR}</if>
- <if test = "param.location != null and param.location != ''"> and location like #{param.location}</if>
- <if test = "param.startDate != null and param.startDate != 0"> and read_date >= #{param.startDate}</if>
- <if test = "param.endDate != null and param.endDate != 0"> and read_date <![CDATA[ <= ]]> #{param.endDate}</if>
- GROUP BY
- province
- ) b ON ( a.province = b.province )
- order by total desc
- </select>
- <select id="statisticReadRecordsByCity" resultType="com.bz.smart_city.entity.MeterRecordStat">
- SELECT
- '市' as level,
- a.city as item_id,
- a.NAME as item_name,
- CASE WHEN b.total IS NULL THEN 0 ELSE b.total END AS total
- FROM
- (
- SELECT
- DISTINCT
- city,
- a.NAME
- FROM
- sc_building
- LEFT JOIN sc_area a ON (city = a.id )
- WHERE
- 1 = 1
- and STATUS = 1
- <if test = "param.siteId != null and param.siteId != 0"> and site_id = #{param.siteId}</if>
- <if test = "param.province != null and param.province != ''"> and province = #{param.province}</if>
- <if test='param.programItems != null and param.programItems.size() != 0' >
- and <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
- <if test = 'item.dimensionCode == "PROVINCE" '>
- province = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "CITY" '>
- city = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "REGION" '>
- region = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "COMMUNITY" '>
- community = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "BUILDING" '>
- id = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- ) a
- LEFT JOIN (
- SELECT
- city,
- count( 1 ) AS total
- FROM
- sc_meter_read_record
- WHERE
- 1 = 1
- AND STATUS = 1
- <if test="param.channelId != null and param.channelId != 0 "> and sys_id = #{param.channelId}</if>
- <if test = "param.siteId !=null and param.siteId != 0"> and site_id = #{param.siteId}</if>
- <if test='param.programItems != null and param.programItems.size() != 0' >
- and EXISTS (
- select 1 from
- (select
- distinct df.device_id
- FROM sc_device_dim_info df
- WHERE 1 = 1
- and <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
- (df.dimension_code = #{item.dimensionCode} and df.dimension_value = #{item.dimensionValue})
- </foreach> ) ud WHERE ud.device_id = device_id)
- </if>
- <if test = "param.province != null and param.province != ''"> and province = #{param.province}</if>
- <if test = "param.deviceNo != null and param.deviceNo != ''"> and device_no like #{param.deviceNo}</if>
- <if test = 'param.readStatus != null and param.readStatus != "0"'> and read_status = #{param.readStatus,jdbcType=VARCHAR}</if>
- <if test = "param.location != null and param.location != ''"> and location like #{param.location}</if>
- <if test = "param.startDate != null and param.startDate != 0"> and read_date >= #{param.startDate}</if>
- <if test = "param.endDate != null and param.endDate != 0"> and read_date <![CDATA[ <= ]]> #{param.endDate}</if>
- GROUP BY
- city
- ) b ON ( a.city = b.city )
- order by total desc
- </select>
- -->
- <!-- 按照小区进行汇总
- <select id="statisticReadRecordsByCommunity" resultType="com.bz.smart_city.entity.MeterRecordStat">
- SELECT
- '小区' as level,
- a.community as item_id,
- a.NAME as item_name,
- CASE WHEN b.total IS NULL THEN 0 ELSE b.total END AS total
- FROM
- (
- SELECT
- DISTINCT
- community,
- a.NAME
- FROM
- sc_building b
- left join sc_community a on (community = a.id)
- WHERE
- 1 = 1
- and a.STATUS = 1
- <if test = "param.siteId != null and param.siteId != 0"> and b.site_id = #{param.siteId}</if>
- <if test = "param.city != null and param.city != ''"> and b.city = #{param.city}</if>
- <if test='param.programItems != null and param.programItems.size() != 0' >
- and <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
- <if test = 'item.dimensionCode == "PROVINCE" '>
- b.province = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "CITY" '>
- b.city = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "REGION" '>
- b.region = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "COMMUNITY" '>
- b.community = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "BUILDING" '>
- b.id = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- ) a
- LEFT JOIN (
- SELECT
- community,
- count( 1 ) AS total
- FROM
- sc_meter_read_record
- WHERE
- 1 = 1
- AND STATUS = 1
- <if test="param.channelId != null and param.channelId != 0 "> and sys_id = #{param.channelId}</if>
- <if test = "param.siteId !=null and param.siteId != 0"> and site_id = #{param.siteId}</if>
- <if test='param.programItems != null and param.programItems.size() != 0' >
- and EXISTS (
- select 1 from
- (select
- distinct df.device_id
- FROM sc_device_dim_info df
- WHERE 1 = 1
- and <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
- (df.dimension_code = #{item.dimensionCode} and df.dimension_value = #{item.dimensionValue})
- </foreach> ) ud WHERE ud.device_id = device_id)
- </if>
- <if test = "param.city != null and param.city != ''"> and city = #{param.city}</if>
- <if test = "param.deviceNo != null and param.deviceNo != ''"> and device_no like #{param.deviceNo}</if>
- <if test = 'param.readStatus != null and param.readStatus != "0"'> and read_status = #{param.readStatus,jdbcType=VARCHAR}</if>
- <if test = "param.location != null and param.location != ''"> and location like #{param.location}</if>
- <if test = "param.startDate != null and param.startDate != 0"> and read_date >= #{param.startDate}</if>
- <if test = "param.endDate != null and param.endDate != 0"> and read_date <![CDATA[ <= ]]> #{param.endDate}</if>
- GROUP BY
- community
- ) b ON ( a.community = b.community )
- order by total desc
- </select>
- -->
- <update id = "createTmpTable">
- create TEMPORARY table ${tableName} as
- select
- province,
- city,
- community,
- building_id,
- id
- from
- sc_meter_read_record
- where status = 1
- <if test="param.channelId != null and param.channelId != 0 "> and sys_id = #{param.channelId}</if>
- <if test = "param.siteId !=null and param.siteId != 0"> and site_id = #{param.siteId}</if>
- <if test='param.programItems != null and param.programItems.size() != 0' >
- and device_id in (
- select
- df.device_id
- FROM sc_device_dim_info df
- WHERE 1 = 1
- and <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
- (df.dimension_code = #{item.dimensionCode} and df.dimension_value = #{item.dimensionValue})
- </foreach>
- )
- </if>
- <if test = "param.province != null and param.province != ''"> and province = #{param.province}</if>
- <if test = "param.region != null and param.region != ''"> and region = #{param.region}</if>
- <if test = "param.city != null and param.city != ''"> and city = #{param.city}</if>
- <if test = "param.communityId != null and param.communityId != '' ">and community = #{param.communityId} </if>
- <if test = "param.deviceNo != null and param.deviceNo != ''"> and device_no like #{param.deviceNo}</if>
- <if test = 'param.readStatus != null and param.readStatus != "0"'> and read_status = #{param.readStatus,jdbcType=VARCHAR}</if>
- <if test = "param.location != null and param.location != ''"> and location like #{param.location}</if>
- <if test = "param.startDate != null and param.startDate != 0"> and read_date >= #{param.startDate}</if>
- <if test = "param.endDate != null and param.endDate != 0"> and read_date <![CDATA[ <= ]]> #{param.endDate}</if>
- </update>
-
- <update id="dropTmpTable" >
- drop TEMPORARY table if exists ${tableName}
- </update>
-
- <select id= "statisticReadRecordsByProvince" resultType="com.bz.smart_city.entity.MeterRecordStat">
- select
- 1 as level,
- a.parent_id as parent_id,
- province as item_id,
- a.name as item_name,
- count(1) as total
- from
- ${tableName}
- left join sc_area a on (province = a.id)
- group by province,a.name,a.parent_id
- </select>
- <select id= "statisticReadRecordsByCity" resultType="com.bz.smart_city.entity.MeterRecordStat">
- select
- 2 as level,
- a.parent_id as parent_id,
- city as item_id,
- a.name as item_name,
- count(1) as total
- from
- ${tableName}
- left join sc_area a on (city = a.id)
- group by city,a.name,a.parent_id
- </select>
-
- <select id= "statisticReadRecordsByCommuinty" resultType="com.bz.smart_city.entity.MeterRecordStat">
- select
- 3 as level,
- a.city as parent_id,
- community as item_id,
- a.name as item_name,
- count(1) as total
- from
- ${tableName}
- left join sc_community a on (community = a.id)
- group by community,a.name,a.city
- </select>
-
-
- <select id= "statisticReadRecordsByBuilding" resultType="com.bz.smart_city.entity.MeterRecordStat">
- select
- 4 as level,
- a.community as parent_id,
- building_id as item_id,
- a.name as item_name,
- count(1) as total
- from
- ${tableName}
- left join sc_building a on (building_id = a.id)
- group by building_id,a.name,a.community
- </select>
-
- <!--
- <select id="statisticReadRecordsByRegion" resultType="com.bz.smart_city.entity.MeterRecordStat">
- SELECT
- '区' as level,
- a.region as item_id,
- a.NAME as item_name,
- CASE WHEN b.total IS NULL THEN 0 ELSE b.total END AS total
- FROM
- (
- SELECT DISTINCT
- region,
- NAME
- FROM
- sc_meter_read_record
- LEFT JOIN sc_area a ON ( region = a.id )
- WHERE
- 1 = 1
- AND a.STATUS = 1
- <if test="param.channelId != null and param.channelId != 0 "> and sys_id = #{param.channelId}</if>
- <if test = "param.siteId !=null and param.siteId != 0"> and site_id = #{param.siteId}</if>
- <if test = "param.city != null and param.city != ''"> and city = #{param.city}</if>
- ) a
- LEFT JOIN (
- SELECT
- region,
- count( 1 ) AS total
- FROM
- sc_meter_read_record
- WHERE
- 1 = 1
- AND STATUS = 1
- <if test="param.channelId != null and param.channelId != 0 "> and sys_id = #{param.channelId}</if>
- <if test = "param.siteId !=null and param.siteId != 0"> and site_id = #{param.siteId}</if>
- <if test = "param.province != null and param.province != ''"> and province = #{param.province}</if>
- <if test = "param.region != null and param.region != ''"> and region = #{param.region}</if>
- <if test = "param.city != null and param.city != ''"> and city = #{param.city}</if>
- <if test = "param.communityId != null and param.communityId != '' ">and community = #{param.communityId} </if>
- <if test = "param.deviceNo != null and param.deviceNo != ''"> and device_no like #{param.deviceNo}</if>
- <if test = 'param.readStatus != null and param.readStatus != "0"'> and read_status = #{param.readStatus,jdbcType=VARCHAR}</if>
- <if test = "param.location != null and param.location != ''"> and location like #{param.location}</if>
- <if test = "param.startDate != null and param.startDate != 0"> and read_date >= #{param.startDate}</if>
- <if test = "param.endDate != null and param.endDate != 0"> and read_date <![CDATA[ <= ]]> #{param.endDate}</if>
- GROUP BY
- region
- ) b ON ( a.region = b.region )
- order by total desc
- </select>
-
- <select id="statisticReadRecordsByBuilding" resultType="com.bz.smart_city.entity.MeterRecordStat">
- SELECT
- '建筑' as level,
- a.id as item_id,
- a.name as item_name,
- case when b.total is null then 0 else b.total end as total
- FROM
- (
- SELECT
- DISTINCT
- id,
- NAME
- FROM
- sc_building
- WHERE
- 1 = 1
- and STATUS = 1
- <if test = "param.siteId != null and param.siteId != 0"> and site_id = #{param.siteId}</if>
- <if test = "param.province != null and param.province != ''"> and province = #{param.province}</if>
- <if test = "param.region != null and param.region != ''"> and region = #{param.region}</if>
- <if test = "param.city != null and param.city != ''"> and city = #{param.city}</if>
- <if test=" param.communityId != null and param.communityId != '' ">and community = #{param.communityId} </if>
- <if test='param.programItems != null and param.programItems.size() != 0' >
- and <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
- <if test = 'item.dimensionCode == "PROVINCE" '>
- province = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "CITY" '>
- city = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "REGION" '>
- region = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "COMMUNITY" '>
- community = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "BUILDING" '>
- id = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- ) a
- LEFT JOIN (
- SELECT
- building_id,
- count( 1 ) AS total
- FROM
- sc_meter_read_record
- WHERE
- 1 = 1
- AND STATUS = 1
- <if test = "param.channelId != null and param.channelId != 0 "> and sys_id = #{param.channelId}</if>
- <if test = "param.siteId !=null and param.siteId != 0"> and site_id = #{param.siteId}</if>
- <if test = "param.city != null and param.city != ''"> and city = #{param.city}</if>
- <if test = "param.region != null and param.region != ''"> and region = #{param.region}</if>
- <if test=" param.communityId != null and param.communityId != '' ">and community = #{param.communityId} </if>
- <if test='param.programItems != null and param.programItems.size() != 0' >
- and EXISTS (
- select 1 from
- (select
- distinct df.device_id
- FROM sc_device_dim_info df
- WHERE 1 = 1
- and <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
- (df.dimension_code = #{item.dimensionCode} and df.dimension_value = #{item.dimensionValue})
- </foreach> ) ud WHERE ud.device_id = device_id)
- </if>
- <if test = "param.deviceNo != null and param.deviceNo != ''"> and device_no like #{param.deviceNo}</if>
- <if test = 'param.readStatus != null and param.readStatus != "0"'> and read_status = #{param.readStatus,jdbcType=VARCHAR}</if>
- <if test = "param.location != null and param.location != ''"> and location like #{param.location}</if>
- <if test = "param.startDate != null and param.startDate != 0"> and read_date >= #{param.startDate}</if>
- <if test = "param.endDate != null and param.endDate != 0"> and read_date <![CDATA[ <= ]]> #{param.endDate}</if>
- GROUP BY
- building_id
- ) b ON ( a.id = b.building_id )
- order by b.total desc
- </select>
- -->
- <select id="queryMeterReadRecordWithCondtion" resultType="com.bz.smart_city.entity.MeterReadRecord">
- SELECT
- m.id AS id,
- m.read_date as read_date,
- m.site_id AS site_id,
- m.sys_id AS sys_id,
- m.province AS province,
- m.city AS city,
- m.community AS community_id,
- com.`name` as community_name,
- m.building_id AS building_id,
- b.NAME AS building_name,
- m.location AS location,
- device_type_id ,
- device_id,
- device_no,
- meter_no,
- meter_file_no,
- read_time,
- read_status,
- read_data,
- m.concentrator_id as concentrator_id,
- con.serial_number as concentrator_no,
- m.collector_id as collector_id ,
- col.collector_no as collector_no,
- m.customer_id as customer_id,
- cust.customer_name as customer_name,
- dt.manufacturer_id as factory_id,
- dm.`name` as factory_name
- FROM
- sc_meter_read_record m
- LEFT JOIN sc_building b ON ( m.building_id = b.id )
- left join sc_community com on (com.id = m.community)
- left join sc_customer cust on (cust.id = m.customer_id)
- left join sc_concentrator con on (con.id = m.concentrator_id)
- left join sc_collector col on (col.id = m.collector_id)
- left join sc_device_type dt on (dt.id = m.device_type_id)
- left join sc_device_manufacturer dm on (dm.id = dt.manufacturer_id)
- WHERE m.STATUS = 1
- <!-- 数据权限 -->
- <if test="param.siteId != null and param.siteId != 0">
- and m.site_id = #{param.siteId}
- </if>
- <if test="param.sites != null and param.sites.size() != 0">
- and m.site_id in
- <foreach collection="param.sites" item="site" open="(" separator="," close=")">
- #{site.id}
- </foreach>
- </if>
- <if test="param.buildingIds != null and param.buildingIds.size() != 0">
- and m.building_id in <foreach collection="param.buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
-
- <!--
- <if test='param.programItems != null and param.programItems.size() != 0' >
- and EXISTS (
- select 1 from
- (select
- distinct df.device_id
- FROM sc_device_dim_info df
- WHERE 1 = 1
- and <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
- (df.dimension_code = #{item.dimensionCode} and df.dimension_value = #{item.dimensionValue})
- </foreach> ) ud WHERE ud.device_id = m.device_id)
- </if>
- -->
- <if test = "param.concentratorCode != null and param.concentratorCode != '' "> and con.serial_number like #{param.concentratorCode}</if>
- <if test = "param.collectorCode != null and param.collectorCode != '' "> and col.collector like #{param.collectorCode}</if>
- <if test = "param.deviceNo != null and param.deviceNo != '' ">
- and ( m.device_no like #{param.deviceNo}
- or m.meter_no like #{param.deviceElectricNo}
- or m.meter_file_no like #{param.devicefileNo})
- </if>
- <if test = "param.custormerId !=null and param.custormerId != 0"> and m.customer_id = #{param.custormerId}</if>
- <if test = "param.communityId != null and param.communityId != 0"> and m.community = #{param.communityId}</if>
- <if test = "param.buildingId != null and param.buildingId != 0"> and m.building_id = #{param.buildingId}</if>
- <if test = 'param.readStatus != null and param.readStatus != ""'> and read_status = #{param.readStatus}</if>
- <if test = "param.channelId != null and param.channelId != 0"> and m.sys_id = #{param.channelId}</if>
- <if test = "param.startDate != null and param.startDate != 0"> and read_date >= #{param.startDate}</if>
- <if test = "param.endDate != null and param.endDate != 0"> and read_date <![CDATA[ <= ]]> #{param.endDate}</if>
- order by read_time desc
- </select>
- <select id="queryUnReadDeviceListWithNew" resultType="com.bz.smart_city.dto.DeviceDto">
- SELECT
- d.site_id as siteId,
- d.customer_id as customerId,
- d.sys_id as sysId,
- d.id as id,
- d.device_type as deviceType,
- d.building_id as buildingId,
- co.id as community,
- p.id as province,
- c.id as city,
- r.id as region,
- cu.customer_name as customerName,
- b.`name`as buildingName,
- co.`name`as communityName,
- col.collector_no as collectorName,
- con.serial_number as concentratorName,
- d.water_meter_no as waterMeterNo,
- d.water_meter_file_no as waterMeterFileNo,
- d.device_no as deviceNo,
- d.device_status as deviceStatus,
- d.floor as floor,
- d.loc_desc as locDesc,
- d.last_receive_time as lastReceiveTime
- FROM
- sc_device d
- LEFT JOIN sc_w_meter_type wmt ON ( d.device_type = wmt.device_type_id AND wmt.`status` = 1 )
- LEFT JOIN sc_customer cu ON ( d.customer_id = cu.id AND cu.`status` = 1 )
- LEFT JOIN sc_building b ON ( d.building_id = b.id AND b.`status` = 1 )
- LEFT JOIN sc_community co ON ( b.community = co.id AND co.`status` = 1 )
- LEFT JOIN sc_area p ON ( b.province = p.id )
- LEFT JOIN sc_area c ON ( b.city = c.id )
- LEFT JOIN sc_area r ON ( b.region = r.id )
- LEFT JOIN sc_water_related_device rd ON ( rd.device_id = d.id AND rd.`status` = 1 )
- LEFT JOIN sc_collector col ON ( col.id = rd.collector_id AND col.`status` = 1 )
- LEFT JOIN sc_concentrator con ON ( con.id = rd.concentrator_id AND con.`status` = 1 )
- where d.status = 1
- <if test = "param.buildingId != null and param.buildingId != 0">
- and d.building_id = #{param.buildingId}
- </if>
- <if test="param.siteId != null and param.siteId != 0">
- and d.site_id = #{param.siteId}
- </if>
- <if test = "param.channelId != null and param.channelId != 0">
- and d.sys_id = #{param.channelId}
- </if>
- <if test="param.custormerId != null and param.custormerId != 0">
- and d.customer_id = #{param.custormerId}
- </if>
- and ( d.id IN (
- SELECT
- tmp.device_id
- FROM
- (
- SELECT
- site_id,
- sys_id,
- building_id,
- device_id
- FROM
- sc_meter_read_record
- WHERE
- <if test = "param.statDay != null and param.statDay != 0">
- read_date = #{param.statDay}
- </if>
- <if test = "param.buildingId != null and param.buildingId != 0">
- AND building_id = #{param.buildingId}
- </if>
- AND read_status = 1
- ) tmp
- ) or d.device_status = 5)
- </select>
- <select id="queryUnReadDeviceList" resultType="com.bz.smart_city.dto.DeviceDto">
- SELECT
- d.site_id as siteId,
- d.customer_id as customerId,
- d.sys_id as sysId,
- d.id as id,
- d.device_type as deviceType,
- d.building_id as buildingId,
- co.id as community,
- p.id as province,
- c.id as city,
- r.id as region,
- cu.customer_name as customerName,
- b.`name`as buildingName,
- co.`name`as communityName,
- col.collector_no as collectorName,
- con.serial_number as concentratorName,
- d.water_meter_no as waterMeterNo,
- d.water_meter_file_no as waterMeterFileNo,
- d.device_no as deviceNo,
- d.device_status as deviceStatus,
- d.floor as floor,
- d.loc_desc as locDesc,
- d.last_receive_time as lastReceiveTime
- FROM
- sc_device d
- LEFT JOIN sc_w_meter_type wmt ON ( d.device_type = wmt.device_type_id AND wmt.`status` = 1 )
- LEFT JOIN sc_customer cu ON ( d.customer_id = cu.id AND cu.`status` = 1 )
- LEFT JOIN sc_building b ON ( d.building_id = b.id AND b.`status` = 1 )
- LEFT JOIN sc_community co ON ( b.community = co.id AND co.`status` = 1 )
- LEFT JOIN sc_area p ON ( b.province = p.id )
- LEFT JOIN sc_area c ON ( b.city = c.id )
- LEFT JOIN sc_area r ON ( b.region = r.id )
- LEFT JOIN sc_water_related_device rd ON ( rd.device_id = d.id AND rd.`status` = 1 )
- LEFT JOIN sc_collector col ON ( col.id = rd.collector_id AND col.`status` = 1 )
- LEFT JOIN sc_concentrator con ON ( con.id = rd.concentrator_id AND con.`status` = 1 )
- where d.status = 1
- <if test = "param.buildingId != null and param.buildingId != 0">
- and d.building_id = #{param.buildingId}
- </if>
- <if test="param.siteId != null and param.siteId != 0">
- and d.site_id = #{param.siteId}
- </if>
- <if test = "param.channelId != null and param.channelId != 0">
- and d.sys_id = #{param.channelId}
- </if>
- <if test="param.custormerId != null and param.custormerId != 0">
- and d.customer_id = #{param.custormerId}
- </if>
- and d.id IN (
- SELECT
- tmp.device_id
- FROM
- (
- SELECT
- site_id,
- channel_id,
- building_id,
- device_id
- FROM
- sc_stat_meter_unread_device_by_building
- WHERE
- <if test = "param.statDay != null and param.statDay != 0">
- stat_day = #{param.statDay}
- </if>
- <if test = "param.buildingId != null and param.buildingId != 0">
- AND building_id = #{param.buildingId}
- </if>
- ) tmp
- )
- </select>
- <select id="queryUnReadDeviceListV2" resultType="com.bz.smart_city.dto.DeviceDto">
- SELECT
- d.site_id as siteId,
- d.customer_id as customerId,
- d.sys_id as sysId,
- d.id as id,
- d.device_type as deviceType,
- d.building_id as buildingId,
- co.id as community,
- p.id as province,
- c.id as city,
- r.id as region,
- cu.customer_name as customerName,
- b.`name`as buildingName,
- co.`name`as communityName,
- col.collector_no as collectorName,
- con.serial_number as concentratorName,
- d.water_meter_no as waterMeterNo,
- d.water_meter_file_no as waterMeterFileNo,
- d.device_no as deviceNo,
- d.device_status as deviceStatus,
- d.floor as floor,
- d.loc_desc as locDesc,
- d.last_receive_time as lastReceiveTime
- FROM ${tableName} as t1
- LEFT JOIN sc_device d on(t1.device_id = d.id)
- LEFT JOIN sc_w_meter_type wmt ON ( d.device_type = wmt.device_type_id AND wmt.`status` = 1 )
- LEFT JOIN sc_customer cu ON ( d.customer_id = cu.id AND cu.`status` = 1 )
- LEFT JOIN sc_building b ON ( d.building_id = b.id AND b.`status` = 1 )
- LEFT JOIN sc_community co ON ( b.community = co.id AND co.`status` = 1 )
- LEFT JOIN sc_area p ON ( b.province = p.id )
- LEFT JOIN sc_area c ON ( b.city = c.id )
- LEFT JOIN sc_area r ON ( b.region = r.id )
- LEFT JOIN sc_water_related_device rd ON ( rd.device_id = d.id AND rd.`status` = 1 )
- LEFT JOIN sc_collector col ON ( col.id = rd.collector_id AND col.`status` = 1 )
- LEFT JOIN sc_concentrator con ON ( con.id = rd.concentrator_id AND con.`status` = 1 )
- where d.status = 1
- <if test = "param.buildingId != null and param.buildingId != 0">
- and d.building_id = #{param.buildingId}
- </if>
- <if test="param.siteId != null and param.siteId != 0">
- and d.site_id = #{param.siteId}
- </if>
- <if test = "param.channelId != null and param.channelId != 0">
- and d.sys_id = #{param.channelId}
- </if>
- <if test="param.custormerId != null and param.custormerId != 0">
- and d.customer_id = #{param.custormerId}
- </if>
- <if test = "param.statDay != null and param.statDay != 0">
- and t1.stat_day = #{param.statDay}
- </if>
- <if test = "param.buildingId != null and param.buildingId != 0">
- AND t1.building_id = #{param.buildingId}
- </if>
- </select>
- <select id="queryUnReadDeviceListFor7Day" resultType="com.bz.smart_city.dto.DeviceDto">
- SELECT
- d.site_id as siteId,
- d.customer_id as customerId,
- d.sys_id as sysId,
- d.id as id,
- d.device_type as deviceType,
- d.building_id as buildingId,
- co.id as community,
- p.id as province,
- c.id as city,
- r.id as region,
- cu.customer_name as customerName,
- b.`name`as buildingName,
- co.`name`as communityName,
- col.collector_no as collectorName,
- con.serial_number as concentratorName,
- d.water_meter_no as waterMeterNo,
- d.water_meter_file_no as waterMeterFileNo,
- d.device_no as deviceNo,
- d.device_status as deviceStatus,
- d.floor as floor,
- d.loc_desc as locDesc,
- d.last_receive_time as lastReceiveTime
- FROM
- sc_device d
- LEFT JOIN sc_w_meter_type wmt ON ( d.device_type = wmt.device_type_id AND wmt.`status` = 1 )
- LEFT JOIN sc_customer cu ON ( d.customer_id = cu.id AND cu.`status` = 1 )
- LEFT JOIN sc_building b ON ( d.building_id = b.id AND b.`status` = 1 )
- LEFT JOIN sc_community co ON ( b.community = co.id AND co.`status` = 1 )
- LEFT JOIN sc_area p ON ( b.province = p.id )
- LEFT JOIN sc_area c ON ( b.city = c.id )
- LEFT JOIN sc_area r ON ( b.region = r.id )
- LEFT JOIN sc_water_related_device rd ON ( rd.device_id = d.id AND rd.`status` = 1 )
- LEFT JOIN sc_collector col ON ( col.id = rd.collector_id AND col.`status` = 1 )
- LEFT JOIN sc_concentrator con ON ( con.id = rd.concentrator_id AND con.`status` = 1 )
- where d.status = 1
- <if test = "param.buildingId != null and param.buildingId != 0">
- and d.building_id = #{param.buildingId}
- </if>
- <if test="param.siteId != null and param.siteId != 0">
- and d.site_id = #{param.siteId}
- </if>
- <if test = "param.channelId != null and param.channelId != 0">
- and d.sys_id = #{param.channelId}
- </if>
- <if test="param.custormerId != null and param.custormerId != 0">
- and d.customer_id = #{param.custormerId}
- </if>
- and d.id IN (
- SELECT
- tmp.device_id
- FROM
- (
- SELECT
- site_id,
- channel_id,
- building_id,
- device_id
- FROM
- sc_stat_meter_unread_device_by_building_7day
- WHERE
- <if test = "param.statDay != null and param.statDay != 0">
- stat_day = #{param.statDay}
- </if>
- <if test = "param.buildingId != null and param.buildingId != 0">
- AND building_id = #{param.buildingId}
- </if>
- ) tmp
- )
- </select>
- <select id="queryUnReadDeviceListFor7DayWithNew" resultType="com.bz.smart_city.dto.DeviceDto">
- SELECT
- d.site_id as siteId,
- d.customer_id as customerId,
- d.sys_id as sysId,
- d.id as id,
- d.device_type as deviceType,
- d.building_id as buildingId,
- co.id as community,
- p.id as province,
- c.id as city,
- r.id as region,
- cu.customer_name as customerName,
- b.`name`as buildingName,
- co.`name`as communityName,
- col.collector_no as collectorName,
- con.serial_number as concentratorName,
- d.water_meter_no as waterMeterNo,
- d.water_meter_file_no as waterMeterFileNo,
- d.device_no as deviceNo,
- d.device_status as deviceStatus,
- d.floor as floor,
- d.loc_desc as locDesc,
- d.last_receive_time as lastReceiveTime
- FROM
- sc_device d
- LEFT JOIN sc_w_meter_type wmt ON ( d.device_type = wmt.device_type_id AND wmt.`status` = 1 )
- LEFT JOIN sc_customer cu ON ( d.customer_id = cu.id AND cu.`status` = 1 )
- LEFT JOIN sc_building b ON ( d.building_id = b.id AND b.`status` = 1 )
- LEFT JOIN sc_community co ON ( b.community = co.id AND co.`status` = 1 )
- LEFT JOIN sc_area p ON ( b.province = p.id )
- LEFT JOIN sc_area c ON ( b.city = c.id )
- LEFT JOIN sc_area r ON ( b.region = r.id )
- LEFT JOIN sc_water_related_device rd ON ( rd.device_id = d.id AND rd.`status` = 1 )
- LEFT JOIN sc_collector col ON ( col.id = rd.collector_id AND col.`status` = 1 )
- LEFT JOIN sc_concentrator con ON ( con.id = rd.concentrator_id AND con.`status` = 1 )
- where d.status = 1
- <if test = "param.buildingId != null and param.buildingId != 0">
- and d.building_id = #{param.buildingId}
- </if>
- <if test="param.siteId != null and param.siteId != 0">
- and d.site_id = #{param.siteId}
- </if>
- <if test = "param.channelId != null and param.channelId != 0">
- and d.sys_id = #{param.channelId}
- </if>
- <if test="param.custormerId != null and param.custormerId != 0">
- and d.customer_id = #{param.custormerId}
- </if>
- and ( d.id IN (
- SELECT
- tmp.device_id
- FROM
- (
- SELECT
- site_id,
- channel_id,
- building_id,
- device_id
- FROM
- sc_stat_meter_unread_device_by_building_7day
- WHERE
- <if test = "param.statDay != null and param.statDay != 0">
- stat_day = #{param.statDay}
- </if>
- <if test = "param.buildingId != null and param.buildingId != 0">
- AND building_id = #{param.buildingId}
- </if>
- ) tmp
- ) or d.device_status = 5 )
- </select>
- <select id="queryUnReadDeviceListFor15Day" resultType="com.bz.smart_city.dto.DeviceDto">
- SELECT
- d.site_id as siteId,
- d.customer_id as customerId,
- d.sys_id as sysId,
- d.id as id,
- d.device_type as deviceType,
- d.building_id as buildingId,
- co.id as community,
- p.id as province,
- c.id as city,
- r.id as region,
- cu.customer_name as customerName,
- b.`name`as buildingName,
- co.`name`as communityName,
- col.collector_no as collectorName,
- con.serial_number as concentratorName,
- d.water_meter_no as waterMeterNo,
- d.water_meter_file_no as waterMeterFileNo,
- d.device_no as deviceNo,
- d.device_status as deviceStatus,
- d.floor as floor,
- d.loc_desc as locDesc,
- d.last_receive_time as lastReceiveTime
- FROM
- sc_device d
- LEFT JOIN sc_w_meter_type wmt ON ( d.device_type = wmt.device_type_id AND wmt.`status` = 1 )
- LEFT JOIN sc_customer cu ON ( d.customer_id = cu.id AND cu.`status` = 1 )
- LEFT JOIN sc_building b ON ( d.building_id = b.id AND b.`status` = 1 )
- LEFT JOIN sc_community co ON ( b.community = co.id AND co.`status` = 1 )
- LEFT JOIN sc_area p ON ( b.province = p.id )
- LEFT JOIN sc_area c ON ( b.city = c.id )
- LEFT JOIN sc_area r ON ( b.region = r.id )
- LEFT JOIN sc_water_related_device rd ON ( rd.device_id = d.id AND rd.`status` = 1 )
- LEFT JOIN sc_collector col ON ( col.id = rd.collector_id AND col.`status` = 1 )
- LEFT JOIN sc_concentrator con ON ( con.id = rd.concentrator_id AND con.`status` = 1 )
- where d.status = 1
- <if test = "param.buildingId != null and param.buildingId != 0">
- and d.building_id = #{param.buildingId}
- </if>
- <if test="param.siteId != null and param.siteId != 0">
- and d.site_id = #{param.siteId}
- </if>
- <if test = "param.channelId != null and param.channelId != 0">
- and d.sys_id = #{param.channelId}
- </if>
- <if test="param.custormerId != null and param.custormerId != 0">
- and d.customer_id = #{param.custormerId}
- </if>
- and d.id IN (
- SELECT
- tmp.device_id
- FROM
- (
- SELECT
- site_id,
- channel_id,
- building_id,
- device_id
- FROM
- sc_stat_meter_unread_device_by_building_15day
- WHERE
- <if test = "param.statDay != null and param.statDay != 0">
- stat_day = #{param.statDay}
- </if>
- <if test = "param.buildingId != null and param.buildingId != 0">
- AND building_id = #{param.buildingId}
- </if>
- ) tmp
- )
- </select>
- <select id="queryUnReadDeviceListForMonth" resultType="com.bz.smart_city.dto.DeviceDto">
- SELECT
- d.site_id as siteId,
- d.customer_id as customerId,
- d.sys_id as sysId,
- d.id as id,
- d.device_type as deviceType,
- d.building_id as buildingId,
- co.id as community,
- p.id as province,
- c.id as city,
- r.id as region,
- cu.customer_name as customerName,
- b.`name`as buildingName,
- co.`name`as communityName,
- col.collector_no as collectorName,
- con.serial_number as concentratorName,
- d.water_meter_no as waterMeterNo,
- d.water_meter_file_no as waterMeterFileNo,
- d.device_no as deviceNo,
- d.device_status as deviceStatus,
- d.floor as floor,
- d.loc_desc as locDesc,
- d.last_receive_time as lastReceiveTime
- FROM
- sc_device d
- LEFT JOIN sc_w_meter_type wmt ON ( d.device_type = wmt.device_type_id AND wmt.`status` = 1 )
- LEFT JOIN sc_customer cu ON ( d.customer_id = cu.id AND cu.`status` = 1 )
- LEFT JOIN sc_building b ON ( d.building_id = b.id AND b.`status` = 1 )
- LEFT JOIN sc_community co ON ( b.community = co.id AND co.`status` = 1 )
- LEFT JOIN sc_area p ON ( b.province = p.id )
- LEFT JOIN sc_area c ON ( b.city = c.id )
- LEFT JOIN sc_area r ON ( b.region = r.id )
- LEFT JOIN sc_water_related_device rd ON ( rd.device_id = d.id AND rd.`status` = 1 )
- LEFT JOIN sc_collector col ON ( col.id = rd.collector_id AND col.`status` = 1 )
- LEFT JOIN sc_concentrator con ON ( con.id = rd.concentrator_id AND con.`status` = 1 )
- where d.status = 1
- <if test = "param.buildingId != null and param.buildingId != 0">
- and d.building_id = #{param.buildingId}
- </if>
- <if test="param.siteId != null and param.siteId != 0">
- and d.site_id = #{param.siteId}
- </if>
- <if test = "param.channelId != null and param.channelId != 0">
- and d.sys_id = #{param.channelId}
- </if>
- <if test="param.custormerId != null and param.custormerId != 0">
- and d.customer_id = #{param.custormerId}
- </if>
- and d.id IN (
- SELECT
- tmp.device_id
- FROM
- (
- SELECT
- site_id,
- channel_id,
- building_id,
- device_id
- FROM
- sc_stat_meter_unread_device_by_building_month
- WHERE
- <if test = "param.statDay != null and param.statDay != 0">
- stat_day = #{param.statDay}
- </if>
- <if test = "param.buildingId != null and param.buildingId != 0">
- AND building_id = #{param.buildingId}
- </if>
- ) tmp
- )
- </select>
- <select id="queryUnReadDeviceListFor15DayWithNew" resultType="com.bz.smart_city.dto.DeviceDto">
- SELECT
- d.site_id as siteId,
- d.customer_id as customerId,
- d.sys_id as sysId,
- d.id as id,
- d.device_type as deviceType,
- d.building_id as buildingId,
- co.id as community,
- p.id as province,
- c.id as city,
- r.id as region,
- cu.customer_name as customerName,
- b.`name`as buildingName,
- co.`name`as communityName,
- col.collector_no as collectorName,
- con.serial_number as concentratorName,
- d.water_meter_no as waterMeterNo,
- d.water_meter_file_no as waterMeterFileNo,
- d.device_no as deviceNo,
- d.device_status as deviceStatus,
- d.floor as floor,
- d.loc_desc as locDesc,
- d.last_receive_time as lastReceiveTime
- FROM
- sc_device d
- LEFT JOIN sc_w_meter_type wmt ON ( d.device_type = wmt.device_type_id AND wmt.`status` = 1 )
- LEFT JOIN sc_customer cu ON ( d.customer_id = cu.id AND cu.`status` = 1 )
- LEFT JOIN sc_building b ON ( d.building_id = b.id AND b.`status` = 1 )
- LEFT JOIN sc_community co ON ( b.community = co.id AND co.`status` = 1 )
- LEFT JOIN sc_area p ON ( b.province = p.id )
- LEFT JOIN sc_area c ON ( b.city = c.id )
- LEFT JOIN sc_area r ON ( b.region = r.id )
- LEFT JOIN sc_water_related_device rd ON ( rd.device_id = d.id AND rd.`status` = 1 )
- LEFT JOIN sc_collector col ON ( col.id = rd.collector_id AND col.`status` = 1 )
- LEFT JOIN sc_concentrator con ON ( con.id = rd.concentrator_id AND con.`status` = 1 )
- where d.status = 1
- <if test = "param.buildingId != null and param.buildingId != 0">
- and d.building_id = #{param.buildingId}
- </if>
- <if test="param.siteId != null and param.siteId != 0">
- and d.site_id = #{param.siteId}
- </if>
- <if test = "param.channelId != null and param.channelId != 0">
- and d.sys_id = #{param.channelId}
- </if>
- <if test="param.custormerId != null and param.custormerId != 0">
- and d.customer_id = #{param.custormerId}
- </if>
- and (d.id IN (
- SELECT
- tmp.device_id
- FROM
- (
- SELECT
- site_id,
- channel_id,
- building_id,
- device_id
- FROM
- sc_stat_meter_unread_device_by_building_15day
- WHERE
- <if test = "param.statDay != null and param.statDay != 0">
- stat_day = #{param.statDay}
- </if>
- <if test = "param.buildingId != null and param.buildingId != 0">
- AND building_id = #{param.buildingId}
- </if>
- ) tmp
- ) or d.device_status = 5)
- </select>
- <select id="queryDeviceMeterReadRecordWithCondtion" resultType="com.bz.smart_city.entity.MeterReadRecord">
- select
- <include refid="Base_Column_List" />
- from
- sc_meter_read_record
- where read_status = 2
- and device_id = #{param.deviceId}
- <if test = "param.startDate != null and param.startDate != 0"> and read_date >= #{param.startDate}</if>
- <if test = "param.endDate != null and param.endDate != 0"> and read_date <![CDATA[ <= ]]> #{param.endDate}</if>
- order by read_date desc
- </select>
- <select id="getSummary" resultType="com.bz.smart_city.dto.WaterConsumptionSummaryDto">
- select
- ifnull(sum(result.water_consumption), 0) as total_water_consumption,
- count(result.device_id) as total_device_count
- from (
- select
- smrr.device_id as device_id,
- smrr.building_id as building_id,
- ifnull(sum(smrr.last_cost), 0) as water_consumption
- from
- sc_meter_read_record smrr
- where smrr.status = 1
- <if test="param.siteId != null"> and smrr.site_id = #{param.siteId}</if>
- <if test="param.custormerId != null"> and smrr.customer_id = #{param.custormerId} </if>
- <if test="param.buildingIds != null and param.buildingIds.size() != 0">
- and smrr.building_id in <foreach collection="param.buildingIds" item="item" open="(" separator="," close=")"> #{item}</foreach>
- </if>
- <if test="param.startDate != null"> and smrr.read_date <![CDATA[ >= ]]> #{param.startDate} </if>
- <if test="param.endDate != null"> and smrr.read_date <![CDATA[ <= ]]> #{param.endDate} </if>
- group by
- smrr.device_id, smrr.building_id
- ) result
- left join sc_building sb on (result.building_id = sb.id and sb.status = 1)
- <if test="param.programItems != null and param.programItems.size() != 0"> left join sc_device_dimension sdd on (sdd.device_id = result.device_id and sdd.status = 1) </if>
- where 1 = 1
- <if test="param.programItems != null and param.programItems.size() != 0"> and
- <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- <if test="param.provinces != null and param.provinces.size() != 0">
- and sb.province in <foreach collection="param.provinces" item="item" open="(" separator="," close=")"> #{item} </foreach>
- </if>
- <if test="param.cities != null and param.cities.size() != 0">
- and sb.city in <foreach collection="param.cities" item="item" open="(" separator="," close=")"> #{item} </foreach>
- </if>
- <if test="param.regions != null and param.regions.size() != 0">
- and sb.region in <foreach collection="param.regions" item="item" open="(" separator="," close=")"> #{item} </foreach>
- </if>
- <if test="param.communities != null and param.communities.size() != 0">
- and sb.community in <foreach collection="param.communities" item="item" open="(" separator="," close=")"> #{item} </foreach>
- </if>
- <if test="param.beginRate != null"> and result.water_consumption <![CDATA[ >= ]]> #{param.beginRate} </if>
- <if test="param.endRate != null"> and result.water_consumption <![CDATA[ <= ]]> #{param.endRate} </if>
- </select>
- <select id="getList" resultType="com.bz.smart_city.dto.WaterConsumptionDto">
- select
- list.meter_no as meter_no,
- list.device_type as device_type,
- list.customer as customer,
- list.district as district,
- list.community as community,
- list.building as building,
- list.location as location,
- list.water_consumption as water_consumption
- from (
- select
- smrr.meter_no as meter_no,
- sdt.equipment_type as device_type,
- scu.customer_name as customer,
- replace(replace(sa.manger_name, "中国", ""), ",", "") as district,
- sco.name as community,
- sb.name as building,
- smrr.location as location,
- ifnull(sum(smrr.last_cost), 0) as water_consumption
- from
- sc_meter_read_record smrr
- left join sc_device_type sdt on (smrr.device_type_id = sdt.id and sdt.status = 1)
- left join sc_customer scu on (smrr.customer_id = scu.id and scu.status = 1)
- left join sc_building sb on (smrr.building_id = sb.id and sb.status = 1)
- left join sc_area sa on (sa.id = sb.region)
- left join sc_community sco on (sb.community = sco.id and sco.id)
- <if test="param.programItems != null and param.programItems.size() != 0"> left join sc_device_dimension sdd on (sdd.device_id = smrr.device_id and sdd.status = 1) </if>
- where
- smrr.status = 1
- <if test="param.siteId != null"> and smrr.site_id = #{param.siteId} </if>
- <if test="param.programItems != null and param.programItems.size() != 0"> and
- <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- <if test="param.custormerId != null"> and smrr.customer_id = #{param.custormerId} </if>
- <if test="param.provinces != null and param.provinces.size() != 0">
- and sb.province in <foreach collection="param.provinces" item="item" open="(" separator="," close=")"> #{item} </foreach>
- </if>
- <if test="param.cities != null and param.cities.size() != 0">
- and sb.city in <foreach collection="param.cities" item="item" open="(" separator="," close=")"> #{item} </foreach>
- </if>
- <if test="param.regions != null and param.regions.size() != 0">
- and sb.region in <foreach collection="param.regions" item="item" open="(" separator="," close=")"> #{item} </foreach>
- </if>
- <if test="param.communities != null and param.communities.size() != 0">
- and sb.community in <foreach collection="param.communities" item="item" open="(" separator="," close=")"> #{item} </foreach>
- </if>
- <if test="param.buildingIds != null and param.buildingIds.size() != 0">
- and smrr.building_id in <foreach collection="param.buildingIds" item="item" open="(" separator="," close=")"> #{item}</foreach>
- </if>
- <if test="param.startDate != null"> and smrr.read_date <![CDATA[ >= ]]> #{param.startDate} </if>
- <if test="param.endDate != null"> and smrr.read_date <![CDATA[ <= ]]> #{param.endDate} </if>
- group by
- smrr.meter_no, sdt.equipment_type, scu.customer_name, district, sco.name, sb.name, smrr.location
- ) list
- where 1 = 1
- <if test="param.beginRate != null"> and list.water_consumption <![CDATA[ >= ]]> #{param.beginRate} </if>
- <if test="param.endRate != null"> and list.water_consumption <![CDATA[ <= ]]> #{param.endRate} </if>
- <if test="param.sortOrder != null"> order by list.water_consumption ${param.sortOrder} </if>
- </select>
- <select id="getList_COUNT" resultType="Long">
- select
- count(result.device_id)
- from (
- select
- smrr.device_id as device_id,
- smrr.building_id as building_id,
- ifnull(sum(smrr.last_cost), 0) as water_consumption
- from
- sc_meter_read_record smrr
- where smrr.status = 1
- <if test="param.siteId != null"> and smrr.site_id = #{param.siteId}</if>
- <if test="param.custormerId != null"> and smrr.customer_id = #{param.custormerId} </if>
- <if test="param.buildingIds != null and param.buildingIds.size() != 0">
- and smrr.building_id in <foreach collection="param.buildingIds" item="item" open="(" separator="," close=")"> #{item}</foreach>
- </if>
- <if test="param.startDate != null"> and smrr.read_date <![CDATA[ >= ]]> #{param.startDate} </if>
- <if test="param.endDate != null"> and smrr.read_date <![CDATA[ <= ]]> #{param.endDate} </if>
- group by
- smrr.device_id, smrr.building_id
- ) result
- left join sc_building sb on (result.building_id = sb.id and sb.status = 1)
- <if test="param.programItems != null and param.programItems.size() != 0"> left join sc_device_dimension sdd on (sdd.device_id = result.device_id and sdd.status = 1) </if>
- where 1 = 1
- <if test="param.programItems != null and param.programItems.size() != 0"> and
- <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- <if test="param.provinces != null and param.provinces.size() != 0">
- and sb.province in <foreach collection="param.provinces" item="item" open="(" separator="," close=")"> #{item} </foreach>
- </if>
- <if test="param.cities != null and param.cities.size() != 0">
- and sb.city in <foreach collection="param.cities" item="item" open="(" separator="," close=")"> #{item} </foreach>
- </if>
- <if test="param.regions != null and param.regions.size() != 0">
- and sb.region in <foreach collection="param.regions" item="item" open="(" separator="," close=")"> #{item} </foreach>
- </if>
- <if test="param.communities != null and param.communities.size() != 0">
- and sb.community in <foreach collection="param.communities" item="item" open="(" separator="," close=")"> #{item} </foreach>
- </if>
- <if test="param.beginRate != null"> and result.water_consumption <![CDATA[ >= ]]> #{param.beginRate} </if>
- <if test="param.endRate != null"> and result.water_consumption <![CDATA[ <= ]]> #{param.endRate} </if>
- </select>
- <select id="getLastDayData" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from
- sc_meter_read_record
- where
- status = 1 and device_id = #{deviceId} and read_date = #{lastDate}
- </select>
- <select id="getLastDayDataV2" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from
- sc_meter_read_record
- where
- status = 1 and device_id = #{deviceId} and read_date <![CDATA[ < ]]> #{lastDate} order by read_date desc limit 1
- </select>
- <select id="getAllDeviceId" resultType="Long">
- select distinct device_id
- from sc_meter_read_record
- where status = 1 and sys_id = -99
- <if test="startDate != null"> and read_date <![CDATA[ >= ]]> #{startDate} </if>
- order by device_id asc
- </select>
- <select id="getMeterReadRecordByDeviceId" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from sc_meter_read_record
- where status = 1
- <if test="deviceId != null"> and device_id = #{deviceId} </if>
- <if test="startDate != null"> and read_date <![CDATA[ >= ]]> #{startDate} </if>
- order by read_date asc
- </select>
- <update id="batchUpdate" parameterType="list">
- UPDATE sc_meter_read_record
- <trim prefix="set" suffixOverrides=",">
- <trim prefix="last_valid =case" suffix="end,">
- <foreach collection="list" item="item">
- <if test="item.lastValid!=null">
- when id=#{item.id} then #{item.lastValid}
- </if>
- </foreach>
- </trim>
- <trim prefix="last_cost =case" suffix="end,">
- <foreach collection="list" item="item">
- <if test="item.lastCost!=null">
- when id=#{item.id} then #{item.lastCost}
- </if>
- </foreach>
- </trim>
- </trim>
- <where>
- id in <foreach collection="list" item="item" open="(" separator="," close=")">#{item.id}</foreach>
- </where>
- </update>
- <select id="getDeviceIdOnDate" resultType="Long">
- select
- device_id
- from sc_meter_read_record
- where status = 1 and read_date = #{date}
- limit #{limit}
- </select>
- <select id="queryMeterReadData" resultType="com.bz.smart_city.dto.MeterReadDataDTO">
- SELECT
- read_date as meter_read_date,
- device_no,
- meter_no as electronic_no,
- read_data as meter_read_data,
- read_time as meter_read_time
- FROM
- sc_meter_read_record
- WHERE
- read_status = 2
- AND read_date = #{meterReadDate}
- <if test="deviceNo != null and deviceNo != ''">
- and device_no = #{deviceNo}
- </if>
- <if test="electronicNo != null and electronicNo != ''">
- and meter_no = #{electronicNo}
- </if>
- <if test="custId != null">
- and customer_id = #{custId}
- </if>
- </select>
- <update id="updateHitoryData">
- UPDATE sc_meter_read_record
- <set>
- <if test="meterReadRecord.sysId != null"> sys_id= #{meterReadRecord.sysId,jdbcType=INTEGER},</if>
- </set>
- where device_id= #{meterReadRecord.deviceId,jdbcType=BIGINT}
- </update>
- <select id="findSyncMeterRecord" resultMap="BaseResultMap">
- select device_id,meter_file_no,read_data from sc_meter_read_record
- where read_date=#{readTime}
- and device_id in
- <foreach collection="deviceIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </select>
- <select id="findMeterLastReadRecord" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List"></include>
- from
- sc_meter_read_record
- where device_id = #{deviceId,jdbcType=BIGINT}
- and read_status = 2
- and status = 1
- and read_date = ( SELECT max( read_date ) FROM sc_meter_read_record WHERE device_id = #{deviceId,jdbcType=BIGINT} and read_status = 2)
- limit 1
- </select>
- </mapper>
|