AttOrgBaseDao.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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.com.goldenwater.dcproj.dao.AttOrgBaseDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.AttOrgBase" id="attOrgBaseResultMap">
  5. <result property="guid" column="GUID"/>
  6. <result property="pguid" column="PGUID"/>
  7. <result property="orgCode" column="ORG_CODE"/>
  8. <result property="orgName" column="ORG_NAME"/>
  9. <result property="orgLevel" column="ORG_LEVEL"/>
  10. <result property="orgGrad" column="ORG_GRAD"/>
  11. <result property="orgType" column="ORG_TYPE"/>
  12. <result property="ordernum" column="ORDERNUM"/>
  13. <result property="adCode" column="AD_CODE"/>
  14. <result property="status" column="STATUS"/>
  15. <result property="modifier" column="MODIFIER"/>
  16. <result property="fromDate" column="FROM_DATE"/>
  17. <result property="toDate" column="TO_DATE"/>
  18. <result property="note" column="NOTE"/>
  19. <result property="jurd" column="JURD"/>
  20. <result property="areaType" column="AREA_TYPE"/>
  21. <result property="nodeCode" column="NODE_CODE"/>
  22. </resultMap>
  23. <sql id="table_columns">
  24. GUID,
  25. PGUID,
  26. ORG_CODE,
  27. ORG_NAME,
  28. ORG_LEVEL,
  29. ORG_GRAD,
  30. ORG_TYPE,
  31. ORDERNUM,
  32. AD_CODE,
  33. STATUS,
  34. MODIFIER,
  35. FROM_DATE,
  36. TO_DATE,
  37. NOTE,
  38. JURD,
  39. AREA_TYPE,
  40. NODE_CODE
  41. </sql>
  42. <sql id="entity_properties">
  43. #{guid},
  44. #{pguid},
  45. #{orgCode},
  46. #{orgName},
  47. #{orgLevel},
  48. #{orgGrad},
  49. #{orgType},
  50. #{ordernum},
  51. #{adCode},
  52. #{status},
  53. #{modifier},
  54. #{fromDate},
  55. #{toDate},
  56. #{note},
  57. #{jurd},
  58. #{areaType},
  59. #{nodeCode}
  60. </sql>
  61. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  62. <sql id="page_where">
  63. <trim prefix="where" prefixOverrides="and | or ">
  64. <if test="pguid != null and pguid != ''">and PGUID = #{pguid}</if>
  65. <if test="orgCode != null and orgCode != ''">and ORG_CODE = #{orgCode}</if>
  66. <if test="orgName != null and orgName != ''">and ORG_NAME = #{orgName}</if>
  67. <if test="orgLevel != null and orgLevel != ''">and ORG_LEVEL = #{orgLevel}</if>
  68. <if test="orgGrad != null and orgGrad != ''">and ORG_GRAD = #{orgGrad}</if>
  69. <if test="orgType != null and orgType != ''">and ORG_TYPE = #{orgType}</if>
  70. <if test="ordernum != null and ordernum != ''">and ORDERNUM = #{ordernum}</if>
  71. <if test="adCode != null and adCode != ''">and AD_CODE LIKE #{adCode}</if>
  72. <if test="status != null and status != ''">and STATUS = #{status}</if>
  73. <if test="modifier != null and modifier != ''">and MODIFIER = #{modifier}</if>
  74. <if test="fromDate != null">and FROM_DATE = #{fromDate}</if>
  75. <if test="toDate != null">and TO_DATE = #{toDate}</if>
  76. <if test="note != null and note != ''">and NOTE = #{note}</if>
  77. <if test="jurd != null and jurd != ''">and JURD = #{jurd}</if>
  78. <if test="areaType != null and areaType != ''">and AREA_TYPE = #{areaType}</if>
  79. <if test="nodeCode != null and nodeCode != ''">and NODE_CODE = #{nodeCode}</if>
  80. </trim>
  81. </sql>
  82. <select id="get" resultMap="attOrgBaseResultMap" parameterType="String">
  83. select
  84. <include refid="table_columns"/>
  85. from att_org_base where GUID = #{id}
  86. </select>
  87. <select id="getBy" resultMap="attOrgBaseResultMap">
  88. select
  89. <include refid="table_columns"/>
  90. from att_org_base
  91. <include refid="page_where"/>
  92. </select>
  93. <select id="findAll" resultMap="attOrgBaseResultMap">
  94. select
  95. <include refid="table_columns"/>
  96. from att_org_base
  97. </select>
  98. <select id="findList" resultMap="attOrgBaseResultMap">
  99. select
  100. <include refid="table_columns"/>
  101. from att_org_base
  102. <include refid="page_where"/>
  103. ORDER BY ORDERNUM ASC
  104. </select>
  105. <select id="selectCount" resultType="int">
  106. select count(ID) from att_org_base
  107. <include refid="page_where"/>
  108. </select>
  109. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.AttOrgBase">
  110. insert into att_org_base(
  111. <include refid="table_columns"/>
  112. )
  113. values (
  114. <include refid="entity_properties"/>
  115. )
  116. </insert>
  117. <delete id="delete" parameterType="java.lang.String">
  118. delete from att_org_base where ID = #{id}
  119. </delete>
  120. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.AttOrgBase">
  121. delete from att_org_base
  122. <include refid="page_where"/>
  123. </delete>
  124. <update id="deleteInFlag" parameterType="java.lang.String">
  125. update att_org_base set flag_valid = 0 where ID = #{id}
  126. </update>
  127. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.AttOrgBase">
  128. update att_org_base
  129. <trim prefix="set" suffixOverrides=",">
  130. <if test="pguid != null and pguid != ''">PGUID = #{pguid},</if>
  131. <if test="orgCode != null and orgCode != ''">ORG_CODE = #{orgCode},</if>
  132. <if test="orgName != null and orgName != ''">ORG_NAME = #{orgName},</if>
  133. <if test="orgLevel != null and orgLevel != ''">ORG_LEVEL = #{orgLevel},</if>
  134. <if test="orgGrad != null and orgGrad != ''">ORG_GRAD = #{orgGrad},</if>
  135. <if test="orgType != null and orgType != ''">ORG_TYPE = #{orgType},</if>
  136. <if test="ordernum != null and ordernum != ''">ORDERNUM = #{ordernum},</if>
  137. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  138. <if test="status != null and status != ''">STATUS = #{status},</if>
  139. <if test="modifier != null and modifier != ''">MODIFIER = #{modifier},</if>
  140. <if test="fromDate != null">FROM_DATE = #{fromDate},</if>
  141. <if test="toDate != null">TO_DATE = #{toDate},</if>
  142. <if test="note != null and note != ''">NOTE = #{note},</if>
  143. <if test="jurd != null and jurd != ''">JURD = #{jurd},</if>
  144. <if test="areaType != null and areaType != ''">AREA_TYPE = #{areaType},</if>
  145. <if test="nodeCode != null and nodeCode != ''">NODE_CODE = #{nodeCode},</if>
  146. </trim>
  147. <where>ID = #{id}</where>
  148. </update>
  149. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.AttOrgBase">
  150. update att_org_base
  151. <trim prefix="set" suffixOverrides=",">
  152. <if test="pguid != null and pguid != ''">PGUID = #{pguid},</if>
  153. <if test="orgCode != null and orgCode != ''">ORG_CODE = #{orgCode},</if>
  154. <if test="orgName != null and orgName != ''">ORG_NAME = #{orgName},</if>
  155. <if test="orgLevel != null and orgLevel != ''">ORG_LEVEL = #{orgLevel},</if>
  156. <if test="orgGrad != null and orgGrad != ''">ORG_GRAD = #{orgGrad},</if>
  157. <if test="orgType != null and orgType != ''">ORG_TYPE = #{orgType},</if>
  158. <if test="ordernum != null and ordernum != ''">ORDERNUM = #{ordernum},</if>
  159. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  160. <if test="status != null and status != ''">STATUS = #{status},</if>
  161. <if test="modifier != null and modifier != ''">MODIFIER = #{modifier},</if>
  162. <if test="fromDate != null">FROM_DATE = #{fromDate},</if>
  163. <if test="toDate != null">TO_DATE = #{toDate},</if>
  164. <if test="note != null and note != ''">NOTE = #{note},</if>
  165. <if test="jurd != null and jurd != ''">JURD = #{jurd},</if>
  166. <if test="areaType != null and areaType != ''">AREA_TYPE = #{areaType},</if>
  167. <if test="nodeCode != null and nodeCode != ''">NODE_CODE = #{nodeCode},</if>
  168. </trim>
  169. <include refid="page_where"/>
  170. </update>
  171. <!-- 其他自定义SQL -->
  172. <select id="getOrgListBySchmId" resultType="cn.com.goldenwater.dcproj.model.AttOrgBase">
  173. select t1.*
  174. from BIS_INSP_DVDWK t
  175. left join ATT_ORG_BASE t1
  176. on TRIM (t.org_dp) = TRIM (t1.guid)
  177. where TRIM (t.schm_id) = TRIM (#{schmId})
  178. </select>
  179. <!--查所有关联流域及行政区划-->
  180. <select id="getFirstOrgOrAdByCodeAndType" resultType="cn.com.goldenwater.dcproj.model.AdOrOrg">
  181. select *
  182. from ((select t1.ad_code as code, t1.ad_name as name, 2 as type
  183. from ATT_AD_BASE t1
  184. where t1.ad_code like '__0000000000'
  185. and t1.ad_code != '000000000000') union all
  186. (select t.guid as code, t.org_name as name, 1 as type
  187. from ATT_ORG_BASE t
  188. where t.pguid = 'F55E8EE21E084FA28EF47DB52BABE505'
  189. and t.area_type = '4')) temp
  190. order by temp.type desc, temp.code asc
  191. </select>
  192. <select id="getOrgByCodeAndType" resultType="cn.com.goldenwater.dcproj.model.AdOrOrg">
  193. select t.guid as code, t.org_name as name, 1 as type
  194. from ATT_ORG_BASE t
  195. where t.status = '1'
  196. and t.pguid = #{code}
  197. </select>
  198. <!--根据方案id和行政区划id查询关联的行政区及机构,参数示例1和4355A1641209412DA5534DE05A941BCC -->
  199. <select id="getOrgOrAdBySchmIdAndGuid" resultType="cn.com.goldenwater.dcproj.model.AdOrOrg">
  200. select *
  201. from ((select t1.ad_code as code, t1.ad_name as name, 2 as type
  202. from ATT_AD_BASE t1
  203. where TRIM (t1.guid) in (select d.vst_dp
  204. from BIS_INSP_DVDWK d
  205. where TRIM(d.schm_id) = TRIM(#{schmId})
  206. and TRIM(d.org_dp) = TRIM(#{guid})
  207. and TRIM (d.dptype) = '2')) union all
  208. (select t.guid as code, t.org_name as name, 1 as type
  209. from ATT_ORG_BASE t
  210. where TRIM (t.guid) in (select d.vst_dp
  211. from BIS_INSP_DVDWK d
  212. where TRIM(d.schm_id) = TRIM(#{schmId})
  213. and TRIM(d.org_dp) = TRIM(#{guid})
  214. and TRIM (d.dptype) = '1'))) temp
  215. order by temp.type desc, temp.code asc
  216. </select>
  217. <select id="getListByPid" parameterType="String" resultType="cn.com.goldenwater.dcproj.model.AttOrgBase">
  218. SELECT GUID,
  219. PGUID,
  220. ORG_CODE,
  221. ORG_NAME,
  222. ORG_LEVEL,
  223. ORG_GRAD,
  224. ORG_TYPE,
  225. ORDERNUM,
  226. AD_CODE,
  227. STATUS,
  228. MODIFIER,
  229. NOTE,
  230. JURD,
  231. AREA_TYPE,
  232. NODE_CODE FROM ATT_ORG_BASE WHERE pguid = #{pid}
  233. </select>
  234. </mapper>