12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364 |
- <?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.BuildingMapper">
- <!--auto generated Code-->
- <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.Building">
- <result column="id" property="id" jdbcType="INTEGER"/>
- <result column="site_id" property="siteId" jdbcType="INTEGER"/>
- <result column="name" property="name" jdbcType="VARCHAR"/>
- <result column="address" property="address" jdbcType="VARCHAR"/>
- <result column="contact_penson" property="contactPenson" jdbcType="VARCHAR"/>
- <result column="completion_date" property="completionDate" jdbcType="TIMESTAMP"/>
- <result column="contact_phone" property="contactPhone" jdbcType="VARCHAR"/>
- <result column="access_unit_id" property="accessUnitId" 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="detail_address" property="detailAddress" jdbcType="VARCHAR"/>
- <result column="region_code" property="regionCode" jdbcType="VARCHAR"/>
- <result column="door_no" property="doorNo" jdbcType="VARCHAR"/>
- <result column="road_name" property="roadName" jdbcType="VARCHAR"/>
- <result column="stree_no" property="streeNo" jdbcType="VARCHAR"/>
- <result column="buildl_no" property="buildlNo" jdbcType="VARCHAR"/>
- <result column="longitude" property="longitude" jdbcType="VARCHAR"/>
- <result column="latitude" property="latitude" jdbcType="VARCHAR"/>
- <result column="highly" property="highly" jdbcType="VARCHAR"/>
- <result column="building_area" property="buildingArea" jdbcType="VARCHAR"/>
- <result column="building_category" property="buildingCategory" jdbcType="INTEGER"/>
- <result column="building_structure" property="buildingStructure" jdbcType="INTEGER"/>
- <result column="fire_rating" property="fireRating" jdbcType="INTEGER"/>
- <result column="risk_rating" property="riskRating" jdbcType="INTEGER"/>
- <result column="has_control_roon" property="hasControlRoon" jdbcType="INTEGER"/>
- <result column="control_roon_loc" property="controlRoonLoc" jdbcType="VARCHAR"/>
- <result column="building_usage" property="buildingUsage" jdbcType="INTEGER"/>
- <result column="building_usage_cla" property="buildingUsageCla" jdbcType="VARCHAR"/>
- <result column="rights" property="rights" jdbcType="INTEGER"/>
- <result column="cover_area" property="coverArea" jdbcType="VARCHAR"/>
- <result column="stand_bed_area" property="standBedArea" jdbcType="VARCHAR"/>
- <result column="under_floor_num" property="underFloorNum" jdbcType="INTEGER"/>
- <result column="under_floor_area" property="underFloorArea" jdbcType="VARCHAR"/>
- <result column="floor_num" property="floorNum" jdbcType="INTEGER"/>
- <result column="floor_area" property="floorArea" jdbcType="VARCHAR"/>
- <result column="asylum_floor_num" property="asylumFloorNum" jdbcType="VARCHAR"/>
- <result column="asylum_floor_area" property="asylumFloorArea" jdbcType="VARCHAR"/>
- <result column="asylum_floor_loc" property="asylumFloorLoc" jdbcType="VARCHAR"/>
- <result column="fire_lift_num" property="fireLiftNum" jdbcType="VARCHAR"/>
- <result column="fire_lift_loc" property="fireLiftLoc" jdbcType="VARCHAR"/>
- <result column="check_in_func" property="checkInFunc" jdbcType="VARCHAR"/>
- <result column="max_capacity" property="maxCapacity" jdbcType="VARCHAR"/>
- <result column="has_auto_equipme" property="hasAutoEquipme" jdbcType="INTEGER"/>
- <result column="equipment_status" property="equipmentStatus" jdbcType="VARCHAR"/>
- <result column="equipment_desc" property="equipmentDesc" jdbcType="VARCHAR"/>
- <result column="beside_buildind_desc" property="besideBuildindDesc" jdbcType="VARCHAR"/>
- <result column="geography" property="geography" jdbcType="VARCHAR"/>
- <result column="status" property="status" jdbcType="INTEGER"/>
- <result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
- <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
- <result column="update_date" property="updateDate" jdbcType="TIMESTAMP"/>
- <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
- <result column="community" property="community" jdbcType="VARCHAR"/>
- <result column="unit" property="unit" jdbcType="VARCHAR"/>
- </resultMap>
- <!--auto generated Code-->
- <sql id="Base_Column_List">
- id,
- site_id,
- name,
- address,
- contact_penson,
- completion_date,
- contact_phone,
- access_unit_id,
- province,
- city,
- region,
- detail_address,
- region_code,
- door_no,
- road_name,
- stree_no,
- buildl_no,
- longitude,
- latitude,
- highly,
- building_area,
- building_category,
- building_structure,
- fire_rating,
- risk_rating,
- has_control_roon,
- control_roon_loc,
- building_usage,
- building_usage_cla,
- rights,
- cover_area,
- stand_bed_area,
- under_floor_num,
- under_floor_area,
- floor_num,
- floor_area,
- asylum_floor_num,
- asylum_floor_area,
- asylum_floor_loc,
- fire_lift_num,
- fire_lift_loc,
- check_in_func,
- max_capacity,
- has_auto_equipme,
- equipment_status,
- equipment_desc,
- beside_buildind_desc,
- geography,
- status,
- create_date,
- create_by,
- update_date,
- update_by,
- community,
- unit
- </sql>
- <!--auto generated Code-->
- <insert id="insert" useGeneratedKeys="true" keyProperty="building.id">
- INSERT INTO sc_building (
- id,
- site_id,
- name,
- address,
- contact_penson,
- completion_date,
- contact_phone,
- access_unit_id,
- province,
- city,
- region,
- detail_address,
- region_code,
- door_no,
- road_name,
- stree_no,
- buildl_no,
- longitude,
- latitude,
- highly,
- building_area,
- building_category,
- building_structure,
- fire_rating,
- risk_rating,
- has_control_roon,
- control_roon_loc,
- building_usage,
- building_usage_cla,
- rights,
- cover_area,
- stand_bed_area,
- under_floor_num,
- under_floor_area,
- floor_num,
- floor_area,
- asylum_floor_num,
- asylum_floor_area,
- asylum_floor_loc,
- fire_lift_num,
- fire_lift_loc,
- check_in_func,
- max_capacity,
- has_auto_equipme,
- equipment_status,
- equipment_desc,
- beside_buildind_desc,
- geography,
- status,
- create_date,
- create_by,
- update_date,
- update_by,
- community,
- unit
- ) VALUES (
- #{building.id,jdbcType=INTEGER},
- #{building.siteId,jdbcType=INTEGER},
- #{building.name,jdbcType=VARCHAR},
- #{building.address,jdbcType=VARCHAR},
- #{building.contactPenson,jdbcType=VARCHAR},
- #{building.completionDate,jdbcType=TIMESTAMP},
- #{building.contactPhone,jdbcType=VARCHAR},
- #{building.accessUnitId,jdbcType=INTEGER},
- #{building.province,jdbcType=INTEGER},
- #{building.city,jdbcType=INTEGER},
- #{building.region,jdbcType=INTEGER},
- #{building.detailAddress,jdbcType=VARCHAR},
- #{building.regionCode,jdbcType=VARCHAR},
- #{building.doorNo,jdbcType=VARCHAR},
- #{building.roadName,jdbcType=VARCHAR},
- #{building.streeNo,jdbcType=VARCHAR},
- #{building.buildlNo,jdbcType=VARCHAR},
- #{building.longitude,jdbcType=VARCHAR},
- #{building.latitude,jdbcType=VARCHAR},
- #{building.highly,jdbcType=VARCHAR},
- #{building.buildingArea,jdbcType=VARCHAR},
- #{building.buildingCategory,jdbcType=INTEGER},
- #{building.buildingStructure,jdbcType=INTEGER},
- #{building.fireRating,jdbcType=INTEGER},
- #{building.riskRating,jdbcType=INTEGER},
- #{building.hasControlRoon,jdbcType=INTEGER},
- #{building.controlRoonLoc,jdbcType=VARCHAR},
- #{building.buildingUsage,jdbcType=INTEGER},
- #{building.buildingUsageCla,jdbcType=VARCHAR},
- #{building.rights,jdbcType=INTEGER},
- #{building.coverArea,jdbcType=VARCHAR},
- #{building.standBedArea,jdbcType=VARCHAR},
- #{building.underFloorNum,jdbcType=INTEGER},
- #{building.underFloorArea,jdbcType=VARCHAR},
- #{building.floorNum,jdbcType=INTEGER},
- #{building.floorArea,jdbcType=VARCHAR},
- #{building.asylumFloorNum,jdbcType=VARCHAR},
- #{building.asylumFloorArea,jdbcType=VARCHAR},
- #{building.asylumFloorLoc,jdbcType=VARCHAR},
- #{building.fireLiftNum,jdbcType=VARCHAR},
- #{building.fireLiftLoc,jdbcType=VARCHAR},
- #{building.checkInFunc,jdbcType=VARCHAR},
- #{building.maxCapacity,jdbcType=VARCHAR},
- #{building.hasAutoEquipme,jdbcType=INTEGER},
- #{building.equipmentStatus,jdbcType=VARCHAR},
- #{building.equipmentDesc,jdbcType=VARCHAR},
- #{building.besideBuildindDesc,jdbcType=VARCHAR},
- #{building.geography,jdbcType=VARCHAR},
- #{building.status,jdbcType=INTEGER},
- #{building.createDate,jdbcType=TIMESTAMP},
- #{building.createBy,jdbcType=VARCHAR},
- #{building.updateDate,jdbcType=TIMESTAMP},
- #{building.updateBy,jdbcType=VARCHAR},
- #{building.community,jdbcType=VARCHAR},
- #{building.unit,jdbcType=VARCHAR}
- )
- </insert>
- <!--auto generated Code-->
- <insert id="insertSelective" useGeneratedKeys="true" keyProperty="building.id">
- INSERT INTO sc_building
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="building.id!=null"> id,</if>
- <if test="building.siteId!=null"> site_id,</if>
- <if test="building.name!=null"> name,</if>
- <if test="building.address!=null"> address,</if>
- <if test="building.contactPenson!=null"> contact_penson,</if>
- <if test="building.completionDate!=null"> completion_date,</if>
- <if test="building.contactPhone!=null"> contact_phone,</if>
- <if test="building.accessUnitId!=null"> access_unit_id,</if>
- <if test="building.province!=null"> province,</if>
- <if test="building.city!=null"> city,</if>
- <if test="building.region!=null"> region,</if>
- <if test="building.detailAddress!=null"> detail_address,</if>
- <if test="building.regionCode!=null"> region_code,</if>
- <if test="building.doorNo!=null"> door_no,</if>
- <if test="building.roadName!=null"> road_name,</if>
- <if test="building.streeNo!=null"> stree_no,</if>
- <if test="building.buildlNo!=null"> buildl_no,</if>
- <if test="building.longitude!=null"> longitude,</if>
- <if test="building.latitude!=null"> latitude,</if>
- <if test="building.highly!=null"> highly,</if>
- <if test="building.buildingArea!=null"> building_area,</if>
- <if test="building.buildingCategory!=null"> building_category,</if>
- <if test="building.buildingStructure!=null"> building_structure,</if>
- <if test="building.fireRating!=null"> fire_rating,</if>
- <if test="building.riskRating!=null"> risk_rating,</if>
- <if test="building.hasControlRoon!=null"> has_control_roon,</if>
- <if test="building.controlRoonLoc!=null"> control_roon_loc,</if>
- <if test="building.buildingUsage!=null"> building_usage,</if>
- <if test="building.buildingUsageCla!=null"> building_usage_cla,</if>
- <if test="building.rights!=null"> rights,</if>
- <if test="building.coverArea!=null"> cover_area,</if>
- <if test="building.standBedArea!=null"> stand_bed_area,</if>
- <if test="building.underFloorNum!=null"> under_floor_num,</if>
- <if test="building.underFloorArea!=null"> under_floor_area,</if>
- <if test="building.floorNum!=null"> floor_num,</if>
- <if test="building.floorArea!=null"> floor_area,</if>
- <if test="building.asylumFloorNum!=null"> asylum_floor_num,</if>
- <if test="building.asylumFloorArea!=null"> asylum_floor_area,</if>
- <if test="building.asylumFloorLoc!=null"> asylum_floor_loc,</if>
- <if test="building.fireLiftNum!=null"> fire_lift_num,</if>
- <if test="building.fireLiftLoc!=null"> fire_lift_loc,</if>
- <if test="building.checkInFunc!=null"> check_in_func,</if>
- <if test="building.maxCapacity!=null"> max_capacity,</if>
- <if test="building.hasAutoEquipme!=null"> has_auto_equipme,</if>
- <if test="building.equipmentStatus!=null"> equipment_status,</if>
- <if test="building.equipmentDesc!=null"> equipment_desc,</if>
- <if test="building.besideBuildindDesc!=null"> beside_buildind_desc,</if>
- <if test="building.geography!=null"> geography,</if>
- <if test="building.status!=null"> status,</if>
- <if test="building.createDate!=null"> create_date,</if>
- <if test="building.createBy!=null"> create_by,</if>
- <if test="building.updateDate!=null"> update_date,</if>
- <if test="building.updateBy!=null"> update_by,</if>
- <if test="building.community!=null"> community,</if>
- <if test="building.unit!=null"> unit</if>
- </trim>
- VALUES
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="building.id!=null"> #{building.id,jdbcType=INTEGER},</if>
- <if test="building.siteId!=null"> #{building.siteId,jdbcType=INTEGER},</if>
- <if test="building.name!=null"> #{building.name,jdbcType=VARCHAR},</if>
- <if test="building.address!=null"> #{building.address,jdbcType=VARCHAR},</if>
- <if test="building.contactPenson!=null"> #{building.contactPenson,jdbcType=VARCHAR},</if>
- <if test="building.completionDate!=null"> #{building.completionDate,jdbcType=TIMESTAMP},</if>
- <if test="building.contactPhone!=null"> #{building.contactPhone,jdbcType=VARCHAR},</if>
- <if test="building.accessUnitId!=null"> #{building.accessUnitId,jdbcType=INTEGER},</if>
- <if test="building.province!=null"> #{building.province,jdbcType=INTEGER},</if>
- <if test="building.city!=null"> #{building.city,jdbcType=INTEGER},</if>
- <if test="building.region!=null"> #{building.region,jdbcType=INTEGER},</if>
- <if test="building.detailAddress!=null"> #{building.detailAddress,jdbcType=VARCHAR},</if>
- <if test="building.regionCode!=null"> #{building.regionCode,jdbcType=VARCHAR},</if>
- <if test="building.doorNo!=null"> #{building.doorNo,jdbcType=VARCHAR},</if>
- <if test="building.roadName!=null"> #{building.roadName,jdbcType=VARCHAR},</if>
- <if test="building.streeNo!=null"> #{building.streeNo,jdbcType=VARCHAR},</if>
- <if test="building.buildlNo!=null"> #{building.buildlNo,jdbcType=VARCHAR},</if>
- <if test="building.longitude!=null"> #{building.longitude,jdbcType=VARCHAR},</if>
- <if test="building.latitude!=null"> #{building.latitude,jdbcType=VARCHAR},</if>
- <if test="building.highly!=null"> #{building.highly,jdbcType=VARCHAR},</if>
- <if test="building.buildingArea!=null"> #{building.buildingArea,jdbcType=VARCHAR},</if>
- <if test="building.buildingCategory!=null"> #{building.buildingCategory,jdbcType=INTEGER},</if>
- <if test="building.buildingStructure!=null"> #{building.buildingStructure,jdbcType=INTEGER},</if>
- <if test="building.fireRating!=null"> #{building.fireRating,jdbcType=INTEGER},</if>
- <if test="building.riskRating!=null"> #{building.riskRating,jdbcType=INTEGER},</if>
- <if test="building.hasControlRoon!=null"> #{building.hasControlRoon,jdbcType=INTEGER},</if>
- <if test="building.controlRoonLoc!=null"> #{building.controlRoonLoc,jdbcType=VARCHAR},</if>
- <if test="building.buildingUsage!=null"> #{building.buildingUsage,jdbcType=INTEGER},</if>
- <if test="building.buildingUsageCla!=null"> #{building.buildingUsageCla,jdbcType=VARCHAR},</if>
- <if test="building.rights!=null"> #{building.rights,jdbcType=INTEGER},</if>
- <if test="building.coverArea!=null"> #{building.coverArea,jdbcType=VARCHAR},</if>
- <if test="building.standBedArea!=null"> #{building.standBedArea,jdbcType=VARCHAR},</if>
- <if test="building.underFloorNum!=null"> #{building.underFloorNum,jdbcType=INTEGER},</if>
- <if test="building.underFloorArea!=null"> #{building.underFloorArea,jdbcType=VARCHAR},</if>
- <if test="building.floorNum!=null"> #{building.floorNum,jdbcType=INTEGER},</if>
- <if test="building.floorArea!=null"> #{building.floorArea,jdbcType=VARCHAR},</if>
- <if test="building.asylumFloorNum!=null"> #{building.asylumFloorNum,jdbcType=VARCHAR},</if>
- <if test="building.asylumFloorArea!=null"> #{building.asylumFloorArea,jdbcType=VARCHAR},</if>
- <if test="building.asylumFloorLoc!=null"> #{building.asylumFloorLoc,jdbcType=VARCHAR},</if>
- <if test="building.fireLiftNum!=null"> #{building.fireLiftNum,jdbcType=VARCHAR},</if>
- <if test="building.fireLiftLoc!=null"> #{building.fireLiftLoc,jdbcType=VARCHAR},</if>
- <if test="building.checkInFunc!=null"> #{building.checkInFunc,jdbcType=VARCHAR},</if>
- <if test="building.maxCapacity!=null"> #{building.maxCapacity,jdbcType=VARCHAR},</if>
- <if test="building.hasAutoEquipme!=null"> #{building.hasAutoEquipme,jdbcType=INTEGER},</if>
- <if test="building.equipmentStatus!=null"> #{building.equipmentStatus,jdbcType=VARCHAR},</if>
- <if test="building.equipmentDesc!=null"> #{building.equipmentDesc,jdbcType=VARCHAR},</if>
- <if test="building.besideBuildindDesc!=null"> #{building.besideBuildindDesc,jdbcType=VARCHAR},</if>
- <if test="building.geography!=null"> #{building.geography,jdbcType=VARCHAR},</if>
- <if test="building.status!=null"> #{building.status,jdbcType=INTEGER},</if>
- <if test="building.createDate!=null"> #{building.createDate,jdbcType=TIMESTAMP},</if>
- <if test="building.createBy!=null"> #{building.createBy,jdbcType=VARCHAR},</if>
- <if test="building.updateDate!=null"> #{building.updateDate,jdbcType=TIMESTAMP},</if>
- <if test="building.updateBy!=null"> #{building.updateBy,jdbcType=VARCHAR},</if>
- <if test="building.community!=null"> #{building.community,jdbcType=VARCHAR},</if>
- <if test="building.unit!=null"> #{building.unit,jdbcType=VARCHAR}</if>
- </trim>
- </insert>
- <!--auto generated Code-->
- <insert id="insertList">
- INSERT INTO sc_building(
- id,
- site_id,
- name,
- address,
- contact_penson,
- completion_date,
- contact_phone,
- access_unit_id,
- province,
- city,
- region,
- detail_address,
- region_code,
- door_no,
- road_name,
- stree_no,
- buildl_no,
- longitude,
- latitude,
- highly,
- building_area,
- building_category,
- building_structure,
- fire_rating,
- risk_rating,
- has_control_roon,
- control_roon_loc,
- building_usage,
- building_usage_cla,
- rights,
- cover_area,
- stand_bed_area,
- under_floor_num,
- under_floor_area,
- floor_num,
- floor_area,
- asylum_floor_num,
- asylum_floor_area,
- asylum_floor_loc,
- fire_lift_num,
- fire_lift_loc,
- check_in_func,
- max_capacity,
- has_auto_equipme,
- equipment_status,
- equipment_desc,
- beside_buildind_desc,
- geography,
- status,
- create_date,
- create_by,
- update_date,
- update_by,
- community,
- unit
- )VALUES
- <foreach collection="buildings" item="building" index="index" separator=",">
- (
- #{building.id,jdbcType=INTEGER},
- #{building.siteId,jdbcType=INTEGER},
- #{building.name,jdbcType=VARCHAR},
- #{building.address,jdbcType=VARCHAR},
- #{building.contactPenson,jdbcType=VARCHAR},
- #{building.completionDate,jdbcType=TIMESTAMP},
- #{building.contactPhone,jdbcType=VARCHAR},
- #{building.accessUnitId,jdbcType=INTEGER},
- #{building.province,jdbcType=INTEGER},
- #{building.city,jdbcType=INTEGER},
- #{building.region,jdbcType=INTEGER},
- #{building.detailAddress,jdbcType=VARCHAR},
- #{building.regionCode,jdbcType=VARCHAR},
- #{building.doorNo,jdbcType=VARCHAR},
- #{building.roadName,jdbcType=VARCHAR},
- #{building.streeNo,jdbcType=VARCHAR},
- #{building.buildlNo,jdbcType=VARCHAR},
- #{building.longitude,jdbcType=VARCHAR},
- #{building.latitude,jdbcType=VARCHAR},
- #{building.highly,jdbcType=VARCHAR},
- #{building.buildingArea,jdbcType=VARCHAR},
- #{building.buildingCategory,jdbcType=INTEGER},
- #{building.buildingStructure,jdbcType=INTEGER},
- #{building.fireRating,jdbcType=INTEGER},
- #{building.riskRating,jdbcType=INTEGER},
- #{building.hasControlRoon,jdbcType=INTEGER},
- #{building.controlRoonLoc,jdbcType=VARCHAR},
- #{building.buildingUsage,jdbcType=INTEGER},
- #{building.buildingUsageCla,jdbcType=VARCHAR},
- #{building.rights,jdbcType=INTEGER},
- #{building.coverArea,jdbcType=VARCHAR},
- #{building.standBedArea,jdbcType=VARCHAR},
- #{building.underFloorNum,jdbcType=INTEGER},
- #{building.underFloorArea,jdbcType=VARCHAR},
- #{building.floorNum,jdbcType=INTEGER},
- #{building.floorArea,jdbcType=VARCHAR},
- #{building.asylumFloorNum,jdbcType=VARCHAR},
- #{building.asylumFloorArea,jdbcType=VARCHAR},
- #{building.asylumFloorLoc,jdbcType=VARCHAR},
- #{building.fireLiftNum,jdbcType=VARCHAR},
- #{building.fireLiftLoc,jdbcType=VARCHAR},
- #{building.checkInFunc,jdbcType=VARCHAR},
- #{building.maxCapacity,jdbcType=VARCHAR},
- #{building.hasAutoEquipme,jdbcType=INTEGER},
- #{building.equipmentStatus,jdbcType=VARCHAR},
- #{building.equipmentDesc,jdbcType=VARCHAR},
- #{building.besideBuildindDesc,jdbcType=VARCHAR},
- #{building.geography,jdbcType=VARCHAR},
- #{building.status,jdbcType=INTEGER},
- #{building.createDate,jdbcType=TIMESTAMP},
- #{building.createBy,jdbcType=VARCHAR},
- #{building.updateDate,jdbcType=TIMESTAMP},
- #{building.updateBy,jdbcType=VARCHAR},
- #{building.community,jdbcType=VARCHAR},
- #{building.unit,jdbcType=VARCHAR}
- )
- </foreach>
- </insert>
- <!--auto generated Code-->
- <update id="updateByPrimaryKeySelective">
- UPDATE sc_building
- <set>
- <if test="building.id != null"> id = #{building.id,jdbcType=INTEGER},</if>
- <if test="building.siteId != null"> site_id = #{building.siteId,jdbcType=INTEGER},</if>
- <if test="building.name != null"> name = #{building.name,jdbcType=VARCHAR},</if>
- <if test="building.address != null"> address = #{building.address,jdbcType=VARCHAR},</if>
- <if test="building.contactPenson != null"> contact_penson = #{building.contactPenson,jdbcType=VARCHAR},</if>
- <if test="building.completionDate != null"> completion_date = #{building.completionDate,jdbcType=TIMESTAMP},</if>
- <if test="building.contactPhone != null"> contact_phone = #{building.contactPhone,jdbcType=VARCHAR},</if>
- <if test="building.accessUnitId != null"> access_unit_id = #{building.accessUnitId,jdbcType=INTEGER},</if>
- <if test="building.province != null"> province = #{building.province,jdbcType=INTEGER},</if>
- <if test="building.city != null"> city = #{building.city,jdbcType=INTEGER},</if>
- <if test="building.region != null"> region = #{building.region,jdbcType=INTEGER},</if>
- <if test="building.detailAddress != null"> detail_address = #{building.detailAddress,jdbcType=VARCHAR},</if>
- <if test="building.regionCode != null"> region_code = #{building.regionCode,jdbcType=VARCHAR},</if>
- <if test="building.doorNo != null"> door_no = #{building.doorNo,jdbcType=VARCHAR},</if>
- <if test="building.roadName != null"> road_name = #{building.roadName,jdbcType=VARCHAR},</if>
- <if test="building.streeNo != null"> stree_no = #{building.streeNo,jdbcType=VARCHAR},</if>
- <if test="building.buildlNo != null"> buildl_no = #{building.buildlNo,jdbcType=VARCHAR},</if>
- <if test="building.longitude != null"> longitude = #{building.longitude,jdbcType=VARCHAR},</if>
- <if test="building.latitude != null"> latitude = #{building.latitude,jdbcType=VARCHAR},</if>
- <if test="building.highly != null"> highly = #{building.highly,jdbcType=VARCHAR},</if>
- <if test="building.buildingArea != null"> building_area = #{building.buildingArea,jdbcType=VARCHAR},</if>
- <if test="building.buildingCategory != null"> building_category = #{building.buildingCategory,jdbcType=INTEGER},</if>
- <if test="building.buildingStructure != null"> building_structure = #{building.buildingStructure,jdbcType=INTEGER},</if>
- <if test="building.fireRating != null"> fire_rating = #{building.fireRating,jdbcType=INTEGER},</if>
- <if test="building.riskRating != null"> risk_rating = #{building.riskRating,jdbcType=INTEGER},</if>
- <if test="building.hasControlRoon != null"> has_control_roon = #{building.hasControlRoon,jdbcType=INTEGER},</if>
- <if test="building.controlRoonLoc != null"> control_roon_loc = #{building.controlRoonLoc,jdbcType=VARCHAR},</if>
- <if test="building.buildingUsage != null"> building_usage = #{building.buildingUsage,jdbcType=INTEGER},</if>
- <if test="building.buildingUsageCla != null"> building_usage_cla = #{building.buildingUsageCla,jdbcType=VARCHAR},</if>
- <if test="building.rights != null"> rights = #{building.rights,jdbcType=INTEGER},</if>
- <if test="building.coverArea != null"> cover_area = #{building.coverArea,jdbcType=VARCHAR},</if>
- <if test="building.standBedArea != null"> stand_bed_area = #{building.standBedArea,jdbcType=VARCHAR},</if>
- <if test="building.underFloorNum != null"> under_floor_num = #{building.underFloorNum,jdbcType=INTEGER},</if>
- <if test="building.underFloorArea != null"> under_floor_area = #{building.underFloorArea,jdbcType=VARCHAR},</if>
- <if test="building.floorNum != null"> floor_num = #{building.floorNum,jdbcType=INTEGER},</if>
- <if test="building.floorArea != null"> floor_area = #{building.floorArea,jdbcType=VARCHAR},</if>
- <if test="building.asylumFloorNum != null"> asylum_floor_num = #{building.asylumFloorNum,jdbcType=VARCHAR},</if>
- <if test="building.asylumFloorArea != null"> asylum_floor_area = #{building.asylumFloorArea,jdbcType=VARCHAR},</if>
- <if test="building.asylumFloorLoc != null"> asylum_floor_loc = #{building.asylumFloorLoc,jdbcType=VARCHAR},</if>
- <if test="building.fireLiftNum != null"> fire_lift_num = #{building.fireLiftNum,jdbcType=VARCHAR},</if>
- <if test="building.fireLiftLoc != null"> fire_lift_loc = #{building.fireLiftLoc,jdbcType=VARCHAR},</if>
- <if test="building.checkInFunc != null"> check_in_func = #{building.checkInFunc,jdbcType=VARCHAR},</if>
- <if test="building.maxCapacity != null"> max_capacity = #{building.maxCapacity,jdbcType=VARCHAR},</if>
- <if test="building.hasAutoEquipme != null"> has_auto_equipme = #{building.hasAutoEquipme,jdbcType=INTEGER},</if>
- <if test="building.equipmentStatus != null"> equipment_status = #{building.equipmentStatus,jdbcType=VARCHAR},</if>
- <if test="building.equipmentDesc != null"> equipment_desc = #{building.equipmentDesc,jdbcType=VARCHAR},</if>
- <if test="building.besideBuildindDesc != null"> beside_buildind_desc = #{building.besideBuildindDesc,jdbcType=VARCHAR},</if>
- <if test="building.geography != null"> geography = #{building.geography,jdbcType=VARCHAR},</if>
- <if test="building.status != null"> status = #{building.status,jdbcType=INTEGER},</if>
- <if test="building.createDate != null"> create_date = #{building.createDate,jdbcType=TIMESTAMP},</if>
- <if test="building.createBy != null"> create_by = #{building.createBy,jdbcType=VARCHAR},</if>
- <if test="building.updateDate != null"> update_date = #{building.updateDate,jdbcType=TIMESTAMP},</if>
- <if test="building.updateBy != null"> update_by = #{building.updateBy,jdbcType=VARCHAR},</if>
- <if test="building.community != null"> community = #{building.community,jdbcType=VARCHAR},</if>
- <if test="building.unit != null"> unit = #{building.unit,jdbcType=VARCHAR}</if>
- </set>
- WHERE id = #{building.id,jdbcType=INTEGER}
- </update>
- <!--auto generated by codehelper on 2018-12-18-->
- <select id="findBySiteId" resultMap="BaseResultMap">
- select
- sb.id,sb.name,sb.province,sb.city,sb.region,sb.community
- from sc_building sb
- left join sc_community sc on(sc.id = sb.community)
- where sb.status = 1
- <if test="siteId != null"> and sb.site_id=#{siteId} </if>
- <if test="sysId != null">
- and sb.id in( SELECT sc_device.building_id FROM sc_device WHERE sc_device.status = 1 <if test="siteId != null"> and sc_device.site_id=#{siteId} </if> and sc_device.sys_id = #{sysId} GROUP BY sc_device.building_id)
- </if>
- <if test="customerIds != null and customerIds.size() != 0">
- and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- </select>
- <select id="findBySiteIdAndCustomerIds" resultMap="BaseResultMap">
- select
- b.id,
- b.name,
- b.province,
- b.city,
- b.region,
- b.community
- from sc_building b
- left join sc_community c on(c.id = b.community)
- where b.status = 1
- <if test="siteId != null"> and b.site_id=#{siteId} </if>
- <if test="sysId != null">
- and b.id in( SELECT sc_device.building_id FROM sc_device WHERE sc_device.status = 1 <if test="siteId != null"> and sc_device.site_id=#{siteId} </if> and sc_device.sys_id = #{sysId} GROUP BY sc_device.building_id)
- </if>
- <if test="customerIds != null and customerIds.size() != 0">
- and c.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- </select>
- <select id="findBySiteIdAndProgramItem" resultMap="BaseResultMap">
- select
- sb.id,sb.name,sb.province,sb.city,sb.region,sb.community,sb.longitude,sb.latitude
- from sc_building sb
- left join sc_community sc on(sc.id = sb.community)
- where sb.status = 1
- <if test="siteId != null"> and sb.site_id=#{siteId} </if>
- <if test="customerId != null"> and sc.customer_id=#{customerId} </if>
- <if test="buildingIds != null and buildingIds.size() != 0"> and sb.id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
- <if test="sysId != null"> and sb.id in (select sd.building_id from sc_device sd where sd.status = 1 and sd.sys_id = #{sysId} <if test="siteId != null"> and sd.site_id=#{siteId} </if> group by sd.building_id) </if>
- <if test="buildingName != null and buildingName != ''"> AND sb.name LIKE concat('%',#{buildingName},'%')</if>
- <if test="customerIds != null and customerIds.size() != 0">
- and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- order by sb.name asc
- </select>
- <select id="findBuildingCountDeviceNum" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
- select
- sb.id,
- sb.name,
- sb.province,
- sb.city,
- sb.region,
- sb.community,
- sb.longitude,
- sb.latitude,
- (
- SELECT count(1) FROM sc_device sd
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
- WHERE sd.status = 1 and sd.building_id=sb.id and sd.sys_id != -99
- <if test="siteId != null"> and sd.site_id=#{siteId} </if>
- <if test="sysId != null"> and sd.sys_id=#{sysId} </if>
- <if test="deviceNo != null and deviceNo != ''"> AND sd.device_no LIKE concat('%',#{deviceNo},'%')</if>
- <if test="deviceTypeId != null"> AND sd.device_type = #{deviceTypeId} </if>
- <if test="locDesc != null and locDesc != ''"> AND sd.loc_desc LIKE concat('%',#{locDesc},'%')</if>
- <if test="deviceStatus != null">and sd.device_status = #{deviceStatus} </if>
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- ) as device_count
- from sc_building sb
- where sb.status = 1
- <if test="siteId != null"> and sb.site_id=#{siteId} </if>
- <if test="region != null"> and sb.region = #{region} </if>
- <if test="communityId != null"> and sb.community = #{communityId} </if>
- </select>
- <select id="findBuildingCountErrorNum" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
- select
- sb.id,
- sb.name,
- sb.province,
- sb.city,
- sb.region,
- sb.community,
- sb.longitude,
- sb.latitude,
- (
- SELECT count(1) FROM sc_device_error sde
- left join sc_device sd on sd.id = sde.device_id and sd.status = 1
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sde.device_id and sdd.status = 1)</if>
- WHERE sde.status = 1 and sde.building_id=sb.id
- <if test="siteId != null"> and sde.site_id=#{siteId} </if>
- <if test="sysId != null"> and sde.sys_id=#{sysId} </if>
- <if test="deviceNo != null and deviceNo != ''"> AND sde.device_no LIKE concat('%',#{deviceNo},'%')</if>
- <if test="alarmCategory != null"> AND sde.alarm_category = #{alarmCategory} </if>
- <if test="handleStatus != null"> AND sde.handle_status = #{handleStatus} </if>
- <if test="deviceTypeId != null"> AND sd.device_type = #{deviceTypeId} </if>
- <if test="location != null and location != ''"> and sde.location LIKE concat('%',#{location},'%')</if>
- <if test="startDate != null"> and sde.alarm_time <![CDATA[ >= ]]> #{startDate}</if>
- <if test="endDate != null"> and sde.alarm_time <![CDATA[ <= ]]> #{endDate}</if>
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- ) as device_count
- from sc_building sb
- where sb.status = 1
- <if test="siteId != null"> and sb.site_id=#{siteId} </if>
- <if test="region != null"> and sb.region=#{region} </if>
- <if test="communityId != null"> and sb.community=#{communityId} </if>
- </select>
- <select id="findBuildingCountError" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
- select
- sb.id,
- sb.name,
- sb.province,
- sb.city,
- sb.region,
- sb.community,
- sb.longitude,
- sb.latitude
- from sc_building sb
- where sb.status = 1
- <if test="siteId != null"> and sb.site_id=#{siteId} </if>
- <if test="region != null"> and sb.region=#{region} </if>
- <if test="communityId != null"> and sb.community=#{communityId} </if>
- </select>
- <select id="findBySiteIdAndName" resultType="com.bz.smart_city.dto.BuildingInfoDto">
- select
- sb.id as building_id,
- sb.name as building_name,
- sb.longitude,
- sb.latitude,
- (SELECT count(1) from sc_device WHERE `status`=1 and building_id = sb.id AND device_status = 2 <if test="sysId != null"> and sys_id = #{sysId}</if>) as alarm_count,
- (SELECT count(1) from sc_device WHERE `status`=1 and building_id = sb.id AND device_status = 3 <if test="sysId != null"> and sys_id = #{sysId}</if>) as fault_count,
- (SELECT count(1) from sc_device WHERE `status`=1 and building_id = sb.id AND device_status = 1 <if test="sysId != null"> and sys_id = #{sysId}</if>) as normal_count,
- (SELECT count(1) from sc_device WHERE `status`=1 and building_id = sb.id AND device_status = 5 <if test="sysId != null"> and sys_id = #{sysId}</if>) as device_unused_count,
- (SELECT count(1) from sc_device WHERE `status`=1 and building_id = sb.id <if test="sysId != null"> and sys_id = #{sysId}</if>) as device_count,
- sb.status
- from sc_building sb
- where status = 1
- and sb.id in(
- SELECT sd.building_id FROM sc_device sd
- WHERE sd.status = 1
- <if test="sysId != null"> and sd.sys_id = #{sysId}</if>
- <if test="siteId != null"> and sd.site_id = #{siteId}</if>
- GROUP BY sd.building_id
- )
- <if test="siteId != null"> and sb.site_id=#{siteId} </if>
- <if test="buildingId != null"> and sb.id=#{buildingId} </if>
- <if test="buildingName != null and buildingName != ''"> AND name LIKE concat('%',#{buildingName},'%')</if>
- </select>
- <select id="getBuildingList" resultType="com.bz.smart_city.dto.BuildingInfoListDto">
- select
- sb.id as building_id,
- sb.name as building_name,
- sb.address ,
- sau.fire_resp_name,
- sau.fire_resp_phone,
- sb.province,
- sb.city,
- sb.region,
- sb.community,
- sa1.name as province_name,
- sa2.name as city_name,
- sa3.name as region_name,
- sc.name as community_name,
- sb.latitude,
- sb.longitude,
- temp.device_count,
- temp.normal_count,
- temp.alarm_count,
- temp.fault_count,
- temp.offline_count,
- temp.device_unused_count
- from sc_building sb
- LEFT JOIN(
- SELECT
- sd.building_id,
- <if test="sysId != null">sd.sys_id,</if>
- count(1) as device_count,
- SUM(IF(sd.device_status = 1, 1, 0)) as normal_count,
- SUM(IF(sd.device_status = 2, 1, 0)) as alarm_count,
- SUM(IF(sd.device_status = 3, 1, 0)) as fault_count,
- SUM(IF(sd.device_status = 4, 1, 0)) as offline_count,
- SUM(IF(sd.device_status = 5, 1, 0)) as device_unused_count
- from sc_device sd
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
- WHERE sd.status = 1 and sd.sys_id != -99
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- GROUP BY sd.building_id <if test="sysId != null">,sd.sys_id</if>
- ) temp on (sb.id = temp.building_id)
- left join sc_access_unit sau on sau.id = sb.access_unit_id and sau.status = 1
- left join sc_area sa1 on sa1.id = sb.province
- left join sc_area sa2 on sa2.id = sb.city
- left join sc_area sa3 on sa3.id = sb.region
- left join sc_community sc on sc.id = sb.community
- where sb.status = 1
- <if test="siteId != null"> and sb.site_id = #{siteId}</if>
- <if test="sysId != null"> and temp.sys_id = #{sysId} </if>
- <if test="buildingName != null and buildingName != ''"> AND sb.name LIKE concat('%',#{buildingName},'%')</if>
- <if test="province != null"> AND sb.province = #{province}</if>
- <if test="city != null"> AND sb.city = #{city}</if>
- <if test="region != null"> AND sb.region = #{region}</if>
- <if test="community != null"> AND sb.community = #{community}</if>
- <if test="customerIds != null and customerIds.size() != 0">
- and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- order by sb.create_date desc
- </select>
- <!--自定义设备列表分页-->
- <!--<select id="getBuildingList_COUNT" resultType="Long">
- select
- count(1)
- from sc_building sb
- where sb.status = 1
- <if test="siteId != null"> and sb.site_id = #{siteId}</if>
- <if test="sysId != null"> and sb.id in(
- SELECT sd.building_id FROM sc_device sd
- WHERE sd.status = 1
- <if test="sysId != null"> and sd.sys_id = #{sysId}</if>
- <if test="siteId != null"> and sd.site_id = #{siteId}</if>
- <if test="buildingIds != null and buildingIds.size() != 0"> and sd.building_id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
- GROUP BY sd.building_id
- )</if>
- <if test="buildingName != null and buildingName != ''"> AND sb.name LIKE concat('%',#{buildingName},'%')</if>
- <if test="province != null"> AND sb.province = #{province}</if>
- <if test="city != null"> AND sb.city = #{city}</if>
- <if test="region != null"> AND sb.region = #{region}</if>
- </select>-->
- <select id="getBuildingListV2" resultType="com.bz.smart_city.dto.BuildingInfoListDto">
- select
- sb.id as building_id,
- sb.name as building_name,
- sb.address ,
- sau.fire_resp_name,
- sau.fire_resp_phone,
- sb.province,
- sb.city,
- sb.region,
- sb.community,
- sa1.name as province_name,
- sa2.name as city_name,
- sa3.name as region_name,
- sc.name as community_name,
- sb.latitude,
- sb.longitude,
- IFNULL((SELECT 1 as device_count
- from sc_device sd
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
- WHERE sd.status = 1 and sd.building_id = sb.id
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- limit 1),0) as device_count
- from sc_building sb
- left join sc_access_unit sau on sau.id = sb.access_unit_id and sau.status = 1
- left join sc_area sa1 on sa1.id = sb.province
- left join sc_area sa2 on sa2.id = sb.city
- left join sc_area sa3 on sa3.id = sb.region
- left join sc_community sc on sc.id = sb.community
- where sb.status = 1
- <if test="siteId != null"> and sb.site_id = #{siteId}</if>
- <if test="sysId != null"> and temp.sys_id = #{sysId} </if>
- <if test="buildingName != null and buildingName != ''"> AND sb.name LIKE concat('%',#{buildingName},'%')</if>
- <if test="province != null"> AND sb.province = #{province}</if>
- <if test="city != null"> AND sb.city = #{city}</if>
- <if test="region != null"> AND sb.region = #{region}</if>
- <if test="community != null"> AND sb.community = #{community}</if>
- <if test="customerIds != null and customerIds.size() != 0">
- and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- order by sb.create_date desc,sb.id desc
- </select>
- <select id="queryFloor" resultType="com.bz.smart_city.dto.FloorDto">
- select
- sbf.floor_no as floor,
- (select count(1) from sc_device sd where sd.status = 1 and sd.building_id = sbf.building and sd.floor = sbf.floor_no
- <if test="sysId != null"> and sd.sys_id=#{sysId} </if>
- and (sd.device_status = 2 or sd.device_status = 3)) as abnormal_count
- from sc_building_floor sbf
- where sbf.status = 1 and sbf.building = #{buildingId} order by sbf.floor_no desc
- </select>
- <select id="deleteQuery" resultType="int">
- select count(1) from sc_device where status = 1 and building_id = #{buildingId}
- </select>
- <select id="getBuilding" resultType="com.bz.smart_city.dto.BuildingDto">
- select
- sb.*,
- sau.name as access_unit_name,
- sa1.name as province_name,
- sa2.name as city_name,
- sa3.name as region_name,
- sc.name as community_name
- from sc_building sb
- left join sc_access_unit sau on (sau.id = sb.access_unit_id and sau.status = 1)
- left join sc_area sa1 on (sa1.id = sb.province)
- left join sc_area sa2 on (sa2.id = sb.city)
- left join sc_area sa3 on (sa3.id = sb.region)
- left join sc_community sc on (sc.id = sb.community)
- where sb.status = 1 and sb.id = #{buildingId}
- </select>
- <update id="deleteBySiteId">
- update sc_building set status = 0,update_date=now(),update_by=#{updateBy} where status = 1 and site_id = #{siteId}
- </update>
- <select id="getBuildingBySiteId" resultType="com.bz.smart_city.dto.BuildingDto">
- select
- b.id as id,
- b.`name` as name,
- b.province as province,
- p.short_name as province_name,
- b.city as city,
- c.short_name as city_name,
- b.region as region,
- r.short_name as region_name
- from sc_building b 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 = c.id)
- where site_id = #{siteId};
- </select>
- <select id="queryTest1" resultType = "com.bz.smart_city.dto.Test">
- select * from sc_building_import where status = '1' ;
- </select>
- <update id="updateTest1">
- update sc_building_import set lat = #{param.lat,jdbcType=VARCHAR},
- lng = #{param.lng,jdbcType=VARCHAR},
- status = #{param.status,jdbcType=VARCHAR}
- where 1 = 1
- and building = #{param.building,jdbcType=VARCHAR}
- and community = #{param.community,jdbcType=VARCHAR}
- </update>
- <select id="queryTest2" resultType = "com.bz.smart_city.dto.Test">
- select * from t2_test where 1 = 1
- <if test="name != null and name != '' ">
- and name like #{name,jdbcType=VARCHAR}
- </if>
- </select>
- <update id="updateTest2">
- update t2_test set address = #{param.address,jdbcType=VARCHAR},
- province = #{param.province,jdbcType=VARCHAR},
- city = #{param.city,jdbcType=VARCHAR},
- region = #{param.region,jdbcType=VARCHAR},
- lat = #{param.lat,jdbcType=VARCHAR},
- lag = #{param.lag,jdbcType=VARCHAR}
- where name = #{param.name,jdbcType=VARCHAR}
- </update>
- <select id="findByBuildingName" resultMap="BaseResultMap">
- select * from sc_building where status = 1 and name = #{buildingName}
- </select>
- <select id="getBuildingStatistics" resultType="com.bz.smart_city.dto.BuildingInfoListDto">
- select
- sb.id as building_id,
- sb.name as building_name,
- sb.address ,
- sb.province,
- sb.city,
- sb.region,
- sb.community,
- sa1.name as province_name,
- sa2.name as city_name,
- sa3.name as region_name,
- sc.name as community_name,
- sb.latitude,
- sb.longitude,
- temp.device_count,
- temp.normal_count,
- temp.alarm_count,
- temp.fault_count,
- temp.offline_count,
- temp.device_unused_count
- from sc_building sb
- LEFT JOIN(
- SELECT
- sd.building_id,
- <if test="sysId != null">sd.sys_id,</if>
- count(1) as device_count,
- SUM(IF(sd.device_status = 1, 1, 0)) as normal_count,
- SUM(IF(sd.device_status = 2, 1, 0)) as alarm_count,
- SUM(IF(sd.device_status = 3, 1, 0)) as fault_count,
- SUM(IF(sd.device_status = 4, 1, 0)) as offline_count,
- SUM(IF(sd.device_status = 5, 1, 0)) as device_unused_count
- from sc_device sd
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
- WHERE sd.status = 1 and sd.sys_id != -99
- <if test="siteList != null and siteList.size() != 0"> and sd.site_id in <foreach collection="siteList" item="item" open="(" separator="," close=")">#{item}</foreach></if>
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- GROUP BY sd.building_id <if test="sysId != null">,sd.sys_id</if>
- ) temp on (sb.id = temp.building_id)
- left join sc_area sa1 on sa1.id = sb.province
- left join sc_area sa2 on sa2.id = sb.city
- left join sc_area sa3 on sa3.id = sb.region
- left join sc_community sc on sc.id = sb.community
- where sb.status = 1
- <if test="sysId != null"> and temp.sys_id = #{sysId} </if>
- <if test="siteList != null and siteList.size() != 0"> and sb.site_id in <foreach collection="siteList" item="item" open="(" separator="," close=")">#{item}</foreach></if>
- <if test="buildingId != null"> and sb.id = #{buildingId} </if>
- <if test="buildingName != null and buildingName != ''"> AND sb.name LIKE concat('%',#{buildingName},'%')</if>
- <if test="province != null"> AND sb.province = #{province}</if>
- <if test="city != null"> AND sb.city = #{city}</if>
- <if test="region != null"> AND sb.region = #{region}</if>
- <if test="community != null"> AND sb.community = #{community}</if>
- <if test="type != null and (type == 4 or type == 5) and longitudeMin != 0 and longitudeMax != 0"> and sb.longitude > #{longitudeMin} AND sb.longitude <![CDATA[ < ]]> #{longitudeMax} </if>
- <if test="type != null and (type == 4 or type == 5) and latitudeMin != 0 and latitudeMax != 0"> and sb.latitude > #{latitudeMin} AND sb.latitude <![CDATA[ < ]]> #{latitudeMax} </if>
- <if test="customerIds != null and customerIds.size() != 0">
- and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- order by sb.update_date desc
- </select>
- <select id="getList" resultType="com.bz.smart_city.dto.BuildingDto">
- select
- sb.id,
- sb.name,
- sb.address,
- sb.province,
- sb.city,
- sb.region,
- sb.community,
- sb.longitude,
- sb.latitude,
- sa1.name as province_name,
- sa2.name as city_name,
- sa3.name as region_name,
- sc.name as community_name
- from sc_building sb
- left join sc_area sa1 on sb.province =sa1.id
- left join sc_area sa2 on sb.city=sa2.id
- left join sc_area sa3 on sb.region=sa3.id
- left join sc_community sc on sc.id=sb.community
- where sb.status = 1
- <if test="siteId != null"> and sb.site_id =#{siteId} </if>
- <if test="buildingName != null and buildingName != ''"> AND sb.name LIKE concat('%',#{buildingName},'%')</if>
- <if test="customerIds != null and customerIds.size() != 0">
- and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- </select>
- <select id="getBuildingByDeviceId" resultMap="BaseResultMap">
- select
- sb.*,
- sau.name as access_unit_name,
- sa1.name as province_name,
- sa2.name as city_name,
- sa3.name as region_name
- from sc_building sb
- left join sc_access_unit sau on (sau.id = sb.access_unit_id and sau.status = 1)
- left join sc_area sa1 on (sa1.id = sb.province)
- left join sc_area sa2 on (sa2.id = sb.city)
- left join sc_area sa3 on (sa3.id = sb.region)
- where sb.status = 1 and sb.id in (select sd.building_id from sc_device sd where sd.status = 1 and sd.id = #{deviceId} group by sd.building_id ) limit 1
- </select>
- <select id="getIdsByDataPermission" resultType="java.lang.Integer">
- select c.id
- from
- sc_building c
- where c.status = 1
- <if test="siteList != null and siteList.size() != 0"> and c.site_id in <foreach collection="siteList" item="item" open="(" separator="," close=")">#{item}</foreach></if>
- <if test="programItems != null and programItems.size() != 0">
- and <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- <if test = 'item.dimensionCode == "PROVINCE" '>
- c.province = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "CITY" '>
- c.city = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "REGION" '>
- c.region = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "COMMUNITY" '>
- c.community = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "BUILDING" '>
- c.id = #{item.dimensionValue}
- </if>
- <if test = 'item.dimensionCode == "CUSTOMER" '>
- c.id = -1
- </if>
- </foreach>
- </if>
- </select>
- <select id="findByName" resultMap="BaseResultMap">
- select <include refid="Base_Column_List"></include> from sc_building where status = 1 and site_id = #{siteId} and name = #{buildingName}
- </select>
- <select id="findByNameV2" resultMap="BaseResultMap">
- select <include refid="Base_Column_List"></include> from sc_building where status = 1 and site_id = #{siteId} and name = #{buildingName} <if test="communityId != null"> and community = #{communityId}</if>
- </select>
- <select id="findByIds" resultType="com.bz.smart_city.entity.Building">
- select <include refid="Base_Column_List"></include> from sc_building where status = 1
- and id in <foreach collection="ids" item="item" open="(" separator="," close=")">#{item}</foreach>
- </select>
- <select id="deviceCountAreaList" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
- select
- b.id,
- b.name,
- b.province,
- b.city,
- b.region,
- b.community,
- b.longitude,
- b.latitude,
- t1.device_count
- from sc_building b
- right join (
- select sd.building_id,count(1) as device_count
- from sc_device sd
- <if test=" (valveStatus != null)">left join sc_device_type sdt on (sdt.id = sd.device_type and sdt.status = 1)</if>
- <if test="province != null or city != null or region != null or community != null">left join sc_building sb on (sb.id = sd.building_id and sb.status = 1)</if>
- <if test="concentratorId != null or collectorId != null or channelNumberId != null or (concentratorNo != null and concentratorNo != '') or (collectorNo != null and collectorNo != '') or issueStatus != null">left join sc_water_related_device swrd on ( swrd.device_id = sd.id and swrd.status = 1)</if>
- <if test="concentratorNo != null and concentratorNo != ''">left join sc_concentrator scon on ( scon.id = swrd.concentrator_id and scon.status = 1)</if>
- <if test="collectorNo != null and collectorNo != ''">left join sc_collector scol on ( scol.id = swrd.collector_id)</if>
- <if test="(errorType != null and errorType != '') or days != null or (valveStatus != null) or startReading != null or endReading != null">left join sc_water_meter_error_days swmed on ( swmed.device_id = sd.id)</if>
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
- where sd.status = 1 and sys_id <![CDATA[ <> ]]> -99
- <!--and sd.site_id = 1-->
- <if test="sysId != null"> AND sd.sys_id = #{sysId}</if>
- <if test="buildingId != null"> AND sd.building_id = #{buildingId}</if>
- <if test="siteId != null"> AND sd.site_id = #{siteId}</if>
- <if test="deviceNo != null and deviceNo != ''"> AND (sd.device_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_file_no LIKE concat('%',#{deviceNo},'%'))</if>
- <if test="status != null"> AND sd.device_status = #{status}</if>
- <if test="deviceTypeId != null"> AND sd.device_type = #{deviceTypeId}</if>
- <if test="floor != null"> AND sd.floor = #{floor}</if>
- <if test="locDesc != null and locDesc != ''"> AND sd.loc_desc LIKE concat('%',#{locDesc},'%')</if>
- <if test="province != null"> and sb.province = #{province}</if>
- <if test="city != null"> and sb.city = #{city}</if>
- <if test="region != null"> and sb.region = #{region}</if>
- <if test="community != null"> and sb.community = #{community}</if>
- <if test="concentratorId != null"> and swrd.concentrator_id = #{concentratorId}</if>
- <if test="concentratorNo != null and concentratorNo != ''"> AND scon.serial_number LIKE concat('%',#{concentratorNo},'%')</if>
- <if test="collectorId != null"> and swrd.collector_id = #{collectorId}</if>
- <if test="collectorNo != null and collectorNo != ''"> AND scol.collector_no LIKE concat('%',#{collectorNo},'%')</if>
- <if test="channelNumberId != null"> and swrd.channel_number_id = #{channelNumberId}</if>
- <if test="errorType != null and errorType != ''"> AND swmed.last_error_type LIKE concat('%',#{errorType},'%')</if>
- <if test="customerId != null"> and sd.customer_id = #{customerId}</if>
- <if test="days != null"> and swmed.days = #{days} </if>
- <if test="startReading != null"> and swmed.meter_reading >= #{startReading} </if>
- <if test="endReading != null"> and swmed.meter_reading <![CDATA[ <= ]]> #{endReading} </if>
- <if test="valveStatus != null and valveStatus == 0"> and swmed.valve_status = #{valveStatus} and sdt.is_valve = 1</if>
- <if test="valveStatus != null and valveStatus == 1"> and (swmed.valve_status = #{valveStatus} or swmed.valve_status is null ) and sdt.is_valve = 1</if>
- <if test="valveStatus != null and valveStatus == 2"> and sdt.is_valve = 0</if>
- <if test="registerStatus != null"> and sd.register_status = #{registerStatus} </if>
- <if test="issueStatus != null"> and swrd.issue_status = #{issueStatus} </if>
- <if test="syncStatus != null"> and sd.sync_status = #{syncStatus} </if>
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- GROUP BY sd.building_id
- ) t1 on (t1.building_id = b.id)
- where b.status = 1
- <if test="siteId != null"> and b.site_id=#{siteId} </if>
- <if test="programItems != null and programItems.size() != 0">
- and b.id in (
- select sd.building_id
- from sc_device sd
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
- where sd.status = 1 and sys_id != -99
- <if test="sysId != null"> AND sd.sys_id = #{sysId}</if>
- <if test="siteId != null"> AND sd.site_id = #{siteId}</if>
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- GROUP BY sd.building_id
- )
- </if>
- </select>
- <select id="abnormalAreaBuildingList" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
- select
- b.id,
- b.name,
- b.province,
- b.city,
- b.region,
- b.community,
- b.longitude,
- b.latitude,
- t1.device_count
- from sc_building b
- left join (
- select sde.building_id,count(1) as device_count
- from sc_device_error sde
- <if test="manufacturerId != null or customerId != null or (deviceNo != null and deviceNo != '')">left join sc_device sd on sd.id = sde.device_id and sd.status = 1</if>
- <if test="province != null or city != null or region != null or communityId != null">left join sc_building sb on sb.id = sde.building_id and sb.status = 1</if>
- <if test="equipmentId != null">left join sc_device_type sdt on sdt.id = sd.device_type</if>
- <if test="measuringId != null"> left join sc_alarm_measuring_data samd on (samd.status = 1 and samd.alarm_id = sde.id ) </if>
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sde.device_id and sdd.status = 1)</if>
- where sde.status = 1
- <if test="handleStatus != null"> and sde.handle_status = #{handleStatus} </if>
- <if test="sysId != null"> and sde.sys_id = #{sysId}</if>
- <if test="buildingId != null"> and sde.building_id = #{buildingId}</if>
- <if test="floor != null"> and sde.floor = #{floor}</if>
- <if test="measuringId != null"> and samd.measuring_id = #{measuringId}</if>
- <if test="deviceId != null"> and sde.device_id = #{deviceId} </if>
- <if test="deviceNo != null and deviceNo != ''"> and (sde.device_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_file_no LIKE concat('%',#{deviceNo},'%'))</if>
- <if test="location != null and location != ''"> and sde.location LIKE concat('%',#{location},'%')</if>
- <if test="alarmCategory != null"> and sde.alarm_category = #{alarmCategory}</if>
- <if test="alarmTypeId != null"> and sde.alarm_type_id = #{alarmTypeId}</if>
- <if test="equipmentId != null"> and sdt.id = #{equipmentId} </if>
- <if test="manufacturerId != null"> and sd.manufacturer_id = #{manufacturerId} </if>
- <if test="customerId != null"> and sd.customer_id = #{customerId} </if>
- <if test="province != null"> and sb.province = #{province} </if>
- <if test="city != null"> and sb.city = #{city} </if>
- <if test="region != null"> and sb.region = #{region} </if>
- <if test="communityId != null"> and sb.community = #{communityId} </if>
- <if test="startDate != null"> and sde.alarm_time <![CDATA[ >= ]]> #{startDate}</if>
- <if test="endDate != null"> and sde.alarm_time <![CDATA[ <= ]]> #{endDate}</if>
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- GROUP BY sde.building_id
- ) t1 on (t1.building_id = b.id)
- where b.status = 1
- <if test="siteId != null"> and b.site_id=#{siteId} </if>
- <if test="programItems != null and programItems.size() != 0">
- and b.id in (
- select sd.building_id
- from sc_device sd
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
- where sd.status = 1 and sys_id != -99
- <if test="sysId != null"> AND sd.sys_id = #{sysId}</if>
- <if test="siteId != null"> AND sd.site_id = #{siteId}</if>
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- GROUP BY sd.building_id
- )
- </if>
- </select>
- <select id="installAreaList" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
- select
- b.id,
- b.name,
- b.province,
- b.city,
- b.region,
- b.community,
- b.longitude,
- b.latitude,
- t1.device_count
- from sc_building b
- right join (
- select sd.building_id,count(1) as device_count
- from sc_device sd
- <if test="province != null or city != null or region != null or community != null">left join sc_building sb on (sb.id = sd.building_id and sb.status = 1)</if>
- <if test="errorType != null and errorType != ''">left join sc_water_meter_error_days swmed on ( swmed.device_id = sd.id)</if>
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
- <if test="registerStatus != null"> left join sc_device_type sdt on (sdt.id = sd.device_type)</if>
- <if test="concentratorId != null or channelNumberId != null or (collectorNo != null and collectorNo != '') or issueStatus != null"> left join sc_water_related_device swrd on ( swrd.device_id = sd.id and swrd.status = 1)
- left join sc_concentrator scon on ( scon.id = swrd.concentrator_id and scon.status = 1)
- left join sc_collector scol on ( scol.id = swrd.collector_id)</if>
- left join sc_install_list sil on (sil.device_id = sd.id)
- where sd.status = 1 and sd.sys_id = -99 and sil.status = 1
- <if test="channelId != null"> and sd.device_type in(select scdtu.device_type_id from sc_channel_device_type_use scdtu where scdtu.status = 1 and scdtu.channel_id = #{channelId})</if>
- <if test="buildingId != null"> AND sd.building_id = #{buildingId}</if>
- <if test="siteId != null"> AND sd.site_id = #{siteId}</if>
- <if test="deviceNo != null and deviceNo != ''"> AND (sd.device_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_file_no LIKE concat('%',#{deviceNo},'%'))</if>
- <if test="status != null"> AND sd.device_status = #{status}</if>
- <if test="province != null"> and sb.province = #{province}</if>
- <if test="city != null"> and sb.city = #{city}</if>
- <if test="region != null"> and sb.region = #{region}</if>
- <if test="community != null"> and sb.community = #{community}</if>
- <if test="errorType != null and errorType != ''"> AND swmed.last_error_type LIKE concat('%',#{errorType},'%')</if>
- <if test="locDesc != null and locDesc != ''"> AND sd.loc_desc LIKE concat('%',#{locDesc},'%')</if>
- <if test="deviceTypeId != null"> and sd.device_type = #{deviceTypeId}</if>
- <if test="registerStatus != null and registerStatus == 1"> and sd.register_status = #{registerStatus} and sdt.is_register = 1</if>
- <if test="registerStatus != null and registerStatus == 0"> and sd.register_status = #{registerStatus} and sdt.is_register = 1</if>
- <if test="issueStatus != null"> and swrd.issue_status = #{issueStatus}</if>
- <if test="concentratorId != null"> AND swrd.concentrator_id = #{concentratorId}</if>
- <if test="channelNumberId != null"> AND swrd.channel_number_id = #{channelNumberId}</if>
- <if test="collectorNo != null and collectorNo != ''"> AND scol.collector_no LIKE concat('%',#{collectorNo},'%')</if>
- <if test="customerId != null"> and sd.customer_id = #{customerId}</if>
- <if test="startDate != null"> and sil.install_time <![CDATA[ >= ]]> #{startDate}</if>
- <if test="endDate != null"> and sil.install_time <![CDATA[ <= ]]> #{endDate}</if>
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- GROUP BY sd.building_id
- ) t1 on (t1.building_id = b.id)
- where b.status = 1
- <if test="siteId != null"> and b.site_id=#{siteId} </if>
- <if test="programItems != null and programItems.size() != 0">
- and b.id in (
- select sd.building_id
- from sc_device sd
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
- where sd.status = 1 and sys_id = -99
- <if test="siteId != null"> AND sd.site_id = #{siteId}</if>
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- GROUP BY sd.building_id
- )
- </if>
- </select>
- <select id="getBuildingByInstallPlanId" resultMap="BaseResultMap">
- select
- sb.*,
- sau.name as access_unit_name,
- sa1.name as province_name,
- sa2.name as city_name,
- sa3.name as region_name,
- sc.name as community_name
- from sc_building sb
- left join sc_access_unit sau on (sau.id = sb.access_unit_id and sau.status = 1)
- left join sc_area sa1 on (sa1.id = sb.province)
- left join sc_area sa2 on (sa2.id = sb.city)
- left join sc_area sa3 on (sa3.id = sb.region)
- left join sc_community sc on (sc.id = sb.community)
- where sb.status = 1 and sb.id in (
- select sil.building_id from sc_install_list sil where sil.status = 1 and sil.install_plan_id = #{installPlanId} group by sil.building_id
- )
- </select>
- <select id="countBycCommunityId" resultType="int">
- select count(1) from sc_building where status = 1 and community = #{communityId}
- </select>
- <select id="findByNameUnique" resultType="int">
- select count(1) from sc_building where status = 1 and name = #{name} and site_id = #{siteId} and community = #{community}
- <if test="id != null"> and id != #{id}</if>
- </select>
- <select id="obtainBuildingInformationOnTheIntegratedMap"
- resultType="com.bz.smart_city.dto.BuildingInfoListDto">
- select
- sb.id as building_id,
- sb.name as building_name,
- sb.address ,
- sb.province,
- sb.city,
- sb.region,
- sb.community,
- sa1.name as province_name,
- sa2.name as city_name,
- sa3.name as region_name,
- sc.name as community_name,
- sb.latitude,
- sb.longitude,
- temp.device_count,
- temp.normal_count,
- temp.alarm_count,
- temp.fault_count,
- temp.offline_count,
- temp.device_unused_count
- from sc_building sb
- JOIN(
- SELECT
- sd.building_id,
- count(1) as device_count,
- SUM(IF(sd.device_status = 1, 1, 0)) as normal_count,
- SUM(IF(sd.device_status = 2, 1, 0)) as alarm_count,
- SUM(IF(sd.device_status = 3, 1, 0)) as fault_count,
- SUM(IF(sd.device_status = 4, 1, 0)) as offline_count,
- SUM(IF(sd.device_status = 5, 1, 0)) as device_unused_count
- from sc_device sd
- <if test="programItems != null and programItems.size() != 0">
- left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
- WHERE sd.status = 1 and sd.sys_id != -99
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- GROUP BY sd.building_id
- ) temp on (sb.id = temp.building_id)
- left join sc_area sa1 on sa1.id = sb.province
- left join sc_area sa2 on sa2.id = sb.city
- left join sc_area sa3 on sa3.id = sb.region
- left join sc_community sc on sc.id = sb.community
- where sb.status = 1
- <if test=" longitudeMin != 0 and longitudeMax != 0"> and sb.longitude > #{longitudeMin} AND sb.longitude <![CDATA[ < ]]> #{longitudeMax} </if>
- <if test=" latitudeMin != 0 and latitudeMax != 0"> and sb.latitude > #{latitudeMin} AND sb.latitude <![CDATA[ < ]]> #{latitudeMax} </if>
- </select>
- </mapper>
|