BisInspWtgtRgstrDao.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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.BisInspWtgtRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspWtgtRgstr" id="bisInspWtgtRgstrResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="depName" column="DEP_NAME"/>
  8. <result property="adCode" column="AD_CODE"/>
  9. <result property="adName" column="AD_NAME"/>
  10. <result property="wintCode" column="WINT_CODE"/>
  11. <result property="depPers" column="DEP_PERS"/>
  12. <result property="depPersTel" column="DEP_PERS_TEL"/>
  13. <result property="loc" column="LOC"/>
  14. <result property="utLead" column="UT_LEAD"/>
  15. <result property="principalTel" column="PRINCIPAL_TEL" />
  16. <result property="note" column="NOTE" />
  17. <result property="centerX" column="CENTER_X"/>
  18. <result property="centerY" column="CENTER_Y"/>
  19. <result property="gdX" column="GD_X"/>
  20. <result property="gdY" column="GD_Y"/>
  21. <result property="payState" column="PAY_STATE"/>
  22. <result property="planState" column="PLAN_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. DEP_NAME,
  34. AD_CODE,
  35. AD_NAME,
  36. WINT_CODE,
  37. DEP_PERS,
  38. DEP_PERS_TEL,
  39. LOC,
  40. UT_LEAD,
  41. PRINCIPAL_TEL,
  42. NOTE,
  43. CENTER_X,
  44. CENTER_Y,
  45. GD_X,
  46. GD_Y,
  47. PAY_STATE,
  48. PLAN_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. #{depName},
  60. #{adCode},
  61. #{adName},
  62. #{wintCode},
  63. #{depPers},
  64. #{depPersTel},
  65. #{loc},
  66. #{utLead},
  67. #{principalTel},
  68. #{note},
  69. #{centerX},
  70. #{centerY},
  71. #{gdX},
  72. #{gdY},
  73. #{payState},
  74. #{planState},
  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="depName != null and depName != ''">and DEP_NAME LIKE '%' || #{depName} || '%'</if>
  87. <if test="adCode != null and adCode != ''">and AD_CODE LIKE '%' || #{adCode} || '%'</if>
  88. <if test="adName != null and adName != ''">and AD_NAME LIKE '%' || #{adName} || '%'</if>
  89. <if test="wintCode != null and wintCode != ''">and WINT_CODE = #{wintCode}</if>
  90. <if test="depPers != null and depPers != ''">and DEP_PERS LIKE '%' || #{depPers} || '%'</if>
  91. <if test="depPersTel != null and depPersTel != ''">and DEP_PERS_TEL LIKE '%' || #{depPersTel} || '%'</if>
  92. <if test="loc != null and loc != ''">and LOC LIKE '%' || #{loc} || '%'</if>
  93. <if test="utLead != null and utLead != ''">and UT_LEAD LIKE '%' || #{utLead} || '%'</if>
  94. <if test="principalTel != null and principalTel != ''">and PRINCIPAL_TEL LIKE '%' || #{principalTel} || '%'</if>
  95. <if test="note != null and note != ''">and NOTE = #{note}</if>
  96. <if test="centerX != null and centerX != ''">and CENTER_X = #{centerX}</if>
  97. <if test="centerY != null and centerY != ''">and CENTER_Y = #{centerY}</if>
  98. <if test="gdX != null and gdX != ''">and GD_X = #{gdX}</if>
  99. <if test="gdY != null and gdY != ''">and GD_Y = #{gdY}</if>
  100. <if test="payState != null and payState != ''">and PAY_STATE = #{payState}</if>
  101. <if test="planState != null and planState != ''">and PLAN_STATE = #{planState}</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="sttm != null and sttm != ''">and INTM &gt;= TO_DATE(#{sttm},'YYYY-MM-DD')</if>
  105. <if test="entm != null and entm != ''">and INTM &lt;= To_DATE(#{entm},'yyyy-MM-dd')</if>
  106. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  107. and DATA_STAT='0'
  108. </trim>
  109. </sql>
  110. <sql id="page_where2">
  111. <trim prefix="where" prefixOverrides="and | or ">
  112. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  113. <if test="depName != null and depName != ''">and DEP_NAME LIKE '%' || #{depName} || '%'</if>
  114. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  115. <if test="adName != null and adName != ''">and AD_NAME LIKE '%' || #{adName} || '%'</if>
  116. <if test="wintCode != null and wintCode != ''">and WINT_CODE = #{wintCode}</if>
  117. <if test="depPers != null and depPers != ''">and DEP_PERS LIKE '%' || #{depPers} || '%'</if>
  118. <if test="depPersTel != null and depPersTel != ''">and DEP_PERS_TEL LIKE '%' || #{depPersTel} || '%'</if>
  119. <if test="loc != null and loc != ''">and LOC LIKE '%' || #{loc} || '%'</if>
  120. <if test="utLead != null and utLead != ''">and UT_LEAD LIKE '%' || #{utLead} || '%'</if>
  121. <if test="principalTel != null and principalTel != ''">and PRINCIPAL_TEL LIKE '%' || #{principalTel} || '%'</if>
  122. <if test="note != null and note != ''">and NOTE = #{note}</if>
  123. <if test="centerX != null and centerX != ''">and CENTER_X = #{centerX}</if>
  124. <if test="centerY != null and centerY != ''">and CENTER_Y = #{centerY}</if>
  125. <if test="gdX != null and gdX != ''">and GD_X = #{gdX}</if>
  126. <if test="gdY != null and gdY != ''">and GD_Y = #{gdY}</if>
  127. <if test="payState != null and payState != ''">and PAY_STATE = #{payState}</if>
  128. <if test="planState != null and planState != ''">and PLAN_STATE = #{planState}</if>
  129. <if test="state != null and state != ''">and STATE = #{state}</if>
  130. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  131. <if test="groupId != null and groupId != ''">and GROUP_ID = #{groupId}</if>
  132. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  133. and DATA_STAT='0'
  134. </trim>
  135. </sql>
  136. <select id="get" resultMap="bisInspWtgtRgstrResultMap" parameterType="String">
  137. select
  138. <include refid="table_columns"/>
  139. from BIS_INSP_WTGT_RGSTR where ID = #{id}
  140. </select>
  141. <select id="getBy" resultMap="bisInspWtgtRgstrResultMap">
  142. select
  143. <include refid="table_columns"/>
  144. from BIS_INSP_WTGT_RGSTR
  145. <include refid="page_where2"/>
  146. </select>
  147. <select id="findAll" resultMap="bisInspWtgtRgstrResultMap">
  148. select
  149. <include refid="table_columns"/>
  150. from BIS_INSP_WTGT_RGSTR
  151. </select>
  152. <select id="findList" resultMap="bisInspWtgtRgstrResultMap">
  153. SELECT
  154. B.*,A.PNM groupName, B.ID as "rgstrId"
  155. FROM
  156. (
  157. select <include refid="table_columns" />
  158. from BIS_INSP_WTGT_RGSTR <include refid="page_where" />
  159. ) B
  160. LEFT JOIN BIS_INSP_ALL_OBJ O ON B.OBJ_ID = O.OBJ_ID
  161. LEFT JOIN BIS_INSP_ALL A ON A.ID = O.ID
  162. <where>
  163. <if test="groupName != null and groupName != ''">and A.PNM = #{groupName}</if>
  164. <if test="id != null and id != ''">and A.ID like '${id}%' </if>
  165. <if test="groupId != null and groupId != ''">and A.ID = #{groupId}</if>
  166. <if test="province != null and province != ''">and B.AD_CODE LIKE '' || #{province} || '%' </if>
  167. <if test="groupIds != null and groupIds.length &gt; 0">
  168. <foreach collection="groupIds" index="index" item="gId" separator=" OR " open="and (" close=")">
  169. A.ID LIKE '${gId}%'
  170. </foreach>
  171. </if>
  172. <if test="plnaId !=null and plnaId !=''">
  173. and A.ID like '${plnaId}%'
  174. </if>
  175. <if test="tabType =='2'.toString()">
  176. and A.entm &lt;to_date(#{nowTime},'yyyy-MM-dd')+1
  177. </if>
  178. <if test="tabType =='1'.toString()">
  179. and A.entm &gt;=to_date(#{nowTime},'yyyy-MM-dd')
  180. </if>
  181. <if test="null != pType">
  182. and O.PTYPE = #{pType}
  183. </if>
  184. </where>
  185. </select>
  186. <select id="selectCount" resultType="int">
  187. select count(ID) from BIS_INSP_WTGT_RGSTR
  188. <include refid="page_where"/>
  189. </select>
  190. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspWtgtRgstr">
  191. insert into BIS_INSP_WTGT_RGSTR(
  192. <include refid="table_columns"/>
  193. )
  194. values (
  195. <include refid="entity_properties"/>
  196. )
  197. </insert>
  198. <delete id="delete" parameterType="java.lang.String">
  199. update BIS_INSP_WTGT_RGSTR set DATA_STAT='9' where ID = #{id}
  200. </delete>
  201. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspWtgtRgstr">
  202. update BIS_INSP_WTGT_RGSTR set DATA_STAT='9'
  203. <include refid="page_where2"/>
  204. </delete>
  205. <update id="deleteInFlag" parameterType="java.lang.String">
  206. update BIS_INSP_WTGT_RGSTR set DATA_STAT = '9' where ID = #{id}
  207. </update>
  208. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspWtgtRgstr">
  209. update BIS_INSP_WTGT_RGSTR
  210. <trim prefix="set" suffixOverrides=",">
  211. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  212. <if test="depName != null and depName != ''">DEP_NAME = #{depName},</if>
  213. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  214. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  215. <if test="wintCode != null and wintCode != ''">WINT_CODE = #{wintCode},</if>
  216. <if test="depPers != null and depPers != ''">DEP_PERS = #{depPers},</if>
  217. <if test="depPersTel != null and depPersTel != ''">DEP_PERS_TEL = #{depPersTel},</if>
  218. <if test="loc != null and loc != ''">LOC = #{loc},</if>
  219. <if test="utLead != null and utLead != ''">UT_LEAD = #{utLead},</if>
  220. <if test="principalTel != null and principalTel != ''">PRINCIPAL_TEL = #{principalTel},</if>
  221. <if test="note != null and note != ''">NOTE = #{note},</if>
  222. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  223. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  224. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  225. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  226. <if test="payState != null and payState != ''">PAY_STATE = #{payState},</if>
  227. <if test="planState != null and planState != ''">PLAN_STATE = #{planState},</if>
  228. <if test="state != null and state != ''">STATE = #{state},</if>
  229. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  230. <if test="intm != null">INTM = #{intm},</if>
  231. <if test="uptm != null">UPTM = #{uptm},</if>
  232. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  233. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  234. </trim>
  235. <where>ID = #{id}</where>
  236. </update>
  237. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspWtgtRgstr">
  238. update BIS_INSP_WTGT_RGSTR
  239. <trim prefix="set" suffixOverrides=",">
  240. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  241. <if test="depName != null and depName != ''">DEP_NAME = #{depName},</if>
  242. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  243. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  244. <if test="wintCode != null and wintCode != ''">WINT_CODE = #{wintCode},</if>
  245. <if test="depPers != null and depPers != ''">DEP_PERS = #{depPers},</if>
  246. <if test="depPersTel != null and depPersTel != ''">DEP_PERS_TEL = #{depPersTel},</if>
  247. <if test="loc != null and loc != ''">LOC = #{loc},</if>
  248. <if test="utLead != null and utLead != ''">UT_LEAD = #{utLead},</if>
  249. <if test="principalTel != null and principalTel != ''">PRINCIPAL_TEL = #{principalTel},</if>
  250. <if test="note != null and note != ''">NOTE = #{note},</if>
  251. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  252. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  253. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  254. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  255. <if test="payState != null and payState != ''">PAY_STATE = #{payState},</if>
  256. <if test="planState != null and planState != ''">PLAN_STATE = #{planState},</if>
  257. <if test="state != null and state != ''">STATE = #{state},</if>
  258. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  259. <if test="intm != null">INTM = #{intm},</if>
  260. <if test="uptm != null">UPTM = #{uptm},</if>
  261. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  262. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  263. </trim>
  264. <include refid="page_where2"/>
  265. </update>
  266. <!-- 其他自定义SQL -->
  267. <select id="findPageList" resultType="cn.com.goldenwater.dcproj.dto.BisInspWtgtRgstrDto">
  268. SELECT * FROM (
  269. select
  270. A.CODE, A.ID nodeId, A.NM, A.ptype, A.OBJ_ID,
  271. aw.id as baseId, ia.pnm groupName,
  272. B.ID ID, B.id as rgstrId,
  273. (case when b.STATE is null then '0' else b.state end) STATE,
  274. B.DEP_NAME, B.AD_CODE, B.AD_NAME, B.WINT_CODE, B.DEP_PERS, B.DEP_PERS_TEL, B.LOC,
  275. B.CENTER_X, B.CENTER_Y, B.GD_X,
  276. B.GD_Y, B.PAY_STATE, B.PLAN_STATE, B.PERS_ID,B.UT_LEAD,
  277. B.PRINCIPAL_TEL, B.NOTE, B.INTM, B.UPTM, B.GROUP_ID, B.DATA_STAT
  278. FROM BIS_INSP_ALL_OBJ A
  279. LEFT JOIN BIS_INSP_WTGT_RGSTR B ON A.OBJ_ID=B.OBJ_ID
  280. LEFT JOIN BIS_INSP_ALL IA ON A.ID = IA.ID
  281. LEFT JOIN ATT_WTGT_BASE AW ON A.CODE = AW.ID
  282. where A.ptype= #{pType}
  283. and B.DATA_STAT='0'
  284. <if test="adCodes ==null or adCodes ==''">
  285. <choose>
  286. <when test='isAll =="1"'>
  287. </when>
  288. <otherwise>
  289. and
  290. A.Id in (
  291. select distinct id from (
  292. SELECT P.id FROM BIS_INSP_ALL P START WITH P.PID IN (SELECT id FROM BIS_INSP_ALL_RLATION A
  293. WHERE A.PERSID = #{presId} and TYPE = #{pType} and length(id) in (3,6,9))
  294. CONNECT BY P.PID = PRIOR P.ID
  295. union all
  296. SELECT P.id FROM BIS_INSP_ALL P where p.id in (SELECT id FROM BIS_INSP_ALL_RLATION A
  297. WHERE A.PERSID =#{presId} and TYPE = #{pType} and length(id)=12 )
  298. )
  299. )
  300. </otherwise>
  301. </choose>
  302. </if>
  303. <if test="adCodes !=null and adCodes !=''">
  304. and
  305. <foreach item="item" index="index" collection="adCodes.split(',')" open="(" separator="or" close=")">
  306. b.ad_code like concat('${item}','%')
  307. </foreach>
  308. </if>
  309. ) A WHERE a.PTYPE=#{pType}
  310. <if test="plnaId !=null and plnaId !=''">
  311. and a.nodeId like '${plnaId}%'
  312. </if>
  313. <if test="state !=null and state !=''">
  314. and STATE in (${state})
  315. </if>
  316. <if test="rsName !=null and rsName !=''">
  317. and a.nm like '%${rsName}%'
  318. </if>
  319. <if test="code !=null and code !=''">
  320. and a.code = #{code}
  321. </if>
  322. <if test="adName != null and adName != ''">and a.adName like '%${adName}%'</if>
  323. <if test="sttm != null and sttm != ''">and a.Intm&gt;= TO_DATE(#{sttm},'YYYY-MM-DD')</if>
  324. <if test="entm != null and entm != ''">and a.Intm &lt; To_DATE(#{entm},'yyyy-MM-dd') + 1</if>
  325. <if test="groupId != null and groupId != ''">and a.nodeId = #{groupId}</if>
  326. order by nodeId asc
  327. <if test="orderBy != null and orderBy != ''">
  328. ,nlssort(nm,'NLS_SORT=SCHINESE_PINYIN_M')
  329. </if>
  330. </select>
  331. <select id="getListByInspGroupIdObjType" resultType="cn.com.goldenwater.dcproj.dto.BisInspWtgtRgstrDto"
  332. parameterType="cn.com.goldenwater.dcproj.param.PagePersObjParam">
  333. SELECT
  334. C.id groupId,C.PNM groupName,B.obj_id,
  335. T.ID,
  336. T.DEP_NAME,
  337. T.AD_CODE,
  338. T.AD_NAME,
  339. T.WINT_CODE,
  340. T.DEP_PERS,
  341. T.DEP_PERS_TEL,
  342. T.LOC, T.UT_LEAD,
  343. T.PRINCIPAL_TEL, T.NOTE,
  344. T.CENTER_X,
  345. T.CENTER_Y,
  346. T.GD_X,
  347. T.GD_Y,
  348. T.PAY_STATE,
  349. T.PLAN_STATE,
  350. T.STATE,
  351. T.PERS_ID,
  352. T.INTM,
  353. T.UPTM,
  354. T.GROUP_ID,
  355. T.DATA_STAT
  356. FROM BIS_INSP_ALL_OBJ B
  357. LEFT JOIN BIS_INSP_WTGT_RGSTR T ON B.OBJ_ID = t.OBJ_ID
  358. LEFT JOIN BIS_INSP_ALL C ON B.ID = C.ID
  359. where B.ptype = #{objType}
  360. and T.DATA_STAT='0'
  361. <if test='isAll == "0"'>and B.ID = #{inspGroupId}</if>
  362. <if test='isAll == "1"'>and B.ID LIKE '${inspGroupId}%'</if>
  363. <if test="rsName != null and rsName != ''">
  364. and t.DEP_NAME like '${rsName}%'
  365. </if>
  366. <if test="wtdstState != null and wtdstState != ''">
  367. and t.STATE like #{wtdstState}
  368. </if>
  369. <if test="adCode != null and adCode != ''">
  370. and t.AD_CODE like '${adCode}%'
  371. </if>
  372. <choose>
  373. <when test="province != null and province != ''">
  374. and B.AD_CODE LIKE '${province}%'
  375. </when>
  376. <otherwise>
  377. and B.AD_CODE is null
  378. </otherwise>
  379. </choose>
  380. </select>
  381. </mapper>