BisInspSamrmpRgstrDao.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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.BisInspSamrmpRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspSamrmpRgstr" id="bisInspSamrmpRgstrResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="prjId" column="PRJ_ID"/>
  8. <result property="prjName" column="PRJ_NAME"/>
  9. <result property="rvName" column="RV_NAME"/>
  10. <result property="adCode" column="AD_CODE"/>
  11. <result property="adName" column="AD_NAME"/>
  12. <result property="addr" column="ADDR"/>
  13. <result property="centerX" column="CENTER_X"/>
  14. <result property="centerY" column="CENTER_Y"/>
  15. <result property="gdX" column="GD_X"/>
  16. <result property="gdY" column="GD_Y"/>
  17. <result property="smrmpState" column="SMRMP_STATE"/>
  18. <result property="state" column="STATE"/>
  19. <result property="groupLeader" column="GROUP_LEADER"/>
  20. <result property="groupLeaderTel" column="GROUP_LEADER_TEL"/>
  21. <result property="recPersId" column="REC_PERS_ID"/>
  22. <result property="recPers" column="REC_PERS"/>
  23. <result property="recPersTel" column="REC_PERS_TEL"/>
  24. <result property="intm" column="INTM"/>
  25. <result property="uptm" column="UPTM"/>
  26. <result property="note" column="NOTE"/>
  27. <result property="rvLong" column="RV_LONG"/>
  28. <result property="pgi" column="PGI"/>
  29. </resultMap>
  30. <sql id="table_columns">
  31. RV_LONG,
  32. PGI,
  33. ID,
  34. OBJ_ID,
  35. PRJ_ID,
  36. PRJ_NAME,
  37. RV_NAME,
  38. AD_CODE,
  39. AD_NAME,
  40. ADDR,
  41. CENTER_X,
  42. CENTER_Y,
  43. GD_X,
  44. GD_Y,
  45. SMRMP_STATE,
  46. STATE,
  47. GROUP_LEADER,
  48. GROUP_LEADER_TEL,
  49. REC_PERS_ID,
  50. REC_PERS,
  51. REC_PERS_TEL,
  52. INTM,
  53. UPTM,
  54. NOTE
  55. </sql>
  56. <sql id="entity_properties">
  57. #{rvLong},
  58. #{pgi},
  59. #{id},
  60. #{objId},
  61. #{prjId},
  62. #{prjName},
  63. #{rvName},
  64. #{adCode},
  65. #{adName},
  66. #{addr},
  67. #{centerX},
  68. #{centerY},
  69. #{gdX},
  70. #{gdY},
  71. #{smrmpState},
  72. #{state},
  73. #{groupLeader},
  74. #{groupLeaderTel},
  75. #{recPersId},
  76. #{recPers},
  77. #{recPersTel},
  78. #{intm},
  79. #{uptm},
  80. #{note}
  81. </sql>
  82. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  83. <sql id="page_where">
  84. <trim prefix="where" prefixOverrides="and | or ">
  85. <if test="rvLong != null and rvLong != ''">and RV_LONG = #{rvLong}</if>
  86. <if test="pgi != null and pgi != ''">and PGI = #{pgi}</if>
  87. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  88. <if test="prjId != null and prjId != ''">and PRJ_ID = #{prjId}</if>
  89. <if test="prjName != null and prjName != ''">and PRJ_NAME = #{prjName}</if>
  90. <if test="rvName != null and rvName != ''">and RV_NAME = #{rvName}</if>
  91. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  92. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  93. <if test="addr != null and addr != ''">and ADDR = #{addr}</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="smrmpState != null and smrmpState != ''">and SMRMP_STATE = #{smrmpState}</if>
  99. <if test="state != null and state != ''">and STATE = #{state}</if>
  100. <if test="groupLeader != null and groupLeader != ''">and GROUP_LEADER = #{groupLeader}</if>
  101. <if test="groupLeaderTel != null and groupLeaderTel != ''">and GROUP_LEADER_TEL = #{groupLeaderTel}</if>
  102. <if test="recPersId != null and recPersId != ''">and REC_PERS_ID = #{recPersId}</if>
  103. <if test="recPers != null and recPers != ''">and REC_PERS = #{recPers}</if>
  104. <if test="recPersTel != null and recPersTel != ''">and REC_PERS_TEL = #{recPersTel}</if>
  105. <if test="intm != null">and INTM = #{intm}</if>
  106. <if test="uptm != null">and UPTM = #{uptm}</if>
  107. <if test="note != null and note != ''">and NOTE = #{note}</if>
  108. </trim>
  109. </sql>
  110. <select id="get" resultMap="bisInspSamrmpRgstrResultMap" parameterType="String">
  111. select
  112. <include refid="table_columns"/>
  113. from BIS_INSP_SAMRMP_RGSTR where ID = #{id}
  114. </select>
  115. <select id="getBy" resultMap="bisInspSamrmpRgstrResultMap">
  116. select
  117. <include refid="table_columns"/>
  118. from BIS_INSP_SAMRMP_RGSTR
  119. <include refid="page_where"/>
  120. </select>
  121. <select id="findAll" resultMap="bisInspSamrmpRgstrResultMap">
  122. select
  123. <include refid="table_columns"/>
  124. from BIS_INSP_SAMRMP_RGSTR
  125. </select>
  126. <select id="findList" resultMap="bisInspSamrmpRgstrResultMap">
  127. select
  128. <include refid="table_columns"/>
  129. from BIS_INSP_SAMRMP_RGSTR
  130. <include refid="page_where"/>
  131. </select>
  132. <select id="selectCount" resultType="int">
  133. select count(ID) from BIS_INSP_SAMRMP_RGSTR
  134. <include refid="page_where"/>
  135. </select>
  136. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspSamrmpRgstr">
  137. insert into BIS_INSP_SAMRMP_RGSTR(
  138. <include refid="table_columns"/>
  139. )
  140. values (
  141. <include refid="entity_properties"/>
  142. )
  143. </insert>
  144. <delete id="delete" parameterType="java.lang.String">
  145. delete from BIS_INSP_SAMRMP_RGSTR where ID = #{id}
  146. </delete>
  147. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspSamrmpRgstr">
  148. delete from BIS_INSP_SAMRMP_RGSTR
  149. <include refid="page_where"/>
  150. </delete>
  151. <update id="deleteInFlag" parameterType="java.lang.String">
  152. update BIS_INSP_SAMRMP_RGSTR set flag_valid = 0 where>ID = #{id}
  153. </update>
  154. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspSamrmpRgstr">
  155. update BIS_INSP_SAMRMP_RGSTR
  156. <trim prefix="set" suffixOverrides=",">
  157. <if test="rvLong != null and rvLong != ''">RV_LONG = #{rvLong},</if>
  158. <if test="pgi != null and pgi != ''">PGI = #{pgi},</if>
  159. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  160. <if test="prjId != null and prjId != ''">PRJ_ID = #{prjId},</if>
  161. <if test="prjName != null and prjName != ''">PRJ_NAME = #{prjName},</if>
  162. <if test="rvName != null and rvName != ''">RV_NAME = #{rvName},</if>
  163. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  164. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  165. <if test="addr != null and addr != ''">ADDR = #{addr},</if>
  166. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  167. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  168. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  169. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  170. <if test="smrmpState != null and smrmpState != ''">SMRMP_STATE = #{smrmpState},</if>
  171. <if test="state != null and state != ''">STATE = #{state},</if>
  172. <if test="groupLeader != null and groupLeader != ''">GROUP_LEADER = #{groupLeader},</if>
  173. <if test="groupLeaderTel != null and groupLeaderTel != ''">GROUP_LEADER_TEL = #{groupLeaderTel},</if>
  174. <if test="recPersId != null and recPersId != ''">REC_PERS_ID = #{recPersId},</if>
  175. <if test="recPers != null and recPers != ''">REC_PERS = #{recPers},</if>
  176. <if test="recPersTel != null and recPersTel != ''">REC_PERS_TEL = #{recPersTel},</if>
  177. <if test="intm != null">INTM = #{intm},</if>
  178. <if test="uptm != null">UPTM = #{uptm},</if>
  179. <if test="note != null and note != ''">NOTE = #{note},</if>
  180. </trim>
  181. <where>ID = #{id}</where>
  182. </update>
  183. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspSamrmpRgstr">
  184. update BIS_INSP_SAMRMP_RGSTR
  185. <trim prefix="set" suffixOverrides=",">
  186. <if test="rvLong != null and rvLong != ''">RV_LONG = #{rvLong},</if>
  187. <if test="pgi != null and pgi != ''">PGI = #{pgi},</if>
  188. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  189. <if test="prjId != null and prjId != ''">PRJ_ID = #{prjId},</if>
  190. <if test="prjName != null and prjName != ''">PRJ_NAME = #{prjName},</if>
  191. <if test="rvName != null and rvName != ''">RV_NAME = #{rvName},</if>
  192. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  193. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  194. <if test="addr != null and addr != ''">ADDR = #{addr},</if>
  195. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  196. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  197. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  198. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  199. <if test="smrmpState != null and smrmpState != ''">SMRMP_STATE = #{smrmpState},</if>
  200. <if test="state != null and state != ''">STATE = #{state},</if>
  201. <if test="groupLeader != null and groupLeader != ''">GROUP_LEADER = #{groupLeader},</if>
  202. <if test="groupLeaderTel != null and groupLeaderTel != ''">GROUP_LEADER_TEL = #{groupLeaderTel},</if>
  203. <if test="recPersId != null and recPersId != ''">REC_PERS_ID = #{recPersId},</if>
  204. <if test="recPers != null and recPers != ''">REC_PERS = #{recPers},</if>
  205. <if test="recPersTel != null and recPersTel != ''">REC_PERS_TEL = #{recPersTel},</if>
  206. <if test="intm != null">INTM = #{intm},</if>
  207. <if test="uptm != null">UPTM = #{uptm},</if>
  208. <if test="note != null and note != ''">NOTE = #{note},</if>
  209. </trim>
  210. <include refid="page_where"/>
  211. </update>
  212. <!-- 其他自定义SQL -->
  213. <select id="findSamrmpList" resultType="cn.com.goldenwater.dcproj.dto.BisInspRgstrDto">
  214. SELECT * FROM (
  215. select
  216. A.CODE,
  217. A.ID nodeId,
  218. A.NM,
  219. #{pType} pType,
  220. A.OBJ_ID,
  221. B.ID ID,
  222. b.id as rgstrId,
  223. (case when b.State is null then '0' else b.state end) STATE,
  224. B.intm,B.UPTM,
  225. b.AD_CODE,
  226. b.AD_NAME as adName,
  227. b.SMRMP_STATE,
  228. ia.pnm groupName
  229. from BIS_INSP_ALL_OBJ
  230. A LEFT JOIN BIS_INSP_SAMRMP_RGSTR B ON A.OBJ_ID=B.OBJ_ID
  231. LEFT JOIN BIS_INSP_ALL ia on A.ID = ia.id
  232. where A.ptype= #{pType}
  233. <if test="adCodes ==null or adCodes ==''">
  234. <choose>
  235. <when test='isAll =="1"'>
  236. </when>
  237. <otherwise>
  238. AND
  239. A.Id in (
  240. select distinct id from (
  241. SELECT P.id FROM BIS_INSP_ALL P
  242. WHERE FIND_IN_SET(P.ID, getSubNodes_bis_insp_all((SELECT group_concat(A.id) FROM BIS_INSP_ALL_RLATION A
  243. WHERE A.PERSID = #{presId} AND A.Type=#{pType} and (length(A.id) between 2 and 10) group by A.PERSID ),0,0)) &gt; 0
  244. union all
  245. SELECT P.id FROM BIS_INSP_ALL P where p.id in (SELECT id FROM BIS_INSP_ALL_RLATION A
  246. WHERE A.PERSID = #{presId} AND Type=#{pType}
  247. and length(id)&gt; 11 )
  248. )
  249. )
  250. </otherwise>
  251. </choose>
  252. </if>
  253. <if test="adCodes !=null and adCodes !=''">
  254. and
  255. <foreach item="item" index="index" collection="adCodes.split(',')" open="(" separator="or" close=")">
  256. b.ad_code like concat('${item}','%')
  257. </foreach>
  258. </if>
  259. ) A WHERE a.PTYPE=#{pType}
  260. <if test="adCode !=null and adCode !='' ">
  261. and a.AD_CODE like '${province}%'
  262. </if>
  263. <if test="plnaId !=null and plnaId !=''">
  264. and a.nodeId like '${plnaId}%'
  265. </if>
  266. <if test="state !=null and state !=''">
  267. and STATE in (${state})
  268. </if>
  269. <if test="rsName !=null and rsName !=''">
  270. and a.nm like '%${rsName}%'
  271. </if>
  272. <if test="code !=null and code !=''">
  273. and a.code = #{code}
  274. </if>
  275. <if test="adName != null and adName != ''">and a.adName like '%${adName}%'</if>
  276. <if test="sttm != null and sttm != ''">and a.Intm&gt;= STR_TO_DATE(#{sttm},'%Y-%m-%d')</if>
  277. <if test="entm != null and entm != ''">and a.Intm &lt; DATE_ADD(STR_TO_DATE(#{entm},'%Y-%m-%d') , INTERVAL 1 DAY)</if>
  278. <if test="groupId != null and groupId != ''">and a.nodeId = #{groupId}</if>
  279. order by nodeId asc
  280. <if test="orderBy != null and orderBy != ''">
  281. ,CONVERT( nm USING gbk ) COLLATE gbk_chinese_ci ASC
  282. </if>
  283. </select>
  284. <select id="getListByInspGroupIdObjType" resultType="cn.com.goldenwater.dcproj.model.BisInspSamrmpRgstr">
  285. SELECT C.id groupId,C.PNM groupName,B.obj_id,
  286. T.RV_LONG,
  287. T.PGI,
  288. T.ID,
  289. T.PRJ_ID,
  290. T.PRJ_NAME,
  291. T.RV_NAME,
  292. T.AD_CODE,
  293. T.AD_NAME,
  294. T.ADDR,
  295. T.CENTER_X,
  296. T.CENTER_Y,
  297. T.GD_X,
  298. T.GD_Y,
  299. T.SMRMP_STATE,
  300. T.STATE,
  301. T.GROUP_LEADER,
  302. T.GROUP_LEADER_TEL,
  303. T.REC_PERS_ID,
  304. T.REC_PERS,
  305. T.REC_PERS_TEL,
  306. T.INTM,
  307. T.UPTM,
  308. T.NOTE
  309. FROM BIS_INSP_ALL_OBJ B
  310. LEFT JOIN BIS_INSP_SAMRMP_RGSTR t ON B.OBJ_ID = t.OBJ_ID
  311. LEFT JOIN BIS_INSP_ALL C ON B.ID = C.ID
  312. where B.ptype = #{objType}
  313. <if test='isAll == "0"'>and B.ID = #{inspGroupId}</if>
  314. <if test='isAll == "1"'>and B.ID LIKE '${inspGroupId}%'</if>
  315. <if test="adCode != null and adCode != ''">
  316. and t.AD_CODE like '${adCode}%'
  317. </if>
  318. <if test="wtdstNm != null and wtdstNm != ''">
  319. and t.PRJ_NAME like '${wtdstNm}%'
  320. </if>
  321. <choose>
  322. <when test="province != null and province != ''">
  323. and B.AD_CODE LIKE '${province}%'
  324. </when>
  325. <otherwise>
  326. and B.AD_CODE is null
  327. </otherwise>
  328. </choose>
  329. </select>
  330. </mapper>