BisInspGrowRgstrDao.xml 14 KB

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