AttCwsBaseDao.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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.AttCwsBaseDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.AttCwsBase" id="attCwsBaseResultMap">
  5. <result property="edtrPesr" column="EDTR_PESR"/>
  6. <result property="uptm" column="UPTM"/>
  7. <result property="centerXGd" column="CENTER_X_GD"/>
  8. <result property="centerYGd" column="CENTER_Y_GD"/>
  9. <result property="addvcd" column="ADDVCD"/>
  10. <result property="guid" column="GUID"/>
  11. <result property="cwsCode" column="CWS_CODE"/>
  12. <result property="cwsName" column="CWS_NAME"/>
  13. <result property="cwsLong" column="CWS_LONG"/>
  14. <result property="cwsLat" column="CWS_LAT"/>
  15. <result property="cwsLoc" column="CWS_LOC"/>
  16. <result property="engType" column="ENG_TYPE"/>
  17. <result property="wasuType" column="WASU_TYPE"/>
  18. <result property="wasuRang" column="WASU_RANG"/>
  19. <result property="desWasuScal" column="DES_WASU_SCAL"/>
  20. <result property="desWasuPop" column="DES_WASU_POP"/>
  21. <result property="engStat" column="ENG_STAT"/>
  22. <result property="startDate" column="START_DATE"/>
  23. <result property="compDate" column="COMP_DATE"/>
  24. <result property="note" column="NOTE"/>
  25. <result property="effDate" column="EFF_DATE"/>
  26. <result property="exprDate" column="EXPR_DATE"/>
  27. <result property="compYear" column="COMP_YEAR"/>
  28. </resultMap>
  29. <sql id="table_columns">
  30. EDTR_PESR ,
  31. DATE_FORMAT(UPTM,'%Y-%m-%d %H:%i:%s') UPTM,
  32. CENTER_X_GD ,
  33. CENTER_Y_GD ,
  34. ADDVCD ,
  35. GUID ,
  36. CWS_CODE ,
  37. CWS_NAME ,
  38. CWS_LONG ,
  39. CWS_LAT ,
  40. CWS_LOC ,
  41. ENG_TYPE ,
  42. WASU_TYPE ,
  43. WASU_RANG ,
  44. DES_WASU_SCAL ,
  45. DES_WASU_POP ,
  46. ENG_STAT ,
  47. START_DATE ,
  48. DATE_FORMAT(COMP_DATE,'%Y-%m-%d') COMP_DATE,
  49. DATE_FORMAT(COMP_DATE,'%Y') COMP_YEAR,
  50. NOTE ,
  51. DATE_FORMAT(EFF_DATE,'%Y-%m-%d %H:%i:%s') EFF_DATE,
  52. DATE_FORMAT(EXPR_DATE,'%Y-%m-%d %H:%i:%s') EXPR_DATE
  53. </sql>
  54. <sql id="table_columns2">
  55. EDTR_PESR ,
  56. UPTM ,
  57. CENTER_X_GD ,
  58. CENTER_Y_GD ,
  59. ADDVCD ,
  60. GUID ,
  61. CWS_CODE ,
  62. CWS_NAME ,
  63. CWS_LONG ,
  64. CWS_LAT ,
  65. CWS_LOC ,
  66. ENG_TYPE ,
  67. WASU_TYPE ,
  68. WASU_RANG ,
  69. DES_WASU_SCAL ,
  70. DES_WASU_POP ,
  71. ENG_STAT ,
  72. START_DATE ,
  73. COMP_DATE ,
  74. NOTE ,
  75. EFF_DATE ,
  76. EXPR_DATE
  77. </sql>
  78. <sql id="entity_properties">
  79. #{edtrPesr},
  80. STR_TO_DATE(#{uptm},'%Y-%m-%d %H:%i:%s') ,
  81. #{centerXGd},
  82. #{centerYGd},
  83. #{addvcd},
  84. #{guid},
  85. #{cwsCode},
  86. #{cwsName},
  87. #{cwsLong},
  88. #{cwsLat},
  89. #{cwsLoc},
  90. #{engType},
  91. #{wasuType},
  92. #{wasuRang},
  93. #{desWasuScal},
  94. #{desWasuPop},
  95. #{engStat},
  96. #{startDate},
  97. STR_TO_DATE(#{compDate},'%Y-%m-%d'),
  98. #{note},
  99. STR_TO_DATE(#{effDate},'%Y-%m-%d %H:%i:%s') ,
  100. STR_TO_DATE(#{exprDate},'%Y-%m-%d %H:%i:%s')
  101. </sql>
  102. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  103. <sql id="page_where">
  104. <trim prefix="where" prefixOverrides="and | or ">
  105. <if test="edtrPesr != null and edtrPesr != ''">and EDTR_PESR = #{edtrPesr}</if>
  106. <if test="uptm != null and uptm != ''">and UPTM = STR_TO_DATE(#{uptm},'%Y-%m-%d %H:%i:%s')</if>
  107. <if test="centerXGd != null and centerXGd != ''">and CENTER_X_GD = #{centerXGd}</if>
  108. <if test="centerYGd != null and centerYGd != ''">and CENTER_Y_GD = #{centerYGd}</if>
  109. <if test="addvcd != null and addvcd != ''">and ADDVCD LIKE CONCAT(#{addvcd}, '%') </if>
  110. <if test="guid != null and guid != ''">and GUID = #{guid}</if>
  111. <if test="cwsCode != null and cwsCode != ''">and CWS_CODE = #{cwsCode}</if>
  112. <if test="cwsName != null and cwsName != ''">and CWS_NAME LIKE CONCAT('%', #{cwsName}, '%') </if>
  113. <if test="cwsLong != null and cwsLong != ''">and CWS_LONG = #{cwsLong}</if>
  114. <if test="cwsLat != null and cwsLat != ''">and CWS_LAT = #{cwsLat}</if>
  115. <if test="cwsLoc != null and cwsLoc != ''">and CWS_LOC = #{cwsLoc}</if>
  116. <if test="engType != null and engType != ''">and ENG_TYPE = #{engType}</if>
  117. <if test="wasuType != null and wasuType != ''">and WASU_TYPE = #{wasuType}</if>
  118. <if test="wasuRang != null and wasuRang != ''">and WASU_RANG = #{wasuRang}</if>
  119. <if test="desWasuScal != null and desWasuScal != ''">and DES_WASU_SCAL = #{desWasuScal}</if>
  120. <if test="desWasuPop != null and desWasuPop != ''">and DES_WASU_POP = #{desWasuPop}</if>
  121. <if test="engStat != null and engStat != ''">and ENG_STAT = #{engStat}</if>
  122. <if test="startDate != null and startDate != ''">and START_DATE = #{startDate}</if>
  123. <if test="compDate != null and compDate != ''">and COMP_DATE = STR_TO_DATE(#{compDate},'%Y-%m-%d')</if>
  124. <if test="note != null and note != ''">and NOTE = #{note}</if>
  125. <if test="effDate != null and effDate != ''">and EFF_DATE = STR_TO_DATE(#{effDate},'%Y-%m-%d %H:%i:%s')</if>
  126. <if test="exprDate != null and exprDate != ''">and EXPR_DATE = STR_TO_DATE(#{exprDate},'%Y-%m-%d %H:%i:%s')
  127. </if>
  128. AND EXPR_DATE IS NULL
  129. </trim>
  130. </sql>
  131. <select id="get" resultMap="attCwsBaseResultMap" parameterType="String">
  132. select
  133. <include refid="table_columns"/>
  134. from att_cws_base where CWS_CODE = #{id} AND EXPR_DATE IS NULL
  135. </select>
  136. <select id="getBy" resultMap="attCwsBaseResultMap">
  137. select
  138. <include refid="table_columns"/>
  139. from att_cws_base
  140. <include refid="page_where"/>
  141. </select>
  142. <select id="findAll" resultMap="attCwsBaseResultMap">
  143. select
  144. <include refid="table_columns"/>
  145. from att_cws_base
  146. </select>
  147. <select id="findList" resultMap="attCwsBaseResultMap">
  148. select
  149. <include refid="table_columns"/>
  150. from att_cws_base
  151. <include refid="page_where"/>
  152. ORDER BY EFF_DATE desc
  153. </select>
  154. <select id="selectCount" resultType="int">
  155. select count(GUID) from att_cws_base
  156. <include refid="page_where"/>
  157. </select>
  158. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.AttCwsBase">
  159. insert into att_cws_base(
  160. <include refid="table_columns2"/>
  161. )
  162. values (
  163. <include refid="entity_properties"/>
  164. )
  165. </insert>
  166. <delete id="delete" parameterType="java.lang.String">
  167. delete from att_cws_base where GUID = #{id}
  168. </delete>
  169. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.AttCwsBase">
  170. delete from att_cws_base
  171. <include refid="page_where"/>
  172. </delete>
  173. <update id="deleteInFlag" parameterType="java.lang.String">
  174. update att_cws_base set flag_valid = 0 where GUID = #{id}
  175. </update>
  176. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.AttCwsBase">
  177. update att_cws_base
  178. <trim prefix="set" suffixOverrides=",">
  179. <if test="edtrPesr != null and edtrPesr != ''">EDTR_PESR = #{edtrPesr},</if>
  180. <if test="uptm != null and uptm != ''">UPTM = STR_TO_DATE(#{uptm},'%Y-%m-%d %H:%i:%s'),</if>
  181. <if test="centerXGd != null and centerXGd != ''">CENTER_X_GD = #{centerXGd},</if>
  182. <if test="centerYGd != null and centerYGd != ''">CENTER_Y_GD = #{centerYGd},</if>
  183. <if test="addvcd != null and addvcd != ''">ADDVCD = #{addvcd},</if>
  184. <if test="guid != null and guid != ''">GUID = #{guid},</if>
  185. <if test="cwsCode != null and cwsCode != ''">CWS_CODE = #{cwsCode},</if>
  186. <if test="cwsName != null and cwsName != ''">CWS_NAME = #{cwsName},</if>
  187. <if test="cwsLong != null and cwsLong != ''">CWS_LONG = #{cwsLong},</if>
  188. <if test="cwsLat != null and cwsLat != ''">CWS_LAT = #{cwsLat},</if>
  189. <if test="cwsLoc != null and cwsLoc != ''">CWS_LOC = #{cwsLoc},</if>
  190. <if test="engType != null and engType != ''">ENG_TYPE = #{engType},</if>
  191. <if test="wasuType != null and wasuType != ''">WASU_TYPE = #{wasuType},</if>
  192. <if test="wasuRang != null and wasuRang != ''">WASU_RANG = #{wasuRang},</if>
  193. <if test="desWasuScal != null and desWasuScal != ''">DES_WASU_SCAL = #{desWasuScal},</if>
  194. <if test="desWasuPop != null and desWasuPop != ''">DES_WASU_POP = #{desWasuPop},</if>
  195. <if test="engStat != null and engStat != ''">ENG_STAT = #{engStat},</if>
  196. <if test="startDate != null and startDate != ''">START_DATE = #{startDate},</if>
  197. <if test="compDate != null and compDate != ''">COMP_DATE = STR_TO_DATE(#{compDate},'%Y-%m-%d'),</if>
  198. <if test="note != null and note != ''">NOTE = #{note},</if>
  199. <if test="effDate != null and effDate != ''">EFF_DATE = STR_TO_DATE(#{effDate},'%Y-%m-%d %H:%i:%s'),</if>
  200. <if test="exprDate != null and exprDate != ''">EXPR_DATE = STR_TO_DATE(#{exprDate},'%Y-%m-%d %H:%i:%s'),
  201. </if>
  202. </trim>
  203. <where>GUID = #{guid}</where>
  204. </update>
  205. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.AttCwsBase">
  206. update att_cws_base
  207. <trim prefix="set" suffixOverrides=",">
  208. <if test="edtrPesr != null and edtrPesr != ''">EDTR_PESR = #{edtrPesr},</if>
  209. <if test="uptm != null and uptm != ''">UPTM = STR_TO_DATE(#{uptm},'%Y-%m-%d %H:%i:%s'),</if>
  210. <if test="centerXGd != null and centerXGd != ''">CENTER_X_GD = #{centerXGd},</if>
  211. <if test="centerYGd != null and centerYGd != ''">CENTER_Y_GD = #{centerYGd},</if>
  212. <if test="addvcd != null and addvcd != ''">ADDVCD = #{addvcd},</if>
  213. <if test="guid != null and guid != ''">GUID = #{guid},</if>
  214. <if test="cwsCode != null and cwsCode != ''">CWS_CODE = #{cwsCode},</if>
  215. <if test="cwsName != null and cwsName != ''">CWS_NAME = #{cwsName},</if>
  216. <if test="cwsLong != null and cwsLong != ''">CWS_LONG = #{cwsLong},</if>
  217. <if test="cwsLat != null and cwsLat != ''">CWS_LAT = #{cwsLat},</if>
  218. <if test="cwsLoc != null and cwsLoc != ''">CWS_LOC = #{cwsLoc},</if>
  219. <if test="engType != null and engType != ''">ENG_TYPE = #{engType},</if>
  220. <if test="wasuType != null and wasuType != ''">WASU_TYPE = #{wasuType},</if>
  221. <if test="wasuRang != null and wasuRang != ''">WASU_RANG = #{wasuRang},</if>
  222. <if test="desWasuScal != null and desWasuScal != ''">DES_WASU_SCAL = #{desWasuScal},</if>
  223. <if test="desWasuPop != null and desWasuPop != ''">DES_WASU_POP = #{desWasuPop},</if>
  224. <if test="engStat != null and engStat != ''">ENG_STAT = #{engStat},</if>
  225. <if test="startDate != null and startDate != ''">START_DATE = #{startDate},</if>
  226. <if test="compDate != null and compDate != ''">COMP_DATE = STR_TO_DATE(#{compDate},'%Y-%m-%d'),</if>
  227. <if test="note != null and note != ''">NOTE = #{note},</if>
  228. <if test="effDate != null and effDate != ''">EFF_DATE = STR_TO_DATE(#{effDate},'%Y-%m-%d %H:%i:%s'),</if>
  229. <if test="exprDate != null and exprDate != ''">EXPR_DATE = STR_TO_DATE(#{exprDate},'%Y-%m-%d %H:%i:%s'),
  230. </if>
  231. </trim>
  232. <include refid="page_where"/>
  233. </update>
  234. <!-- 其他自定义SQL -->
  235. <select id="queryListByObjId" resultMap="attCwsBaseResultMap" parameterType="string">
  236. SELECT A.EDTR_PESR ,
  237. DATE_FORMAT(A.UPTM,'%Y-%m-%d %H:%i:%s') UPTM,
  238. A.CENTER_X_GD ,
  239. A.CENTER_Y_GD ,
  240. A.ADDVCD ,
  241. A.GUID ,
  242. A.CWS_CODE ,
  243. A.CWS_NAME ,
  244. A.CWS_LONG ,
  245. A.CWS_LAT ,
  246. A.CWS_LOC ,
  247. A.ENG_TYPE ,
  248. A.WASU_TYPE ,
  249. A.WASU_RANG ,
  250. A.DES_WASU_SCAL ,
  251. A.DES_WASU_POP ,
  252. A.ENG_STAT ,
  253. A.START_DATE ,
  254. DATE_FORMAT(COMP_DATE,'%Y-%m-%d') COMP_DATE,
  255. DATE_FORMAT(COMP_DATE,'%Y') COMP_YEAR,
  256. A.NOTE ,
  257. DATE_FORMAT(A.EFF_DATE,'%Y-%m-%d %H:%i:%s') EFF_DATE,
  258. DATE_FORMAT(A.EXPR_DATE,'%Y-%m-%d %H:%i:%s') EXPR_DATE
  259. FROM ATT_CWS_BASE A
  260. RIGHT JOIN BIS_INSP_VLGDRINK_PROJ_MANAGE B
  261. ON A.CWS_CODE=B.CWS_CODE WHERE
  262. B.ENG_ID=#{engId} AND A.ADDVCD=#{adCode} AND A.EXPR_DATE IS NULL
  263. <if test="name !=null and name !=''">
  264. AND A.CWS_NAME LIKE CONCAT('%', #{name}, '%')
  265. </if>
  266. ORDER BY A.GUID
  267. </select>
  268. <select id="queryListByObjIdNotDC" resultMap="attCwsBaseResultMap" parameterType="string">
  269. SELECT A.EDTR_PESR ,
  270. DATE_FORMAT(A.UPTM,'%Y-%m-%d %H:%i:%s') UPTM,
  271. A.CENTER_X_GD ,
  272. A.CENTER_Y_GD ,
  273. A.ADDVCD ,
  274. A.GUID ,
  275. A.CWS_CODE ,
  276. A.CWS_NAME ,
  277. A.CWS_LONG ,
  278. A.CWS_LAT ,
  279. A.CWS_LOC ,
  280. A.ENG_TYPE ,
  281. A.WASU_TYPE ,
  282. A.WASU_RANG ,
  283. A.DES_WASU_SCAL ,
  284. A.DES_WASU_POP ,
  285. A.ENG_STAT ,
  286. A.START_DATE ,
  287. DATE_FORMAT(COMP_DATE,'%Y-%m-%d') COMP_DATE,
  288. DATE_FORMAT(COMP_DATE,'%Y') COMP_YEAR,
  289. A.NOTE ,
  290. DATE_FORMAT(A.EFF_DATE,'%Y-%m-%d %H:%i:%s') EFF_DATE,
  291. DATE_FORMAT(A.EXPR_DATE,'%Y-%m-%d %H:%i:%s') EXPR_DATE
  292. FROM ATT_CWS_BASE A
  293. left JOIN BIS_INSP_VLGDRINK_PROJ_MANAGE B
  294. ON A.CWS_CODE=B.CWS_CODE WHERE
  295. ( B.ENG_ID!=#{engId} OR B.ENG_ID IS NULL)
  296. AND A.ADDVCD=#{adCode} AND A.EXPR_DATE IS NULL
  297. <if test="name !=null and name !=''">
  298. AND A.CWS_NAME LIKE CONCAT('%', #{name}, '%')
  299. </if>
  300. ORDER BY A.GUID
  301. </select>
  302. <select id="getMaxCwsCode" parameterType="string" resultType="string">
  303. SELECT MAX(CWS_CODE) FROM att_cws_base WHERE ADDVCD=#{adCode}
  304. </select>
  305. <select id="queryListWithStatus" resultType="cn.com.goldenwater.dcproj.dto.AttCwsBaseDto" parameterType="string">
  306. SELECT A.EDTR_PESR ,
  307. DATE_FORMAT(A.UPTM,'%Y-%m-%d %H:%i:%s') UPTM,
  308. A.CENTER_X_GD ,
  309. A.CENTER_Y_GD ,
  310. A.ADDVCD ,
  311. A.GUID ,
  312. A.CWS_CODE ,
  313. A.CWS_NAME ,
  314. A.CWS_LONG ,
  315. A.CWS_LAT ,
  316. A.CWS_LOC ,
  317. A.ENG_TYPE ,
  318. A.WASU_TYPE ,
  319. A.WASU_RANG ,
  320. A.DES_WASU_SCAL ,
  321. A.DES_WASU_POP ,
  322. A.ENG_STAT ,
  323. A.START_DATE ,
  324. DATE_FORMAT(COMP_DATE,'%Y-%m-%d') COMP_DATE,
  325. DATE_FORMAT(COMP_DATE,'%Y') COMP_YEAR,
  326. A.NOTE ,
  327. DATE_FORMAT(A.EFF_DATE,'%Y-%m-%d %H:%i:%s') EFF_DATE,
  328. DATE_FORMAT(A.EXPR_DATE,'%Y-%m-%d %H:%i:%s') EXPR_DATE,
  329. CASE WHEN B.ENG_ID = #{engId} THEN 1 ELSE 0 end STATUS
  330. FROM att_cws_base A
  331. LEFT JOIN BIS_INSP_VLGDRINK_PROJ_MANAGE B
  332. ON A.CWS_CODE = B.CWS_CODE
  333. WHERE A.ADDVCD = #{adCode} AND A.EXPR_DATE IS NULL
  334. <if test="name !=null and name !=''">
  335. AND A.CWS_NAME LIKE CONCAT('%', #{name}, '%')
  336. </if>
  337. order by status desc,A.EFF_DATE DESC
  338. </select>
  339. <select id="queryListByRegstrIdNotDC" resultType="cn.com.goldenwater.dcproj.model.AttCwsBase" parameterType="cn.com.goldenwater.dcproj.param.CwsParam">
  340. SELECT *
  341. FROM
  342. (
  343. SELECT
  344. E.*, F.STATUS
  345. FROM ATT_CWS_BASE E
  346. LEFT JOIN
  347. <choose>
  348. <when test="type=='25'.toString()">
  349. (SELECT CWS_CODE, IFNULL(STATUS, '0') STATUS FROM BIS_NEW_COUNTRY_FEE) F
  350. </when>
  351. <otherwise>
  352. (SELECT CWS_CODE, IFNULL(STATUS, '0') STATUS FROM BIS_ZHEJIANG_COUNTRY_FEE) F
  353. </otherwise>
  354. </choose>
  355. ON E.CWS_CODE=F.CWS_CODE
  356. ) S
  357. WHERE
  358. S.STATUS='0'
  359. <if test="name !=null and name !=''">
  360. AND S.CWS_NAME LIKE '%${name}%'
  361. </if>
  362. <if test="adCode !=null and adCode !=''">
  363. AND S.ADDVCD LIKE '${adCode}%'
  364. </if>
  365. <if test="engType !=null and engType !=''">
  366. AND S.ENG_TYPE =#{engType}
  367. </if>
  368. </select>
  369. </mapper>