BisInspDstfldqhDao.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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.BisInspDstfldqhDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspDstfldqh" id="bisInspDstfldqhResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="nm" column="NM"/>
  8. <result property="prjtType" column="PRJT_TYPE"/>
  9. <result property="adCode" column="AD_CODE"/>
  10. <result property="adName" column="AD_NAME"/>
  11. <result property="loc" column="LOC"/>
  12. <result property="unit" column="UNIT"/>
  13. <result property="content" column="CONTENT"/>
  14. <result property="note" column="NOTE"/>
  15. <result property="centerX" column="CENTER_X"/>
  16. <result property="centerY" column="CENTER_Y"/>
  17. <result property="gdX" column="GD_X"/>
  18. <result property="gdY" column="GD_Y"/>
  19. <result property="state" column="STATE"/>
  20. <result property="noteState" column="NOTE_STATE"/>
  21. <result property="persId" column="PERS_ID"/>
  22. <result property="intm" column="INTM"/>
  23. <result property="uptm" column="UPTM"/>
  24. <result property="dataStat" column="DATA_STAT"/>
  25. </resultMap>
  26. <sql id="table_columns">
  27. ID,
  28. OBJ_ID,
  29. NM,
  30. PRJT_TYPE,
  31. AD_CODE,
  32. AD_NAME,
  33. LOC,
  34. UNIT,
  35. CONTENT,
  36. NOTE,
  37. CENTER_X,
  38. CENTER_Y,
  39. GD_X,
  40. GD_Y,
  41. STATE,
  42. NOTE_STATE,
  43. PERS_ID,
  44. INTM,
  45. UPTM,
  46. DATA_STAT
  47. </sql>
  48. <sql id="entity_properties">
  49. #{id},
  50. #{objId},
  51. #{nm},
  52. #{prjtType},
  53. #{adCode},
  54. #{adName},
  55. #{loc},
  56. #{unit},
  57. #{content},
  58. #{note},
  59. #{centerX},
  60. #{centerY},
  61. #{gdX},
  62. #{gdY},
  63. #{state},
  64. #{noteState},
  65. #{persId},
  66. #{intm},
  67. #{uptm},
  68. #{dataStat}
  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="nm != null and nm != ''">and NM = #{nm}</if>
  75. <if test="prjtType != null and prjtType != ''">and PRJT_TYPE = #{prjtType}</if>
  76. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  77. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  78. <if test="loc != null and loc != ''">and LOC = #{loc}</if>
  79. <if test="unit != null and unit != ''">and UNIT = #{unit}</if>
  80. <if test="content != null and content != ''">and CONTENT = #{content}</if>
  81. <if test="note != null and note != ''">and NOTE = #{note}</if>
  82. <if test="centerX != null and centerX != ''">and CENTER_X = #{centerX}</if>
  83. <if test="centerY != null and centerY != ''">and CENTER_Y = #{centerY}</if>
  84. <if test="gdX != null and gdX != ''">and GD_X = #{gdX}</if>
  85. <if test="gdY != null and gdY != ''">and GD_Y = #{gdY}</if>
  86. <if test="state != null and state != ''">and STATE = #{state}</if>
  87. <if test="noteState != null and noteState != ''">and NOTE_STATE = #{noteState}</if>
  88. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  89. <if test="intm != null">and INTM = #{intm}</if>
  90. <if test="uptm != null">and UPTM = #{uptm}</if>
  91. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  92. </trim>
  93. </sql>
  94. <select id="get" resultMap="bisInspDstfldqhResultMap" parameterType="String" >
  95. select <include refid="table_columns" /> from BIS_INSP_DSTFLDQH where ID = #{id}
  96. </select>
  97. <select id="getBy" resultMap="bisInspDstfldqhResultMap">
  98. select <include refid="table_columns" /> from BIS_INSP_DSTFLDQH <include refid="page_where" />
  99. </select>
  100. <select id="findAll" resultMap="bisInspDstfldqhResultMap">
  101. select <include refid="table_columns" /> from BIS_INSP_DSTFLDQH
  102. </select>
  103. <select id="findList" resultMap="bisInspDstfldqhResultMap">
  104. select <include refid="table_columns" /> from BIS_INSP_DSTFLDQH <include refid="page_where" />
  105. </select>
  106. <select id="selectCount" resultType="int" >
  107. select count(ID) from BIS_INSP_DSTFLDQH <include refid="page_where" />
  108. </select>
  109. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspDstfldqh">
  110. insert into BIS_INSP_DSTFLDQH( <include refid="table_columns" /> )
  111. values ( <include refid="entity_properties" /> )
  112. </insert>
  113. <delete id="delete" parameterType="java.lang.String">
  114. update BIS_INSP_DSTFLDQH set DATA_STAT='9' where ID = #{id}
  115. </delete>
  116. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspDstfldqh">
  117. delete from BIS_INSP_DSTFLDQH <include refid="page_where" />
  118. </delete>
  119. <update id="deleteInFlag" parameterType="java.lang.String">
  120. update BIS_INSP_DSTFLDQH set flag_valid = 0 where ID = #{id}
  121. </update>
  122. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspDstfldqh">
  123. update BIS_INSP_DSTFLDQH
  124. <trim prefix="set" suffixOverrides=",">
  125. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  126. <if test="nm != null and nm != ''">NM = #{nm},</if>
  127. <if test="prjtType != null and prjtType != ''">PRJT_TYPE = #{prjtType},</if>
  128. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  129. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  130. <if test="loc != null and loc != ''">LOC = #{loc},</if>
  131. <if test="unit != null and unit != ''">UNIT = #{unit},</if>
  132. <if test="content != null and content != ''">CONTENT = #{content},</if>
  133. <if test="note != null and note != ''">NOTE = #{note},</if>
  134. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  135. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  136. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  137. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  138. <if test="state != null and state != ''">STATE = #{state},</if>
  139. <if test="noteState != null and noteState != ''">NOTE_STATE = #{noteState},</if>
  140. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  141. <if test="intm != null">INTM = #{intm},</if>
  142. <if test="uptm != null">UPTM = #{uptm},</if>
  143. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  144. </trim>
  145. <where>ID = #{id}</where>
  146. </update>
  147. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspDstfldqh">
  148. update BIS_INSP_DSTFLDQH
  149. <trim prefix="set" suffixOverrides=",">
  150. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  151. <if test="nm != null and nm != ''">NM = #{nm},</if>
  152. <if test="prjtType != null and prjtType != ''">PRJT_TYPE = #{prjtType},</if>
  153. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  154. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  155. <if test="loc != null and loc != ''">LOC = #{loc},</if>
  156. <if test="unit != null and unit != ''">UNIT = #{unit},</if>
  157. <if test="content != null and content != ''">CONTENT = #{content},</if>
  158. <if test="note != null and note != ''">NOTE = #{note},</if>
  159. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  160. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  161. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  162. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  163. <if test="state != null and state != ''">STATE = #{state},</if>
  164. <if test="noteState != null and noteState != ''">NOTE_STATE = #{noteState},</if>
  165. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  166. <if test="intm != null">INTM = #{intm},</if>
  167. <if test="uptm != null">UPTM = #{uptm},</if>
  168. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  169. </trim>
  170. <include refid="page_where" />
  171. </update>
  172. <!-- 其他自定义SQL -->
  173. <select id="findPageList" resultType="cn.com.goldenwater.dcproj.dto.BisInspDstfldqhDto">
  174. SELECT * FROM (
  175. select
  176. A.CODE, A.ID nodeId, A.ptype, ia.pnm groupName, AW.AD_FULL_NAME,
  177. B.id as rgstrId, (case when b.STATE is null then '0' else b.state end) STATE,
  178. B.GD_X AS LGTD,B.GD_Y LTTD,
  179. B.ID,
  180. B.OBJ_ID,
  181. B.NM,
  182. B.PRJT_TYPE,
  183. B.AD_CODE,
  184. B.AD_NAME,
  185. B.LOC,
  186. B.UNIT,
  187. B.CONTENT,
  188. B.NOTE,
  189. B.CENTER_X,
  190. B.CENTER_Y,
  191. B.GD_X,
  192. B.GD_Y,
  193. B.NOTE_STATE,
  194. B.PERS_ID,
  195. B.INTM,
  196. B.UPTM,
  197. B.DATA_STAT
  198. FROM BIS_INSP_ALL_OBJ A
  199. JOIN BIS_INSP_DSTFLDQH B ON A.OBJ_ID=B.OBJ_ID
  200. LEFT JOIN BIS_INSP_ALL IA ON A.ID = IA.ID
  201. LEFT JOIN ATT_AD_X_BASE AW ON B.AD_CODE = AW.AD_CODE
  202. where A.ptype = #{pType}
  203. and B.DATA_STAT='0'
  204. <if test="adCodes ==null or adCodes ==''">
  205. <choose>
  206. <when test='isAll =="1"'>
  207. </when>
  208. <otherwise>
  209. and
  210. A.Id in (
  211. select distinct id from (
  212. SELECT P.id FROM BIS_INSP_ALL P
  213. WHERE FIND_IN_SET(P.id, getSubNodes_bis_insp_all( (SELECT group_concat(A.id) FROM BIS_INSP_ALL_RLATION A
  214. WHERE A.PERSID = #{presId} and A.TYPE = #{pType} and length(A.id) in (3,6,9) group by A.PERSID ),0,0) ) &gt; 0
  215. union all
  216. SELECT P.id FROM BIS_INSP_ALL P where p.id in (SELECT id FROM BIS_INSP_ALL_RLATION A
  217. WHERE A.PERSID =#{presId} and TYPE = #{pType} and length(id)=12 )
  218. )w
  219. )
  220. </otherwise>
  221. </choose>
  222. </if>
  223. <if test="adCodes !=null and adCodes !=''">
  224. and
  225. <foreach item="item" index="index" collection="adCodes.split(',')" open="(" separator="or" close=")">
  226. b.ad_code like concat('${item}','%')
  227. </foreach>
  228. </if>
  229. ) A
  230. <where>
  231. <if test="id !=null and id !=''">and nodeId like '${id}%'</if>
  232. <if test="plnaId !=null and plnaId !=''">and nodeId like '${plnaId}%'</if>
  233. <if test="groupId != null and groupId != ''">and nodeId like '${groupId}%'</if>
  234. <if test="code !=null and code !=''">and code = #{code}</if>
  235. <if test="nm !=null and nm !=''">and nm like '%${nm}%'</if>
  236. <if test="rsName !=null and rsName !=''">and nm like '%${rsName}%'</if>
  237. <if test="state !=null and state !=''">and STATE in (${state})</if>
  238. <if test="adName != null and adName != ''">and AD_NAME like '%${adName}%'</if>
  239. <if test="sttm != null and sttm != ''">and Intm &gt;= STR_TO_DATE(#{sttm},'%Y-%m-%d')</if>
  240. <if test="entm != null and entm != ''">and Intm &lt; DATE_ADD(STR_TO_DATE(#{entm},'%Y-%m-%d') ,INTERVAL 1 DAY)</if>
  241. </where>
  242. order by nodeId asc
  243. <if test="orderBy != null and orderBy != ''">
  244. ,CONVERT( nm USING gbk ) COLLATE gbk_chinese_ci ASC
  245. </if>
  246. </select>
  247. </mapper>