BisInspCdepRgstrDao.xml 14 KB

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