BisInspVillRgstrDao.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. DATE_FORMAT(INTM,'%Y-%m-%d %T') INTM,
  33. DATE_FORMAT(UPTM,'%Y-%m-%d %T') 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. DATE_FORMAT(#{intm},'%Y-%m-%d %T') ,
  63. DATE_FORMAT(#{uptm},'%Y-%m-%d %T') ,
  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 = STR_TO_DATE(#{intm},'%Y-%m-%d %T')</if>
  80. <if test="uptm != null and uptm != ''">and UPTM = STR_TO_DATE(#{uptm},'%Y-%m-%d %T')</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" />
  96. from BIS_INSP_VILL_RGSTR
  97. <include refid="page_where" />
  98. ORDER BY UPTM DESC
  99. </select>
  100. <select id="findPageByType" resultType="cn.com.goldenwater.dcproj.dto.BisInspVillRgstrDto" parameterType="cn.com.goldenwater.dcproj.param.TypeParam" >
  101. select * from (select A.*,CASE WHEN b.state IS NULL THEN '0' ELSE b.state END AS wtdstState,B.ENG_ID,B.INTM
  102. FROM BIS_INSP_ALL_OBJ A
  103. LEFT JOIN BIS_INSP_VILL_RGSTR B
  104. ON A.OBJ_ID = B.OBJ_ID
  105. LEFT JOIN BIS_INSP_ALL ia
  106. ON A.id=ia.id
  107. where 1=1
  108. <if test="tabType =='2'.toString()">
  109. and ia.entm &lt; DATE_ADD(STR_TO_DATE(#{nowTime},'%Y-%m-%d'),INTERVAL 1 DAY)
  110. </if>
  111. <if test="tabType =='1'.toString()">
  112. and ia.entm &gt;=STR_TO_DATE(#{nowTime},'%Y-%m-%d')
  113. </if>
  114. <if test="orgId != null and orgId != ''">and A.ORG_ID = #{orgId}</if>
  115. and
  116. A.id in (${inIdsSql})
  117. ) a
  118. where ptype=#{pType}
  119. <if test="plnaId !=null and plnaId !=''">
  120. and a.id like '${plnaId}%'
  121. </if>
  122. <if test="state !=null and state !=''">
  123. and wtdstState =#{state}
  124. </if>
  125. <if test="rsName !=null and rsName !=''">
  126. and a.nm like '%${rsName}%'
  127. </if>
  128. order by wtdstState asc
  129. <if test="orderBy != null and orderBy != ''">
  130. ,CONVERT(nm USING gbk)
  131. </if>
  132. </select>
  133. <select id="findTree" resultType="cn.com.goldenwater.dcproj.dto.BisInspVillRgstrDto" parameterType="cn.com.goldenwater.dcproj.param.TypeParam" >
  134. select *
  135. from (
  136. SELECT
  137. a.id,pid,pnm nm,0 lgtd,0 lttd,'' eng_id,''obj_id,'node'noteType,a.id code
  138. FROM BIS_INSP_ALL A
  139. where
  140. a.id like '002${orgId}%'
  141. <if test=" inIdsSql != null and inIdsSql != '' ">
  142. and A.id in (${inIdsSql})
  143. </if>
  144. union all
  145. select
  146. A.CODE ID,C.ID PID,A.NM NM,A.LTTD,A.LGTD,B.ENG_ID,A.obj_id,'county'noteType,A.ID code
  147. from bis_insp_all_obj A
  148. LEFT JOIN BIS_INSP_VILL_RGSTR B ON A.OBJ_ID=B.OBJ_ID
  149. LEFT JOIN BIS_INSP_ALL C ON A.ID=C.ID
  150. WHERE
  151. A.PTYPE='2'
  152. <if test=" inIdsSql != null and inIdsSql != '' ">
  153. and A.id in (${inIdsSql})
  154. </if>
  155. ) B where 1=1
  156. order by id
  157. </select>
  158. <sql id="choseSql">
  159. <choose>
  160. <when test="province !=null and province !=''">
  161. and B.ad_code=#{province}
  162. </when>
  163. <otherwise>
  164. and B.ad_code is null
  165. </otherwise>
  166. </choose>
  167. </sql>
  168. <select id="selectCount" resultType="int" >
  169. select count(ENG_ID) from BIS_INSP_VILL_RGSTR <include refid="page_where" />
  170. </select>
  171. <!--</select>-->
  172. <select id="sumVillNum" resultType="cn.com.goldenwater.dcproj.model.SumVillNUm" parameterType="String">
  173. select sum(tcNum) as tcNum,sum(proNum) as proNum,sum(surNum) as surNum,sum(waterUserNum) as waterUserNum from (
  174. SELECT max(num) as tcNum,0 as proNum,0 as surNum,0 as waterUserNum
  175. FROM (
  176. SELECT COUNT(B.VILL_ID) num
  177. FROM BIS_INSP_SECSURVEY_VLG B
  178. where B.ENG_ID=#{engId}
  179. UNION
  180. SELECT count(B.RUNSTSE_ID) num
  181. FROM BIS_INSP_VLGDRINK_FAC_OPER B
  182. where B.ENG_ID=#{engId}
  183. UNION
  184. SELECT
  185. COUNT(B.PRSN_WATER_ID) num
  186. FROM BIS_INSP_WATERUSER_INFO B
  187. where B.ENG_ID=#{engId} group by village_code
  188. )
  189. UNION
  190. SELECT 0 as tcNum,count(B.RUN_ID) as proNum,0 as surNum,0 as waterUserNum
  191. FROM BIS_INSP_VLGDRINK_PROJ_MANAGE B
  192. where B.ENG_ID=#{engId}
  193. UNION
  194. SELECT 0 as tcNum,0 as proNum, 0 as surNum, count(B.PRSN_WATER_ID) as waterUserNum
  195. FROM BIS_INSP_WATERUSER_INFO B
  196. where B.ENG_ID=#{engId}
  197. UNION
  198. SELECT
  199. 0 as tcNum,0 as proNum,COUNT(B.ENG_SUR_ID) as surNum,0 as waterUserNum
  200. FROM BIS_INSP_PRO_SOURCE_PROTECT B
  201. where B.ENG_ID=#{engId}
  202. ) w
  203. </select>
  204. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspVillRgstr">
  205. insert into BIS_INSP_VILL_RGSTR( <include refid="table_columns2" /> )
  206. values ( <include refid="entity_properties" /> )
  207. </insert>
  208. <delete id="delete" parameterType="java.lang.String">
  209. delete from BIS_INSP_VILL_RGSTR where ENG_ID = #{id}
  210. </delete>
  211. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspVillRgstr">
  212. delete from BIS_INSP_VILL_RGSTR <include refid="page_where" />
  213. </delete>
  214. <update id="deleteInFlag" parameterType="java.lang.String">
  215. update BIS_INSP_VILL_RGSTR set flag_valid = 0 where ENG_ID = #{id}
  216. </update>
  217. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspVillRgstr">
  218. update BIS_INSP_VILL_RGSTR
  219. <trim prefix="set" suffixOverrides=",">
  220. <if test="dataStat != null and dataStat != ''"> DATA_STAT = #{dataStat},</if>
  221. <if test="state != null and state != ''"> STATE = #{state},</if>
  222. <if test="objId != null and objId != ''"> OBJ_ID = #{objId},</if>
  223. <if test="regsNm != null and regsNm != ''"> REGS_NM = #{regsNm},</if>
  224. <if test="groupLeader != null and groupLeader != ''"> GROUP_LEADER = #{groupLeader},</if>
  225. <if test="groupLeaderTel != null and groupLeaderTel != ''"> GROUP_LEADER_TEL = #{groupLeaderTel},</if>
  226. <if test="recPersId != null and recPersId != ''"> REC_PERS_ID = #{recPersId},</if>
  227. <if test="recPers != null and recPers != ''"> REC_PERS = #{recPers},</if>
  228. <if test="recPersTel != null and recPersTel != ''"> REC_PERS_TEL = #{recPersTel},</if>
  229. <if test="intm != null and intm != ''"> INTM = STR_TO_DATE(#{intm},'%Y-%m-%d %T'),</if>
  230. <if test="uptm != null and uptm != ''"> UPTM = STR_TO_DATE(#{uptm},'%Y-%m-%d %T'),</if>
  231. <if test="note != null and note != ''"> NOTE = #{note},</if>
  232. <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
  233. </trim>
  234. <where>ENG_ID = #{engId}</where>
  235. </update>
  236. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspVillRgstr">
  237. update BIS_INSP_VILL_RGSTR
  238. <trim prefix="set" suffixOverrides=",">
  239. <if test="dataStat != null and dataStat != ''"> DATA_STAT = #{dataStat},</if>
  240. <if test="state != null and state != ''"> STATE = #{state},</if>
  241. <if test="objId != null and objId != ''"> OBJ_ID = #{objId},</if>
  242. <if test="regsNm != null and regsNm != ''"> REGS_NM = #{regsNm},</if>
  243. <if test="groupLeader != null and groupLeader != ''"> GROUP_LEADER = #{groupLeader},</if>
  244. <if test="groupLeaderTel != null and groupLeaderTel != ''"> GROUP_LEADER_TEL = #{groupLeaderTel},</if>
  245. <if test="recPersId != null and recPersId != ''"> REC_PERS_ID = #{recPersId},</if>
  246. <if test="recPers != null and recPers != ''"> REC_PERS = #{recPers},</if>
  247. <if test="recPersTel != null and recPersTel != ''"> REC_PERS_TEL = #{recPersTel},</if>
  248. <if test="intm != null and intm != ''"> INTM = STR_TO_DATE(#{intm},'%Y-%m-%d %T'),</if>
  249. <if test="uptm != null and uptm != ''"> UPTM = STR_TO_DATE(#{uptm},'%Y-%m-%d %T'),</if>
  250. <if test="note != null and note != ''"> NOTE = #{note},</if>
  251. <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
  252. </trim>
  253. <include refid="page_where" />
  254. </update>
  255. <!-- 其他自定义SQL -->
  256. <select id="findListByPersId" resultMap="bisInspVillRgstrResultMap" parameterType="string">
  257. SELECT
  258. D.DATA_STAT ,
  259. D.ENG_ID ,
  260. D.OBJ_ID ,
  261. D.REGS_NM ,
  262. D.GROUP_LEADER ,
  263. D.GROUP_LEADER_TEL ,
  264. D.REC_PERS_ID ,
  265. D.REC_PERS ,
  266. D.REC_PERS_TEL ,
  267. DATE_FORMAT(D.INTM,'%Y-%m-%d %T') INTM,
  268. DATE_FORMAT(D.UPTM,'%Y-%m-%d %T') UPTM,
  269. D.NOTE
  270. FROM REL_PERS_INSPGROUP B
  271. LEFT JOIN BIS_INSP_OBJ C ON B.INSP_GROUP_ID=C.INSP_GROUP_ID
  272. RIGHT JOIN BIS_INSP_VILL_RGSTR D ON C.OBJ_ID=D.OBJ_ID
  273. WHERE B.PERS_ID=#{id}
  274. <if test="orgId != null and orgId != ''"> and B.ORG_ID = #{orgId}</if>
  275. </select>
  276. <!--村-->
  277. <select id="getRgstrByAdXCode" resultType="cn.com.goldenwater.dcproj.dto.VillRgstrEngIdDto">
  278. SELECT T1.* FROM
  279. (SELECT A.CODE,A.NM,A.OBJ_ID,B.ENG_ID FROM ATT_AD_X_BASE AD LEFT JOIN
  280. 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
  281. WHERE A.PTYPE = '2' AND AD.AD_CODE = #{code}
  282. <if test="orgId != null and orgId != ''">and B.ORG_ID = #{orgId}</if>
  283. ORDER BY B.ENG_ID ASC) T1 limit 1
  284. </select>
  285. <!--农饮工程-->
  286. <select id="getRgstrByCwsCode" resultType="cn.com.goldenwater.dcproj.dto.VillRgstrEngIdDto">
  287. SELECT T1.* FROM
  288. (SELECT A.CODE,A.NM,A.OBJ_ID,B.ENG_ID FROM ATT_cws_BASE AD LEFT JOIN
  289. 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
  290. WHERE A.PTYPE = '2'
  291. <if test="orgId != null and orgId != ''"> and A.ORG_ID = #{orgId}</if>
  292. AND AD.CWS_CODE = #{code} ORDER BY B.ENG_ID ASC) T1 limit 1
  293. </select>
  294. </mapper>