BisInspRvgmRgstrDao.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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.BisInspRvgmRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspRvgmRgstr" id="bisInspRvgmRgstrResultMap">
  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="loc" column="LOC"/>
  11. <result property="utLead" column="UT_LEAD"/>
  12. <result property="principalTel" column="PRINCIPAL_TEL"/>
  13. <result property="depPers" column="DEP_PERS"/>
  14. <result property="depPersTel" column="DEP_PERS_TEL"/>
  15. <result property="note" column="NOTE"/>
  16. <result property="state" column="STATE"/>
  17. <result property="sysStat" column="SYS_STAT"/>
  18. <result property="admStat" column="ADM_STAT"/>
  19. <result property="bswkStat" column="BSWK_STAT"/>
  20. <result property="costStat" column="COST_STAT"/>
  21. <result property="othrStat" column="OTHR_STAT"/>
  22. <result property="centerX" column="CENTER_X"/>
  23. <result property="centerY" column="CENTER_Y"/>
  24. <result property="gdX" column="GD_X"/>
  25. <result property="gdY" column="GD_Y"/>
  26. <result property="persId" column="PERS_ID"/>
  27. <result property="intm" column="INTM"/>
  28. <result property="uptm" column="UPTM"/>
  29. <result property="dataStat" column="DATA_STAT"/>
  30. </resultMap>
  31. <sql id="table_columns">
  32. ID,
  33. OBJ_ID,
  34. DEP_NAME,
  35. AD_CODE,
  36. AD_NAME,
  37. LOC,
  38. UT_LEAD,
  39. PRINCIPAL_TEL,
  40. DEP_PERS,
  41. DEP_PERS_TEL,
  42. NOTE,
  43. STATE,
  44. SYS_STAT,
  45. ADM_STAT,
  46. BSWK_STAT,
  47. COST_STAT,
  48. OTHR_STAT,
  49. CENTER_X,
  50. CENTER_Y,
  51. GD_X,
  52. GD_Y,
  53. PERS_ID,
  54. INTM,
  55. UPTM,
  56. DATA_STAT
  57. </sql>
  58. <sql id="entity_properties">
  59. #{id},
  60. #{objId},
  61. #{depName},
  62. #{adCode},
  63. #{adName},
  64. #{loc},
  65. #{utLead},
  66. #{principalTel},
  67. #{depPers},
  68. #{depPersTel},
  69. #{note},
  70. #{state},
  71. #{sysStat},
  72. #{admStat},
  73. #{bswkStat},
  74. #{costStat},
  75. #{othrStat},
  76. #{centerX},
  77. #{centerY},
  78. #{gdX},
  79. #{gdY},
  80. #{persId},
  81. #{intm},
  82. #{uptm},
  83. #{dataStat}
  84. </sql>
  85. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  86. <sql id="page_where">
  87. <trim prefix="where" prefixOverrides="and | or ">
  88. <if test="objId != null and objId != ''">
  89. and OBJ_ID = #{objId}
  90. </if>
  91. <if test="depName != null and depName != ''">
  92. and DEP_NAME = #{depName}
  93. </if>
  94. <if test="adCode != null and adCode != ''">
  95. and AD_CODE = #{adCode}
  96. </if>
  97. <if test="adName != null and adName != ''">
  98. and AD_NAME = #{adName}
  99. </if>
  100. <if test="loc != null and loc != ''">
  101. and LOC = #{loc}
  102. </if>
  103. <if test="utLead != null and utLead != ''">
  104. and UT_LEAD = #{utLead}
  105. </if>
  106. <if test="principalTel != null and principalTel != ''">
  107. and PRINCIPAL_TEL = #{principalTel}
  108. </if>
  109. <if test="depPers != null and depPers != ''">
  110. and DEP_PERS = #{depPers}
  111. </if>
  112. <if test="depPersTel != null and depPersTel != ''">
  113. and DEP_PERS_TEL = #{depPersTel}
  114. </if>
  115. <if test="note != null and note != ''">
  116. and NOTE = #{note}
  117. </if>
  118. <if test="state != null and state != ''">
  119. and STATE = #{state}
  120. </if>
  121. <if test="sysStat != null and sysStat != ''">
  122. and SYS_STAT = #{sysStat}
  123. </if>
  124. <if test="admStat != null and admStat != ''">
  125. and ADM_STAT = #{admStat}
  126. </if>
  127. <if test="bswkStat != null and bswkStat != ''">
  128. and BSWK_STAT = #{bswkStat}
  129. </if>
  130. <if test="costStat != null and costStat != ''">
  131. and COST_STAT = #{costStat}
  132. </if>
  133. <if test="othrStat != null and othrStat != ''">
  134. and OTHR_STAT = #{othrStat}
  135. </if>
  136. <if test="centerX != null and centerX != ''">
  137. and CENTER_X = #{centerX}
  138. </if>
  139. <if test="centerY != null and centerY != ''">
  140. and CENTER_Y = #{centerY}
  141. </if>
  142. <if test="gdX != null and gdX != ''">
  143. and GD_X = #{gdX}
  144. </if>
  145. <if test="gdY != null and gdY != ''">
  146. and GD_Y = #{gdY}
  147. </if>
  148. <if test="persId != null and persId != ''">
  149. and PERS_ID = #{persId}
  150. </if>
  151. <if test="intm != null">
  152. and INTM = #{intm}
  153. </if>
  154. <if test="uptm != null">
  155. and UPTM = #{uptm}
  156. </if>
  157. <if test="dataStat != null and dataStat != ''">
  158. and DATA_STAT = #{dataStat}
  159. </if>
  160. and DATA_STAT='0'
  161. </trim>
  162. </sql>
  163. <select id="get" resultMap="bisInspRvgmRgstrResultMap" parameterType="String">
  164. select R.ID,
  165. R.OBJ_ID,
  166. R.DEP_NAME,
  167. R.AD_CODE,
  168. R.AD_NAME,
  169. R.LOC,
  170. R.UT_LEAD,
  171. R.PRINCIPAL_TEL,
  172. R.DEP_PERS,
  173. R.DEP_PERS_TEL,
  174. R.STATE,
  175. R.SYS_STAT,
  176. R.ADM_STAT,
  177. R.BSWK_STAT,
  178. R.COST_STAT,
  179. R.OTHR_STAT,
  180. R.NOTE,
  181. R.CENTER_X,
  182. R.CENTER_Y,
  183. R.GD_X,
  184. R.GD_Y,
  185. R.PERS_ID,
  186. R.INTM,
  187. R.UPTM,
  188. R.GD_X AS LGTD,
  189. R.GD_Y AS LTTD,
  190. AAB.AD_FULL_NAME,
  191. R.DATA_STAT
  192. from BIS_INSP_RVGM_RGSTR R
  193. LEFT JOIN ATT_AD_BASE AAB on R.AD_CODE = AAB.AD_CODE
  194. where R.ID = #{id}
  195. </select>
  196. <select id="getBy" resultMap="bisInspRvgmRgstrResultMap">
  197. select
  198. <include refid="table_columns"/>
  199. from BIS_INSP_RVGM_RGSTR
  200. <include refid="page_where"/>
  201. </select>
  202. <select id="findAll" resultMap="bisInspRvgmRgstrResultMap">
  203. select
  204. <include refid="table_columns"/>
  205. from BIS_INSP_RVGM_RGSTR
  206. </select>
  207. <select id="findList" resultMap="bisInspRvgmRgstrResultMap">
  208. select
  209. <include refid="table_columns"/>
  210. from BIS_INSP_RVGM_RGSTR
  211. <include refid="page_where"/>
  212. </select>
  213. <select id="selectCount" resultType="int">
  214. select count(ID) from BIS_INSP_RVGM_RGSTR
  215. <include refid="page_where"/>
  216. </select>
  217. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspRvgmRgstr">
  218. insert into BIS_INSP_RVGM_RGSTR(
  219. <include refid="table_columns"/>
  220. )
  221. values (
  222. <include refid="entity_properties"/>
  223. )
  224. </insert>
  225. <delete id="delete" parameterType="java.lang.String">
  226. update BIS_INSP_RVGM_RGSTR
  227. set DATA_STAT='9'
  228. where ID = #{id}
  229. </delete>
  230. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspRvgmRgstr">
  231. update BIS_INSP_RVGM_RGSTR set DATA_STAT='9'
  232. <include refid="page_where"/>
  233. </delete>
  234. <update id="deleteInFlag" parameterType="java.lang.String">
  235. update BIS_INSP_RVGM_RGSTR
  236. set DATA_STAT = '9'
  237. where ID = #{id}
  238. </update>
  239. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspRvgmRgstr">
  240. update BIS_INSP_RVGM_RGSTR
  241. <trim prefix="set" suffixOverrides=",">
  242. <if test="objId != null and objId != ''">OBJ_ID
  243. = #{objId},
  244. </if>
  245. <if test="depName != null and depName != ''">DEP_NAME
  246. = #{depName},
  247. </if>
  248. <if test="adCode != null and adCode != ''">AD_CODE
  249. = #{adCode},
  250. </if>
  251. <if test="adName != null and adName != ''">AD_NAME
  252. = #{adName},
  253. </if>
  254. <if test="loc != null and loc != ''">LOC
  255. = #{loc},
  256. </if>
  257. <if test="utLead != null and utLead != ''">UT_LEAD
  258. = #{utLead},
  259. </if>
  260. <if test="principalTel != null and principalTel != ''">PRINCIPAL_TEL
  261. = #{principalTel},
  262. </if>
  263. <if test="depPers != null and depPers != ''">DEP_PERS
  264. = #{depPers},
  265. </if>
  266. <if test="depPersTel != null and depPersTel != ''">DEP_PERS_TEL
  267. = #{depPersTel},
  268. </if>
  269. <if test="note != null and note != ''">NOTE
  270. = #{note},
  271. </if>
  272. <if test="state != null and state != ''">STATE
  273. = #{state},
  274. </if>
  275. <if test="sysStat != null and sysStat != ''">SYS_STAT
  276. = #{sysStat},
  277. </if>
  278. <if test="admStat != null and admStat != ''">ADM_STAT
  279. = #{admStat},
  280. </if>
  281. <if test="bswkStat != null and bswkStat != ''">BSWK_STAT
  282. = #{bswkStat},
  283. </if>
  284. <if test="costStat != null and costStat != ''">COST_STAT
  285. = #{costStat},
  286. </if>
  287. <if test="othrStat != null and othrStat != ''">OTHR_STAT
  288. = #{othrStat},
  289. </if>
  290. <if test="centerX != null and centerX != ''">CENTER_X
  291. = #{centerX},
  292. </if>
  293. <if test="centerY != null and centerY != ''">CENTER_Y
  294. = #{centerY},
  295. </if>
  296. <if test="gdX != null and gdX != ''">GD_X
  297. = #{gdX},
  298. </if>
  299. <if test="gdY != null and gdY != ''">GD_Y
  300. = #{gdY},
  301. </if>
  302. <if test="persId != null and persId != ''">PERS_ID
  303. = #{persId},
  304. </if>
  305. <if test="intm != null">INTM
  306. = #{intm},
  307. </if>
  308. <if test="uptm != null">UPTM
  309. = #{uptm},
  310. </if>
  311. <if test="dataStat != null and dataStat != ''">DATA_STAT
  312. = #{dataStat},
  313. </if>
  314. </trim>
  315. <where>ID = #{id}</where>
  316. </update>
  317. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspRvgmRgstr">
  318. update BIS_INSP_RVGM_RGSTR
  319. <trim prefix="set" suffixOverrides=",">
  320. <if test="objId != null and objId != ''">OBJ_ID
  321. = #{objId},
  322. </if>
  323. <if test="depName != null and depName != ''">DEP_NAME
  324. = #{depName},
  325. </if>
  326. <if test="adCode != null and adCode != ''">AD_CODE
  327. = #{adCode},
  328. </if>
  329. <if test="adName != null and adName != ''">AD_NAME
  330. = #{adName},
  331. </if>
  332. <if test="loc != null and loc != ''">LOC
  333. = #{loc},
  334. </if>
  335. <if test="utLead != null and utLead != ''">UT_LEAD
  336. = #{utLead},
  337. </if>
  338. <if test="principalTel != null and principalTel != ''">PRINCIPAL_TEL
  339. = #{principalTel},
  340. </if>
  341. <if test="depPers != null and depPers != ''">DEP_PERS
  342. = #{depPers},
  343. </if>
  344. <if test="depPersTel != null and depPersTel != ''">DEP_PERS_TEL
  345. = #{depPersTel},
  346. </if>
  347. <if test="note != null and note != ''">NOTE
  348. = #{note},
  349. </if>
  350. <if test="state != null and state != ''">STATE
  351. = #{state},
  352. </if>
  353. <if test="sysStat != null and sysStat != ''">SYS_STAT
  354. = #{sysStat},
  355. </if>
  356. <if test="admStat != null and admStat != ''">ADM_STAT
  357. = #{admStat},
  358. </if>
  359. <if test="bswkStat != null and bswkStat != ''">BSWK_STAT
  360. = #{bswkStat},
  361. </if>
  362. <if test="costStat != null and costStat != ''">COST_STAT
  363. = #{costStat},
  364. </if>
  365. <if test="othrStat != null and othrStat != ''">OTHR_STAT
  366. = #{othrStat},
  367. </if>
  368. <if test="centerX != null and centerX != ''">CENTER_X
  369. = #{centerX},
  370. </if>
  371. <if test="centerY != null and centerY != ''">CENTER_Y
  372. = #{centerY},
  373. </if>
  374. <if test="gdX != null and gdX != ''">GD_X
  375. = #{gdX},
  376. </if>
  377. <if test="gdY != null and gdY != ''">GD_Y
  378. = #{gdY},
  379. </if>
  380. <if test="persId != null and persId != ''">PERS_ID
  381. = #{persId},
  382. </if>
  383. <if test="intm != null">INTM
  384. = #{intm},
  385. </if>
  386. <if test="uptm != null">UPTM
  387. = #{uptm},
  388. </if>
  389. <if test="dataStat != null and dataStat != ''">DATA_STAT
  390. = #{dataStat},
  391. </if>
  392. </trim>
  393. <include refid="page_where"/>
  394. </update>
  395. <!-- 其他自定义SQL -->
  396. <select id="findPageList" resultType="cn.com.goldenwater.dcproj.dto.BisInspRvgmRgstrDto">
  397. SELECT * FROM (
  398. select
  399. A.CODE, A.ID AS NODE_ID, A.NM, A.PTYPE, IA.PNM AS GROUP_NAME,
  400. B.ID AS RGSTR_ID, (CASE WHEN B.STATE IS NULL THEN '0' ELSE B.STATE END) STATE,
  401. B.GD_X AS LGTD,B.GD_Y LTTD,AW.AD_FULL_NAME,
  402. B.ID,B.OBJ_ID,B.DEP_NAME,B.AD_CODE,B.AD_NAME,B.LOC, B.UT_LEAD,B.PRINCIPAL_TEL,B.DEP_PERS,B.DEP_PERS_TEL,
  403. B.NOTE,B.CENTER_X,B.CENTER_Y,B.GD_X,B.GD_Y,B.PERS_ID,B.INTM,B.UPTM,B.DATA_STAT,
  404. B.SYS_STAT,B.ADM_STAT,B.BSWK_STAT,B.COST_STAT,B.OTHR_STAT
  405. FROM BIS_INSP_ALL_OBJ A
  406. JOIN BIS_INSP_RVGM_RGSTR B ON A.OBJ_ID=B.OBJ_ID
  407. LEFT JOIN BIS_INSP_ALL IA ON A.ID = IA.ID
  408. LEFT JOIN ATT_AD_BASE AW ON B.AD_CODE = AW.AD_CODE
  409. where B.DATA_STAT='0'
  410. <if test="adCodes ==null or adCodes ==''">
  411. <choose>
  412. <when test='isAll =="1"'>
  413. </when>
  414. <otherwise>
  415. and
  416. A.Id in (
  417. select distinct w.id from (
  418. SELECT P.id FROM BIS_INSP_ALL P
  419. WHERE FIND_IN_SET(P.ID, getSubNodes_bis_insp_all((SELECT group_concat(A.id) FROM BIS_INSP_ALL_RLATION A
  420. WHERE A.PERSID = #{presId} AND A.Type=#{pType} and length(A.id) in (3,6,9) group by A.PERSID ),0,0)) &gt; 0
  421. union all
  422. SELECT P.id FROM BIS_INSP_ALL P where p.id in (SELECT id FROM BIS_INSP_ALL_RLATION A
  423. WHERE A.PERSID =#{presId} and TYPE = #{pType} and length(id)=12 )
  424. ) w
  425. )
  426. </otherwise>
  427. </choose>
  428. </if>
  429. <if test="adCodes !=null and adCodes !=''">
  430. and
  431. <foreach item="item" index="index" collection="adCodes.split(',')" open="(" separator="or" close=")">
  432. b.ad_code like concat('${item}','%')
  433. </foreach>
  434. </if>
  435. ) A
  436. <where>
  437. <if test="id !=null and id !=''">and NODE_ID like '${id}%'</if>
  438. <if test="plnaId !=null and plnaId !=''">and NODE_ID like '${plnaId}%'</if>
  439. <if test="groupId != null and groupId != ''">and NODE_ID like '${groupId}%'</if>
  440. <if test="code !=null and code !=''">and code = #{code}</if>
  441. <if test="nm !=null and nm !=''">and nm like '%${nm}%'</if>
  442. <if test="state !=null and state !=''">and STATE in (${state})</if>
  443. <if test="adName != null and adName != ''">and AD_NAME like '%${adName}%'</if>
  444. <if test="sttm != null and sttm != ''">and Intm &gt;= STR_TO_DATE(#{sttm},'%Y-%m-%d')</if>
  445. <if test="entm != null and entm != ''">and Intm &lt; DATE_ADD(STR_TO_DATE(#{entm},'%Y-%m-%d') ,INTERVAL 1 DAY)</if>
  446. </where>
  447. order by NODE_ID asc
  448. <if test="orderBy != null and orderBy != ''">
  449. ,CONVERT( nm USING gbk ) COLLATE gbk_chinese_ci ASC
  450. </if>
  451. </select>
  452. </mapper>