BisInspWintRgstrDao.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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.BisInspWintRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspWintRgstr" id="bisInspWintRgstrResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="province" column="PROVINCE"/>
  8. <result property="adName" column="AD_NAME"/>
  9. <result property="adCode" column="AD_CODE"/>
  10. <result property="loc" column="LOC"/>
  11. <result property="pcX" column="PC_X"/>
  12. <result property="pcY" column="PC_Y"/>
  13. <result property="gdX" column="GD_X"/>
  14. <result property="gdY" column="GD_Y"/>
  15. <result property="bChkUnit" column="B_CHK_UNIT"/>
  16. <result property="contact" column="CONTACT"/>
  17. <result property="contactTel" column="CONTACT_TEL"/>
  18. <result property="principal" column="PRINCIPAL"/>
  19. <result property="principalTel" column="PRINCIPAL_TEL"/>
  20. <result property="note" column="NOTE"/>
  21. <result property="state" column="STATE"/>
  22. <result property="dataStat" column="DATA_STAT"/>
  23. <result property="chkUnit" column="CHK_UNIT"/>
  24. <result property="chkPers" column="CHK_PERS"/>
  25. <result property="chkTm" column="CHK_TM"/>
  26. <result property="intInfoStat" column="INT_INFO_STAT"/>
  27. <result property="persId" column="PERS_ID"/>
  28. <result property="groupId" column="GROUP_ID"/>
  29. <result property="inTm" column="IN_TM"/>
  30. <result property="upTm" column="UP_TM"/>
  31. </resultMap>
  32. <sql id="table_columns">
  33. ID,
  34. OBJ_ID,
  35. AD_NAME,
  36. AD_CODE,
  37. LOC,
  38. PC_X,
  39. PC_Y,
  40. GD_X,
  41. GD_Y,
  42. B_CHK_UNIT,
  43. CONTACT,
  44. CONTACT_TEL,
  45. PRINCIPAL,
  46. PRINCIPAL_TEL,
  47. NOTE,
  48. STATE,
  49. DATA_STAT,
  50. CHK_UNIT,
  51. CHK_PERS,
  52. CHK_TM,
  53. INT_INFO_STAT,
  54. PERS_ID,
  55. GROUP_ID,
  56. IN_TM,
  57. UP_TM,PROVINCE
  58. </sql>
  59. <sql id="entity_properties">
  60. #{id},
  61. #{objId},
  62. #{adName},
  63. #{adCode},
  64. #{loc},
  65. #{pcX},
  66. #{pcY},
  67. #{gdX},
  68. #{gdY},
  69. #{bChkUnit},
  70. #{contact},
  71. #{contactTel},
  72. #{principal},
  73. #{principalTel},
  74. #{note},
  75. #{state},
  76. #{dataStat},
  77. #{chkUnit},
  78. #{chkPers},
  79. #{chkTm},
  80. #{intInfoStat},
  81. #{persId},
  82. #{groupId},
  83. #{inTm},
  84. #{upTm},#{province}
  85. </sql>
  86. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  87. <sql id="page_where">
  88. <trim prefix="where" prefixOverrides="and | or ">
  89. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  90. <choose>
  91. <when test="province !=null and province !=''">
  92. and province =#{province}
  93. </when>
  94. <otherwise>
  95. and province is null
  96. </otherwise>
  97. </choose>
  98. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  99. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  100. <if test="loc != null and loc != ''">and LOC = #{loc}</if>
  101. <if test="pcX != null and pcX != ''">and PC_X = #{pcX}</if>
  102. <if test="pcY != null and pcY != ''">and PC_Y = #{pcY}</if>
  103. <if test="gdX != null and gdX != ''">and GD_X = #{gdX}</if>
  104. <if test="gdY != null and gdY != ''">and GD_Y = #{gdY}</if>
  105. <if test="bChkUnit != null and bChkUnit != ''">and B_CHK_UNIT = #{bChkUnit}</if>
  106. <if test="contact != null and contact != ''">and CONTACT = #{contact}</if>
  107. <if test="contactTel != null and contactTel != ''">and CONTACT_TEL = #{contactTel}</if>
  108. <if test="principal != null and principal != ''">and PRINCIPAL = #{principal}</if>
  109. <if test="principalTel != null and principalTel != ''">and PRINCIPAL_TEL = #{principalTel}</if>
  110. <if test="note != null and note != ''">and NOTE = #{note}</if>
  111. <if test="state != null and state != ''">and STATE = #{state}</if>
  112. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  113. <if test="chkUnit != null and chkUnit != ''">and CHK_UNIT = #{chkUnit}</if>
  114. <if test="chkPers != null and chkPers != ''">and CHK_PERS = #{chkPers}</if>
  115. <if test="chkTm != null">and CHK_TM = #{chkTm}</if>
  116. <if test="intInfoStat != null and intInfoStat != ''">and INT_INFO_STAT = #{intInfoStat}</if>
  117. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  118. <if test="groupId != null and groupId != ''">and GROUP_ID = #{groupId}</if>
  119. <if test="inTm != null">and IN_TM = #{inTm}</if>
  120. <if test="upTm != null">and UP_TM = #{upTm}</if>
  121. </trim>
  122. </sql>
  123. <select id="get" resultMap="bisInspWintRgstrResultMap" parameterType="String" >
  124. select <include refid="table_columns" /> from BIS_INSP_WINT_RGSTR where ID = #{id}
  125. </select>
  126. <select id="getBy" resultMap="bisInspWintRgstrResultMap">
  127. select <include refid="table_columns" /> from BIS_INSP_WINT_RGSTR <include refid="page_where" />
  128. </select>
  129. <select id="findAll" resultMap="bisInspWintRgstrResultMap">
  130. select <include refid="table_columns" /> from BIS_INSP_WINT_RGSTR
  131. </select>
  132. <select id="findList" resultMap="bisInspWintRgstrResultMap">
  133. select <include refid="table_columns" /> from BIS_INSP_WINT_RGSTR <include refid="page_where" />
  134. </select>
  135. <select id="selectCount" resultType="int" >
  136. select count(ID) from BIS_INSP_WINT_RGSTR <include refid="page_where" />
  137. </select>
  138. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspWintRgstr">
  139. insert into BIS_INSP_WINT_RGSTR( <include refid="table_columns" /> )
  140. values ( <include refid="entity_properties" /> )
  141. </insert>
  142. <delete id="delete" parameterType="java.lang.String">
  143. delete from BIS_INSP_WINT_RGSTR where ID = #{id}
  144. </delete>
  145. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspWintRgstr">
  146. delete from BIS_INSP_WINT_RGSTR <include refid="page_where" />
  147. </delete>
  148. <update id="deleteInFlag" parameterType="java.lang.String">
  149. update BIS_INSP_WINT_RGSTR set flag_valid = 0 where ID = #{id}
  150. </update>
  151. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspWintRgstr">
  152. update BIS_INSP_WINT_RGSTR
  153. <trim prefix="set" suffixOverrides=",">
  154. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  155. <if test="province != null and province != ''">PROVINCE = #{province},</if>
  156. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  157. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  158. LOC = #{loc},
  159. PC_X = #{pcX},
  160. PC_Y = #{pcY},
  161. GD_X = #{gdX},
  162. GD_Y = #{gdY},
  163. B_CHK_UNIT = #{bChkUnit},
  164. CONTACT = #{contact},
  165. CONTACT_TEL = #{contactTel},
  166. PRINCIPAL = #{principal},
  167. PRINCIPAL_TEL = #{principalTel},
  168. <if test="note != null and note != ''">NOTE = #{note},</if>
  169. <if test="state != null and state != ''">STATE = #{state},</if>
  170. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  171. CHK_UNIT = #{chkUnit},
  172. CHK_PERS = #{chkPers},
  173. CHK_TM = #{chkTm},
  174. <if test="intInfoStat != null and intInfoStat != ''">INT_INFO_STAT = #{intInfoStat},</if>
  175. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  176. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  177. <if test="inTm != null">IN_TM = #{inTm},</if>
  178. <if test="upTm != null">UP_TM = #{upTm},</if>
  179. </trim>
  180. <where>ID = #{id}</where>
  181. </update>
  182. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspWintRgstr">
  183. update BIS_INSP_WINT_RGSTR
  184. <trim prefix="set" suffixOverrides=",">
  185. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  186. <if test="province != null and province != ''">PROVINCE = #{province},</if>
  187. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  188. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  189. LOC = #{loc},
  190. PC_X = #{pcX},
  191. PC_Y = #{pcY},
  192. GD_X = #{gdX},
  193. GD_Y = #{gdY},
  194. B_CHK_UNIT = #{bChkUnit},
  195. CONTACT = #{contact},
  196. CONTACT_TEL = #{contactTel},
  197. PRINCIPAL = #{principal},
  198. PRINCIPAL_TEL = #{principalTel},
  199. <if test="note != null and note != ''">NOTE = #{note},</if>
  200. <if test="state != null and state != ''">STATE = #{state},</if>
  201. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  202. CHK_UNIT = #{chkUnit},
  203. CHK_PERS = #{chkPers},
  204. CHK_TM = #{chkTm},
  205. <if test="intInfoStat != null and intInfoStat != ''">INT_INFO_STAT = #{intInfoStat},</if>
  206. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  207. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  208. <if test="inTm != null">IN_TM = #{inTm},</if>
  209. <if test="upTm != null">UP_TM = #{upTm},</if>
  210. </trim>
  211. <include refid="page_where" />
  212. </update>
  213. <sql id="choseSql">
  214. <choose>
  215. <when test="province !=null and province !=''">
  216. and B.province like '${province}%'
  217. </when>
  218. <otherwise>
  219. and B.province is null
  220. </otherwise>
  221. </choose>
  222. </sql>
  223. <select id="getListByInspGroupIdObjType" parameterType="cn.com.goldenwater.dcproj.param.PagePersObjParam"
  224. resultType="cn.com.goldenwater.dcproj.model.BisInspWintRgstr" >
  225. select t.*,C.id groupId,C.PNM groupName,B.obj_id,r.loc
  226. from att_ad_x_base t
  227. left join BIS_INSP_ALL_OBJ B
  228. on B.CODE = t.ad_code
  229. LEFT JOIN BIS_INSP_ALL C ON B.ID = C.ID
  230. and B.ptype = #{objType}
  231. left join BIS_INSP_WINT_RGSTR r on b.obj_id=r.obj_id
  232. where 1 = 1
  233. <if test='isAll == "0"'>and B.ID = #{inspGroupId}</if>
  234. <if test='isAll == "1"'>and B.ID LIKE '${inspGroupId}%'</if>
  235. <if test="adCode != null and adCode != ''">
  236. and t.AD_CODE like '${adCode}%'
  237. </if>
  238. <choose>
  239. <when test="province != null and province != ''">
  240. and B.AD_CODE LIKE '${province}%'
  241. </when>
  242. <otherwise>
  243. and B.AD_CODE is null
  244. </otherwise>
  245. </choose>
  246. </select>
  247. <sql id="orgIdSql">
  248. <choose>
  249. <when test="orgId !=null and orgId !=''">
  250. and ORG_ID=#{orgId}
  251. </when>
  252. <otherwise>
  253. and ORG_ID is null
  254. </otherwise>
  255. </choose>
  256. </sql>
  257. <!-- 其他自定义SQL -->
  258. <select id="findCityPage" resultType="cn.com.goldenwater.dcproj.dto.BisInspRgstrDto" parameterType="cn.com.goldenwater.dcproj.param.TypeParam">
  259. SELECT * FROM (
  260. select A.CODE,A.ID nodeId,
  261. A.NM,
  262. #{pType} PTYPE,
  263. B.pc_x,
  264. B.pc_y,
  265. B.GD_X,
  266. B.GD_y,
  267. A.OBJ_ID,B.ID ID,
  268. (case when b.loc is null then c.ad_full_name else b.loc end) as location,
  269. (case when b.State is null then '0' else b.state end)STATE
  270. ,B.IN_TM,
  271. B.INT_INFO_STAT,
  272. c.ad_full_name as adName,
  273. ia.pnm groupName
  274. from BIS_INSP_ALL_OBJ
  275. A LEFT JOIN BIS_INSP_WINT_RGSTR B ON A.OBJ_ID=B.OBJ_ID
  276. LEFT JOIN ATT_AD_X_BASE C ON A.CODE=C.AD_CODE
  277. LEFT JOIN BIS_INSP_ALL ia on A.ID = ia.id
  278. where A.ptype= #{pType}
  279. <if test="tabType =='2'.toString()">
  280. and ia.entm &lt;DATE_FORMAT(#{nowTime},'%Y-%m-%d')
  281. </if>
  282. <if test="tabType =='1'.toString()">
  283. and ia.entm &gt;=DATE_FORMAT(#{nowTime},'%Y-%m-%d')
  284. </if>
  285. <if test="inIdsSql != null and inIdsSql != '' ">
  286. and A.id in (${inIdsSql})
  287. </if>
  288. <include refid="choseSql"/>
  289. ) A
  290. WHERE a.PTYPE=#{pType}
  291. <if test="plnaId !=null and plnaId !=''">
  292. and a.nodeId like '${plnaId}%'
  293. </if>
  294. <if test="state !=null and state !=''">
  295. and STATE=#{state}
  296. </if>
  297. <if test="rsName !=null and rsName !=''">
  298. and a.nm like '%${rsName}%'
  299. </if>
  300. <if test="code !=null and code !=''">
  301. and a.code = #{code}
  302. </if>
  303. <if test="adName != null and adName != ''">and a.adName like '%${adName}%'</if>
  304. <if test="sttm != null and sttm != ''">and a.IN_TM&gt;= DATE_FORMAT(#{sttm},'%Y-%m-%d')</if>
  305. <if test="entm != null and entm != ''">and a.IN_TM &lt; DATE_FORMAT(#{entm},'%Y-%m-%d')</if>
  306. order by nodeId asc
  307. <if test="orderBy != null and orderBy != ''">
  308. , CONVERT(nm USING gbk)
  309. </if>
  310. </select>
  311. <update id="updateWintRgstrState" parameterType="java.lang.String">
  312. update BIS_INSP_WINT_RGSTR t set t.STATE = '2' where t.id = #{id}
  313. </update>
  314. </mapper>