IotOpeationFillMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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. rqiot.rq_iot_model_template a,
  16. rqiot.rq_iot_model_template_attrs b,
  17. rqiot.rq_iot_device c,
  18. rqiot.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. </select>
  28. <select id="getFillById" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  29. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  30. select * from rqiot.rq_iot_opeation_fill_order where id = #{id}
  31. </select>
  32. <select id="getFillDevices1"
  33. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  34. select
  35. distinct
  36. c.id,
  37. c.dept_id,
  38. c.device_code,
  39. c.device_name,
  40. b.device_category_id,
  41. d.person_id user_id
  42. from
  43. rqiot.rq_iot_model_template a,
  44. rqiot.rq_iot_model_template_attrs b,
  45. rqiot.rq_iot_device c,
  46. rqiot.rq_iot_device_person d
  47. where
  48. a.device_category_id = b.device_category_id
  49. and
  50. a.device_category_id = c.asset_class
  51. and
  52. c.id = d.device_id
  53. and
  54. c.device_status in ('sg','dm')
  55. and c.device_id in
  56. <foreach item="deviceId" collection="array" open="(" separator="," close=")">
  57. #{deviceId}
  58. </foreach>
  59. </select>
  60. <insert id="insertFill"
  61. parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  62. insert into rqiot.rq_iot_opeation_fill(device_id,device_code,device_name,device_category_id,create_time,dept_id,order_id)
  63. values
  64. <foreach collection="list" item="item" separator=",">
  65. (#{item.deviceId},#{item.deviceCode},#{item.deviceName},
  66. #{item.deviceCategoryId},#{item.createTime},#{item.deptId},#{item.orderId})
  67. </foreach>
  68. </insert>
  69. <insert id="insertFillOrder"
  70. parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  71. insert into rqiot.rq_iot_opeation_fill_order(dept_id,order_name,
  72. order_status,create_time,order_type,user_name,user_id)
  73. values
  74. <foreach collection="list" item="item" separator=",">
  75. (#{item.deptId},#{item.orderName},#{item.orderStatus},
  76. #{item.createTime},#{item.orderType},#{item.userName},#{item.userId})
  77. </foreach>
  78. </insert>
  79. <insert id="insertLog"
  80. parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  81. insert into rqiot.rq_iot_device_run_log
  82. (dept_id,device_id,device_code,point_code,fill_content,create_time,point_name,total_run_time)
  83. values
  84. <foreach collection="list" item="item" separator=",">
  85. (#{item.deptId},#{item.deviceId},#{item.deviceCode},
  86. #{item.pointCode},#{item.fillContent},#{item.createTime},#{item.pointName},#{item.totalRunTime})
  87. </foreach>
  88. </insert>
  89. <!-- <select id="fillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  90. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  91. SELECT * FROM
  92. rqiot.rq_iot_opeation_fill
  93. WHERE DATE(create_time) = CURDATE()
  94. <if test="deptId != null and deptId != ''">
  95. and dept_id in (SELECT d1.id
  96. FROM system_dept d1
  97. JOIN system_dept d2 ON d2.id = d1.parent_id
  98. WHERE d2.parent_id = #{deptId}
  99. union
  100. select id from system_dept where id = #{deptId})
  101. </if>
  102. </select>-->
  103. <select id="fillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  104. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  105. SELECT * FROM
  106. rqiot.rq_iot_opeation_fill
  107. WHERE DATE(create_time) = CURDATE()
  108. <if test="userId != null and userId != ''">
  109. and device_id in (select device_id from
  110. rqiot.rq_iot_device_person where person_id = #{userId})
  111. </if>
  112. </select>
  113. <select id="fills" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  114. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  115. SELECT * FROM
  116. rqiot.rq_iot_opeation_fill
  117. WHERE 1=1
  118. and c.device_id in
  119. <foreach item="deviceId" collection="array" open="(" separator="," close=")">
  120. #{deviceId}
  121. </foreach>
  122. </select>
  123. <update id="upFill" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  124. update rqiot.rq_iot_opeation_fill set dept_id = #{deptId} where device_id in
  125. <foreach item="id" collection="array" open="(" separator="," close=")">
  126. #{deviceId}
  127. </foreach>
  128. </update>
  129. <select id="deviceList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  130. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  131. select device_id from
  132. rqiot.rq_iot_device_person where person_id = #{userId}
  133. </select>
  134. <select id="fillListByUserId" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  135. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  136. select
  137. distinct
  138. a.*,
  139. b.name org_name
  140. from
  141. rq_iot_opeation_fill a,
  142. system_dept b,
  143. rqiot.rq_iot_model_template_attrs c
  144. where
  145. a.dept_id = b.id
  146. and
  147. a.device_category_id = c.device_category_id
  148. <if test="orderId != null and orderId != ''">
  149. and a.order_id = #{orderId}
  150. </if>
  151. </select>
  152. <select id="fillListByDeptId" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  153. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  154. select
  155. distinct
  156. a.*,
  157. b.name org_name
  158. from
  159. rq_iot_opeation_fill a,
  160. system_dept b,
  161. rqiot.rq_iot_model_template_attrs c
  162. where
  163. a.dept_id = b.id
  164. and
  165. a.device_category_id = c.device_category_id
  166. <if test="orderId != null and orderId != ''">
  167. and a.order_id = #{orderId}
  168. </if>
  169. <if test="deviceId != null and deviceId != ''">
  170. and a.device_id = #{deviceId}
  171. </if>
  172. </select>
  173. <select id="fillRecords" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO"
  174. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
  175. select a.*
  176. from
  177. rq_iot_opeation_fill_order a,
  178. rq_iot_opeation_fill b
  179. where
  180. a.id = b.order_id
  181. and
  182. b.device_id = #{deviceId}
  183. <if test="orderName != null and orderName != ''">
  184. and a.order_name like #{orderName}
  185. </if>
  186. <if test="orderStatus != null and orderStatus != ''">
  187. and a.order_status like #{orderStatus}
  188. </if>
  189. </select>
  190. <select id="rhList"
  191. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  192. SELECT au.id, au.name, au.parent_id
  193. FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
  194. (SELECT @parent_id := '157') pd
  195. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  196. AND @parent_id := concat(@parent_id, ',', id)
  197. UNION
  198. SELECT id, name, parent_id
  199. FROM system_dept
  200. WHERE id = '157'
  201. ORDER BY id;
  202. </select>
  203. <select id="rdList"
  204. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  205. SELECT au.id, au.name, au.parent_id
  206. FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
  207. (SELECT @parent_id := '163') pd
  208. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  209. AND @parent_id := concat(@parent_id, ',', id)
  210. UNION
  211. SELECT id, name, parent_id
  212. FROM system_dept
  213. WHERE id = '163'
  214. ORDER BY id;
  215. </select>
  216. <select id="ryList"
  217. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  218. SELECT au.id, au.name, au.parent_id
  219. FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
  220. (SELECT @parent_id := '158') pd
  221. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  222. AND @parent_id := concat(@parent_id, ',', id)
  223. UNION
  224. SELECT id, name, parent_id
  225. FROM system_dept
  226. WHERE id = '158'
  227. ORDER BY id;
  228. </select>
  229. <select id="pdList1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  230. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  231. SELECT au.id, au.name, au.parent_id
  232. FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
  233. (SELECT @parent_id := #{id}) pd
  234. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  235. AND @parent_id := concat(@parent_id, ',', id)
  236. UNION
  237. SELECT id, name, parent_id
  238. FROM system_dept
  239. WHERE id = #{id}
  240. ORDER BY id;
  241. </select>
  242. <select id="flList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
  243. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  244. SELECT au.id, au.name, au.parent_id
  245. FROM (SELECT * FROM rq_iot_product_classify WHERE parent_id IS NOT NULL) au,
  246. (SELECT @parent_id := #{id}) pd
  247. WHERE FIND_IN_SET(parent_id, @parent_id) > 0
  248. AND @parent_id := concat(@parent_id, ',', id)
  249. UNION
  250. SELECT id, name, parent_id
  251. FROM rqiot.rq_iot_product_classify
  252. WHERE id = #{id}
  253. ORDER BY id;
  254. </select>
  255. <select id="pdList" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  256. select
  257. distinct
  258. a.id user_id,
  259. a.nickname user_name,
  260. a.dept_id,
  261. a.mobile
  262. from
  263. system_users a,
  264. rq_iot_device_person b
  265. where
  266. a.id = b.person_id
  267. </select>
  268. <select id="fillList1" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  269. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
  270. SELECT * FROM
  271. rqiot.rq_iot_opeation_fill_order
  272. WHERE 1=1
  273. <if test="deptId != null and deptId != ''">
  274. and dept_id = #{deptId}
  275. </if>
  276. </select>
  277. <select id="getAttrsById" parameterType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO"
  278. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotModelTemplateAttrsDO">
  279. select
  280. name,
  281. type,
  282. model_attr,
  283. is_sum
  284. from
  285. rqiot.rq_iot_model_template_attrs
  286. where
  287. device_category_id = #{deviceCategoryId} and deleted = 0
  288. </select>
  289. <update id="updateFill" parameterType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotOpeationModelPageReqVO">
  290. update rqiot.rq_iot_opeation_fill
  291. set is_fill = '1'
  292. where device_id = #{deviceId}
  293. and DATE(create_time) = DATE(#{createTime})
  294. </update>
  295. <select id="getFillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
  296. resultType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO">
  297. select distinct b.* from
  298. rq_iot_opeation_fill b
  299. where
  300. b.order_id = #{orderId}
  301. and
  302. DATE(b.create_time)=DATE(#{createTime})
  303. order by b.create_time desc
  304. </select>
  305. <select id="getDeivceFillInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  306. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  307. <!--SELECT * FROM rq_iot_device_run_log
  308. WHERE
  309. device_id = #{deviceId}
  310. and
  311. create_time = (SELECT MAX(create_time) FROM rq_iot_device_run_log WHERE
  312. device_id = #{deviceId})-->
  313. SELECT
  314. point_name,
  315. fill_content,
  316. (select max(total_run_time) from rq_iot_device_run_log where device_id = #{deviceId})total_run_time
  317. FROM rq_iot_device_run_log
  318. WHERE
  319. device_id = #{deviceId}
  320. and
  321. DATE(create_time) = DATE(#{createTime})
  322. order by id
  323. desc
  324. limit 1
  325. </select>
  326. <select id="getLogInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  327. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  328. <!--SELECT * FROM rq_iot_device_run_log
  329. WHERE
  330. device_id = #{deviceId}
  331. and
  332. create_time = (SELECT MAX(create_time) FROM rq_iot_device_run_log WHERE
  333. device_id = #{deviceId})-->
  334. SELECT
  335. *
  336. FROM rq_iot_device_run_log
  337. WHERE
  338. device_id = #{deviceId}
  339. and
  340. point_name = #{pointName}
  341. and
  342. DATE(create_time) = DATE(#{createTime})
  343. order by id
  344. desc
  345. limit 1
  346. </select>
  347. <select id="getMaxFillInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
  348. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  349. <!--SELECT * FROM rq_iot_device_run_log
  350. WHERE
  351. device_id = #{deviceId}
  352. and
  353. create_time = (SELECT MAX(create_time) FROM rq_iot_device_run_log WHERE
  354. device_id = #{deviceId})-->
  355. select max(total_run_time)total_run_time
  356. from rq_iot_device_run_log
  357. where
  358. device_id = #{deviceId}
  359. and
  360. point_name=#{pointName}
  361. </select>
  362. <update id="updateFillOrder" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  363. update rqiot.rq_iot_opeation_fill_order set order_status = 1 where id = #{id}
  364. </update>
  365. <update id="updateFillOrder1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  366. update rqiot.rq_iot_opeation_fill_order set order_status = 0 where id = #{id}
  367. </update>
  368. <update id="updateFillOrder2" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
  369. update rqiot.rq_iot_opeation_fill_order set order_status = 2 where id = #{id}
  370. </update>
  371. <select id="carList"
  372. resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotZHBD.DeviceZHBDDO">
  373. select distinct device_code ,car_id from rqiot.rq_iot_car_zhbd
  374. </select>
  375. <update id="upLocation"
  376. parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotZHBD.DeviceZHBDDO">
  377. update rq_iot_device set location= #{location} where device_code = #{deviceCode}
  378. </update>
  379. </mapper>