BisInspSvwtAreaRgstrDao.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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.BisInspSvwtAreaRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspSvwtAreaRgstr" id="bisInspSvwtAreaRgstrResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="adName" column="AD_NAME"/>
  8. <result property="adCode" column="AD_CODE"/>
  9. <result property="loc" column="LOC"/>
  10. <result property="pcX" column="PC_X"/>
  11. <result property="pcY" column="PC_Y"/>
  12. <result property="gdX" column="GD_X"/>
  13. <result property="gdY" column="GD_Y"/>
  14. <result property="bChkUnit" column="B_CHK_UNIT"/>
  15. <result property="contact" column="CONTACT"/>
  16. <result property="contactTel" column="CONTACT_TEL"/>
  17. <result property="principal" column="PRINCIPAL"/>
  18. <result property="principalTel" column="PRINCIPAL_TEL"/>
  19. <result property="note" column="NOTE"/>
  20. <result property="state" column="STATE"/>
  21. <result property="dataStat" column="DATA_STAT"/>
  22. <result property="chkUnit" column="CHK_UNIT"/>
  23. <result property="chkPers" column="CHK_PERS"/>
  24. <result property="chkTm" column="CHK_TM"/>
  25. <result property="wswmInfoStat" column="WSWM_INFO_STAT"/>
  26. <result property="wseInfoStat2" column="WSE_INFO_STAT2"/>
  27. <result property="persId" column="PERS_ID"/>
  28. <result property="groupId" column="GROUP_ID"/>
  29. <result property="inTm" column="IN_TM"/>
  30. <result property="upTm" column="UP_TM"/>
  31. <result property="province" column="PROVINCE"/>
  32. </resultMap>
  33. <sql id="table_columns">
  34. ID,PROVINCE,
  35. OBJ_ID,
  36. AD_NAME,
  37. AD_CODE,
  38. LOC,
  39. PC_X,
  40. PC_Y,
  41. GD_X,
  42. GD_Y,
  43. B_CHK_UNIT,
  44. CONTACT,
  45. CONTACT_TEL,
  46. PRINCIPAL,
  47. PRINCIPAL_TEL,
  48. NOTE,
  49. STATE,
  50. DATA_STAT,
  51. CHK_UNIT,
  52. CHK_PERS,
  53. CHK_TM,
  54. WSWM_INFO_STAT,
  55. WSE_INFO_STAT2,
  56. PERS_ID,
  57. GROUP_ID,
  58. IN_TM,
  59. UP_TM
  60. </sql>
  61. <sql id="entity_properties">
  62. #{id},#{province},
  63. #{objId},
  64. #{adName},
  65. #{adCode},
  66. #{loc},
  67. #{pcX},
  68. #{pcY},
  69. #{gdX},
  70. #{gdY},
  71. #{bChkUnit},
  72. #{contact},
  73. #{contactTel},
  74. #{principal},
  75. #{principalTel},
  76. #{note},
  77. #{state},
  78. #{dataStat},
  79. #{chkUnit},
  80. #{chkPers},
  81. #{chkTm},
  82. #{wswmInfoStat},
  83. #{wseInfoStat2},
  84. #{persId},
  85. #{groupId},
  86. #{inTm},
  87. #{upTm}
  88. </sql>
  89. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  90. <sql id="page_where">
  91. <trim prefix="where" prefixOverrides="and | or ">
  92. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  93. <if test="province != null and province != ''">and PROVINCE = #{province}</if>
  94. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  95. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  96. <if test="loc != null and loc != ''">and LOC = #{loc}</if>
  97. <if test="pcX != null and pcX != ''">and PC_X = #{pcX}</if>
  98. <if test="pcY != null and pcY != ''">and PC_Y = #{pcY}</if>
  99. <if test="gdX != null and gdX != ''">and GD_X = #{gdX}</if>
  100. <if test="gdY != null and gdY != ''">and GD_Y = #{gdY}</if>
  101. <if test="bChkUnit != null and bChkUnit != ''">and B_CHK_UNIT = #{bChkUnit}</if>
  102. <if test="contact != null and contact != ''">and CONTACT = #{contact}</if>
  103. <if test="contactTel != null and contactTel != ''">and CONTACT_TEL = #{contactTel}</if>
  104. <if test="principal != null and principal != ''">and PRINCIPAL = #{principal}</if>
  105. <if test="principalTel != null and principalTel != ''">and PRINCIPAL_TEL = #{principalTel}</if>
  106. <if test="note != null and note != ''">and NOTE = #{note}</if>
  107. <if test="state != null and state != ''">and STATE = #{state}</if>
  108. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  109. <if test="chkUnit != null and chkUnit != ''">and CHK_UNIT = #{chkUnit}</if>
  110. <if test="chkPers != null and chkPers != ''">and CHK_PERS = #{chkPers}</if>
  111. <if test="chkTm != null">and CHK_TM = #{chkTm}</if>
  112. <if test="wswmInfoStat != null and wswmInfoStat != ''">and WSWM_INFO_STAT = #{wswmInfoStat}</if>
  113. <if test="wseInfoStat2 != null and wseInfoStat2 != ''">and WSE_INFO_STAT2 = #{wseInfoStat2}</if>
  114. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  115. <if test="groupId != null and groupId != ''">and GROUP_ID = #{groupId}</if>
  116. <if test="inTm != null">and IN_TM = #{inTm}</if>
  117. <if test="upTm != null">and UP_TM = #{upTm}</if>
  118. </trim>
  119. </sql>
  120. <select id="get" resultMap="bisInspSvwtAreaRgstrResultMap" parameterType="String" >
  121. select <include refid="table_columns" /> from BIS_INSP_SVWT_AREA_RGSTR where ID = #{id}
  122. </select>
  123. <select id="getBy" resultMap="bisInspSvwtAreaRgstrResultMap">
  124. select <include refid="table_columns" /> from BIS_INSP_SVWT_AREA_RGSTR <include refid="page_where" />
  125. </select>
  126. <select id="findAll" resultMap="bisInspSvwtAreaRgstrResultMap">
  127. select <include refid="table_columns" /> from BIS_INSP_SVWT_AREA_RGSTR
  128. </select>
  129. <select id="findList" resultMap="bisInspSvwtAreaRgstrResultMap">
  130. select <include refid="table_columns" /> from BIS_INSP_SVWT_AREA_RGSTR <include refid="page_where" />
  131. </select>
  132. <select id="selectCount" resultType="int" >
  133. select count(ID) from BIS_INSP_SVWT_AREA_RGSTR <include refid="page_where" />
  134. </select>
  135. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspSvwtAreaRgstr">
  136. insert into BIS_INSP_SVWT_AREA_RGSTR( <include refid="table_columns" /> )
  137. values ( <include refid="entity_properties" /> )
  138. </insert>
  139. <delete id="delete" parameterType="java.lang.String">
  140. delete from BIS_INSP_SVWT_AREA_RGSTR where ID = #{id}
  141. </delete>
  142. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspSvwtAreaRgstr">
  143. delete from BIS_INSP_SVWT_AREA_RGSTR <include refid="page_where" />
  144. </delete>
  145. <update id="deleteInFlag" parameterType="java.lang.String">
  146. update BIS_INSP_SVWT_AREA_RGSTR set flag_valid = 0 where ID = #{id}
  147. </update>
  148. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspSvwtAreaRgstr">
  149. update BIS_INSP_SVWT_AREA_RGSTR
  150. <trim prefix="set" suffixOverrides=",">
  151. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  152. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  153. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  154. <if test="province != null and province != ''"> PROVINCE = #{province},</if>
  155. <if test="loc != null and loc != ''">LOC = #{loc},</if>
  156. <if test="pcX != null and pcX != ''">PC_X = #{pcX},</if>
  157. <if test="pcY != null and pcY != ''">PC_Y = #{pcY},</if>
  158. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  159. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  160. <if test="bChkUnit != null and bChkUnit != ''">B_CHK_UNIT = #{bChkUnit},</if>
  161. <if test="contact != null and contact != ''">CONTACT = #{contact},</if>
  162. <if test="contactTel != null and contactTel != ''">CONTACT_TEL = #{contactTel},</if>
  163. <if test="principal != null and principal != ''">PRINCIPAL = #{principal},</if>
  164. <if test="principalTel != null and principalTel != ''">PRINCIPAL_TEL = #{principalTel},</if>
  165. <if test="note != null and note != ''">NOTE = #{note},</if>
  166. <if test="state != null and state != ''">STATE = #{state},</if>
  167. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  168. <if test="chkUnit != null and chkUnit != ''">CHK_UNIT = #{chkUnit},</if>
  169. <if test="chkPers != null and chkPers != ''">CHK_PERS = #{chkPers},</if>
  170. <if test="chkTm != null">CHK_TM = #{chkTm},</if>
  171. <if test="wswmInfoStat != null and wswmInfoStat != ''">WSWM_INFO_STAT = #{wswmInfoStat},</if>
  172. <if test="wseInfoStat2 != null and wseInfoStat2 != ''">WSE_INFO_STAT2 = #{wseInfoStat2},</if>
  173. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  174. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  175. <if test="inTm != null">IN_TM = #{inTm},</if>
  176. <if test="upTm != null">UP_TM = #{upTm},</if>
  177. </trim>
  178. <where>ID = #{id}</where>
  179. </update>
  180. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspSvwtAreaRgstr">
  181. update BIS_INSP_SVWT_AREA_RGSTR
  182. <trim prefix="set" suffixOverrides=",">
  183. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  184. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  185. <if test="province != null and province != ''"> PROVINCE = #{province},</if>
  186. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  187. <if test="loc != null and loc != ''">LOC = #{loc},</if>
  188. <if test="pcX != null and pcX != ''">PC_X = #{pcX},</if>
  189. <if test="pcY != null and pcY != ''">PC_Y = #{pcY},</if>
  190. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  191. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  192. <if test="bChkUnit != null and bChkUnit != ''">B_CHK_UNIT = #{bChkUnit},</if>
  193. <if test="contact != null and contact != ''">CONTACT = #{contact},</if>
  194. <if test="contactTel != null and contactTel != ''">CONTACT_TEL = #{contactTel},</if>
  195. <if test="principal != null and principal != ''">PRINCIPAL = #{principal},</if>
  196. <if test="principalTel != null and principalTel != ''">PRINCIPAL_TEL = #{principalTel},</if>
  197. <if test="note != null and note != ''">NOTE = #{note},</if>
  198. <if test="state != null and state != ''">STATE = #{state},</if>
  199. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  200. <if test="chkUnit != null and chkUnit != ''">CHK_UNIT = #{chkUnit},</if>
  201. <if test="chkPers != null and chkPers != ''">CHK_PERS = #{chkPers},</if>
  202. <if test="chkTm != null">CHK_TM = #{chkTm},</if>
  203. <if test="wswmInfoStat != null and wswmInfoStat != ''">WSWM_INFO_STAT = #{wswmInfoStat},</if>
  204. <if test="wseInfoStat2 != null and wseInfoStat2 != ''">WSE_INFO_STAT2 = #{wseInfoStat2},</if>
  205. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  206. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  207. <if test="inTm != null">IN_TM = #{inTm},</if>
  208. <if test="upTm != null">UP_TM = #{upTm},</if>
  209. </trim>
  210. <include refid="page_where" />
  211. </update>
  212. <sql id="choseSql">
  213. <choose>
  214. <when test="province !=null and province !=''">
  215. and B.province like '${province}%'
  216. </when>
  217. <otherwise>
  218. and B.province is null
  219. </otherwise>
  220. </choose>
  221. </sql>
  222. <sql id="choseAdcodeSql">
  223. <choose>
  224. <when test="province !=null and province !=''">
  225. and B.AD_CODE like '${province}%'
  226. </when>
  227. <otherwise>
  228. and B.AD_CODE is null
  229. </otherwise>
  230. </choose>
  231. </sql>
  232. <select id="getListByInspGroupIdObjType" parameterType="cn.com.goldenwater.dcproj.param.PagePersObjParam"
  233. resultType="cn.com.goldenwater.dcproj.model.BisInspSvwtAreaRgstr">
  234. select t.*,C.id groupId,C.PNM groupName,B.obj_id,r.loc
  235. from att_ad_x_base t
  236. left join BIS_INSP_ALL_OBJ B
  237. on B.CODE = t.ad_code
  238. LEFT JOIN BIS_INSP_ALL C ON B.ID = C.ID and B.ptype = #{objType}
  239. left join BIS_INSP_SVWT_AREA_RGSTR r
  240. on B.obj_id=r.obj_id
  241. where 1 = 1
  242. <if test='isAll == "0"'>and B.ID = #{inspGroupId}</if>
  243. <if test='isAll == "1"'>and B.ID LIKE '${inspGroupId}%'</if>
  244. <if test="adCode != null and adCode != ''">
  245. and t.AD_CODE like '${adCode}%'
  246. </if>
  247. <choose>
  248. <when test="province != null and province != ''">
  249. and B.AD_CODE LIKE '${province}%'
  250. </when>
  251. <otherwise>
  252. and B.AD_CODE is null
  253. </otherwise>
  254. </choose>
  255. </select>
  256. <!-- 其他自定义SQL -->
  257. <select id="findSvwtAreaList" parameterType="cn.com.goldenwater.dcproj.param.TypeParam" resultType="cn.com.goldenwater.dcproj.dto.BisInspRgstrDto">
  258. SELECT * FROM (
  259. select A.CODE,A.ID nodeId,
  260. A.NM,
  261. #{pType} PTYPE,
  262. B.pc_x,
  263. B.pc_y,
  264. B.GD_X,
  265. B.GD_y,
  266. A.OBJ_ID,B.ID ID,
  267. (case when b.loc is null then c.ad_full_name else b.loc end) as location,
  268. (case when b.State is null then '0' else b.state end)STATE
  269. ,B.IN_TM,
  270. B.WSWM_INFO_STAT,
  271. B.WSE_INFO_STAT2 as WSE_INFO_STAT,
  272. c.ad_full_name as adName,
  273. ia.pnm groupName
  274. from BIS_INSP_ALL_OBJ
  275. A LEFT JOIN BIS_INSP_SVWT_AREA_RGSTR B ON A.OBJ_ID=B.OBJ_ID
  276. LEFT JOIN ATT_AD_X_BASE C ON A.CODE=C.AD_CODE
  277. LEFT JOIN BIS_INSP_ALL ia on A.ID = ia.id
  278. where A.ptype= #{pType}
  279. <if test="tabType =='2'.toString()">
  280. and ia.entm &lt;to_date(#{nowTime},'yyyy-MM-dd')+1
  281. </if>
  282. <if test="tabType =='1'.toString()">
  283. and ia.entm &gt;=to_date(#{nowTime},'yyyy-MM-dd')
  284. </if>
  285. <include refid="choseSql"/>
  286. and REGEXP_LIKE(
  287. A.Id,'^('||
  288. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION B WHERE PERSID =#{presId}
  289. <include refid="choseAdcodeSql"/>
  290. )>0 then
  291. (SELECT LISTAGG(id, '|') as
  292. id FROM BIS_INSP_ALL_RLATION B WHERE PERSID =#{presId}
  293. <include refid="choseAdcodeSql"/> group by persid
  294. )
  295. else (select 'non' from dual) end)
  296. ||')')
  297. ) A WHERE a.PTYPE=#{pType}
  298. <if test="plnaId !=null and plnaId !=''">
  299. and a.nodeId like '${plnaId}%'
  300. </if>
  301. <if test="state !=null and state !=''">
  302. and STATE=#{state}
  303. </if>
  304. <if test="rsName !=null and rsName !=''">
  305. and a.nm like '%${rsName}%'
  306. </if>
  307. <if test="code !=null and code !=''">
  308. and a.code = #{code}
  309. </if>
  310. <if test="adName != null and adName != ''">and a.adName like '%${adName}%'</if>
  311. <if test="sttm != null and sttm != ''">and a.IN_TM&gt;= TO_DATE(#{sttm},'YYYY-MM-DD')</if>
  312. <if test="entm != null and entm != ''">and a.IN_TM &lt; To_DATE(#{entm},'yyyy-MM-dd') + 1</if>
  313. <if test="groupId != null and groupId != ''">and a.nodeId = #{groupId}</if>
  314. order by nodeId asc
  315. <if test="orderBy != null and orderBy != ''">
  316. ,nlssort(nm,'NLS_SORT=SCHINESE_PINYIN_M')
  317. </if>
  318. </select>
  319. </mapper>