ThingSettingMapper.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.huaxu.dao.ThingSettingMapper">
  6. <resultMap type="ThingSettingEntity" id="ThingSettingResult">
  7. <result property="id" column="id"/>
  8. <result property="tenantId" column="tenant_id"/>
  9. <result property="companyOrgId" column="company_org_id"/>
  10. <result property="deptOrgId" column="dept_org_id"/>
  11. <result property="thingType" column="thing_type"/>
  12. <result property="thingObjectType" column="thing_object_type"/>
  13. <result property="thingBore" column="thing_bore"/>
  14. <result property="thingLength" column="thing_length"/>
  15. <result property="thingCount" column="thing_count"/>
  16. <result property="remark" column="remark"/>
  17. <result property="status" column="status"/>
  18. <result property="dateCreate" column="date_create"/>
  19. <result property="createBy" column="create_by"/>
  20. <result property="dateUpdate" column="date_update"/>
  21. <result property="updateBy" column="update_by"/>
  22. </resultMap>
  23. <!-- 实体栏位 -->
  24. <sql id="thingSettingColumns">
  25. a.id as "id" ,
  26. a.tenant_id as "tenantId" ,
  27. a.company_org_id as "companyOrgId" ,
  28. a.dept_org_id as "deptOrgId" ,
  29. a.thing_type as "thingType" ,
  30. a.thing_object_type as "thingObjectType" ,
  31. a.thing_bore as "thingBore" ,
  32. a.thing_length as "thingLength" ,
  33. a.thing_count as "thingCount" ,
  34. a.remark as "remark" ,
  35. a.status as "status" ,
  36. a.date_create as "dateCreate" ,
  37. a.create_by as "createBy" ,
  38. a.date_update as "dateUpdate" ,
  39. a.update_by as "updateBy"
  40. </sql>
  41. <!-- 根据主键获取实体 -->
  42. <select id="findThingSettingById" resultType="com.huaxu.entity.ThingSettingEntity">
  43. SELECT
  44. <include refid="thingSettingColumns"/>
  45. FROM sms_thing_setting a
  46. WHERE a.id = #{id} and a.status=1
  47. </select>
  48. <!-- 根据获取实体List -->
  49. <select id="findList" resultType="com.huaxu.entity.ThingSettingEntity">
  50. SELECT
  51. <include refid="thingSettingColumns"/>
  52. FROM sms_thing_setting a
  53. <where>
  54. a.status=1
  55. <if test="thingSetting.tenantId != null and thingSetting.tenantId != ''">and a.tenant_id = #{thingSetting.tenantId}</if>
  56. <if test="thingSetting.thingType != null ">and a.thing_type = #{thingSetting.thingType}</if>
  57. <if test="thingSetting.thingObjectType != null ">and a.thing_object_type = #{thingSetting.thingObjectType}</if>
  58. <if test="thingSetting.userType!=null and thingSetting.userType!=-999 and thingSetting.userType!=-9999 and thingSetting.programItems != null and thingSetting.programItems.size() > 0">
  59. <if test="thingSetting.permissonType == 5 or thingSetting.permissonType == 2">
  60. and ( a.DEPT_ORG_ID in
  61. <foreach collection="thingSetting.programItems" item="item" open="(" close=")" separator=",">
  62. #{item.orgId}
  63. </foreach>
  64. or
  65. a.COMPANY_ORG_ID in
  66. <foreach collection="thingSetting.programItems" item="item" open="(" close=")" separator=",">
  67. #{item.orgId}
  68. </foreach>
  69. )
  70. </if>
  71. <if test="thingSetting.permissonType == 4 or thingSetting.permissonType == 3">
  72. and a.DEPT_ORG_ID in
  73. <foreach collection="thingSetting.programItems" item="item" open="(" close=")" separator=",">
  74. #{item.orgId}
  75. </foreach>
  76. </if>
  77. <if test="thingSetting.permissonType == 1">
  78. and a.COMPANY_ORG_ID in
  79. <foreach collection="thingSetting.programItems" item="item" open="(" close=")" separator=",">
  80. #{item.orgId}
  81. </foreach>
  82. and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
  83. </if>
  84. </if>
  85. </where>
  86. </select>
  87. <!-- 根据获取实体List -->
  88. <select id="findTotalList" resultType="com.huaxu.entity.ThingSettingEntity">
  89. SELECT
  90. a.thing_type as "thingType",sum(a.thing_length) as "thingLength" , sum(a.thing_count) as "thingCount"
  91. FROM sms_thing_setting a
  92. <where>
  93. a.status=1
  94. <if test="thingSetting.tenantId != null and thingSetting.tenantId != ''">and a.tenant_id = #{thingSetting.tenantId}</if>
  95. <if test="thingSetting.thingType != null ">and a.thing_type = #{thingSetting.thingType}</if>
  96. <if test="thingSetting.thingObjectType != null ">and a.thing_object_type = #{thingSetting.thingObjectType}</if>
  97. <if test="thingSetting.userType!=null and thingSetting.userType!=-999 and thingSetting.userType!=-9999 and thingSetting.programItems != null and thingSetting.programItems.size() > 0">
  98. <if test="thingSetting.permissonType == 5 or thingSetting.permissonType == 2">
  99. and ( a.DEPT_ORG_ID in
  100. <foreach collection="thingSetting.programItems" item="item" open="(" close=")" separator=",">
  101. #{item.orgId}
  102. </foreach>
  103. or
  104. a.COMPANY_ORG_ID in
  105. <foreach collection="thingSetting.programItems" item="item" open="(" close=")" separator=",">
  106. #{item.orgId}
  107. </foreach>
  108. )
  109. </if>
  110. <if test="thingSetting.permissonType == 4 or thingSetting.permissonType == 3">
  111. and a.DEPT_ORG_ID in
  112. <foreach collection="thingSetting.programItems" item="item" open="(" close=")" separator=",">
  113. #{item.orgId}
  114. </foreach>
  115. </if>
  116. <if test="thingSetting.permissonType == 1">
  117. and a.COMPANY_ORG_ID in
  118. <foreach collection="thingSetting.programItems" item="item" open="(" close=")" separator=",">
  119. #{item.orgId}
  120. </foreach>
  121. and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
  122. </if>
  123. </if>
  124. </where>
  125. group by a.thing_type
  126. </select>
  127. <!-- 根据获取实体 page -->
  128. <select id="findPage" resultType="com.huaxu.entity.ThingSettingEntity">
  129. SELECT
  130. <include refid="thingSettingColumns"/>
  131. FROM sms_thing_setting a
  132. <where>
  133. a.status=1
  134. <if test="thingSetting.tenantId != null and thingSetting.tenantId != ''">and a.tenant_id =
  135. #{thingSetting.tenantId}
  136. </if>
  137. <if test="thingSetting.thingType != null ">and a.thing_type = #{thingSetting.thingType}</if>
  138. <if test="thingSetting.thingObjectType != null ">and a.thing_object_type = #{thingSetting.thingObjectType}
  139. </if>
  140. </where>
  141. </select>
  142. </mapper>