BisInspSafetyRgstrDao.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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.BisInspSafetyRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspSafetyRgstr" id="bisInspSafetyRgstrResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="name" column="NAME"/>
  8. <result property="mgPers" column="MG_PERS"/>
  9. <result property="mgPersTel" column="MG_PERS_TEL"/>
  10. <result property="adCode" column="AD_CODE"/>
  11. <result property="adName" column="AD_NAME"/>
  12. <result property="loc" column="LOC"/>
  13. <result property="note" column="NOTE"/>
  14. <result property="centerX" column="CENTER_X"/>
  15. <result property="centerY" column="CENTER_Y"/>
  16. <result property="gdX" column="GD_X"/>
  17. <result property="gdY" column="GD_Y"/>
  18. <result property="intm" column="INTM"/>
  19. <result property="uptm" column="UPTM"/>
  20. <result property="dataStat" column="DATA_STAT"/>
  21. <result property="state" column="STATE"/>
  22. </resultMap>
  23. <sql id="table_columns">
  24. ID,
  25. OBJ_ID,
  26. NAME,
  27. MG_PERS,
  28. MG_PERS_TEL,
  29. AD_CODE,
  30. AD_NAME,
  31. LOC,
  32. NOTE,
  33. CENTER_X,
  34. CENTER_Y,
  35. GD_X,
  36. GD_Y,
  37. INTM,
  38. UPTM,
  39. DATA_STAT,
  40. STATE
  41. </sql>
  42. <sql id="entity_properties">
  43. #{id},
  44. #{objId},
  45. #{name},
  46. #{mgPers},
  47. #{mgPersTel},
  48. #{adCode},
  49. #{adName},
  50. #{loc},
  51. #{note},
  52. #{centerX},
  53. #{centerY},
  54. #{gdX},
  55. #{gdY},
  56. #{intm},
  57. #{uptm},
  58. #{dataStat},
  59. #{state}
  60. </sql>
  61. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  62. <sql id="page_where">
  63. <trim prefix="where" prefixOverrides="and | or ">
  64. <if test="objId != null and objId != ''">
  65. and OBJ_ID = #{objId}
  66. </if>
  67. <if test="name != null and name != ''">
  68. and NAME = #{name}
  69. </if>
  70. <if test="mgPers != null and mgPers != ''">
  71. and MG_PERS = #{mgPers}
  72. </if>
  73. <if test="mgPersTel != null and mgPersTel != ''">
  74. and MG_PERS_TEL = #{mgPersTel}
  75. </if>
  76. <if test="adCode != null and adCode != ''">
  77. and AD_CODE = #{adCode}
  78. </if>
  79. <if test="adName != null and adName != ''">
  80. and AD_NAME = #{adName}
  81. </if>
  82. <if test="loc != null and loc != ''">
  83. and LOC = #{loc}
  84. </if>
  85. <if test="note != null and note != ''">
  86. and NOTE = #{note}
  87. </if>
  88. <if test="centerX != null and centerX != ''">
  89. and CENTER_X = #{centerX}
  90. </if>
  91. <if test="centerY != null and centerY != ''">
  92. and CENTER_Y = #{centerY}
  93. </if>
  94. <if test="gdX != null and gdX != ''">
  95. and GD_X = #{gdX}
  96. </if>
  97. <if test="gdY != null and gdY != ''">
  98. and GD_Y = #{gdY}
  99. </if>
  100. <if test="intm != null">
  101. and INTM = #{intm}
  102. </if>
  103. <if test="uptm != null">
  104. and UPTM = #{uptm}
  105. </if>
  106. <if test="dataStat != null and dataStat != ''">
  107. and DATA_STAT = #{dataStat}
  108. </if>
  109. <if test="state != null and state != ''">
  110. and STATE = #{state}
  111. </if>
  112. and DATA_STAT='0'
  113. </trim>
  114. </sql>
  115. <select id="get" resultMap="bisInspSafetyRgstrResultMap" parameterType="String">
  116. select
  117. <include refid="table_columns"/>
  118. from BIS_INSP_SAFETY_RGSTR where ID = #{id}
  119. </select>
  120. <select id="getBy" resultMap="bisInspSafetyRgstrResultMap">
  121. select
  122. <include refid="table_columns"/>
  123. from BIS_INSP_SAFETY_RGSTR
  124. <include refid="page_where"/>
  125. </select>
  126. <select id="findAll" resultMap="bisInspSafetyRgstrResultMap">
  127. select
  128. <include refid="table_columns"/>
  129. from BIS_INSP_SAFETY_RGSTR
  130. </select>
  131. <select id="findList" resultMap="bisInspSafetyRgstrResultMap">
  132. select
  133. <include refid="table_columns"/>
  134. from BIS_INSP_SAFETY_RGSTR
  135. <include refid="page_where"/>
  136. </select>
  137. <select id="selectCount" resultType="int">
  138. select count(ID) from BIS_INSP_SAFETY_RGSTR
  139. <include refid="page_where"/>
  140. </select>
  141. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspSafetyRgstr">
  142. insert into BIS_INSP_SAFETY_RGSTR(
  143. <include refid="table_columns"/>
  144. )
  145. values (
  146. <include refid="entity_properties"/>
  147. )
  148. </insert>
  149. <delete id="delete" parameterType="java.lang.String">
  150. update BIS_INSP_SAFETY_RGSTR set DATA_STAT='9' where ID = #{id}
  151. </delete>
  152. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspSafetyRgstr">
  153. update BIS_INSP_SAFETY_RGSTR set DATA_STAT='9'
  154. <include refid="page_where"/>
  155. </delete>
  156. <update id="deleteInFlag" parameterType="java.lang.String">
  157. update BIS_INSP_SAFETY_RGSTR set DATA_STAT = '9' where ID = #{id}
  158. </update>
  159. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspSafetyRgstr">
  160. update BIS_INSP_SAFETY_RGSTR
  161. <trim prefix="set" suffixOverrides=",">
  162. <if test="objId != null and objId != ''">OBJ_ID
  163. = #{objId},
  164. </if>
  165. <if test="name != null and name != ''">NAME
  166. = #{name},
  167. </if>
  168. <if test="mgPers != null and mgPers != ''">MG_PERS
  169. = #{mgPers},
  170. </if>
  171. <if test="mgPersTel != null and mgPersTel != ''">MG_PERS_TEL
  172. = #{mgPersTel},
  173. </if>
  174. <if test="adCode != null and adCode != ''">AD_CODE
  175. = #{adCode},
  176. </if>
  177. <if test="adName != null and adName != ''">AD_NAME
  178. = #{adName},
  179. </if>
  180. <if test="loc != null and loc != ''">LOC
  181. = #{loc},
  182. </if>
  183. <if test="note != null and note != ''">NOTE
  184. = #{note},
  185. </if>
  186. <if test="centerX != null and centerX != ''">CENTER_X
  187. = #{centerX},
  188. </if>
  189. <if test="centerY != null and centerY != ''">CENTER_Y
  190. = #{centerY},
  191. </if>
  192. <if test="gdX != null and gdX != ''">GD_X
  193. = #{gdX},
  194. </if>
  195. <if test="gdY != null and gdY != ''">GD_Y
  196. = #{gdY},
  197. </if>
  198. <if test="intm != null">INTM
  199. = #{intm},
  200. </if>
  201. <if test="uptm != null">UPTM
  202. = #{uptm},
  203. </if>
  204. <if test="dataStat != null and dataStat != ''">DATA_STAT
  205. = #{dataStat},
  206. </if>
  207. <if test="state != null and state != ''">STATE
  208. = #{state},
  209. </if>
  210. </trim>
  211. <where>ID = #{id}</where>
  212. </update>
  213. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspSafetyRgstr">
  214. update BIS_INSP_SAFETY_RGSTR
  215. <trim prefix="set" suffixOverrides=",">
  216. <if test="objId != null and objId != ''">OBJ_ID
  217. = #{objId},
  218. </if>
  219. <if test="name != null and name != ''">NAME
  220. = #{name},
  221. </if>
  222. <if test="mgPers != null and mgPers != ''">MG_PERS
  223. = #{mgPers},
  224. </if>
  225. <if test="mgPersTel != null and mgPersTel != ''">MG_PERS_TEL
  226. = #{mgPersTel},
  227. </if>
  228. <if test="adCode != null and adCode != ''">AD_CODE
  229. = #{adCode},
  230. </if>
  231. <if test="adName != null and adName != ''">AD_NAME
  232. = #{adName},
  233. </if>
  234. <if test="loc != null and loc != ''">LOC
  235. = #{loc},
  236. </if>
  237. <if test="note != null and note != ''">NOTE
  238. = #{note},
  239. </if>
  240. <if test="centerX != null and centerX != ''">CENTER_X
  241. = #{centerX},
  242. </if>
  243. <if test="centerY != null and centerY != ''">CENTER_Y
  244. = #{centerY},
  245. </if>
  246. <if test="gdX != null and gdX != ''">GD_X
  247. = #{gdX},
  248. </if>
  249. <if test="gdY != null and gdY != ''">GD_Y
  250. = #{gdY},
  251. </if>
  252. <if test="intm != null">INTM
  253. = #{intm},
  254. </if>
  255. <if test="uptm != null">UPTM
  256. = #{uptm},
  257. </if>
  258. <if test="dataStat != null and dataStat != ''">DATA_STAT
  259. = #{dataStat},
  260. </if>
  261. <if test="state != null and state != ''">STATE
  262. = #{state},
  263. </if>
  264. </trim>
  265. <include refid="page_where"/>
  266. </update>
  267. <!-- 其他自定义SQL -->
  268. <select id="findPageList" resultType="cn.com.goldenwater.dcproj.dto.BisInspSafetyRgstrDto">
  269. SELECT * FROM (
  270. select
  271. A.CODE, A.ID nodeId, A.NM, A.ptype, ia.pnm groupName,
  272. B.id as rgstrId, (case when b.STATE is null then '0' else b.state end) STATE,
  273. B.ID, B.OBJ_ID, B.NAME, B.MG_PERS,
  274. B.MG_PERS_TEL, B.AD_CODE, B.AD_NAME, B.LOC, B.NOTE,
  275. B.CENTER_X, B.CENTER_Y, B.GD_X, B.GD_Y, B.INTM, B.UPTM
  276. FROM BIS_INSP_ALL_OBJ A
  277. JOIN BIS_INSP_SAFETY_RGSTR B ON A.OBJ_ID=B.OBJ_ID
  278. LEFT JOIN BIS_INSP_ALL IA ON A.ID = IA.ID
  279. LEFT JOIN ATT_AD_BASE AW ON B.AD_CODE = AW.AD_CODE
  280. where A.ptype = #{pType}
  281. and B.DATA_STAT='0'
  282. <if test="adCodes ==null or adCodes ==''">
  283. <choose>
  284. <when test='isAll =="1"'>
  285. </when>
  286. <otherwise>
  287. and
  288. A.Id in (
  289. select distinct w.id from (
  290. SELECT P.id FROM BIS_INSP_ALL P
  291. WHERE FIND_IN_SET(P.id, getSubNodes_bis_insp_all( (SELECT group_concat(A.id) FROM BIS_INSP_ALL_RLATION A
  292. WHERE A.PERSID = #{presId} and A.TYPE = #{pType} and length(A.id) in (3,6,9) group by A.PERSID ),0,0) ) &gt; 0
  293. union all
  294. SELECT P.id FROM BIS_INSP_ALL P where p.id in (SELECT id FROM BIS_INSP_ALL_RLATION A
  295. WHERE A.PERSID =#{presId} and TYPE = #{pType} and length(id)=12 )
  296. ) w
  297. )
  298. </otherwise>
  299. </choose>
  300. </if>
  301. <if test="adCodes !=null and adCodes !=''">
  302. and
  303. <foreach item="item" index="index" collection="adCodes.split(',')" open="(" separator="or" close=")">
  304. b.ad_code like concat('${item}','%')
  305. </foreach>
  306. </if>
  307. ) A
  308. <where>
  309. <if test="id !=null and id !=''">and nodeId like '${id}%'</if>
  310. <if test="plnaId !=null and plnaId !=''">and nodeId like '${plnaId}%'</if>
  311. <if test="groupId != null and groupId != ''">and nodeId like '${groupId}%'</if>
  312. <if test="code !=null and code !=''">and code = #{code}</if>
  313. <if test="nm !=null and nm !=''">and nm like '%${nm}%'</if>
  314. <if test="state !=null and state !=''">and STATE in (${state})</if>
  315. <if test="adName != null and adName != ''">and AD_NAME like '%${adName}%'</if>
  316. <if test="sttm != null and sttm != ''">and Intm &gt;= STR_TO_DATE(#{sttm},'%Y-%m-%d')</if>
  317. <if test="entm != null and entm != ''">and Intm &lt; DATE_ADD(STR_TO_DATE(#{entm},'%Y-%m-%d') ,INTERVAL 1 DAY)</if>
  318. </where>
  319. order by nodeId asc
  320. <if test="orderBy != null and orderBy != ''">
  321. ,CONVERT( nm USING gbk ) COLLATE gbk_chinese_ci ASC
  322. </if>
  323. </select>
  324. </mapper>