BisInspDrdmpRgstrDao.xml 12 KB

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