BisInspOprdCstrProjRgstrDao.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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.BisInspOprdCstrProjRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspOprdCstrProjRgstr" id="bisInspOprdCstrProjRgstrResultMap">
  5. <result property="objId" column="OBJ_ID"/>
  6. <result property="name" column="NAME"/>
  7. <result property="type" column="TYPE"/>
  8. <result property="adCode" column="AD_CODE"/>
  9. <result property="adName" column="AD_NAME"/>
  10. <result property="location" column="LOCATION"/>
  11. <result property="filePath" column="FILE_PATH"/>
  12. <result property="centerX" column="CENTER_X"/>
  13. <result property="centerY" column="CENTER_Y"/>
  14. <result property="gdX" column="GD_X"/>
  15. <result property="gdY" column="GD_Y"/>
  16. <result property="state" column="STATE"/>
  17. <result property="persId" column="PERS_ID"/>
  18. <result property="groupId" column="GROUP_ID"/>
  19. <result property="inTm" column="IN_TM"/>
  20. <result property="upTm" column="UP_TM"/>
  21. <result property="province" column="PROVINCE"/>
  22. <result property="id" column="ID"/>
  23. </resultMap>
  24. <sql id="table_columns">
  25. OBJ_ID,
  26. NAME,
  27. TYPE,
  28. AD_CODE,
  29. AD_NAME,
  30. LOCATION,
  31. FILE_PATH,
  32. CENTER_X,
  33. CENTER_Y,
  34. GD_X,
  35. GD_Y,
  36. STATE,
  37. PERS_ID,
  38. GROUP_ID,
  39. IN_TM,
  40. UP_TM,
  41. PROVINCE,
  42. ID
  43. </sql>
  44. <sql id="entity_properties">
  45. #{objId},
  46. #{name},
  47. #{type},
  48. #{adCode},
  49. #{adName},
  50. #{location},
  51. #{filePath},
  52. #{centerX},
  53. #{centerY},
  54. #{gdX},
  55. #{gdY},
  56. #{state},
  57. #{persId},
  58. #{groupId},
  59. #{inTm},
  60. #{upTm},
  61. #{province},
  62. #{id}
  63. </sql>
  64. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  65. <sql id="page_where">
  66. <trim prefix="where" prefixOverrides="and | or ">
  67. <if test="name != null and name != ''">and NAME = #{name}</if>
  68. <if test="type != null and type != ''">and TYPE = #{type}</if>
  69. <if test="adCode != null and adCode != ''">and AD_CODE like '${adCode}%'</if>
  70. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  71. <if test="location != null and location != ''">and LOCATION = #{location}</if>
  72. <if test="objId != null and objId != ''">and OBJ_Id = #{objId}</if>
  73. <if test="filePath != null and filePath != ''">and FILE_PATH = #{filePath}</if>
  74. <if test="centerX != null and centerX != ''">and CENTER_X = #{centerX}</if>
  75. <if test="centerY != null and centerY != ''">and CENTER_Y = #{centerY}</if>
  76. <if test="gdX != null and gdX != ''">and GD_X = #{gdX}</if>
  77. <if test="gdY != null and gdY != ''">and GD_Y = #{gdY}</if>
  78. <if test="state != null and state != ''">and STATE = #{state}</if>
  79. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  80. <if test="groupId != null and groupId != ''">and GROUP_ID = #{groupId}</if>
  81. <if test="inTm != null">and IN_TM = #{inTm}</if>
  82. <if test="upTm != null">and UP_TM = #{upTm}</if>
  83. <if test="province != null and province != ''">and PROVINCE like '%${province}%'</if>
  84. <if test="id != null and id != ''">and ID = #{id}</if>
  85. </trim>
  86. </sql>
  87. <select id="get" resultMap="bisInspOprdCstrProjRgstrResultMap" parameterType="String" >
  88. select <include refid="table_columns" /> from BIS_INSP_OPRD_CSTR_PROJ_RGSTR where ID = #{id}
  89. </select>
  90. <select id="getBy" resultMap="bisInspOprdCstrProjRgstrResultMap">
  91. select <include refid="table_columns" /> from BIS_INSP_OPRD_CSTR_PROJ_RGSTR <include refid="page_where" />
  92. </select>
  93. <select id="findAll" resultMap="bisInspOprdCstrProjRgstrResultMap">
  94. select <include refid="table_columns" /> from BIS_INSP_OPRD_CSTR_PROJ_RGSTR
  95. </select>
  96. <select id="findList" resultMap="bisInspOprdCstrProjRgstrResultMap">
  97. select <include refid="table_columns" /> from BIS_INSP_OPRD_CSTR_PROJ_RGSTR <include refid="page_where" />
  98. </select>
  99. <select id="selectCount" resultType="int" >
  100. select count(ID) from BIS_INSP_OPRD_CSTR_PROJ_RGSTR <include refid="page_where" />
  101. </select>
  102. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspOprdCstrProjRgstr">
  103. insert into BIS_INSP_OPRD_CSTR_PROJ_RGSTR( <include refid="table_columns" /> )
  104. values ( <include refid="entity_properties" /> )
  105. </insert>
  106. <delete id="delete" parameterType="java.lang.String">
  107. delete from BIS_INSP_OPRD_CSTR_PROJ_RGSTR where ID = #{id}
  108. </delete>
  109. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspOprdCstrProjRgstr">
  110. delete from BIS_INSP_OPRD_CSTR_PROJ_RGSTR <include refid="page_where" />
  111. </delete>
  112. <update id="deleteInFlag" parameterType="java.lang.String">
  113. update BIS_INSP_OPRD_CSTR_PROJ_RGSTR set flag_valid = 0 where ID = #{id}
  114. </update>
  115. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspOprdCstrProjRgstr">
  116. update BIS_INSP_OPRD_CSTR_PROJ_RGSTR
  117. <trim prefix="set" suffixOverrides=",">
  118. <if test="name != null and name != ''">NAME = #{name},</if>
  119. <if test="type != null and type != ''">TYPE = #{type},</if>
  120. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  121. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  122. <if test="location != null and location != ''">LOCATION = #{location},</if>
  123. <if test="filePath != null and filePath != ''">FILE_PATH = #{filePath},</if>
  124. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  125. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  126. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  127. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  128. <if test="state != null and state != ''">STATE = #{state},</if>
  129. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  130. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  131. <if test="inTm != null">IN_TM = #{inTm},</if>
  132. <if test="upTm != null">UP_TM = #{upTm},</if>
  133. <if test="province != null and province != ''">PROVINCE = #{province},</if>
  134. <if test="id != null and id != ''">ID = #{id},</if>
  135. </trim>
  136. <where>ID = #{id}</where>
  137. </update>
  138. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspOprdCstrProjRgstr">
  139. update BIS_INSP_OPRD_CSTR_PROJ_RGSTR
  140. <trim prefix="set" suffixOverrides=",">
  141. <if test="name != null and name != ''">NAME = #{name},</if>
  142. <if test="type != null and type != ''">TYPE = #{type},</if>
  143. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  144. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  145. <if test="location != null and location != ''">LOCATION = #{location},</if>
  146. <if test="filePath != null and filePath != ''">FILE_PATH = #{filePath},</if>
  147. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  148. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  149. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  150. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  151. <if test="state != null and state != ''">STATE = #{state},</if>
  152. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  153. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  154. <if test="inTm != null">IN_TM = #{inTm},</if>
  155. <if test="upTm != null">UP_TM = #{upTm},</if>
  156. <if test="province != null and province != ''">PROVINCE = #{province},</if>
  157. <if test="id != null and id != ''">ID = #{id},</if>
  158. </trim>
  159. <include refid="page_where" />
  160. </update>
  161. <sql id="choseSql">
  162. <choose>
  163. <when test="province !=null and province !=''">
  164. and A.AD_Code like '${province}%'
  165. </when>
  166. <otherwise>
  167. and A.AD_CODE is null
  168. </otherwise>
  169. </choose>
  170. </sql>
  171. <!-- 其他自定义SQL -->
  172. <select id="findCstrPrdPage" resultType="cn.com.goldenwater.dcproj.dto.BisInspRgstrDto" parameterType="cn.com.goldenwater.dcproj.param.TypeParam">
  173. select w.* from (
  174. select A.*,b.id as rgstrId,CASE WHEN B.STATE IS NULL THEN '0' ELSE B.STATE END AS state,(case when b.name is
  175. null then cast(c.name as char) else b.name end) as name,b.type,b.IN_TM,b.UP_TM,b.file_path,
  176. c.id as baseId,
  177. (case when b.location is null then c.location else b.location end) as location,ia.pnm groupName,ria.pnm
  178. riverName,ad.ad_full_name as ad_name from BIS_INSP_ALL_OBJ A join BIS_INSP_OPRD_CSTR_PROJ_RGSTR B on A.Obj_Id
  179. = B.Obj_Id left join ATT_PRD_CSTR_PROJ_BASE c on a.code = c.id
  180. left join ATT_AD_X_BASE ad on b.ad_code = ad.ad_code LEFT JOIN BIS_INSP_ALL ia on A.ID = ia.id
  181. left join BIS_INSP_ALL ria on substr(A.ID,1,6) = ria.id
  182. where 1 = 1
  183. <if test="tabType =='2'.toString()">
  184. and ia.entm &lt; date_add(str_to_date(#{nowTime},'%Y-%m-%d'), INTERVAL 1 DAY)
  185. </if>
  186. <if test="tabType =='1'.toString()">
  187. and ia.entm &gt;=str_to_date(#{nowTime},'%Y-%m-%d')
  188. </if>
  189. <include refid="choseSql"/>
  190. <if test="adName != null and adName != ''">and ad.AD_FULL_NAME LIKE '%${adName}%'</if>
  191. <if test="groupId != null and groupId != ''">and A.id like '${groupId}%'</if>
  192. <if test="adCode != null and adCode !=''">and B.AD_CODE like '${adCode}%'</if>
  193. <if test="plnaId !=null and plnaId !=''">
  194. and A.id like '${plnaId}%'
  195. </if>
  196. <if test="orgId != null and orgId !=''">and A.org_id = #{orgId}</if>
  197. <if test="sttm != null and sttm != '' and entm != null and entm != ''">
  198. AND B.IN_TM &gt;= STR_TO_DATE(#{sttm},'%Y-%m-%d') AND B.UP_TM &lt; DATE_ADD(STR_TO_DATE(#{entm},'%Y-%m-%d') ,INTERVAL 1 DAY)
  199. </if>
  200. and
  201. REGEXP_LIKE(
  202. A.Id,concat('^(',
  203. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION A WHERE PERSID =#{presId}
  204. <include refid="choseSql"/>
  205. )>0 then
  206. (SELECT group_concat(id separator '|') as
  207. id FROM BIS_INSP_ALL_RLATION A WHERE PERSID =#{presId}
  208. <include refid="choseSql"/>
  209. GROUP BY PERSID
  210. )
  211. else (select 'non' from dual) end)
  212. ,')'))
  213. ) w where 1 = 1
  214. <if test="state != null and state != ''">
  215. and state in (${state})
  216. </if>
  217. <if test="name != null and name != ''">
  218. and name like '%${name}%'
  219. </if>
  220. </select>
  221. <select id="getListOprdByInspGroupIdObjType" parameterType="cn.com.goldenwater.dcproj.param.PagePersObjParam"
  222. resultType="cn.com.goldenwater.dcproj.model.BisInspOprdCstrProjRgstr">
  223. select t.*,C.id groupId,C.PNM groupName,B.obj_id
  224. from ATT_PRD_CSTR_PROJ_BASE t
  225. left join BIS_INSP_ALL_OBJ B
  226. on B.CODE = t.ID
  227. LEFT JOIN BIS_INSP_ALL C ON B.ID = C.ID
  228. and B.ptype = #{objType}
  229. where 1 = 1
  230. <if test="wtdstNm !=null and wtdstNm !=''">
  231. and b.nm like '%${wtdstNm}%'
  232. </if>
  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. <select id="getObjPrdListNotInspGroupId" resultType="cn.com.goldenwater.dcproj.model.AttPrdCstrProjBase" parameterType="String">
  248. select t.*
  249. from ATT_PRD_CSTR_PROJ_BASE t
  250. where t.id not in (
  251. select CODE from BIS_INSP_ALL_OBJ B where id like concat(#{inspGroupId},'%') and B.obj_type=#{objType}
  252. <choose>
  253. <when test="province !=null and province !=''">
  254. and B.AD_CODE =#{province}
  255. </when>
  256. <otherwise>
  257. and B.AD_CODE is null
  258. </otherwise>
  259. </choose>
  260. )
  261. <if test="adName != null and adName != ''">and t.nm LIKE '%${adName}%'</if>
  262. <if test="adCode != null and adCode != ''">and t.AD_CODE LIKE '${adCode}%'</if>
  263. </select>
  264. <select id="findPrdPcPage" parameterType="cn.com.goldenwater.dcproj.param.BisInspOprdCstrProjRgstrParam"
  265. resultType="cn.com.goldenwater.dcproj.dto.BisInspOprdCstrProjRgstrDto" >
  266. select w.* from (
  267. select A.*,b.id as rgstrId,CASE WHEN B.STATE IS NULL THEN '0' ELSE B.STATE END AS state,(case when b.name is
  268. null then cast(c.name as char) else b.name end) as name,b.type,b.IN_TM,b.UP_TM,b.file_path,
  269. c.id as baseId,
  270. (case when b.CENTER_X is null then c.CENTER_X else b.CENTER_X end) as centerX,
  271. (case when b.CENTER_Y is null then c.CENTER_Y else b.CENTER_Y end) as centerY,
  272. (case when b.location is null then c.location else b.location end) as location,ia.pnm groupName,ria.pnm
  273. riverName,ad.ad_full_name from BIS_INSP_ALL_OBJ A join BIS_INSP_OPRD_CSTR_PROJ_RGSTR B on A.Obj_Id
  274. = B.Obj_Id left join ATT_PRD_CSTR_PROJ_BASE c on a.code = c.id
  275. left join ATT_AD_X_BASE ad on b.ad_code = ad.ad_code LEFT JOIN BIS_INSP_ALL ia on A.ID = ia.id
  276. left join BIS_INSP_ALL ria on substr(A.ID,1,6) = ria.id
  277. where 1 = 1
  278. <if test="tabType =='2'.toString()">
  279. and ia.entm &lt; date_add(str_to_date(#{nowTime},'%Y-%m-%d'), INTERVAL 1 DAY)
  280. </if>
  281. <if test="tabType =='1'.toString()">
  282. and ia.entm &gt;=str_to_date(#{nowTime},'%Y-%m-%d')
  283. </if>
  284. <include refid="choseSql"/>
  285. <if test="adName != null and adName != ''">and ad.AD_FULL_NAME LIKE '%${adName}%'</if>
  286. <if test="groupId != null and groupId != ''">and A.id like '${groupId}%'</if>
  287. <if test="adCode != null and adCode !=''">and B.AD_CODE like '${adCode}%'</if>
  288. <if test="plnaId !=null and plnaId !=''">
  289. and A.id like '${plnaId}%'
  290. </if>
  291. <if test="orgId != null and orgId !=''">and A.org_id =#{orgId}</if>
  292. <if test="sttm != null and sttm != '' and entm != null and entm != ''">
  293. AND B.IN_TM &gt;= STR_TO_DATE(#{sttm},'%Y-%m-%d') AND B.UP_TM &lt; DATE_ADD(STR_TO_DATE(#{entm},'%Y-%m-%d') ,INTERVAL 1 DAY)
  294. </if>
  295. and
  296. REGEXP_LIKE(
  297. A.Id,concat('^(',
  298. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION A WHERE PERSID =#{persId}
  299. <include refid="choseSql"/>
  300. )>0 then
  301. (SELECT group_concat(id separator '|') as
  302. id FROM BIS_INSP_ALL_RLATION A WHERE PERSID =#{persId}
  303. <include refid="choseSql"/>
  304. GROUP BY PERSID
  305. )
  306. else (select 'non' from dual) end)
  307. ,')'))
  308. )w where 1 = 1
  309. <if test="state != null and state != ''">
  310. and w.state in (${state})
  311. </if>
  312. <if test="name != null and name != ''">
  313. and w.name like '%${name}%'
  314. </if>
  315. </select>
  316. </mapper>