HtAnalogDataMapper.xml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 siteId
  81. from ht_analog_data as had
  82. left join device as d
  83. on had.deviceName = d.device_code
  84. <where>
  85. <if test="endTime != null and startTime != null">
  86. and dataTime BETWEEN #{startTime} and #{endTime}
  87. </if>
  88. </where>
  89. order by had.id asc
  90. limit #{current},#{size}
  91. </select>
  92. <select id="getDateList" resultType="java.util.Map">
  93. select d.site_id as siteId,date(had.dataTime) as dat
  94. FROM
  95. ht_analog_data as had
  96. INNER JOIN device as d
  97. on had.deviceName = d.device_code
  98. <where>
  99. <if test="endTime != null and startTime != null">
  100. and had.dataTime BETWEEN #{startTime} and #{endTime}
  101. </if>
  102. </where>
  103. GROUP BY d.site_id,dat
  104. </select>
  105. <select id="selectCount" resultType="java.lang.Double">
  106. select
  107. IFNULL(sum(had.epp),0)
  108. from device as d
  109. inner join ht_analog_data as had
  110. on d.device_code = had.deviceName
  111. <where>
  112. <if test="siteId != null and siteId != 0">
  113. and d.site_id = #{siteId}
  114. </if>
  115. <if test="endTime != null and startTime != null">
  116. and dataTime BETWEEN #{startTime} and #{endTime}
  117. </if>
  118. </where>
  119. </select>
  120. <select id="yearOnYearOne" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  121. select
  122. id,deviceName,AVG(Busot) AS Busot,AVG(COS) as COS,AVG(COSa) as COSa,AVG(COSb) as COSb,AVG(COSc) as COSc,AVG(Demand) as Demand,AVG(DevResetTimes) as DevResetTimes,AVG(DeviceTemp) as DeviceTemp,
  123. AVG(Epn) as Epn,AVG(Epn1) as Epn1,AVG(Epn2) as Epn2,AVG(Epn3) as Epn3,AVG(Epn4) as Epn4,AVG(Epp) as Epp,AVG(Epp1) as Epp1,AVG(Epp2) as Epp2,AVG(Epp3) as Epp3,AVG(Epp4) as Epp4,AVG(Eqn) as Eqn,
  124. AVG(Eqp) as Eqp,AVG(F) as F,AVG(I0) as I0,AVG(I2) as I2,AVG(IHa) as IHa,AVG(IHb) as IHb,AVG(IHc) as IHc,AVG(Ia) as Ia,AVG(Ib) as Ib,AVG(Ic) as Ic,AVG(Ir) as Ir,AVG(LastDayMD) as LastDayMD,
  125. AVG(LastDayMDt) as LastDayMDt,AVG(P) as P,AVG(Pa) as Pa,AVG(Pb) as Pb,AVG(Pc) as Pc,AVG(Q) as Q,AVG(Qa) as Qa,AVG(Qb) as Qb,AVG(Qc) as Qc,AVG(SignalIntensity) as SignalIntensity,AVG(T1) as T1,
  126. AVG(T2) as T2,AVG(T3) as T3,AVG(T4) as T4,AVG(THDUa) as THDUa,AVG(THDUb) as THDUb,AVG(THDUc) as THDUc,AVG(Ua) as Ua,AVG(Uab) as Uab,AVG(Ub) as Ub,AVG(Ubc) as Ubc,AVG(UblU0) as UblU0,AVG(UblU2) as UblU2,
  127. AVG(Uc) as Uc,AVG(Uca) as Uca,AVG(Udt) as Udt,AVG(Ul) as Ul,AVG(Upt) as Upt,AVG(Ust) as Ust,FROM_UNIXTIME(UNIX_TIMESTAMP(dataTime) , '%m-%d %H:%i') as freezingTimes,dataTime
  128. from ht_analog_data
  129. <where>
  130. and deviceName = #{deviceCode}
  131. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  132. and dataTime BETWEEN #{startTime} and #{endTime}
  133. </if>
  134. </where>
  135. <if test="type != 0">
  136. GROUP BY freezingTime
  137. </if>
  138. </select>
  139. <select id="yearOnYearTwo" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  140. select
  141. id,deviceName,AVG(Busot) AS Busot,AVG(COS) as COS,AVG(COSa) as COSa,AVG(COSb) as COSb,AVG(COSc) as COSc,AVG(Demand) as Demand,AVG(DevResetTimes) as DevResetTimes,AVG(DeviceTemp) as DeviceTemp,
  142. AVG(Epn) as Epn,AVG(Epn1) as Epn1,AVG(Epn2) as Epn2,AVG(Epn3) as Epn3,AVG(Epn4) as Epn4,AVG(Epp) as Epp,AVG(Epp1) as Epp1,AVG(Epp2) as Epp2,AVG(Epp3) as Epp3,AVG(Epp4) as Epp4,AVG(Eqn) as Eqn,
  143. AVG(Eqp) as Eqp,AVG(F) as F,AVG(I0) as I0,AVG(I2) as I2,AVG(IHa) as IHa,AVG(IHb) as IHb,AVG(IHc) as IHc,AVG(Ia) as Ia,AVG(Ib) as Ib,AVG(Ic) as Ic,AVG(Ir) as Ir,AVG(LastDayMD) as LastDayMD,
  144. AVG(LastDayMDt) as LastDayMDt,AVG(P) as P,AVG(Pa) as Pa,AVG(Pb) as Pb,AVG(Pc) as Pc,AVG(Q) as Q,AVG(Qa) as Qa,AVG(Qb) as Qb,AVG(Qc) as Qc,AVG(SignalIntensity) as SignalIntensity,AVG(T1) as T1,
  145. AVG(T2) as T2,AVG(T3) as T3,AVG(T4) as T4,AVG(THDUa) as THDUa,AVG(THDUb) as THDUb,AVG(THDUc) as THDUc,AVG(Ua) as Ua,AVG(Uab) as Uab,AVG(Ub) as Ub,AVG(Ubc) as Ubc,AVG(UblU0) as UblU0,AVG(UblU2) as UblU2,
  146. AVG(Uc) as Uc,AVG(Uca) as Uca,AVG(Udt) as Udt,AVG(Ul) as Ul,AVG(Upt) as Upt,AVG(Ust) as Ust,FROM_UNIXTIME(UNIX_TIMESTAMP(dataTime) , '%m-%d %H:%i') as freezingTimes,dataTime
  147. from ht_analog_data
  148. <where>
  149. and deviceName = #{deviceCode}
  150. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  151. and dataTime BETWEEN #{startTime} and #{endTime}
  152. </if>
  153. </where>
  154. GROUP BY freezingTimes
  155. </select>
  156. <select id="yearOnYearThree" resultType="com.bizmatics.model.vo.HtAnalogDataVo">
  157. select
  158. id,deviceName,Busot,COS,COSa,COSb,COSc,Demand,DevResetTimes,DeviceTemp,Epn,Epn1,Epn2,Epn3,Epn4,Epp,
  159. 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,
  160. T1,T2,T3,T4,THDUa,THDUb,THDUc,Ua,Uab,Ub,Ubc,UblU0,UblU2,Uc,Uca,Udt,Ul,Upt,Ust,FROM_UNIXTIME(UNIX_TIMESTAMP(dataTime) , '%m-%d %H:%i') as freezingTimes,dataTime
  161. from ht_analog_data
  162. <where>
  163. and deviceName = #{deviceCode}
  164. <if test="endTime != null and startTime != null and endTime != '' and startTime != ''">
  165. and dataTime BETWEEN #{startTime} and #{endTime}
  166. </if>
  167. </where>
  168. GROUP BY dataTime
  169. </select>
  170. </mapper>