ShowYdtsMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.railway.business.bi.mapper.ShowYdtsMapper">
  5. <resultMap id="BaseResultMap" type="com.railway.business.bi.domain.ShowYdts">
  6. <result column="id" property="id"/>
  7. <result column="branch_name" property="branchName"/>
  8. <result column="dept_name" property="deptName"/>
  9. <result column="line_sddj" property="lineSddj"/>
  10. <result column="line_name" property="lineName"/>
  11. <result column="station_name" property="stationName"/>
  12. <result column="line_xz" property="lineXz"/>
  13. <result column="substation_name" property="substationName"/>
  14. <result column="switch_high" property="switchHigh"/>
  15. <result column="switch_low" property="switchLow"/>
  16. <result column="last_year" property="lastYear"/>
  17. <result column="plan_month" property="planMonth"/>
  18. <result column="overdue_reminder" property="overdueReminder"/>
  19. <result column="completion_date" property="completionDate"/>
  20. <result column="jhtzjy" property="jhtzjy"/>
  21. <result column="overdue_reason" property="overdueReason"/>
  22. <result column="create_by" property="createBy"/>
  23. <result column="create_time" property="createTime"/>
  24. <result column="update_by" property="updateBy"/>
  25. <result column="update_time" property="updateTime"/>
  26. <result column="file_id" property="fileId"/>
  27. <result column="del_flag" property="delFlag"/>
  28. </resultMap>
  29. <sql id="Base_Column_List">
  30. id,
  31. branch_name,
  32. dept_name,
  33. line_sddj,
  34. line_name,
  35. station_name,
  36. line_xz,
  37. substation_name,
  38. switch_high,
  39. switch_low,
  40. last_year,
  41. plan_month,
  42. overdue_reminder,
  43. completion_date,
  44. jhtzjy,
  45. overdue_reason,
  46. create_by,
  47. create_time,
  48. update_by,
  49. update_time,
  50. del_flag,
  51. file_id
  52. </sql>
  53. <insert id="insert" parameterType="com.railway.business.bi.domain.ShowYdts">
  54. INSERT INTO show_ydts
  55. <trim prefix="(" suffix=")" suffixOverrides=",">
  56. <if test='null != branchName'>
  57. branch_name,
  58. </if>
  59. <if test='null != deptName'>
  60. dept_name,
  61. </if>
  62. <if test='null != lineSddj'>
  63. line_sddj,
  64. </if>
  65. <if test='null != lineName'>
  66. line_name,
  67. </if>
  68. <if test='null != stationName'>
  69. station_name,
  70. </if>
  71. <if test='null != lineXz'>
  72. line_xz,
  73. </if>
  74. <if test='null != substationName'>
  75. substation_name,
  76. </if>
  77. <if test='null != switchHigh'>
  78. switch_high,
  79. </if>
  80. <if test='null != switchLow'>
  81. switch_low,
  82. </if>
  83. <if test='null != lastYear'>
  84. last_year,
  85. </if>
  86. <if test='null != planMonth'>
  87. plan_month,
  88. </if>
  89. <if test='null != overdueReminder'>
  90. overdue_reminder,
  91. </if>
  92. <if test='null != completionDate'>
  93. completion_date,
  94. </if>
  95. <if test='null != jhtzjy'>
  96. jhtzjy,
  97. </if>
  98. <if test='null != overdueReason'>
  99. overdue_reason,
  100. </if>
  101. <if test='null != createBy'>
  102. create_by,
  103. </if>
  104. <if test='null != createTime'>
  105. create_time,
  106. </if>
  107. <if test='null != fileId'>
  108. file_id,
  109. </if>
  110. <if test='null != delFlag'>
  111. del_flag
  112. </if>
  113. </trim>
  114. <trim prefix="values (" suffix=")" suffixOverrides=",">
  115. <if test='null != branchName'>
  116. #{branchName},
  117. </if>
  118. <if test='null != deptName'>
  119. #{deptName},
  120. </if>
  121. <if test='null != lineSddj'>
  122. #{lineSddj},
  123. </if>
  124. <if test='null != lineName'>
  125. #{lineName},
  126. </if>
  127. <if test='null != stationName'>
  128. #{stationName},
  129. </if>
  130. <if test='null != lineXz'>
  131. #{lineXz},
  132. </if>
  133. <if test='null != substationName'>
  134. #{substationName},
  135. </if>
  136. <if test='null != switchHigh'>
  137. #{switchHigh},
  138. </if>
  139. <if test='null != switchLow'>
  140. #{switchLow},
  141. </if>
  142. <if test='null != lastYear'>
  143. #{lastYear},
  144. </if>
  145. <if test='null != planMonth'>
  146. #{planMonth},
  147. </if>
  148. <if test='null != overdueReminder'>
  149. #{overdueReminder},
  150. </if>
  151. <if test='null != completionDate'>
  152. #{completionDate},
  153. </if>
  154. <if test='null != jhtzjy'>
  155. #{jhtzjy},
  156. </if>
  157. <if test='null != overdueReason'>
  158. #{overdueReason},
  159. </if>
  160. <if test='null != createBy'>
  161. #{createBy},
  162. </if>
  163. <if test='null != createTime'>
  164. #{createTime},
  165. </if>
  166. <if test='null != fileId'>
  167. #{fileId},
  168. </if>
  169. <if test='null != delFlag'>
  170. #{delFlag}
  171. </if>
  172. </trim>
  173. </insert>
  174. <delete id="delete">
  175. UPDATE show_ydts
  176. set del_flag='1'
  177. WHERE id = #{id}
  178. </delete>
  179. <update id="update" parameterType="com.railway.business.bi.domain.ShowYdts">
  180. UPDATE show_ydts
  181. <set>
  182. <if test='null != branchName'>branch_name = #{branchName},</if>
  183. <if test='null != deptName'>dept_name = #{deptName},</if>
  184. <if test='null != lineSddj'>line_sddj = #{lineSddj},</if>
  185. <if test='null != lineName'>line_name = #{lineName},</if>
  186. <if test='null != stationName'>station_name = #{stationName},</if>
  187. <if test='null != lineXz'>line_xz = #{lineXz},</if>
  188. <if test='null != substationName'>substation_name = #{substationName},</if>
  189. <if test='null != switchHigh'>switch_high = #{switchHigh},</if>
  190. <if test='null != switchLow'>switch_low = #{switchLow},</if>
  191. <if test='null != lastYear'>last_year = #{lastYear},</if>
  192. <if test='null != planMonth'>plan_month = #{planMonth},</if>
  193. <if test='null != overdueReminder'>overdue_reminder = #{overdueReminder},</if>
  194. <if test='null != completionDate'>completion_date = #{completionDate},</if>
  195. <if test='null != jhtzjy'>jhtzjy = #{jhtzjy},</if>
  196. <if test='null != overdueReason'>overdue_reason = #{overdueReason},</if>
  197. <if test='null != updateBy'>update_by = #{updateBy},</if>
  198. <if test='null != updateTime'>update_time = #{updateTime},</if>
  199. <if test='null != fileId'>file_id = #{fileId},</if>
  200. <if test='null != delFlag'>del_flag = #{delFlag}</if>
  201. </set>
  202. WHERE id = #{id}
  203. </update>
  204. <select id="getInfo" resultMap="BaseResultMap">
  205. SELECT
  206. <include refid="Base_Column_List"/>
  207. FROM show_ydts
  208. WHERE del_flag='0' and id = #{id}
  209. </select>
  210. <select id="getList" resultMap="BaseResultMap">
  211. SELECT
  212. <include refid="Base_Column_List"/>
  213. FROM show_ydts
  214. <where>
  215. del_flag='0'
  216. and file_id = (select max(id) from show_file where data_type = 'scrw' and imp_result = '1')
  217. <if test="lineName!=null and lineName!=''">
  218. and line_name like concat('%', #{lineName}, '%')
  219. </if>
  220. <if test="planMonth!=null and planMonth!=''">
  221. and plan_month like concat('%', #{planMonth})
  222. </if>
  223. </where>
  224. </select>
  225. <select id="getLineList" resultType="java.lang.String">
  226. SELECT distinct line_name
  227. FROM show_ydts
  228. <where>
  229. del_flag='0'
  230. and file_id = (select max(id) from show_file where data_type = 'scrw' and imp_result = '1')
  231. </where>
  232. </select>
  233. <resultMap id="TotalResultMap" type="com.railway.business.bi.domain.vo.QuarterTotalVO">
  234. <result column="plan1" property="plan1"/>
  235. <result column="plan2" property="plan2"/>
  236. <result column="plan3" property="plan3"/>
  237. <result column="plan4" property="plan4"/>
  238. <result column="actual1" property="actual1"/>
  239. <result column="actual2" property="actual2"/>
  240. <result column="actual3" property="actual3"/>
  241. <result column="actual4" property="actual4"/>
  242. </resultMap>
  243. <select id="getYdtsTotal" resultMap="TotalResultMap">
  244. select sum(plan1) as plan1, sum(plan2) as plan2, sum(plan3) as plan3, sum(plan4) as plan4,
  245. sum(actual1) as actual1, sum(actual2) as actual2, sum(actual3) as actual3, sum(actual4) as actual4
  246. from(
  247. select
  248. case when plan_month>=1 and plan_month <![CDATA[<=]]> 3 then 1 else 0 end as plan1,
  249. case when plan_month>=4 and plan_month <![CDATA[<=]]> 6 then 1 else 0 end as plan2,
  250. case when plan_month>=7 and plan_month <![CDATA[<=]]> 9 then 1 else 0 end as plan3,
  251. case when plan_month>=10 and plan_month <![CDATA[<=]]> 12 then 1 else 0 end as plan4,
  252. case when QUARTER(completion_date)=1 then 1 else 0 end as actual1,
  253. case when QUARTER(completion_date)=2 then 1 else 0 end as actual2,
  254. case when QUARTER(completion_date)=3 then 1 else 0 end as actual3,
  255. case when QUARTER(completion_date)=4 then 1 else 0 end as actual4
  256. from show_ydts
  257. where del_flag='0'
  258. and file_id = (select max(id) from show_file where data_type = 'scrw' and imp_result = '1')
  259. ) a
  260. </select>
  261. <resultMap id="SingleTotalResultMap" type="com.railway.business.bi.domain.vo.SingleTotalVO">
  262. <result column="plan" property="plan"/>
  263. <result column="actual" property="actual"/>
  264. </resultMap>
  265. <select id="getYdtsTotalByDate" resultMap="SingleTotalResultMap">
  266. select sum(plan) as plan,
  267. sum(actual) as actual
  268. from(
  269. select
  270. case when plan_month = #{month} then 1 else 0 end as plan,
  271. case when completion_date>=#{startDate}
  272. and completion_date <![CDATA[<=]]> #{endDate} then 1 else 0 end as actual
  273. from show_ydts
  274. where del_flag='0'
  275. and file_id = (select max(id) from show_file where data_type = 'scrw' and imp_result = '1')
  276. ) a
  277. </select>
  278. <select id="countUndone" resultType="java.lang.Integer">
  279. select count(*)
  280. from show_ydts
  281. where del_flag='0'
  282. and file_id = (select max(id) from show_file where data_type = 'scrw' and imp_result = '1')
  283. and plan_month = #{month} and (completion_date is null or completion_date = '')
  284. </select>
  285. <select id="countByywc" resultType="java.lang.Integer">
  286. select count(*)
  287. from show_gsd
  288. where del_flag='0'
  289. and file_id = (select max(id) from show_file where data_type = 'scrw' and imp_result = '1')
  290. and plan_month = #{month} and completion_date is not null and completion_date != '';
  291. </select>
  292. <select id="countBywwc" resultType="java.lang.Integer">
  293. select count(*)
  294. from show_gsd
  295. where del_flag='0'
  296. and file_id = (select max(id) from show_file where data_type = 'scrw' and imp_result = '1')
  297. and plan_month = #{month} and (completion_date is null or completion_date = '')
  298. </select>
  299. <select id="countXyjhwc" resultType="java.lang.Integer">
  300. select count(*)
  301. from show_gsd
  302. where del_flag='0'
  303. and file_id = (select max(id) from show_file where data_type = 'scrw' and imp_result = '1')
  304. and plan_month = #{month}
  305. </select>
  306. <select id="countNdsys" resultType="java.lang.Integer">
  307. select count(*)
  308. from show_gsd
  309. where del_flag='0'
  310. and file_id = (select max(id) from show_file where data_type = 'scrw' and imp_result = '1')
  311. and (completion_date is null or completion_date = '')
  312. </select>
  313. <select id="listWwcmx" resultType="java.lang.String">
  314. select substation_name
  315. from show_gsd
  316. where del_flag='0'
  317. and file_id = (select max(id) from show_file where data_type = 'scrw' and imp_result = '1')
  318. and plan_month = #{month} and (completion_date is null or completion_date = '')
  319. </select>
  320. </mapper>