物管理后端
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.

105 lines
4.4 KiB

  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.thing.device.source.mapper.IotThingSourceMapper">
  4. <resultMap type="com.thing.device.source.entity.IotThingSourceEntity" id="iotThingSourceMap">
  5. <result property="id" column="id"/>
  6. <result property="pid" column="pid"/>
  7. <result property="thingRelationId" column="thing_relation_id"/>
  8. <result property="thingName" column="thing_name"/>
  9. <result property="thingCode" column="thing_code"/>
  10. <result property="thingAttrName" column="thing_attr_name"/>
  11. <result property="thingAttrCode" column="thing_attr_code"/>
  12. <result property="thingAttrCodeType" column="thing_attr_code_type"/>
  13. <result property="thingAttrType" column="thing_attr_type"/>
  14. <result property="thingAttrUnit" column="thing_attr_unit"/>
  15. <result property="thingIcon" column="thing_icon"/>
  16. <result property="gatherFrequency" column="gather_frequency"/>
  17. <result property="dataTreatingMark" column="data_treating_mark"/>
  18. <result property="dataRule" column="data_rule"/>
  19. <result property="configType" column="config_type"/>
  20. <result property="remark" column="remark"/>
  21. <result property="extendData" column="extend_data"/>
  22. <result property="tenantCode" column="tenant_code"/>
  23. <result property="companyId" column="company_id"/>
  24. <result property="deptId" column="dept_id"/>
  25. <result property="creator" column="creator"/>
  26. <result property="createDate" column="create_date"/>
  27. <result property="updater" column="updater"/>
  28. <result property="updateDate" column="update_date"/>
  29. </resultMap>
  30. <select id="getParentList" resultType="com.thing.device.source.dto.IotThingSourcePidDTO">
  31. SELECT
  32. its.id,
  33. its.root_id,
  34. its.thing_id,
  35. its.thing_code,
  36. its.thing_attr_code,
  37. its.thing_attr_name,
  38. its.thing_attr_code_type,
  39. its.data_deal_config as data_rule,
  40. its.thing_serial,
  41. its.thing_icon,
  42. its.thing_attr_unit,
  43. its.gather_frequency,
  44. its.thing_attr_boundary,
  45. itt.ID AS thing_tenant_id,
  46. its.data_treating_mark,
  47. its.data_deal_config
  48. FROM
  49. iot_thing_source its
  50. INNER JOIN iot_thing_entity itt ON its.thing_id = itt.id
  51. <where>
  52. -- its.pid is null
  53. 1=1
  54. <if test="thingIdList != null">
  55. and its.thing_id in
  56. <foreach item="thingId" collection="thingIdList" open="(" separator="," close=")">
  57. #{thingId}
  58. </foreach>
  59. </if>
  60. <if test="rootIdList != null">
  61. and its.root_id in
  62. <foreach item="rootId" collection="rootIdList" open="(" separator="," close=")">
  63. #{rootId}
  64. </foreach>
  65. </if>
  66. <if test="thingAttrCodeList != null">
  67. and its.thing_attr_code in
  68. <foreach item="thingAttrCode" collection="thingAttrCodeList" open="(" separator="," close=")">
  69. #{thingAttrCode}
  70. </foreach>
  71. </if>
  72. <if test="thingAttrCodeType != null and thingAttrCodeType.trim() != ''">
  73. and its.thing_attr_code_type = #{thingAttrCodeType}
  74. </if>
  75. <if test="configType != null and configType.trim() != ''">
  76. and its.config_type = #{configType}
  77. </if>
  78. </where>
  79. </select>
  80. <select id="getChildList" resultType="com.thing.device.source.dto.IotThingSourcePidDTO">
  81. SELECT
  82. its.ID,
  83. its.pid,
  84. its.thing_code,
  85. its.thing_attr_code,
  86. its.thing_attr_code_type,
  87. itt.ID AS thing_id,
  88. its.thing_serial
  89. FROM
  90. iot_thing_source its
  91. INNER JOIN iot_thing_entity itt ON its.thing_id = itt.id
  92. <where>
  93. its.pid in
  94. <foreach item="pid" collection="pidList" open="(" separator="," close=")">
  95. #{pid}
  96. </foreach>
  97. </where>
  98. </select>
  99. <select id="getRootIdsByThingIdAndConfigTypeAndTenantCode" resultType="java.lang.Long">
  100. SELECT DISTINCT(root_id) from iot_thing_source where thing_id=#{thingId} and config_type=#{configType} and tenant_code=#{tenantCode}
  101. </select>
  102. </mapper>