BisInspWrm2021Dao.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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.BisInspWrm2021Dao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspWrm2021" id="bisInspWrm2021ResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="nm" column="NM"/>
  8. <result property="adCode" column="AD_CODE"/>
  9. <result property="adName" column="AD_NAME"/>
  10. <result property="state" column="STATE"/>
  11. <result property="spotaState" column="SPOTA_STATE"/>
  12. <result property="usrState" column="USR_STATE"/>
  13. <result property="wellState" column="WELL_STATE"/>
  14. <result property="wellwState" column="WELLW_STATE"/>
  15. <result property="persId" column="PERS_ID"/>
  16. <result property="intm" column="INTM"/>
  17. <result property="uptm" column="UPTM"/>
  18. <result property="note" column="NOTE"/>
  19. <result property="dataStat" column="DATA_STAT"/>
  20. </resultMap>
  21. <sql id="table_columns">
  22. ID,
  23. OBJ_ID,
  24. NM,
  25. AD_CODE,
  26. AD_NAME,
  27. STATE,
  28. SPOTA_STATE,
  29. USR_STATE,
  30. WELL_STATE,
  31. WELLW_STATE,
  32. PERS_ID,
  33. INTM,
  34. UPTM,
  35. NOTE,
  36. DATA_STAT
  37. </sql>
  38. <sql id="entity_properties">
  39. #{id},
  40. #{objId},
  41. #{nm},
  42. #{adCode},
  43. #{adName},
  44. #{state},
  45. #{spotaState},
  46. #{usrState},
  47. #{wellState},
  48. #{wellwState},
  49. #{persId},
  50. #{intm},
  51. #{uptm},
  52. #{note},
  53. #{dataStat}
  54. </sql>
  55. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  56. <sql id="page_where">
  57. <trim prefix="where" prefixOverrides="and | or ">
  58. <if test="objId != null and objId != ''">
  59. and OBJ_ID = #{objId}
  60. </if>
  61. <if test="nm != null and nm != ''">
  62. and NM = #{nm}
  63. </if>
  64. <if test="adCode != null and adCode != ''">
  65. and AD_CODE = #{adCode}
  66. </if>
  67. <if test="adName != null and adName != ''">
  68. and AD_NAME = #{adName}
  69. </if>
  70. <if test="state != null and state != ''">
  71. and STATE = #{state}
  72. </if>
  73. <if test="spotaState != null and spotaState != ''">
  74. and SPOTA_STATE = #{spotaState}
  75. </if>
  76. <if test="usrState != null and usrState != ''">
  77. and USR_STATE = #{usrState}
  78. </if>
  79. <if test="wellState != null and wellState != ''">
  80. and WELL_STATE = #{wellState}
  81. </if>
  82. <if test="wellwState != null and wellwState != ''">
  83. and WELLW_STATE = #{wellwState}
  84. </if>
  85. <if test="persId != null and persId != ''">
  86. and PERS_ID = #{persId}
  87. </if>
  88. <if test="intm != null">
  89. and INTM = #{intm}
  90. </if>
  91. <if test="uptm != null">
  92. and UPTM = #{uptm}
  93. </if>
  94. <if test="note != null and note != ''">
  95. and NOTE = #{note}
  96. </if>
  97. <if test="dataStat != null and dataStat != ''">
  98. and DATA_STAT = #{dataStat}
  99. </if>
  100. and DATA_STAT='0'
  101. </trim>
  102. </sql>
  103. <select id="get" resultMap="bisInspWrm2021ResultMap" parameterType="String">
  104. select
  105. <include refid="table_columns"/>
  106. from BIS_INSP_WRM2021 where ID = #{id}
  107. </select>
  108. <select id="getBy" resultMap="bisInspWrm2021ResultMap">
  109. select
  110. <include refid="table_columns"/>
  111. from BIS_INSP_WRM2021
  112. <include refid="page_where"/>
  113. </select>
  114. <select id="findAll" resultMap="bisInspWrm2021ResultMap">
  115. select
  116. <include refid="table_columns"/>
  117. from BIS_INSP_WRM2021
  118. </select>
  119. <select id="findList" resultMap="bisInspWrm2021ResultMap">
  120. select
  121. <include refid="table_columns"/>
  122. from BIS_INSP_WRM2021
  123. <include refid="page_where"/>
  124. </select>
  125. <select id="selectCount" resultType="int">
  126. select count(ID) from BIS_INSP_WRM2021
  127. <include refid="page_where"/>
  128. </select>
  129. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspWrm2021">
  130. insert into BIS_INSP_WRM2021(
  131. <include refid="table_columns"/>
  132. )
  133. values (
  134. <include refid="entity_properties"/>
  135. )
  136. </insert>
  137. <delete id="delete" parameterType="java.lang.String">
  138. update BIS_INSP_WRM2021 set DATA_STAT='9' where ID = #{id}
  139. </delete>
  140. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspWrm2021">
  141. update BIS_INSP_WRM2021 set DATA_STAT='9'
  142. <include refid="page_where"/>
  143. </delete>
  144. <update id="deleteInFlag" parameterType="java.lang.String">
  145. update BIS_INSP_WRM2021 set DATA_STAT = '9' where ID = #{id}
  146. </update>
  147. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspWrm2021">
  148. update BIS_INSP_WRM2021
  149. <trim prefix="set" suffixOverrides=",">
  150. <if test="objId != null and objId != ''">OBJ_ID
  151. = #{objId},
  152. </if>
  153. <if test="nm != null and nm != ''">NM
  154. = #{nm},
  155. </if>
  156. <if test="adCode != null and adCode != ''">AD_CODE
  157. = #{adCode},
  158. </if>
  159. <if test="adName != null and adName != ''">AD_NAME
  160. = #{adName},
  161. </if>
  162. <if test="state != null and state != ''">STATE
  163. = #{state},
  164. </if>
  165. <if test="spotaState != null and spotaState != ''">SPOTA_STATE
  166. = #{spotaState},
  167. </if>
  168. <if test="usrState != null and usrState != ''">USR_STATE
  169. = #{usrState},
  170. </if>
  171. <if test="wellState != null and wellState != ''">WELL_STATE
  172. = #{wellState},
  173. </if>
  174. <if test="wellwState != null and wellwState != ''">WELLW_STATE
  175. = #{wellwState},
  176. </if>
  177. <if test="persId != null and persId != ''">PERS_ID
  178. = #{persId},
  179. </if>
  180. <if test="intm != null">INTM
  181. = #{intm},
  182. </if>
  183. <if test="uptm != null">UPTM
  184. = #{uptm},
  185. </if>
  186. <if test="note != null and note != ''">NOTE
  187. = #{note},
  188. </if>
  189. <if test="dataStat != null and dataStat != ''">DATA_STAT
  190. = #{dataStat},
  191. </if>
  192. </trim>
  193. <where>ID = #{id}</where>
  194. </update>
  195. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspWrm2021">
  196. update BIS_INSP_WRM2021
  197. <trim prefix="set" suffixOverrides=",">
  198. <if test="objId != null and objId != ''">OBJ_ID
  199. = #{objId},
  200. </if>
  201. <if test="nm != null and nm != ''">NM
  202. = #{nm},
  203. </if>
  204. <if test="adCode != null and adCode != ''">AD_CODE
  205. = #{adCode},
  206. </if>
  207. <if test="adName != null and adName != ''">AD_NAME
  208. = #{adName},
  209. </if>
  210. <if test="state != null and state != ''">STATE
  211. = #{state},
  212. </if>
  213. <if test="spotaState != null and spotaState != ''">SPOTA_STATE
  214. = #{spotaState},
  215. </if>
  216. <if test="usrState != null and usrState != ''">USR_STATE
  217. = #{usrState},
  218. </if>
  219. <if test="wellState != null and wellState != ''">WELL_STATE
  220. = #{wellState},
  221. </if>
  222. <if test="wellwState != null and wellwState != ''">WELLW_STATE
  223. = #{wellwState},
  224. </if>
  225. <if test="persId != null and persId != ''">PERS_ID
  226. = #{persId},
  227. </if>
  228. <if test="intm != null">INTM
  229. = #{intm},
  230. </if>
  231. <if test="uptm != null">UPTM
  232. = #{uptm},
  233. </if>
  234. <if test="note != null and note != ''">NOTE
  235. = #{note},
  236. </if>
  237. <if test="dataStat != null and dataStat != ''">DATA_STAT
  238. = #{dataStat},
  239. </if>
  240. </trim>
  241. <include refid="page_where"/>
  242. </update>
  243. <!-- 其他自定义SQL -->
  244. <select id="findPage" resultType="cn.com.goldenwater.dcproj.dto.BisInspRgstrDto">
  245. SELECT * FROM (
  246. select
  247. A.CODE,
  248. A.ID nodeId,
  249. A.NM,
  250. #{pType} pType,
  251. A.OBJ_ID,
  252. B.ID ID,
  253. b.id as rgstrId,
  254. (case when b.State is null then '0' else b.state end) STATE,
  255. B.INTM,B.UPTM,
  256. ( CASE WHEN b.AD_NAME IS NULL THEN to_char( e.AD_FULL_NAME ) ELSE b.AD_NAME END ) adName,
  257. ia.pnm groupName,
  258. b.SPOTA_STATE as spotaState,
  259. b.USR_STATE as usrState,
  260. b.WELL_STATE as wellState ,
  261. b.WELLW_STATE as wellwState
  262. from BIS_INSP_ALL_OBJ
  263. A LEFT JOIN BIS_INSP_WRM2021 B ON A.OBJ_ID=B.OBJ_ID
  264. LEFT JOIN BIS_INSP_ALL ia on A.ID = ia.id
  265. LEFT JOIN ATT_AD_X_BASE e on B.AD_CODE = e.ad_code
  266. where A.ptype= #{pType}
  267. <if test="adCodes ==null or adCodes ==''">
  268. <choose>
  269. <when test='isAll =="1"'>
  270. </when>
  271. <otherwise>
  272. AND
  273. A.Id in (
  274. select distinct id from (
  275. SELECT P.id FROM BIS_INSP_ALL P START WITH P.PID IN (SELECT id FROM BIS_INSP_ALL_RLATION A
  276. WHERE A.PERSID = #{presId} AND Type=#{pType}
  277. and (length(id) between 2 and 20))
  278. <if test="year !=null and year !=''">
  279. and P.INSP_YEAR = #{year}
  280. </if>
  281. CONNECT BY P.PID = PRIOR P.ID
  282. union all
  283. SELECT P.id FROM BIS_INSP_ALL P where p.id in (SELECT id FROM BIS_INSP_ALL_RLATION A
  284. WHERE A.PERSID = #{presId} AND Type=#{pType}
  285. and length(id)&gt; 11 )
  286. <if test="year !=null and year !=''">
  287. and P.INSP_YEAR = #{year}
  288. </if>
  289. )
  290. )
  291. </otherwise>
  292. </choose>
  293. </if>
  294. <if test="adCodes !=null and adCodes !=''">
  295. and
  296. <foreach item="item" index="index" collection="adCodes.split(',')" open="(" separator="or" close=")">
  297. b.ad_code like concat('${item}','%')
  298. </foreach>
  299. </if>
  300. ) A WHERE a.PTYPE=#{pType}
  301. <if test="plnaId !=null and plnaId !=''">
  302. and a.nodeId like '${plnaId}%'
  303. </if>
  304. <if test="state !=null and state !=''">
  305. and STATE in (${state})
  306. </if>
  307. <if test="rsName !=null and rsName !=''">
  308. and a.nm like '%${rsName}%'
  309. </if>
  310. <if test="code !=null and code !=''">
  311. and a.code = #{code}
  312. </if>
  313. <if test="adName != null and adName != ''">and a.adName like '%${adName}%'</if>
  314. <if test="sttm != null and sttm != ''">and a.Intm&gt;= TO_DATE(#{sttm},'YYYY-MM-DD')</if>
  315. <if test="entm != null and entm != ''">and a.Intm &lt; To_DATE(#{entm},'yyyy-MM-dd') + 1</if>
  316. <if test="groupId != null and groupId != ''">and a.nodeId = #{groupId}</if>
  317. order by nodeId asc
  318. <if test="orderBy != null and orderBy != ''">
  319. ,nlssort(nm,'NLS_SORT=SCHINESE_PINYIN_M')
  320. </if>
  321. </select>
  322. </mapper>