HtAnalogDataMapper.xml 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469
  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.bizmatics.persistence.mapper.HtAnalogDataMapper">
  4. <select id="selectByEndTime" resultType="com.bizmatics.model.HtAnalogData">
  5. select had.id,deviceName,Busot,COS,COSa,COSb,COSc,Demand,DevResetTimes,DeviceTemp,Epn,Epn1,Epn2,Epn3,Epn4,Epp,
  6. Epp1,Epp2,Epp3,Epp4,Eqn,Eqp,F,I0,I2,IHa,IHb,IHc,Ia,Ib,Ic,Ir,LastDayMD,LastDayMDt,P,Pa,Pb,Pc,Q,Qa,Qb,Qc,SignalIntensity,
  7. T1,T2,T3,T4,THDUa,THDUb,THDUc,Ua,Uab,Ub,Ubc,UblU0,UblU2,Uc,Uca,Udt,Ul,Upt,Ust,freezingTime,dataTime
  8. from user_site as us
  9. inner join device as d
  10. on us.site_id = d.site_id
  11. inner join ht_analog_data as had
  12. on d.device_code = had.deviceName
  13. <where>
  14. <if test="userId != null and userId != 0">
  15. and us.user_id = #{userId}
  16. </if>
  17. <if test="siteId != null and siteId != 0">
  18. and us.site_id = #{siteId}
  19. </if>
  20. <if test="endTime != null and startTime != null">
  21. and dataTime BETWEEN #{startTime} and #{endTime}
  22. </if>
  23. </where>
  24. order by had.id desc limit 0,1
  25. </select>
  26. <select id="selectByStartTime" resultType="com.bizmatics.model.HtAnalogData">
  27. select had.id,deviceName,Busot,COS,COSa,COSb,COSc,Demand,DevResetTimes,DeviceTemp,Epn,Epn1,Epn2,Epn3,Epn4,Epp,
  28. Epp1,Epp2,Epp3,Epp4,Eqn,Eqp,F,I0,I2,IHa,IHb,IHc,Ia,Ib,Ic,Ir,LastDayMD,LastDayMDt,P,Pa,Pb,Pc,Q,Qa,Qb,Qc,SignalIntensity,
  29. T1,T2,T3,T4,THDUa,THDUb,THDUc,Ua,Uab,Ub,Ubc,UblU0,UblU2,Uc,Uca,Udt,Ul,Upt,Ust,freezingTime,dataTime
  30. from user_site as us
  31. inner join device as d
  32. on us.site_id = d.site_id
  33. inner join ht_analog_data as had
  34. on d.device_code = had.deviceName
  35. <where>
  36. <if test="userId != null and userId != 0">
  37. and us.user_id = #{userId}
  38. </if>
  39. <if test="siteId != null and siteId != 0">
  40. and us.site_id = #{siteId}
  41. </if>
  42. <if test="endTime != null and startTime != null">
  43. and dataTime BETWEEN #{startTime} and #{endTime}
  44. </if>
  45. </where>
  46. order by had.id asc limit 0,1
  47. </select>
  48. <select id="selectMaxAndMinAndAvg" resultType="java.util.Map">
  49. select max(Demand) as demandMax,min(Demand) as demandMin,avg(Demand) as demandAvg,
  50. max(Epp) as eppMax,min(Epp) as eppMin,avg(Epp) as eppAvg
  51. from device as d
  52. inner join ht_analog_data as had
  53. on d.device_code = had.deviceName
  54. <where>
  55. <if test="siteId != null and siteId != 0">
  56. and d.site_id = #{siteId}
  57. </if>
  58. <if test="endTime != null and startTime != null">
  59. and dataTime BETWEEN #{startTime} and #{endTime}
  60. </if>
  61. </where>
  62. </select>
  63. <select id="list" resultType="com.bizmatics.model.HtAnalogData">
  64. select max(Epp),min(Epp)
  65. from
  66. ht_analog_data
  67. <where>
  68. <if test="deviceCode != null and deviceCode != ''">
  69. and deviceName = #{deviceCode}
  70. </if>
  71. <if test="endTime != null and startTime != null">
  72. and dataTime BETWEEN #{startTime} and #{endTime}
  73. </if>
  74. </where>
  75. </select>
  76. <select id="page" resultType="com.bizmatics.model.HtAnalogData">
  77. select
  78. had.id,deviceName,Busot,COS,COSa,COSb,COSc,Demand,DevResetTimes,DeviceTemp,Epn,Epn1,Epn2,Epn3,Epn4,Epp,
  79. Epp1,Epp2,Epp3,Epp4,Eqn,Eqp,F,I0,I2,IHa,IHb,IHc,Ia,Ib,Ic,Ir,LastDayMD,LastDayMDt,P,Pa,Pb,Pc,Q,Qa,Qb,Qc,SignalIntensity,
  80. T1,T2,T3,T4,THDUa,THDUb,THDUc,Ua,Uab,Ub,Ubc,UblU0,UblU2,Uc,Uca,Udt,Ul,Upt,Ust,freezingTime,dataTime,d.site_id as
  81. siteId
  82. from ht_analog_data as had
  83. left join device as d
  84. on had.deviceName = d.device_code
  85. <where>
  86. <if test="endTime != null and startTime != null">
  87. and dataTime BETWEEN #{startTime} and #{endTime}
  88. </if>
  89. </where>
  90. order by had.id asc
  91. limit #{current},#{size}
  92. </select>
  93. <select id="getDateList" resultType="java.util.Map">
  94. select d.site_id as siteId,date(had.dataTime) as dat
  95. FROM
  96. ht_analog_data as had
  97. INNER JOIN device as d
  98. on had.deviceName = d.device_code
  99. <where>
  100. <if test="endTime != null and startTime != null">
  101. and had.dataTime BETWEEN #{startTime} and #{endTime}
  102. </if>
  103. </where>
  104. GROUP BY d.site_id,dat
  105. </select>
  106. <select id="selectCount" resultType="java.lang.Double">
  107. select
  108. IFNULL(sum(had.epp),0)
  109. from device as d
  110. inner join ht_analog_data as had
  111. on d.device_code = had.deviceName
  112. <where>
  113. <if test="siteId != null and siteId != 0">
  114. and d.site_id = #{siteId}
  115. </if>
  116. <if test="endTime != null and startTime != null">
  117. and dataTime BETWEEN #{startTime} and #{endTime}
  118. </if>
  119. </where>
  120. </select>
  121. <select id="yearOnYearOne" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  122. SELECT
  123. a.id,
  124. a.deviceName,
  125. AVG(a.Busot) AS Busot,
  126. AVG(a.COS) AS COS,
  127. AVG(a.COSa) AS COSa,
  128. AVG(a.COSb) AS COSb,
  129. AVG(a.COSc) AS COSc,
  130. AVG(a.Demand) AS Demand,
  131. AVG(a.DevResetTimes) AS DevResetTimes,
  132. AVG(a.DeviceTemp) AS DeviceTemp,
  133. AVG(a.Epn) AS Epn,
  134. AVG(a.Epn1) AS Epn1,
  135. AVG(a.Epn2) AS Epn2,
  136. AVG(a.Epn3) AS Epn3,
  137. AVG(a.Epn4) AS Epn4,
  138. AVG(a.Epp) AS Epp,
  139. AVG(a.Epp1) AS Epp1,
  140. AVG(a.Epp2) AS Epp2,
  141. AVG(a.Epp3) AS Epp3,
  142. AVG(a.Epp4) AS Epp4,
  143. AVG(a.Eqn) AS Eqn,
  144. AVG(a.Eqp) AS Eqp,
  145. AVG(a.F) AS F,
  146. AVG(a.I0) AS I0,
  147. AVG(a.I2) AS I2,
  148. AVG(a.IHa) AS IHa,
  149. AVG(a.IHb) AS IHb,
  150. AVG(a.IHc) AS IHc,
  151. AVG(a.Ia) AS Ia,
  152. AVG(a.Ib) AS Ib,
  153. AVG(a.Ic) AS Ic,
  154. AVG(a.Ir) AS Ir,
  155. AVG(a.LastDayMD) AS LastDayMD,
  156. AVG(a.LastDayMDt) AS LastDayMDt,
  157. AVG(a.P) AS P,
  158. AVG(a.Pa) AS Pa,
  159. AVG(a.Pb) AS Pb,
  160. AVG(a.Pc) AS Pc,
  161. AVG(a.Q) AS Q,
  162. AVG(a.Qa) AS Qa,
  163. AVG(a.Qb) AS Qb,
  164. AVG(a.Qc) AS Qc,
  165. AVG(a.SignalIntensity) AS SignalIntensity,
  166. AVG(a.T1) AS T1,
  167. AVG(a.T2) AS T2,
  168. AVG(a.T3) AS T3,
  169. AVG(a.T4) AS T4,
  170. AVG(a.THDUa) AS THDUa,
  171. AVG(a.THDUb) AS THDUb,
  172. AVG(a.THDUc) AS THDUc,
  173. AVG(a.Ua) AS Ua,
  174. AVG(a.Uab) AS Uab,
  175. AVG(a.Ub) AS Ub,
  176. AVG(a.Ubc) AS Ubc,
  177. AVG(a.UblU0) AS UblU0,
  178. AVG(a.UblU2) AS UblU2,
  179. AVG(a.Uc) AS Uc,
  180. AVG(a.Uca) AS Uca,
  181. AVG(a.Udt) AS Udt,
  182. AVG(a.Ul) AS Ul,
  183. AVG(a.Upt) AS Upt,
  184. AVG(a.Ust) AS Ust,
  185. FROM_UNIXTIME(
  186. UNIX_TIMESTAMP(a.dataTime),
  187. '%Y-%m-%d'
  188. ) AS freezingTimes,
  189. a.dataTime,
  190. d.monitor_device_name,
  191. d.id as device_attribute_id
  192. FROM
  193. ht_analog_data AS a
  194. JOIN device_analog_variable_list AS c ON a.deviceName = c.device_code
  195. JOIN device_attribute AS d ON c.monitoring_equipment = d.id
  196. <where>
  197. and a.deviceName IN
  198. <foreach item="item" collection="deviceCode" open="(" separator="," close=")">
  199. #{item.displayField}
  200. </foreach>
  201. AND c.variable_coding in
  202. <foreach item="item" collection="variableCoding" open="(" separator="," close=")">
  203. #{item.variableCoding}
  204. </foreach>
  205. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  206. and a.dataTime BETWEEN #{startTime} and #{endTime}
  207. </if>
  208. </where>
  209. GROUP BY freezingTimes,a.deviceName
  210. </select>
  211. <select id="dayMaxDataList" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  212. SELECT
  213. a.id,
  214. a.deviceName,
  215. max(a.Busot) AS Busot,
  216. max(a.COS) AS COS,
  217. max(a.COSa) AS COSa,
  218. max(a.COSb) AS COSb,
  219. max(a.COSc) AS COSc,
  220. max(a.Demand) AS Demand,
  221. max(a.DevResetTimes) AS DevResetTimes,
  222. max(a.DeviceTemp) AS DeviceTemp,
  223. max(a.Epn) AS Epn,
  224. max(a.Epn1) AS Epn1,
  225. max(a.Epn2) AS Epn2,
  226. max(a.Epn3) AS Epn3,
  227. max(a.Epn4) AS Epn4,
  228. max(a.Epp) AS Epp,
  229. max(a.Epp1) AS Epp1,
  230. max(a.Epp2) AS Epp2,
  231. max(a.Epp3) AS Epp3,
  232. max(a.Epp4) AS Epp4,
  233. max(a.Eqn) AS Eqn,
  234. max(a.Eqp) AS Eqp,
  235. max(a.F) AS F,
  236. max(a.I0) AS I0,
  237. max(a.I2) AS I2,
  238. max(a.IHa) AS IHa,
  239. max(a.IHb) AS IHb,
  240. max(a.IHc) AS IHc,
  241. max(a.Ia) AS Ia,
  242. max(a.Ib) AS Ib,
  243. max(a.Ic) AS Ic,
  244. max(a.Ir) AS Ir,
  245. max(a.LastDayMD) AS LastDayMD,
  246. max(a.LastDayMDt) AS LastDayMDt,
  247. max(a.P) AS P,
  248. max(a.Pa) AS Pa,
  249. max(a.Pb) AS Pb,
  250. max(a.Pc) AS Pc,
  251. max(a.Q) AS Q,
  252. max(a.Qa) AS Qa,
  253. max(a.Qb) AS Qb,
  254. max(a.Qc) AS Qc,
  255. max(a.SignalIntensity) AS SignalIntensity,
  256. max(a.T1) AS T1,
  257. max(a.T2) AS T2,
  258. max(a.T3) AS T3,
  259. max(a.T4) AS T4,
  260. max(a.THDUa) AS THDUa,
  261. max(a.THDUb) AS THDUb,
  262. max(a.THDUc) AS THDUc,
  263. max(a.Ua) AS Ua,
  264. max(a.Uab) AS Uab,
  265. max(a.Ub) AS Ub,
  266. max(a.Ubc) AS Ubc,
  267. max(a.UblU0) AS UblU0,
  268. max(a.UblU2) AS UblU2,
  269. max(a.Uc) AS Uc,
  270. max(a.Uca) AS Uca,
  271. max(a.Udt) AS Udt,
  272. max(a.Ul) AS Ul,
  273. max(a.Upt) AS Upt,
  274. max(a.Ust) AS Ust,
  275. FROM_UNIXTIME(
  276. UNIX_TIMESTAMP(a.dataTime),
  277. '%Y-%m-%d'
  278. ) AS freezingTimes,
  279. a.dataTime,
  280. d.monitor_device_name,
  281. d.id as device_attribute_id
  282. FROM
  283. ht_analog_data AS a
  284. JOIN device_analog_variable_list AS c ON a.deviceName = c.device_code
  285. JOIN device_attribute AS d ON c.monitoring_equipment = d.id
  286. <where>
  287. a.deviceName IN
  288. <foreach item="item" collection="deviceCode" open="(" separator="," close=")">
  289. #{item.displayField}
  290. </foreach>
  291. AND c.variable_coding in
  292. <foreach item="item" collection="variableCoding" open="(" separator="," close=")">
  293. #{item.variableCoding}
  294. </foreach>
  295. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  296. and a.dataTime BETWEEN #{startTime} and #{endTime}
  297. </if>
  298. </where>
  299. GROUP BY a.freezingTime,
  300. a.deviceName
  301. </select>
  302. <select id="dayMinDataList" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  303. SELECT
  304. a.id,
  305. a.deviceName,
  306. min(a.Busot) AS Busot,
  307. min(a.COS) AS COS,
  308. min(a.COSa) AS COSa,
  309. min(a.COSb) AS COSb,
  310. min(a.COSc) AS COSc,
  311. min(a.Demand) AS Demand,
  312. min(a.DevResetTimes) AS DevResetTimes,
  313. min(a.DeviceTemp) AS DeviceTemp,
  314. min(a.Epn) AS Epn,
  315. min(a.Epn1) AS Epn1,
  316. min(a.Epn2) AS Epn2,
  317. min(a.Epn3) AS Epn3,
  318. min(a.Epn4) AS Epn4,
  319. min(a.Epp) AS Epp,
  320. min(a.Epp1) AS Epp1,
  321. min(a.Epp2) AS Epp2,
  322. min(a.Epp3) AS Epp3,
  323. min(a.Epp4) AS Epp4,
  324. min(a.Eqn) AS Eqn,
  325. min(a.Eqp) AS Eqp,
  326. min(a.F) AS F,
  327. min(a.I0) AS I0,
  328. min(a.I2) AS I2,
  329. min(a.IHa) AS IHa,
  330. min(a.IHb) AS IHb,
  331. min(a.IHc) AS IHc,
  332. min(a.Ia) AS Ia,
  333. min(a.Ib) AS Ib,
  334. min(a.Ic) AS Ic,
  335. min(a.Ir) AS Ir,
  336. min(a.LastDayMD) AS LastDayMD,
  337. min(a.LastDayMDt) AS LastDayMDt,
  338. min(a.P) AS P,
  339. min(a.Pa) AS Pa,
  340. min(a.Pb) AS Pb,
  341. min(a.Pc) AS Pc,
  342. min(a.Q) AS Q,
  343. min(a.Qa) AS Qa,
  344. min(a.Qb) AS Qb,
  345. min(a.Qc) AS Qc,
  346. min(a.SignalIntensity) AS SignalIntensity,
  347. min(a.T1) AS T1,
  348. min(a.T2) AS T2,
  349. min(a.T3) AS T3,
  350. min(a.T4) AS T4,
  351. min(a.THDUa) AS THDUa,
  352. min(a.THDUb) AS THDUb,
  353. min(a.THDUc) AS THDUc,
  354. min(a.Ua) AS Ua,
  355. min(a.Uab) AS Uab,
  356. min(a.Ub) AS Ub,
  357. min(a.Ubc) AS Ubc,
  358. min(a.UblU0) AS UblU0,
  359. min(a.UblU2) AS UblU2,
  360. min(a.Uc) AS Uc,
  361. min(a.Uca) AS Uca,
  362. min(a.Udt) AS Udt,
  363. min(a.Ul) AS Ul,
  364. min(a.Upt) AS Upt,
  365. min(a.Ust) AS Ust,
  366. FROM_UNIXTIME(
  367. UNIX_TIMESTAMP(a.dataTime),
  368. '%Y-%m-%d'
  369. ) AS freezingTimes,
  370. a.dataTime,
  371. d.monitor_device_name,
  372. d.id as device_attribute_id
  373. FROM
  374. ht_analog_data AS a
  375. JOIN device_analog_variable_list AS c ON a.deviceName = c.device_code
  376. JOIN device_attribute AS d ON c.monitoring_equipment = d.id
  377. <where>
  378. and a.deviceName IN
  379. <foreach item="item" collection="deviceCode" open="(" separator="," close=")">
  380. #{item.displayField}
  381. </foreach>
  382. AND c.variable_coding in
  383. <foreach item="item" collection="variableCoding" open="(" separator="," close=")">
  384. #{item.variableCoding}
  385. </foreach>
  386. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  387. and a.dataTime BETWEEN #{startTime} and #{endTime}
  388. </if>
  389. </where>
  390. GROUP BY a.freezingTime,a.deviceName
  391. </select>
  392. <select id="daySumDataList" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  393. SELECT
  394. a.id,
  395. a.deviceName,
  396. sum(a.Busot) AS Busot,
  397. sum(a.COS) AS COS,
  398. sum(a.COSa) AS COSa,
  399. sum(a.COSb) AS COSb,
  400. sum(a.COSc) AS COSc,
  401. sum(a.Demand) AS Demand,
  402. sum(a.DevResetTimes) AS DevResetTimes,
  403. sum(a.DeviceTemp) AS DeviceTemp,
  404. sum(a.Epn) AS Epn,
  405. sum(a.Epn1) AS Epn1,
  406. sum(a.Epn2) AS Epn2,
  407. sum(a.Epn3) AS Epn3,
  408. sum(a.Epn4) AS Epn4,
  409. sum(a.Epp) AS Epp,
  410. sum(a.Epp1) AS Epp1,
  411. sum(a.Epp2) AS Epp2,
  412. sum(a.Epp3) AS Epp3,
  413. sum(a.Epp4) AS Epp4,
  414. sum(a.Eqn) AS Eqn,
  415. sum(a.Eqp) AS Eqp,
  416. sum(a.F) AS F,
  417. sum(a.I0) AS I0,
  418. sum(a.I2) AS I2,
  419. sum(a.IHa) AS IHa,
  420. sum(a.IHb) AS IHb,
  421. sum(a.IHc) AS IHc,
  422. sum(a.Ia) AS Ia,
  423. sum(a.Ib) AS Ib,
  424. sum(a.Ic) AS Ic,
  425. sum(a.Ir) AS Ir,
  426. sum(a.LastDayMD) AS LastDayMD,
  427. sum(a.LastDayMDt) AS LastDayMDt,
  428. sum(a.P) AS P,
  429. sum(a.Pa) AS Pa,
  430. sum(a.Pb) AS Pb,
  431. sum(a.Pc) AS Pc,
  432. sum(a.Q) AS Q,
  433. sum(a.Qa) AS Qa,
  434. sum(a.Qb) AS Qb,
  435. sum(a.Qc) AS Qc,
  436. sum(a.SignalIntensity) AS SignalIntensity,
  437. sum(a.T1) AS T1,
  438. sum(a.T2) AS T2,
  439. sum(a.T3) AS T3,
  440. sum(a.T4) AS T4,
  441. sum(a.THDUa) AS THDUa,
  442. sum(a.THDUb) AS THDUb,
  443. sum(a.THDUc) AS THDUc,
  444. sum(a.Ua) AS Ua,
  445. sum(a.Uab) AS Uab,
  446. sum(a.Ub) AS Ub,
  447. sum(a.Ubc) AS Ubc,
  448. sum(a.UblU0) AS UblU0,
  449. sum(a.UblU2) AS UblU2,
  450. sum(a.Uc) AS Uc,
  451. sum(a.Uca) AS Uca,
  452. sum(a.Udt) AS Udt,
  453. sum(a.Ul) AS Ul,
  454. sum(a.Upt) AS Upt,
  455. sum(a.Ust) AS Ust,
  456. FROM_UNIXTIME(
  457. UNIX_TIMESTAMP(a.dataTime),
  458. '%Y-%m-%d'
  459. ) AS freezingTimes,
  460. a.dataTime,
  461. d.monitor_device_name,
  462. d.id as device_attribute_id
  463. FROM
  464. ht_analog_data AS a
  465. JOIN device_analog_variable_list AS c ON a.deviceName = c.device_code
  466. JOIN device_attribute AS d ON c.monitoring_equipment = d.id
  467. <where>
  468. and a.deviceName in
  469. <foreach item="item" collection="deviceCode" open="(" separator="," close=")">
  470. #{item.displayField}
  471. </foreach>
  472. AND c.variable_coding in
  473. <foreach item="item" collection="variableCoding" open="(" separator="," close=")">
  474. #{item.variableCoding}
  475. </foreach>
  476. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  477. and a.dataTime BETWEEN #{startTime} and #{endTime}
  478. </if>
  479. </where>
  480. GROUP BY a.freezingTime,a.deviceName
  481. </select>
  482. <select id="yearOnYearTwo" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  483. SELECT
  484. a.id,
  485. a.deviceName,
  486. AVG(a.Busot) AS Busot,
  487. AVG(a.COS) AS COS,
  488. AVG(a.COSa) AS COSa,
  489. AVG(a.COSb) AS COSb,
  490. AVG(a.COSc) AS COSc,
  491. AVG(a.Demand) AS Demand,
  492. AVG(a.DevResetTimes) AS DevResetTimes,
  493. AVG(a.DeviceTemp) AS DeviceTemp,
  494. AVG(a.Epn) AS Epn,
  495. AVG(a.Epn1) AS Epn1,
  496. AVG(a.Epn2) AS Epn2,
  497. AVG(a.Epn3) AS Epn3,
  498. AVG(a.Epn4) AS Epn4,
  499. AVG(a.Epp) AS Epp,
  500. AVG(a.Epp1) AS Epp1,
  501. AVG(a.Epp2) AS Epp2,
  502. AVG(a.Epp3) AS Epp3,
  503. AVG(a.Epp4) AS Epp4,
  504. AVG(a.Eqn) AS Eqn,
  505. AVG(a.Eqp) AS Eqp,
  506. AVG(a.F) AS F,
  507. AVG(a.I0) AS I0,
  508. AVG(a.I2) AS I2,
  509. AVG(a.IHa) AS IHa,
  510. AVG(a.IHb) AS IHb,
  511. AVG(a.IHc) AS IHc,
  512. AVG(a.Ia) AS Ia,
  513. AVG(a.Ib) AS Ib,
  514. AVG(a.Ic) AS Ic,
  515. AVG(a.Ir) AS Ir,
  516. AVG(a.LastDayMD) AS LastDayMD,
  517. AVG(a.LastDayMDt) AS LastDayMDt,
  518. AVG(a.P) AS P,
  519. AVG(a.Pa) AS Pa,
  520. AVG(a.Pb) AS Pb,
  521. AVG(a.Pc) AS Pc,
  522. AVG(a.Q) AS Q,
  523. AVG(a.Qa) AS Qa,
  524. AVG(a.Qb) AS Qb,
  525. AVG(a.Qc) AS Qc,
  526. AVG(a.SignalIntensity) AS SignalIntensity,
  527. AVG(a.T1) AS T1,
  528. AVG(a.T2) AS T2,
  529. AVG(a.T3) AS T3,
  530. AVG(a.T4) AS T4,
  531. AVG(a.THDUa) AS THDUa,
  532. AVG(a.THDUb) AS THDUb,
  533. AVG(a.THDUc) AS THDUc,
  534. AVG(a.Ua) AS Ua,
  535. AVG(a.Uab) AS Uab,
  536. AVG(a.Ub) AS Ub,
  537. AVG(a.Ubc) AS Ubc,
  538. AVG(a.UblU0) AS UblU0,
  539. AVG(a.UblU2) AS UblU2,
  540. AVG(a.Uc) AS Uc,
  541. AVG(a.Uca) AS Uca,
  542. AVG(a.Udt) AS Udt,
  543. AVG(a.Ul) AS Ul,
  544. AVG(a.Upt) AS Upt,
  545. AVG(a.Ust) AS Ust,
  546. FROM_UNIXTIME(
  547. UNIX_TIMESTAMP(a.dataTime),
  548. '%Y-%m'
  549. ) AS freezingTimes,
  550. a.dataTime,
  551. d.monitor_device_name,
  552. d.id as device_attribute_id
  553. FROM
  554. ht_analog_data AS a
  555. JOIN device_analog_variable_list AS c ON a.deviceName = c.device_code
  556. JOIN device_attribute AS d ON c.monitoring_equipment = d.id
  557. <where>
  558. and a.deviceName in
  559. <foreach item="item" collection="deviceCode" open="(" separator="," close=")">
  560. #{item.displayField}
  561. </foreach>
  562. AND c.variable_coding in
  563. <foreach item="item" collection="variableCoding" open="(" separator="," close=")">
  564. #{item.variableCoding}
  565. </foreach>
  566. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  567. and a.dataTime BETWEEN #{startTime} and #{endTime}
  568. </if>
  569. </where>
  570. GROUP BY freezingTimes,a.deviceName
  571. </select>
  572. <select id="monthMaxDataList" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  573. SELECT
  574. a.id,
  575. a.deviceName,
  576. max(a.Busot) AS Busot,
  577. max(a.COS) AS COS,
  578. max(a.COSa) AS COSa,
  579. max(a.COSb) AS COSb,
  580. max(a.COSc) AS COSc,
  581. max(a.Demand) AS Demand,
  582. max(a.DevResetTimes) AS DevResetTimes,
  583. max(a.DeviceTemp) AS DeviceTemp,
  584. max(a.Epn) AS Epn,
  585. max(a.Epn1) AS Epn1,
  586. max(a.Epn2) AS Epn2,
  587. max(a.Epn3) AS Epn3,
  588. max(a.Epn4) AS Epn4,
  589. max(a.Epp) AS Epp,
  590. max(a.Epp1) AS Epp1,
  591. max(a.Epp2) AS Epp2,
  592. max(a.Epp3) AS Epp3,
  593. max(a.Epp4) AS Epp4,
  594. max(a.Eqn) AS Eqn,
  595. max(a.Eqp) AS Eqp,
  596. max(a.F) AS F,
  597. max(a.I0) AS I0,
  598. max(a.I2) AS I2,
  599. max(a.IHa) AS IHa,
  600. max(a.IHb) AS IHb,
  601. max(a.IHc) AS IHc,
  602. max(a.Ia) AS Ia,
  603. max(a.Ib) AS Ib,
  604. max(a.Ic) AS Ic,
  605. max(a.Ir) AS Ir,
  606. max(a.LastDayMD) AS LastDayMD,
  607. max(a.LastDayMDt) AS LastDayMDt,
  608. max(a.P) AS P,
  609. max(a.Pa) AS Pa,
  610. max(a.Pb) AS Pb,
  611. max(a.Pc) AS Pc,
  612. max(a.Q) AS Q,
  613. max(a.Qa) AS Qa,
  614. max(a.Qb) AS Qb,
  615. max(a.Qc) AS Qc,
  616. max(a.SignalIntensity) AS SignalIntensity,
  617. max(a.T1) AS T1,
  618. max(a.T2) AS T2,
  619. max(a.T3) AS T3,
  620. max(a.T4) AS T4,
  621. max(a.THDUa) AS THDUa,
  622. max(a.THDUb) AS THDUb,
  623. max(a.THDUc) AS THDUc,
  624. max(a.Ua) AS Ua,
  625. max(a.Uab) AS Uab,
  626. max(a.Ub) AS Ub,
  627. max(a.Ubc) AS Ubc,
  628. max(a.UblU0) AS UblU0,
  629. max(a.UblU2) AS UblU2,
  630. max(a.Uc) AS Uc,
  631. max(a.Uca) AS Uca,
  632. max(a.Udt) AS Udt,
  633. max(a.Ul) AS Ul,
  634. max(a.Upt) AS Upt,
  635. max(a.Ust) AS Ust,
  636. FROM_UNIXTIME(
  637. UNIX_TIMESTAMP(a.dataTime),
  638. '%Y-%m'
  639. ) AS freezingTimes,
  640. a.dataTime,
  641. d.monitor_device_name,
  642. d.id as device_attribute_id
  643. FROM
  644. ht_analog_data AS a
  645. JOIN device_analog_variable_list AS c ON a.deviceName = c.device_code
  646. JOIN device_attribute AS d ON c.monitoring_equipment = d.id
  647. <where>
  648. and a.deviceName in
  649. <foreach item="item" collection="deviceCode" open="(" separator="," close=")">
  650. #{item.displayField}
  651. </foreach>
  652. AND c.variable_coding in
  653. <foreach item="item" collection="variableCoding" open="(" separator="," close=")">
  654. #{item.variableCoding}
  655. </foreach>
  656. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  657. and a.dataTime BETWEEN #{startTime} and #{endTime}
  658. </if>
  659. </where>
  660. GROUP BY freezingTimes,a.deviceName
  661. </select>
  662. <select id="monthMinDataList" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  663. SELECT
  664. a.id,
  665. a.deviceName,
  666. min(a.Busot) AS Busot,
  667. min(a.COS) AS COS,
  668. min(a.COSa) AS COSa,
  669. min(a.COSb) AS COSb,
  670. min(a.COSc) AS COSc,
  671. min(a.Demand) AS Demand,
  672. min(a.DevResetTimes) AS DevResetTimes,
  673. min(a.DeviceTemp) AS DeviceTemp,
  674. min(a.Epn) AS Epn,
  675. min(a.Epn1) AS Epn1,
  676. min(a.Epn2) AS Epn2,
  677. min(a.Epn3) AS Epn3,
  678. min(a.Epn4) AS Epn4,
  679. min(a.Epp) AS Epp,
  680. min(a.Epp1) AS Epp1,
  681. min(a.Epp2) AS Epp2,
  682. min(a.Epp3) AS Epp3,
  683. min(a.Epp4) AS Epp4,
  684. min(a.Eqn) AS Eqn,
  685. min(a.Eqp) AS Eqp,
  686. min(a.F) AS F,
  687. min(a.I0) AS I0,
  688. min(a.I2) AS I2,
  689. min(a.IHa) AS IHa,
  690. min(a.IHb) AS IHb,
  691. min(a.IHc) AS IHc,
  692. min(a.Ia) AS Ia,
  693. min(a.Ib) AS Ib,
  694. min(a.Ic) AS Ic,
  695. min(a.Ir) AS Ir,
  696. min(a.LastDayMD) AS LastDayMD,
  697. min(a.LastDayMDt) AS LastDayMDt,
  698. min(a.P) AS P,
  699. min(a.Pa) AS Pa,
  700. min(a.Pb) AS Pb,
  701. min(a.Pc) AS Pc,
  702. min(a.Q) AS Q,
  703. min(a.Qa) AS Qa,
  704. min(a.Qb) AS Qb,
  705. min(a.Qc) AS Qc,
  706. min(a.SignalIntensity) AS SignalIntensity,
  707. min(a.T1) AS T1,
  708. min(a.T2) AS T2,
  709. min(a.T3) AS T3,
  710. min(a.T4) AS T4,
  711. min(a.THDUa) AS THDUa,
  712. min(a.THDUb) AS THDUb,
  713. min(a.THDUc) AS THDUc,
  714. min(a.Ua) AS Ua,
  715. min(a.Uab) AS Uab,
  716. min(a.Ub) AS Ub,
  717. min(a.Ubc) AS Ubc,
  718. min(a.UblU0) AS UblU0,
  719. min(a.UblU2) AS UblU2,
  720. min(a.Uc) AS Uc,
  721. min(a.Uca) AS Uca,
  722. min(a.Udt) AS Udt,
  723. min(a.Ul) AS Ul,
  724. min(a.Upt) AS Upt,
  725. min(a.Ust) AS Ust,
  726. FROM_UNIXTIME(
  727. UNIX_TIMESTAMP(a.dataTime),
  728. '%Y-%m'
  729. ) AS freezingTimes,
  730. a.dataTime,
  731. d.monitor_device_name,
  732. d.id as device_attribute_id
  733. FROM
  734. ht_analog_data AS a
  735. JOIN device_analog_variable_list AS c ON a.deviceName = c.device_code
  736. JOIN device_attribute AS d ON c.monitoring_equipment = d.id
  737. <where>
  738. and a.deviceName in
  739. <foreach item="item" collection="deviceCode" open="(" separator="," close=")">
  740. #{item.displayField}
  741. </foreach>
  742. AND c.variable_coding in
  743. <foreach item="item" collection="variableCoding" open="(" separator="," close=")">
  744. #{item.variableCoding}
  745. </foreach>
  746. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  747. and a.dataTime BETWEEN #{startTime} and #{endTime}
  748. </if>
  749. </where>
  750. GROUP BY freezingTimes,a.deviceName
  751. </select>
  752. <select id="monthSumDataList" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  753. SELECT
  754. a.id,
  755. a.deviceName,
  756. sum(a.Busot) AS Busot,
  757. sum(a.COS) AS COS,
  758. sum(a.COSa) AS COSa,
  759. sum(a.COSb) AS COSb,
  760. sum(a.COSc) AS COSc,
  761. sum(a.Demand) AS Demand,
  762. sum(a.DevResetTimes) AS DevResetTimes,
  763. sum(a.DeviceTemp) AS DeviceTemp,
  764. sum(a.Epn) AS Epn,
  765. sum(a.Epn1) AS Epn1,
  766. sum(a.Epn2) AS Epn2,
  767. sum(a.Epn3) AS Epn3,
  768. sum(a.Epn4) AS Epn4,
  769. sum(a.Epp) AS Epp,
  770. sum(a.Epp1) AS Epp1,
  771. sum(a.Epp2) AS Epp2,
  772. sum(a.Epp3) AS Epp3,
  773. sum(a.Epp4) AS Epp4,
  774. sum(a.Eqn) AS Eqn,
  775. sum(a.Eqp) AS Eqp,
  776. sum(a.F) AS F,
  777. sum(a.I0) AS I0,
  778. sum(a.I2) AS I2,
  779. sum(a.IHa) AS IHa,
  780. sum(a.IHb) AS IHb,
  781. sum(a.IHc) AS IHc,
  782. sum(a.Ia) AS Ia,
  783. sum(a.Ib) AS Ib,
  784. sum(a.Ic) AS Ic,
  785. sum(a.Ir) AS Ir,
  786. sum(a.LastDayMD) AS LastDayMD,
  787. sum(a.LastDayMDt) AS LastDayMDt,
  788. sum(a.P) AS P,
  789. sum(a.Pa) AS Pa,
  790. sum(a.Pb) AS Pb,
  791. sum(a.Pc) AS Pc,
  792. sum(a.Q) AS Q,
  793. sum(a.Qa) AS Qa,
  794. sum(a.Qb) AS Qb,
  795. sum(a.Qc) AS Qc,
  796. sum(a.SignalIntensity) AS SignalIntensity,
  797. sum(a.T1) AS T1,
  798. sum(a.T2) AS T2,
  799. sum(a.T3) AS T3,
  800. sum(a.T4) AS T4,
  801. sum(a.THDUa) AS THDUa,
  802. sum(a.THDUb) AS THDUb,
  803. sum(a.THDUc) AS THDUc,
  804. sum(a.Ua) AS Ua,
  805. sum(a.Uab) AS Uab,
  806. sum(a.Ub) AS Ub,
  807. sum(a.Ubc) AS Ubc,
  808. sum(a.UblU0) AS UblU0,
  809. sum(a.UblU2) AS UblU2,
  810. sum(a.Uc) AS Uc,
  811. sum(a.Uca) AS Uca,
  812. sum(a.Udt) AS Udt,
  813. sum(a.Ul) AS Ul,
  814. sum(a.Upt) AS Upt,
  815. sum(a.Ust) AS Ust,
  816. FROM_UNIXTIME(
  817. UNIX_TIMESTAMP(a.dataTime),
  818. '%Y-%m'
  819. ) AS freezingTimes,
  820. a.dataTime,
  821. d.monitor_device_name,
  822. d.id as device_attribute_id
  823. FROM
  824. ht_analog_data AS a
  825. JOIN device_analog_variable_list AS c ON a.deviceName = c.device_code
  826. JOIN device_attribute AS d ON c.monitoring_equipment = d.id
  827. <where>
  828. and a.deviceName in
  829. <foreach item="item" collection="deviceCode" open="(" separator="," close=")">
  830. #{item.displayField}
  831. </foreach>
  832. AND c.variable_coding in
  833. <foreach item="item" collection="variableCoding" open="(" separator="," close=")">
  834. #{item.variableCoding}
  835. </foreach>
  836. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  837. and a.dataTime BETWEEN #{startTime} and #{endTime}
  838. </if>
  839. </where>
  840. GROUP BY freezingTimes,a.deviceName
  841. </select>
  842. <select id="energyUseList" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  843. <if test="cycle == 1">
  844. SELECT
  845. b.id,
  846. a.minid,
  847. b.Epp,
  848. b.Demand,
  849. freezingTime AS freezingTimes
  850. FROM
  851. (
  852. <if test="sign == 1">
  853. SELECT
  854. max(id) AS minid,
  855. freezingTime AS freezingTimess
  856. </if>
  857. <if test="sign == 2">
  858. SELECT
  859. min(id) AS minid,
  860. freezingTime AS freezingTimess
  861. </if>
  862. FROM
  863. ht_analog_data
  864. <where>
  865. and deviceName = #{deviceCode}
  866. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  867. and dataTime BETWEEN #{startTime} and #{endTime}
  868. </if>
  869. </where>
  870. GROUP BY freezingTimess
  871. ) a
  872. LEFT JOIN ht_analog_data b ON a.minid = b.id;
  873. </if>
  874. <if test="cycle == 2">
  875. SELECT
  876. b.id,
  877. a.minid,
  878. b.Epp,
  879. b.Demand,
  880. FROM_UNIXTIME(
  881. UNIX_TIMESTAMP(b.dataTime),
  882. '%Y-%m'
  883. ) AS freezingTimes
  884. FROM
  885. (
  886. <if test="sign == 1">
  887. SELECT
  888. max(id) AS minid,
  889. FROM_UNIXTIME(
  890. UNIX_TIMESTAMP(dataTime),
  891. '%Y-%m'
  892. ) AS freezingTimess
  893. </if>
  894. <if test="sign == 2">
  895. SELECT
  896. min(id) AS minid,
  897. FROM_UNIXTIME(
  898. UNIX_TIMESTAMP(dataTime),
  899. '%Y-%m'
  900. ) AS freezingTimess
  901. </if>
  902. FROM
  903. ht_analog_data
  904. <where>
  905. and deviceName = #{deviceCode}
  906. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  907. and dataTime BETWEEN #{startTime} and #{endTime}
  908. </if>
  909. </where>
  910. GROUP BY freezingTimess
  911. ) a
  912. LEFT JOIN ht_analog_data b ON a.minid = b.id;
  913. </if>
  914. <if test="cycle == 3">
  915. SELECT
  916. b.id,
  917. a.minid,
  918. b.Epp,
  919. b.Demand,
  920. FROM_UNIXTIME(
  921. UNIX_TIMESTAMP(b.dataTime),
  922. '%Y-%m'
  923. ) AS freezingTimes
  924. FROM
  925. (
  926. <if test="sign == 1">
  927. SELECT
  928. max(id) AS minid,
  929. FROM_UNIXTIME(
  930. UNIX_TIMESTAMP(dataTime),
  931. '%Y'
  932. ) AS freezingTimess
  933. </if>
  934. <if test="sign == 2">
  935. SELECT
  936. min(id) AS minid,
  937. FROM_UNIXTIME(
  938. UNIX_TIMESTAMP(dataTime),
  939. '%Y'
  940. ) AS freezingTimess
  941. </if>
  942. FROM
  943. ht_analog_data
  944. <where>
  945. and deviceName = #{deviceCode}
  946. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  947. and dataTime BETWEEN #{startTime} and #{endTime}
  948. </if>
  949. </where>
  950. GROUP BY freezingTimess
  951. ) a
  952. LEFT JOIN ht_analog_data b ON a.minid = b.id;
  953. </if>
  954. </select>
  955. <select id="getEnergyUseList" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  956. <if test="cycle == 1">
  957. SELECT
  958. b.id,
  959. a.minid,
  960. b.Epp,
  961. b.Demand,
  962. freezingTime AS freezingTimes
  963. FROM
  964. (
  965. <if test="sign == 1">
  966. SELECT
  967. max(id) AS minid,
  968. freezingTime AS freezingTimess
  969. </if>
  970. <if test="sign == 2">
  971. SELECT
  972. min(id) AS minid,
  973. freezingTime AS freezingTimess
  974. </if>
  975. FROM
  976. ${table}
  977. <where>
  978. and deviceName = #{deviceCode}
  979. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  980. and dataTime BETWEEN #{startTime} and #{endTime}
  981. </if>
  982. </where>
  983. GROUP BY freezingTimess
  984. ) a
  985. LEFT JOIN ${table} b ON a.minid = b.id;
  986. </if>
  987. <if test="cycle == 2">
  988. SELECT
  989. b.id,
  990. a.minid,
  991. b.Epp,
  992. b.Demand,
  993. FROM_UNIXTIME(
  994. UNIX_TIMESTAMP(b.dataTime),
  995. '%Y-%m'
  996. ) AS freezingTimes
  997. FROM
  998. (
  999. <if test="sign == 1">
  1000. SELECT
  1001. max(id) AS minid,
  1002. FROM_UNIXTIME(
  1003. UNIX_TIMESTAMP(dataTime),
  1004. '%Y-%m'
  1005. ) AS freezingTimess
  1006. </if>
  1007. <if test="sign == 2">
  1008. SELECT
  1009. min(id) AS minid,
  1010. FROM_UNIXTIME(
  1011. UNIX_TIMESTAMP(dataTime),
  1012. '%Y-%m'
  1013. ) AS freezingTimess
  1014. </if>
  1015. FROM
  1016. ${table}
  1017. <where>
  1018. and deviceName = #{deviceCode}
  1019. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  1020. and dataTime BETWEEN #{startTime} and #{endTime}
  1021. </if>
  1022. </where>
  1023. GROUP BY freezingTimess
  1024. ) a
  1025. LEFT JOIN ${table} b ON a.minid = b.id;
  1026. </if>
  1027. <if test="cycle == 3">
  1028. SELECT
  1029. b.id,
  1030. a.minid,
  1031. b.Epp,
  1032. b.Demand,
  1033. FROM_UNIXTIME(
  1034. UNIX_TIMESTAMP(b.dataTime),
  1035. '%Y-%m'
  1036. ) AS freezingTimes
  1037. FROM
  1038. (
  1039. <if test="sign == 1">
  1040. SELECT
  1041. max(id) AS minid,
  1042. FROM_UNIXTIME(
  1043. UNIX_TIMESTAMP(dataTime),
  1044. '%Y'
  1045. ) AS freezingTimess
  1046. </if>
  1047. <if test="sign == 2">
  1048. SELECT
  1049. min(id) AS minid,
  1050. FROM_UNIXTIME(
  1051. UNIX_TIMESTAMP(dataTime),
  1052. '%Y'
  1053. ) AS freezingTimess
  1054. </if>
  1055. FROM
  1056. ${table}
  1057. <where>
  1058. and deviceName = #{deviceCode}
  1059. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  1060. and dataTime BETWEEN #{startTime} and #{endTime}
  1061. </if>
  1062. </where>
  1063. GROUP BY freezingTimess
  1064. ) a
  1065. LEFT JOIN ${table} b ON a.minid = b.id;
  1066. </if>
  1067. </select>
  1068. <select id="energyUseListOne" resultType="com.bizmatics.model.vo.HtAnalogDataOneVo">
  1069. <if test="cycle == 1">
  1070. SELECT
  1071. b.id,
  1072. b.Epp,
  1073. freezingTime AS freezingTime
  1074. FROM
  1075. (
  1076. <if test="sign == 1">
  1077. SELECT
  1078. max(id) AS minid,
  1079. freezingTime AS freezingTimess
  1080. </if>
  1081. <if test="sign == 2">
  1082. SELECT
  1083. min(id) AS minid,
  1084. freezingTime AS freezingTimess
  1085. </if>
  1086. FROM
  1087. ht_analog_data
  1088. <where>
  1089. and deviceName = #{deviceCode}
  1090. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  1091. and dataTime BETWEEN #{startTime} and #{endTime}
  1092. </if>
  1093. </where>
  1094. GROUP BY freezingTimess
  1095. ) a
  1096. LEFT JOIN ht_analog_data b ON a.minid = b.id
  1097. <if test="startCurrent != null and size !=0 and size!=null">
  1098. LIMIT #{startCurrent},
  1099. #{size}
  1100. </if>
  1101. </if>
  1102. <if test="cycle == 2">
  1103. SELECT
  1104. b.id,
  1105. b.Epp,
  1106. FROM_UNIXTIME(
  1107. UNIX_TIMESTAMP(b.dataTime),
  1108. '%Y-%m'
  1109. ) AS freezingTime
  1110. FROM
  1111. (
  1112. <if test="sign == 1">
  1113. SELECT
  1114. max(id) AS minid,
  1115. FROM_UNIXTIME(
  1116. UNIX_TIMESTAMP(dataTime),
  1117. '%Y-%m'
  1118. ) AS freezingTimess
  1119. </if>
  1120. <if test="sign == 2">
  1121. SELECT
  1122. min(id) AS minid,
  1123. FROM_UNIXTIME(
  1124. UNIX_TIMESTAMP(dataTime),
  1125. '%Y-%m'
  1126. ) AS freezingTimess
  1127. </if>
  1128. FROM
  1129. ht_analog_data
  1130. <where>
  1131. and deviceName = #{deviceCode}
  1132. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  1133. and dataTime BETWEEN #{startTime} and #{endTime}
  1134. </if>
  1135. </where>
  1136. GROUP BY freezingTimess
  1137. ) a
  1138. LEFT JOIN ht_analog_data b ON a.minid = b.id
  1139. <if test="startCurrent != null and size !=0 and size!=null">
  1140. LIMIT #{startCurrent},
  1141. #{size}
  1142. </if>
  1143. </if>
  1144. <if test="cycle == 3">
  1145. SELECT
  1146. b.id,
  1147. b.Epp,
  1148. FROM_UNIXTIME(
  1149. UNIX_TIMESTAMP(b.dataTime),
  1150. '%Y-%m'
  1151. ) AS freezingTime
  1152. FROM
  1153. (
  1154. <if test="sign == 1">
  1155. SELECT
  1156. max(id) AS minid,
  1157. FROM_UNIXTIME(
  1158. UNIX_TIMESTAMP(dataTime),
  1159. '%Y'
  1160. ) AS freezingTimess
  1161. </if>
  1162. <if test="sign == 2">
  1163. SELECT
  1164. min(id) AS minid,
  1165. FROM_UNIXTIME(
  1166. UNIX_TIMESTAMP(dataTime),
  1167. '%Y'
  1168. ) AS freezingTimess
  1169. </if>
  1170. FROM
  1171. ht_analog_data
  1172. <where>
  1173. and deviceName = #{deviceCode}
  1174. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  1175. and dataTime BETWEEN #{startTime} and #{endTime}
  1176. </if>
  1177. </where>
  1178. GROUP BY freezingTimess
  1179. ) a
  1180. LEFT JOIN ht_analog_data b ON a.minid = b.id
  1181. <if test="startCurrent != null and size !=0 and size!=null">
  1182. LIMIT #{startCurrent},
  1183. #{size}
  1184. </if>
  1185. </if>
  1186. </select>
  1187. <select id="getEnergyUseListOne" resultType="com.bizmatics.model.vo.HtAnalogDataOneVo">
  1188. <if test="cycle == 1">
  1189. SELECT
  1190. b.id,
  1191. b.Epp,
  1192. freezingTime AS freezingTime
  1193. FROM
  1194. (
  1195. <if test="sign == 1">
  1196. SELECT
  1197. max(id) AS minid,
  1198. freezingTime AS freezingTimess
  1199. </if>
  1200. <if test="sign == 2">
  1201. SELECT
  1202. min(id) AS minid,
  1203. freezingTime AS freezingTimess
  1204. </if>
  1205. FROM
  1206. ${table}
  1207. <where>
  1208. and deviceName = #{deviceCode}
  1209. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  1210. and dataTime BETWEEN #{startTime} and #{endTime}
  1211. </if>
  1212. </where>
  1213. GROUP BY freezingTimess
  1214. ) a
  1215. LEFT JOIN ${table} b ON a.minid = b.id
  1216. <if test="startCurrent != null and size !=0 and size!=null">
  1217. LIMIT #{startCurrent},
  1218. #{size}
  1219. </if>
  1220. </if>
  1221. <if test="cycle == 2">
  1222. SELECT
  1223. b.id,
  1224. b.Epp,
  1225. FROM_UNIXTIME(
  1226. UNIX_TIMESTAMP(b.dataTime),
  1227. '%Y-%m'
  1228. ) AS freezingTime
  1229. FROM
  1230. (
  1231. <if test="sign == 1">
  1232. SELECT
  1233. max(id) AS minid,
  1234. FROM_UNIXTIME(
  1235. UNIX_TIMESTAMP(dataTime),
  1236. '%Y-%m'
  1237. ) AS freezingTimess
  1238. </if>
  1239. <if test="sign == 2">
  1240. SELECT
  1241. min(id) AS minid,
  1242. FROM_UNIXTIME(
  1243. UNIX_TIMESTAMP(dataTime),
  1244. '%Y-%m'
  1245. ) AS freezingTimess
  1246. </if>
  1247. FROM
  1248. ${table}
  1249. <where>
  1250. and deviceName = #{deviceCode}
  1251. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  1252. and dataTime BETWEEN #{startTime} and #{endTime}
  1253. </if>
  1254. </where>
  1255. GROUP BY freezingTimess
  1256. ) a
  1257. LEFT JOIN ${table} b ON a.minid = b.id
  1258. <if test="startCurrent != null and size !=0 and size!=null">
  1259. LIMIT #{startCurrent},
  1260. #{size}
  1261. </if>
  1262. </if>
  1263. <if test="cycle == 3">
  1264. SELECT
  1265. b.id,
  1266. b.Epp,
  1267. FROM_UNIXTIME(
  1268. UNIX_TIMESTAMP(b.dataTime),
  1269. '%Y-%m'
  1270. ) AS freezingTime
  1271. FROM
  1272. (
  1273. <if test="sign == 1">
  1274. SELECT
  1275. max(id) AS minid,
  1276. FROM_UNIXTIME(
  1277. UNIX_TIMESTAMP(dataTime),
  1278. '%Y'
  1279. ) AS freezingTimess
  1280. </if>
  1281. <if test="sign == 2">
  1282. SELECT
  1283. min(id) AS minid,
  1284. FROM_UNIXTIME(
  1285. UNIX_TIMESTAMP(dataTime),
  1286. '%Y'
  1287. ) AS freezingTimess
  1288. </if>
  1289. FROM
  1290. ${table}
  1291. <where>
  1292. and deviceName = #{deviceCode}
  1293. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  1294. and dataTime BETWEEN #{startTime} and #{endTime}
  1295. </if>
  1296. </where>
  1297. GROUP BY freezingTimess
  1298. ) a
  1299. LEFT JOIN ${table} b ON a.minid = b.id
  1300. <if test="startCurrent != null and size !=0 and size!=null">
  1301. LIMIT #{startCurrent},
  1302. #{size}
  1303. </if>
  1304. </if>
  1305. </select>
  1306. <select id="demandAnalysisList" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  1307. SELECT
  1308. MAX(Demand) as Demand,
  1309. freezingTime AS freezingTimes
  1310. FROM
  1311. ht_analog_data
  1312. <where>
  1313. and deviceName = #{deviceCode}
  1314. <if test="monthDate != null and monthDate != ''">
  1315. and freezingTime LIKE CONCAT(CONCAT('%', #{monthDate}), '%')
  1316. </if>
  1317. </where>
  1318. GROUP BY freezingTime;
  1319. </select>
  1320. <select id="getDemandAnalysisList" resultType="com.bizmatics.model.HtAnalogData">
  1321. SELECT
  1322. *
  1323. FROM
  1324. ${table}
  1325. WHERE
  1326. deviceName = #{deviceCode}
  1327. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  1328. AND freezingTime BETWEEN #{startTime}
  1329. AND #{endTime}
  1330. </if>
  1331. GROUP BY
  1332. freezingTime
  1333. </select>
  1334. <select id="yearOnYearThree" parameterType="java.util.List" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  1335. SELECT
  1336. a.id,
  1337. a.deviceName,
  1338. <foreach collection="list" item="fieldDisplay" open=" " separator="," close=" ">
  1339. ${fieldDisplay}
  1340. </foreach>
  1341. ,
  1342. FROM_UNIXTIME(
  1343. UNIX_TIMESTAMP(a.dataTime),
  1344. '%m-%d %H:%i'
  1345. ) AS freezingTimes,
  1346. a.dataTime,
  1347. d.monitor_device_name,
  1348. d.id as device_attribute_id
  1349. FROM
  1350. ht_analog_data AS a
  1351. JOIN device_analog_variable_list AS c ON a.deviceName = c.device_code
  1352. JOIN device_attribute AS d ON c.monitoring_equipment = d.id
  1353. <where>
  1354. and a.deviceName in
  1355. <foreach item="item" collection="deviceCode" open="(" separator="," close=")">
  1356. #{item.displayField}
  1357. </foreach>
  1358. AND c.variable_coding in
  1359. <foreach item="item" collection="variableCoding" open="(" separator="," close=")">
  1360. #{item.variableCoding}
  1361. </foreach>
  1362. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  1363. and a.dataTime BETWEEN #{startTime} and #{endTime}
  1364. </if>
  1365. </where>
  1366. GROUP BY a.dataTime,a.deviceName
  1367. </select>
  1368. <select id="SingleLoopReportData" resultType="com.bizmatics.model.vo.SingleLoopReportVo">
  1369. SELECT
  1370. a.device_code,
  1371. a.device_name,
  1372. AVG(b.COS) AS COS,
  1373. AVG(F) AS avgF,
  1374. MAX(F) AS maxF,
  1375. min(F) AS minF,
  1376. AVG(b.Ia) AS avgIa,
  1377. AVG(b.Ib) AS avgIb,
  1378. AVG(b.Ic) AS avgIc,
  1379. max(b.Ia) AS maxIa,
  1380. max(b.Ib) AS maxIb,
  1381. max(b.Ic) AS maxIc,
  1382. min(b.Ia) AS minIa,
  1383. min(b.Ib) AS minIb,
  1384. min(b.Ic) AS minIc,
  1385. AVG(b.Ua) AS avgUa,
  1386. AVG(b.Ub) AS avgUb,
  1387. AVG(b.Uc) AS avgUc,
  1388. max(b.Ua) AS maxUa,
  1389. max(b.Ub) AS maxUb,
  1390. max(b.Uc) AS maxUc,
  1391. min(b.Ua) AS minUa,
  1392. min(b.Ub) AS minUb,
  1393. min(b.Uc) AS minUc,
  1394. c.voltage_level,
  1395. d.rated_current,
  1396. COUNT(b.id) AS measuringPoints
  1397. FROM
  1398. device AS a
  1399. LEFT JOIN ht_analog_data AS b ON a.device_code = b.deviceName
  1400. LEFT JOIN site_dynamic_properties AS c ON a.site_id = c.site_id
  1401. LEFT JOIN device_attribute AS d ON a.device_code = d.monitor_device_code
  1402. <where>
  1403. and a. ENABLE = 1
  1404. AND a.device_type = 1
  1405. AND a.device_code = #{deviceCode}
  1406. AND b.dataTime BETWEEN #{startTime}
  1407. AND #{endTime}
  1408. </where>
  1409. GROUP BY a.device_code
  1410. </select>
  1411. <select id="getYearOnYearThree" parameterType="java.util.List" resultType="com.bizmatics.model.vo.ContextualDataVo">
  1412. SELECT
  1413. <foreach collection="list" item="fieldDisplay" open=" " separator="," close=" ">
  1414. ${fieldDisplay}
  1415. </foreach>
  1416. FROM
  1417. ${table} AS a
  1418. JOIN device_analog_variable_list AS c ON a.deviceName = c.device_code
  1419. JOIN device_attribute AS d ON c.monitoring_equipment = d.id
  1420. <where>
  1421. and a.deviceName in
  1422. <foreach item="item" collection="deviceCode" open="(" separator="," close=")">
  1423. #{item.displayField}
  1424. </foreach>
  1425. AND c.variable_coding in
  1426. <foreach item="item" collection="variableCoding" open="(" separator="," close=")">
  1427. #{item.variableCoding}
  1428. </foreach>
  1429. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  1430. and a.dataTime BETWEEN #{startTime} and #{endTime}
  1431. </if>
  1432. <if test="dataArea != null and dataArea != 0">
  1433. and c.data_area = #{dataArea}
  1434. </if>
  1435. </where>
  1436. GROUP BY a.dataTime,a.deviceName
  1437. </select>
  1438. <select id="getDeviceList" parameterType="java.util.List" resultType="com.bizmatics.model.Device">
  1439. SELECT * FROM device
  1440. <where>
  1441. device_code IN
  1442. <foreach item="item" collection="deviceCode" open="(" separator="," close=")">
  1443. #{item.displayField}
  1444. </foreach>
  1445. </where>
  1446. </select>
  1447. </mapper>