BisInspVillRgstrDao.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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.BisInspVillRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspVillRgstr" id="bisInspVillRgstrResultMap">
  5. <result property="dataStat" column="DATA_STAT"/>
  6. <result property="state" column="STATE"/>
  7. <result property="engId" column="ENG_ID"/>
  8. <result property="objId" column="OBJ_ID"/>
  9. <result property="regsNm" column="REGS_NM"/>
  10. <result property="groupLeader" column="GROUP_LEADER"/>
  11. <result property="groupLeaderTel" column="GROUP_LEADER_TEL"/>
  12. <result property="recPersId" column="REC_PERS_ID"/>
  13. <result property="recPers" column="REC_PERS"/>
  14. <result property="recPersTel" column="REC_PERS_TEL"/>
  15. <result property="intm" column="INTM"/>
  16. <result property="uptm" column="UPTM"/>
  17. <result property="note" column="NOTE"/>
  18. <result property="inspGroupId" column="INSP_GROUP_ID"/>
  19. <result property="orgId" column="ORG_ID"/>
  20. </resultMap>
  21. <sql id="table_columns">
  22. DATA_STAT ,
  23. STATE ,
  24. ENG_ID ,
  25. OBJ_ID ,
  26. REGS_NM ,
  27. GROUP_LEADER ,
  28. GROUP_LEADER_TEL ,
  29. REC_PERS_ID ,
  30. REC_PERS ,
  31. REC_PERS_TEL ,
  32. TO_CHAR(INTM,'YYYY-MM-DD HH24:MI:SS') INTM,
  33. TO_CHAR(UPTM,'YYYY-MM-DD HH24:MI:SS') UPTM,
  34. NOTE ,ORG_ID
  35. </sql>
  36. <sql id="table_columns2">
  37. DATA_STAT ,
  38. STATE ,
  39. ENG_ID ,
  40. OBJ_ID ,
  41. REGS_NM ,
  42. GROUP_LEADER ,
  43. GROUP_LEADER_TEL ,
  44. REC_PERS_ID ,
  45. REC_PERS ,
  46. REC_PERS_TEL ,
  47. INTM ,
  48. UPTM ,
  49. NOTE ,ORG_ID
  50. </sql>
  51. <sql id="entity_properties">
  52. #{dataStat},
  53. #{state},
  54. #{engId},
  55. #{objId},
  56. #{regsNm},
  57. #{groupLeader},
  58. #{groupLeaderTel},
  59. #{recPersId},
  60. #{recPers},
  61. #{recPersTel},
  62. TO_DATE(#{intm},'YYYY-MM-DD HH24:MI:SS') ,
  63. TO_DATE(#{uptm},'YYYY-MM-DD HH24:MI:SS') ,
  64. #{note},#{orgId}
  65. </sql>
  66. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  67. <sql id="page_where">
  68. <trim prefix="where" prefixOverrides="and | or ">
  69. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  70. <if test="state != null and state != ''">and STATE = #{state}</if>
  71. <if test="engId != null and engId != ''">and ENG_ID = #{engId}</if>
  72. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  73. <if test="regsNm != null and regsNm != ''">and REGS_NM = #{regsNm}</if>
  74. <if test="groupLeader != null and groupLeader != ''">and GROUP_LEADER = #{groupLeader}</if>
  75. <if test="groupLeaderTel != null and groupLeaderTel != ''">and GROUP_LEADER_TEL = #{groupLeaderTel}</if>
  76. <if test="recPersId != null and recPersId != ''">and REC_PERS_ID = #{recPersId}</if>
  77. <if test="recPers != null and recPers != ''">and REC_PERS = #{recPers}</if>
  78. <if test="recPersTel != null and recPersTel != ''">and REC_PERS_TEL = #{recPersTel}</if>
  79. <if test="intm != null and intm != ''">and INTM = TO_DATE(#{intm},'YYYY-MM-DD HH24:MI:SS')</if>
  80. <if test="uptm != null and uptm != ''">and UPTM = TO_DATE(#{uptm},'YYYY-MM-DD HH24:MI:SS')</if>
  81. <if test="note != null and note != ''">and NOTE = #{note}</if>
  82. <if test="orgId != null and orgId != ''">and ORG_ID = #{orgId}</if>
  83. </trim>
  84. </sql>
  85. <select id="get" resultMap="bisInspVillRgstrResultMap" parameterType="String" >
  86. select <include refid="table_columns" /> from BIS_INSP_VILL_RGSTR where ENG_ID = #{id}
  87. </select>
  88. <select id="getBy" resultMap="bisInspVillRgstrResultMap">
  89. select <include refid="table_columns" /> from BIS_INSP_VILL_RGSTR <include refid="page_where" />
  90. </select>
  91. <select id="findAll" resultMap="bisInspVillRgstrResultMap">
  92. select <include refid="table_columns" /> from BIS_INSP_VILL_RGSTR
  93. </select>
  94. <select id="findList" resultMap="bisInspVillRgstrResultMap">
  95. select <include refid="table_columns" /> from BIS_INSP_VILL_RGSTR <include refid="page_where" /> ORDER BY UPTM DESC
  96. </select>
  97. <select id="findPageByType" resultType="cn.com.goldenwater.dcproj.dto.BisInspVillRgstrDto" parameterType="cn.com.goldenwater.dcproj.param.TypeParam" >
  98. select * from
  99. (
  100. select A.*,CASE WHEN b.state IS NULL THEN '0' ELSE b.state END AS wtdstState,B.ENG_ID,B.INTM
  101. FROM BIS_INSP_ALL_OBJ A
  102. LEFT JOIN BIS_INSP_VILL_RGSTR B ON A.OBJ_ID = B.OBJ_ID
  103. LEFT JOIN BIS_INSP_ALL ia
  104. ON A.id=ia.id
  105. where 1=1
  106. <if test="tabType =='2'.toString()">
  107. and ia.entm &lt;to_date(#{nowTime},'yyyy-MM-dd')+1
  108. </if>
  109. <if test="tabType =='1'.toString()">
  110. and ia.entm &gt;=to_date(#{nowTime},'yyyy-MM-dd')
  111. </if>
  112. <if test="orgId != null and orgId != ''">and A.ORG_ID = #{orgId}</if>
  113. and
  114. REGEXP_LIKE(
  115. A.Id,'^('||
  116. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION B WHERE PERSID =#{presId}
  117. <include refid="choseSql"/>
  118. )>0 then
  119. (SELECT LISTAGG(id, '|') as
  120. id FROM BIS_INSP_ALL_RLATION B WHERE PERSID =#{presId}
  121. <include refid="choseSql"/> group by persid
  122. )
  123. else (select 'non' from dual) end)
  124. ||')')
  125. ) a
  126. where ptype=#{pType}
  127. <if test="plnaId !=null and plnaId !=''">
  128. and a.id like '${plnaId}%'
  129. </if>
  130. <if test="state !=null and state !=''">
  131. and wtdstState =#{state}
  132. </if>
  133. <if test="rsName !=null and rsName !=''">
  134. and a.nm like '%${rsName}%'
  135. </if>
  136. order by wtdstState asc
  137. <if test="orderBy != null and orderBy != ''">
  138. ,nlssort(nm,'NLS_SORT=SCHINESE_PINYIN_M')
  139. </if>
  140. </select>
  141. <select id="findTree" resultType="cn.com.goldenwater.dcproj.dto.BisInspVillRgstrDto" parameterType="cn.com.goldenwater.dcproj.param.TypeParam" >
  142. select * from (
  143. SELECT a.id,pid,pnm nm,0 lgtd,0 lttd,'' eng_id,''obj_id,'node'noteType,a.id code
  144. FROM BIS_INSP_ALL A where a.id like '002${orgId}%' and REGEXP_LIKE(
  145. A.Id,'^('||
  146. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION b WHERE PERSID = #{presId} <include refid="choseSql"/>)>0 then
  147. (SELECT LISTAGG(id, '|') as
  148. id FROM BIS_INSP_ALL_RLATION b WHERE PERSID = #{presId} <include refid="choseSql"/> group by persid)
  149. else (select 'non' from dual) end)
  150. ||')')
  151. union all
  152. select A.CODE ID,C.ID PID,A.NM NM,A.LTTD,A.LGTD,B.ENG_ID,A.obj_id,'county'noteType,A.ID code from bis_insp_all_obj A
  153. LEFT JOIN BIS_INSP_VILL_RGSTR B ON A.OBJ_ID=B.OBJ_ID
  154. LEFT JOIN BIS_INSP_ALL C ON A.ID=C.ID
  155. WHERE A.PTYPE='2'
  156. and REGEXP_LIKE(
  157. A.Id,'^('||
  158. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION b WHERE PERSID = #{presId} <include refid="choseSql"/>)>0 then
  159. (SELECT LISTAGG(id, '|') as
  160. id FROM BIS_INSP_ALL_RLATION b WHERE PERSID = #{presId} <include refid="choseSql"/> group by persid)
  161. else (select 'non' from dual) end)
  162. ||')')
  163. ) B where 1=1
  164. order by id
  165. </select>
  166. <sql id="choseSql">
  167. <choose>
  168. <when test="province !=null and province !=''">
  169. and B.ad_code=#{province}
  170. </when>
  171. <otherwise>
  172. and B.ad_code is null
  173. </otherwise>
  174. </choose>
  175. </sql>
  176. <select id="selectCount" resultType="int" >
  177. select count(ENG_ID) from BIS_INSP_VILL_RGSTR <include refid="page_where" />
  178. </select>
  179. <!--</select>-->
  180. <select id="sumVillNum" resultType="cn.com.goldenwater.dcproj.model.SumVillNUm" parameterType="String">
  181. select sum(tcNum) as tcNum,sum(proNum) as proNum,sum(surNum) as surNum,sum(waterUserNum) as waterUserNum from (
  182. SELECT max(num) as tcNum,0 as proNum,0 as surNum,0 as waterUserNum
  183. FROM (
  184. SELECT COUNT(B.VILL_ID) num
  185. FROM BIS_INSP_SECSURVEY_VLG B
  186. where B.ENG_ID=#{engId}
  187. UNION
  188. SELECT count(B.RUNSTSE_ID) num
  189. FROM BIS_INSP_VLGDRINK_FAC_OPER B
  190. where B.ENG_ID=#{engId}
  191. UNION
  192. SELECT
  193. COUNT(B.PRSN_WATER_ID) num
  194. FROM BIS_INSP_WATERUSER_INFO B
  195. where B.ENG_ID=#{engId} group by village_code
  196. )
  197. UNION
  198. SELECT 0 as tcNum,count(B.RUN_ID) as proNum,0 as surNum,0 as waterUserNum
  199. FROM BIS_INSP_VLGDRINK_PROJ_MANAGE B
  200. where B.ENG_ID=#{engId}
  201. UNION
  202. SELECT 0 as tcNum,0 as proNum, 0 as surNum, count(B.PRSN_WATER_ID) as waterUserNum
  203. FROM BIS_INSP_WATERUSER_INFO B
  204. where B.ENG_ID=#{engId}
  205. UNION
  206. SELECT
  207. 0 as tcNum,0 as proNum,COUNT(B.ENG_SUR_ID) as surNum,0 as waterUserNum
  208. FROM BIS_INSP_PRO_SOURCE_PROTECT B
  209. where B.ENG_ID=#{engId}
  210. ) w
  211. </select>
  212. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspVillRgstr">
  213. insert into BIS_INSP_VILL_RGSTR( <include refid="table_columns2" /> )
  214. values ( <include refid="entity_properties" /> )
  215. </insert>
  216. <delete id="delete" parameterType="java.lang.String">
  217. delete from BIS_INSP_VILL_RGSTR where ENG_ID = #{id}
  218. </delete>
  219. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspVillRgstr">
  220. delete from BIS_INSP_VILL_RGSTR <include refid="page_where" />
  221. </delete>
  222. <update id="deleteInFlag" parameterType="java.lang.String">
  223. update BIS_INSP_VILL_RGSTR set flag_valid = 0 where ENG_ID = #{id}
  224. </update>
  225. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspVillRgstr">
  226. update BIS_INSP_VILL_RGSTR
  227. <trim prefix="set" suffixOverrides=",">
  228. <if test="dataStat != null and dataStat != ''"> DATA_STAT = #{dataStat},</if>
  229. <if test="state != null and state != ''"> STATE = #{state},</if>
  230. <if test="objId != null and objId != ''"> OBJ_ID = #{objId},</if>
  231. <if test="regsNm != null and regsNm != ''"> REGS_NM = #{regsNm},</if>
  232. <if test="groupLeader != null and groupLeader != ''"> GROUP_LEADER = #{groupLeader},</if>
  233. <if test="groupLeaderTel != null and groupLeaderTel != ''"> GROUP_LEADER_TEL = #{groupLeaderTel},</if>
  234. <if test="recPersId != null and recPersId != ''"> REC_PERS_ID = #{recPersId},</if>
  235. <if test="recPers != null and recPers != ''"> REC_PERS = #{recPers},</if>
  236. <if test="recPersTel != null and recPersTel != ''"> REC_PERS_TEL = #{recPersTel},</if>
  237. <if test="intm != null and intm != ''"> INTM = TO_DATE(#{intm},'YYYY-MM-DD HH24:MI:SS'),</if>
  238. <if test="uptm != null and uptm != ''"> UPTM = TO_DATE(#{uptm},'YYYY-MM-DD HH24:MI:SS'),</if>
  239. <if test="note != null and note != ''"> NOTE = #{note},</if>
  240. <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
  241. </trim>
  242. <where>ENG_ID = #{engId}</where>
  243. </update>
  244. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspVillRgstr">
  245. update BIS_INSP_VILL_RGSTR
  246. <trim prefix="set" suffixOverrides=",">
  247. <if test="dataStat != null and dataStat != ''"> DATA_STAT = #{dataStat},</if>
  248. <if test="state != null and state != ''"> STATE = #{state},</if>
  249. <if test="objId != null and objId != ''"> OBJ_ID = #{objId},</if>
  250. <if test="regsNm != null and regsNm != ''"> REGS_NM = #{regsNm},</if>
  251. <if test="groupLeader != null and groupLeader != ''"> GROUP_LEADER = #{groupLeader},</if>
  252. <if test="groupLeaderTel != null and groupLeaderTel != ''"> GROUP_LEADER_TEL = #{groupLeaderTel},</if>
  253. <if test="recPersId != null and recPersId != ''"> REC_PERS_ID = #{recPersId},</if>
  254. <if test="recPers != null and recPers != ''"> REC_PERS = #{recPers},</if>
  255. <if test="recPersTel != null and recPersTel != ''"> REC_PERS_TEL = #{recPersTel},</if>
  256. <if test="intm != null and intm != ''"> INTM = TO_DATE(#{intm},'YYYY-MM-DD HH24:MI:SS'),</if>
  257. <if test="uptm != null and uptm != ''"> UPTM = TO_DATE(#{uptm},'YYYY-MM-DD HH24:MI:SS'),</if>
  258. <if test="note != null and note != ''"> NOTE = #{note},</if>
  259. <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
  260. </trim>
  261. <include refid="page_where" />
  262. </update>
  263. <!-- 其他自定义SQL -->
  264. <select id="findListByPersId" resultMap="bisInspVillRgstrResultMap" parameterType="string">
  265. SELECT
  266. D.DATA_STAT ,
  267. D.ENG_ID ,
  268. D.OBJ_ID ,
  269. D.REGS_NM ,
  270. D.GROUP_LEADER ,
  271. D.GROUP_LEADER_TEL ,
  272. D.REC_PERS_ID ,
  273. D.REC_PERS ,
  274. D.REC_PERS_TEL ,
  275. TO_CHAR(D.INTM,'YYYY-MM-DD HH24:MI:SS') INTM,
  276. TO_CHAR(D.UPTM,'YYYY-MM-DD HH24:MI:SS') UPTM,
  277. D.NOTE
  278. FROM REL_PERS_INSPGROUP B
  279. LEFT JOIN BIS_INSP_OBJ C ON B.INSP_GROUP_ID=C.INSP_GROUP_ID
  280. RIGHT JOIN BIS_INSP_VILL_RGSTR D ON C.OBJ_ID=D.OBJ_ID
  281. WHERE B.PERS_ID=#{id}
  282. <if test="orgId != null and orgId != ''"> and B.ORG_ID = #{orgId}</if>
  283. </select>
  284. <!--村-->
  285. <select id="getRgstrByAdXCode" resultType="cn.com.goldenwater.dcproj.dto.VillRgstrEngIdDto">
  286. SELECT T1.* FROM
  287. (SELECT A.CODE,A.NM,A.OBJ_ID,B.ENG_ID FROM ATT_AD_X_BASE AD LEFT JOIN
  288. BIS_INSP_ALL_OBJ A ON CONCAT(SUBSTR(AD.AD_CODE,1,6),'000000') = A.CODE LEFT JOIN BIS_INSP_VILL_RGSTR B ON A.OBJ_ID = B.OBJ_ID
  289. WHERE A.PTYPE = '2' AND AD.AD_CODE = #{code}
  290. <if test="orgId != null and orgId != ''">and B.ORG_ID = #{orgId}</if>
  291. ORDER BY B.ENG_ID ASC) T1 WHERE ROWNUM &lt; 2
  292. </select>
  293. <!--农饮工程-->
  294. <select id="getRgstrByCwsCode" resultType="cn.com.goldenwater.dcproj.dto.VillRgstrEngIdDto">
  295. SELECT T1.* FROM
  296. (SELECT A.CODE,A.NM,A.OBJ_ID,B.ENG_ID FROM ATT_cws_BASE AD LEFT JOIN
  297. BIS_INSP_ALL_OBJ A ON CONCAT(SUBSTR(AD.ADDVCD,1,6),'000000') = A.CODE LEFT JOIN BIS_INSP_VILL_RGSTR B ON A.OBJ_ID = B.OBJ_ID
  298. WHERE A.PTYPE = '2'
  299. <if test="orgId != null and orgId != ''"> and A.ORG_ID = #{orgId}</if>
  300. AND AD.CWS_CODE = #{code} ORDER BY B.ENG_ID ASC) T1 WHERE ROWNUM &lt; 2
  301. </select>
  302. </mapper>