IotMaintainMapper.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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="cn.iocoder.yudao.module.pms.dal.mysql.maintain.IotMaintainMapper">
  4. <select id="selectNotice"
  5. resultType="cn.iocoder.yudao.module.pms.controller.admin.stat.vo.OrderVo">
  6. select * from (select a.id,
  7. a.failure_name title,
  8. '待填写' as status,
  9. (select nickname COLLATE utf8mb4_general_ci from system_users mm where cast(mm.id COLLATE utf8mb4_general_ci as char) =a.maintain_person COLLATE utf8mb4_general_ci) as person,
  10. '维修工单' as type,
  11. a.create_time
  12. from rq_iot_maintain a
  13. where status = 'tx'
  14. and deleted = false
  15. union all
  16. select b.id,
  17. b.inspect_order_title title,
  18. '待执行' as status,
  19. b.charge_name person,
  20. '巡检工单' as type,
  21. b.create_time
  22. from rq_iot_inspect_order b
  23. where status = 'todo'
  24. and deleted = false
  25. union all
  26. select c.id,
  27. c.name title,
  28. '待填写' as status,
  29. (select nickname COLLATE utf8mb4_general_ci from system_users bb where cast(bb.id COLLATE utf8mb4_general_ci as char) = c.responsible_person COLLATE utf8mb4_general_ci) as person,
  30. '保养工单' as type,
  31. c.create_time
  32. from rq_iot_main_work_order c
  33. where result = 1
  34. and deleted = false
  35. union all
  36. select d.id,
  37. d.order_name title,
  38. '待填写' as status,
  39. user_name as person,
  40. '运行记录' as type,
  41. d.create_time
  42. from rq_iot_opeation_fill_order d
  43. where order_status = 0
  44. and deleted = false)fin
  45. <where>
  46. <if test="reqVO.commonParam != null and reqVO.commonParam != ''">
  47. (fin.title LIKE CONCAT('%', #{reqVO.commonParam}, '%')
  48. OR fin.type LIKE CONCAT('%', #{reqVO.commonParam}, '%')
  49. OR fin.person LIKE CONCAT('%', #{reqVO.commonParam}, '%'))
  50. </if>
  51. </where>
  52. </select>
  53. <select id="getCost" parameterType="cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO"
  54. resultType="cn.iocoder.yudao.module.pms.controller.admin.stat.vo.ReportCost">
  55. select * from (select CAST(create_time AS CHAR) as date, '内部维修'as type, device_code as deviceCode, device_name as deviceName, maintain_fee as cost from rq_iot_maintain a
  56. <where>
  57. a.deleted=0 and a.type!='out'
  58. <if test="reqVO.createTime[0] != null">
  59. AND a.create_time &gt;= #{reqVO.createTime[0]}
  60. </if>
  61. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  62. AND a.create_time &lt;= #{reqVO.createTime[1]}
  63. </if>
  64. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  65. AND a.dept_id IN
  66. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  67. #{key}
  68. </foreach>
  69. </if>
  70. </where>
  71. select CAST(create_time AS CHAR) as date, '委外维修'as type, device_code as deviceCode, device_name as deviceName, maintain_fee as cost from rq_iot_maintain a
  72. <where>
  73. a.deleted=0 and a.type='out'
  74. <if test="reqVO.createTime[0] != null">
  75. AND a.create_time &gt;= #{reqVO.createTime[0]}
  76. </if>
  77. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  78. AND a.create_time &lt;= #{reqVO.createTime[1]}
  79. </if>
  80. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  81. AND a.dept_id IN
  82. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  83. #{key}
  84. </foreach>
  85. </if>
  86. </where>
  87. UNION ALL
  88. SELECT
  89. CAST(wo.update_time AS CHAR) as date,
  90. '保养' as type,
  91. d.device_code as deviceCode,
  92. d.device_name as deviceName,
  93. wo.cost
  94. FROM rq_iot_main_work_order wo
  95. LEFT JOIN rq_iot_main_work_order_bom wob ON (wob.work_order_id = wo.id AND wob.deleted = 0)
  96. LEFT JOIN rq_iot_device d ON (d.id = wob.device_id AND d.deleted = 0)
  97. WHERE
  98. wob.deleted = 0
  99. AND wo.deleted = 0
  100. AND d.deleted = 0
  101. <if test="reqVO.createTime[0] != null">
  102. AND wo.create_time &gt;= #{reqVO.createTime[0]}
  103. </if>
  104. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  105. AND wo.create_time &lt;= #{reqVO.createTime[1]}
  106. </if>
  107. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  108. AND wo.dept_id IN
  109. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  110. #{key}
  111. </foreach>
  112. </if>
  113. GROUP BY wo.id, wob.device_id) fin
  114. <where>
  115. <if test="reqVO.type != null">
  116. AND fin.type = #{reqVO.type}
  117. </if>
  118. </where>
  119. </select>
  120. <select id="selectStatusNumber" parameterType="cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO"
  121. resultType="cn.iocoder.yudao.module.pms.controller.admin.stat.vo.AllOrderResp">
  122. select status,count(status) as num from rq_iot_maintain a
  123. <where>
  124. a.deleted=0
  125. <if test="reqVO.createTime[0] != null">
  126. AND a.create_time &gt;= #{reqVO.createTime[0]}
  127. </if>
  128. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  129. AND a.create_time &lt;= #{reqVO.createTime[1]}
  130. </if>
  131. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  132. AND a.dept_id IN
  133. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  134. #{key}
  135. </foreach>
  136. </if>
  137. </where>
  138. group by status
  139. </select>
  140. <select id="getAllOrder" parameterType="cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO"
  141. resultType="cn.iocoder.yudao.module.pms.controller.admin.stat.vo.AllOrderResp">
  142. select * from (
  143. select a.id,'维修工单' as type,
  144. '' as taskId,
  145. a.create_time as createTime,
  146. CASE
  147. WHEN a.status = 'todo' THEN '未完成'
  148. WHEN a.status = 'finished' THEN '已完成'
  149. WHEN a.status = 'ignore' THEN '忽略'
  150. ELSE '' -- 兼容其他未知状态值
  151. END AS status,concat(a.device_code,'|',a.device_name) as device, a.dept_id as deptId,
  152. CASE
  153. WHEN d.type = 1 THEN COALESCE(d.`name`, '')
  154. WHEN d.type = 2 THEN COALESCE(p1.`name`, '')
  155. WHEN d.type = 3 THEN COALESCE(p2.`name`, '')
  156. ELSE ''
  157. END AS company,
  158. -- 按type规则填充project字段
  159. CASE
  160. WHEN d.type = 2 THEN COALESCE(d.`name`, '')
  161. WHEN d.type = 3 THEN COALESCE(p1.`name`, '')
  162. ELSE ''
  163. END AS project,
  164. -- 按type规则填充deptName字段(仅type=3时有值)
  165. CASE
  166. WHEN d.type = 3 THEN COALESCE(d.`name`, '')
  167. ELSE ''
  168. END AS deptName
  169. from rq_iot_maintain a
  170. -- 左关联当前部门(避免主表数据丢失)
  171. LEFT JOIN system_dept d ON a.dept_id = d.id
  172. -- 左关联父级部门(type=2/3时用)
  173. LEFT JOIN system_dept p1 ON d.parent_id = p1.id
  174. -- 左关联祖父级部门(type=3时用)
  175. LEFT JOIN system_dept p2 ON p1.parent_id = p2.id
  176. <where>
  177. a.deleted=0
  178. <if test="reqVO.createTime[0] != null">
  179. AND a.create_time &gt;= #{reqVO.createTime[0]}
  180. </if>
  181. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  182. AND a.create_time &lt;= #{reqVO.createTime[1]}
  183. </if>
  184. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  185. AND a.dept_id IN
  186. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  187. #{key}
  188. </foreach>
  189. </if>
  190. </where>
  191. UNION ALL
  192. select b.id,'巡检工单' as type,
  193. '' as taskId,
  194. b.create_time as createTime,
  195. CASE
  196. WHEN b.status = 'todo' THEN '未完成'
  197. WHEN b.status = 'finished' THEN '已完成'
  198. WHEN b.status = 'ignore' THEN '忽略'
  199. ELSE '' -- 兼容其他未知状态值
  200. END AS status, '' as device,b.dept_id as deptId,
  201. CASE
  202. WHEN d.type = 1 THEN COALESCE(d.`name`, '')
  203. WHEN d.type = 2 THEN COALESCE(p1.`name`, '')
  204. WHEN d.type = 3 THEN COALESCE(p2.`name`, '')
  205. ELSE ''
  206. END AS company,
  207. -- 按type规则填充project字段
  208. CASE
  209. WHEN d.type = 2 THEN COALESCE(d.`name`, '')
  210. WHEN d.type = 3 THEN COALESCE(p1.`name`, '')
  211. ELSE ''
  212. END AS project,
  213. -- 按type规则填充deptName字段(仅type=3时有值)
  214. CASE
  215. WHEN d.type = 3 THEN COALESCE(d.`name`, '')
  216. ELSE ''
  217. END AS deptName
  218. from rq_iot_inspect_order b
  219. -- 左关联当前部门(避免主表数据丢失)
  220. LEFT JOIN system_dept d ON b.dept_id = d.id
  221. -- 左关联父级部门(type=2/3时用)
  222. LEFT JOIN system_dept p1 ON d.parent_id = p1.id
  223. -- 左关联祖父级部门(type=3时用)
  224. LEFT JOIN system_dept p2 ON p1.parent_id = p2.id
  225. <where>
  226. b.deleted=0
  227. <if test="reqVO.createTime[0] != null">
  228. AND b.create_time &gt;= #{reqVO.createTime[0]}
  229. </if>
  230. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  231. AND b.create_time &lt;= #{reqVO.createTime[1]}
  232. </if>
  233. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  234. AND b.dept_id IN
  235. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  236. #{key}
  237. </foreach>
  238. </if>
  239. </where>
  240. UNION ALL
  241. SELECT
  242. c.id,
  243. '' AS taskId,
  244. '运行记录' AS type,
  245. c.create_time AS createTime,
  246. -- 核心优化:status 数值转中文描述
  247. CASE
  248. WHEN c.order_status = 0 THEN '未完成'
  249. WHEN c.order_status = 1 THEN '已完成'
  250. WHEN c.order_status = 2 THEN '填写中'
  251. ELSE '' -- 兼容其他未知状态值
  252. END AS status,
  253. '' AS device,
  254. c.dept_id AS deptId,
  255. -- 按type规则填充company字段
  256. CASE
  257. WHEN d.type = 1 THEN COALESCE(d.`name`, '')
  258. WHEN d.type = 2 THEN COALESCE(p1.`name`, '')
  259. WHEN d.type = 3 THEN COALESCE(p2.`name`, '')
  260. ELSE ''
  261. END AS company,
  262. -- 按type规则填充project字段
  263. CASE
  264. WHEN d.type = 2 THEN COALESCE(d.`name`, '')
  265. WHEN d.type = 3 THEN COALESCE(p1.`name`, '')
  266. ELSE ''
  267. END AS project,
  268. -- 按type规则填充deptName字段(仅type=3时有值)
  269. CASE
  270. WHEN d.type = 3 THEN COALESCE(d.`name`, '')
  271. ELSE ''
  272. END AS deptName
  273. FROM rq_iot_opeation_fill_order c
  274. -- 左关联当前部门(避免主表数据丢失)
  275. LEFT JOIN system_dept d ON c.dept_id = d.id
  276. -- 左关联父级部门(type=2/3时用)
  277. LEFT JOIN system_dept p1 ON d.parent_id = p1.id
  278. -- 左关联祖父级部门(type=3时用)
  279. LEFT JOIN system_dept p2 ON p1.parent_id = p2.id
  280. <where>
  281. c.deleted=0
  282. <if test="reqVO.createTime[0] != null">
  283. AND c.create_time &gt;= #{reqVO.createTime[0]}
  284. </if>
  285. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  286. AND c.create_time &lt;= #{reqVO.createTime[1]}
  287. </if>
  288. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  289. AND c.dept_id IN
  290. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  291. #{key}
  292. </foreach>
  293. </if>
  294. </where>
  295. union all
  296. select b.id,'保养工单' as type,
  297. '' as taskId,
  298. b.create_time as createTime,
  299. CASE
  300. WHEN b.result = 1 THEN '未完成'
  301. WHEN b.result = 2 THEN '已完成'
  302. ELSE '' -- 兼容其他未知状态值
  303. END AS status, '' as device,b.dept_id as deptId,
  304. CASE
  305. WHEN d.type = 1 THEN COALESCE(d.`name`, '')
  306. WHEN d.type = 2 THEN COALESCE(p1.`name`, '')
  307. WHEN d.type = 3 THEN COALESCE(p2.`name`, '')
  308. ELSE ''
  309. END AS company,
  310. -- 按type规则填充project字段
  311. CASE
  312. WHEN d.type = 2 THEN COALESCE(d.`name`, '')
  313. WHEN d.type = 3 THEN COALESCE(p1.`name`, '')
  314. ELSE ''
  315. END AS project,
  316. -- 按type规则填充deptName字段(仅type=3时有值)
  317. CASE
  318. WHEN d.type = 3 THEN COALESCE(d.`name`, '')
  319. ELSE ''
  320. END AS deptName
  321. from rq_iot_main_work_order b
  322. -- 左关联当前部门(避免主表数据丢失)
  323. LEFT JOIN system_dept d ON b.dept_id = d.id
  324. -- 左关联父级部门(type=2/3时用)
  325. LEFT JOIN system_dept p1 ON d.parent_id = p1.id
  326. -- 左关联祖父级部门(type=3时用)
  327. LEFT JOIN system_dept p2 ON p1.parent_id = p2.id
  328. <where>
  329. b.deleted = 0
  330. <if test="reqVO.createTime[0] != null">
  331. AND b.create_time &gt;= #{reqVO.createTime[0]}
  332. </if>
  333. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  334. AND b.create_time &lt;= #{reqVO.createTime[1]}
  335. </if>
  336. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  337. AND b.dept_id IN
  338. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  339. #{key}
  340. </foreach>
  341. </if>
  342. </where>
  343. UNION ALL
  344. select b.id,'瑞恒日报' as type,
  345. b.task_id as taskId,
  346. b.create_time as createTime,
  347. CASE
  348. WHEN b.status = 0 THEN '未完成'
  349. WHEN b.status = 1 THEN '已完成'
  350. ELSE '' -- 兼容其他未知状态值
  351. END AS status, '' as device,b.dept_id as deptId,
  352. CASE
  353. WHEN d.type = 1 THEN COALESCE(d.`name`, '')
  354. WHEN d.type = 2 THEN COALESCE(p1.`name`, '')
  355. WHEN d.type = 3 THEN COALESCE(p2.`name`, '')
  356. ELSE ''
  357. END AS company,
  358. -- 按type规则填充project字段
  359. CASE
  360. WHEN d.type = 2 THEN COALESCE(d.`name`, '')
  361. WHEN d.type = 3 THEN COALESCE(p1.`name`, '')
  362. ELSE ''
  363. END AS project,
  364. -- 按type规则填充deptName字段(仅type=3时有值)
  365. CASE
  366. WHEN d.type = 3 THEN COALESCE(d.`name`, '')
  367. ELSE ''
  368. END AS deptName
  369. from rq_iot_rh_daily_report b
  370. -- 左关联当前部门(避免主表数据丢失)
  371. LEFT JOIN system_dept d ON b.dept_id = d.id
  372. -- 左关联父级部门(type=2/3时用)
  373. LEFT JOIN system_dept p1 ON d.parent_id = p1.id
  374. -- 左关联祖父级部门(type=3时用)
  375. LEFT JOIN system_dept p2 ON p1.parent_id = p2.id
  376. <where>
  377. b.deleted = 0
  378. <if test="reqVO.createTime[0] != null">
  379. AND b.create_time &gt;= #{reqVO.createTime[0]}
  380. </if>
  381. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  382. AND b.create_time &lt;= #{reqVO.createTime[1]}
  383. </if>
  384. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  385. AND b.dept_id IN
  386. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  387. #{key}
  388. </foreach>
  389. </if>
  390. </where>
  391. UNION ALL
  392. select b.id,'瑞鹰日报' as type,
  393. b.task_id taskId,
  394. b.create_time as createTime,
  395. CASE
  396. WHEN b.status = 0 THEN '未完成'
  397. WHEN b.status = 1 THEN '已完成'
  398. ELSE '' -- 兼容其他未知状态值
  399. END AS status, '' as device,b.dept_id as deptId,
  400. CASE
  401. WHEN d.type = 1 THEN COALESCE(d.`name`, '')
  402. WHEN d.type = 2 THEN COALESCE(p1.`name`, '')
  403. WHEN d.type = 3 THEN COALESCE(p2.`name`, '')
  404. ELSE ''
  405. END AS company,
  406. -- 按type规则填充project字段
  407. CASE
  408. WHEN d.type = 2 THEN COALESCE(d.`name`, '')
  409. WHEN d.type = 3 THEN COALESCE(p1.`name`, '')
  410. ELSE ''
  411. END AS project,
  412. -- 按type规则填充deptName字段(仅type=3时有值)
  413. CASE
  414. WHEN d.type = 3 THEN COALESCE(d.`name`, '')
  415. ELSE ''
  416. END AS deptName
  417. from rq_iot_ry_daily_report b
  418. -- 左关联当前部门(避免主表数据丢失)
  419. LEFT JOIN system_dept d ON b.dept_id = d.id
  420. -- 左关联父级部门(type=2/3时用)
  421. LEFT JOIN system_dept p1 ON d.parent_id = p1.id
  422. -- 左关联祖父级部门(type=3时用)
  423. LEFT JOIN system_dept p2 ON p1.parent_id = p2.id
  424. <where>
  425. b.deleted = 0
  426. <if test="reqVO.createTime[0] != null">
  427. AND b.create_time &gt;= #{reqVO.createTime[0]}
  428. </if>
  429. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  430. AND b.create_time &lt;= #{reqVO.createTime[1]}
  431. </if>
  432. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  433. AND b.dept_id IN
  434. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  435. #{key}
  436. </foreach>
  437. </if>
  438. </where>
  439. UNION ALL
  440. select b.id,'瑞都日报' as type,
  441. b.task_id as taskId,
  442. b.create_time as createTime,
  443. CASE
  444. WHEN b.status = 0 THEN '未完成'
  445. WHEN b.status = 1 THEN '已完成'
  446. ELSE '' -- 兼容其他未知状态值
  447. END AS status, '' as device,b.dept_id as deptId,
  448. CASE
  449. WHEN d.type = 1 THEN COALESCE(d.`name`, '')
  450. WHEN d.type = 2 THEN COALESCE(p1.`name`, '')
  451. WHEN d.type = 3 THEN COALESCE(p2.`name`, '')
  452. ELSE ''
  453. END AS company,
  454. -- 按type规则填充project字段
  455. CASE
  456. WHEN d.type = 2 THEN COALESCE(d.`name`, '')
  457. WHEN d.type = 3 THEN COALESCE(p1.`name`, '')
  458. ELSE ''
  459. END AS project,
  460. -- 按type规则填充deptName字段(仅type=3时有值)
  461. CASE
  462. WHEN d.type = 3 THEN COALESCE(d.`name`, '')
  463. ELSE ''
  464. END AS deptName
  465. from rq_iot_rd_daily_report b
  466. -- 左关联当前部门(避免主表数据丢失)
  467. LEFT JOIN system_dept d ON b.dept_id = d.id
  468. -- 左关联父级部门(type=2/3时用)
  469. LEFT JOIN system_dept p1 ON d.parent_id = p1.id
  470. -- 左关联祖父级部门(type=3时用)
  471. LEFT JOIN system_dept p2 ON p1.parent_id = p2.id
  472. <where>
  473. b.deleted = 0
  474. <if test="reqVO.createTime[0] != null">
  475. AND b.create_time &gt;= #{reqVO.createTime[0]}
  476. </if>
  477. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  478. AND b.create_time &lt;= #{reqVO.createTime[1]}
  479. </if>
  480. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  481. AND b.dept_id IN
  482. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  483. #{key}
  484. </foreach>
  485. </if>
  486. </where>
  487. ) fin
  488. <where>
  489. <if test="reqVO.type != null">
  490. AND fin.type LIKE concat("%",#{reqVO.type},"%")
  491. </if>
  492. </where>
  493. </select>
  494. <select id="getMaintainFee" resultType="java.math.BigDecimal" >
  495. select sum(maintain_fee) from rq_iot_maintain c
  496. <where>
  497. c.deleted=0
  498. <if test="reqVO.createTime[0] != null">
  499. AND c.create_time &gt;= #{reqVO.createTime[0]}
  500. </if>
  501. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  502. AND c.create_time &lt;= #{reqVO.createTime[1]}
  503. </if>
  504. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  505. AND c.dept_id IN
  506. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  507. #{key}
  508. </foreach>
  509. </if>
  510. <if test="reqVO.type != null">
  511. AND c.type = #{reqVO.type}
  512. </if>
  513. </where>
  514. </select>
  515. <select id="getMaintainFeeIn" resultType="java.math.BigDecimal" >
  516. select sum(maintain_fee) from rq_iot_maintain c
  517. <where>
  518. c.deleted=0 and c.type !='out'
  519. <if test="reqVO.createTime[0] != null">
  520. AND c.create_time &gt;= #{reqVO.createTime[0]}
  521. </if>
  522. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  523. AND c.create_time &lt;= #{reqVO.createTime[1]}
  524. </if>
  525. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  526. AND c.dept_id IN
  527. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  528. #{key}
  529. </foreach>
  530. </if>
  531. <if test="reqVO.type != null">
  532. AND c.type = #{reqVO.type}
  533. </if>
  534. </where>
  535. </select>
  536. </mapper>