MonthReportMapper.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.huaxu.dao.MonthReportMapper">
  6. <resultMap type="MonthReportEntity" id="MonthReportResult">
  7. <result property="id" column="id"/>
  8. <result property="tenantId" column="tenant_id"/>
  9. <result property="year" column="year"/>
  10. <result property="month" column="month"/>
  11. <result property="day" column="day"/>
  12. <result property="hour" column="hour"/>
  13. <result property="parentSceneId" column="parent_scene_id"/>
  14. <result property="parentSceneName" column="parent_scene_name"/>
  15. <result property="sceneId" column="scene_id"/>
  16. <result property="sceneName" column="scene_name"/>
  17. <result property="deviceId" column="device_id"/>
  18. <result property="deviceName" column="device_name"/>
  19. <result property="deviceCode" column="device_code"/>
  20. <result property="attributeId" column="attribute_id"/>
  21. <result property="attributeName" column="attribute_name"/>
  22. <result property="minValue" column="min_value"/>
  23. <result property="maxValue" column="max_value"/>
  24. <result property="avgValue" column="avg_value"/>
  25. <result property="sumValue" column="sum_value"/>
  26. <result property="latestValue" column="latest_value"/>
  27. <result property="collectDate" column="collect_date"/>
  28. <result property="dateCreate" column="date_create"/>
  29. <result property="createBy" column="create_by"/>
  30. <result property="dateUpdate" column="date_update"/>
  31. <result property="updateBy" column="update_by"/>
  32. </resultMap>
  33. <!-- 实体栏位 -->
  34. <sql id="monthReportColumns">
  35. a.id as "id" ,
  36. a.tenant_id as "tenantId" ,
  37. a.year as "year" ,
  38. a.month as "month" ,
  39. a.day as "day" ,
  40. a.hour as "hour" ,
  41. a.parent_scene_id as "parentSceneId" ,
  42. a.parent_scene_name as "parentSceneName" ,
  43. a.scene_id as "sceneId" ,
  44. a.scene_name as "sceneName" ,
  45. a.device_id as "deviceId" ,
  46. a.device_name as "deviceName" ,
  47. a.device_code as "deviceCode" ,
  48. a.attribute_id as "attributeId" ,
  49. a.attribute_name as "attributeName" ,
  50. a.min_value as "minValue" ,
  51. a.max_value as "maxValue" ,
  52. a.avg_value as "avgValue" ,
  53. a.sum_value as "sumValue" ,
  54. a.latest_value as "latestValue" ,
  55. a.collect_date as "collectDate" ,
  56. a.date_create as "dateCreate" ,
  57. a.create_by as "createBy" ,
  58. a.date_update as "dateUpdate" ,
  59. a.update_by as "updateBy"
  60. </sql>
  61. <!-- 根据主键获取实体 -->
  62. <select id="findMonthReportById" resultType="com.huaxu.entity.MonthReportEntity">
  63. SELECT
  64. <include refid="monthReportColumns"/>
  65. FROM sms_month_report a
  66. WHERE a.id = #{id}
  67. </select>
  68. <!-- 根据获取实体List -->
  69. <select id="findList" resultType="com.huaxu.entity.MonthReportEntity">
  70. SELECT
  71. <include refid="monthReportColumns"/>
  72. FROM sms_month_report a
  73. <where>
  74. <if test="tenantId != null and tenantId != ''">and a.tenant_id = #{tenantId}</if>
  75. <if test="year != null ">and a.year = #{year}</if>
  76. <if test="month != null ">and a.month = #{month}</if>
  77. <if test="day != null ">and a.day = #{day}</if>
  78. <if test="hour != null ">and a.hour = #{hour}</if>
  79. <if test="parentSceneId != null ">and a.parent_scene_id = #{parentSceneId}</if>
  80. <if test="sceneId != null ">and a.scene_id = #{sceneId}</if>
  81. <if test="deviceId != null ">and a.device_id = #{deviceId}</if>
  82. <if test="deviceCode != null and deviceCode != ''">and a.device_code = #{deviceCode}</if>
  83. <if test="attributeId != null ">and a.attribute_id = #{attributeId}</if>
  84. <if test="collectDate != null ">and a.collect_date = #{collectDate}</if>
  85. </where>
  86. </select>
  87. <!-- 根据获取实体 page -->
  88. <select id="findPage" resultType="com.huaxu.dto.ReportDto">
  89. SELECT
  90. distinct
  91. a.tenant_id as "tenantId" ,
  92. a.year as "year" ,
  93. a.month as "month" ,
  94. a.day as "day" ,
  95. a.DEVICE_NAME as "deviceName",
  96. b.parent_scene_id as "parentSceneId",
  97. c.SCENE_NAME as "parentSceneName"
  98. FROM sms_month_report a
  99. inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID
  100. <if test="monthReport.typeIds != null">
  101. and b.PARM_TYPE in
  102. <foreach collection="monthReport.typeIds" item="typeId" open="(" close=")" separator=",">
  103. #{typeId}
  104. </foreach>
  105. </if>
  106. and b.`STATUS`=1
  107. inner join sms_scene c on b.PARENT_SCENE_ID=c.id
  108. <where>
  109. b.IS_REPORT=1
  110. <if test="monthReport.tenantId != null and monthReport.tenantId != ''">and a.tenant_id =
  111. #{monthReport.tenantId}
  112. </if>
  113. <if test="monthReport.deviceIds != null and monthReport.deviceIds.size() > 0">
  114. and b.DEVICE_ID in
  115. <foreach collection="monthReport.deviceIds" item="dramaId" open="(" close=")" separator=",">
  116. #{dramaId.id}
  117. </foreach>
  118. </if>
  119. <if test="monthReport.year != null ">and a.year = #{monthReport.year}</if>
  120. <if test="monthReport.month != null ">and a.month = #{monthReport.month}</if>
  121. <if test="monthReport.parentSceneIds != null and monthReport.parentSceneIds.length > 0">
  122. and b.parent_scene_id in
  123. <foreach collection = "monthReport.parentSceneIds" item = "dramaId" open = "(" close = ")" separator = "," >
  124. #{dramaId}
  125. </foreach>
  126. </if>
  127. </where>
  128. order by b.parent_scene_id,a.year,a.month,a.day
  129. </select>
  130. <!-- 根据获取实体 page -->
  131. <select id="findPageReprot" resultType="com.huaxu.dto.ReportDto">
  132. SELECT
  133. distinct
  134. a.tenant_id as "tenantId" ,
  135. a.year as "year" ,
  136. a.month as "month" ,
  137. a.day as "day" ,
  138. <if test="monthReport.type != null">
  139. a.DEVICE_NAME as "deviceName"
  140. </if>
  141. <if test="monthReport.type == null">
  142. b.parent_scene_id as "parentSceneId",
  143. c.SCENE_NAME as "parentSceneName",
  144. t.SCENE_TYPE_NAME as "sceneTypeName"
  145. </if>
  146. FROM sms_month_report a
  147. inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID
  148. <if test="monthReport.typeIds != null">
  149. and b.PARM_TYPE in
  150. <foreach collection="monthReport.typeIds" item="typeId" open="(" close=")" separator=",">
  151. #{typeId}
  152. </foreach>
  153. </if>
  154. and b.`STATUS`=1
  155. inner join sms_scene c on b.PARENT_SCENE_ID=c.id
  156. inner join sms_scene_type t on c.SCENE_TYPE_ID = t.id
  157. <where>
  158. b.IS_REPORT=1
  159. <if test="monthReport.tenantId != null and monthReport.tenantId != ''">and a.tenant_id =
  160. #{monthReport.tenantId}
  161. </if>
  162. <if test="monthReport.deviceIds != null and monthReport.deviceIds.size() > 0">
  163. and b.DEVICE_ID in
  164. <foreach collection="monthReport.deviceIds" item="dramaId" open="(" close=")" separator=",">
  165. #{dramaId.id}
  166. </foreach>
  167. </if>
  168. <if test="monthReport.startTime != null and monthReport.endTime != null ">
  169. and a.COLLECT_DATE BETWEEN #{monthReport.startTime} AND #{monthReport.endTime}
  170. </if>
  171. <if test="monthReport.year != null ">and a.year = #{monthReport.year}</if>
  172. <if test="monthReport.month != null ">and a.month = #{monthReport.month}</if>
  173. <if test="monthReport.parentSceneIds != null and monthReport.parentSceneIds.length > 0">
  174. and b.parent_scene_id in
  175. <foreach collection = "monthReport.parentSceneIds" item = "dramaId" open = "(" close = ")" separator = "," >
  176. #{dramaId}
  177. </foreach>
  178. </if>
  179. <if test="monthReport.sceneId != null ">
  180. and b.scene_id = #{monthReport.sceneId}
  181. </if>
  182. </where>
  183. <if test="monthReport.type == null">
  184. order by b.parent_scene_id,a.year,a.month,a.day
  185. </if>
  186. <if test="monthReport.type != null">
  187. order by a.year,a.month,a.day
  188. </if>
  189. </select>
  190. <select id="findAttributeList" resultType="com.huaxu.dto.ReportAttributeDto">
  191. SELECT tab.deviceParmId,tab.attributeName,tab.ATTRIBUTE_TYPE,min(tab.minValue) as "minValue",
  192. max(tab.maxValue) as "maxValue",AVG(tab.avgValue)as "avgValue",
  193. AVG(tab.sumValue)as "sumValue",AVG(tab.latestValue) as "latestValue"
  194. from
  195. (SELECT a.id as "deviceParmId",IFNULL(a.REMARK,b.`NAME`) AS "attributeName",
  196. c.min_value as "minValue" ,c.max_value as "maxValue" ,c.avg_value as "avgValue" ,
  197. c.sum_value as "sumValue" ,c.latest_value as "latestValue",
  198. a.PARM_TYPE ATTRIBUTE_TYPE
  199. FROM sms_device_parm a
  200. INNER JOIN sms_device_attribute b on a.ATTRIBUTE_ID=b.ID
  201. INNER JOIN sms_month_report c on a.ATTRIBUTE_ID=c.ATTRIBUTE_ID and a.DEVICE_ID=c.DEVICE_ID
  202. where
  203. a.IS_REPORT=1 and a.`STATUS`=1
  204. <if test="report.deviceIds != null and report.deviceIds.size() > 0">
  205. and a.DEVICE_ID in
  206. <foreach collection="report.deviceIds" item="dramaId" open="(" close=")" separator=",">
  207. #{dramaId.id}
  208. </foreach>
  209. </if>
  210. <if test="report.startTime != null and report.endTime != null ">
  211. and c.COLLECT_DATE BETWEEN #{report.startTime} AND #{report.endTime}
  212. </if>
  213. <if test="report.year != null ">and c.`YEAR`=#{report.year}</if>
  214. <if test="report.month != null ">and c.`MONTH`=#{report.month}</if>
  215. <if test="report.day != null ">and c.`DAY`=#{report.day}</if>
  216. <if test="report.parentSceneId != null ">and a.PARENT_SCENE_ID=#{report.parentSceneId}</if>
  217. <if test="report.sceneId != null ">and a.scene_id = #{report.sceneId} </if>
  218. ORDER BY a.SEQ
  219. ) as tab
  220. group by tab.deviceParmId,tab.attributeName,tab.ATTRIBUTE_TYPE
  221. </select>
  222. <select id="findReport" resultType="com.huaxu.dto.ReportDto">
  223. select
  224. tab.year,tab.month,tab.day,
  225. sum(ifnull(intakeWaterUsage,0))as "intakeWaterUsage",
  226. sum(ifnull(yieldWaterUsage,0))as "yieldWaterUsage",
  227. sum(ifnull(powerUsage,0))as "powerUsage",
  228. sum(ifnull(drugUsage,0))as "drugUsage"
  229. from
  230. (SELECT
  231. c.year,c.month,c.day,
  232. case when a.PARM_TYPE=4 then
  233. c.SUM_VALUE end as "intakeWaterUsage",
  234. case when a.PARM_TYPE=3 then
  235. c.SUM_VALUE end as "yieldWaterUsage",
  236. case when a.PARM_TYPE=5 then
  237. c.SUM_VALUE end as "powerUsage",
  238. case when a.PARM_TYPE=6 then
  239. c.SUM_VALUE end as "drugUsage"
  240. FROM sms_device_parm a
  241. INNER JOIN sms_device_attribute b on a.ATTRIBUTE_ID=b.ID
  242. INNER JOIN sms_month_report c on a.ATTRIBUTE_ID=c.ATTRIBUTE_ID and a.DEVICE_ID=c.DEVICE_ID
  243. where
  244. <if test="report.deviceIds != null and report.deviceIds.size() > 0">
  245. a.DEVICE_ID in
  246. <foreach collection="report.deviceIds" item="dramaId" open="(" close=")" separator=",">
  247. #{dramaId.id}
  248. </foreach>
  249. </if>
  250. <if test="report.parentSceneIds != null">
  251. and a.PARENT_SCENE_ID in
  252. <foreach collection="report.parentSceneIds" item="dramaId" open="(" close=")" separator=",">
  253. #{dramaId}
  254. </foreach>
  255. </if>
  256. <if test="report.sceneId != null ">
  257. and a.scene_id = #{report.sceneId}
  258. </if>
  259. <if test="report.startTime != null and report.endTime != null ">
  260. and c.COLLECT_DATE BETWEEN #{report.startTime} AND #{report.endTime}
  261. </if>
  262. <if test="report.year != null ">and c.`YEAR`=#{report.year}</if>
  263. <if test="report.month != null ">and c.`MONTH`=#{report.month}</if>
  264. <if test="report.parentSceneId != null ">and c.PARENT_SCENE_ID=#{report.parentSceneId}</if>
  265. <if test="report.parmType != null ">and a.PARM_TYPE in
  266. <foreach collection="report.parmType" item="ptype" open="(" close=")" separator=",">
  267. #{ptype}
  268. </foreach>
  269. and a.`STATUS`=1) tab
  270. </if>
  271. <if test="report.parmType == null ">
  272. and (a.PARM_TYPE =3 or a.PARM_TYPE =4 or a.PARM_TYPE =5 or a.PARM_TYPE =6) and a.`STATUS`=1) tab
  273. </if>
  274. group by tab.year,tab.month,tab.day
  275. order by tab.year desc,tab.month desc,tab.day desc
  276. </select>
  277. <!-- 根据获取实体 page -->
  278. <select id="findDevicePressPage" resultType="com.huaxu.dto.DevicePressReportAttributeDto">
  279. SELECT
  280. a.DEVICE_CODE as "deviceCode",
  281. a.DEVICE_NAME as "deviceName",
  282. a.min_value as "minValue" ,a.max_value as "maxValue" ,a.avg_value as "avgValue" ,
  283. a.sum_value as "sumValue" ,a.latest_value as "latestValue",
  284. a.COLLECT_DATE as "collectDate"
  285. FROM sms_month_report a
  286. inner join sms_device d on d.id = a.DEVICE_ID
  287. inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID and b.`STATUS`=1
  288. <if test="monthReport.type == 1">
  289. and b.PARM_TYPE = 13
  290. </if>
  291. <if test="monthReport.type == 2">
  292. and b.PARM_TYPE = 14
  293. </if>
  294. <where>
  295. <if test="monthReport.tenantId != null and monthReport.tenantId != ''">and a.tenant_id =
  296. #{monthReport.tenantId}
  297. </if>
  298. <if test="monthReport.year != null ">and a.year = #{monthReport.year}</if>
  299. <if test="monthReport.month != null ">and a.month = #{monthReport.month}</if>
  300. and a.DEVICE_ID in
  301. <foreach collection="monthReport.deviceIds" item="dramaId" open="(" close=")" separator=",">
  302. #{dramaId.id}
  303. </foreach>
  304. </where>
  305. order by a.DEVICE_ID,a.year,a.month,a.day
  306. </select>
  307. <!-- 根据获取实体 page -->
  308. <select id="findDeviceWaterPage" resultType="com.huaxu.dto.DeviceWaterReportAttributeDto">
  309. select tab.deviceCode,tab.deviceName,tab.collectDate,
  310. sum(tab.minPHValue) as minPHValue,sum(tab.maxPHValue) as maxPHValue,sum(tab.avgPHValue) as avgPHValue,sum(tab.sumPHValue) as sumPHValue,sum(tab.latestPHValue) as latestPHValue,
  311. sum(tab.minQuValue) as minQuValue,sum(tab.maxQuValue) as maxQuValue,sum(tab.avgQuValue) as avgQuValue,sum(tab.sumQuValue) as sumQuValue,sum(tab.latestQuValue) as latestQuValue,
  312. sum(tab.minCLValue) as minCLValue,sum(tab.maxCLValue) as maxCLValue,sum(tab.avgCLValue) as avgCLValue,sum(tab.sumCLValue) as sumCLValue,sum(tab.latestCLValue) as latestCLValue
  313. from (
  314. SELECT a.DEVICE_ID,a.id,a.DEVICE_CODE as "deviceCode", a.DEVICE_NAME as "deviceName",
  315. case when b.PARM_TYPE=7 then a.min_value end as "minPHValue" ,
  316. case when b.PARM_TYPE=7 then a.max_value end as "maxPHValue" ,
  317. case when b.PARM_TYPE=7 then a.avg_value end as "avgPHValue" ,
  318. case when b.PARM_TYPE=7 then a.sum_value end as "sumPHValue" ,
  319. case when b.PARM_TYPE=7 then a.latest_value end as "latestPHValue",
  320. case when b.PARM_TYPE=9 then a.min_value end as "minQuValue" ,
  321. case when b.PARM_TYPE=9 then a.max_value end as "maxQuValue" ,
  322. case when b.PARM_TYPE=9 then a.avg_value end as "avgQuValue" ,
  323. case when b.PARM_TYPE=9 then a.sum_value end as "sumQuValue" ,
  324. case when b.PARM_TYPE=9 then a.latest_value end as "latestQuValue",
  325. case when b.PARM_TYPE=11 then a.min_value end as "minCLValue" ,
  326. case when b.PARM_TYPE=11 then a.max_value end as "maxCLValue" ,
  327. case when b.PARM_TYPE=11 then a.avg_value end as "avgCLValue" ,
  328. case when b.PARM_TYPE=11 then a.sum_value end as "sumCLValue" ,
  329. case when b.PARM_TYPE=11 then a.latest_value end as "latestCLValue",
  330. a.COLLECT_DATE as "collectDate" ,
  331. a.year,a.month,a.day
  332. FROM sms_month_report a
  333. inner join sms_device d on d.id = a.DEVICE_ID
  334. inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID and b.`STATUS`=1
  335. and (b.PARM_TYPE = 7 or b.PARM_TYPE = 9 or b.PARM_TYPE = 11)
  336. <where>
  337. <if test="monthReport.tenantId != null and monthReport.tenantId != ''">and a.tenant_id =
  338. #{monthReport.tenantId}
  339. </if>
  340. <if test="monthReport.year != null ">and a.year = #{monthReport.year}</if>
  341. <if test="monthReport.month != null ">and a.month = #{monthReport.month}</if>
  342. and a.DEVICE_ID in
  343. <foreach collection="monthReport.deviceIds" item="dramaId" open="(" close=")" separator=",">
  344. #{dramaId.id}
  345. </foreach>
  346. </where>) as tab
  347. group by tab.DEVICE_ID,tab.year,tab.month,tab.day,tab.deviceCode,tab.deviceName,tab.collectDate
  348. order by tab.DEVICE_ID,tab.year,tab.month,tab.day
  349. </select>
  350. <select id="findAmountBySceneIds" resultType="com.huaxu.entity.MonthReportEntity">
  351. SELECT a.year as "year",a.`MONTH` as "month",a.`DAY` as "day",sum(a.LATEST_VALUE) as "latestValue",
  352. sum(a.SUM_VALUE) as "sumValue"
  353. FROM sms_month_report a
  354. INNER JOIN sms_device_parm b on a.DEVICE_ID=b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID and b.`STATUS`=1
  355. where DATE_SUB(CURDATE(), INTERVAL 15 DAY) &lt;= date(a.COLLECT_DATE)
  356. and b.PARM_TYPE=3 and b.PARENT_SCENE_ID in
  357. <foreach collection="monthReport.parentSceneLists" item="dramaId" open="(" close=")" separator=",">
  358. #{dramaId.id}
  359. </foreach>
  360. group by a.year,a.`MONTH`,a.`DAY`
  361. order by a.year desc,a.`MONTH` desc,a.`DAY` desc
  362. </select>
  363. <select id="findAmountTotalBySceneIds" resultType="com.huaxu.entity.MonthReportEntity">
  364. select sum(a.LATEST_VALUE) as "latestValue"
  365. from sms_month_report a
  366. inner join sms_device_parm b on a.DEVICE_ID=b.DEVICE_ID and b.ATTRIBUTE_ID=a.ATTRIBUTE_ID and b.`STATUS`=1
  367. inner join (
  368. select max(a.`DAY`) as day,a.DEVICE_ID
  369. from sms_month_report a
  370. inner join sms_device_parm b on a.DEVICE_ID=b.DEVICE_ID and b.ATTRIBUTE_ID=a.ATTRIBUTE_ID and b.`STATUS`=1
  371. where b.PARM_TYPE=3 and b.PARENT_SCENE_ID in
  372. <foreach collection="monthReport.parentSceneLists" item="dramaId" open="(" close=")" separator=",">
  373. #{dramaId.id}
  374. </foreach>
  375. <if test="monthReport.year != null ">and a.year = #{monthReport.year}</if>
  376. <if test="monthReport.month != null ">and a.month = #{monthReport.month}</if>
  377. GROUP BY a.DEVICE_ID
  378. )as tab on tab.DEVICE_ID=a.DEVICE_ID and a.`DAY`=tab.`day`
  379. where b.PARM_TYPE=3 and b.PARENT_SCENE_ID in
  380. <foreach collection="monthReport.parentSceneLists" item="dramaId" open="(" close=")" separator=",">
  381. #{dramaId.id}
  382. </foreach>
  383. <if test="monthReport.year != null ">and a.year = #{monthReport.year}</if>
  384. <if test="monthReport.month != null ">and a.month = #{monthReport.month}</if>
  385. </select>
  386. <select id="findAttributeListForMonth" resultType="com.huaxu.dto.ReportAttributeDto">
  387. SELECT tab.attributeName,tab.ATTRIBUTE_TYPE,sum(tab.sumValue)as "sumValue"
  388. from
  389. (SELECT IFNULL(a.REMARK,b.`NAME`) AS "attributeName",
  390. c.min_value as "minValue" ,c.max_value as "maxValue" ,c.avg_value as "avgValue" ,
  391. c.sum_value as "sumValue" ,c.latest_value as "latestValue",
  392. a.PARM_TYPE ATTRIBUTE_TYPE
  393. FROM sms_device_parm a
  394. INNER JOIN sms_device_attribute b on a.ATTRIBUTE_ID=b.ID
  395. INNER JOIN sms_month_report c on a.ATTRIBUTE_ID=c.ATTRIBUTE_ID and a.DEVICE_ID=c.DEVICE_ID
  396. where a.`STATUS`=1 and (a.PARM_TYPE=3 or a.PARM_TYPE=4)
  397. <if test="report.deviceIds != null and report.deviceIds.size() > 0">
  398. and a.DEVICE_ID in
  399. <foreach collection="report.deviceIds" item="dramaId" open="(" close=")" separator=",">
  400. #{dramaId.id}
  401. </foreach>
  402. </if>
  403. <if test="report.year != null ">and c.`YEAR`=#{report.year}</if>
  404. <if test="report.month != null ">and c.`MONTH`=#{report.month}</if>
  405. <if test="report.day != null ">and c.`DAY`=#{report.day}</if>
  406. <if test="report.parentSceneId != null ">and a.PARENT_SCENE_ID=#{report.parentSceneId}</if>
  407. ) as tab
  408. group by tab.attributeName,tab.ATTRIBUTE_TYPE
  409. </select>
  410. </mapper>