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. union all
  72. 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
  73. <where>
  74. a.deleted=0 and a.type='out'
  75. <if test="reqVO.createTime[0] != null">
  76. AND a.create_time &gt;= #{reqVO.createTime[0]}
  77. </if>
  78. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  79. AND a.create_time &lt;= #{reqVO.createTime[1]}
  80. </if>
  81. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  82. AND a.dept_id IN
  83. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  84. #{key}
  85. </foreach>
  86. </if>
  87. </where>
  88. UNION ALL
  89. SELECT
  90. CAST(wo.update_time AS CHAR) as date,
  91. '保养' as type,
  92. d.device_code as deviceCode,
  93. d.device_name as deviceName,
  94. wo.cost
  95. FROM rq_iot_main_work_order wo
  96. LEFT JOIN rq_iot_main_work_order_bom wob ON (wob.work_order_id = wo.id AND wob.deleted = 0)
  97. LEFT JOIN rq_iot_device d ON (d.id = wob.device_id AND d.deleted = 0)
  98. WHERE
  99. wob.deleted = 0
  100. AND wo.deleted = 0
  101. AND d.deleted = 0
  102. <if test="reqVO.createTime[0] != null">
  103. AND wo.create_time &gt;= #{reqVO.createTime[0]}
  104. </if>
  105. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  106. AND wo.create_time &lt;= #{reqVO.createTime[1]}
  107. </if>
  108. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  109. AND wo.dept_id IN
  110. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  111. #{key}
  112. </foreach>
  113. </if>
  114. GROUP BY wo.id, wob.device_id) fin
  115. <where>
  116. <if test="reqVO.type != null">
  117. AND fin.type = #{reqVO.type}
  118. </if>
  119. </where>
  120. </select>
  121. <select id="selectStatusNumber" parameterType="cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO"
  122. resultType="cn.iocoder.yudao.module.pms.controller.admin.stat.vo.AllOrderResp">
  123. select status,count(status) as num from rq_iot_maintain a
  124. <where>
  125. a.deleted=0
  126. <if test="reqVO.createTime[0] != null">
  127. AND a.create_time &gt;= #{reqVO.createTime[0]}
  128. </if>
  129. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  130. AND a.create_time &lt;= #{reqVO.createTime[1]}
  131. </if>
  132. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  133. AND a.dept_id IN
  134. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  135. #{key}
  136. </foreach>
  137. </if>
  138. </where>
  139. group by status
  140. </select>
  141. <select id="getAllOrder" parameterType="cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO"
  142. resultType="cn.iocoder.yudao.module.pms.controller.admin.stat.vo.AllOrderResp">
  143. select * from (
  144. select a.id,'维修工单' as type,
  145. '' as taskId,
  146. a.create_time as createTime,
  147. CASE
  148. WHEN a.status = 'todo' THEN '未完成'
  149. WHEN a.status = 'finished' THEN '已完成'
  150. WHEN a.status = 'ignore' THEN '忽略'
  151. ELSE '' -- 兼容其他未知状态值
  152. END AS status,concat(a.device_code,'|',a.device_name) as device, a.dept_id as deptId,
  153. CASE
  154. WHEN d.type = 1 THEN COALESCE(d.`name`, '')
  155. WHEN d.type = 2 THEN COALESCE(p1.`name`, '')
  156. WHEN d.type = 3 THEN COALESCE(p2.`name`, '')
  157. ELSE ''
  158. END AS company,
  159. -- 按type规则填充project字段
  160. CASE
  161. WHEN d.type = 2 THEN COALESCE(d.`name`, '')
  162. WHEN d.type = 3 THEN COALESCE(p1.`name`, '')
  163. ELSE ''
  164. END AS project,
  165. -- 按type规则填充deptName字段(仅type=3时有值)
  166. CASE
  167. WHEN d.type = 3 THEN COALESCE(d.`name`, '')
  168. ELSE ''
  169. END AS deptName
  170. from rq_iot_maintain a
  171. -- 左关联当前部门(避免主表数据丢失)
  172. LEFT JOIN system_dept d ON a.dept_id = d.id
  173. -- 左关联父级部门(type=2/3时用)
  174. LEFT JOIN system_dept p1 ON d.parent_id = p1.id
  175. -- 左关联祖父级部门(type=3时用)
  176. LEFT JOIN system_dept p2 ON p1.parent_id = p2.id
  177. <where>
  178. a.deleted=0
  179. <if test="reqVO.createTime[0] != null">
  180. AND a.create_time &gt;= #{reqVO.createTime[0]}
  181. </if>
  182. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  183. AND a.create_time &lt;= #{reqVO.createTime[1]}
  184. </if>
  185. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  186. AND a.dept_id IN
  187. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  188. #{key}
  189. </foreach>
  190. </if>
  191. </where>
  192. UNION ALL
  193. select b.id,'巡检工单' as type,
  194. '' as taskId,
  195. b.create_time as createTime,
  196. CASE
  197. WHEN b.status = 'todo' THEN '未完成'
  198. WHEN b.status = 'finished' THEN '已完成'
  199. WHEN b.status = 'ignore' THEN '忽略'
  200. ELSE '' -- 兼容其他未知状态值
  201. END AS status, '' as device,b.dept_id as deptId,
  202. CASE
  203. WHEN d.type = 1 THEN COALESCE(d.`name`, '')
  204. WHEN d.type = 2 THEN COALESCE(p1.`name`, '')
  205. WHEN d.type = 3 THEN COALESCE(p2.`name`, '')
  206. ELSE ''
  207. END AS company,
  208. -- 按type规则填充project字段
  209. CASE
  210. WHEN d.type = 2 THEN COALESCE(d.`name`, '')
  211. WHEN d.type = 3 THEN COALESCE(p1.`name`, '')
  212. ELSE ''
  213. END AS project,
  214. -- 按type规则填充deptName字段(仅type=3时有值)
  215. CASE
  216. WHEN d.type = 3 THEN COALESCE(d.`name`, '')
  217. ELSE ''
  218. END AS deptName
  219. from rq_iot_inspect_order b
  220. -- 左关联当前部门(避免主表数据丢失)
  221. LEFT JOIN system_dept d ON b.dept_id = d.id
  222. -- 左关联父级部门(type=2/3时用)
  223. LEFT JOIN system_dept p1 ON d.parent_id = p1.id
  224. -- 左关联祖父级部门(type=3时用)
  225. LEFT JOIN system_dept p2 ON p1.parent_id = p2.id
  226. <where>
  227. b.deleted=0
  228. <if test="reqVO.createTime[0] != null">
  229. AND b.create_time &gt;= #{reqVO.createTime[0]}
  230. </if>
  231. <if test="reqVO.createTime.length > 1 and reqVO.createTime[1] != null">
  232. AND b.create_time &lt;= #{reqVO.createTime[1]}
  233. </if>
  234. <if test="reqVO.deptIds != null and reqVO.deptIds.size &gt; 0">
  235. AND b.dept_id IN
  236. <foreach collection="reqVO.deptIds" index="index" item="key" open="(" separator="," close=")">
  237. #{key}
  238. </foreach>
  239. </if>
  240. </where>
  241. UNION ALL
  242. SELECT
  243. c.id,'运行记录' AS type,
  244. '' AS taskId,
  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>