TaskItemDayDao.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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.TaskItemDayDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.TaskItemDay" id="taskItemDayResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="orgId" column="ORG_ID"/>
  7. <result property="adCode" column="AD_CODE"/>
  8. <result property="adName" column="AD_NAME"/>
  9. <result property="adFullName" column="AD_FULL_NAME"/>
  10. <result property="adGrad" column="AD_GRAD"/>
  11. <result property="tm" column="TM"/>
  12. <result property="objType" column="OBJ_TYPE"/>
  13. <result property="objName" column="OBJ_NAME"/>
  14. <result property="itemName" column="ITEM_NAME"/>
  15. <result property="itemCode" column="ITEM_CODE"/>
  16. <result property="mendSize" column="MEND_SIZE"/>
  17. <result property="pblmLogSize" column="PBLM_LOG_SIZE"/>
  18. <result property="pblmSize" column="PBLM_SIZE"/>
  19. <result property="infoPlbm" column="INFO_PLBM"/>
  20. <result property="warmPlbm" column="WARM_PLBM"/>
  21. <result property="errorPlbm" column="ERROR_PLBM"/>
  22. <result property="intm" column="INTM"/>
  23. <result property="uptm" column="UPTM"/>
  24. <result property="dataStat" column="DATA_STAT"/>
  25. </resultMap>
  26. <sql id="table_columns">
  27. INFO_PLBM,
  28. WARM_PLBM,
  29. ERROR_PLBM,
  30. ID,
  31. ORG_ID,
  32. AD_CODE,
  33. AD_NAME,
  34. AD_FULL_NAME,
  35. AD_GRAD,
  36. TM,
  37. OBJ_TYPE,
  38. OBJ_NAME,
  39. ITEM_NAME,
  40. ITEM_CODE,
  41. MEND_SIZE,
  42. PBLM_LOG_SIZE,
  43. PBLM_SIZE,
  44. INTM,
  45. UPTM,
  46. DATA_STAT
  47. </sql>
  48. <sql id="entity_properties">
  49. #{infoPlbm},
  50. #{warmPlbm},
  51. #{errorPlbm},
  52. #{id},
  53. #{orgId},
  54. #{adCode},
  55. #{adName},
  56. #{adFullName},
  57. #{adGrad},
  58. #{tm},
  59. #{objType},
  60. #{objName},
  61. #{itemName},
  62. #{itemCode},
  63. #{mendSize},
  64. #{pblmLogSize},
  65. #{pblmSize},
  66. #{intm},
  67. #{uptm},
  68. #{dataStat}
  69. </sql>
  70. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  71. <sql id="page_where">
  72. <trim prefix="where" prefixOverrides="and | or ">
  73. <if test="warmPlbm != null and warmPlbm != ''">and WARM_PLBM = #{warmPlbm}</if>
  74. <if test="errorPlbm != null and errorPlbm != ''">and ERROR_PLBM = #{errorPlbm}</if>
  75. <if test="infoPlbm != null and infoPlbm != ''">and INFO_PLBM = #{infoPlbm}</if>
  76. <if test="orgId != null and orgId != ''">and ORG_ID = #{orgId}</if>
  77. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  78. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  79. <if test="adFullName != null and adFullName != ''">and AD_FULL_NAME = #{adFullName}</if>
  80. <if test="adGrad != null and adGrad != ''">and AD_GRAD = #{adGrad}</if>
  81. <if test="tm != null">and TM = #{tm}</if>
  82. <if test="objType != null and objType != ''">and OBJ_TYPE = #{objType}</if>
  83. <if test="objName != null and objName != ''">and OBJ_NAME = #{objName}</if>
  84. <if test="itemName != null and itemName != ''">and ITEM_NAME = #{itemName}</if>
  85. <if test="itemCode != null and itemCode != ''">and ITEM_CODE = #{itemCode}</if>
  86. <if test="mendSize != null and mendSize != ''">and MEND_SIZE = #{mendSize}</if>
  87. <if test="pblmLogSize != null and pblmLogSize != ''">and PBLM_LOG_SIZE = #{pblmLogSize}</if>
  88. <if test="pblmSize != null and pblmSize != ''">and PBLM_SIZE = #{pblmSize}</if>
  89. <if test="intm != null">and INTM = #{intm}</if>
  90. <if test="uptm != null">and UPTM = #{uptm}</if>
  91. and DATA_STAT='0'
  92. </trim>
  93. </sql>
  94. <select id="get" resultMap="taskItemDayResultMap" parameterType="String">
  95. select
  96. <include refid="table_columns"/>
  97. from GW_SYS_TASK_ITEM_DAY where ID = #{id}
  98. </select>
  99. <select id="getBy" resultMap="taskItemDayResultMap">
  100. select
  101. <include refid="table_columns"/>
  102. from GW_SYS_TASK_ITEM_DAY
  103. <include refid="page_where"/>
  104. </select>
  105. <select id="findAll" resultMap="taskItemDayResultMap">
  106. select
  107. <include refid="table_columns"/>
  108. from GW_SYS_TASK_ITEM_DAY
  109. </select>
  110. <select id="findList" resultMap="taskItemDayResultMap">
  111. select
  112. <include refid="table_columns"/>
  113. from GW_SYS_TASK_ITEM_DAY
  114. <include refid="page_where"/>
  115. </select>
  116. <select id="selectCount" resultType="int">
  117. select count(ID) from GW_SYS_TASK_ITEM_DAY
  118. <include refid="page_where"/>
  119. </select>
  120. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.TaskItemDay">
  121. insert into GW_SYS_TASK_ITEM_DAY(
  122. <include refid="table_columns"/>
  123. )
  124. values (
  125. <include refid="entity_properties"/>
  126. )
  127. </insert>
  128. <delete id="delete" parameterType="java.lang.String">
  129. update GW_SYS_TASK_ITEM_DAY set DATA_STAT='9' where ID = #{id}
  130. </delete>
  131. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.TaskItemDay">
  132. update GW_SYS_TASK_ITEM_DAY set DATA_STAT='9'
  133. <include refid="page_where"/>
  134. </delete>
  135. <update id="deleteInFlag" parameterType="java.lang.String">
  136. update GW_SYS_TASK_ITEM_DAY set DATA_STAT = '9' where ID = #{id}
  137. </update>
  138. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.TaskItemDay">
  139. update GW_SYS_TASK_ITEM_DAY
  140. <trim prefix="set" suffixOverrides=",">
  141. <if test="warmPlbm != null and warmPlbm != ''">WARM_PLBM = #{warmPlbm},</if>
  142. <if test="errorPlbm != null and errorPlbm != ''">ERROR_PLBM = #{errorPlbm},</if>
  143. <if test="infoPlbm != null and infoPlbm != ''">INFO_PLBM = #{infoPlbm},</if>
  144. <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
  145. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  146. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  147. <if test="adFullName != null and adFullName != ''">AD_FULL_NAME = #{adFullName},</if>
  148. <if test="adGrad != null and adGrad != ''">AD_GRAD = #{adGrad},</if>
  149. <if test="tm != null">TM = #{tm},</if>
  150. <if test="objType != null and objType != ''">OBJ_TYPE = #{objType},</if>
  151. <if test="objName != null and objName != ''">OBJ_NAME = #{objName},</if>
  152. <if test="itemName != null and itemName != ''">ITEM_NAME = #{itemName},</if>
  153. <if test="itemCode != null and itemCode != ''">ITEM_CODE = #{itemCode},</if>
  154. <if test="mendSize != null and mendSize != ''">MEND_SIZE = #{mendSize},</if>
  155. <if test="pblmLogSize != null and pblmLogSize != ''">PBLM_LOG_SIZE = #{pblmLogSize},</if>
  156. <if test="pblmSize != null and pblmSize != ''">PBLM_SIZE = #{pblmSize},</if>
  157. <if test="intm != null">INTM = #{intm},</if>
  158. <if test="uptm != null">UPTM = #{uptm},</if>
  159. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  160. </trim>
  161. <where>ID = #{id}</where>
  162. </update>
  163. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.TaskItemDay">
  164. update GW_SYS_TASK_ITEM_DAY
  165. <trim prefix="set" suffixOverrides=",">
  166. <if test="warmPlbm != null and warmPlbm != ''">WARM_PLBM = #{warmPlbm},</if>
  167. <if test="errorPlbm != null and errorPlbm != ''">ERROR_PLBM = #{errorPlbm},</if>
  168. <if test="infoPlbm != null and infoPlbm != ''">INFO_PLBM = #{infoPlbm},</if>
  169. <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
  170. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  171. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  172. <if test="adFullName != null and adFullName != ''">AD_FULL_NAME = #{adFullName},</if>
  173. <if test="adGrad != null and adGrad != ''">AD_GRAD = #{adGrad},</if>
  174. <if test="tm != null">TM = #{tm},</if>
  175. <if test="objType != null and objType != ''">OBJ_TYPE = #{objType},</if>
  176. <if test="objName != null and objName != ''">OBJ_NAME = #{objName},</if>
  177. <if test="itemName != null and itemName != ''">ITEM_NAME = #{itemName},</if>
  178. <if test="itemCode != null and itemCode != ''">ITEM_CODE = #{itemCode},</if>
  179. <if test="mendSize != null and mendSize != ''">MEND_SIZE = #{mendSize},</if>
  180. <if test="pblmLogSize != null and pblmLogSize != ''">PBLM_LOG_SIZE = #{pblmLogSize},</if>
  181. <if test="pblmSize != null and pblmSize != ''">PBLM_SIZE = #{pblmSize},</if>
  182. <if test="intm != null">INTM = #{intm},</if>
  183. <if test="uptm != null">UPTM = #{uptm},</if>
  184. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  185. </trim>
  186. <include refid="page_where"/>
  187. </update>
  188. <!-- 其他自定义SQL -->
  189. <!-- <select id="findForCity" resultType="cn.com.goldenwater.dcproj.model.TaskItemDay">-->
  190. <!-- SELECT-->
  191. <!-- A.AD_CODE, A.AD_NAME, A.LGTD, A.LTTD, T.ITEM_NAME,-->
  192. <!-- SUM(PBLM_SIZE) PBLM_SIZE, SUM(MEND_SIZE) MEND_SIZE,-->
  193. <!-- SUM(INFO_PLBM) INFO_PLBM, SUM(WARM_PLBM) WARM_PLBM, SUM(ERROR_PLBM) ERROR_PLBM,-->
  194. <!-- SUM(PBLM_LOG_SIZE) PBLM_LOG_SIZE-->
  195. <!-- FROM (SELECT * FROM ATT_AD_BASE WHERE AD_CODE LIKE '${province}%'-->
  196. <!-- <choose>-->
  197. <!-- <when test='adGrad == "4" '>-->
  198. <!-- AND AD_CODE = SUBSTR(AD_CODE, 0, 6) || '000000'-->
  199. <!-- </when>-->
  200. <!-- <otherwise>-->
  201. <!-- AND AD_CODE = SUBSTR(AD_CODE, 0, 4) || '00000000'-->
  202. <!-- </otherwise>-->
  203. <!-- </choose>-->
  204. <!-- and AD_CODE != SUBSTR(AD_CODE, 0, 2) || '0000000000') A-->
  205. <!-- LEFT JOIN (-->
  206. <!-- SELECT-->
  207. <!-- ID, ORG_ID,-->
  208. <!-- <choose>-->
  209. <!-- <when test='adGrad == "4" '>-->
  210. <!-- SUBSTR(AD_CODE, 0, 6) || '000000' AD_CODE,-->
  211. <!-- </when>-->
  212. <!-- <otherwise>-->
  213. <!-- SUBSTR(AD_CODE, 0, 4) || '00000000' AD_CODE,-->
  214. <!-- </otherwise>-->
  215. <!-- </choose> AD_FULL_NAME,-->
  216. <!-- TM, OBJ_TYPE, OBJ_NAME, ITEM_NAME, PBLM_SIZE, MEND_SIZE, PBLM_LOG_SIZE,-->
  217. <!-- INFO_PLBM, WARM_PLBM, ERROR_PLBM, DATA_STAT-->
  218. <!-- FROM GW_SYS_TASK_ITEM_DAY-->
  219. <!-- where-->
  220. <!-- DATA_STAT='0'-->
  221. <!-- and AD_CODE != SUBSTR(AD_CODE, 0, 2) || '0000000000'-->
  222. <!-- <if test="warmPlbm != null and warmPlbm != ''">and WARM_PLBM = #{warmPlbm}</if>-->
  223. <!-- <if test="errorPlbm != null and errorPlbm != ''">and ERROR_PLBM = #{errorPlbm}</if>-->
  224. <!-- <if test="infoPlbm != null and infoPlbm != ''">and INFO_PLBM = #{infoPlbm}</if>-->
  225. <!-- <if test="orgId != null and orgId != ''">and ORG_ID = #{orgId}</if>-->
  226. <!-- <if test="adCode != null and adCode != ''">and AD_CODE LIKE '${adCode}%' </if>-->
  227. <!-- <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>-->
  228. <!-- <if test="adFullName != null and adFullName != ''">and AD_FULL_NAME = #{adFullName}</if>-->
  229. <!-- <if test="tm != null">and TO_CHAR(TM, 'YYYY-MM-DD') = TO_CHAR(#{tm}, 'YYYY-MM-DD')</if>-->
  230. <!-- <if test="objType != null and objType != ''">and OBJ_TYPE = #{objType}</if>-->
  231. <!-- <if test="objName != null and objName != ''">and OBJ_NAME = #{objName}</if>-->
  232. <!-- <if test="itemName != null and itemName != ''">and ITEM_NAME = #{itemName}</if>-->
  233. <!-- <if test="itemCode != null and itemCode != ''">and ITEM_CODE = #{itemCode}</if>-->
  234. <!-- <if test="mendSize != null and mendSize != ''">and MEND_SIZE = #{mendSize}</if>-->
  235. <!-- <if test="pblmLogSize != null and pblmLogSize != ''">and PBLM_LOG_SIZE = #{pblmLogSize}</if>-->
  236. <!-- <if test="pblmSize != null and pblmSize != ''">and PBLM_SIZE = #{pblmSize}</if>-->
  237. <!-- <if test="intm != null">and INTM = #{intm}</if>-->
  238. <!-- <if test="uptm != null">and UPTM = #{uptm}</if>-->
  239. <!-- <if test="sttm != null and sttm != '' and entm != null and entm != '' ">-->
  240. <!-- and to_date(to_CHAR(TM, '%Y-%m-%d'), '%Y-%m-%d')-->
  241. <!-- between to_date(substr(#{sttm}, 0, 10), '%Y-%m-%d') and to_date(substr(#{entm}, 0, 10), '%Y-%m-%d')-->
  242. <!-- </if>-->
  243. <!-- ) T ON T.AD_CODE = A.AD_CODE-->
  244. <!-- <where>-->
  245. <!-- <if test="adGrad != null and adGrad != ''">and A.AD_GRAD = #{adGrad}</if>-->
  246. <!-- </where>-->
  247. <!-- GROUP BY A.AD_CODE, A.AD_NAME, A.LGTD, A.LTTD, T.ITEM_NAME-->
  248. <!-- ORDER BY A.AD_CODE, T.ITEM_NAME-->
  249. <!-- </select>-->
  250. <select id="findForCity" resultType="cn.com.goldenwater.dcproj.model.TaskItemDay">
  251. SELECT
  252. A.AD_CODE, A.AD_NAME, A.LGTD, A.LTTD, T.ITEM_NAME,
  253. SUM(PBLM_SIZE) PBLM_SIZE, SUM(MEND_SIZE) MEND_SIZE,
  254. SUM(INFO_PLBM) INFO_PLBM, SUM(WARM_PLBM) WARM_PLBM, SUM(ERROR_PLBM) ERROR_PLBM,
  255. SUM(PBLM_LOG_SIZE) PBLM_LOG_SIZE
  256. FROM (SELECT * FROM ATT_AD_BASE WHERE AD_CODE LIKE '${adCode}%'
  257. <choose>
  258. <when test='adGrad == "4" '>
  259. AND AD_CODE = concat(SUBSTR(AD_CODE, 1, 6) || '000000')
  260. </when>
  261. <otherwise>
  262. AND AD_CODE = concat(SUBSTR(AD_CODE, 1, 4) || '00000000')
  263. </otherwise>
  264. </choose>
  265. <if test="adGrad != null and adGrad != ''">and AD_GRAD = #{adGrad}</if>
  266. ) A
  267. LEFT JOIN (
  268. SELECT
  269. <choose>
  270. <when test='adGrad == "4" '>
  271. concat(SUBSTR(AD_CODE, 1, 6) || '000000') AD_CODE,
  272. </when>
  273. <otherwise>
  274. concat(SUBSTR(AD_CODE, 1, 4) || '00000000') AD_CODE,
  275. </otherwise>
  276. </choose>
  277. TM, OBJ_TYPE, ITEM_NAME, PBLM_SIZE, MEND_SIZE, PBLM_LOG_SIZE,
  278. INFO_PLBM, WARM_PLBM, ERROR_PLBM, ERRORS_PLBM
  279. FROM (
  280. SELECT
  281. OBJ_AD_CODE AS "AD_CODE",
  282. obj_type,
  283. coll_time AS "TM",
  284. A.INSP_PBLM_NAME AS "ITEM_NAME",
  285. COUNT(A.PBLM_ID) AS "PBLM_SIZE",
  286. 0 AS "MEND_SIZE",
  287. 0 AS "PBLM_LOG_SIZE",
  288. SUM(CASE A.INSP_PBLM_CATE WHEN '0' THEN 1 ELSE 0 END) INFO_PLBM,
  289. SUM(CASE A.INSP_PBLM_CATE WHEN '1' THEN 1 ELSE 0 END) WARM_PLBM,
  290. SUM(CASE A.INSP_PBLM_CATE WHEN '2' THEN 1 ELSE 0 END) ERROR_PLBM,
  291. SUM(CASE A.INSP_PBLM_CATE WHEN '3' THEN 1 ELSE 0 END) ERRORS_PLBM
  292. FROM BIS_INSP_PBLM A
  293. GROUP BY OBJ_AD_CODE, obj_type, coll_time, INSP_PBLM_NAME
  294. ) o
  295. <where>
  296. <if test="adCode != null and adCode != ''">and AD_CODE LIKE '${adCode}%'</if>
  297. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  298. <if test="objType != null and objType != ''">and OBJ_TYPE = #{objType}</if>
  299. <if test="itemName != null and itemName != ''">and ITEM_NAME = #{itemName}</if>
  300. <if test="sttm != null and sttm != '' and entm != null and entm != '' ">
  301. and str_to_date(DATE_FORMAT(TM, '%Y-%m-%d'), '%Y-%m-%d')
  302. between str_to_date(substr(#{sttm}, 1, 10), '%Y-%m-%d') and str_to_date(substr(#{entm}, 1, 10), '%Y-%m-%d')
  303. </if>
  304. </where>
  305. ) T ON T.AD_CODE = A.AD_CODE
  306. GROUP BY A.AD_CODE, A.AD_NAME, A.LGTD, A.LTTD, T.ITEM_NAME
  307. ORDER BY A.AD_CODE, T.ITEM_NAME
  308. </select>
  309. </mapper>