BisInspRsraqgRgstrDao.xml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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.BisInspRsraqgRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspRsraqgRgstr" id="bisInspRsraqgRgstrResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="adName" column="AD_NAME"/>
  8. <result property="adCode" column="AD_CODE"/>
  9. <result property="loc" column="LOC"/>
  10. <result property="pcX" column="PC_X"/>
  11. <result property="pcY" column="PC_Y"/>
  12. <result property="gdX" column="GD_X"/>
  13. <result property="gdY" column="GD_Y"/>
  14. <result property="note" column="NOTE"/>
  15. <result property="state" column="STATE"/>
  16. <result property="persId" column="PERS_ID"/>
  17. <result property="groupId" column="GROUP_ID"/>
  18. <result property="intm" column="INTM"/>
  19. <result property="uptm" column="UPTM"/>
  20. </resultMap>
  21. <sql id="table_columns">
  22. ID,
  23. OBJ_ID,
  24. AD_NAME,
  25. AD_CODE,
  26. LOC,
  27. PC_X,
  28. PC_Y,
  29. GD_X,
  30. GD_Y,
  31. NOTE,
  32. STATE,
  33. PERS_ID,
  34. GROUP_ID,
  35. INTM,
  36. UPTM
  37. </sql>
  38. <sql id="entity_properties">
  39. #{id},
  40. #{objId},
  41. #{adName},
  42. #{adCode},
  43. #{loc},
  44. #{pcX},
  45. #{pcY},
  46. #{gdX},
  47. #{gdY},
  48. #{note},
  49. #{state},
  50. #{persId},
  51. #{groupId},
  52. #{intm},
  53. #{uptm}
  54. </sql>
  55. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  56. <sql id="page_where">
  57. <trim prefix="where" prefixOverrides="and | or ">
  58. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  59. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  60. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  61. <if test="loc != null and loc != ''">and LOC = #{loc}</if>
  62. <if test="pcX != null and pcX != ''">and PC_X = #{pcX}</if>
  63. <if test="pcY != null and pcY != ''">and PC_Y = #{pcY}</if>
  64. <if test="gdX != null and gdX != ''">and GD_X = #{gdX}</if>
  65. <if test="gdY != null and gdY != ''">and GD_Y = #{gdY}</if>
  66. <if test="note != null and note != ''">and NOTE = #{note}</if>
  67. <if test="state != null and state != ''">and STATE = #{state}</if>
  68. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  69. <if test="groupId != null and groupId != ''">and GROUP_ID = #{groupId}</if>
  70. <if test="intm != null">and INTM = #{intm}</if>
  71. <if test="uptm != null">and UPTM = #{uptm}</if>
  72. </trim>
  73. </sql>
  74. <select id="get" resultMap="bisInspRsraqgRgstrResultMap" parameterType="String" >
  75. select <include refid="table_columns" /> from BIS_INSP_RSRAQG_RGSTR where ID = #{id}
  76. </select>
  77. <select id="getBy" resultMap="bisInspRsraqgRgstrResultMap">
  78. select <include refid="table_columns" /> from BIS_INSP_RSRAQG_RGSTR <include refid="page_where" />
  79. </select>
  80. <select id="findAll" resultMap="bisInspRsraqgRgstrResultMap">
  81. select <include refid="table_columns" /> from BIS_INSP_RSRAQG_RGSTR
  82. </select>
  83. <select id="findList" resultMap="bisInspRsraqgRgstrResultMap">
  84. select <include refid="table_columns" /> from BIS_INSP_RSRAQG_RGSTR <include refid="page_where" />
  85. </select>
  86. <select id="selectCount" resultType="int" >
  87. select count(ID) from BIS_INSP_RSRAQG_RGSTR <include refid="page_where" />
  88. </select>
  89. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspRsraqgRgstr">
  90. insert into BIS_INSP_RSRAQG_RGSTR( <include refid="table_columns" /> )
  91. values ( <include refid="entity_properties" /> )
  92. </insert>
  93. <delete id="delete" parameterType="java.lang.String">
  94. update BIS_INSP_RSRAQG_RGSTR set DATA_STAT='9' where ID = #{id}
  95. </delete>
  96. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspRsraqgRgstr">
  97. update BIS_INSP_RSRAQG_RGSTR set DATA_STAT='9' <include refid="page_where" />
  98. </delete>
  99. <update id="deleteInFlag" parameterType="java.lang.String">
  100. update BIS_INSP_RSRAQG_RGSTR set DATA_STAT = '9' where ID = #{id}
  101. </update>
  102. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspRsraqgRgstr">
  103. update BIS_INSP_RSRAQG_RGSTR
  104. <trim prefix="set" suffixOverrides=",">
  105. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  106. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  107. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  108. <if test="loc != null and loc != ''">LOC = #{loc},</if>
  109. <if test="pcX != null and pcX != ''">PC_X = #{pcX},</if>
  110. <if test="pcY != null and pcY != ''">PC_Y = #{pcY},</if>
  111. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  112. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  113. <if test="note != null and note != ''">NOTE = #{note},</if>
  114. <if test="state != null and state != ''">STATE = #{state},</if>
  115. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  116. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  117. <if test="intm != null">INTM = #{intm},</if>
  118. <if test="uptm != null">UPTM = #{uptm},</if>
  119. </trim>
  120. <where>ID = #{id}</where>
  121. </update>
  122. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspRsraqgRgstr">
  123. update BIS_INSP_RSRAQG_RGSTR
  124. <trim prefix="set" suffixOverrides=",">
  125. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  126. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  127. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  128. <if test="loc != null and loc != ''">LOC = #{loc},</if>
  129. <if test="pcX != null and pcX != ''">PC_X = #{pcX},</if>
  130. <if test="pcY != null and pcY != ''">PC_Y = #{pcY},</if>
  131. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  132. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  133. <if test="note != null and note != ''">NOTE = #{note},</if>
  134. <if test="state != null and state != ''">STATE = #{state},</if>
  135. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  136. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  137. <if test="intm != null">INTM = #{intm},</if>
  138. <if test="uptm != null">UPTM = #{uptm},</if>
  139. </trim>
  140. <include refid="page_where" />
  141. </update>
  142. <!-- 其他自定义SQL -->
  143. <select id="findRsraqgRgstrPage" parameterType="cn.com.goldenwater.dcproj.param.TypeParam" resultType="cn.com.goldenwater.dcproj.dto.BisInspRgstrDto">
  144. SELECT * FROM (
  145. select A.CODE,A.ID nodeId,
  146. A.NM,
  147. '23' PTYPE,
  148. B.pc_x,
  149. B.pc_y,
  150. B.GD_X,
  151. B.GD_y,
  152. A.OBJ_ID,B.ID ID,B.ID rgstrId,
  153. (case when b.loc is null then c.ad_full_name else b.loc end) as location,
  154. (case when b.State is null then '0' else b.state end)STATE
  155. ,B.INTM
  156. ,B.UPTM
  157. ,c.AD_NAME as adName,
  158. ia.pnm groupName
  159. from BIS_INSP_ALL_OBJ
  160. A LEFT JOIN BIS_INSP_RSRAQG_RGSTR B ON A.OBJ_ID=B.OBJ_ID
  161. LEFT JOIN ATT_AD_X_BASE C ON A.CODE=C.AD_CODE
  162. LEFT JOIN BIS_INSP_ALL ia on A.ID = ia.id
  163. where A.ptype='23'
  164. <if test="tabType =='2'.toString()">
  165. and ia.entm &lt; DATE_ADD(STR_TO_DATE(#{nowTime},'%Y-%m-%d'),INTERVAL 1 DAY)
  166. </if>
  167. <if test="tabType =='1'.toString()">
  168. and ia.entm &gt;=STR_TO_DATE(#{nowTime},'%Y-%m-%d')
  169. </if>
  170. <include refid="choseSql"/>
  171. <if test="adName != null and adName != ''">and ad.AD_NAME LIKE '%${adName}%'</if>
  172. <if test="groupId != null and groupId != ''">and A.id = #{groupId}</if>
  173. <if test="adCode != null and adCode !=''">and B.AD_CODE like '${adCode}%'</if>
  174. <if test="plnaId !=null and plnaId !=''">
  175. and A.id like '${plnaId}%'
  176. </if>
  177. <if test="orgId != null and orgId !=''">and A.org_id = #{orgId}</if>
  178. <if test="sttm != null and sttm != '' and entm != null and entm != ''">
  179. AND B.intm &gt;= STR_TO_DATE(#{sttm},'%Y-%m-%d') AND B.uptm &lt; DATE_ADD(STR_TO_DATE(#{entm},'%Y-%m-%d') , INTERVAL 1 DAY)
  180. </if>
  181. and
  182. A.id in (${inIdsSql})
  183. ) rr where 1 = 1
  184. <if test="state != null and state != ''">
  185. and state in (${state})
  186. </if>
  187. <if test="name != null and name != ''">
  188. and name like '%${name}%'
  189. </if>
  190. </select>
  191. <sql id="choseSql">
  192. <choose>
  193. <when test="province !=null and province !=''">
  194. and A.ad_code=#{province}
  195. </when>
  196. <otherwise>
  197. and A.ad_code is null
  198. </otherwise>
  199. </choose>
  200. </sql>
  201. <select id="getListRsraqByInspGroupIdObjType" resultType="cn.com.goldenwater.dcproj.model.BisInspRsraqgRgstr" parameterType="cn.com.goldenwater.dcproj.param.PagePersObjParam">
  202. select t.*,C.id groupId,C.PNM groupName,B.obj_id,r.loc
  203. from att_ad_base t
  204. left join BIS_INSP_ALL_OBJ B
  205. on B.CODE = t.ad_code
  206. LEFT JOIN BIS_INSP_ALL C ON B.ID = C.ID
  207. and B.ptype = #{objType}
  208. left join BIS_INSP_RSRAQG_RGSTR r on b.obj_id=r.obj_id
  209. where 1 = 1
  210. <if test='isAll == "0"'>and B.ID = #{inspGroupId}</if>
  211. <if test='isAll == "1"'>and B.ID LIKE '${inspGroupId}%'</if>
  212. <if test="adCode != null and adCode != ''">
  213. and t.AD_CODE like '${adCode}%'
  214. </if>
  215. <choose>
  216. <when test="province != null and province != ''">
  217. and B.AD_CODE LIKE '${province}%'
  218. </when>
  219. <otherwise>
  220. and B.AD_CODE is null
  221. </otherwise>
  222. </choose>
  223. </select>
  224. </mapper>