BisInspHystRgstrDao.xml 11 KB

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