IotOpeationFillMapper.xml 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  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.iotopeationfill.IotOpeationFillMapper">
  4. <select id="getFillDevices"
  5. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  6. select
  7. distinct
  8. c.id,
  9. c.dept_id,
  10. c.device_code,
  11. c.device_name,
  12. b.device_category_id,
  13. d.person_id user_id
  14. from
  15. rq_iot_model_template a,
  16. rq_iot_model_template_attrs b,
  17. rq_iot_device c,
  18. rq_iot_device_person d
  19. where
  20. a.device_category_id = b.device_category_id
  21. and
  22. a.device_category_id = c.asset_class
  23. and
  24. c.id = d.device_id
  25. and
  26. c.device_status in ('sg','dm')
  27. and
  28. a.deleted = 0
  29. and
  30. c.deleted = 0
  31. and
  32. d.deleted = 0
  33. <if test="deviceIds != null and !deviceIds.isEmpty()">
  34. and c.id in
  35. <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
  36. #{id}
  37. </foreach>
  38. </if>
  39. </select>
  40. <select id="getFillById" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  41. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  42. select * from rq_iot_opeation_fill_order where id = #{id}
  43. </select>
  44. <select id="getFillDevices1"
  45. resultType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO">
  46. select
  47. distinct
  48. c.id,
  49. c.dept_id,
  50. c.device_code,
  51. c.device_name,
  52. b.device_category_id,
  53. d.person_id user_id,
  54. e.name dept_name,
  55. f.nickname,
  56. g.name,
  57. c.device_status
  58. from
  59. rq_iot_model_template a,
  60. rq_iot_model_template_attrs b,
  61. rq_iot_device c,
  62. rq_iot_device_person d,
  63. system_dept e,
  64. system_users f,
  65. rq_iot_product_classify g
  66. where
  67. a.device_category_id = b.device_category_id
  68. and
  69. a.device_category_id = c.asset_class
  70. and
  71. c.id = d.device_id
  72. and
  73. c.dept_id = e.id
  74. and
  75. d.person_id = f.id
  76. and
  77. a.device_category_id = g.id
  78. and
  79. c.device_status in ('sg','dm')
  80. and
  81. a.deleted = 0
  82. and
  83. c.deleted = 0
  84. and
  85. d.deleted = 0
  86. <if test="deviceIds != null and !deviceIds.isEmpty()">
  87. and e.id in
  88. <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
  89. #{id}
  90. </foreach>
  91. </if>
  92. order by c.dept_id
  93. </select>
  94. <select id="getFillDevices2"
  95. resultType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO">
  96. select
  97. distinct
  98. c.id,
  99. c.dept_id,
  100. c.device_code,
  101. c.device_name,
  102. b.device_category_id,
  103. d.person_id user_id,
  104. e.name dept_name,
  105. f.nickname,
  106. g.name,
  107. c.device_status
  108. from
  109. rq_iot_model_template a,
  110. rq_iot_model_template_attrs b,
  111. rq_iot_device c,
  112. rq_iot_device_person d,
  113. system_dept e,
  114. system_users f,
  115. rq_iot_product_classify g
  116. where
  117. a.device_category_id = b.device_category_id
  118. and
  119. a.device_category_id = c.asset_class
  120. and
  121. c.id = d.device_id
  122. and
  123. c.dept_id = e.id
  124. and
  125. d.person_id = f.id
  126. and
  127. a.device_category_id = g.id
  128. and
  129. c.device_status = 'sg'
  130. and
  131. a.deleted = 0
  132. and
  133. c.deleted = 0
  134. and
  135. d.deleted = 0
  136. <if test="deptIds != null and !deptIds.isEmpty()">
  137. and e.id in
  138. <foreach collection="deptIds" item="id" open="(" separator="," close=")">
  139. #{id}
  140. </foreach>
  141. </if>
  142. order by c.dept_id
  143. </select>
  144. <insert id="insertFill"
  145. parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  146. insert into rq_iot_opeation_fill(device_id,device_code,device_name,device_category_id,create_time,dept_id,order_id,is_report)
  147. values
  148. <foreach collection="list" item="item" separator=",">
  149. (#{item.deviceId},#{item.deviceCode},#{item.deviceName},
  150. #{item.deviceCategoryId},#{item.createTime},#{item.deptId},#{item.orderId},#{item.isReport})
  151. </foreach>
  152. </insert>
  153. <!-- <insert id="insertFillOrder"
  154. parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  155. insert into rq_iot_opeation_fill_order(dept_id,order_name,
  156. order_status,create_time,order_type,user_name,user_id)
  157. values
  158. <foreach collection="list" item="item" separator=",">
  159. (#{item.deptId},#{item.orderName},#{item.orderStatus},
  160. #{item.createTime},#{item.orderType},#{item.userName},#{item.userId})
  161. </foreach>
  162. </insert>-->
  163. <insert id="insertLog"
  164. parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  165. insert into rq_iot_device_run_log
  166. (dept_id,device_id,device_code,point_code,fill_content,create_time,point_name,total_run_time,is_sum)
  167. values
  168. <foreach collection="list" item="item" separator=",">
  169. (#{item.deptId},#{item.deviceId},#{item.deviceCode},
  170. #{item.pointCode},#{item.fillContent},#{item.createTime},#{item.pointName},#{item.totalRunTime},#{item.isSum})
  171. </foreach>
  172. </insert>
  173. <insert id="insertLog1"
  174. parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  175. insert into rq_iot_device_run_log
  176. (dept_id, device_id, device_code, point_code, fill_content, create_time, point_name, total_run_time,is_sum)
  177. values
  178. (#{deptId}, #{deviceId}, #{deviceCode},
  179. #{pointCode}, #{fillContent}, #{createTime}, #{pointName}, #{totalRunTime},#{isSum})
  180. </insert>
  181. <update id="updateLog" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  182. update rq_iot_device_run_log
  183. set
  184. fill_content = #{fillContent}
  185. where
  186. device_code = #{deviceCode}
  187. and
  188. point_name = #{pointName}
  189. and
  190. DATE(create_time) = #{createTime}
  191. and
  192. is_sum = 0
  193. </update>
  194. <update id="updateSumLog" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  195. update rq_iot_device_run_log
  196. set
  197. total_run_time = #{totalRunTime}
  198. where
  199. device_code = #{deviceCode}
  200. and
  201. point_name = #{pointName}
  202. and
  203. DATE(create_time) = #{createTime}
  204. and
  205. is_sum = 1
  206. </update>
  207. <!-- <select id="fillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  208. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  209. SELECT * FROM
  210. rq_iot_opeation_fill
  211. WHERE DATE(create_time) = CURDATE()
  212. <if test="deptId != null and deptId != ''">
  213. and dept_id in (SELECT d1.id
  214. FROM system_dept d1
  215. JOIN system_dept d2 ON d2.id = d1.parent_id
  216. WHERE d2.parent_id = #{deptId}
  217. union
  218. select id from system_dept where id = #{deptId})
  219. </if>
  220. </select>-->
  221. <select id="fillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  222. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  223. SELECT * FROM
  224. rq_iot_opeation_fill
  225. WHERE DATE(create_time) = CURDATE()
  226. <if test="userId != null and userId != ''">
  227. and device_id in (select device_id from
  228. rq_iot_device_person where person_id = #{userId})
  229. </if>
  230. </select>
  231. <select id="fills" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  232. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  233. SELECT * FROM
  234. rq_iot_opeation_fill
  235. WHERE 1=1
  236. <if test="deviceIds != null and !deviceIds.isEmpty()">
  237. and device_id in
  238. <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
  239. #{id}
  240. </foreach>
  241. </if>
  242. </select>
  243. <update id="upFill" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  244. update rq_iot_opeation_fill set dept_id = #{deptId} where 1=1
  245. <if test="deviceIds != null and !deviceIds.isEmpty()">
  246. and device_id in
  247. <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
  248. #{id}
  249. </foreach>
  250. </if>
  251. </update>
  252. <update id="upFill1" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillSaveReqVO">
  253. update rq_iot_opeation_fill_order
  254. set order_status = '3',
  255. reason = #{reason}
  256. where
  257. id = #{id}
  258. </update>
  259. <update id="upFill2" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillSaveReqVO">
  260. update rq_iot_opeation_fill
  261. set is_fill = '3'
  262. where
  263. order_id = #{id}
  264. </update>
  265. <select id="deviceList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  266. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  267. select device_id from
  268. rq_iot_device_person where person_id = #{userId}
  269. </select>
  270. <select id="fillListByUserId" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  271. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  272. SELECT DISTINCT
  273. a.*,
  274. b.name org_name
  275. FROM
  276. rq_iot_opeation_fill a
  277. JOIN system_dept b ON a.dept_id = b.id
  278. JOIN rq_iot_model_template_attrs c ON a.device_category_id = c.device_category_id
  279. JOIN rq_iot_opeation_fill_order d ON a.order_id = d.id
  280. WHERE
  281. a.dept_id IN (
  282. SELECT id FROM (
  283. SELECT d1.id FROM system_dept d1 WHERE d1.id = #{deptId}
  284. UNION ALL
  285. SELECT d2.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id WHERE d1.id = #{deptId}
  286. UNION ALL
  287. SELECT d3.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id JOIN system_dept d3 ON d3.parent_id = d2.id WHERE d1.id = #{deptId}
  288. UNION ALL
  289. SELECT d4.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id JOIN system_dept d3 ON d3.parent_id = d2.id JOIN system_dept d4 ON d4.parent_id = d3.id WHERE d1.id = #{deptId}
  290. ) AS dept_hierarchy
  291. )
  292. AND (
  293. <if test="orderId != null and orderId != ''">
  294. a.order_id = #{orderId}
  295. </if>
  296. <!--<if test="orgName != null and orgName != ''">
  297. (
  298. a.device_name LIKE CONCAT('%', #{orgName}, '%')
  299. OR a.device_code LIKE CONCAT('%', #{orgName}, '%')
  300. OR d.user_name LIKE CONCAT('%', #{orgName}, '%')
  301. )
  302. </if>
  303. <if test="orgName == null or orgName == ''">
  304. 1=1
  305. </if>-->
  306. )
  307. ORDER BY
  308. CASE WHEN device_code IS NULL OR device_code = '' THEN 1 ELSE 0 END ASC,
  309. CAST(SUBSTRING(device_code, 3) AS UNSIGNED) ASC
  310. </select>
  311. <select id="getOrderIds" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  312. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  313. select
  314. distinct a.order_id
  315. from
  316. rq_iot_opeation_fill a,
  317. rq_iot_opeation_fill_order b
  318. where
  319. a.order_id = b.id
  320. and
  321. a.deleted = 0
  322. and
  323. b.deleted = 0
  324. and
  325. a.order_id is not null
  326. and(
  327. <if test="orgName != null and orgName != ''">
  328. (
  329. a.device_name LIKE CONCAT('%', #{orgName}, '%')
  330. OR a.device_code LIKE CONCAT('%', #{orgName}, '%')
  331. or b.user_name LIKE CONCAT('%', #{orgName}, '%')
  332. or b.order_name LIKE CONCAT('%', #{orgName}, '%')
  333. )
  334. </if>
  335. <if test="orgName == null or orgName == ''">
  336. 1=1
  337. </if>)
  338. </select>
  339. <select id="fillListByDeptId" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  340. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  341. select
  342. distinct
  343. a.*,
  344. b.name org_name
  345. from
  346. rq_iot_opeation_fill a,
  347. system_dept b,
  348. rq_iot_model_template_attrs c
  349. where
  350. a.dept_id = b.id
  351. and
  352. a.device_category_id = c.device_category_id
  353. <if test="orderId != null and orderId != ''">
  354. and a.order_id = #{orderId}
  355. </if>
  356. <if test="deviceId != null and deviceId != ''">
  357. and a.device_id = #{deviceId}
  358. </if>
  359. </select>
  360. <select id="devListByOrderId" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  361. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  362. SELECT
  363. COUNT(*) AS allDev, -- 总数量
  364. SUM(CASE WHEN is_fill = 1 THEN 1 ELSE 0 END) AS fillDev, -- is_fill为1的数量
  365. SUM(CASE WHEN is_fill = 0 THEN 1 ELSE 0 END) AS unFillDev -- is_fill为0的数量
  366. FROM
  367. rq_iot_opeation_fill
  368. WHERE
  369. order_id = #{orderId}
  370. and
  371. dept_id IN (
  372. SELECT id FROM (
  373. SELECT d1.id FROM system_dept d1 WHERE d1.id = #{deptId}
  374. UNION ALL
  375. SELECT d2.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id WHERE d1.id = #{deptId}
  376. UNION ALL
  377. SELECT d3.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id JOIN system_dept d3 ON d3.parent_id = d2.id WHERE d1.id = #{deptId}
  378. UNION ALL
  379. SELECT d4.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id JOIN system_dept d3 ON d3.parent_id = d2.id JOIN system_dept d4 ON d4.parent_id = d3.id WHERE d1.id = #{deptId}
  380. ) AS dept_hierarchy
  381. )
  382. and device_name != '日报填报'
  383. </select>
  384. <!-- -->
  385. <select id="selectReportsByYear" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  386. SELECT *
  387. FROM rq_iot_opeation_fill
  388. WHERE is_report = 1
  389. <if test="deptId != null">
  390. AND dept_id = #{deptId}
  391. </if>
  392. AND YEAR(create_time) = #{year}
  393. </select>
  394. <select id="fillRecords" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO"
  395. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
  396. SELECT a.*
  397. FROM rq_iot_opeation_fill_order a
  398. JOIN rq_iot_opeation_fill b ON a.id = b.order_id
  399. WHERE b.device_id = #{deviceId}
  400. <if test="orderName != null and orderName != ''">
  401. AND (a.order_name LIKE CONCAT('%', #{orderName}, '%')
  402. OR b.device_code LIKE CONCAT('%', #{orderName}, '%')
  403. OR b.device_name LIKE CONCAT('%', #{orderName}, '%'))
  404. </if>
  405. <if test="orderStatus != null">
  406. AND a.order_status = #{orderStatus}
  407. </if>
  408. ORDER BY a.create_time DESC
  409. </select>
  410. <select id="selectListByCreateTime" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO"
  411. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
  412. SELECT a.id, a.create_time
  413. FROM rq_iot_opeation_fill_order a
  414. WHERE a.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  415. <if test="deptIds != null and deptIds.size &gt; 0">
  416. AND a.dept_id IN
  417. <foreach collection="deptIds" index="index" item="key" open="(" separator="," close=")">
  418. #{key}
  419. </foreach>
  420. </if>
  421. </select>
  422. <select id="rhList"
  423. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  424. SELECT au.id, au.name, au.parent_id
  425. FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
  426. (SELECT @parent_id := '157') pd
  427. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  428. AND @parent_id := concat(@parent_id, ',', id)
  429. UNION
  430. SELECT id, name, parent_id
  431. FROM system_dept
  432. WHERE id = '157'
  433. ORDER BY id;
  434. </select>
  435. <select id="rdList"
  436. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  437. SELECT au.id, au.name, au.parent_id
  438. FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
  439. (SELECT @parent_id := '163') pd
  440. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  441. AND @parent_id := concat(@parent_id, ',', id)
  442. UNION
  443. SELECT id, name, parent_id
  444. FROM system_dept
  445. WHERE id = '163'
  446. ORDER BY id;
  447. </select>
  448. <select id="ryList"
  449. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  450. SELECT au.id, au.name, au.parent_id
  451. FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
  452. (SELECT @parent_id := '158') pd
  453. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  454. AND @parent_id := concat(@parent_id, ',', id)
  455. UNION
  456. SELECT id, name, parent_id
  457. FROM system_dept
  458. WHERE id = '158'
  459. ORDER BY id;
  460. </select>
  461. <select id="pdList1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  462. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  463. SELECT au.id, au.name, au.parent_id
  464. FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
  465. (SELECT @parent_id := #{id}) pd
  466. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  467. AND @parent_id := concat(@parent_id, ',', id)
  468. UNION
  469. SELECT id, name, parent_id
  470. FROM system_dept
  471. WHERE id = #{id}
  472. ORDER BY id;
  473. </select>
  474. <select id="flList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  475. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  476. SELECT au.id, au.name, au.parent_id
  477. FROM (SELECT * FROM rq_iot_product_classify WHERE parent_id IS NOT NULL) au,
  478. (SELECT @parent_id := #{id}) pd
  479. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  480. AND @parent_id := concat(@parent_id, ',', id)
  481. UNION
  482. SELECT id, name, parent_id
  483. FROM rq_iot_product_classify
  484. WHERE id = #{id}
  485. ORDER BY id;
  486. </select>
  487. <select id="pdList" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  488. select
  489. distinct
  490. b.id user_id,
  491. b.nickname user_name,
  492. c.id dept_id,
  493. b.mobile,
  494. c.name orgName
  495. from
  496. rq_iot_device_person a
  497. left join
  498. system_users b
  499. on
  500. a.person_id = b.id
  501. left join
  502. system_dept c
  503. on
  504. b.dept_id = c.id
  505. where b.id is not null
  506. <if test="deviceIds != null and !deviceIds.isEmpty()">
  507. and a.device_id in
  508. <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
  509. #{id}
  510. </foreach>
  511. </if>
  512. </select>
  513. <select id="allOrder" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
  514. select distinct user_name
  515. from
  516. rq_iot_opeation_fill_order
  517. where
  518. DATE(create_time) = DATE(#{localDateTime})
  519. <if test="userNames != null and !userNames.isEmpty()">
  520. and user_name in
  521. <foreach collection="userNames" item="userName" open="(" separator="," close=")">
  522. #{userName}
  523. </foreach>
  524. </if>
  525. </select>
  526. <select id="pdList2" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  527. select
  528. distinct
  529. b.id user_id,
  530. b.nickname user_name,
  531. c.id dept_id,
  532. b.mobile,
  533. c.name orgName
  534. from
  535. rq_iot_device_person a
  536. left join
  537. system_users b
  538. on
  539. a.person_id = b.id
  540. left join
  541. system_dept c
  542. on
  543. b.dept_id = c.id
  544. where
  545. b.id is not null
  546. and
  547. c.id is not null
  548. <if test="deviceIds != null and !deviceIds.isEmpty()">
  549. and c.id in
  550. <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
  551. #{id}
  552. </foreach>
  553. </if>
  554. and
  555. a.person_id
  556. not in
  557. (select
  558. distinct
  559. d.person_id
  560. from
  561. rq_iot_model_template a,
  562. rq_iot_model_template_attrs b,
  563. rq_iot_device c,
  564. rq_iot_device_person d
  565. where
  566. a.device_category_id = b.device_category_id
  567. and
  568. a.device_category_id = c.asset_class
  569. and
  570. c.id = d.device_id
  571. and
  572. c.device_status in ('sg','dm')
  573. and
  574. a.deleted = 0
  575. and
  576. c.deleted = 0
  577. and
  578. d.deleted = 0)
  579. </select>
  580. <select id="fillList1" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  581. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  582. SELECT * FROM
  583. rq_iot_opeation_fill_order
  584. WHERE 1=1
  585. <if test="deptId != null and deptId != ''">
  586. and dept_id = #{deptId}
  587. </if>
  588. </select>
  589. <select id="getAttrsById" parameterType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO"
  590. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotModelTemplateAttrsDO">
  591. select
  592. id,
  593. name,
  594. type,
  595. model_attr,
  596. is_sum,
  597. threshold,
  598. default_value,
  599. sum_id,
  600. description
  601. from
  602. rq_iot_model_template_attrs
  603. where
  604. device_category_id = #{deviceCategoryId} and deleted = 0
  605. </select>
  606. <update id="updateFill" parameterType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotOpeationModelPageReqVO">
  607. update rq_iot_opeation_fill
  608. set is_fill = '1'
  609. where device_id = #{deviceId}
  610. and DATE(create_time) = DATE(#{createTime})
  611. </update>
  612. <select id="getFillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  613. resultType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO">
  614. select distinct b.* from
  615. rq_iot_opeation_fill b,
  616. rq_iot_opeation_fill_order c
  617. where
  618. c.id = #{orderId}
  619. and
  620. b.dept_id = c.dept_id
  621. and
  622. b.order_id = c.id
  623. and
  624. DATE(b.create_time)=DATE(#{createTime})
  625. order by b.create_time desc
  626. </select>
  627. <select id="getDeivceFillInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  628. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  629. <!--SELECT * FROM rq_iot_device_run_log
  630. WHERE
  631. device_id = #{deviceId}
  632. and
  633. create_time = (SELECT MAX(create_time) FROM rq_iot_device_run_log WHERE
  634. device_id = #{deviceId})-->
  635. SELECT
  636. point_name,
  637. fill_content,
  638. (select max(total_run_time) from rq_iot_device_run_log where device_id = #{deviceId})total_run_time
  639. FROM rq_iot_device_run_log
  640. WHERE
  641. device_id = #{deviceId}
  642. and
  643. DATE(create_time) = DATE(#{createTime})
  644. order by id
  645. desc
  646. limit 1
  647. </select>
  648. <select id="getLogInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  649. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  650. <!--SELECT * FROM rq_iot_device_run_log
  651. WHERE
  652. device_id = #{deviceId}
  653. and
  654. create_time = (SELECT MAX(create_time) FROM rq_iot_device_run_log WHERE
  655. device_id = #{deviceId})-->
  656. SELECT
  657. *
  658. FROM rq_iot_device_run_log
  659. WHERE
  660. device_id = #{deviceId}
  661. and
  662. point_name = #{pointName}
  663. and
  664. DATE(create_time) = DATE(#{createTime})
  665. order by id
  666. desc
  667. limit 1
  668. </select>
  669. <select id="getMaxFillInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  670. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  671. <!--SELECT * FROM rq_iot_device_run_log
  672. WHERE
  673. device_id = #{deviceId}
  674. and
  675. create_time = (SELECT MAX(create_time) FROM rq_iot_device_run_log WHERE
  676. device_id = #{deviceId})-->
  677. select max(total_run_time)total_run_time
  678. from rq_iot_device_run_log
  679. where
  680. device_id = #{deviceId}
  681. and
  682. point_name=#{pointName}
  683. </select>
  684. <select id="devList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  685. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  686. select device_id from rq_iot_opeation_fill where order_id = #{orderId}
  687. </select>
  688. <select id="orderList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  689. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  690. select distinct order_id
  691. from
  692. rq_iot_opeation_fill
  693. where
  694. device_id = #{deviceId}
  695. and DATE(create_time) = #{creDate}
  696. and order_id != #{orderId}
  697. </select>
  698. <select id="delList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  699. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  700. select * from rq_iot_opeation_fill where order_id = #{orderId}
  701. </select>
  702. <delete id="delRepeat" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  703. delete from rq_iot_opeation_fill where order_id = #{orderId}
  704. </delete>
  705. <delete id="delRepeatOrder" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  706. delete from rq_iot_opeation_fill_order where id = #{orderId}
  707. </delete>
  708. <update id="updateFillOrder" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  709. update rq_iot_opeation_fill_order set order_status = 1,update_time = NOW() where id = #{id}
  710. </update>
  711. <update id="updateFillOrder1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  712. update rq_iot_opeation_fill_order set order_status = 0 where id = #{id}
  713. </update>
  714. <update id="updateFillOrder2" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  715. update rq_iot_opeation_fill_order set order_status = 2,update_time = NOW() where id = #{id}
  716. </update>
  717. <select id="carList"
  718. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotZHBD.DeviceZHBDDO">
  719. select distinct device_code ,car_id from rq_iot_car_zhbd
  720. </select>
  721. <update id="upLocation"
  722. parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotZHBD.DeviceZHBDDO">
  723. update rq_iot_device set location= #{location} where device_code = #{deviceCode}
  724. </update>
  725. <select id="deviceCountList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicecountdata.IotDeviceCountData"
  726. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicecountdata.IotDeviceCountData">
  727. select
  728. distinct
  729. a.device_code,
  730. a.device_name,
  731. a.create_time,
  732. b.name dept_name,
  733. a.is_fill,
  734. d.nickname,
  735. e.order_name
  736. FROM rq_iot_opeation_fill a
  737. LEFT JOIN system_dept b
  738. ON a.dept_id = b.id
  739. AND b.deleted = 0 -- 将删除检查移至JOIN条件
  740. LEFT JOIN rq_iot_device_person c
  741. ON a.device_id = c.device_id
  742. AND c.deleted = 0 -- 将删除检查移至JOIN条件
  743. LEFT JOIN system_users d
  744. ON c.person_id = d.id
  745. AND d.deleted = 0 -- 将删除检查移至JOIN条件
  746. LEFT JOIN rq_iot_opeation_fill_order e
  747. ON a.order_id = e.id
  748. and e.deleted = 0
  749. WHERE a.deleted = 0
  750. and e.order_name is not null
  751. and a.device_name != '生产日报'
  752. AND b.id IN (
  753. SELECT id FROM system_dept WHERE id = #{deptId}
  754. UNION ALL
  755. SELECT id FROM system_dept WHERE parent_id = #{deptId}
  756. UNION ALL
  757. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})
  758. UNION ALL
  759. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId}))
  760. UNION ALL
  761. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})))
  762. )
  763. <if test="isFill != null">
  764. and a.is_fill = #{isFill}
  765. </if>
  766. <if test="createTime != null and createTime.length > 0">
  767. <choose>
  768. <when test="createTime.length == 1">
  769. AND a.create_time = #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  770. </when>
  771. <otherwise>
  772. AND a.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  773. </otherwise>
  774. </choose>
  775. </if>
  776. <if test="orderName != null and orderName != ''">
  777. AND (e.order_name LIKE CONCAT('%', #{orderName}, '%')
  778. OR a.device_code LIKE CONCAT('%', #{orderName}, '%')
  779. OR a.device_name LIKE CONCAT('%', #{orderName}, '%')
  780. OR d.nickname LIKE CONCAT('%', #{orderName}, '%'))
  781. </if>
  782. order by a.create_time desc,a.is_fill asc,b.name asc
  783. </select>
  784. <select id="countList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO"
  785. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO">
  786. -- 统计指定部门及其子部门的工单状态
  787. SELECT
  788. dept_id,
  789. name,
  790. COALESCE(total_count, 0) AS total_count,
  791. COALESCE(filled_count, 0) AS filled_count,
  792. COALESCE(unfilled_count, 0) AS unfilled_count,
  793. COALESCE(filling_count, 0) AS filling_count,
  794. COALESCE(ignore_count, 0) AS ignore_count
  795. FROM (
  796. -- 第一行:汇总数据
  797. SELECT
  798. #{deptId} AS dept_id,
  799. (SELECT name FROM system_dept WHERE id = #{deptId}) AS name,
  800. COUNT(o.id) AS total_count,
  801. SUM(CASE WHEN o.order_status = 1 THEN 1 ELSE 0 END) AS filled_count,
  802. SUM(CASE WHEN o.order_status = 0 THEN 1 ELSE 0 END) AS unfilled_count,
  803. SUM(CASE WHEN o.order_status = 2 THEN 1 ELSE 0 END) AS filling_count,
  804. SUM(CASE WHEN o.order_status = 3 THEN 1 ELSE 0 END) AS ignore_count,
  805. 0 AS sort_order -- 确保汇总数据排在第一行
  806. FROM rq_iot_opeation_fill_order o
  807. WHERE o.deleted = 0
  808. <if test="createTime != null and createTime.length > 0">
  809. <choose>
  810. <when test="createTime.length == 1">
  811. AND o.create_time = #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  812. </when>
  813. <otherwise>
  814. AND o.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  815. </otherwise>
  816. </choose>
  817. </if>
  818. AND o.dept_id IN (
  819. SELECT id FROM system_dept WHERE id = #{deptId} -- 包含根部门自身
  820. UNION ALL
  821. SELECT id FROM system_dept WHERE parent_id = #{deptId} -- 一级子部门
  822. UNION ALL
  823. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId}) -- 二级子部门
  824. UNION ALL
  825. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})) -- 三级子部门
  826. UNION ALL
  827. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId}))) -- 四级子部门
  828. )
  829. UNION ALL
  830. -- 后续行:直接子部门数据
  831. SELECT
  832. d.id AS dept_id,
  833. d.name,
  834. COUNT(o.id) AS total_count,
  835. SUM(CASE WHEN o.order_status = 1 THEN 1 ELSE 0 END) AS filled_count,
  836. SUM(CASE WHEN o.order_status = 0 THEN 1 ELSE 0 END) AS unfilled_count,
  837. SUM(CASE WHEN o.order_status = 2 THEN 1 ELSE 0 END) AS filling_count,
  838. SUM(CASE WHEN o.order_status = 3 THEN 1 ELSE 0 END) AS ignore_count,
  839. 1 AS sort_order -- 子部门数据排在后面
  840. FROM system_dept d
  841. LEFT JOIN rq_iot_opeation_fill_order o
  842. ON o.deleted = 0
  843. <if test="createTime != null and createTime.length > 0">
  844. <choose>
  845. <when test="createTime.length == 1">
  846. AND o.create_time = #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  847. </when>
  848. <otherwise>
  849. AND o.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  850. </otherwise>
  851. </choose>
  852. </if>
  853. AND o.dept_id IN (
  854. SELECT id FROM system_dept WHERE id = d.id -- 子部门自身
  855. UNION ALL
  856. SELECT id FROM system_dept WHERE parent_id = d.id -- 子部门的一级子部门
  857. UNION ALL
  858. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = d.id) -- 子部门的二级子部门
  859. UNION ALL
  860. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = d.id)) -- 子部门的三级子部门
  861. UNION ALL
  862. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = d.id))) -- 子部门的四级子部门
  863. )
  864. WHERE d.parent_id = #{deptId} -- 只查询直接子部门
  865. AND d.deleted = 0 -- 排除已删除的部门
  866. GROUP BY d.id, d.name
  867. HAVING COUNT(o.id) > 0 -- 只显示有数据的部门
  868. ) t
  869. ORDER BY sort_order, dept_id;
  870. </select>
  871. <select id="countDeviceList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO"
  872. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO">
  873. -- 统计指定部门及其子部门的工单状态
  874. -- 第一行:汇总数据
  875. SELECT
  876. COUNT(*) AS total_count,
  877. SUM(CASE WHEN is_fill = 1 THEN 1 ELSE 0 END) AS filled_count,
  878. SUM(CASE WHEN is_fill = 3 THEN 1 ELSE 0 END) AS ignore_count,
  879. COUNT(*) - SUM(CASE WHEN is_fill = 1 THEN 1 ELSE 0 END)-SUM(CASE WHEN is_fill = 3 THEN 1 ELSE 0 END) AS unfilled_count
  880. from(
  881. select
  882. distinct
  883. a.device_code,
  884. a.device_name,
  885. a.create_time,
  886. b.name dept_name,
  887. a.is_fill,
  888. d.nickname,
  889. e.order_name
  890. FROM rq_iot_opeation_fill a
  891. LEFT JOIN system_dept b
  892. ON a.dept_id = b.id
  893. AND b.deleted = 0 -- 将删除检查移至JOIN条件
  894. LEFT JOIN rq_iot_device_person c
  895. ON a.device_id = c.device_id
  896. AND c.deleted = 0 -- 将删除检查移至JOIN条件
  897. LEFT JOIN system_users d
  898. ON c.person_id = d.id
  899. AND d.deleted = 0 -- 将删除检查移至JOIN条件
  900. LEFT JOIN rq_iot_opeation_fill_order e
  901. ON a.order_id = e.id
  902. and e.deleted = 0
  903. WHERE a.deleted = 0
  904. and e.order_name is not null
  905. and a.device_name != '生产日报'
  906. AND b.id IN (
  907. SELECT id FROM system_dept WHERE id = #{deptId}
  908. UNION ALL
  909. SELECT id FROM system_dept WHERE parent_id = #{deptId}
  910. UNION ALL
  911. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})
  912. UNION ALL
  913. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM
  914. system_dept WHERE parent_id = #{deptId}))
  915. UNION ALL
  916. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM
  917. system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})))
  918. )
  919. <if test="createTime != null and createTime.length > 0">
  920. <choose>
  921. <when test="createTime.length == 1">
  922. AND a.create_time = #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  923. </when>
  924. <otherwise>
  925. AND a.create_time BETWEEN
  926. #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND
  927. #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  928. </otherwise>
  929. </choose>
  930. </if>) a
  931. </select>
  932. <select id="childList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO"
  933. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
  934. SELECT id dept_id
  935. FROM system_dept
  936. WHERE parent_id = #{deptId}
  937. AND deleted = 0
  938. </select>
  939. <select id="isReport" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  940. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  941. select * from
  942. rq_iot_opeation_fill
  943. where
  944. device_id = #{deviceId}
  945. and
  946. DATE(create_time) = #{createTime}
  947. LIMIT 1
  948. </select>
  949. <select id="orderDO" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  950. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  951. select
  952. order_id
  953. from
  954. rq_iot_opeation_fill
  955. where
  956. device_id = #{deviceId}
  957. and
  958. DATE(create_time) = #{createTime}
  959. </select>
  960. <select id="reportList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  961. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  962. SELECT DISTINCT
  963. a.device_id,
  964. a.device_code,
  965. a.device_name,
  966. a.create_time,
  967. b.name AS org_name
  968. FROM
  969. rq_iot_opeation_fill a
  970. INNER JOIN
  971. rq_iot_model_template_attrs b
  972. ON
  973. a.device_category_id = b.device_category_id
  974. WHERE
  975. a.order_id = #{orderId}
  976. AND (
  977. -- 第一个查询的条件
  978. (a.is_report = 1 AND b.daily_report = 0
  979. AND b.name NOT IN (
  980. SELECT
  981. DISTINCT
  982. b2.name
  983. FROM
  984. rq_iot_opeation_fill a2
  985. INNER JOIN
  986. rq_iot_model_template_attrs b2
  987. ON
  988. a2.device_category_id = b2.device_category_id
  989. WHERE
  990. a2.order_id = #{orderId}
  991. AND
  992. a2.is_report = 0
  993. AND
  994. b2.daily_report = 1
  995. ))
  996. -- 第二个查询的条件(通过OR代替UNION)
  997. OR (a.is_report = 0 AND b.daily_report = 1)
  998. )
  999. </select>
  1000. <select id="reportList1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  1001. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  1002. SELECT DISTINCT
  1003. a.device_id,
  1004. a.device_code,
  1005. a.device_name,
  1006. a.create_time,
  1007. b.name AS org_name
  1008. FROM
  1009. rq_iot_opeation_fill a
  1010. INNER JOIN
  1011. rq_iot_model_template_attrs b
  1012. ON
  1013. a.device_category_id = b.device_category_id
  1014. WHERE
  1015. a.order_id = #{orderId}
  1016. and
  1017. a.is_report = 1
  1018. </select>
  1019. <select id="reportData" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  1020. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  1021. select * from
  1022. rq_iot_device_run_log
  1023. where
  1024. device_id = #{deviceId}
  1025. and
  1026. point_name = #{pointName}
  1027. and DATE(create_time) = DATE(#{createTime})
  1028. </select>
  1029. <select id="reportData1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  1030. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  1031. select * from
  1032. rq_iot_device_run_log
  1033. where
  1034. device_id = #{deviceId}
  1035. and
  1036. point_name = #{pointName}
  1037. and DATE(create_time) = DATE(#{createTime})
  1038. </select>
  1039. <select id="getDesc" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  1040. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  1041. select
  1042. description point_name
  1043. from
  1044. rq_iot_model_template_attrs
  1045. where
  1046. name = #{pointName}
  1047. and
  1048. device_category_id =
  1049. (select device_category_id from rq_iot_opeation_fill where device_id = #{deviceId} and DATE(create_time) = #{createTime})
  1050. </select>
  1051. </mapper>