GoafSensorMapper.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.goaf.mapper.GoafSensorMapper">
  5. <resultMap id="GoafSensorMapper" type="com.zhyc.xps.goaf.entity.GoafSensor">
  6. <id column="goaf_sensor_id" property="goafSensorId" jdbcType="BIGINT"/>
  7. <result column="oc_id" property="ocId" jdbcType="BIGINT"/>
  8. <result column="goaf_sensor_name" property="goafSensorName" jdbcType="VARCHAR"/>
  9. <result column="sensor_code" property="sensorCode" jdbcType="BIGINT"/>
  10. <result column="modbus_id" property="modbusId" jdbcType="BIGINT"/>
  11. <result column="sensor_baudrate" property="sensorBaudrate" jdbcType="BIGINT"/>
  12. <result column="goaf_sensor_ip" property="goafSensorIp" jdbcType="VARCHAR"/>
  13. <result column="goaf_dev_name" property="goafDevName" jdbcType="VARCHAR"/>
  14. <result column="goaf_dev_typename" property="goafDevTypename" jdbcType="VARCHAR"/>
  15. <result column="goaf_sensor_location" property="goafSensorLocation" jdbcType="VARCHAR"/>
  16. <result column="goaf_check_time_interval" property="goafCheckTimeInterval" jdbcType="BIGINT"/>
  17. <result column="goaf_install_time" property="goafInstallTime" jdbcType="TIMESTAMP"/>
  18. <result column="goaf_sensor_status" property="goafSensorStatus" jdbcType="BIGINT"/>
  19. <result column="thv_acc_x" property="thvAccX" jdbcType="BIGINT"/>
  20. <result column="thv_acc_y" property="thvAccY" jdbcType="BIGINT"/>
  21. <result column="thv_acc_z" property="thvAccZ" jdbcType="BIGINT"/>
  22. <result column="thv_vel_x" property="thvVelX" jdbcType="BIGINT"/>
  23. <result column="thv_vel_y" property="thvVelY" jdbcType="BIGINT"/>
  24. <result column="thv_vel_z" property="thvVelZ" jdbcType="BIGINT"/>
  25. <result column="thv_dis_x" property="thvDisX" jdbcType="BIGINT"/>
  26. <result column="thv_dis_y" property="thvDisY" jdbcType="BIGINT"/>
  27. <result column="thv_dis_z" property="thvDisZ" jdbcType="BIGINT"/>
  28. <result column="thv_temperature" property="thvTemperature" jdbcType="BIGINT"/>
  29. </resultMap>
  30. <resultMap id="GoafSensorAlarmOverviewMapper" type="com.zhyc.xps.goaf.dto.GoafSensoralarmOverviewDto">
  31. <result column="goaf_sensor_name" property="goafSensorName" jdbcType="VARCHAR"/>
  32. <result column="goaf_sensor_location" property="goafSensorLocation" jdbcType="VARCHAR"/>
  33. <result column="goaf_sensor_status" property="goafSensorStatus" jdbcType="BIGINT"/>
  34. <result column="goaf_install_time" property="goafInstallTime" jdbcType="TIMESTAMP"/>
  35. <result column="goaf_sensor_alarm_id" property="goafSensorAlarmId" jdbcType="BIGINT"/>
  36. <result column="goaf_sensor_alarm_level" property="goafSensorAlarmLevel" jdbcType="BIGINT"/>
  37. <result column="goaf_sensor_alarm_type" property="goafSensorAlarmType" jdbcType="VARCHAR"/>
  38. <result column="goaf_datareport_time" property="goafDatareportTime" jdbcType="TIMESTAMP"/>
  39. </resultMap>
  40. <!-- <select id="getGoafDevOverview" parameterType="java.util.Map" resultMap="GoafSensorAlarmOverviewMapper">-->
  41. <!-- SELECT C.goaf_sensor_name, C.goaf_sensor_location, C.goaf_sensor_status, C.goaf_install_time,-->
  42. <!-- B.goaf_sensor_alarm_id, B.goaf_sensor_alarm_level, B.goaf_sensor_alarm_type, A.goaf_datareport_time-->
  43. <!-- FROM goaf_sensor AS C-->
  44. <!-- LEFT JOIN-->
  45. <!-- (SELECT goaf_sensor_id, goaf_data_id, goaf_datareport_time-->
  46. <!-- FROM goaf_sensordata-->
  47. <!-- ORDER BY goaf_datareport_time DESC-->
  48. <!-- LIMIT 1) AS A ON A.goaf_sensor_id = C.goaf_sensor_id-->
  49. <!-- LEFT JOIN goaf_sensoralarm AS B ON A.goaf_data_id = B.goaf_data_id-->
  50. <!-- WHERE C.goaf_sensor_id = #{goafSensorId ,jdbcType=BIGINT}-->
  51. <!-- </select>-->
  52. <select id="getGoafDevOverview" parameterType="java.util.Map" resultMap="GoafSensorAlarmOverviewMapper">
  53. SELECT C.goaf_sensor_name, C.goaf_sensor_location, C.goaf_sensor_status, C.goaf_install_time,
  54. B.goaf_sensor_alarm_id, B.goaf_sensor_alarm_level, B.goaf_sensor_alarm_type, A.goaf_datareport_time
  55. FROM goaf_sensor AS C
  56. LEFT JOIN
  57. (SELECT goaf_sensor_id, goaf_data_id, goaf_datareport_time
  58. FROM goaf_sensordata_new
  59. ) AS A ON A.goaf_sensor_id = C.goaf_sensor_id
  60. LEFT JOIN goaf_sensoralarm AS B ON A.goaf_data_id = B.goaf_data_id
  61. WHERE C.goaf_sensor_id = #{goafSensorId ,jdbcType=BIGINT}
  62. </select>
  63. <select id="getByList" parameterType="java.util.Map" resultMap="GoafSensorMapper">
  64. SELECT *
  65. FROM goaf_sensor
  66. <trim prefix="where" prefixOverrides="AND">
  67. <if test="ocId !=null">
  68. oc_id = #{ocId ,jdbcType=BIGINT}
  69. </if>
  70. <if test="goafSensorName !=null and goafSensorName != ''">
  71. AND goaf_sensor_name = #{goafSensorName ,jdbcType=VARCHAR}
  72. </if>
  73. <if test="goafDevName !=null and goafDevName != ''">
  74. AND goaf_dev_name = #{goafDevName ,jdbcType=VARCHAR}
  75. </if>
  76. <if test="goafSensorStatus !=null and goafSensorStatus != ''">
  77. AND goaf_sensor_status = #{goafSensorStatus ,jdbcType=BIGINT}
  78. </if>
  79. <if test="startDate != null and startDate !='' and endDate != null and endDate != ''">
  80. AND goaf_install_time BETWEEN #{startDate} AND #{endDate}
  81. </if>
  82. </trim>
  83. </select>
  84. <!--分页查询-->
  85. <select id="getByPage" parameterType="java.util.Map" resultMap="GoafSensorMapper">
  86. SELECT *
  87. FROM goaf_sensor
  88. <trim prefix="where" prefixOverrides="AND">
  89. <if test="ocId !=null">
  90. oc_id = #{ocId ,jdbcType=BIGINT}
  91. </if>
  92. <if test="goafSensorName !=null and goafSensorName != ''">
  93. AND goaf_sensor_name = #{goafSensorName ,jdbcType=VARCHAR}
  94. </if>
  95. <if test="goafSensorStatus !=null and goafSensorStatus != ''">
  96. AND goaf_sensor_status = #{goafSensorStatus ,jdbcType=BIGINT}
  97. </if>
  98. <if test="startDate != null and startDate !='' and endDate != null and endDate != ''">
  99. AND goaf_install_time BETWEEN #{startDate} AND #{endDate}
  100. </if>
  101. </trim>
  102. </select>
  103. <select id="getByGoafSensorId" resultMap="GoafSensorMapper">
  104. SELECT *
  105. FROM goaf_sensor
  106. WHERE goaf_sensor_id = #{goafSensorId, jdbcType=BIGINT}
  107. </select>
  108. <select id="getByGoafSensorIP" resultMap="GoafSensorMapper">
  109. SELECT *
  110. FROM goaf_sensor
  111. WHERE goaf_sensor_ip = #{goafSensorIP, jdbcType=VARCHAR}
  112. </select>
  113. <select id="getByGoafsensorCode" resultMap="GoafSensorMapper">
  114. SELECT *
  115. FROM goaf_sensor
  116. WHERE sensor_code = #{sensorCode, jdbcType=BIGINT}
  117. </select>
  118. <select id="getByGoafModbusId" resultMap="GoafSensorMapper">
  119. SELECT *
  120. FROM goaf_sensor
  121. WHERE modbus_id = #{modbusId, jdbcType=BIGINT}
  122. </select>
  123. <select id="getByGoafSensorName" resultMap="GoafSensorMapper">
  124. SELECT *
  125. FROM goaf_sensor
  126. <if test="ocId !=null">
  127. oc_id = #{ocId ,jdbcType=BIGINT}
  128. </if>
  129. WHERE goaf_sensor_name = #{goafSensorName, jdbcType=VARCHAR}
  130. </select>
  131. <insert id="create" parameterType="com.zhyc.xps.goaf.entity.GoafSensor">
  132. insert into goaf_sensor
  133. <trim prefix="(" suffix=")" suffixOverrides=",">
  134. <if test="goafSensorId != null">
  135. goaf_sensor_id,
  136. </if>
  137. <if test="ocId != null">
  138. oc_id,
  139. </if>
  140. <if test="goafSensorName != null and goafSensorName != ''">
  141. goaf_sensor_name,
  142. </if>
  143. <if test="sensorCode != null">
  144. sensor_code,
  145. </if>
  146. <if test="modbusId != null">
  147. modbus_id,
  148. </if>
  149. <if test="sensorBaudrate != null">
  150. sensor_baudrate,
  151. </if>
  152. <if test="goafSensorIp != null and goafSensorIp != ''">
  153. goaf_sensor_ip,
  154. </if>
  155. <if test="goafDevName != null and goafDevName != ''">
  156. goaf_dev_name,
  157. </if>
  158. <if test="goafDevTypename != null and goafDevTypename != ''">
  159. goaf_dev_typename,
  160. </if>
  161. <if test="goafSensorLocation != null and goafSensorLocation != ''">
  162. goaf_sensor_location,
  163. </if>
  164. <if test="goafCheckTimeInterval != null">
  165. goaf_check_time_interval,
  166. </if>
  167. <if test="goafInstallTime != null">
  168. goaf_install_time,
  169. </if>
  170. <if test="goafSensorStatus != null">
  171. goaf_sensor_status,
  172. </if>
  173. <if test="thvAccX != null">
  174. thv_acc_x,
  175. </if>
  176. <if test="thvAccY != null">
  177. thv_acc_y,
  178. </if>
  179. <if test="thvAccZ != null">
  180. thv_acc_z,
  181. </if>
  182. <if test="thvVelX != null">
  183. thv_vel_x,
  184. </if>
  185. <if test="thvVelY != null">
  186. thv_vel_y,
  187. </if>
  188. <if test="thvVelZ != null">
  189. thv_vel_z,
  190. </if>
  191. <if test="thvDisX != null">
  192. thv_dis_x,
  193. </if>
  194. <if test="thvDisY != null">
  195. thv_dis_y,
  196. </if>
  197. <if test="thvDisZ != null">
  198. thv_dis_z,
  199. </if>
  200. <if test="thvTemperature != null">
  201. thv_temperature,
  202. </if>
  203. <if test="ewAccX1 != null">
  204. ew_acc_x_1,
  205. </if>
  206. <if test="ewAccX2 != null">
  207. ew_acc_x_2,
  208. </if>
  209. <if test="ewAccX3 != null">
  210. ew_acc_x_3,
  211. </if>
  212. <if test="ewAccX4 != null">
  213. ew_acc_x_4,
  214. </if>
  215. <if test="ewAccY1 != null">
  216. ew_acc_y_1,
  217. </if>
  218. <if test="ewAccY2 != null">
  219. ew_acc_y_2,
  220. </if>
  221. <if test="ewAccY3 != null">
  222. ew_acc_y_3,
  223. </if>
  224. <if test="ewAccY4 != null">
  225. ew_acc_y_4,
  226. </if>
  227. <if test="ewAccZ1 != null">
  228. ew_acc_z_1,
  229. </if>
  230. <if test="ewAccZ2 != null">
  231. ew_acc_z_2,
  232. </if>
  233. <if test="ewAccZ3 != null">
  234. ew_acc_z_3,
  235. </if>
  236. <if test="ewAccZ4 != null">
  237. ew_acc_z_4,
  238. </if>
  239. </trim>
  240. <trim prefix="values (" suffix=")" suffixOverrides=",">
  241. <if test="goafSensorId != null">
  242. #{goafSensorId, jdbcType=BIGINT},
  243. </if>
  244. <if test="ocId != null">
  245. #{ocId, jdbcType=BIGINT},
  246. </if>
  247. <if test="goafSensorName != null and goafSensorName != ''">
  248. #{goafSensorName, jdbcType=VARCHAR},
  249. </if>
  250. <if test="sensorCode != null">
  251. #{sensorCode, jdbcType=BIGINT},
  252. </if>
  253. <if test="modbusId != null">
  254. #{modbusId, jdbcType=BIGINT},
  255. </if>
  256. <if test="sensorBaudrate != null">
  257. #{sensorBaudrate, jdbcType=BIGINT},
  258. </if>
  259. <if test="goafSensorIp != null and goafSensorIp != ''">
  260. #{goafSensorIp, jdbcType=VARCHAR},
  261. </if>
  262. <if test="goafDevName != null and goafDevName != ''">
  263. #{goafDevName, jdbcType=VARCHAR},
  264. </if>
  265. <if test="goafDevTypename != null and goafDevTypename != ''">
  266. #{goafDevTypename, jdbcType=VARCHAR},
  267. </if>
  268. <if test="goafSensorLocation != null and goafSensorLocation != ''">
  269. #{goafSensorLocation, jdbcType=VARCHAR},
  270. </if>
  271. <if test="goafCheckTimeInterval != null">
  272. #{goafCheckTimeInterval, jdbcType=BIGINT},
  273. </if>
  274. <if test="goafInstallTime != null">
  275. #{goafInstallTime, jdbcType=TIMESTAMP},
  276. </if>
  277. <if test="goafSensorStatus != null">
  278. #{goafSensorStatus, jdbcType=BIGINT},
  279. </if>
  280. <if test="thvAccX != null">
  281. #{thvAccX, jdbcType=BIGINT},
  282. </if>
  283. <if test="thvAccY != null">
  284. #{thvAccY, jdbcType=BIGINT},
  285. </if>
  286. <if test="thvAccZ != null">
  287. #{thvAccZ, jdbcType=BIGINT},
  288. </if>
  289. <if test="thvVelX != null">
  290. #{thvVelX, jdbcType=BIGINT},
  291. </if>
  292. <if test="thvVelY != null">
  293. #{thvVelY, jdbcType=BIGINT},
  294. </if>
  295. <if test="thvVelZ != null">
  296. #{thvVelZ, jdbcType=BIGINT},
  297. </if>
  298. <if test="thvDisX != null">
  299. #{thvDisX, jdbcType=BIGINT},
  300. </if>
  301. <if test="thvDisY != null">
  302. #{thvDisY, jdbcType=BIGINT},
  303. </if>
  304. <if test="thvDisZ != null">
  305. #{thvDisZ, jdbcType=BIGINT},
  306. </if>
  307. <if test="thvTemperature != null">
  308. #{thvTemperature, jdbcType=BIGINT},
  309. </if>
  310. <if test="ewAccX1 != null">
  311. #{ewAccX1, jdbcType=BIGINT},
  312. </if>
  313. <if test="ewAccX2 != null">
  314. #{ewAccX2, jdbcType=BIGINT},
  315. </if>
  316. <if test="ewAccX3 != null">
  317. #{ewAccX3, jdbcType=BIGINT},
  318. </if>
  319. <if test="ewAccX4 != null">
  320. #{ewAccX4, jdbcType=BIGINT},
  321. </if>
  322. <if test="ewAccY1 != null">
  323. #{ewAccY1, jdbcType=BIGINT},
  324. </if>
  325. <if test="ewAccY2 != null">
  326. #{ewAccY2, jdbcType=BIGINT},
  327. </if>
  328. <if test="ewAccY3 != null">
  329. #{ewAccY3, jdbcType=BIGINT},
  330. </if>
  331. <if test="ewAccY4 != null">
  332. #{ewAccY4, jdbcType=BIGINT},
  333. </if>
  334. <if test="ewAccZ1 != null">
  335. #{ewAccZ1, jdbcType=BIGINT},
  336. </if>
  337. <if test="ewAccZ2 != null">
  338. #{ewAccZ2, jdbcType=BIGINT},
  339. </if>
  340. <if test="ewAccZ3 != null">
  341. #{ewAccZ3, jdbcType=BIGINT},
  342. </if>
  343. <if test="ewAccZ4 != null">
  344. #{ewAccZ4, jdbcType=BIGINT},
  345. </if>
  346. </trim>
  347. </insert>
  348. <!--Update更新-->
  349. <update id="update" parameterType="com.zhyc.xps.goaf.entity.GoafSensor">
  350. UPDATE goaf_sensor
  351. <trim suffixOverrides=",">
  352. <set>
  353. <if test="goafSensorName != null and goafSensorName != ''">
  354. goaf_sensor_name = #{goafSensorName, jdbcType=VARCHAR},
  355. </if>
  356. <if test="sensorCode != null">
  357. sensor_code = #{sensorCode, jdbcType=BIGINT},
  358. </if>
  359. <if test="modbusId != null">
  360. modbus_id = #{modbusId, jdbcType=BIGINT},
  361. </if>
  362. <if test="sensorBaudrate != null">
  363. sensor_baudrate = #{sensorBaudrate, jdbcType=BIGINT},
  364. </if>
  365. <if test="goafSensorIp != null and goafSensorIp != ''">
  366. goaf_sensor_ip = #{goafSensorIp, jdbcType=VARCHAR},
  367. </if>
  368. <if test="goafDevName != null and goafDevName != ''">
  369. goaf_dev_name = #{goafDevName, jdbcType=VARCHAR},
  370. </if>
  371. <if test="goafDevTypename != null and goafDevTypename != ''">
  372. goaf_dev_typename = #{goafDevTypename, jdbcType=VARCHAR},
  373. </if>
  374. <if test="goafSensorLocation != null and goafSensorLocation != ''">
  375. goaf_sensor_location = #{goafSensorLocation, jdbcType=VARCHAR},
  376. </if>
  377. <if test="goafCheckTimeInterval != null">
  378. goaf_check_time_interval = #{goafCheckTimeInterval, jdbcType=BIGINT},
  379. </if>
  380. <if test="goafInstallTime != null">
  381. goaf_install_time = #{goafInstallTime, jdbcType=TIMESTAMP},
  382. </if>
  383. <if test="goafSensorStatus != null">
  384. goaf_sensor_status = #{goafSensorStatus, jdbcType=BIGINT},
  385. </if>
  386. <if test="thvAccX != null">
  387. thv_acc_x = #{thvAccX, jdbcType=BIGINT},
  388. </if>
  389. <if test="thvAccY != null">
  390. thv_acc_y = #{thvAccY, jdbcType=BIGINT},
  391. </if>
  392. <if test="thvAccZ != null">
  393. thv_acc_z = #{thvAccZ, jdbcType=BIGINT},
  394. </if>
  395. <if test="thvVelX != null">
  396. thv_vel_x = #{thvVelX, jdbcType=BIGINT},
  397. </if>
  398. <if test="thvVelY != null">
  399. thv_vel_y = #{thvVelY, jdbcType=BIGINT},
  400. </if>
  401. <if test="thvVelZ != null">
  402. thv_vel_z = #{thvVelZ, jdbcType=BIGINT},
  403. </if>
  404. <if test="thvDisX != null">
  405. thv_dis_x = #{thvDisX, jdbcType=BIGINT},
  406. </if>
  407. <if test="thvDisY != null">
  408. thv_dis_y = #{thvDisY, jdbcType=BIGINT},
  409. </if>
  410. <if test="thvDisZ != null">
  411. thv_dis_z = #{thvDisZ, jdbcType=BIGINT},
  412. </if>
  413. <if test="thvTemperature != null">
  414. thv_temperature = #{thvTemperature, jdbcType=BIGINT},
  415. </if>
  416. <if test="ewAccX1 != null">
  417. ew_acc_x_1 = #{ewAccX1, jdbcType=BIGINT},
  418. </if>
  419. <if test="ewAccX2 != null">
  420. ew_acc_x_2 = #{ewAccX2, jdbcType=BIGINT},
  421. </if>
  422. <if test="ewAccX3 != null">
  423. ew_acc_x_3 = #{ewAccX3, jdbcType=BIGINT},
  424. </if>
  425. <if test="ewAccX4 != null">
  426. ew_acc_x_4 = #{ewAccX4, jdbcType=BIGINT},
  427. </if>
  428. <if test="ewAccY1 != null">
  429. ew_acc_y_1 = #{ewAccY1, jdbcType=BIGINT},
  430. </if>
  431. <if test="ewAccY2 != null">
  432. ew_acc_y_2 = #{ewAccY2, jdbcType=BIGINT},
  433. </if>
  434. <if test="ewAccY3 != null">
  435. ew_acc_y_3 = #{ewAccY3, jdbcType=BIGINT},
  436. </if>
  437. <if test="ewAccY4 != null">
  438. ew_acc_y_4 = #{ewAccY4, jdbcType=BIGINT},
  439. </if>
  440. <if test="ewAccZ1 != null">
  441. ew_acc_z_1 = #{ewAccZ1, jdbcType=BIGINT},
  442. </if>
  443. <if test="ewAccZ2 != null">
  444. ew_acc_z_2 = #{ewAccZ2, jdbcType=BIGINT},
  445. </if>
  446. <if test="ewAccZ3 != null">
  447. ew_acc_z_3 = #{ewAccZ3, jdbcType=BIGINT},
  448. </if>
  449. <if test="ewAccZ4 != null">
  450. ew_acc_z_4 = #{ewAccZ4, jdbcType=BIGINT},
  451. </if>
  452. </set>
  453. </trim>
  454. WHERE goaf_sensor_id = #{goafSensorId, jdbcType=BIGINT}
  455. </update>
  456. <delete id="delete" >
  457. DELETE FROM goaf_sensor
  458. WHERE goaf_sensor_id = #{goafSensorId, jdbcType=BIGINT}
  459. </delete>
  460. <!--列表查询-->
  461. <select id="getStatisNum" parameterType="java.util.Map" resultType="com.zhyc.xps.goaf.vo.DevStatisVo">
  462. SELECT
  463. COUNT(*) AS 'goafSensorTotalNum',
  464. IFNULL(SUM( CASE WHEN goaf_sensor_status = 1 THEN 1 ELSE 0 END ), 0) AS 'sensorOnlineNum'
  465. FROM goaf_sensor
  466. WHERE oc_id = #{ocId ,jdbcType=BIGINT}
  467. </select>
  468. </mapper>