IotOpeationFillMapper.xml 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567
  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')
  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. <insert id="batchInsertLogs" parameterType="java.util.List">
  182. insert into rq_iot_device_run_log
  183. (dept_id, device_id, device_code, point_code, fill_content, create_time, point_name, total_run_time, is_sum)
  184. values
  185. <foreach collection="list" item="item" separator=",">
  186. (#{item.deptId}, #{item.deviceId}, #{item.deviceCode},
  187. #{item.pointCode}, #{item.fillContent}, #{item.createTime}, #{item.pointName}, #{item.totalRunTime}, #{item.isSum})
  188. </foreach>
  189. </insert>
  190. <update id="updateLog" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  191. update rq_iot_device_run_log
  192. set
  193. fill_content = #{fillContent}
  194. where
  195. device_id = #{deviceId}
  196. and
  197. point_name = #{pointName}
  198. and
  199. DATE(create_time) = #{createTime}
  200. and
  201. is_sum = 0
  202. </update>
  203. <update id="batchUpdateLogs" parameterType="java.util.List">
  204. update rq_iot_device_run_log
  205. set
  206. fill_content = CASE
  207. <foreach collection="list" item="item" separator="">
  208. WHEN device_id = #{item.deviceId}
  209. AND point_name = #{item.pointName}
  210. AND DATE(create_time) = #{item.createTime}
  211. AND is_sum = 0
  212. THEN #{item.fillContent}
  213. </foreach>
  214. ELSE fill_content <!-- 不满足条件的记录不更新 -->
  215. END
  216. where
  217. <!-- 只更新集合中存在的记录,避免全表扫描 -->
  218. (device_id, point_name, DATE(create_time), is_sum) IN (
  219. <foreach collection="list" item="item" separator=",">
  220. (#{item.deviceId}, #{item.pointName}, #{item.createTime}, 0)
  221. </foreach>
  222. )
  223. </update>
  224. <update id="updateSumLog" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  225. update rq_iot_device_run_log
  226. set
  227. total_run_time = #{totalRunTime}
  228. where
  229. device_id = #{deviceId}
  230. and
  231. point_name = #{pointName}
  232. and
  233. DATE(create_time) = #{createTime}
  234. and
  235. is_sum = 1
  236. </update>
  237. <update id="batchUpdateSumLogs" parameterType="java.util.List">
  238. update rq_iot_device_run_log
  239. set
  240. total_run_time = CASE
  241. <foreach collection="list" item="item" separator="">
  242. <!-- 匹配每条记录的唯一条件:device_id + point_name + 日期 + is_sum=1 -->
  243. WHEN device_id = #{item.deviceId}
  244. AND point_name = #{item.pointName}
  245. AND DATE(create_time) = #{item.createTime}
  246. AND is_sum = 1
  247. THEN #{item.totalRunTime} <!-- 赋值对应的总运行时间 -->
  248. </foreach>
  249. ELSE total_run_time <!-- 不匹配的记录保持原数值,不更新 -->
  250. END
  251. where
  252. <!-- 限定更新范围,避免全表扫描(仅更新集合中存在的记录) -->
  253. (device_id, point_name, DATE(create_time), is_sum) IN (
  254. <foreach collection="list" item="item" separator=",">
  255. (#{item.deviceId}, #{item.pointName}, #{item.createTime}, 1)
  256. </foreach>
  257. )
  258. </update>
  259. <!-- <select id="fillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  260. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  261. SELECT * FROM
  262. rq_iot_opeation_fill
  263. WHERE DATE(create_time) = CURDATE()
  264. <if test="deptId != null and deptId != ''">
  265. and dept_id in (SELECT d1.id
  266. FROM system_dept d1
  267. JOIN system_dept d2 ON d2.id = d1.parent_id
  268. WHERE d2.parent_id = #{deptId}
  269. union
  270. select id from system_dept where id = #{deptId})
  271. </if>
  272. </select>-->
  273. <select id="fillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  274. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  275. SELECT * FROM
  276. rq_iot_opeation_fill
  277. WHERE DATE(create_time) = CURDATE()
  278. <if test="userId != null and userId != ''">
  279. and device_id in (select device_id from
  280. rq_iot_device_person where person_id = #{userId})
  281. </if>
  282. </select>
  283. <select id="fills" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  284. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  285. SELECT * FROM
  286. rq_iot_opeation_fill
  287. WHERE 1=1
  288. <if test="deviceIds != null and !deviceIds.isEmpty()">
  289. and device_id in
  290. <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
  291. #{id}
  292. </foreach>
  293. </if>
  294. </select>
  295. <update id="upFill" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  296. update rq_iot_opeation_fill set dept_id = #{deptId} where 1=1
  297. <if test="deviceIds != null and !deviceIds.isEmpty()">
  298. and device_id in
  299. <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
  300. #{id}
  301. </foreach>
  302. </if>
  303. </update>
  304. <update id="upFill1" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillSaveReqVO">
  305. update rq_iot_opeation_fill_order
  306. set order_status = '3',
  307. reason = #{reason}
  308. where
  309. id = #{id}
  310. </update>
  311. <update id="upFill2" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillSaveReqVO">
  312. update rq_iot_opeation_fill
  313. set is_fill = '3'
  314. where
  315. order_id = #{id}
  316. </update>
  317. <select id="deviceList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  318. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  319. select device_id from
  320. rq_iot_device_person where person_id = #{userId}
  321. </select>
  322. <select id="fillListByUserId" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  323. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  324. SELECT DISTINCT
  325. a.*,
  326. b.name org_name
  327. FROM
  328. rq_iot_opeation_fill a
  329. JOIN system_dept b ON a.dept_id = b.id
  330. JOIN rq_iot_model_template_attrs c ON a.device_category_id = c.device_category_id
  331. JOIN rq_iot_opeation_fill_order d ON a.order_id = d.id
  332. WHERE
  333. (
  334. 1=1
  335. <if test="orderId != null and orderId != ''">
  336. and a.order_id = #{orderId}
  337. </if>
  338. )
  339. ORDER BY
  340. CASE WHEN device_code IS NULL OR device_code = '' THEN 1 ELSE 0 END ASC,
  341. CAST(SUBSTRING(device_code, 3) AS UNSIGNED) ASC
  342. </select>
  343. <select id="fillListPage" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  344. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  345. SELECT DISTINCT
  346. a.*,
  347. b.name org_name
  348. FROM
  349. rq_iot_opeation_fill a
  350. JOIN system_dept b ON a.dept_id = b.id
  351. JOIN rq_iot_model_template_attrs c ON a.device_category_id = c.device_category_id
  352. JOIN rq_iot_opeation_fill_order d ON a.order_id = d.id
  353. WHERE
  354. (
  355. 1=1
  356. <if test="orderId != null and orderId != ''">
  357. and a.order_id = #{orderId}
  358. </if>
  359. )
  360. ORDER BY
  361. CASE WHEN device_code IS NULL OR device_code = '' THEN 1 ELSE 0 END ASC,
  362. CAST(SUBSTRING(device_code, 3) AS UNSIGNED) ASC
  363. </select>
  364. <select id="getOrderIds" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  365. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  366. select
  367. distinct a.order_id
  368. from
  369. rq_iot_opeation_fill a,
  370. rq_iot_opeation_fill_order b
  371. where
  372. a.order_id = b.id
  373. and
  374. a.deleted = 0
  375. and
  376. b.deleted = 0
  377. and
  378. a.order_id is not null
  379. and(
  380. <if test="orgName != null and orgName != ''">
  381. (
  382. a.device_name LIKE CONCAT('%', #{orgName}, '%')
  383. OR a.device_code LIKE CONCAT('%', #{orgName}, '%')
  384. or b.user_name LIKE CONCAT('%', #{orgName}, '%')
  385. or b.order_name LIKE CONCAT('%', #{orgName}, '%')
  386. )
  387. </if>
  388. <if test="orgName == null or orgName == ''">
  389. 1=1
  390. </if>)
  391. </select>
  392. <select id="fillListByDeptId" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  393. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  394. select
  395. distinct
  396. a.*,
  397. b.name org_name
  398. from
  399. rq_iot_opeation_fill a,
  400. system_dept b,
  401. rq_iot_model_template_attrs c
  402. where
  403. a.dept_id = b.id
  404. and
  405. a.device_category_id = c.device_category_id
  406. <if test="orderId != null and orderId != ''">
  407. and a.order_id = #{orderId}
  408. </if>
  409. <if test="deviceId != null and deviceId != ''">
  410. and a.device_id = #{deviceId}
  411. </if>
  412. </select>
  413. <select id="devListByOrderId" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  414. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  415. SELECT
  416. COUNT(*) AS allDev, -- 总数量
  417. SUM(CASE WHEN is_fill = 1 THEN 1 ELSE 0 END) AS fillDev, -- is_fill为1的数量
  418. SUM(CASE WHEN is_fill = 0 THEN 1 ELSE 0 END) AS unFillDev -- is_fill为0的数量
  419. FROM
  420. rq_iot_opeation_fill
  421. WHERE
  422. order_id = #{orderId}
  423. and
  424. dept_id IN (
  425. SELECT id FROM (
  426. SELECT d1.id FROM system_dept d1 WHERE d1.id = #{deptId}
  427. UNION ALL
  428. SELECT d2.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id WHERE d1.id = #{deptId}
  429. UNION ALL
  430. 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}
  431. UNION ALL
  432. 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}
  433. ) AS dept_hierarchy
  434. )
  435. and device_name != '日报填报'
  436. </select>
  437. <!-- -->
  438. <select id="selectReportsByYear" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  439. SELECT *
  440. FROM rq_iot_opeation_fill
  441. WHERE is_report = 1
  442. <if test="deptId != null">
  443. AND dept_id = #{deptId}
  444. </if>
  445. AND YEAR(create_time) = #{year}
  446. </select>
  447. <select id="fillRecords" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO"
  448. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
  449. SELECT a.*
  450. FROM rq_iot_opeation_fill_order a
  451. JOIN rq_iot_opeation_fill b ON a.id = b.order_id
  452. WHERE b.device_id = #{deviceId}
  453. <if test="orderName != null and orderName != ''">
  454. AND (a.order_name LIKE CONCAT('%', #{orderName}, '%')
  455. OR b.device_code LIKE CONCAT('%', #{orderName}, '%')
  456. OR b.device_name LIKE CONCAT('%', #{orderName}, '%'))
  457. </if>
  458. <if test="orderStatus != null">
  459. AND a.order_status = #{orderStatus}
  460. </if>
  461. ORDER BY a.create_time DESC
  462. </select>
  463. <select id="selectListByCreateTime" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO"
  464. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
  465. SELECT a.id, a.create_time
  466. FROM rq_iot_opeation_fill_order a
  467. WHERE a.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  468. <if test="deptIds != null and deptIds.size &gt; 0">
  469. AND a.dept_id IN
  470. <foreach collection="deptIds" index="index" item="key" open="(" separator="," close=")">
  471. #{key}
  472. </foreach>
  473. </if>
  474. </select>
  475. <select id="countFills" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO"
  476. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  477. SELECT a.*
  478. FROM rq_iot_opeation_fill a
  479. WHERE a.deleted = 0
  480. AND a.device_name = '生产日报'
  481. AND a.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  482. AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  483. <if test="deptIds != null and deptIds.size &gt; 0">
  484. AND a.dept_id IN
  485. <foreach collection="deptIds" index="index" item="key" open="(" separator="," close=")">
  486. #{key}
  487. </foreach>
  488. </if>
  489. </select>
  490. <select id="rhList"
  491. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  492. SELECT au.id, au.name, au.parent_id
  493. FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
  494. (SELECT @parent_id := '157') pd
  495. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  496. AND @parent_id := concat(@parent_id, ',', id)
  497. UNION
  498. SELECT id, name, parent_id
  499. FROM system_dept
  500. WHERE id = '157'
  501. ORDER BY id;
  502. </select>
  503. <select id="rdList"
  504. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  505. SELECT au.id, au.name, au.parent_id
  506. FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
  507. (SELECT @parent_id := '163') pd
  508. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  509. AND @parent_id := concat(@parent_id, ',', id)
  510. UNION
  511. SELECT id, name, parent_id
  512. FROM system_dept
  513. WHERE id = '163'
  514. ORDER BY id;
  515. </select>
  516. <select id="ryList"
  517. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  518. SELECT au.id, au.name, au.parent_id
  519. FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
  520. (SELECT @parent_id := '158') pd
  521. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  522. AND @parent_id := concat(@parent_id, ',', id)
  523. UNION
  524. SELECT id, name, parent_id
  525. FROM system_dept
  526. WHERE id = '158'
  527. ORDER BY id;
  528. </select>
  529. <select id="pdList1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  530. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  531. SELECT au.id, au.name, au.parent_id
  532. FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
  533. (SELECT @parent_id := #{id}) pd
  534. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  535. AND @parent_id := concat(@parent_id, ',', id)
  536. UNION
  537. SELECT id, name, parent_id
  538. FROM system_dept
  539. WHERE id = #{id}
  540. ORDER BY id;
  541. </select>
  542. <select id="flList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  543. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  544. SELECT au.id, au.name, au.parent_id
  545. FROM (SELECT * FROM rq_iot_product_classify WHERE parent_id IS NOT NULL) au,
  546. (SELECT @parent_id := #{id}) pd
  547. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  548. AND @parent_id := concat(@parent_id, ',', id)
  549. UNION
  550. SELECT id, name, parent_id
  551. FROM rq_iot_product_classify
  552. WHERE id = #{id}
  553. ORDER BY id;
  554. </select>
  555. <select id="pdList" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  556. select
  557. distinct
  558. b.id user_id,
  559. b.nickname user_name,
  560. c.id dept_id,
  561. b.mobile,
  562. c.name orgName
  563. from
  564. rq_iot_device_person a
  565. left join
  566. system_users b
  567. on
  568. a.person_id = b.id
  569. left join
  570. system_dept c
  571. on
  572. b.dept_id = c.id
  573. where b.id is not null
  574. <if test="deviceIds != null and !deviceIds.isEmpty()">
  575. and a.device_id in
  576. <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
  577. #{id}
  578. </foreach>
  579. </if>
  580. </select>
  581. <select id="pdListRh" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  582. select
  583. distinct
  584. b.id user_id,
  585. b.nickname user_name,
  586. c.id dept_id,
  587. b.mobile,
  588. c.name orgName
  589. from
  590. rq_iot_device_person a
  591. left join
  592. system_users b
  593. on
  594. a.person_id = b.id
  595. left join
  596. system_dept c
  597. on
  598. b.dept_id = c.id
  599. where b.id is not null
  600. <if test="deviceIds != null and !deviceIds.isEmpty()">
  601. and c.id in
  602. <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
  603. #{id}
  604. </foreach>
  605. </if>
  606. </select>
  607. <select id="allOrder" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
  608. select distinct user_name
  609. from
  610. rq_iot_opeation_fill_order
  611. where
  612. DATE(create_time) = DATE(#{localDateTime})
  613. <if test="userNames != null and !userNames.isEmpty()">
  614. and user_name in
  615. <foreach collection="userNames" item="userName" open="(" separator="," close=")">
  616. #{userName}
  617. </foreach>
  618. </if>
  619. </select>
  620. <select id="pdList2" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  621. select
  622. distinct
  623. b.id user_id,
  624. b.nickname user_name,
  625. c.id dept_id,
  626. b.mobile,
  627. c.name orgName
  628. from
  629. rq_iot_device_person a
  630. left join
  631. system_users b
  632. on
  633. a.person_id = b.id
  634. left join
  635. system_dept c
  636. on
  637. b.dept_id = c.id
  638. where
  639. b.id is not null
  640. and
  641. c.id is not null
  642. <if test="deviceIds != null and !deviceIds.isEmpty()">
  643. and c.id in
  644. <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
  645. #{id}
  646. </foreach>
  647. </if>
  648. and
  649. a.person_id
  650. not in
  651. (select
  652. distinct
  653. d.person_id
  654. from
  655. rq_iot_model_template a,
  656. rq_iot_model_template_attrs b,
  657. rq_iot_device c,
  658. rq_iot_device_person d
  659. where
  660. a.device_category_id = b.device_category_id
  661. and
  662. a.device_category_id = c.asset_class
  663. and
  664. c.id = d.device_id
  665. and
  666. c.device_status in ('sg','dm')
  667. and
  668. a.deleted = 0
  669. and
  670. c.deleted = 0
  671. and
  672. d.deleted = 0)
  673. </select>
  674. <select id="fillList1" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  675. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  676. SELECT * FROM
  677. rq_iot_opeation_fill_order
  678. WHERE 1=1
  679. <if test="deptId != null and deptId != ''">
  680. and dept_id = #{deptId}
  681. </if>
  682. </select>
  683. <select id="getAttrsById" parameterType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO"
  684. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotModelTemplateAttrsDO">
  685. select
  686. id,
  687. name,
  688. type,
  689. model_attr,
  690. is_sum,
  691. threshold,
  692. default_value,
  693. sum_id,
  694. description
  695. from
  696. rq_iot_model_template_attrs
  697. where
  698. device_category_id = #{deviceCategoryId} and deleted = 0
  699. </select>
  700. <!--
  701. 批量查询属性模板:入参为List<IotDeviceRespVO>(含多个deviceCategoryId)
  702. 出参:List<IotModelTemplateAttrsDO>(所有分类ID对应的属性模板,包含deviceCategoryId便于分组)
  703. -->
  704. <select id="getAttrsByIdBatch" parameterType="java.util.List"
  705. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotModelTemplateAttrsDO">
  706. SELECT
  707. id,
  708. name,
  709. type,
  710. model_attr,
  711. is_sum,
  712. threshold,
  713. default_value,
  714. sum_id,
  715. description,
  716. device_category_id
  717. FROM
  718. rq_iot_model_template_attrs
  719. WHERE
  720. -- 批量匹配多个deviceCategoryId,deleted=0条件不变
  721. device_category_id IN (
  722. <foreach collection="vos" item="item" separator="," open="" close="">
  723. #{item.deviceCategoryId}
  724. </foreach>
  725. )
  726. AND deleted = 0
  727. -- 按分类ID和属性名称排序,保持结果一致性
  728. ORDER BY
  729. device_category_id ASC, name ASC
  730. </select>
  731. <update id="updateFill" parameterType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotOpeationModelPageReqVO">
  732. update rq_iot_opeation_fill
  733. set is_fill = '1'
  734. where device_id = #{deviceId}
  735. and DATE(create_time) = DATE(#{createTime})
  736. </update>
  737. <!-- 推荐使用这个方案 -->
  738. <update id="batchUpdateFill" parameterType="java.util.List">
  739. UPDATE rq_iot_opeation_fill
  740. SET is_fill = '1'
  741. WHERE (device_id, DATE(create_time)) IN
  742. <foreach collection="list" item="item" open="(" separator="," close=")">
  743. (#{item.deviceId}, DATE(#{item.createTime}))
  744. </foreach>
  745. </update>
  746. <select id="getFillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  747. resultType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO">
  748. select distinct b.* from
  749. rq_iot_opeation_fill b,
  750. rq_iot_opeation_fill_order c
  751. where
  752. c.id = #{orderId}
  753. and
  754. b.dept_id = c.dept_id
  755. and
  756. b.order_id = c.id
  757. and
  758. DATE(b.create_time)=DATE(#{createTime})
  759. order by b.create_time desc
  760. </select>
  761. <select id="getDeivceFillInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  762. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  763. <!--SELECT * FROM rq_iot_device_run_log
  764. WHERE
  765. device_id = #{deviceId}
  766. and
  767. create_time = (SELECT MAX(create_time) FROM rq_iot_device_run_log WHERE
  768. device_id = #{deviceId})-->
  769. SELECT
  770. point_name,
  771. fill_content,
  772. (select max(total_run_time) from rq_iot_device_run_log where device_id = #{deviceId})total_run_time
  773. FROM rq_iot_device_run_log
  774. WHERE
  775. device_id = #{deviceId}
  776. and
  777. DATE(create_time) = DATE(#{createTime})
  778. order by id
  779. desc
  780. limit 1
  781. </select>
  782. <select id="getLogInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  783. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  784. SELECT
  785. *
  786. FROM rq_iot_device_run_log
  787. WHERE
  788. device_id = #{deviceId}
  789. and
  790. point_name = #{pointName}
  791. and
  792. DATE(create_time) = DATE(#{createTime})
  793. order by id
  794. desc
  795. limit 1
  796. </select>
  797. <select id="batchGetLogInfo" parameterType="java.util.List"
  798. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  799. SELECT
  800. *
  801. FROM rq_iot_device_run_log r
  802. WHERE-- 批量匹配多个 (device_id, point_name, DATE(create_time)) 三元组
  803. (r.device_id, r.point_name, DATE(r.create_time)) IN (
  804. <foreach collection="list" item="item" separator=",">
  805. (#{item.deviceId}, #{item.pointName}, DATE(#{item.createTime}))
  806. </foreach>
  807. )
  808. -- 确保每个条件只返回最新一条记录(按id降序,取最大id)
  809. AND r.id IN (
  810. SELECT MAX(id)
  811. FROM rq_iot_device_run_log
  812. WHERE (device_id, point_name, DATE(create_time)) IN (
  813. <foreach collection="list" item="item" separator=",">
  814. (#{item.deviceId}, #{item.pointName}, DATE(#{item.createTime}))
  815. </foreach>
  816. )
  817. GROUP BY device_id, point_name, DATE(create_time)
  818. )
  819. </select>
  820. <select id="getMaxFillInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  821. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  822. select max(total_run_time)total_run_time
  823. from rq_iot_device_run_log
  824. where
  825. device_id = #{deviceId}
  826. and
  827. point_name=#{pointName}
  828. </select>
  829. <!--<select id="batchGetMaxFillInfo" parameterType="java.util.List"
  830. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  831. select
  832. device_id,
  833. point_name,
  834. max(total_run_time)total_run_time
  835. from rq_iot_device_run_log
  836. where
  837. &#45;&#45; 批量匹配多个 (device_id, point_name) 组合
  838. (device_id, point_name) IN (
  839. <foreach collection="list" item="item" separator=",">
  840. (#{item.deviceId}, #{item.pointName})
  841. </foreach>
  842. )
  843. group by
  844. device_id
  845. </select>-->
  846. <select id="batchGetMaxFillInfo" parameterType="java.util.List"
  847. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  848. SELECT
  849. device_id,
  850. point_name,
  851. total_run_time -- 直接取最新记录的 total_run_time,无需 max()(最新数据已通过排序筛选)
  852. FROM (
  853. SELECT
  854. device_id,
  855. point_name,
  856. total_run_time,
  857. create_time, -- 表中的时间字段,替换为实际字段名(如 log_time/update_time)
  858. -- 按 (device_id, point_name) 分组,每组内按时间倒序排名
  859. ROW_NUMBER() OVER (
  860. PARTITION BY device_id, point_name
  861. ORDER BY create_time DESC -- 时间倒序:最新的排第1
  862. -- 可选:若同一时间有重复记录,加次要排序(如 id DESC)确保唯一
  863. -- ORDER BY create_time DESC, id DESC
  864. ) AS rn
  865. FROM rq_iot_device_run_log
  866. WHERE
  867. -- 批量匹配多个 (device_id, point_name) 组合(保留原 foreach 逻辑)
  868. (device_id, point_name) IN (
  869. <foreach collection="list" item="item" separator=",">
  870. (#{item.deviceId}, #{item.pointName})
  871. </foreach>
  872. )
  873. ) AS temp
  874. WHERE rn = 1; -- 只取每个组合的最新记录(排名第1)
  875. </select>
  876. <select id="devList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  877. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  878. select device_id from rq_iot_opeation_fill where order_id = #{orderId}
  879. </select>
  880. <select id="orderList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  881. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  882. select distinct order_id
  883. from
  884. rq_iot_opeation_fill
  885. where
  886. device_id = #{deviceId}
  887. and DATE(create_time) = #{creDate}
  888. and order_id != #{orderId}
  889. </select>
  890. <select id="delList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  891. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  892. select * from rq_iot_opeation_fill where order_id = #{orderId}
  893. </select>
  894. <delete id="delRepeat" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  895. delete from rq_iot_opeation_fill where order_id = #{orderId}
  896. </delete>
  897. <delete id="delRepeatOrder" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  898. delete from rq_iot_opeation_fill_order where id = #{orderId}
  899. </delete>
  900. <update id="updateFillOrder" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  901. update rq_iot_opeation_fill_order set order_status = 1,update_time = NOW() where id = #{id}
  902. </update>
  903. <update id="updateFillOrder1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  904. update rq_iot_opeation_fill_order set order_status = 0 where id = #{id}
  905. </update>
  906. <update id="updateFillOrder2" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  907. update rq_iot_opeation_fill_order set order_status = 2,update_time = NOW() where id = #{id}
  908. </update>
  909. <select id="carList"
  910. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotZHBD.DeviceZHBDDO">
  911. select distinct device_code ,car_id from rq_iot_car_zhbd
  912. </select>
  913. <update id="upLocation"
  914. parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotZHBD.DeviceZHBDDO">
  915. update rq_iot_device set location= #{location} where device_code = #{deviceCode}
  916. </update>
  917. <select id="deviceCountList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicecountdata.IotDeviceCountData"
  918. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicecountdata.IotDeviceCountData">
  919. select
  920. distinct
  921. a.device_code,
  922. a.device_name,
  923. a.create_time,
  924. b.name dept_name,
  925. a.is_fill,
  926. d.nickname,
  927. e.order_name
  928. FROM rq_iot_opeation_fill a
  929. LEFT JOIN system_dept b
  930. ON a.dept_id = b.id
  931. AND b.deleted = 0 -- 将删除检查移至JOIN条件
  932. LEFT JOIN rq_iot_device_person c
  933. ON a.device_id = c.device_id
  934. AND c.deleted = 0 -- 将删除检查移至JOIN条件
  935. LEFT JOIN system_users d
  936. ON c.person_id = d.id
  937. AND d.deleted = 0 -- 将删除检查移至JOIN条件
  938. LEFT JOIN rq_iot_opeation_fill_order e
  939. ON a.order_id = e.id
  940. and e.deleted = 0
  941. WHERE a.deleted = 0
  942. and e.order_name is not null
  943. and a.device_name != '生产日报'
  944. AND b.id IN (
  945. SELECT id FROM system_dept WHERE id = #{deptId}
  946. UNION ALL
  947. SELECT id FROM system_dept WHERE parent_id = #{deptId}
  948. UNION ALL
  949. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})
  950. UNION ALL
  951. 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}))
  952. UNION ALL
  953. 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})))
  954. )
  955. <if test="isFill != null">
  956. and a.is_fill = #{isFill}
  957. </if>
  958. <if test="createTime != null and createTime.length > 0">
  959. <choose>
  960. <when test="createTime.length == 1">
  961. AND a.create_time = #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  962. </when>
  963. <otherwise>
  964. AND a.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  965. </otherwise>
  966. </choose>
  967. </if>
  968. <if test="orderName != null and orderName != ''">
  969. AND (e.order_name LIKE CONCAT('%', #{orderName}, '%')
  970. OR a.device_code LIKE CONCAT('%', #{orderName}, '%')
  971. OR a.device_name LIKE CONCAT('%', #{orderName}, '%')
  972. OR d.nickname LIKE CONCAT('%', #{orderName}, '%'))
  973. </if>
  974. order by a.create_time desc,a.is_fill asc,b.name asc
  975. </select>
  976. <select id="countList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO"
  977. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO">
  978. -- 统计指定部门及其子部门的工单状态
  979. SELECT
  980. dept_id,
  981. name,
  982. COALESCE(total_count, 0) AS total_count,
  983. COALESCE(filled_count, 0) AS filled_count,
  984. COALESCE(unfilled_count, 0) AS unfilled_count,
  985. COALESCE(filling_count, 0) AS filling_count,
  986. COALESCE(ignore_count, 0) AS ignore_count
  987. FROM (
  988. -- 第一行:汇总数据
  989. SELECT
  990. #{deptId} AS dept_id,
  991. (SELECT name FROM system_dept WHERE id = #{deptId}) AS name,
  992. COUNT(o.id) AS total_count,
  993. SUM(CASE WHEN o.order_status = 1 THEN 1 ELSE 0 END) AS filled_count,
  994. SUM(CASE WHEN o.order_status = 0 THEN 1 ELSE 0 END) AS unfilled_count,
  995. SUM(CASE WHEN o.order_status = 2 THEN 1 ELSE 0 END) AS filling_count,
  996. SUM(CASE WHEN o.order_status = 3 THEN 1 ELSE 0 END) AS ignore_count,
  997. 0 AS sort_order -- 确保汇总数据排在第一行
  998. FROM rq_iot_opeation_fill_order o
  999. WHERE o.deleted = 0
  1000. <if test="createTime != null and createTime.length > 0">
  1001. <choose>
  1002. <when test="createTime.length == 1">
  1003. AND o.create_time = #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  1004. </when>
  1005. <otherwise>
  1006. AND o.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  1007. </otherwise>
  1008. </choose>
  1009. </if>
  1010. AND o.dept_id IN (
  1011. SELECT id FROM system_dept WHERE id = #{deptId} -- 包含根部门自身
  1012. UNION ALL
  1013. SELECT id FROM system_dept WHERE parent_id = #{deptId} -- 一级子部门
  1014. UNION ALL
  1015. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId}) -- 二级子部门
  1016. UNION ALL
  1017. 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})) -- 三级子部门
  1018. UNION ALL
  1019. 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}))) -- 四级子部门
  1020. )
  1021. UNION ALL
  1022. -- 后续行:直接子部门数据
  1023. SELECT
  1024. d.id AS dept_id,
  1025. d.name,
  1026. COUNT(o.id) AS total_count,
  1027. SUM(CASE WHEN o.order_status = 1 THEN 1 ELSE 0 END) AS filled_count,
  1028. SUM(CASE WHEN o.order_status = 0 THEN 1 ELSE 0 END) AS unfilled_count,
  1029. SUM(CASE WHEN o.order_status = 2 THEN 1 ELSE 0 END) AS filling_count,
  1030. SUM(CASE WHEN o.order_status = 3 THEN 1 ELSE 0 END) AS ignore_count,
  1031. 1 AS sort_order -- 子部门数据排在后面
  1032. FROM system_dept d
  1033. LEFT JOIN rq_iot_opeation_fill_order o
  1034. ON o.deleted = 0
  1035. <if test="createTime != null and createTime.length > 0">
  1036. <choose>
  1037. <when test="createTime.length == 1">
  1038. AND o.create_time = #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  1039. </when>
  1040. <otherwise>
  1041. AND o.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  1042. </otherwise>
  1043. </choose>
  1044. </if>
  1045. AND o.dept_id IN (
  1046. SELECT id FROM system_dept WHERE id = d.id -- 子部门自身
  1047. UNION ALL
  1048. SELECT id FROM system_dept WHERE parent_id = d.id -- 子部门的一级子部门
  1049. UNION ALL
  1050. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = d.id) -- 子部门的二级子部门
  1051. UNION ALL
  1052. 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)) -- 子部门的三级子部门
  1053. UNION ALL
  1054. 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))) -- 子部门的四级子部门
  1055. )
  1056. WHERE d.parent_id = #{deptId} -- 只查询直接子部门
  1057. AND d.deleted = 0 -- 排除已删除的部门
  1058. GROUP BY d.id, d.name
  1059. HAVING COUNT(o.id) > 0 -- 只显示有数据的部门
  1060. ) t
  1061. ORDER BY sort_order, dept_id;
  1062. </select>
  1063. <select id="countDeviceList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO"
  1064. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO">
  1065. -- 统计指定部门及其子部门的工单状态
  1066. -- 第一行:汇总数据
  1067. SELECT
  1068. COUNT(*) AS total_count,
  1069. SUM(CASE WHEN is_fill = 1 THEN 1 ELSE 0 END) AS filled_count,
  1070. SUM(CASE WHEN is_fill = 3 THEN 1 ELSE 0 END) AS ignore_count,
  1071. 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
  1072. from(
  1073. select
  1074. distinct
  1075. a.device_code,
  1076. a.device_name,
  1077. a.create_time,
  1078. b.name dept_name,
  1079. a.is_fill,
  1080. d.nickname,
  1081. e.order_name
  1082. FROM rq_iot_opeation_fill a
  1083. LEFT JOIN system_dept b
  1084. ON a.dept_id = b.id
  1085. AND b.deleted = 0 -- 将删除检查移至JOIN条件
  1086. LEFT JOIN rq_iot_device_person c
  1087. ON a.device_id = c.device_id
  1088. AND c.deleted = 0 -- 将删除检查移至JOIN条件
  1089. LEFT JOIN system_users d
  1090. ON c.person_id = d.id
  1091. AND d.deleted = 0 -- 将删除检查移至JOIN条件
  1092. LEFT JOIN rq_iot_opeation_fill_order e
  1093. ON a.order_id = e.id
  1094. and e.deleted = 0
  1095. WHERE a.deleted = 0
  1096. and e.order_name is not null
  1097. and a.device_name != '生产日报'
  1098. AND b.id IN (
  1099. SELECT id FROM system_dept WHERE id = #{deptId}
  1100. UNION ALL
  1101. SELECT id FROM system_dept WHERE parent_id = #{deptId}
  1102. UNION ALL
  1103. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})
  1104. UNION ALL
  1105. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM
  1106. system_dept WHERE parent_id = #{deptId}))
  1107. UNION ALL
  1108. SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM
  1109. system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})))
  1110. )
  1111. <if test="createTime != null and createTime.length > 0">
  1112. <choose>
  1113. <when test="createTime.length == 1">
  1114. AND a.create_time = #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  1115. </when>
  1116. <otherwise>
  1117. AND a.create_time BETWEEN
  1118. #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND
  1119. #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
  1120. </otherwise>
  1121. </choose>
  1122. </if>) a
  1123. </select>
  1124. <select id="childList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO"
  1125. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
  1126. SELECT id dept_id
  1127. FROM system_dept
  1128. WHERE parent_id = #{deptId}
  1129. AND deleted = 0
  1130. </select>
  1131. <select id="devStatus" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO"
  1132. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO">
  1133. SELECT device_status
  1134. FROM rq_iot_device
  1135. WHERE dept_id = #{deptId}
  1136. AND asset_class in (159,160,122,106,157,158,191)
  1137. LIMIT 1
  1138. </select>
  1139. <select id="selectDevStatusBatch" parameterType="java.util.List"
  1140. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO">
  1141. SELECT
  1142. dept_id, -- 建议返回部门ID,方便后续关联结果
  1143. device_status
  1144. FROM rq_iot_device
  1145. WHERE dept_id IN
  1146. <foreach collection="teams" item="item" open="(" separator="," close=")">
  1147. #{item.id}
  1148. </foreach>
  1149. AND asset_class IN (159, 160, 122, 106, 157, 158, 191)
  1150. AND device_status != 'sg'
  1151. GROUP BY dept_id -- 确保每个部门只返回1条记录(若多个设备,取任意1条)
  1152. -- 可选:如需指定返回某条设备(如最新/最早),可加排序:
  1153. -- ORDER BY create_time DESC -- 按创建时间倒序(取最新)
  1154. </select>
  1155. <select id="isReport" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  1156. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  1157. select * from
  1158. rq_iot_opeation_fill
  1159. where
  1160. device_id = #{deviceId}
  1161. and
  1162. DATE(create_time) = DATE(#{createTime})
  1163. LIMIT 1
  1164. </select>
  1165. <!--
  1166. 批量查询isReport状态:入参为List<IotOpeationFillDO>(包含deviceId和createTime)
  1167. 出参:List<IotOpeationFillDO>(每条记录对应一个deviceId+createTime组合的查询结果)
  1168. -->
  1169. <select id="batchGetIsReport" parameterType="java.util.List"
  1170. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  1171. SELECT
  1172. t.device_id,
  1173. COALESCE(t.is_report, 0) AS is_report
  1174. FROM (
  1175. -- 子查询:先过滤批量匹配的记录,再按设备+日期分组取最新1条
  1176. SELECT
  1177. *,
  1178. -- 分组内排序:按create_time降序(最新的排第1)
  1179. ROW_NUMBER() OVER (
  1180. PARTITION BY device_id, DATE(create_time) -- 分组键:设备+日期
  1181. ORDER BY create_time DESC -- 取数规则:最新的1条(可修改)
  1182. ) AS rn
  1183. FROM rq_iot_opeation_fill
  1184. WHERE
  1185. -- 批量匹配:(设备ID, 日期) 组合(与之前批量查询逻辑兼容)
  1186. (device_id, DATE(create_time)) IN
  1187. <foreach collection="list" item="item" separator="," open="(" close=")">
  1188. (#{item.deviceId}, DATE(#{item.createTime}))
  1189. </foreach>
  1190. ) t
  1191. WHERE t.rn = 1; -- 只保留每组第1条(即每个设备每天1条)
  1192. </select>
  1193. <select id="orderDO" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  1194. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  1195. select
  1196. order_id
  1197. from
  1198. rq_iot_opeation_fill
  1199. where
  1200. device_id = #{deviceId}
  1201. and
  1202. DATE(create_time) = #{createTime}
  1203. </select>
  1204. <select id="batchGetOrderDO" parameterType="java.util.List"
  1205. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  1206. select
  1207. order_id
  1208. from(
  1209. -- 内层查询:批量匹配条件 + 去重(同一 deviceId+日期 取最新记录)
  1210. SELECT
  1211. order_id
  1212. FROM
  1213. rq_iot_opeation_fill
  1214. WHERE
  1215. (device_id, DATE(create_time)) IN (
  1216. <foreach collection="list" item="item" separator=",">
  1217. -- 匹配入参中的 deviceId 和 日期(DATE(createTime) 与原逻辑一致)
  1218. (#{item.deviceId}, DATE(#{item.createTime}))
  1219. </foreach>
  1220. )
  1221. -- 去重逻辑:按 id 降序,确保每个分组取最新记录
  1222. AND id IN (
  1223. SELECT MAX(id) -- 取最新记录的 id
  1224. FROM rq_iot_opeation_fill
  1225. WHERE (device_id, DATE(create_time)) IN (
  1226. <foreach collection="list" item="item" separator=",">
  1227. (#{item.deviceId}, DATE(#{item.createTime}))
  1228. </foreach>
  1229. )
  1230. GROUP BY device_id, DATE(create_time) -- 按 deviceId+日期 分组
  1231. )
  1232. ) AS iof
  1233. </select>
  1234. <select id="orderDO1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  1235. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  1236. select
  1237. order_id
  1238. from
  1239. rq_iot_opeation_fill
  1240. where
  1241. device_id = #{deviceId}
  1242. and
  1243. DATE(create_time) = CURDATE()
  1244. </select>
  1245. <select id="reportList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  1246. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  1247. SELECT DISTINCT
  1248. a.device_id,
  1249. a.device_code,
  1250. a.device_name,
  1251. a.create_time,
  1252. b.name AS org_name
  1253. FROM
  1254. rq_iot_opeation_fill a
  1255. INNER JOIN
  1256. rq_iot_model_template_attrs b
  1257. ON
  1258. a.device_category_id = b.device_category_id
  1259. WHERE
  1260. a.order_id = #{orderId}
  1261. AND (
  1262. -- 第一个查询的条件
  1263. (a.is_report = 1 AND b.daily_report = 0
  1264. AND b.name NOT IN (
  1265. SELECT
  1266. DISTINCT
  1267. b2.name
  1268. FROM
  1269. rq_iot_opeation_fill a2
  1270. INNER JOIN
  1271. rq_iot_model_template_attrs b2
  1272. ON
  1273. a2.device_category_id = b2.device_category_id
  1274. WHERE
  1275. a2.order_id = #{orderId}
  1276. AND
  1277. a2.is_report = 0
  1278. AND
  1279. b2.daily_report = 1
  1280. ))
  1281. -- 第二个查询的条件(通过OR代替UNION)
  1282. OR (a.is_report is null AND b.daily_report = 1)
  1283. )
  1284. and a.device_code != ''
  1285. </select>
  1286. <select id="reportList1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  1287. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  1288. SELECT DISTINCT
  1289. a.device_id,
  1290. a.device_code,
  1291. a.device_name,
  1292. a.create_time,
  1293. b.name AS org_name
  1294. FROM
  1295. rq_iot_opeation_fill a
  1296. INNER JOIN
  1297. rq_iot_model_template_attrs b
  1298. ON
  1299. a.device_category_id = b.device_category_id
  1300. WHERE
  1301. a.order_id = #{orderId}
  1302. and
  1303. a.is_report = 1
  1304. </select>
  1305. <select id="reportData" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  1306. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  1307. select * from
  1308. rq_iot_device_run_log
  1309. where
  1310. device_id = #{deviceId}
  1311. and
  1312. point_name = #{pointName}
  1313. and DATE(create_time) = DATE(#{createTime})
  1314. </select>
  1315. <!--
  1316. 批量查询设备运行日志:入参为List<IotDeviceRunLogDO>(含deviceId、pointName、createTime)
  1317. 出参:List<IotDeviceRunLogDO>(所有匹配条件的日志记录,结构与原单查一致)
  1318. -->
  1319. <select id="batchReportData" parameterType="java.util.List"
  1320. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  1321. SELECT
  1322. *
  1323. -- 如需其他字段,按原单查SQL补充(原SQL用select *,此处显式列出避免冗余)
  1324. FROM
  1325. rq_iot_device_run_log
  1326. WHERE
  1327. -- 批量匹配多个 (device_id, point_name, DATE(create_time)) 三元组条件
  1328. (device_id, point_name, DATE(create_time)) IN (
  1329. <foreach collection="list" item="item" separator=",">
  1330. (#{item.deviceId}, #{item.pointName}, DATE(#{item.createTime}))
  1331. </foreach>
  1332. )
  1333. -- 按创建时间降序,保持结果一致性(可选,与原单查行为对齐)
  1334. ORDER BY
  1335. create_time DESC
  1336. </select>
  1337. <select id="batchQueryExistingLogs" parameterType="java.util.List"
  1338. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  1339. select * from rq_iot_device_run_log
  1340. where
  1341. <!-- 多组条件组合:device_id + point_name + 日期 匹配 -->
  1342. (device_id, point_name, DATE(create_time)) IN (
  1343. <foreach collection="list" item="item" separator=",">
  1344. (#{item.deviceId}, #{item.pointName}, DATE(#{item.createTime}))
  1345. </foreach>
  1346. )
  1347. </select>
  1348. <select id="maxReportData" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  1349. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  1350. SELECT
  1351. MAX(total_Run_Time) AS total_run_time
  1352. FROM
  1353. rq_iot_device_run_log
  1354. WHERE
  1355. device_id = #{deviceId}
  1356. AND point_name = #{pointName}
  1357. AND create_time &lt; #{createTime}
  1358. </select>
  1359. <select id="batchQueryMaxReportData" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  1360. SELECT t.device_id, t.point_name, MAX(t.total_run_time) as total_run_time
  1361. FROM rq_iot_device_run_log t
  1362. WHERE
  1363. <foreach collection="list" item="item" separator="OR">
  1364. (t.device_id = #{item.deviceId}
  1365. AND t.point_name = #{item.pointName})
  1366. </foreach>
  1367. GROUP BY t.device_id, t.point_name
  1368. </select>
  1369. <select id="reportData1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  1370. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  1371. select * from
  1372. rq_iot_device_run_log
  1373. where
  1374. device_id = #{deviceId}
  1375. and
  1376. point_name = #{pointName}
  1377. and DATE(create_time) = DATE(#{createTime})
  1378. </select>
  1379. <select id="getDesc" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  1380. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  1381. select
  1382. description point_name
  1383. from
  1384. rq_iot_model_template_attrs
  1385. where
  1386. name = #{pointName}
  1387. and
  1388. device_category_id =
  1389. (select device_category_id from rq_iot_opeation_fill where device_id = #{deviceId} and DATE(create_time) = #{createTime})
  1390. </select>
  1391. <select id="batchGetDescByPointNames" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  1392. <!-- 注意:请根据你的实际表名和字段名修改! -->
  1393. <!-- 假设测点描述存储在 iot_device_run_log 表,核心字段:point_name(测点名)、point_desc(测点描述,可替换为你的实际字段) -->
  1394. select
  1395. description point_name
  1396. from
  1397. rq_iot_model_template_attrs
  1398. WHERE
  1399. 1 = 1
  1400. <!-- 批量查询:用 IN 关键字,配合 foreach 遍历测点名集合 -->
  1401. <if test="pointNameSet != null and pointNameSet.size() > 0">
  1402. AND name IN
  1403. <foreach collection="pointNameSet" item="pointName" open="(" separator="," close=")">
  1404. #{pointName} <!-- 遍历 Set 中的每个测点名 -->
  1405. </foreach>
  1406. </if>
  1407. <!-- 去重:避免同一测点名返回多条重复数据 -->
  1408. GROUP BY
  1409. point_name
  1410. </select>
  1411. <select id="getTeamType" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  1412. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  1413. select type as point_code from system_dept_type where dept_id = #{deptId}
  1414. </select>
  1415. <select id="getUserInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  1416. resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
  1417. select * from system_users where dept_id = #{deptId} and nickname = '技术员'
  1418. </select>
  1419. <select id="getUserId" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  1420. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  1421. select distinct a.person_id device_id from
  1422. rq_iot_device_person a
  1423. left join
  1424. rq_iot_device b
  1425. on a.device_id = b.id
  1426. left join
  1427. system_dept c
  1428. on b.dept_id = c.id
  1429. where c.id = #{deptId}
  1430. limit 1
  1431. </select>
  1432. </mapper>