BisRdwspRgstrDao.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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.BisRdwspRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisRdwspRgstr" id="bisRdwspRgstrResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="adCode" column="AD_CODE"/>
  8. <result property="adName" column="AD_NAME"/>
  9. <result property="adFullName" column="AD_FULL_NAME"/>
  10. <result property="isPkx" column="IS_PKX"/>
  11. <result property="isFoOver" column="IS_FO_OVER"/>
  12. <result property="note" column="NOTE"/>
  13. <result property="feeState" column="FEE_STATE"/>
  14. <result property="poorState" column="POOR_STATE"/>
  15. <result property="state" column="STATE"/>
  16. <result property="persId" column="PERS_ID"/>
  17. <result property="intm" column="INTM"/>
  18. <result property="uptm" column="UPTM"/>
  19. </resultMap>
  20. <sql id="table_columns">
  21. ID,
  22. OBJ_ID,
  23. AD_CODE,
  24. AD_NAME,
  25. AD_FULL_NAME,
  26. IS_PKX,
  27. IS_FO_OVER,
  28. NOTE,
  29. FEE_STATE,
  30. POOR_STATE,
  31. STATE,
  32. PERS_ID,
  33. INTM,
  34. UPTM
  35. </sql>
  36. <sql id="entity_properties">
  37. #{id},
  38. #{objId},
  39. #{adCode},
  40. #{adName},
  41. #{adFullName},
  42. #{isPkx},
  43. #{isFoOver},
  44. #{note},
  45. #{feeState},
  46. #{poorState},
  47. #{state},
  48. #{persId},
  49. #{intm},
  50. #{uptm}
  51. </sql>
  52. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  53. <sql id="page_where">
  54. <trim prefix="where" prefixOverrides="and | or ">
  55. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  56. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  57. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  58. <if test="adFullName != null and adFullName != ''">and AD_FULL_NAME = #{adFullName}</if>
  59. <if test="isPkx != null and isPkx != ''">and IS_PKX = #{isPkx}</if>
  60. <if test="isFoOver != null and isFoOver != ''">and IS_FO_OVER = #{isFoOver}</if>
  61. <if test="note != null and note != ''">and NOTE = #{note}</if>
  62. <if test="feeState != null and feeState != ''">and FEE_STATE = #{feeState}</if>
  63. <if test="poorState != null and poorState != ''">and POOR_STATE = #{poorState}</if>
  64. <if test="state != null and state != ''">and STATE = #{state}</if>
  65. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  66. <if test="intm != null">and INTM = #{intm}</if>
  67. <if test="uptm != null">and UPTM = #{uptm}</if>
  68. </trim>
  69. </sql>
  70. <select id="get" resultMap="bisRdwspRgstrResultMap" parameterType="String">
  71. select
  72. <include refid="table_columns"/>
  73. from BIS_RDWSP_RGSTR where ID = #{id}
  74. </select>
  75. <select id="getBy" resultMap="bisRdwspRgstrResultMap">
  76. select
  77. <include refid="table_columns"/>
  78. from BIS_RDWSP_RGSTR
  79. <include refid="page_where"/>
  80. </select>
  81. <select id="findAll" resultMap="bisRdwspRgstrResultMap">
  82. select
  83. <include refid="table_columns"/>
  84. from BIS_RDWSP_RGSTR
  85. </select>
  86. <select id="findList" resultMap="bisRdwspRgstrResultMap">
  87. select
  88. <include refid="table_columns"/>
  89. from BIS_RDWSP_RGSTR
  90. <include refid="page_where"/>
  91. </select>
  92. <select id="selectCount" resultType="int">
  93. select count(ID) from BIS_RDWSP_RGSTR
  94. <include refid="page_where"/>
  95. </select>
  96. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisRdwspRgstr">
  97. insert into BIS_RDWSP_RGSTR(
  98. <include refid="table_columns"/>
  99. )
  100. values (
  101. <include refid="entity_properties"/>
  102. )
  103. </insert>
  104. <delete id="delete" parameterType="java.lang.String">
  105. delete from BIS_RDWSP_RGSTR where ID = #{id}
  106. </delete>
  107. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisRdwspRgstr">
  108. delete from BIS_RDWSP_RGSTR
  109. <include refid="page_where"/>
  110. </delete>
  111. <update id="deleteInFlag" parameterType="java.lang.String">
  112. update BIS_RDWSP_RGSTR set flag_valid = 0 where>ID = #{id}
  113. </update>
  114. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisRdwspRgstr">
  115. update BIS_RDWSP_RGSTR
  116. <trim prefix="set" suffixOverrides=",">
  117. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  118. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  119. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  120. <if test="adFullName != null and adFullName != ''">AD_FULL_NAME = #{adFullName},</if>
  121. <if test="isPkx != null and isPkx != ''">IS_PKX = #{isPkx},</if>
  122. <if test="isFoOver != null and isFoOver != ''">IS_FO_OVER = #{isFoOver},</if>
  123. <if test="note != null and note != ''">NOTE = #{note},</if>
  124. <if test="feeState != null and feeState != ''">FEE_STATE = #{feeState},</if>
  125. <if test="poorState != null and poorState != ''">POOR_STATE = #{poorState},</if>
  126. <if test="state != null and state != ''">STATE = #{state},</if>
  127. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  128. <if test="intm != null">INTM = #{intm},</if>
  129. <if test="uptm != null">UPTM = #{uptm},</if>
  130. </trim>
  131. <where>ID = #{id}</where>
  132. </update>
  133. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisRdwspRgstr">
  134. update BIS_RDWSP_RGSTR
  135. <trim prefix="set" suffixOverrides=",">
  136. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  137. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  138. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  139. <if test="adFullName != null and adFullName != ''">AD_FULL_NAME = #{adFullName},</if>
  140. <if test="isPkx != null and isPkx != ''">IS_PKX = #{isPkx},</if>
  141. <if test="isFoOver != null and isFoOver != ''">IS_FO_OVER = #{isFoOver},</if>
  142. <if test="note != null and note != ''">NOTE = #{note},</if>
  143. <if test="feeState != null and feeState != ''">FEE_STATE = #{feeState},</if>
  144. <if test="poorState != null and poorState != ''">POOR_STATE = #{poorState},</if>
  145. <if test="state != null and state != ''">STATE = #{state},</if>
  146. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  147. <if test="intm != null">INTM = #{intm},</if>
  148. <if test="uptm != null">UPTM = #{uptm},</if>
  149. </trim>
  150. <include refid="page_where"/>
  151. </update>
  152. <!-- 其他自定义SQL -->
  153. <select id="findRdwspList" resultType="cn.com.goldenwater.dcproj.dto.BisInspRgstrDto">
  154. SELECT * FROM (
  155. select
  156. A.CODE,
  157. A.ID nodeId,
  158. A.NM,
  159. #{pType} pType,
  160. A.OBJ_ID,
  161. B.ID ID,
  162. b.id as rgstrId,
  163. (case when b.State is null then '0' else b.state end) STATE,
  164. B.INTM,B.UPTM,B.AD_CODE,
  165. ( CASE WHEN b.AD_FULL_NAME IS NULL THEN to_char( e.AD_FULL_NAME ) ELSE b.AD_FULL_NAME END ) adName,
  166. ia.pnm groupName,
  167. b.FEE_STATE as feeState,
  168. b.POOR_STATE as poorState
  169. from BIS_INSP_ALL_OBJ
  170. A LEFT JOIN BIS_RDWSP_RGSTR B ON A.OBJ_ID=B.OBJ_ID
  171. LEFT JOIN BIS_INSP_ALL ia on A.ID = ia.id
  172. LEFT JOIN ATT_AD_X_BASE e on B.AD_CODE = e.ad_code
  173. where A.ptype= #{pType}
  174. <if test="adCodes ==null or adCodes ==''">
  175. <choose>
  176. <when test='isAll =="1"'>
  177. </when>
  178. <otherwise>
  179. and
  180. A.Id in (
  181. select distinct id from (
  182. SELECT P.id FROM BIS_INSP_ALL P START WITH P.PID IN (SELECT id FROM BIS_INSP_ALL_RLATION A
  183. WHERE A.PERSID = #{presId} and TYPE = #{pType} and length(id) in (3,6,9))
  184. CONNECT BY P.PID = PRIOR P.ID
  185. union all
  186. SELECT P.id FROM BIS_INSP_ALL P where p.id in (SELECT id FROM BIS_INSP_ALL_RLATION A
  187. WHERE A.PERSID =#{presId} and TYPE = #{pType} and length(id)=12 )
  188. )
  189. )
  190. </otherwise>
  191. </choose>
  192. </if>
  193. <if test="adCodes !=null and adCodes !=''">
  194. and
  195. <foreach item="item" index="index" collection="adCodes.split(',')" open="(" separator="or" close=")">
  196. b.ad_code like concat('${item}','%')
  197. </foreach>
  198. </if>
  199. ) A WHERE a.PTYPE=#{pType}
  200. <if test="adCode != null and adCode != '' ">
  201. and a.AD_CODE like '${adCode}%'
  202. </if>
  203. <if test="plnaId !=null and plnaId !=''">
  204. and a.nodeId like '${plnaId}%'
  205. </if>
  206. <if test="state !=null and state !=''">
  207. and STATE in (${state})
  208. </if>
  209. <if test="rsName !=null and rsName !=''">
  210. and a.nm like '%${rsName}%'
  211. </if>
  212. <if test="code !=null and code !=''">
  213. and a.code = #{code}
  214. </if>
  215. <if test="adName != null and adName != ''">and a.adName like '%${adName}%'</if>
  216. <if test="sttm != null and sttm != ''">and a.Intm&gt;= TO_DATE(#{sttm},'YYYY-MM-DD')</if>
  217. <if test="entm != null and entm != ''">and a.Intm &lt; To_DATE(#{entm},'yyyy-MM-dd') + 1</if>
  218. <if test="groupId != null and groupId != ''">and a.nodeId = #{groupId}</if>
  219. order by nodeId asc
  220. <if test="orderBy != null and orderBy != ''">
  221. ,nlssort(nm,'NLS_SORT=SCHINESE_PINYIN_M')
  222. </if>
  223. </select>
  224. </mapper>