BuildingMapper.xml 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.bz.smart_city.dao.BuildingMapper">
  4. <!--auto generated Code-->
  5. <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.Building">
  6. <result column="id" property="id" jdbcType="INTEGER"/>
  7. <result column="site_id" property="siteId" jdbcType="INTEGER"/>
  8. <result column="name" property="name" jdbcType="VARCHAR"/>
  9. <result column="address" property="address" jdbcType="VARCHAR"/>
  10. <result column="contact_penson" property="contactPenson" jdbcType="VARCHAR"/>
  11. <result column="completion_date" property="completionDate" jdbcType="TIMESTAMP"/>
  12. <result column="contact_phone" property="contactPhone" jdbcType="VARCHAR"/>
  13. <result column="access_unit_id" property="accessUnitId" jdbcType="INTEGER"/>
  14. <result column="province" property="province" jdbcType="INTEGER"/>
  15. <result column="city" property="city" jdbcType="INTEGER"/>
  16. <result column="region" property="region" jdbcType="INTEGER"/>
  17. <result column="detail_address" property="detailAddress" jdbcType="VARCHAR"/>
  18. <result column="region_code" property="regionCode" jdbcType="VARCHAR"/>
  19. <result column="door_no" property="doorNo" jdbcType="VARCHAR"/>
  20. <result column="road_name" property="roadName" jdbcType="VARCHAR"/>
  21. <result column="stree_no" property="streeNo" jdbcType="VARCHAR"/>
  22. <result column="buildl_no" property="buildlNo" jdbcType="VARCHAR"/>
  23. <result column="longitude" property="longitude" jdbcType="VARCHAR"/>
  24. <result column="latitude" property="latitude" jdbcType="VARCHAR"/>
  25. <result column="highly" property="highly" jdbcType="VARCHAR"/>
  26. <result column="building_area" property="buildingArea" jdbcType="VARCHAR"/>
  27. <result column="building_category" property="buildingCategory" jdbcType="INTEGER"/>
  28. <result column="building_structure" property="buildingStructure" jdbcType="INTEGER"/>
  29. <result column="fire_rating" property="fireRating" jdbcType="INTEGER"/>
  30. <result column="risk_rating" property="riskRating" jdbcType="INTEGER"/>
  31. <result column="has_control_roon" property="hasControlRoon" jdbcType="INTEGER"/>
  32. <result column="control_roon_loc" property="controlRoonLoc" jdbcType="VARCHAR"/>
  33. <result column="building_usage" property="buildingUsage" jdbcType="INTEGER"/>
  34. <result column="building_usage_cla" property="buildingUsageCla" jdbcType="VARCHAR"/>
  35. <result column="rights" property="rights" jdbcType="INTEGER"/>
  36. <result column="cover_area" property="coverArea" jdbcType="VARCHAR"/>
  37. <result column="stand_bed_area" property="standBedArea" jdbcType="VARCHAR"/>
  38. <result column="under_floor_num" property="underFloorNum" jdbcType="INTEGER"/>
  39. <result column="under_floor_area" property="underFloorArea" jdbcType="VARCHAR"/>
  40. <result column="floor_num" property="floorNum" jdbcType="INTEGER"/>
  41. <result column="floor_area" property="floorArea" jdbcType="VARCHAR"/>
  42. <result column="asylum_floor_num" property="asylumFloorNum" jdbcType="VARCHAR"/>
  43. <result column="asylum_floor_area" property="asylumFloorArea" jdbcType="VARCHAR"/>
  44. <result column="asylum_floor_loc" property="asylumFloorLoc" jdbcType="VARCHAR"/>
  45. <result column="fire_lift_num" property="fireLiftNum" jdbcType="VARCHAR"/>
  46. <result column="fire_lift_loc" property="fireLiftLoc" jdbcType="VARCHAR"/>
  47. <result column="check_in_func" property="checkInFunc" jdbcType="VARCHAR"/>
  48. <result column="max_capacity" property="maxCapacity" jdbcType="VARCHAR"/>
  49. <result column="has_auto_equipme" property="hasAutoEquipme" jdbcType="INTEGER"/>
  50. <result column="equipment_status" property="equipmentStatus" jdbcType="VARCHAR"/>
  51. <result column="equipment_desc" property="equipmentDesc" jdbcType="VARCHAR"/>
  52. <result column="beside_buildind_desc" property="besideBuildindDesc" jdbcType="VARCHAR"/>
  53. <result column="geography" property="geography" jdbcType="VARCHAR"/>
  54. <result column="status" property="status" jdbcType="INTEGER"/>
  55. <result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
  56. <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
  57. <result column="update_date" property="updateDate" jdbcType="TIMESTAMP"/>
  58. <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
  59. <result column="community" property="community" jdbcType="VARCHAR"/>
  60. <result column="unit" property="unit" jdbcType="VARCHAR"/>
  61. </resultMap>
  62. <!--auto generated Code-->
  63. <sql id="Base_Column_List">
  64. id,
  65. site_id,
  66. name,
  67. address,
  68. contact_penson,
  69. completion_date,
  70. contact_phone,
  71. access_unit_id,
  72. province,
  73. city,
  74. region,
  75. detail_address,
  76. region_code,
  77. door_no,
  78. road_name,
  79. stree_no,
  80. buildl_no,
  81. longitude,
  82. latitude,
  83. highly,
  84. building_area,
  85. building_category,
  86. building_structure,
  87. fire_rating,
  88. risk_rating,
  89. has_control_roon,
  90. control_roon_loc,
  91. building_usage,
  92. building_usage_cla,
  93. rights,
  94. cover_area,
  95. stand_bed_area,
  96. under_floor_num,
  97. under_floor_area,
  98. floor_num,
  99. floor_area,
  100. asylum_floor_num,
  101. asylum_floor_area,
  102. asylum_floor_loc,
  103. fire_lift_num,
  104. fire_lift_loc,
  105. check_in_func,
  106. max_capacity,
  107. has_auto_equipme,
  108. equipment_status,
  109. equipment_desc,
  110. beside_buildind_desc,
  111. geography,
  112. status,
  113. create_date,
  114. create_by,
  115. update_date,
  116. update_by,
  117. community,
  118. unit
  119. </sql>
  120. <!--auto generated Code-->
  121. <insert id="insert" useGeneratedKeys="true" keyProperty="building.id">
  122. INSERT INTO sc_building (
  123. id,
  124. site_id,
  125. name,
  126. address,
  127. contact_penson,
  128. completion_date,
  129. contact_phone,
  130. access_unit_id,
  131. province,
  132. city,
  133. region,
  134. detail_address,
  135. region_code,
  136. door_no,
  137. road_name,
  138. stree_no,
  139. buildl_no,
  140. longitude,
  141. latitude,
  142. highly,
  143. building_area,
  144. building_category,
  145. building_structure,
  146. fire_rating,
  147. risk_rating,
  148. has_control_roon,
  149. control_roon_loc,
  150. building_usage,
  151. building_usage_cla,
  152. rights,
  153. cover_area,
  154. stand_bed_area,
  155. under_floor_num,
  156. under_floor_area,
  157. floor_num,
  158. floor_area,
  159. asylum_floor_num,
  160. asylum_floor_area,
  161. asylum_floor_loc,
  162. fire_lift_num,
  163. fire_lift_loc,
  164. check_in_func,
  165. max_capacity,
  166. has_auto_equipme,
  167. equipment_status,
  168. equipment_desc,
  169. beside_buildind_desc,
  170. geography,
  171. status,
  172. create_date,
  173. create_by,
  174. update_date,
  175. update_by,
  176. community,
  177. unit
  178. ) VALUES (
  179. #{building.id,jdbcType=INTEGER},
  180. #{building.siteId,jdbcType=INTEGER},
  181. #{building.name,jdbcType=VARCHAR},
  182. #{building.address,jdbcType=VARCHAR},
  183. #{building.contactPenson,jdbcType=VARCHAR},
  184. #{building.completionDate,jdbcType=TIMESTAMP},
  185. #{building.contactPhone,jdbcType=VARCHAR},
  186. #{building.accessUnitId,jdbcType=INTEGER},
  187. #{building.province,jdbcType=INTEGER},
  188. #{building.city,jdbcType=INTEGER},
  189. #{building.region,jdbcType=INTEGER},
  190. #{building.detailAddress,jdbcType=VARCHAR},
  191. #{building.regionCode,jdbcType=VARCHAR},
  192. #{building.doorNo,jdbcType=VARCHAR},
  193. #{building.roadName,jdbcType=VARCHAR},
  194. #{building.streeNo,jdbcType=VARCHAR},
  195. #{building.buildlNo,jdbcType=VARCHAR},
  196. #{building.longitude,jdbcType=VARCHAR},
  197. #{building.latitude,jdbcType=VARCHAR},
  198. #{building.highly,jdbcType=VARCHAR},
  199. #{building.buildingArea,jdbcType=VARCHAR},
  200. #{building.buildingCategory,jdbcType=INTEGER},
  201. #{building.buildingStructure,jdbcType=INTEGER},
  202. #{building.fireRating,jdbcType=INTEGER},
  203. #{building.riskRating,jdbcType=INTEGER},
  204. #{building.hasControlRoon,jdbcType=INTEGER},
  205. #{building.controlRoonLoc,jdbcType=VARCHAR},
  206. #{building.buildingUsage,jdbcType=INTEGER},
  207. #{building.buildingUsageCla,jdbcType=VARCHAR},
  208. #{building.rights,jdbcType=INTEGER},
  209. #{building.coverArea,jdbcType=VARCHAR},
  210. #{building.standBedArea,jdbcType=VARCHAR},
  211. #{building.underFloorNum,jdbcType=INTEGER},
  212. #{building.underFloorArea,jdbcType=VARCHAR},
  213. #{building.floorNum,jdbcType=INTEGER},
  214. #{building.floorArea,jdbcType=VARCHAR},
  215. #{building.asylumFloorNum,jdbcType=VARCHAR},
  216. #{building.asylumFloorArea,jdbcType=VARCHAR},
  217. #{building.asylumFloorLoc,jdbcType=VARCHAR},
  218. #{building.fireLiftNum,jdbcType=VARCHAR},
  219. #{building.fireLiftLoc,jdbcType=VARCHAR},
  220. #{building.checkInFunc,jdbcType=VARCHAR},
  221. #{building.maxCapacity,jdbcType=VARCHAR},
  222. #{building.hasAutoEquipme,jdbcType=INTEGER},
  223. #{building.equipmentStatus,jdbcType=VARCHAR},
  224. #{building.equipmentDesc,jdbcType=VARCHAR},
  225. #{building.besideBuildindDesc,jdbcType=VARCHAR},
  226. #{building.geography,jdbcType=VARCHAR},
  227. #{building.status,jdbcType=INTEGER},
  228. #{building.createDate,jdbcType=TIMESTAMP},
  229. #{building.createBy,jdbcType=VARCHAR},
  230. #{building.updateDate,jdbcType=TIMESTAMP},
  231. #{building.updateBy,jdbcType=VARCHAR},
  232. #{building.community,jdbcType=VARCHAR},
  233. #{building.unit,jdbcType=VARCHAR}
  234. )
  235. </insert>
  236. <!--auto generated Code-->
  237. <insert id="insertSelective" useGeneratedKeys="true" keyProperty="building.id">
  238. INSERT INTO sc_building
  239. <trim prefix="(" suffix=")" suffixOverrides=",">
  240. <if test="building.id!=null"> id,</if>
  241. <if test="building.siteId!=null"> site_id,</if>
  242. <if test="building.name!=null"> name,</if>
  243. <if test="building.address!=null"> address,</if>
  244. <if test="building.contactPenson!=null"> contact_penson,</if>
  245. <if test="building.completionDate!=null"> completion_date,</if>
  246. <if test="building.contactPhone!=null"> contact_phone,</if>
  247. <if test="building.accessUnitId!=null"> access_unit_id,</if>
  248. <if test="building.province!=null"> province,</if>
  249. <if test="building.city!=null"> city,</if>
  250. <if test="building.region!=null"> region,</if>
  251. <if test="building.detailAddress!=null"> detail_address,</if>
  252. <if test="building.regionCode!=null"> region_code,</if>
  253. <if test="building.doorNo!=null"> door_no,</if>
  254. <if test="building.roadName!=null"> road_name,</if>
  255. <if test="building.streeNo!=null"> stree_no,</if>
  256. <if test="building.buildlNo!=null"> buildl_no,</if>
  257. <if test="building.longitude!=null"> longitude,</if>
  258. <if test="building.latitude!=null"> latitude,</if>
  259. <if test="building.highly!=null"> highly,</if>
  260. <if test="building.buildingArea!=null"> building_area,</if>
  261. <if test="building.buildingCategory!=null"> building_category,</if>
  262. <if test="building.buildingStructure!=null"> building_structure,</if>
  263. <if test="building.fireRating!=null"> fire_rating,</if>
  264. <if test="building.riskRating!=null"> risk_rating,</if>
  265. <if test="building.hasControlRoon!=null"> has_control_roon,</if>
  266. <if test="building.controlRoonLoc!=null"> control_roon_loc,</if>
  267. <if test="building.buildingUsage!=null"> building_usage,</if>
  268. <if test="building.buildingUsageCla!=null"> building_usage_cla,</if>
  269. <if test="building.rights!=null"> rights,</if>
  270. <if test="building.coverArea!=null"> cover_area,</if>
  271. <if test="building.standBedArea!=null"> stand_bed_area,</if>
  272. <if test="building.underFloorNum!=null"> under_floor_num,</if>
  273. <if test="building.underFloorArea!=null"> under_floor_area,</if>
  274. <if test="building.floorNum!=null"> floor_num,</if>
  275. <if test="building.floorArea!=null"> floor_area,</if>
  276. <if test="building.asylumFloorNum!=null"> asylum_floor_num,</if>
  277. <if test="building.asylumFloorArea!=null"> asylum_floor_area,</if>
  278. <if test="building.asylumFloorLoc!=null"> asylum_floor_loc,</if>
  279. <if test="building.fireLiftNum!=null"> fire_lift_num,</if>
  280. <if test="building.fireLiftLoc!=null"> fire_lift_loc,</if>
  281. <if test="building.checkInFunc!=null"> check_in_func,</if>
  282. <if test="building.maxCapacity!=null"> max_capacity,</if>
  283. <if test="building.hasAutoEquipme!=null"> has_auto_equipme,</if>
  284. <if test="building.equipmentStatus!=null"> equipment_status,</if>
  285. <if test="building.equipmentDesc!=null"> equipment_desc,</if>
  286. <if test="building.besideBuildindDesc!=null"> beside_buildind_desc,</if>
  287. <if test="building.geography!=null"> geography,</if>
  288. <if test="building.status!=null"> status,</if>
  289. <if test="building.createDate!=null"> create_date,</if>
  290. <if test="building.createBy!=null"> create_by,</if>
  291. <if test="building.updateDate!=null"> update_date,</if>
  292. <if test="building.updateBy!=null"> update_by,</if>
  293. <if test="building.community!=null"> community,</if>
  294. <if test="building.unit!=null"> unit</if>
  295. </trim>
  296. VALUES
  297. <trim prefix="(" suffix=")" suffixOverrides=",">
  298. <if test="building.id!=null"> #{building.id,jdbcType=INTEGER},</if>
  299. <if test="building.siteId!=null"> #{building.siteId,jdbcType=INTEGER},</if>
  300. <if test="building.name!=null"> #{building.name,jdbcType=VARCHAR},</if>
  301. <if test="building.address!=null"> #{building.address,jdbcType=VARCHAR},</if>
  302. <if test="building.contactPenson!=null"> #{building.contactPenson,jdbcType=VARCHAR},</if>
  303. <if test="building.completionDate!=null"> #{building.completionDate,jdbcType=TIMESTAMP},</if>
  304. <if test="building.contactPhone!=null"> #{building.contactPhone,jdbcType=VARCHAR},</if>
  305. <if test="building.accessUnitId!=null"> #{building.accessUnitId,jdbcType=INTEGER},</if>
  306. <if test="building.province!=null"> #{building.province,jdbcType=INTEGER},</if>
  307. <if test="building.city!=null"> #{building.city,jdbcType=INTEGER},</if>
  308. <if test="building.region!=null"> #{building.region,jdbcType=INTEGER},</if>
  309. <if test="building.detailAddress!=null"> #{building.detailAddress,jdbcType=VARCHAR},</if>
  310. <if test="building.regionCode!=null"> #{building.regionCode,jdbcType=VARCHAR},</if>
  311. <if test="building.doorNo!=null"> #{building.doorNo,jdbcType=VARCHAR},</if>
  312. <if test="building.roadName!=null"> #{building.roadName,jdbcType=VARCHAR},</if>
  313. <if test="building.streeNo!=null"> #{building.streeNo,jdbcType=VARCHAR},</if>
  314. <if test="building.buildlNo!=null"> #{building.buildlNo,jdbcType=VARCHAR},</if>
  315. <if test="building.longitude!=null"> #{building.longitude,jdbcType=VARCHAR},</if>
  316. <if test="building.latitude!=null"> #{building.latitude,jdbcType=VARCHAR},</if>
  317. <if test="building.highly!=null"> #{building.highly,jdbcType=VARCHAR},</if>
  318. <if test="building.buildingArea!=null"> #{building.buildingArea,jdbcType=VARCHAR},</if>
  319. <if test="building.buildingCategory!=null"> #{building.buildingCategory,jdbcType=INTEGER},</if>
  320. <if test="building.buildingStructure!=null"> #{building.buildingStructure,jdbcType=INTEGER},</if>
  321. <if test="building.fireRating!=null"> #{building.fireRating,jdbcType=INTEGER},</if>
  322. <if test="building.riskRating!=null"> #{building.riskRating,jdbcType=INTEGER},</if>
  323. <if test="building.hasControlRoon!=null"> #{building.hasControlRoon,jdbcType=INTEGER},</if>
  324. <if test="building.controlRoonLoc!=null"> #{building.controlRoonLoc,jdbcType=VARCHAR},</if>
  325. <if test="building.buildingUsage!=null"> #{building.buildingUsage,jdbcType=INTEGER},</if>
  326. <if test="building.buildingUsageCla!=null"> #{building.buildingUsageCla,jdbcType=VARCHAR},</if>
  327. <if test="building.rights!=null"> #{building.rights,jdbcType=INTEGER},</if>
  328. <if test="building.coverArea!=null"> #{building.coverArea,jdbcType=VARCHAR},</if>
  329. <if test="building.standBedArea!=null"> #{building.standBedArea,jdbcType=VARCHAR},</if>
  330. <if test="building.underFloorNum!=null"> #{building.underFloorNum,jdbcType=INTEGER},</if>
  331. <if test="building.underFloorArea!=null"> #{building.underFloorArea,jdbcType=VARCHAR},</if>
  332. <if test="building.floorNum!=null"> #{building.floorNum,jdbcType=INTEGER},</if>
  333. <if test="building.floorArea!=null"> #{building.floorArea,jdbcType=VARCHAR},</if>
  334. <if test="building.asylumFloorNum!=null"> #{building.asylumFloorNum,jdbcType=VARCHAR},</if>
  335. <if test="building.asylumFloorArea!=null"> #{building.asylumFloorArea,jdbcType=VARCHAR},</if>
  336. <if test="building.asylumFloorLoc!=null"> #{building.asylumFloorLoc,jdbcType=VARCHAR},</if>
  337. <if test="building.fireLiftNum!=null"> #{building.fireLiftNum,jdbcType=VARCHAR},</if>
  338. <if test="building.fireLiftLoc!=null"> #{building.fireLiftLoc,jdbcType=VARCHAR},</if>
  339. <if test="building.checkInFunc!=null"> #{building.checkInFunc,jdbcType=VARCHAR},</if>
  340. <if test="building.maxCapacity!=null"> #{building.maxCapacity,jdbcType=VARCHAR},</if>
  341. <if test="building.hasAutoEquipme!=null"> #{building.hasAutoEquipme,jdbcType=INTEGER},</if>
  342. <if test="building.equipmentStatus!=null"> #{building.equipmentStatus,jdbcType=VARCHAR},</if>
  343. <if test="building.equipmentDesc!=null"> #{building.equipmentDesc,jdbcType=VARCHAR},</if>
  344. <if test="building.besideBuildindDesc!=null"> #{building.besideBuildindDesc,jdbcType=VARCHAR},</if>
  345. <if test="building.geography!=null"> #{building.geography,jdbcType=VARCHAR},</if>
  346. <if test="building.status!=null"> #{building.status,jdbcType=INTEGER},</if>
  347. <if test="building.createDate!=null"> #{building.createDate,jdbcType=TIMESTAMP},</if>
  348. <if test="building.createBy!=null"> #{building.createBy,jdbcType=VARCHAR},</if>
  349. <if test="building.updateDate!=null"> #{building.updateDate,jdbcType=TIMESTAMP},</if>
  350. <if test="building.updateBy!=null"> #{building.updateBy,jdbcType=VARCHAR},</if>
  351. <if test="building.community!=null"> #{building.community,jdbcType=VARCHAR},</if>
  352. <if test="building.unit!=null"> #{building.unit,jdbcType=VARCHAR}</if>
  353. </trim>
  354. </insert>
  355. <!--auto generated Code-->
  356. <insert id="insertList">
  357. INSERT INTO sc_building(
  358. id,
  359. site_id,
  360. name,
  361. address,
  362. contact_penson,
  363. completion_date,
  364. contact_phone,
  365. access_unit_id,
  366. province,
  367. city,
  368. region,
  369. detail_address,
  370. region_code,
  371. door_no,
  372. road_name,
  373. stree_no,
  374. buildl_no,
  375. longitude,
  376. latitude,
  377. highly,
  378. building_area,
  379. building_category,
  380. building_structure,
  381. fire_rating,
  382. risk_rating,
  383. has_control_roon,
  384. control_roon_loc,
  385. building_usage,
  386. building_usage_cla,
  387. rights,
  388. cover_area,
  389. stand_bed_area,
  390. under_floor_num,
  391. under_floor_area,
  392. floor_num,
  393. floor_area,
  394. asylum_floor_num,
  395. asylum_floor_area,
  396. asylum_floor_loc,
  397. fire_lift_num,
  398. fire_lift_loc,
  399. check_in_func,
  400. max_capacity,
  401. has_auto_equipme,
  402. equipment_status,
  403. equipment_desc,
  404. beside_buildind_desc,
  405. geography,
  406. status,
  407. create_date,
  408. create_by,
  409. update_date,
  410. update_by,
  411. community,
  412. unit
  413. )VALUES
  414. <foreach collection="buildings" item="building" index="index" separator=",">
  415. (
  416. #{building.id,jdbcType=INTEGER},
  417. #{building.siteId,jdbcType=INTEGER},
  418. #{building.name,jdbcType=VARCHAR},
  419. #{building.address,jdbcType=VARCHAR},
  420. #{building.contactPenson,jdbcType=VARCHAR},
  421. #{building.completionDate,jdbcType=TIMESTAMP},
  422. #{building.contactPhone,jdbcType=VARCHAR},
  423. #{building.accessUnitId,jdbcType=INTEGER},
  424. #{building.province,jdbcType=INTEGER},
  425. #{building.city,jdbcType=INTEGER},
  426. #{building.region,jdbcType=INTEGER},
  427. #{building.detailAddress,jdbcType=VARCHAR},
  428. #{building.regionCode,jdbcType=VARCHAR},
  429. #{building.doorNo,jdbcType=VARCHAR},
  430. #{building.roadName,jdbcType=VARCHAR},
  431. #{building.streeNo,jdbcType=VARCHAR},
  432. #{building.buildlNo,jdbcType=VARCHAR},
  433. #{building.longitude,jdbcType=VARCHAR},
  434. #{building.latitude,jdbcType=VARCHAR},
  435. #{building.highly,jdbcType=VARCHAR},
  436. #{building.buildingArea,jdbcType=VARCHAR},
  437. #{building.buildingCategory,jdbcType=INTEGER},
  438. #{building.buildingStructure,jdbcType=INTEGER},
  439. #{building.fireRating,jdbcType=INTEGER},
  440. #{building.riskRating,jdbcType=INTEGER},
  441. #{building.hasControlRoon,jdbcType=INTEGER},
  442. #{building.controlRoonLoc,jdbcType=VARCHAR},
  443. #{building.buildingUsage,jdbcType=INTEGER},
  444. #{building.buildingUsageCla,jdbcType=VARCHAR},
  445. #{building.rights,jdbcType=INTEGER},
  446. #{building.coverArea,jdbcType=VARCHAR},
  447. #{building.standBedArea,jdbcType=VARCHAR},
  448. #{building.underFloorNum,jdbcType=INTEGER},
  449. #{building.underFloorArea,jdbcType=VARCHAR},
  450. #{building.floorNum,jdbcType=INTEGER},
  451. #{building.floorArea,jdbcType=VARCHAR},
  452. #{building.asylumFloorNum,jdbcType=VARCHAR},
  453. #{building.asylumFloorArea,jdbcType=VARCHAR},
  454. #{building.asylumFloorLoc,jdbcType=VARCHAR},
  455. #{building.fireLiftNum,jdbcType=VARCHAR},
  456. #{building.fireLiftLoc,jdbcType=VARCHAR},
  457. #{building.checkInFunc,jdbcType=VARCHAR},
  458. #{building.maxCapacity,jdbcType=VARCHAR},
  459. #{building.hasAutoEquipme,jdbcType=INTEGER},
  460. #{building.equipmentStatus,jdbcType=VARCHAR},
  461. #{building.equipmentDesc,jdbcType=VARCHAR},
  462. #{building.besideBuildindDesc,jdbcType=VARCHAR},
  463. #{building.geography,jdbcType=VARCHAR},
  464. #{building.status,jdbcType=INTEGER},
  465. #{building.createDate,jdbcType=TIMESTAMP},
  466. #{building.createBy,jdbcType=VARCHAR},
  467. #{building.updateDate,jdbcType=TIMESTAMP},
  468. #{building.updateBy,jdbcType=VARCHAR},
  469. #{building.community,jdbcType=VARCHAR},
  470. #{building.unit,jdbcType=VARCHAR}
  471. )
  472. </foreach>
  473. </insert>
  474. <!--auto generated Code-->
  475. <update id="updateByPrimaryKeySelective">
  476. UPDATE sc_building
  477. <set>
  478. <if test="building.id != null"> id = #{building.id,jdbcType=INTEGER},</if>
  479. <if test="building.siteId != null"> site_id = #{building.siteId,jdbcType=INTEGER},</if>
  480. <if test="building.name != null"> name = #{building.name,jdbcType=VARCHAR},</if>
  481. <if test="building.address != null"> address = #{building.address,jdbcType=VARCHAR},</if>
  482. <if test="building.contactPenson != null"> contact_penson = #{building.contactPenson,jdbcType=VARCHAR},</if>
  483. <if test="building.completionDate != null"> completion_date = #{building.completionDate,jdbcType=TIMESTAMP},</if>
  484. <if test="building.contactPhone != null"> contact_phone = #{building.contactPhone,jdbcType=VARCHAR},</if>
  485. <if test="building.accessUnitId != null"> access_unit_id = #{building.accessUnitId,jdbcType=INTEGER},</if>
  486. <if test="building.province != null"> province = #{building.province,jdbcType=INTEGER},</if>
  487. <if test="building.city != null"> city = #{building.city,jdbcType=INTEGER},</if>
  488. <if test="building.region != null"> region = #{building.region,jdbcType=INTEGER},</if>
  489. <if test="building.detailAddress != null"> detail_address = #{building.detailAddress,jdbcType=VARCHAR},</if>
  490. <if test="building.regionCode != null"> region_code = #{building.regionCode,jdbcType=VARCHAR},</if>
  491. <if test="building.doorNo != null"> door_no = #{building.doorNo,jdbcType=VARCHAR},</if>
  492. <if test="building.roadName != null"> road_name = #{building.roadName,jdbcType=VARCHAR},</if>
  493. <if test="building.streeNo != null"> stree_no = #{building.streeNo,jdbcType=VARCHAR},</if>
  494. <if test="building.buildlNo != null"> buildl_no = #{building.buildlNo,jdbcType=VARCHAR},</if>
  495. <if test="building.longitude != null"> longitude = #{building.longitude,jdbcType=VARCHAR},</if>
  496. <if test="building.latitude != null"> latitude = #{building.latitude,jdbcType=VARCHAR},</if>
  497. <if test="building.highly != null"> highly = #{building.highly,jdbcType=VARCHAR},</if>
  498. <if test="building.buildingArea != null"> building_area = #{building.buildingArea,jdbcType=VARCHAR},</if>
  499. <if test="building.buildingCategory != null"> building_category = #{building.buildingCategory,jdbcType=INTEGER},</if>
  500. <if test="building.buildingStructure != null"> building_structure = #{building.buildingStructure,jdbcType=INTEGER},</if>
  501. <if test="building.fireRating != null"> fire_rating = #{building.fireRating,jdbcType=INTEGER},</if>
  502. <if test="building.riskRating != null"> risk_rating = #{building.riskRating,jdbcType=INTEGER},</if>
  503. <if test="building.hasControlRoon != null"> has_control_roon = #{building.hasControlRoon,jdbcType=INTEGER},</if>
  504. <if test="building.controlRoonLoc != null"> control_roon_loc = #{building.controlRoonLoc,jdbcType=VARCHAR},</if>
  505. <if test="building.buildingUsage != null"> building_usage = #{building.buildingUsage,jdbcType=INTEGER},</if>
  506. <if test="building.buildingUsageCla != null"> building_usage_cla = #{building.buildingUsageCla,jdbcType=VARCHAR},</if>
  507. <if test="building.rights != null"> rights = #{building.rights,jdbcType=INTEGER},</if>
  508. <if test="building.coverArea != null"> cover_area = #{building.coverArea,jdbcType=VARCHAR},</if>
  509. <if test="building.standBedArea != null"> stand_bed_area = #{building.standBedArea,jdbcType=VARCHAR},</if>
  510. <if test="building.underFloorNum != null"> under_floor_num = #{building.underFloorNum,jdbcType=INTEGER},</if>
  511. <if test="building.underFloorArea != null"> under_floor_area = #{building.underFloorArea,jdbcType=VARCHAR},</if>
  512. <if test="building.floorNum != null"> floor_num = #{building.floorNum,jdbcType=INTEGER},</if>
  513. <if test="building.floorArea != null"> floor_area = #{building.floorArea,jdbcType=VARCHAR},</if>
  514. <if test="building.asylumFloorNum != null"> asylum_floor_num = #{building.asylumFloorNum,jdbcType=VARCHAR},</if>
  515. <if test="building.asylumFloorArea != null"> asylum_floor_area = #{building.asylumFloorArea,jdbcType=VARCHAR},</if>
  516. <if test="building.asylumFloorLoc != null"> asylum_floor_loc = #{building.asylumFloorLoc,jdbcType=VARCHAR},</if>
  517. <if test="building.fireLiftNum != null"> fire_lift_num = #{building.fireLiftNum,jdbcType=VARCHAR},</if>
  518. <if test="building.fireLiftLoc != null"> fire_lift_loc = #{building.fireLiftLoc,jdbcType=VARCHAR},</if>
  519. <if test="building.checkInFunc != null"> check_in_func = #{building.checkInFunc,jdbcType=VARCHAR},</if>
  520. <if test="building.maxCapacity != null"> max_capacity = #{building.maxCapacity,jdbcType=VARCHAR},</if>
  521. <if test="building.hasAutoEquipme != null"> has_auto_equipme = #{building.hasAutoEquipme,jdbcType=INTEGER},</if>
  522. <if test="building.equipmentStatus != null"> equipment_status = #{building.equipmentStatus,jdbcType=VARCHAR},</if>
  523. <if test="building.equipmentDesc != null"> equipment_desc = #{building.equipmentDesc,jdbcType=VARCHAR},</if>
  524. <if test="building.besideBuildindDesc != null"> beside_buildind_desc = #{building.besideBuildindDesc,jdbcType=VARCHAR},</if>
  525. <if test="building.geography != null"> geography = #{building.geography,jdbcType=VARCHAR},</if>
  526. <if test="building.status != null"> status = #{building.status,jdbcType=INTEGER},</if>
  527. <if test="building.createDate != null"> create_date = #{building.createDate,jdbcType=TIMESTAMP},</if>
  528. <if test="building.createBy != null"> create_by = #{building.createBy,jdbcType=VARCHAR},</if>
  529. <if test="building.updateDate != null"> update_date = #{building.updateDate,jdbcType=TIMESTAMP},</if>
  530. <if test="building.updateBy != null"> update_by = #{building.updateBy,jdbcType=VARCHAR},</if>
  531. <if test="building.community != null"> community = #{building.community,jdbcType=VARCHAR},</if>
  532. <if test="building.unit != null"> unit = #{building.unit,jdbcType=VARCHAR}</if>
  533. </set>
  534. WHERE id = #{building.id,jdbcType=INTEGER}
  535. </update>
  536. <!--auto generated by codehelper on 2018-12-18-->
  537. <select id="findBySiteId" resultMap="BaseResultMap">
  538. select
  539. sb.id,sb.name,sb.province,sb.city,sb.region,sb.community
  540. from sc_building sb
  541. left join sc_community sc on(sc.id = sb.community)
  542. where sb.status = 1
  543. <if test="siteId != null"> and sb.site_id=#{siteId} </if>
  544. <if test="sysId != null">
  545. 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)
  546. </if>
  547. <if test="customerIds != null and customerIds.size() != 0">
  548. and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
  549. </if>
  550. </select>
  551. <select id="findBySiteIdAndCustomerIds" resultMap="BaseResultMap">
  552. select
  553. b.id,
  554. b.name,
  555. b.province,
  556. b.city,
  557. b.region,
  558. b.community
  559. from sc_building b
  560. left join sc_community c on(c.id = b.community)
  561. where b.status = 1
  562. <if test="siteId != null"> and b.site_id=#{siteId} </if>
  563. <if test="sysId != null">
  564. 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)
  565. </if>
  566. <if test="customerIds != null and customerIds.size() != 0">
  567. and c.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
  568. </if>
  569. </select>
  570. <select id="findBySiteIdAndProgramItem" resultMap="BaseResultMap">
  571. select
  572. sb.id,sb.name,sb.province,sb.city,sb.region,sb.community,sb.longitude,sb.latitude
  573. from sc_building sb
  574. left join sc_community sc on(sc.id = sb.community)
  575. where sb.status = 1
  576. <if test="siteId != null"> and sb.site_id=#{siteId} </if>
  577. <if test="customerId != null"> and sc.customer_id=#{customerId} </if>
  578. <if test="buildingIds != null and buildingIds.size() != 0"> and sb.id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
  579. <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>
  580. <if test="buildingName != null and buildingName != ''"> AND sb.name LIKE concat('%',#{buildingName},'%')</if>
  581. <if test="customerIds != null and customerIds.size() != 0">
  582. and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
  583. </if>
  584. order by sb.name asc
  585. </select>
  586. <select id="findBuildingCountDeviceNum" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
  587. select
  588. sb.id,
  589. sb.name,
  590. sb.province,
  591. sb.city,
  592. sb.region,
  593. sb.community,
  594. sb.longitude,
  595. sb.latitude,
  596. (
  597. SELECT count(1) FROM sc_device sd
  598. <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>
  599. WHERE sd.status = 1 and sd.building_id=sb.id and sd.sys_id != -99
  600. <if test="siteId != null"> and sd.site_id=#{siteId} </if>
  601. <if test="sysId != null"> and sd.sys_id=#{sysId} </if>
  602. <if test="deviceNo != null and deviceNo != ''"> AND sd.device_no LIKE concat('%',#{deviceNo},'%')</if>
  603. <if test="deviceTypeId != null"> AND sd.device_type = #{deviceTypeId} </if>
  604. <if test="locDesc != null and locDesc != ''"> AND sd.loc_desc LIKE concat('%',#{locDesc},'%')</if>
  605. <if test="deviceStatus != null">and sd.device_status = #{deviceStatus} </if>
  606. <if test="programItems != null and programItems.size() != 0"> and
  607. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  608. sdd.${item.dimensionCode} = #{item.dimensionValue}
  609. </foreach>
  610. </if>
  611. ) as device_count
  612. from sc_building sb
  613. where sb.status = 1
  614. <if test="siteId != null"> and sb.site_id=#{siteId} </if>
  615. <if test="region != null"> and sb.region = #{region} </if>
  616. <if test="communityId != null"> and sb.community = #{communityId} </if>
  617. </select>
  618. <select id="findBuildingCountErrorNum" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
  619. select
  620. sb.id,
  621. sb.name,
  622. sb.province,
  623. sb.city,
  624. sb.region,
  625. sb.community,
  626. sb.longitude,
  627. sb.latitude,
  628. (
  629. SELECT count(1) FROM sc_device_error sde
  630. left join sc_device sd on sd.id = sde.device_id and sd.status = 1
  631. <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>
  632. WHERE sde.status = 1 and sde.building_id=sb.id
  633. <if test="siteId != null"> and sde.site_id=#{siteId} </if>
  634. <if test="sysId != null"> and sde.sys_id=#{sysId} </if>
  635. <if test="deviceNo != null and deviceNo != ''"> AND sde.device_no LIKE concat('%',#{deviceNo},'%')</if>
  636. <if test="alarmCategory != null"> AND sde.alarm_category = #{alarmCategory} </if>
  637. <if test="handleStatus != null"> AND sde.handle_status = #{handleStatus} </if>
  638. <if test="deviceTypeId != null"> AND sd.device_type = #{deviceTypeId} </if>
  639. <if test="location != null and location != ''"> and sde.location LIKE concat('%',#{location},'%')</if>
  640. <if test="startDate != null"> and sde.alarm_time <![CDATA[ >= ]]> #{startDate}</if>
  641. <if test="endDate != null"> and sde.alarm_time <![CDATA[ <= ]]> #{endDate}</if>
  642. <if test="programItems != null and programItems.size() != 0"> and
  643. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  644. sdd.${item.dimensionCode} = #{item.dimensionValue}
  645. </foreach>
  646. </if>
  647. ) as device_count
  648. from sc_building sb
  649. where sb.status = 1
  650. <if test="siteId != null"> and sb.site_id=#{siteId} </if>
  651. <if test="region != null"> and sb.region=#{region} </if>
  652. <if test="communityId != null"> and sb.community=#{communityId} </if>
  653. </select>
  654. <select id="findBuildingCountError" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
  655. select
  656. sb.id,
  657. sb.name,
  658. sb.province,
  659. sb.city,
  660. sb.region,
  661. sb.community,
  662. sb.longitude,
  663. sb.latitude
  664. from sc_building sb
  665. where sb.status = 1
  666. <if test="siteId != null"> and sb.site_id=#{siteId} </if>
  667. <if test="region != null"> and sb.region=#{region} </if>
  668. <if test="communityId != null"> and sb.community=#{communityId} </if>
  669. </select>
  670. <select id="findBySiteIdAndName" resultType="com.bz.smart_city.dto.BuildingInfoDto">
  671. select
  672. sb.id as building_id,
  673. sb.name as building_name,
  674. sb.longitude,
  675. sb.latitude,
  676. (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,
  677. (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,
  678. (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,
  679. (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,
  680. (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,
  681. sb.status
  682. from sc_building sb
  683. where status = 1
  684. and sb.id in(
  685. SELECT sd.building_id FROM sc_device sd
  686. WHERE sd.status = 1
  687. <if test="sysId != null"> and sd.sys_id = #{sysId}</if>
  688. <if test="siteId != null"> and sd.site_id = #{siteId}</if>
  689. GROUP BY sd.building_id
  690. )
  691. <if test="siteId != null"> and sb.site_id=#{siteId} </if>
  692. <if test="buildingId != null"> and sb.id=#{buildingId} </if>
  693. <if test="buildingName != null and buildingName != ''"> AND name LIKE concat('%',#{buildingName},'%')</if>
  694. </select>
  695. <select id="getBuildingList" resultType="com.bz.smart_city.dto.BuildingInfoListDto">
  696. select
  697. sb.id as building_id,
  698. sb.name as building_name,
  699. sb.address ,
  700. sau.fire_resp_name,
  701. sau.fire_resp_phone,
  702. sb.province,
  703. sb.city,
  704. sb.region,
  705. sb.community,
  706. sa1.name as province_name,
  707. sa2.name as city_name,
  708. sa3.name as region_name,
  709. sc.name as community_name,
  710. sb.latitude,
  711. sb.longitude,
  712. temp.device_count,
  713. temp.normal_count,
  714. temp.alarm_count,
  715. temp.fault_count,
  716. temp.offline_count,
  717. temp.device_unused_count
  718. from sc_building sb
  719. LEFT JOIN(
  720. SELECT
  721. sd.building_id,
  722. <if test="sysId != null">sd.sys_id,</if>
  723. count(1) as device_count,
  724. SUM(IF(sd.device_status = 1, 1, 0)) as normal_count,
  725. SUM(IF(sd.device_status = 2, 1, 0)) as alarm_count,
  726. SUM(IF(sd.device_status = 3, 1, 0)) as fault_count,
  727. SUM(IF(sd.device_status = 4, 1, 0)) as offline_count,
  728. SUM(IF(sd.device_status = 5, 1, 0)) as device_unused_count
  729. from sc_device sd
  730. <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>
  731. WHERE sd.status = 1 and sd.sys_id != -99
  732. <if test="programItems != null and programItems.size() != 0"> and
  733. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  734. sdd.${item.dimensionCode} = #{item.dimensionValue}
  735. </foreach>
  736. </if>
  737. GROUP BY sd.building_id <if test="sysId != null">,sd.sys_id</if>
  738. ) temp on (sb.id = temp.building_id)
  739. left join sc_access_unit sau on sau.id = sb.access_unit_id and sau.status = 1
  740. left join sc_area sa1 on sa1.id = sb.province
  741. left join sc_area sa2 on sa2.id = sb.city
  742. left join sc_area sa3 on sa3.id = sb.region
  743. left join sc_community sc on sc.id = sb.community
  744. where sb.status = 1
  745. <if test="siteId != null"> and sb.site_id = #{siteId}</if>
  746. <if test="sysId != null"> and temp.sys_id = #{sysId} </if>
  747. <if test="buildingName != null and buildingName != ''"> AND sb.name LIKE concat('%',#{buildingName},'%')</if>
  748. <if test="province != null"> AND sb.province = #{province}</if>
  749. <if test="city != null"> AND sb.city = #{city}</if>
  750. <if test="region != null"> AND sb.region = #{region}</if>
  751. <if test="community != null"> AND sb.community = #{community}</if>
  752. <if test="customerIds != null and customerIds.size() != 0">
  753. and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
  754. </if>
  755. order by sb.create_date desc
  756. </select>
  757. <!--自定义设备列表分页-->
  758. <!--<select id="getBuildingList_COUNT" resultType="Long">
  759. select
  760. count(1)
  761. from sc_building sb
  762. where sb.status = 1
  763. <if test="siteId != null"> and sb.site_id = #{siteId}</if>
  764. <if test="sysId != null"> and sb.id in(
  765. SELECT sd.building_id FROM sc_device sd
  766. WHERE sd.status = 1
  767. <if test="sysId != null"> and sd.sys_id = #{sysId}</if>
  768. <if test="siteId != null"> and sd.site_id = #{siteId}</if>
  769. <if test="buildingIds != null and buildingIds.size() != 0"> and sd.building_id in <foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item}</foreach> </if>
  770. GROUP BY sd.building_id
  771. )</if>
  772. <if test="buildingName != null and buildingName != ''"> AND sb.name LIKE concat('%',#{buildingName},'%')</if>
  773. <if test="province != null"> AND sb.province = #{province}</if>
  774. <if test="city != null"> AND sb.city = #{city}</if>
  775. <if test="region != null"> AND sb.region = #{region}</if>
  776. </select>-->
  777. <select id="getBuildingListV2" resultType="com.bz.smart_city.dto.BuildingInfoListDto">
  778. select
  779. sb.id as building_id,
  780. sb.name as building_name,
  781. sb.address ,
  782. sau.fire_resp_name,
  783. sau.fire_resp_phone,
  784. sb.province,
  785. sb.city,
  786. sb.region,
  787. sb.community,
  788. sa1.name as province_name,
  789. sa2.name as city_name,
  790. sa3.name as region_name,
  791. sc.name as community_name,
  792. sb.latitude,
  793. sb.longitude,
  794. IFNULL((SELECT 1 as device_count
  795. from sc_device sd
  796. <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>
  797. WHERE sd.status = 1 and sd.building_id = sb.id
  798. <if test="programItems != null and programItems.size() != 0"> and
  799. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  800. sdd.${item.dimensionCode} = #{item.dimensionValue}
  801. </foreach>
  802. </if>
  803. limit 1),0) as device_count
  804. from sc_building sb
  805. left join sc_access_unit sau on sau.id = sb.access_unit_id and sau.status = 1
  806. left join sc_area sa1 on sa1.id = sb.province
  807. left join sc_area sa2 on sa2.id = sb.city
  808. left join sc_area sa3 on sa3.id = sb.region
  809. left join sc_community sc on sc.id = sb.community
  810. where sb.status = 1
  811. <if test="siteId != null"> and sb.site_id = #{siteId}</if>
  812. <if test="sysId != null"> and temp.sys_id = #{sysId} </if>
  813. <if test="buildingName != null and buildingName != ''"> AND sb.name LIKE concat('%',#{buildingName},'%')</if>
  814. <if test="province != null"> AND sb.province = #{province}</if>
  815. <if test="city != null"> AND sb.city = #{city}</if>
  816. <if test="region != null"> AND sb.region = #{region}</if>
  817. <if test="community != null"> AND sb.community = #{community}</if>
  818. <if test="customerIds != null and customerIds.size() != 0">
  819. and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
  820. </if>
  821. order by sb.create_date desc,sb.id desc
  822. </select>
  823. <select id="queryFloor" resultType="com.bz.smart_city.dto.FloorDto">
  824. select
  825. sbf.floor_no as floor,
  826. (select count(1) from sc_device sd where sd.status = 1 and sd.building_id = sbf.building and sd.floor = sbf.floor_no
  827. <if test="sysId != null"> and sd.sys_id=#{sysId} </if>
  828. and (sd.device_status = 2 or sd.device_status = 3)) as abnormal_count
  829. from sc_building_floor sbf
  830. where sbf.status = 1 and sbf.building = #{buildingId} order by sbf.floor_no desc
  831. </select>
  832. <select id="deleteQuery" resultType="int">
  833. select count(1) from sc_device where status = 1 and building_id = #{buildingId}
  834. </select>
  835. <select id="getBuilding" resultType="com.bz.smart_city.dto.BuildingDto">
  836. select
  837. sb.*,
  838. sau.name as access_unit_name,
  839. sa1.name as province_name,
  840. sa2.name as city_name,
  841. sa3.name as region_name,
  842. sc.name as community_name
  843. from sc_building sb
  844. left join sc_access_unit sau on (sau.id = sb.access_unit_id and sau.status = 1)
  845. left join sc_area sa1 on (sa1.id = sb.province)
  846. left join sc_area sa2 on (sa2.id = sb.city)
  847. left join sc_area sa3 on (sa3.id = sb.region)
  848. left join sc_community sc on (sc.id = sb.community)
  849. where sb.status = 1 and sb.id = #{buildingId}
  850. </select>
  851. <update id="deleteBySiteId">
  852. update sc_building set status = 0,update_date=now(),update_by=#{updateBy} where status = 1 and site_id = #{siteId}
  853. </update>
  854. <select id="getBuildingBySiteId" resultType="com.bz.smart_city.dto.BuildingDto">
  855. select
  856. b.id as id,
  857. b.`name` as name,
  858. b.province as province,
  859. p.short_name as province_name,
  860. b.city as city,
  861. c.short_name as city_name,
  862. b.region as region,
  863. r.short_name as region_name
  864. from sc_building b left join sc_area p on ( b.province = p.id)
  865. left join sc_area c on (b.city = c.id)
  866. left join sc_area r on (b.region = c.id)
  867. where site_id = #{siteId};
  868. </select>
  869. <select id="queryTest1" resultType = "com.bz.smart_city.dto.Test">
  870. select * from sc_building_import where status = '1' ;
  871. </select>
  872. <update id="updateTest1">
  873. update sc_building_import set lat = #{param.lat,jdbcType=VARCHAR},
  874. lng = #{param.lng,jdbcType=VARCHAR},
  875. status = #{param.status,jdbcType=VARCHAR}
  876. where 1 = 1
  877. and building = #{param.building,jdbcType=VARCHAR}
  878. and community = #{param.community,jdbcType=VARCHAR}
  879. </update>
  880. <select id="queryTest2" resultType = "com.bz.smart_city.dto.Test">
  881. select * from t2_test where 1 = 1
  882. <if test="name != null and name != '' ">
  883. and name like #{name,jdbcType=VARCHAR}
  884. </if>
  885. </select>
  886. <update id="updateTest2">
  887. update t2_test set address = #{param.address,jdbcType=VARCHAR},
  888. province = #{param.province,jdbcType=VARCHAR},
  889. city = #{param.city,jdbcType=VARCHAR},
  890. region = #{param.region,jdbcType=VARCHAR},
  891. lat = #{param.lat,jdbcType=VARCHAR},
  892. lag = #{param.lag,jdbcType=VARCHAR}
  893. where name = #{param.name,jdbcType=VARCHAR}
  894. </update>
  895. <select id="findByBuildingName" resultMap="BaseResultMap">
  896. select * from sc_building where status = 1 and name = #{buildingName}
  897. </select>
  898. <select id="getBuildingStatistics" resultType="com.bz.smart_city.dto.BuildingInfoListDto">
  899. select
  900. sb.id as building_id,
  901. sb.name as building_name,
  902. sb.address ,
  903. sb.province,
  904. sb.city,
  905. sb.region,
  906. sb.community,
  907. sa1.name as province_name,
  908. sa2.name as city_name,
  909. sa3.name as region_name,
  910. sc.name as community_name,
  911. sb.latitude,
  912. sb.longitude,
  913. temp.device_count,
  914. temp.normal_count,
  915. temp.alarm_count,
  916. temp.fault_count,
  917. temp.offline_count,
  918. temp.device_unused_count
  919. from sc_building sb
  920. LEFT JOIN(
  921. SELECT
  922. sd.building_id,
  923. <if test="sysId != null">sd.sys_id,</if>
  924. count(1) as device_count,
  925. SUM(IF(sd.device_status = 1, 1, 0)) as normal_count,
  926. SUM(IF(sd.device_status = 2, 1, 0)) as alarm_count,
  927. SUM(IF(sd.device_status = 3, 1, 0)) as fault_count,
  928. SUM(IF(sd.device_status = 4, 1, 0)) as offline_count,
  929. SUM(IF(sd.device_status = 5, 1, 0)) as device_unused_count
  930. from sc_device sd
  931. <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>
  932. WHERE sd.status = 1 and sd.sys_id != -99
  933. <if test="siteList != null and siteList.size() != 0"> and sd.site_id in <foreach collection="siteList" item="item" open="(" separator="," close=")">#{item}</foreach></if>
  934. <if test="programItems != null and programItems.size() != 0"> and
  935. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  936. sdd.${item.dimensionCode} = #{item.dimensionValue}
  937. </foreach>
  938. </if>
  939. GROUP BY sd.building_id <if test="sysId != null">,sd.sys_id</if>
  940. ) temp on (sb.id = temp.building_id)
  941. left join sc_area sa1 on sa1.id = sb.province
  942. left join sc_area sa2 on sa2.id = sb.city
  943. left join sc_area sa3 on sa3.id = sb.region
  944. left join sc_community sc on sc.id = sb.community
  945. where sb.status = 1
  946. <if test="sysId != null"> and temp.sys_id = #{sysId} </if>
  947. <if test="siteList != null and siteList.size() != 0"> and sb.site_id in <foreach collection="siteList" item="item" open="(" separator="," close=")">#{item}</foreach></if>
  948. <if test="buildingId != null"> and sb.id = #{buildingId} </if>
  949. <if test="buildingName != null and buildingName != ''"> AND sb.name LIKE concat('%',#{buildingName},'%')</if>
  950. <if test="province != null"> AND sb.province = #{province}</if>
  951. <if test="city != null"> AND sb.city = #{city}</if>
  952. <if test="region != null"> AND sb.region = #{region}</if>
  953. <if test="community != null"> AND sb.community = #{community}</if>
  954. <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>
  955. <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>
  956. <if test="customerIds != null and customerIds.size() != 0">
  957. and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
  958. </if>
  959. order by sb.update_date desc
  960. </select>
  961. <select id="getList" resultType="com.bz.smart_city.dto.BuildingDto">
  962. select
  963. sb.id,
  964. sb.name,
  965. sb.address,
  966. sb.province,
  967. sb.city,
  968. sb.region,
  969. sb.community,
  970. sb.longitude,
  971. sb.latitude,
  972. sa1.name as province_name,
  973. sa2.name as city_name,
  974. sa3.name as region_name,
  975. sc.name as community_name
  976. from sc_building sb
  977. left join sc_area sa1 on sb.province =sa1.id
  978. left join sc_area sa2 on sb.city=sa2.id
  979. left join sc_area sa3 on sb.region=sa3.id
  980. left join sc_community sc on sc.id=sb.community
  981. where sb.status = 1
  982. <if test="siteId != null"> and sb.site_id =#{siteId} </if>
  983. <if test="buildingName != null and buildingName != ''"> AND sb.name LIKE concat('%',#{buildingName},'%')</if>
  984. <if test="customerIds != null and customerIds.size() != 0">
  985. and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
  986. </if>
  987. </select>
  988. <select id="getBuildingByDeviceId" resultMap="BaseResultMap">
  989. select
  990. sb.*,
  991. sau.name as access_unit_name,
  992. sa1.name as province_name,
  993. sa2.name as city_name,
  994. sa3.name as region_name
  995. from sc_building sb
  996. left join sc_access_unit sau on (sau.id = sb.access_unit_id and sau.status = 1)
  997. left join sc_area sa1 on (sa1.id = sb.province)
  998. left join sc_area sa2 on (sa2.id = sb.city)
  999. left join sc_area sa3 on (sa3.id = sb.region)
  1000. 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
  1001. </select>
  1002. <select id="getIdsByDataPermission" resultType="java.lang.Integer">
  1003. select c.id
  1004. from
  1005. sc_building c
  1006. where c.status = 1
  1007. <if test="siteList != null and siteList.size() != 0"> and c.site_id in <foreach collection="siteList" item="item" open="(" separator="," close=")">#{item}</foreach></if>
  1008. <if test="programItems != null and programItems.size() != 0">
  1009. and <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  1010. <if test = 'item.dimensionCode == "PROVINCE" '>
  1011. c.province = #{item.dimensionValue}
  1012. </if>
  1013. <if test = 'item.dimensionCode == "CITY" '>
  1014. c.city = #{item.dimensionValue}
  1015. </if>
  1016. <if test = 'item.dimensionCode == "REGION" '>
  1017. c.region = #{item.dimensionValue}
  1018. </if>
  1019. <if test = 'item.dimensionCode == "COMMUNITY" '>
  1020. c.community = #{item.dimensionValue}
  1021. </if>
  1022. <if test = 'item.dimensionCode == "BUILDING" '>
  1023. c.id = #{item.dimensionValue}
  1024. </if>
  1025. <if test = 'item.dimensionCode == "CUSTOMER" '>
  1026. c.id = -1
  1027. </if>
  1028. </foreach>
  1029. </if>
  1030. </select>
  1031. <select id="findByName" resultMap="BaseResultMap">
  1032. select <include refid="Base_Column_List"></include> from sc_building where status = 1 and site_id = #{siteId} and name = #{buildingName}
  1033. </select>
  1034. <select id="findByNameV2" resultMap="BaseResultMap">
  1035. 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>
  1036. </select>
  1037. <select id="findByIds" resultType="com.bz.smart_city.entity.Building">
  1038. select <include refid="Base_Column_List"></include> from sc_building where status = 1
  1039. and id in <foreach collection="ids" item="item" open="(" separator="," close=")">#{item}</foreach>
  1040. </select>
  1041. <select id="deviceCountAreaList" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
  1042. select
  1043. b.id,
  1044. b.name,
  1045. b.province,
  1046. b.city,
  1047. b.region,
  1048. b.community,
  1049. b.longitude,
  1050. b.latitude,
  1051. t1.device_count
  1052. from sc_building b
  1053. right join (
  1054. select sd.building_id,count(1) as device_count
  1055. from sc_device sd
  1056. <if test=" (valveStatus != null)">left join sc_device_type sdt on (sdt.id = sd.device_type and sdt.status = 1)</if>
  1057. <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>
  1058. <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>
  1059. <if test="concentratorNo != null and concentratorNo != ''">left join sc_concentrator scon on ( scon.id = swrd.concentrator_id and scon.status = 1)</if>
  1060. <if test="collectorNo != null and collectorNo != ''">left join sc_collector scol on ( scol.id = swrd.collector_id)</if>
  1061. <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>
  1062. <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>
  1063. where sd.status = 1 and sys_id <![CDATA[ <> ]]> -99
  1064. <!--and sd.site_id = 1-->
  1065. <if test="sysId != null"> AND sd.sys_id = #{sysId}</if>
  1066. <if test="buildingId != null"> AND sd.building_id = #{buildingId}</if>
  1067. <if test="siteId != null"> AND sd.site_id = #{siteId}</if>
  1068. <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>
  1069. <if test="status != null"> AND sd.device_status = #{status}</if>
  1070. <if test="deviceTypeId != null"> AND sd.device_type = #{deviceTypeId}</if>
  1071. <if test="floor != null"> AND sd.floor = #{floor}</if>
  1072. <if test="locDesc != null and locDesc != ''"> AND sd.loc_desc LIKE concat('%',#{locDesc},'%')</if>
  1073. <if test="province != null"> and sb.province = #{province}</if>
  1074. <if test="city != null"> and sb.city = #{city}</if>
  1075. <if test="region != null"> and sb.region = #{region}</if>
  1076. <if test="community != null"> and sb.community = #{community}</if>
  1077. <if test="concentratorId != null"> and swrd.concentrator_id = #{concentratorId}</if>
  1078. <if test="concentratorNo != null and concentratorNo != ''"> AND scon.serial_number LIKE concat('%',#{concentratorNo},'%')</if>
  1079. <if test="collectorId != null"> and swrd.collector_id = #{collectorId}</if>
  1080. <if test="collectorNo != null and collectorNo != ''"> AND scol.collector_no LIKE concat('%',#{collectorNo},'%')</if>
  1081. <if test="channelNumberId != null"> and swrd.channel_number_id = #{channelNumberId}</if>
  1082. <if test="errorType != null and errorType != ''"> AND swmed.last_error_type LIKE concat('%',#{errorType},'%')</if>
  1083. <if test="customerId != null"> and sd.customer_id = #{customerId}</if>
  1084. <if test="days != null"> and swmed.days = #{days} </if>
  1085. <if test="startReading != null"> and swmed.meter_reading >= #{startReading} </if>
  1086. <if test="endReading != null"> and swmed.meter_reading <![CDATA[ <= ]]> #{endReading} </if>
  1087. <if test="valveStatus != null and valveStatus == 0"> and swmed.valve_status = #{valveStatus} and sdt.is_valve = 1</if>
  1088. <if test="valveStatus != null and valveStatus == 1"> and (swmed.valve_status = #{valveStatus} or swmed.valve_status is null ) and sdt.is_valve = 1</if>
  1089. <if test="valveStatus != null and valveStatus == 2"> and sdt.is_valve = 0</if>
  1090. <if test="registerStatus != null"> and sd.register_status = #{registerStatus} </if>
  1091. <if test="issueStatus != null"> and swrd.issue_status = #{issueStatus} </if>
  1092. <if test="syncStatus != null"> and sd.sync_status = #{syncStatus} </if>
  1093. <if test="programItems != null and programItems.size() != 0"> and
  1094. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  1095. sdd.${item.dimensionCode} = #{item.dimensionValue}
  1096. </foreach>
  1097. </if>
  1098. GROUP BY sd.building_id
  1099. ) t1 on (t1.building_id = b.id)
  1100. where b.status = 1
  1101. <if test="siteId != null"> and b.site_id=#{siteId} </if>
  1102. <if test="programItems != null and programItems.size() != 0">
  1103. and b.id in (
  1104. select sd.building_id
  1105. from sc_device sd
  1106. <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>
  1107. where sd.status = 1 and sys_id != -99
  1108. <if test="sysId != null"> AND sd.sys_id = #{sysId}</if>
  1109. <if test="siteId != null"> AND sd.site_id = #{siteId}</if>
  1110. <if test="programItems != null and programItems.size() != 0"> and
  1111. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  1112. sdd.${item.dimensionCode} = #{item.dimensionValue}
  1113. </foreach>
  1114. </if>
  1115. GROUP BY sd.building_id
  1116. )
  1117. </if>
  1118. </select>
  1119. <select id="abnormalAreaBuildingList" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
  1120. select
  1121. b.id,
  1122. b.name,
  1123. b.province,
  1124. b.city,
  1125. b.region,
  1126. b.community,
  1127. b.longitude,
  1128. b.latitude,
  1129. t1.device_count
  1130. from sc_building b
  1131. left join (
  1132. select sde.building_id,count(1) as device_count
  1133. from sc_device_error sde
  1134. <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>
  1135. <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>
  1136. <if test="equipmentId != null">left join sc_device_type sdt on sdt.id = sd.device_type</if>
  1137. <if test="measuringId != null"> left join sc_alarm_measuring_data samd on (samd.status = 1 and samd.alarm_id = sde.id ) </if>
  1138. <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>
  1139. where sde.status = 1
  1140. <if test="handleStatus != null"> and sde.handle_status = #{handleStatus} </if>
  1141. <if test="sysId != null"> and sde.sys_id = #{sysId}</if>
  1142. <if test="buildingId != null"> and sde.building_id = #{buildingId}</if>
  1143. <if test="floor != null"> and sde.floor = #{floor}</if>
  1144. <if test="measuringId != null"> and samd.measuring_id = #{measuringId}</if>
  1145. <if test="deviceId != null"> and sde.device_id = #{deviceId} </if>
  1146. <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>
  1147. <if test="location != null and location != ''"> and sde.location LIKE concat('%',#{location},'%')</if>
  1148. <if test="alarmCategory != null"> and sde.alarm_category = #{alarmCategory}</if>
  1149. <if test="alarmTypeId != null"> and sde.alarm_type_id = #{alarmTypeId}</if>
  1150. <if test="equipmentId != null"> and sdt.id = #{equipmentId} </if>
  1151. <if test="manufacturerId != null"> and sd.manufacturer_id = #{manufacturerId} </if>
  1152. <if test="customerId != null"> and sd.customer_id = #{customerId} </if>
  1153. <if test="province != null"> and sb.province = #{province} </if>
  1154. <if test="city != null"> and sb.city = #{city} </if>
  1155. <if test="region != null"> and sb.region = #{region} </if>
  1156. <if test="communityId != null"> and sb.community = #{communityId} </if>
  1157. <if test="startDate != null"> and sde.alarm_time <![CDATA[ >= ]]> #{startDate}</if>
  1158. <if test="endDate != null"> and sde.alarm_time <![CDATA[ <= ]]> #{endDate}</if>
  1159. <if test="programItems != null and programItems.size() != 0"> and
  1160. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  1161. sdd.${item.dimensionCode} = #{item.dimensionValue}
  1162. </foreach>
  1163. </if>
  1164. GROUP BY sde.building_id
  1165. ) t1 on (t1.building_id = b.id)
  1166. where b.status = 1
  1167. <if test="siteId != null"> and b.site_id=#{siteId} </if>
  1168. <if test="programItems != null and programItems.size() != 0">
  1169. and b.id in (
  1170. select sd.building_id
  1171. from sc_device sd
  1172. <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>
  1173. where sd.status = 1 and sys_id != -99
  1174. <if test="sysId != null"> AND sd.sys_id = #{sysId}</if>
  1175. <if test="siteId != null"> AND sd.site_id = #{siteId}</if>
  1176. <if test="programItems != null and programItems.size() != 0"> and
  1177. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  1178. sdd.${item.dimensionCode} = #{item.dimensionValue}
  1179. </foreach>
  1180. </if>
  1181. GROUP BY sd.building_id
  1182. )
  1183. </if>
  1184. </select>
  1185. <select id="installAreaList" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
  1186. select
  1187. b.id,
  1188. b.name,
  1189. b.province,
  1190. b.city,
  1191. b.region,
  1192. b.community,
  1193. b.longitude,
  1194. b.latitude,
  1195. t1.device_count
  1196. from sc_building b
  1197. right join (
  1198. select sd.building_id,count(1) as device_count
  1199. from sc_device sd
  1200. <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>
  1201. <if test="errorType != null and errorType != ''">left join sc_water_meter_error_days swmed on ( swmed.device_id = sd.id)</if>
  1202. <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>
  1203. <if test="registerStatus != null"> left join sc_device_type sdt on (sdt.id = sd.device_type)</if>
  1204. <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)
  1205. left join sc_concentrator scon on ( scon.id = swrd.concentrator_id and scon.status = 1)
  1206. left join sc_collector scol on ( scol.id = swrd.collector_id)</if>
  1207. left join sc_install_list sil on (sil.device_id = sd.id)
  1208. where sd.status = 1 and sd.sys_id = -99 and sil.status = 1
  1209. <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>
  1210. <if test="buildingId != null"> AND sd.building_id = #{buildingId}</if>
  1211. <if test="siteId != null"> AND sd.site_id = #{siteId}</if>
  1212. <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>
  1213. <if test="status != null"> AND sd.device_status = #{status}</if>
  1214. <if test="province != null"> and sb.province = #{province}</if>
  1215. <if test="city != null"> and sb.city = #{city}</if>
  1216. <if test="region != null"> and sb.region = #{region}</if>
  1217. <if test="community != null"> and sb.community = #{community}</if>
  1218. <if test="errorType != null and errorType != ''"> AND swmed.last_error_type LIKE concat('%',#{errorType},'%')</if>
  1219. <if test="locDesc != null and locDesc != ''"> AND sd.loc_desc LIKE concat('%',#{locDesc},'%')</if>
  1220. <if test="deviceTypeId != null"> and sd.device_type = #{deviceTypeId}</if>
  1221. <if test="registerStatus != null and registerStatus == 1"> and sd.register_status = #{registerStatus} and sdt.is_register = 1</if>
  1222. <if test="registerStatus != null and registerStatus == 0"> and sd.register_status = #{registerStatus} and sdt.is_register = 1</if>
  1223. <if test="issueStatus != null"> and swrd.issue_status = #{issueStatus}</if>
  1224. <if test="concentratorId != null"> AND swrd.concentrator_id = #{concentratorId}</if>
  1225. <if test="channelNumberId != null"> AND swrd.channel_number_id = #{channelNumberId}</if>
  1226. <if test="collectorNo != null and collectorNo != ''"> AND scol.collector_no LIKE concat('%',#{collectorNo},'%')</if>
  1227. <if test="customerId != null"> and sd.customer_id = #{customerId}</if>
  1228. <if test="startDate != null"> and sil.install_time <![CDATA[ >= ]]> #{startDate}</if>
  1229. <if test="endDate != null"> and sil.install_time <![CDATA[ <= ]]> #{endDate}</if>
  1230. <if test="programItems != null and programItems.size() != 0"> and
  1231. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  1232. sdd.${item.dimensionCode} = #{item.dimensionValue}
  1233. </foreach>
  1234. </if>
  1235. GROUP BY sd.building_id
  1236. ) t1 on (t1.building_id = b.id)
  1237. where b.status = 1
  1238. <if test="siteId != null"> and b.site_id=#{siteId} </if>
  1239. <if test="programItems != null and programItems.size() != 0">
  1240. and b.id in (
  1241. select sd.building_id
  1242. from sc_device sd
  1243. <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>
  1244. where sd.status = 1 and sys_id = -99
  1245. <if test="siteId != null"> AND sd.site_id = #{siteId}</if>
  1246. <if test="programItems != null and programItems.size() != 0"> and
  1247. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  1248. sdd.${item.dimensionCode} = #{item.dimensionValue}
  1249. </foreach>
  1250. </if>
  1251. GROUP BY sd.building_id
  1252. )
  1253. </if>
  1254. </select>
  1255. <select id="getBuildingByInstallPlanId" resultMap="BaseResultMap">
  1256. select
  1257. sb.*,
  1258. sau.name as access_unit_name,
  1259. sa1.name as province_name,
  1260. sa2.name as city_name,
  1261. sa3.name as region_name,
  1262. sc.name as community_name
  1263. from sc_building sb
  1264. left join sc_access_unit sau on (sau.id = sb.access_unit_id and sau.status = 1)
  1265. left join sc_area sa1 on (sa1.id = sb.province)
  1266. left join sc_area sa2 on (sa2.id = sb.city)
  1267. left join sc_area sa3 on (sa3.id = sb.region)
  1268. left join sc_community sc on (sc.id = sb.community)
  1269. where sb.status = 1 and sb.id in (
  1270. select sil.building_id from sc_install_list sil where sil.status = 1 and sil.install_plan_id = #{installPlanId} group by sil.building_id
  1271. )
  1272. </select>
  1273. <select id="countBycCommunityId" resultType="int">
  1274. select count(1) from sc_building where status = 1 and community = #{communityId}
  1275. </select>
  1276. <select id="findByNameUnique" resultType="int">
  1277. select count(1) from sc_building where status = 1 and name = #{name} and site_id = #{siteId} and community = #{community}
  1278. <if test="id != null"> and id != #{id}</if>
  1279. </select>
  1280. <select id="obtainBuildingInformationOnTheIntegratedMap"
  1281. resultType="com.bz.smart_city.dto.BuildingInfoListDto">
  1282. select
  1283. sb.id as building_id,
  1284. sb.name as building_name,
  1285. sb.address ,
  1286. sb.province,
  1287. sb.city,
  1288. sb.region,
  1289. sb.community,
  1290. sa1.name as province_name,
  1291. sa2.name as city_name,
  1292. sa3.name as region_name,
  1293. sc.name as community_name,
  1294. sb.latitude,
  1295. sb.longitude,
  1296. temp.device_count,
  1297. temp.normal_count,
  1298. temp.alarm_count,
  1299. temp.fault_count,
  1300. temp.offline_count,
  1301. temp.device_unused_count
  1302. from sc_building sb
  1303. JOIN(
  1304. SELECT
  1305. sd.building_id,
  1306. count(1) as device_count,
  1307. SUM(IF(sd.device_status = 1, 1, 0)) as normal_count,
  1308. SUM(IF(sd.device_status = 2, 1, 0)) as alarm_count,
  1309. SUM(IF(sd.device_status = 3, 1, 0)) as fault_count,
  1310. SUM(IF(sd.device_status = 4, 1, 0)) as offline_count,
  1311. SUM(IF(sd.device_status = 5, 1, 0)) as device_unused_count
  1312. from sc_device sd
  1313. <if test="programItems != null and programItems.size() != 0">
  1314. left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
  1315. WHERE sd.status = 1 and sd.sys_id != -99
  1316. <if test="programItems != null and programItems.size() != 0"> and
  1317. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  1318. sdd.${item.dimensionCode} = #{item.dimensionValue}
  1319. </foreach>
  1320. </if>
  1321. GROUP BY sd.building_id
  1322. ) temp on (sb.id = temp.building_id)
  1323. left join sc_area sa1 on sa1.id = sb.province
  1324. left join sc_area sa2 on sa2.id = sb.city
  1325. left join sc_area sa3 on sa3.id = sb.region
  1326. left join sc_community sc on sc.id = sb.community
  1327. where sb.status = 1
  1328. <if test=" longitudeMin != 0 and longitudeMax != 0"> and sb.longitude > #{longitudeMin} AND sb.longitude <![CDATA[ < ]]> #{longitudeMax} </if>
  1329. <if test=" latitudeMin != 0 and latitudeMax != 0"> and sb.latitude > #{latitudeMin} AND sb.latitude <![CDATA[ < ]]> #{latitudeMax} </if>
  1330. </select>
  1331. </mapper>