BisInspMfdpRgstrDao.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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.BisInspMfdpRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspMfdpRgstr" id="bisInspMfdpRgstrResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="adCode" column="AD_CODE"/>
  8. <result property="adName" column="AD_NAME"/>
  9. <result property="poorCountry" column="POOR_COUNTRY"/>
  10. <result property="inspType" column="INSP_TYPE"/>
  11. <result property="sitroTownNum" column="SITRO_TOWN_NUM"/>
  12. <result property="sitroVlgNum" column="SITRO_VLG_NUM"/>
  13. <result property="sitroRxNum" column="SITRO_RX_NUM"/>
  14. <result property="sitroMsNum" column="SITRO_MS_NUM"/>
  15. <result property="state" column="STATE"/>
  16. <result property="groupLeader" column="GROUP_LEADER"/>
  17. <result property="groupLeaderTel" column="GROUP_LEADER_TEL"/>
  18. <result property="recPersId" column="REC_PERS_ID"/>
  19. <result property="recPers" column="REC_PERS"/>
  20. <result property="recPersTel" column="REC_PERS_TEL"/>
  21. <result property="intm" column="INTM"/>
  22. <result property="uptm" column="UPTM"/>
  23. <result property="note" column="NOTE"/>
  24. </resultMap>
  25. <sql id="table_columns">
  26. ID,
  27. OBJ_ID,
  28. AD_CODE,
  29. AD_NAME,
  30. POOR_COUNTRY,
  31. INSP_TYPE,
  32. SITRO_TOWN_NUM,
  33. SITRO_VLG_NUM,
  34. SITRO_RX_NUM,
  35. SITRO_MS_NUM,
  36. STATE,
  37. GROUP_LEADER,
  38. GROUP_LEADER_TEL,
  39. REC_PERS_ID,
  40. REC_PERS,
  41. REC_PERS_TEL,
  42. INTM,
  43. UPTM,
  44. NOTE
  45. </sql>
  46. <sql id="entity_properties">
  47. #{id},
  48. #{objId},
  49. #{adCode},
  50. #{adName},
  51. #{poorCountry},
  52. #{inspType},
  53. #{sitroTownNum},
  54. #{sitroVlgNum},
  55. #{sitroRxNum},
  56. #{sitroMsNum},
  57. #{state},
  58. #{groupLeader},
  59. #{groupLeaderTel},
  60. #{recPersId},
  61. #{recPers},
  62. #{recPersTel},
  63. #{intm},
  64. #{uptm},
  65. #{note}
  66. </sql>
  67. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  68. <sql id="page_where">
  69. <trim prefix="where" prefixOverrides="and | or ">
  70. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  71. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  72. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  73. <if test="poorCountry != null and poorCountry != ''">and POOR_COUNTRY = #{poorCountry}</if>
  74. <if test="inspType != null and inspType != ''">and INSP_TYPE = #{inspType}</if>
  75. <if test="sitroTownNum != null and sitroTownNum != ''">and SITRO_TOWN_NUM = #{sitroTownNum}</if>
  76. <if test="sitroVlgNum != null and sitroVlgNum != ''">and SITRO_VLG_NUM = #{sitroVlgNum}</if>
  77. <if test="sitroRxNum != null and sitroRxNum != ''">and SITRO_RX_NUM = #{sitroRxNum}</if>
  78. <if test="sitroMsNum != null and sitroMsNum != ''">and SITRO_MS_NUM = #{sitroMsNum}</if>
  79. <if test="state != null and state != ''">and STATE = #{state}</if>
  80. <if test="groupLeader != null and groupLeader != ''">and GROUP_LEADER = #{groupLeader}</if>
  81. <if test="groupLeaderTel != null and groupLeaderTel != ''">and GROUP_LEADER_TEL = #{groupLeaderTel}</if>
  82. <if test="recPersId != null and recPersId != ''">and REC_PERS_ID = #{recPersId}</if>
  83. <if test="recPers != null and recPers != ''">and REC_PERS = #{recPers}</if>
  84. <if test="recPersTel != null and recPersTel != ''">and REC_PERS_TEL = #{recPersTel}</if>
  85. <if test="intm != null">and INTM = #{intm}</if>
  86. <if test="uptm != null">and UPTM = #{uptm}</if>
  87. <if test="note != null and note != ''">and NOTE = #{note}</if>
  88. </trim>
  89. </sql>
  90. <select id="get" resultMap="bisInspMfdpRgstrResultMap" parameterType="String">
  91. select
  92. <include refid="table_columns"/>
  93. from BIS_INSP_MFDP_RGSTR where ID = #{id}
  94. </select>
  95. <select id="getBy" resultMap="bisInspMfdpRgstrResultMap">
  96. select
  97. <include refid="table_columns"/>
  98. from BIS_INSP_MFDP_RGSTR
  99. <include refid="page_where"/>
  100. </select>
  101. <select id="findAll" resultMap="bisInspMfdpRgstrResultMap">
  102. select
  103. <include refid="table_columns"/>
  104. from BIS_INSP_MFDP_RGSTR
  105. </select>
  106. <select id="findList" resultMap="bisInspMfdpRgstrResultMap">
  107. select
  108. <include refid="table_columns"/>
  109. from BIS_INSP_MFDP_RGSTR
  110. <include refid="page_where"/>
  111. </select>
  112. <select id="selectCount" resultType="int">
  113. select count(ID) from BIS_INSP_MFDP_RGSTR
  114. <include refid="page_where"/>
  115. </select>
  116. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspMfdpRgstr">
  117. insert into BIS_INSP_MFDP_RGSTR(
  118. <include refid="table_columns"/>
  119. )
  120. values (
  121. <include refid="entity_properties"/>
  122. )
  123. </insert>
  124. <delete id="delete" parameterType="java.lang.String">
  125. delete from BIS_INSP_MFDP_RGSTR where ID = #{id}
  126. </delete>
  127. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspMfdpRgstr">
  128. delete from BIS_INSP_MFDP_RGSTR
  129. <include refid="page_where"/>
  130. </delete>
  131. <update id="deleteInFlag" parameterType="java.lang.String">
  132. update BIS_INSP_MFDP_RGSTR set flag_valid = 0 where ID = #{id}
  133. </update>
  134. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspMfdpRgstr">
  135. update BIS_INSP_MFDP_RGSTR
  136. <trim prefix="set" suffixOverrides=",">
  137. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  138. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  139. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  140. <if test="poorCountry != null and poorCountry != ''">POOR_COUNTRY = #{poorCountry},</if>
  141. <if test="inspType != null and inspType != ''">INSP_TYPE = #{inspType},</if>
  142. <if test="sitroTownNum != null and sitroTownNum != ''">SITRO_TOWN_NUM = #{sitroTownNum},</if>
  143. <if test="sitroVlgNum != null and sitroVlgNum != ''">SITRO_VLG_NUM = #{sitroVlgNum},</if>
  144. <if test="sitroRxNum != null and sitroRxNum != ''">SITRO_RX_NUM = #{sitroRxNum},</if>
  145. <if test="sitroMsNum != null and sitroMsNum != ''">SITRO_MS_NUM = #{sitroMsNum},</if>
  146. <if test="state != null and state != ''">STATE = #{state},</if>
  147. <if test="groupLeader != null and groupLeader != ''">GROUP_LEADER = #{groupLeader},</if>
  148. <if test="groupLeaderTel != null and groupLeaderTel != ''">GROUP_LEADER_TEL = #{groupLeaderTel},</if>
  149. <if test="recPersId != null and recPersId != ''">REC_PERS_ID = #{recPersId},</if>
  150. <if test="recPers != null and recPers != ''">REC_PERS = #{recPers},</if>
  151. <if test="recPersTel != null and recPersTel != ''">REC_PERS_TEL = #{recPersTel},</if>
  152. <if test="intm != null">INTM = #{intm},</if>
  153. <if test="uptm != null">UPTM = #{uptm},</if>
  154. <if test="note != null and note != ''">NOTE = #{note},</if>
  155. </trim>
  156. <where>ID = #{id}</where>
  157. </update>
  158. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspMfdpRgstr">
  159. update BIS_INSP_MFDP_RGSTR
  160. <trim prefix="set" suffixOverrides=",">
  161. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  162. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  163. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  164. <if test="poorCountry != null and poorCountry != ''">POOR_COUNTRY = #{poorCountry},</if>
  165. <if test="inspType != null and inspType != ''">INSP_TYPE = #{inspType},</if>
  166. <if test="sitroTownNum != null and sitroTownNum != ''">SITRO_TOWN_NUM = #{sitroTownNum},</if>
  167. <if test="sitroVlgNum != null and sitroVlgNum != ''">SITRO_VLG_NUM = #{sitroVlgNum},</if>
  168. <if test="sitroRxNum != null and sitroRxNum != ''">SITRO_RX_NUM = #{sitroRxNum},</if>
  169. <if test="sitroMsNum != null and sitroMsNum != ''">SITRO_MS_NUM = #{sitroMsNum},</if>
  170. <if test="state != null and state != ''">STATE = #{state},</if>
  171. <if test="groupLeader != null and groupLeader != ''">GROUP_LEADER = #{groupLeader},</if>
  172. <if test="groupLeaderTel != null and groupLeaderTel != ''">GROUP_LEADER_TEL = #{groupLeaderTel},</if>
  173. <if test="recPersId != null and recPersId != ''">REC_PERS_ID = #{recPersId},</if>
  174. <if test="recPers != null and recPers != ''">REC_PERS = #{recPers},</if>
  175. <if test="recPersTel != null and recPersTel != ''">REC_PERS_TEL = #{recPersTel},</if>
  176. <if test="intm != null">INTM = #{intm},</if>
  177. <if test="uptm != null">UPTM = #{uptm},</if>
  178. <if test="note != null and note != ''">NOTE = #{note},</if>
  179. </trim>
  180. <include refid="page_where"/>
  181. </update>
  182. <!-- 其他自定义SQL -->
  183. <select id="findMfdpList" parameterType="cn.com.goldenwater.dcproj.param.TypeParam"
  184. resultType="cn.com.goldenwater.dcproj.dto.BisInspRgstrDto">
  185. SELECT * FROM (
  186. SELECT
  187. A.CODE, A.ID nodeId, A.NM, A.PTYPE pType, A.OBJ_ID,B.ID ID,b.id as rgstrId,
  188. b.SITRO_TOWN_NUM, b.SITRO_VLG_NUM, b.SITRO_RX_NUM, b.SITRO_MS_NUM, B.INTM,
  189. b.ad_code,(case when b.State is null then '0' else b.state end)STATE,
  190. C.LGTDPC pc_x, c.LTTDPC pc_y, C.LGTD GD_X, C.LTTD GD_y,
  191. c.ad_full_name as adName, ia.pnm groupName
  192. FROM BIS_INSP_ALL_OBJ A
  193. LEFT JOIN BIS_INSP_MFDP_RGSTR B ON A.OBJ_ID=B.OBJ_ID
  194. LEFT JOIN ATT_AD_X_BASE C ON B.AD_CODE=C.AD_CODE
  195. LEFT JOIN BIS_INSP_ALL IA ON A.ID = IA.ID
  196. <where>
  197. <if test="pType != null and pType != '' ">
  198. A.PTYPE= #{pType}
  199. </if>
  200. <if test="tabType =='2'.toString()">
  201. and ia.entm &lt; DATE_FORMAT(#{nowTime},'%Y-%m-%d')
  202. </if>
  203. <if test="tabType =='1'.toString()">
  204. and ia.entm &gt;= DATE_FORMAT(#{nowTime},'%Y-%m-%d')
  205. </if>
  206. <if test="adCodes ==null or adCodes =='' ">
  207. <if test="inIdsSql != null and inIdsSql !=''">
  208. and A.id in (${inIdsSql})
  209. </if>
  210. </if>
  211. <if test="poorCountry != null and poorCountry != ''">
  212. and (case when b.POOR_COUNTRY is null then c.IS_REPORT else b.POOR_COUNTRY end ) = #{poorCountry}
  213. </if>
  214. <if test="adCode != null and adCode != ''">
  215. and b.ad_code like '${adCode}%'
  216. </if>
  217. <choose>
  218. <when test="province !=null and province !=''">
  219. and A.AD_CODE like '${province}%'
  220. </when>
  221. <otherwise>
  222. and A.AD_CODE is null
  223. </otherwise>
  224. </choose>
  225. </where>
  226. ) A
  227. <where>
  228. <if test="plnaId !=null and plnaId !=''">
  229. and a.nodeId like '${plnaId}%'
  230. </if>
  231. <if test="state !=null and state !=''">
  232. and STATE in (${state})
  233. </if>
  234. <if test="rsName !=null and rsName !=''">
  235. and a.nm like '%${rsName}%'
  236. </if>
  237. <if test="code !=null and code !=''">
  238. and a.code = #{code}
  239. </if>
  240. <if test="adName != null and adName != ''">and a.adName like '%${adName}%'</if>
  241. <if test="sttm != null and sttm != ''">and a.IN_TM&gt;= DATE_FORMAT(#{sttm},'%Y-%m-%d')</if>
  242. <if test="entm != null and entm != ''">and a.IN_TM &lt; DATE_FORMAT(#{entm},'%Y-%m-%d')</if>
  243. <if test="groupId != null and groupId != ''">and a.nodeId = #{groupId}</if>
  244. <if test="adCodes !=null and adCodes !=''">
  245. and
  246. <foreach item="item" index="index" collection="adCodes.split(',')" open="(" separator="or" close=")">
  247. ad_code like concat('${item}','%')
  248. </foreach>
  249. </if>
  250. </where>
  251. order by nodeId asc
  252. <if test="orderBy != null and orderBy != ''">
  253. ,CONVERT(nm using GBK)
  254. </if>
  255. </select>
  256. <select id="findPblmList" resultType="cn.com.goldenwater.dcproj.model.BisInspPblm"
  257. parameterType="cn.com.goldenwater.dcproj.param.PlbmParam">
  258. select w.* from (
  259. select j.id as oid,j.obj_id,m.pblm_id,m.obj_type,m.insp_pblm_name
  260. ,m.insp_pblm_desc,m.pblm_long,m.pblm_lat,s.check_point,m.INSP_PBLM_CATE,
  261. m.new_vill_name,j.nm,m.vill_type,m.has_vedio,m.quote,m.rec_pers,
  262. m.regid,j.code as ad_code,ba.ad_full_name,s.sn_num,p.pers_name,al.sttm,al.entm,
  263. 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,
  264. (select org_nm from bis_insp_org where org_id=substr(al.id,4,3)) as org_nm
  265. from (select m.* from BIS_INSP_PBLM m where m.obj_type='27'
  266. ) m
  267. join (select * from BIS_INSP_ALL_OBJ j where j.pType='27') j on m.obj_id=j.obj_id
  268. join obj_insp_pblms s on m.pblms_type_id=s.guid
  269. left join bis_insp_all al on al.id=j.id
  270. left join bis_insp_all_rlation_pers p on m.rec_pers=p.guid
  271. left join att_ad_x_base ba on j.code=ba.ad_code
  272. ) w
  273. where 1=1
  274. <if test="tabType =='2'.toString()">
  275. and w.entm &lt;DATE_FORMAT(#{nowTime},'%Y-%m-%d')
  276. </if>
  277. <if test="tabType =='1'.toString()">
  278. and w.entm &gt;=DATE_FORMAT(#{nowTime},'%Y-%m-%d')
  279. </if>
  280. and
  281. w.oid in (${inIdsSql})
  282. <if test="inspPblmName !=null and inspPblmName !=''">
  283. and w.insp_pblm_name in (${inspPblmName})
  284. </if>
  285. <if test="checkPoint !=null and checkPoint !=''">
  286. and w.check_point in (${checkPoint})
  287. </if>
  288. <if test="inspPblmCate !=null and inspPblmCate !=''">
  289. and w.INSP_PBLM_CATE in (${inspPblmCate})
  290. </if>
  291. <if test="pblmName != null and pblmName != ''">
  292. and INSP_PBLM_NAME like concat(concat('%',#{pblmName}),'%')
  293. </if>
  294. <if test="startTime != null and startTime != ''">and COLL_TIME &gt;= DATE_FORMAT(#{startTime},'%Y-%m-%d')</if>
  295. <if test="findTime != null and findTime != ''">and COLL_TIME=DATE_FORMAT(#{findTime},'%Y-%m-%d')</if>
  296. <if test="endTime != null and endTime != ''">and COLL_TIME &lt; DATE_FORMAT(#{endTime},'%Y-%m-%d')</if>
  297. <if test="oides != null and oides != ''">and oid in (${oides})</if>
  298. <if test="regid !=null and regid !=''">
  299. and w.regid=#{regid}
  300. </if>
  301. <if test="recPers !=null and recPers !=''">
  302. and w.rec_Pers=#{recPers}
  303. </if>
  304. <if test="objId !=null and objId !=''">
  305. and w.obj_id=#{objId}
  306. </if>
  307. <if test="groupId !=null and groupId !=''">
  308. and oid like '${groupId}%'
  309. </if>
  310. <if test="adFullName !=null and adFullName !=''">
  311. and w.AD_FULL_NAMe like '%${adFullName}%'
  312. </if>
  313. <if test="persName !=null and persName !=''">
  314. and w.PERS_NAME like '%${persName}%'
  315. </if>
  316. <if test="nm !=null and nm !=''">
  317. and w.NM like '%${nm}%'
  318. </if>
  319. <if test="orgNm !=null and orgNm !=''">
  320. and w.ORG_NM like '%${orgNm}%'
  321. </if>
  322. <if test="hasVedio !=null and hasVedio !=''">
  323. and w.HAS_VEDIO=#{hasVedio}
  324. </if>
  325. <if test="adCode !=null and adCode !=''">
  326. and w.AD_CODE like '${adCode}%'
  327. </if>
  328. order by w.AD_CODE
  329. <if test="orderBy !=null and orderBy !=''">
  330. ,${orderBy}
  331. </if>
  332. </select>
  333. </mapper>