You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.7 KiB

3 years ago
  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="com.iteaj.iboot.msn.iot.mapper.PointGroupMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.iteaj.iboot.msn.iot.entity.PointGroup">
  6. <result column="id" property="id" />
  7. <result column="name" property="name" />
  8. <result column="type_id" property="typeId" />
  9. <result column="type_name" property="typeName" />
  10. <result column="model_id" property="modelId" />
  11. <result column="model_name" property="modelName" />
  12. <result column="create_time" property="createTime" />
  13. </resultMap>
  14. <resultMap id="DetailResultMap" type="com.iteaj.iboot.msn.iot.entity.PointGroup" extends="BaseResultMap">
  15. <collection property="signalIds" ofType="java.lang.String">
  16. <constructor>
  17. <arg column="signal_id" />
  18. </constructor>
  19. </collection>
  20. </resultMap>
  21. <select id="detailOfPage" resultMap="BaseResultMap">
  22. select a.id, a.name, dm.model model_name, dm.id model_id, dy.id type_id, dy.name type_name
  23. from iot_point_group a
  24. left join iot_device_model dm on a.model_id=dm.id
  25. left join iot_device_type dy on dm.type_id=dy.id
  26. <where>
  27. <if test="entity.typeId != null">
  28. and find_in_set(#{entity.typeId}, dy.path)
  29. </if>
  30. <if test="entity.modelId != null">
  31. and dm.id=#{entity.modelId}
  32. </if>
  33. <if test="entity.name != null">
  34. and a.name like '%${entity.name}%'
  35. </if>
  36. order by a.create_time desc
  37. </where>
  38. </select>
  39. <select id="detailById" resultMap="DetailResultMap">
  40. select a.id, a.name, dm.model model_name, dm.id model_id, dy.id type_id, dy.name type_name, igp.signal_id
  41. from iot_point_group a
  42. left join iot_device_model dm on a.model_id=dm.id
  43. left join iot_device_type dy on dm.type_id=dy.id
  44. left join iot_group_point igp on igp.group_id=a.id
  45. where a.id=#{id}
  46. </select>
  47. <select id="isBindSignals" resultType="java.lang.Boolean">
  48. select a.group_id is not null from iot_group_point a
  49. where a.signal_id in (
  50. <foreach collection="list" item="id" separator=",">
  51. #{id}
  52. </foreach>
  53. )
  54. limit 1
  55. </select>
  56. <insert id="batchSaveGroupPoint">
  57. insert into iot_group_point (signal_id, group_id) values
  58. <foreach collection="list" item="item" open="(" close=")" separator=",">
  59. #{item.signalId},#{item.groupId}
  60. </foreach>
  61. </insert>
  62. </mapper>