BisZhejiangVillRgstrDao.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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.BisZhejiangVillRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisZhejiangVillRgstr" id="bisZhejiangVillRgstrResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="regsNm" column="REGS_NM"/>
  8. <result property="waterSafeOrPay" column="WATER_SAFE_OR_PAY"/>
  9. <result property="adCode" column="AD_CODE"/>
  10. <result property="persId" column="PERS_ID"/>
  11. <result property="intm" column="INTM"/>
  12. <result property="uptm" column="UPTM"/>
  13. <result property="note" column="NOTE"/>
  14. <result property="dataStat" column="DATA_STAT"/>
  15. <result property="state" column="STATE"/>
  16. <result property="adFullName" column="AD_FULL_NAME"/>
  17. <result property="isPkx" column="IS_PKX"/>
  18. <result property="isFoOver" column="IS_FO_OVER"/>
  19. <result property="villNum" column="VILL_NUM"/>
  20. <result property="proNum" column="PRO_NUM"/>
  21. <result property="lgtd" column="LGTD"/>
  22. <result property="lttd" column="LTTD"/>
  23. <result property="lgtdpc" column="LGTDPC"/>
  24. <result property="lttdpc" column="LTTDPC"/>
  25. </resultMap>
  26. <sql id="table_columns">
  27. ID,
  28. LGTD ,
  29. LTTD ,
  30. LGTDPC ,
  31. LTTDPC ,
  32. OBJ_ID,
  33. REGS_NM,
  34. WATER_SAFE_OR_PAY,
  35. AD_CODE,
  36. PERS_ID,
  37. INTM,
  38. UPTM,
  39. NOTE,
  40. DATA_STAT,
  41. STATE,
  42. AD_FULL_NAME,
  43. IS_PKX,
  44. IS_FO_OVER,
  45. VILL_NUM,
  46. PRO_NUM
  47. </sql>
  48. <sql id="entity_properties">
  49. #{id},
  50. #{lgtd},
  51. #{lttd},
  52. #{lgtdpc},
  53. #{lttdpc},
  54. #{objId},
  55. #{regsNm},
  56. #{waterSafeOrPay},
  57. #{adCode},
  58. #{persId},
  59. #{intm},
  60. #{uptm},
  61. #{note},
  62. #{dataStat},
  63. #{state},
  64. #{adFullName},
  65. #{isPkx},
  66. #{isFoOver},
  67. #{villNum},
  68. #{proNum}
  69. </sql>
  70. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  71. <sql id="page_where">
  72. <trim prefix="where" prefixOverrides="and | or ">
  73. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  74. <if test="regsNm != null and regsNm != ''">and REGS_NM = #{regsNm}</if>
  75. <if test="waterSafeOrPay != null and waterSafeOrPay != ''">and WATER_SAFE_OR_PAY = #{waterSafeOrPay}</if>
  76. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  77. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  78. <if test="intm != null">and INTM = #{intm}</if>
  79. <if test="uptm != null">and UPTM = #{uptm}</if>
  80. <if test="note != null and note != ''">and NOTE = #{note}</if>
  81. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  82. <if test="state != null and state != ''">and STATE = #{state}</if>
  83. <if test="adFullName != null and adFullName != ''">and AD_FULL_NAME = #{adFullName}</if>
  84. <if test="isPkx != null and isPkx != ''">and IS_PKX = #{isPkx}</if>
  85. <if test="isFoOver != null and isFoOver != ''">and IS_FO_OVER = #{isFoOver}</if>
  86. <if test="villNum != null and villNum != ''">and VILL_NUM = #{villNum}</if>
  87. <if test="proNum != null and proNum != ''">and PRO_NUM = #{proNum}</if>
  88. </trim>
  89. </sql>
  90. <select id="get" resultMap="bisZhejiangVillRgstrResultMap" parameterType="String" >
  91. select <include refid="table_columns" /> from BIS_ZHEJIANG_VILL_RGSTR where ID = #{id}
  92. </select>
  93. <select id="getBy" resultMap="bisZhejiangVillRgstrResultMap">
  94. select <include refid="table_columns" /> from BIS_ZHEJIANG_VILL_RGSTR <include refid="page_where" />
  95. </select>
  96. <select id="findAll" resultMap="bisZhejiangVillRgstrResultMap">
  97. select <include refid="table_columns" /> from BIS_ZHEJIANG_VILL_RGSTR
  98. </select>
  99. <select id="findList" resultMap="bisZhejiangVillRgstrResultMap">
  100. select <include refid="table_columns" /> from BIS_ZHEJIANG_VILL_RGSTR <include refid="page_where" />
  101. </select>
  102. <select id="selectCount" resultType="int" >
  103. select count(ID) from BIS_ZHEJIANG_VILL_RGSTR <include refid="page_where" />
  104. </select>
  105. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisZhejiangVillRgstr">
  106. insert into BIS_ZHEJIANG_VILL_RGSTR( <include refid="table_columns" /> )
  107. values ( <include refid="entity_properties" /> )
  108. </insert>
  109. <delete id="delete" parameterType="java.lang.String">
  110. delete from BIS_ZHEJIANG_VILL_RGSTR where ID = #{id}
  111. </delete>
  112. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisZhejiangVillRgstr">
  113. delete from BIS_ZHEJIANG_VILL_RGSTR <include refid="page_where" />
  114. </delete>
  115. <update id="deleteInFlag" parameterType="java.lang.String">
  116. update BIS_ZHEJIANG_VILL_RGSTR set flag_valid = 0 where ID = #{id}
  117. </update>
  118. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisZhejiangVillRgstr">
  119. update BIS_ZHEJIANG_VILL_RGSTR
  120. <trim prefix="set" suffixOverrides=",">
  121. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  122. <if test="regsNm != null and regsNm != ''">REGS_NM = #{regsNm},</if>
  123. <if test="waterSafeOrPay != null and waterSafeOrPay != ''">WATER_SAFE_OR_PAY = #{waterSafeOrPay},</if>
  124. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  125. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  126. <if test="intm != null">INTM = #{intm},</if>
  127. <if test="uptm != null">UPTM = #{uptm},</if>
  128. <if test="note != null and note != ''">NOTE = #{note},</if>
  129. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  130. <if test="state != null and state != ''">STATE = #{state},</if>
  131. <if test="adFullName != null and adFullName != ''">AD_FULL_NAME = #{adFullName},</if>
  132. <if test="isPkx != null and isPkx != ''">IS_PKX = #{isPkx},</if>
  133. <if test="isFoOver != null and isFoOver != ''">IS_FO_OVER = #{isFoOver},</if>
  134. <if test="villNum != null and villNum != ''">VILL_NUM = #{villNum},</if>
  135. <if test="proNum != null and proNum != ''">PRO_NUM = #{proNum},</if>
  136. <if test="lgtd != null and lgtd != ''">LGTD = #{lgtd},</if>
  137. <if test="lttd != null and lttd != ''">LTTD = #{lttd},</if>
  138. <if test="lgtdpc != null and lgtdpc != ''">LGTDPC = #{lgtdpc},</if>
  139. <if test="lttdpc != null and lttdpc != ''">LTTDPC = #{lttdpc},</if>
  140. </trim>
  141. <where>ID = #{id}</where>
  142. </update>
  143. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisZhejiangVillRgstr">
  144. update BIS_ZHEJIANG_VILL_RGSTR
  145. <trim prefix="set" suffixOverrides=",">
  146. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  147. <if test="regsNm != null and regsNm != ''">REGS_NM = #{regsNm},</if>
  148. <if test="waterSafeOrPay != null and waterSafeOrPay != ''">WATER_SAFE_OR_PAY = #{waterSafeOrPay},</if>
  149. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  150. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  151. <if test="intm != null">INTM = #{intm},</if>
  152. <if test="uptm != null">UPTM = #{uptm},</if>
  153. <if test="note != null and note != ''">NOTE = #{note},</if>
  154. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  155. <if test="state != null and state != ''">STATE = #{state},</if>
  156. <if test="adFullName != null and adFullName != ''">AD_FULL_NAME = #{adFullName},</if>
  157. <if test="isPkx != null and isPkx != ''">IS_PKX = #{isPkx},</if>
  158. <if test="isFoOver != null and isFoOver != ''">IS_FO_OVER = #{isFoOver},</if>
  159. <if test="villNum != null and villNum != ''">VILL_NUM = #{villNum},</if>
  160. <if test="proNum != null and proNum != ''">PRO_NUM = #{proNum},</if>
  161. <if test="lgtd != null and lgtd != ''">LGTD = #{lgtd},</if>
  162. <if test="lttd != null and lttd != ''">LTTD = #{lttd},</if>
  163. <if test="lgtdpc != null and lgtdpc != ''">LGTDPC = #{lgtdpc},</if>
  164. <if test="lttdpc != null and lttdpc != ''">LTTDPC = #{lttdpc},</if>
  165. </trim>
  166. <include refid="page_where" />
  167. </update>
  168. <!-- 其他自定义SQL -->
  169. <update id="updateVillSum" parameterType="cn.com.goldenwater.dcproj.model.BisZhejiangVillRgstr" >
  170. update BIS_ZHEJIANG_VILL_RGSTR set VILL_NUM = #{villNum} where ID = #{id}
  171. </update>
  172. <update id="updateProSum" parameterType="cn.com.goldenwater.dcproj.model.BisZhejiangVillRgstr" >
  173. update BIS_ZHEJIANG_VILL_RGSTR set PRO_NUM = #{proNum} where ID = #{id}
  174. </update>
  175. <update id="updateAllNum" parameterType="cn.com.goldenwater.dcproj.model.BisZhejiangVillRgstr">
  176. update BIS_ZHEJIANG_VILL_RGSTR set PRO_NUM = #{proNum},VILL_NUM = #{villNum} where ID = #{id}
  177. </update>
  178. <select id="pageNotAddRegstr" resultType="cn.com.goldenwater.dcproj.dto.AttCountryDto"
  179. parameterType="cn.com.goldenwater.dcproj.param.CommonParam">
  180. select e.ad_code,e.ad_name,(case when e.is_poveryt is null then '0' else e.is_poveryt end) is_poveryt,e.lgtd,e.lttd,
  181. (case when o.obj_id is null then '0' else '1' end) status,o.obj_id,o.id from att_ad_x_base e
  182. left join bis_insp_all_obj o on e.ad_code=o.code
  183. where o.ptype=#{objType}
  184. <if test="objId !=null and objId !=''">
  185. and o.obj_id=#{objId}
  186. </if>
  187. <if test="name !=null and name !=''">
  188. and e.ad_name like '%${name}%'
  189. </if>
  190. <if test="adCode !=null and adCode !=''">
  191. and e.ad_code like '%${adCode}%'
  192. </if>
  193. <if test="isPoveryt !=null and isPoveryt !=''">
  194. and e.is_poveryt =#{isPoveryt}
  195. </if>
  196. <if test="orderBy !=null and orderBy !=''">
  197. order by ${orderBy}
  198. </if>
  199. </select>
  200. <select id="findNewVillPageByType" parameterType="cn.com.goldenwater.dcproj.param.TypeParam" resultType="cn.com.goldenwater.dcproj.dto.BisNewVillRgstrDto">
  201. select * from (select A.*,CASE WHEN b.state IS NULL THEN '0' ELSE b.state END AS wtdstState,B.Id as regstr_id,B.Id as rgstr_id,B.INTM,(
  202. case WHEN B.is_pkx is null THEN '0' else B.is_pkx END ) as is_pkx,
  203. B.WATER_SAFE_OR_PAY,B.vill_num,B.pro_num
  204. FROM BIS_INSP_ALL_OBJ A
  205. LEFT JOIN BIS_Zhejiang_VILL_RGSTR B
  206. ON A.OBJ_ID = B.OBJ_ID
  207. where A.ptype=#{pType} AND
  208. A.AD_CODE=#{province} AND
  209. A.id in (${inIdsSql})
  210. ) a
  211. where 1=1
  212. <if test="adCode !=null and adCode !=''">
  213. and a.code like '${adCode}%'
  214. </if>
  215. <if test="sttm != null and sttm != '' and entm != null and entm != ''">
  216. AND INTM &gt;= str_to_date(#{sttm},'%Y-%m-%d') AND INTM &lt; str_to_date(#{entm},'%Y-%m-%d')
  217. </if>
  218. <if test="plnaId !=null and plnaId !=''">
  219. and a.id like '${plnaId}%'
  220. </if>
  221. <if test="groupId !=null and groupId !=''">
  222. and a.id like '${groupId}%'
  223. </if>
  224. <if test="state !=null and state !=''">
  225. and wtdstState in (${state})
  226. </if>
  227. <if test="rsName !=null and rsName !=''">
  228. and a.nm like '%${rsName}%'
  229. </if>
  230. order by wtdstState asc
  231. <if test="orderBy != null and orderBy != ''">
  232. ,${orderBy}
  233. </if>
  234. </select>
  235. <!-- 其他自定义SQL -->
  236. <select id="sumNewVillNumAdd" resultType="cn.com.goldenwater.dcproj.dto.SumNewVillNumDto" parameterType="String">
  237. select sum(vill_num) as vill_num,sum(pro_num) as pro_num from (
  238. SELECT COUNT(B.ad_code) vill_num,0 as pro_num,0 as water_num
  239. FROM BIS_ZHEJIANG_DCUSER_REL_VILL B
  240. where B.RGSTR_ID =#{rgstrId}
  241. UNION all
  242. SELECT 0 as vill_num,count(B.id) pro_num,0 as water_num
  243. FROM BIS_ZHEJIANG_COUNTRY_FEE B
  244. where B.RGSTR_ID=#{rgstrId}
  245. ) w
  246. </select>
  247. <select id="findPageList" resultType="cn.com.goldenwater.dcproj.model.BisInspPblm" parameterType="cn.com.goldenwater.dcproj.param.PlbmParam">
  248. select w.* from (
  249. select j.id as oid,j.obj_id,m.pblm_id,m.obj_type,m.insp_pblm_name ,m.insp_pblm_desc,m.pblm_long,m.pblm_lat,s.check_point,
  250. m.new_vill_name,j.nm,m.vill_type,m.has_vedio,m.quote,m.rec_pers,
  251. m.regid,j.code as ad_code,ba.ad_full_name,s.sn_num,p.pers_name,m.WATER_USER_ID,
  252. m.insp_add_desc,m.coll_time,(select l.pnm from bis_insp_all l where l.id=substr(al.id,0,6)) as pnm,
  253. (select org_nm from bis_insp_org where org_id=substr(al.id,4,3)) as org_nm,
  254. m.PBLM_REASON as pblmReason,m.PBLM_SGGTN as pblmSggtn
  255. from (select m.* from BIS_INSP_PBLM m where m.obj_type='41'
  256. ) m
  257. join (select * from BIS_INSP_ALL_OBJ j where j.pType='41' and j.ad_code=#{province}) j on m.obj_id=j.obj_id
  258. join obj_insp_pblms s on m.pblms_type_id=s.guid
  259. left join bis_insp_all al on al.id=j.id
  260. left join bis_insp_all_rlation_pers p on m.rec_pers=p.guid
  261. left join att_ad_x_base ba on j.code=ba.ad_code
  262. ) w
  263. where 1=1 and
  264. W.OID in (${inIdsSql})
  265. <if test="villType !=null and villType !=''">
  266. and w.vill_type in (${villType})
  267. </if>
  268. <if test="objIdes != null and objIdes != ''">and OBJ_ID in (${objIdes})</if>
  269. <if test="inspPblmName !=null and inspPblmName !=''">
  270. and w.insp_pblm_name like '${inspPblmName}%'
  271. </if>
  272. <if test="startTime != null and startTime != ''">and COLL_TIME &gt;= str_to_date(#{startTime},'%Y-%m-%d')</if>
  273. <if test="findTime != null and findTime != ''">and COLL_TIME=str_to_date(#{findTime},'%Y-%m-%d')</if>
  274. <if test="endTime != null and endTime != ''">and COLL_TIME &lt; str_to_date(#{endTime},'%Y-%m-%d')</if>
  275. <if test="oides != null and oides != ''">and oid in (${oides})</if>
  276. <if test="regid !=null and regid !=''">
  277. and w.regid=#{regid}
  278. </if>
  279. <if test="objId !=null and objId !=''">
  280. and w.obj_id=#{objId}
  281. </if>
  282. <if test="groupId !=null and groupId !=''">
  283. and oid like '${groupId}%'
  284. </if>
  285. <if test="adFullName !=null and adFullName !=''">
  286. and w.AD_FULL_NAMe like '%${adFullName}%'
  287. </if>
  288. <if test="persName !=null and persName !=''">
  289. and w.PERS_NAME like '%${persName}%'
  290. </if>
  291. <if test="nm !=null and nm !=''">
  292. and w.NM like '%${nm}%'
  293. </if>
  294. <if test="orgNm !=null and orgNm !=''">
  295. and w.ORG_NM like '%${orgNm}%'
  296. </if>
  297. <if test="hasVedio !=null and hasVedio !=''">
  298. and w.HAS_VEDIO=#{hasVedio}
  299. </if>
  300. <if test="adCode !=null and adCode !=''">
  301. and w.WATER_USER_ID like '${adCode}%'
  302. </if>
  303. order by w.WATER_USER_ID
  304. <if test="orderBy !=null and orderBy !=''">
  305. ,${orderBy}
  306. </if>
  307. </select>
  308. <select id="findPageByType" resultType="cn.com.goldenwater.dcproj.dto.BisNewVillRgstrDto"
  309. parameterType="cn.com.goldenwater.dcproj.param.TypeParam">
  310. select * from (select A.id,A.Nm,A.Code,A.Obj_Id,A.Lgtd,A.Lttd,A.Lgtdpc,A.Lttdpc,
  311. A.pType,CASE WHEN b.state IS NULL THEN '0' ELSE b.state
  312. END AS wtdstState,B.Id as rgstr_id,ad.ad_full_name,al.pnm as groupName
  313. ,date_format(b.intm,'%Y-%m-%d %H:%i:%S') as intm,
  314. date_format(b.uptm,'%Y-%m-%d %H:%i:%S') as uptm,B.WATER_SAFE_OR_PAY
  315. FROM BIS_INSP_ALL_OBJ A
  316. LEFT JOIN BIS_Zhejiang_VILL_RGSTR B
  317. ON A.OBJ_ID = B.OBJ_ID
  318. left join ATT_AD_X_BASE ad on b.ad_code = ad.ad_code
  319. left join BIS_INSP_ALL al
  320. on A.id=al.id
  321. where A.ad_code=#{province} and
  322. A.OID in (${inIdsSql})
  323. ) a
  324. where ptype=#{pType}
  325. <if test="plnaId !=null and plnaId !=''">
  326. and a.id like '${plnaId}%'
  327. </if>
  328. <if test="state !=null and state !=''">
  329. and wtdstState in (${state})
  330. </if>
  331. <if test="sttm != null and sttm != '' and entm != null and entm != ''">
  332. AND INTM &gt;= str_to_date(#{sttm},'%Y-%m-%d') AND INTM &lt; str_to_date(#{entm},'%Y-%m-%d')
  333. </if>
  334. <if test="groupId !=null and groupId !=''">
  335. and a.id like '${groupId}%'
  336. </if>
  337. <if test="name !=null and name !=''">
  338. and a.nm like '%${name}%'
  339. </if>
  340. <if test="nm !=null and nm !=''">
  341. and a.nm like '%${nm}%'
  342. </if>
  343. <if test="adName !=null and adName !=''">
  344. and a.ad_full_name like '%${adName}%'
  345. </if>
  346. <if test="rsName !=null and rsName !=''">
  347. and a.nm like '%${rsName}%'
  348. </if>
  349. order by wtdstState asc
  350. <if test="orderBy != null and orderBy != ''">
  351. <!--,${orderBy}-->
  352. ,CONVERT( nm USING gbk ) COLLATE gbk_chinese_ci ASC
  353. </if>
  354. </select>
  355. </mapper>