BisInspRsfcoqhRgstrDao.xml 17 KB

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