BisInspWtgthRgstrDao.xml 16 KB

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