PlanInputMapper.xml 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258
  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="PlanInputMapper">
  4. <select id="companyInputChartData" parameterType="pd" resultType="pd">
  5. select PCOMPANY as COMPANY,
  6. sum(ifnull(DAILY_COMPLETE,0) + ifnull(MINOR_PREVENTION_COMPLETE,0) + ifnull(MIDDLE_PREVENTION_COMPLETE,0) + ifnull(OVERHAUL_PREVENTION_COMPLETE,0)
  7. + ifnull(MINOR_REPAIR_COMPLETE,0) + ifnull(MIDDLE_REPAIR_COMPLETE,0) + ifnull(OVERHAUL_COMPLETE,0)
  8. + ifnull(SPECIAL_COMPLETE,0) + ifnull(TEST_COMPLETE,0) + ifnull(SCIENTIFIC_COMPLETE,0) + ifnull(DEVICE_COMPLETE,0) + ifnull(RESERVE_COMPLETE,0) + ifnull(EMERGENCY_COMPLETE,0))
  9. as DAILY_COMPLETE
  10. from annual_comp_sumtable_view
  11. <if test="YEAR!= ''">
  12. where YEAR = #{YEAR}
  13. </if>
  14. group by PCOMPANY_ID
  15. </select>
  16. <select id="chartsData" parameterType="pd" resultType="pd">
  17. select YEAR,
  18. sum(ifnull(DAILY_COMPLETE,0) + ifnull(MINOR_PREVENTION_COMPLETE,0) + ifnull(MIDDLE_PREVENTION_COMPLETE,0) + ifnull(OVERHAUL_PREVENTION_COMPLETE,0)
  19. + ifnull(MINOR_REPAIR_COMPLETE,0) + ifnull(MIDDLE_REPAIR_COMPLETE,0) + ifnull(OVERHAUL_COMPLETE,0)
  20. + ifnull(SPECIAL_COMPLETE,0) + ifnull(TEST_COMPLETE,0) + ifnull(SCIENTIFIC_COMPLETE,0) + ifnull(DEVICE_COMPLETE,0) + ifnull(RESERVE_COMPLETE,0) + ifnull(EMERGENCY_COMPLETE,0))
  21. as DAILY_COMPLETE,
  22. sum(ifnull(DAILY_DESIGN,0) + ifnull(MINOR_PREVENTION_DESIGN,0) + ifnull(MIDDLE_PREVENTION_DESIGN,0) + ifnull(OVERHAUL_PREVENTION_DESIGN,0)
  23. + ifnull(MINOR_REPAIR_DESIGN,0) + ifnull(MIDDLE_REPAIR_DESIGN,0) + ifnull(OVERHAUL_DESIGN,0)
  24. + ifnull(SPECIAL_DESIGN,0) + ifnull(TEST_DESIGN,0) + ifnull(SCIENTIFIC_DESIGN,0) + ifnull(DEVICE_DESIGN,0) + ifnull(RESERVE_DESIGN,0) + ifnull(EMERGENCY_DESIGN,0))
  25. as DAILY_DESIGN
  26. from annual_comp_sumtable_view
  27. <if test="companyName!= ''">
  28. where PCOMPANY = #{companyName}
  29. </if>
  30. group by YEAR
  31. order by YEAR
  32. </select>
  33. <select id="projectInputChartsData" parameterType="pd" resultType="pd">
  34. select CATEGORY,sum(ACTUAL_COST) as ACTUAL_COST from (
  35. select a.YEAR,CATEGORY,ACTUAL_COST
  36. from monthly_prevention_completion a left join highway_prevention_project_dettable b
  37. on a.COMPANY_ID = b.COMPANY_ID and a.YEAR = b.YEAR
  38. and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  39. <if test="YEAR!= '' ">
  40. where a.YEAR = #{YEAR}
  41. </if>
  42. <if test="companyName!= ''">
  43. and a.COMPANY = #{companyName}
  44. </if>
  45. union all
  46. select a.YEAR,CATEGORY,ACTUAL_COST
  47. from monthly_repair_completion a left join highway_repair_project_dettable b
  48. on a.COMPANY_ID = b.COMPANY_ID and a.YEAR = b.YEAR
  49. and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  50. <if test="YEAR!= '' ">
  51. where a.YEAR = #{YEAR}
  52. </if>
  53. <if test="companyName!= ''">
  54. and a.COMPANY = #{companyName}
  55. </if>
  56. union all
  57. select a.YEAR,CATEGORY,ACTUAL_COST
  58. from monthly_special_completion a left join highway_special_project_dettable b
  59. on a.COMPANY_ID = b.COMPANY_ID and a.YEAR = b.YEAR
  60. and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  61. <if test="YEAR!= '' ">
  62. where a.YEAR = #{YEAR}
  63. </if>
  64. <if test="companyName!= ''">
  65. and a.COMPANY = #{companyName}
  66. </if>
  67. union all
  68. select a.YEAR,CATEGORY,ACTUAL_COST
  69. from monthly_test_project_completion a left join highway_test_project_dettable b
  70. on a.COMPANY_ID = b.COMPANY_ID and a.YEAR = b.YEAR
  71. and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  72. <if test="YEAR!= '' ">
  73. where a.YEAR = #{YEAR}
  74. </if>
  75. <if test="companyName!= ''">
  76. and a.COMPANY = #{companyName}
  77. </if>
  78. union all
  79. select a.YEAR,CATEGORY,ACTUAL_COST
  80. from monthly_scientific_project_completion a left join highway_scientific_project_dettable b
  81. on a.COMPANY_ID = b.COMPANY_ID and a.YEAR = b.YEAR
  82. and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  83. <if test="YEAR!= '' ">
  84. where a.YEAR = #{YEAR}
  85. </if>
  86. <if test="companyName!= ''">
  87. and a.COMPANY = #{companyName}
  88. </if>
  89. union all
  90. select a.YEAR,CATEGORY,ACTUAL_COST
  91. from monthly_emergency_completion a left join highway_emergency_project_dettable b
  92. on a.COMPANY_ID = b.COMPANY_ID and a.YEAR = b.YEAR
  93. and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  94. <if test="YEAR!= '' ">
  95. where a.YEAR = #{YEAR}
  96. </if>
  97. <if test="companyName!= ''">
  98. and a.COMPANY = #{companyName}
  99. </if>
  100. )a
  101. group by CATEGORY
  102. </select>
  103. <select id="getCompanyList" parameterType="String" resultType="pd">
  104. select NAME,BIANMA from oa_department
  105. where PARENT_ID = '0'
  106. <if test="_parameter != ''">
  107. and NAME = #{_parameter}
  108. </if>
  109. ORDER BY BIANMA ASC
  110. </select>
  111. <select id="getDataByScale" parameterType="pd" resultType="pd">
  112. select e.* from (
  113. select
  114. @f:= case when @company_id2=c.company_id then '0' else '1' end as flag,
  115. @company_id2:=c.company_id1 as company_id2,
  116. c.*,cast(num as char) as numstr
  117. from (
  118. SELECT
  119. @r:= case when @company_id=a.company_id then @r+1 else 1 end num,
  120. @company_id:=a.company_id as company_id1,
  121. a.*
  122. from(
  123. select COMPANY,COMPANY_ID,ROAD_ID,ROAD,<include refid="scaleCol"></include>
  124. from (
  125. <if test="datatype == 1">
  126. <include refid="planByscale"></include>
  127. </if>
  128. <if test="datatype == 2">
  129. <include refid="compByscale"></include>
  130. </if>
  131. ) tab
  132. where cost is not null
  133. group by COMPANY,COMPANY_ID,ROAD_ID,ROAD
  134. order by COMPANY,COMPANY_ID,ROAD_ID,ROAD
  135. )a
  136. ,(select @r:=0 ,@company_id:='',@c:=1) b
  137. order by company_id,num desc
  138. )c
  139. ,(select @f:=0,@company_id2:='') d
  140. )e
  141. order by company_id,road_id
  142. </select>
  143. <select id="getData" parameterType="pd" resultType="pd">
  144. select e.* from (
  145. select
  146. @f:= case when @company_id2=c.company_id then '0' else '1' end as flag,
  147. @company_id2:=c.company_id1 as company_id2,
  148. c.*,cast(num as char) as numstr
  149. from (
  150. SELECT
  151. @r:= case when @company_id=a.company_id then @r+1 else 1 end num,
  152. @company_id:=a.company_id as company_id1,
  153. a.*
  154. from(
  155. select COMPANY,COMPANY_ID,ROAD_ID,ROAD,<include refid="col"></include>
  156. from (
  157. <if test="datatype == 1">
  158. <include refid="plan"></include>
  159. </if>
  160. <if test="datatype == 2">
  161. <include refid="comp"></include>
  162. </if>
  163. ) tab
  164. where cost is not null
  165. group by COMPANY,COMPANY_ID,ROAD_ID,ROAD
  166. order by COMPANY,COMPANY_ID,ROAD_ID,ROAD
  167. )a
  168. ,(select @r:=0 ,@company_id:='',@c:=1) b
  169. order by company_id,num desc
  170. )c
  171. ,(select @f:=0,@company_id2:='') d
  172. )e
  173. order by company_id,road_id
  174. </select>
  175. <select id="getSumDataByScale" parameterType="pd" resultType="pd">
  176. select
  177. <if test="groupByCompany == 1">
  178. COMPANY,COMPANY_ID,
  179. </if>
  180. <include refid="scaleCol"></include>
  181. from (
  182. <if test="datatype == 1">
  183. <include refid="planByscale"></include>
  184. </if>
  185. <if test="datatype == 2">
  186. <include refid="compByscale"></include>
  187. </if>
  188. ) tab
  189. where cost is not null
  190. <if test="groupByCompany == 1">
  191. group by COMPANY,COMPANY_ID
  192. order by COMPANY_ID
  193. </if>
  194. </select>
  195. <select id="getSumData" parameterType="pd" resultType="pd">
  196. select
  197. <if test="groupByCompany == 1">
  198. COMPANY,COMPANY_ID,
  199. </if>
  200. <include refid="col"></include>
  201. from (
  202. <if test="datatype == 1">
  203. <include refid="plan"></include>
  204. </if>
  205. <if test="datatype == 2">
  206. <include refid="comp"></include>
  207. </if>
  208. ) tab
  209. where cost is not null
  210. <if test="groupByCompany == 1">
  211. group by COMPANY,COMPANY_ID
  212. order by COMPANY_ID
  213. </if>
  214. </select>
  215. <sql id="col">
  216. sum(CASE WHEN(type='daily' and category='路基') THEN cost ELSE NULL END ) as daily_subgrade,
  217. sum(CASE WHEN(type='daily' and category='路面') THEN cost ELSE NULL END ) as daily_pavement,
  218. sum(CASE WHEN(type='daily' and category='桥梁') THEN cost ELSE NULL END ) as daily_bridge,
  219. sum(CASE WHEN(type='daily' and category='涵洞通道') THEN cost ELSE NULL END ) as daily_culvert,
  220. sum(CASE WHEN(type='daily' and category='隧道') THEN cost ELSE NULL END ) as daily_tunnel,
  221. sum(CASE WHEN(type='daily' and category='交安设施') THEN cost ELSE NULL END ) as daily_safe,
  222. sum(CASE WHEN(type='daily' and category='沿线设施') THEN cost ELSE NULL END ) as daily_line,
  223. sum(CASE WHEN(type='daily' and category='绿化') THEN cost ELSE NULL END ) as daily_green,
  224. sum(CASE WHEN(type='daily' and category='清扫保洁') THEN cost ELSE NULL END ) as daily_clean,
  225. sum(CASE WHEN(type='daily' and category='巡查检查') THEN cost ELSE NULL END ) as daily_patrol,
  226. sum(CASE WHEN(type='daily' and category='养护车辆设备') THEN cost ELSE NULL END ) as daily_car,
  227. sum(CASE WHEN(type='daily' and category='应急保通') THEN cost ELSE NULL END ) as daily_emergency,
  228. sum(CASE WHEN(type='prevention' and category='路基') THEN cost ELSE NULL END ) as prevention_subgrade,
  229. sum(CASE WHEN(type='prevention' and category='路面') THEN cost ELSE NULL END ) as prevention_pavement,
  230. sum(CASE WHEN(type='prevention' and category='桥涵') THEN cost ELSE NULL END ) as prevention_bridgeAndCulvert,
  231. sum(CASE WHEN(type='prevention' and category='隧道') THEN cost ELSE NULL END ) as prevention_tunnel,
  232. sum(CASE WHEN(type='repair' and category='路基') THEN cost ELSE NULL END ) as repair_subgrade,
  233. sum(CASE WHEN(type='repair' and category='路面') THEN cost ELSE NULL END ) as repair_pavement,
  234. sum(CASE WHEN(type='repair' and category='桥涵') THEN cost ELSE NULL END ) as repair_bridgeAndCulvert,
  235. sum(CASE WHEN(type='repair' and category='隧道') THEN cost ELSE NULL END ) as repair_tunnel,
  236. sum(CASE WHEN(type='repair' and category='交安设施') THEN cost ELSE NULL END ) as repair_safe,
  237. sum(CASE WHEN(type='repair' and category='沿线设施') THEN cost ELSE NULL END ) as repair_line,
  238. sum(CASE WHEN(type='repair' and category='绿化') THEN cost ELSE NULL END ) as repair_green,
  239. sum(CASE WHEN(type='repair' and category='其他') THEN cost ELSE NULL END ) as repair_other,
  240. sum(CASE WHEN(type='special' and category='路基') THEN cost ELSE NULL END ) as special_subgrade,
  241. sum(CASE WHEN(type='special' and category='路面') THEN cost ELSE NULL END ) as special_pavement,
  242. sum(CASE WHEN(type='special' and category='桥涵') THEN cost ELSE NULL END ) as special_bridgeAndCulvert,
  243. sum(CASE WHEN(type='special' and category='隧道') THEN cost ELSE NULL END ) as special_tunnel,
  244. sum(CASE WHEN(type='special' and category='交安设施') THEN cost ELSE NULL END ) as special_safe,
  245. sum(CASE WHEN(type='special' and category='沿线设施') THEN cost ELSE NULL END ) as special_line,
  246. sum(CASE WHEN(type='special' and category='绿化') THEN cost ELSE NULL END ) as special_green,
  247. sum(CASE WHEN(type='special' and category='其他') THEN cost ELSE NULL END ) as special_other,
  248. sum(CASE WHEN(type='emergency' and category='路基') THEN cost ELSE NULL END ) as emergency_subgrade,
  249. sum(CASE WHEN(type='emergency' and category='路面') THEN cost ELSE NULL END ) as emergency_pavement,
  250. sum(CASE WHEN(type='emergency' and category='桥涵') THEN cost ELSE NULL END ) as emergency_bridgeAndCulvert,
  251. sum(CASE WHEN(type='emergency' and category='隧道') THEN cost ELSE NULL END ) as emergency_tunnel,
  252. sum(CASE WHEN(type='emergency' and category='交安设施') THEN cost ELSE NULL END ) as emergency_safe,
  253. sum(CASE WHEN(type='emergency' and category='沿线设施') THEN cost ELSE NULL END ) as emergency_line,
  254. sum(CASE WHEN(type='emergency' and category='绿化') THEN cost ELSE NULL END ) as emergency_green,
  255. sum(CASE WHEN(type='emergency' and category='其他') THEN cost ELSE NULL END ) as emergency_other,
  256. sum(CASE WHEN(type='test' and category='路基') THEN cost ELSE NULL END ) as test_subgrade,
  257. sum(CASE WHEN(type='test' and category='路面') THEN cost ELSE NULL END ) as test_pavement,
  258. sum(CASE WHEN(type='test' and category='桥涵') THEN cost ELSE NULL END ) as test_bridgeAndCulvert,
  259. sum(CASE WHEN(type='test' and category='隧道') THEN cost ELSE NULL END ) as test_tunnel,
  260. sum(CASE WHEN(type='test' and category='交安设施') THEN cost ELSE NULL END ) as test_safe,
  261. sum(CASE WHEN(type='test' and category='沿线设施') THEN cost ELSE NULL END ) as test_line,
  262. sum(CASE WHEN(type='test' and category='其他') THEN cost ELSE NULL END ) as test_other,
  263. sum(CASE WHEN(type='scientific' and category='路基') THEN cost ELSE NULL END ) as scientific_subgrade,
  264. sum(CASE WHEN(type='scientific' and category='路面') THEN cost ELSE NULL END ) as scientific_pavement,
  265. sum(CASE WHEN(type='scientific' and category='桥隧') THEN cost ELSE NULL END ) as scientific_bridgeAndTunnel,
  266. sum(CASE WHEN(type='scientific' and category='其他') THEN cost ELSE NULL END ) as scientific_other,
  267. sum(CASE WHEN(type='equipment' and category='noCategory') THEN cost ELSE NULL END ) as equipment_noCategory,
  268. sum(CASE WHEN(type='reserve' and category='noCategory') THEN cost ELSE NULL END ) as reserve_noCategory,
  269. sum(CASE WHEN(category='路基') THEN cost ELSE NULL END ) as subgrade,
  270. sum(CASE WHEN(category='路面') THEN cost ELSE NULL END ) as pavement,
  271. sum(CASE WHEN(category='桥梁') THEN cost ELSE NULL END ) as bridge,
  272. sum(CASE WHEN(category='桥涵') THEN cost ELSE NULL END ) as bridgeAndCulvert,
  273. sum(CASE WHEN(category='涵洞通道') THEN cost ELSE NULL END ) as culvert,
  274. sum(CASE WHEN(category='桥隧') THEN cost ELSE NULL END ) as bridgeAndTunnel,
  275. sum(CASE WHEN(category='隧道') THEN cost ELSE NULL END ) as tunnel,
  276. sum(CASE WHEN(category='交安设施') THEN cost ELSE NULL END ) as safe,
  277. sum(CASE WHEN(category='沿线设施') THEN cost ELSE NULL END ) as line,
  278. sum(CASE WHEN(category='绿化') THEN cost ELSE NULL END ) as green,
  279. sum(CASE WHEN(category='其他') THEN cost ELSE NULL END ) as other,
  280. sum(CASE WHEN(category='清扫保洁') THEN cost ELSE NULL END ) as clean,
  281. sum(CASE WHEN(category='巡查检查') THEN cost ELSE NULL END ) as patrol,
  282. sum(CASE WHEN(category='养护车辆设备') THEN cost ELSE NULL END ) as car,
  283. sum(CASE WHEN(category='应急保通') THEN cost ELSE NULL END ) as emergencyC,
  284. sum(CASE WHEN(type='daily') THEN cost ELSE NULL END ) as daily,
  285. sum(CASE WHEN(type='prevention') THEN cost ELSE NULL END ) as prevention,
  286. sum(CASE WHEN(type='repair') THEN cost ELSE NULL END ) as repair,
  287. sum(CASE WHEN(type='special') THEN cost ELSE NULL END ) as special,
  288. sum(CASE WHEN(type='emergency') THEN cost ELSE NULL END ) as emergency,
  289. sum(CASE WHEN(type='test') THEN cost ELSE NULL END ) as test,
  290. sum(CASE WHEN(type='scientific') THEN cost ELSE NULL END ) as scientific,
  291. sum(CASE WHEN(type='equipment') THEN cost ELSE NULL END ) as equipment,
  292. sum(CASE WHEN(type='reserve') THEN cost ELSE NULL END ) as reserve,
  293. sum(cost) as total
  294. </sql>
  295. <sql id="scaleCol">
  296. sum(CASE WHEN(type='prevention' and scale='大修' and category='路基') THEN cost ELSE NULL END ) as prevention_max_subgrade,
  297. sum(CASE WHEN(type='prevention' and scale='大修' and category='路面') THEN cost ELSE NULL END ) as prevention_max_pavement,
  298. sum(CASE WHEN(type='prevention' and scale='大修' and category='桥涵') THEN cost ELSE NULL END ) as prevention_max_bridgeAndCulvert,
  299. sum(CASE WHEN(type='prevention' and scale='大修' and category='隧道') THEN cost ELSE NULL END ) as prevention_max_tunnel,
  300. sum(CASE WHEN(type='prevention' and scale='中修' and category='路基') THEN cost ELSE NULL END ) as prevention_mid_subgrade,
  301. sum(CASE WHEN(type='prevention' and scale='中修' and category='路面') THEN cost ELSE NULL END ) as prevention_mid_pavement,
  302. sum(CASE WHEN(type='prevention' and scale='中修' and category='桥涵') THEN cost ELSE NULL END ) as prevention_mid_bridgeAndCulvert,
  303. sum(CASE WHEN(type='prevention' and scale='中修' and category='隧道') THEN cost ELSE NULL END ) as prevention_mid_tunnel,
  304. sum(CASE WHEN(type='prevention' and scale='小修' and category='路基') THEN cost ELSE NULL END ) as prevention_min_subgrade,
  305. sum(CASE WHEN(type='prevention' and scale='小修' and category='路面') THEN cost ELSE NULL END ) as prevention_min_pavement,
  306. sum(CASE WHEN(type='prevention' and scale='小修' and category='桥涵') THEN cost ELSE NULL END ) as prevention_min_bridgeAndCulvert,
  307. sum(CASE WHEN(type='prevention' and scale='小修' and category='隧道') THEN cost ELSE NULL END ) as prevention_min_tunnel,
  308. sum(CASE WHEN(type='repair' and scale='大修' and category='路基') THEN cost ELSE NULL END ) as repair_max_subgrade,
  309. sum(CASE WHEN(type='repair' and scale='大修' and category='路面') THEN cost ELSE NULL END ) as repair_max_pavement,
  310. sum(CASE WHEN(type='repair' and scale='大修' and category='桥涵') THEN cost ELSE NULL END ) as repair_max_bridgeAndCulvert,
  311. sum(CASE WHEN(type='repair' and scale='大修' and category='隧道') THEN cost ELSE NULL END ) as repair_max_tunnel,
  312. sum(CASE WHEN(type='repair' and scale='中修' and category='路基') THEN cost ELSE NULL END ) as repair_mid_subgrade,
  313. sum(CASE WHEN(type='repair' and scale='中修' and category='路面') THEN cost ELSE NULL END ) as repair_mid_pavement,
  314. sum(CASE WHEN(type='repair' and scale='中修' and category='桥涵') THEN cost ELSE NULL END ) as repair_mid_bridgeAndCulvert,
  315. sum(CASE WHEN(type='repair' and scale='中修' and category='隧道') THEN cost ELSE NULL END ) as repair_mid_tunnel,
  316. sum(CASE WHEN(type='repair' and scale='小修' and category='路基') THEN cost ELSE NULL END ) as repair_min_subgrade,
  317. sum(CASE WHEN(type='repair' and scale='小修' and category='路面') THEN cost ELSE NULL END ) as repair_min_pavement,
  318. sum(CASE WHEN(type='repair' and scale='小修' and category='桥涵') THEN cost ELSE NULL END ) as repair_min_bridgeAndCulvert,
  319. sum(CASE WHEN(type='repair' and scale='小修' and category='隧道') THEN cost ELSE NULL END ) as repair_min_tunnel,
  320. sum(CASE WHEN(scale='大修' and category='路基') THEN cost ELSE NULL END ) as max_subgrade,
  321. sum(CASE WHEN(scale='大修' and category='路面') THEN cost ELSE NULL END ) as max_pavement,
  322. sum(CASE WHEN(scale='大修' and category='桥涵') THEN cost ELSE NULL END ) as max_bridgeAndCulvert,
  323. sum(CASE WHEN(scale='大修' and category='隧道') THEN cost ELSE NULL END ) as max_tunnel,
  324. sum(CASE WHEN(scale='中修' and category='路基') THEN cost ELSE NULL END ) as mid_subgrade,
  325. sum(CASE WHEN(scale='中修' and category='路面') THEN cost ELSE NULL END ) as mid_pavement,
  326. sum(CASE WHEN(scale='中修' and category='桥涵') THEN cost ELSE NULL END ) as mid_bridgeAndCulvert,
  327. sum(CASE WHEN(scale='中修' and category='隧道') THEN cost ELSE NULL END ) as mid_tunnel,
  328. sum(CASE WHEN(scale='小修' and category='路基') THEN cost ELSE NULL END ) as min_subgrade,
  329. sum(CASE WHEN(scale='小修' and category='路面') THEN cost ELSE NULL END ) as min_pavement,
  330. sum(CASE WHEN(scale='小修' and category='桥涵') THEN cost ELSE NULL END ) as min_bridgeAndCulvert,
  331. sum(CASE WHEN(scale='小修' and category='隧道') THEN cost ELSE NULL END ) as min_tunnel,
  332. sum(CASE WHEN(scale='大修') THEN cost ELSE NULL END ) as max,
  333. sum(CASE WHEN(scale='中修') THEN cost ELSE NULL END ) as mid,
  334. sum(CASE WHEN(scale='小修') THEN cost ELSE NULL END ) as min,
  335. sum(CASE WHEN(category='路基') THEN cost ELSE NULL END ) as subgrade,
  336. sum(CASE WHEN(category='路面') THEN cost ELSE NULL END ) as pavement,
  337. sum(CASE WHEN(category='桥涵') THEN cost ELSE NULL END ) as bridgeAndCulvert,
  338. sum(CASE WHEN(category='隧道') THEN cost ELSE NULL END ) as tunnel,
  339. sum(cost) as total
  340. </sql>
  341. <sql id="planByscale">
  342. <foreach item="tabletypeitem" collection="tabletype">
  343. <if test="tabletypeitem == 'prevention'">
  344. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'prevention' as type,PROJECT_SCALE as scale,CATEGORY,
  345. CASE WHEN isnull(AUDIT_FEE) THEN TOTAL_COST ELSE AUDIT_FEE END as cost
  346. from highway_prevention_project_dettable a
  347. where 1=1
  348. <if test="company != '' and company != null">
  349. and a.COMPANY = #{company}
  350. </if>
  351. <if test="startYear != '' and startYear != null">
  352. and a.YEAR &gt;= #{startYear}
  353. </if>
  354. <if test="endYear != '' and endYear != null">
  355. and a.YEAR &lt;= #{endYear}
  356. </if>
  357. <if test="companys != null">
  358. and a.COMPANY_ID in
  359. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  360. #{item}
  361. </foreach>
  362. </if>
  363. <if test="scale != null">
  364. and a.PROJECT_SCALE in
  365. <foreach item="item" index="index" collection="scale" open="(" close=")" separator=",">
  366. #{item}
  367. </foreach>
  368. </if>
  369. <if test="category != null">
  370. and a.CATEGORY in
  371. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  372. #{item}
  373. </foreach>
  374. </if>
  375. union all
  376. </if>
  377. <if test="tabletypeitem == 'repair'">
  378. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'repair' as type,PROJECT_SCALE as scale,CATEGORY,
  379. CASE WHEN isnull(AUDIT_FEE) THEN TOTAL_COST ELSE AUDIT_FEE END as cost
  380. from highway_repair_project_dettable a
  381. where 1=1
  382. <if test="company != '' and company != null">
  383. and a.COMPANY = #{company}
  384. </if>
  385. <if test="startYear != '' and startYear != null">
  386. and a.YEAR &gt;= #{startYear}
  387. </if>
  388. <if test="endYear != '' and endYear != null">
  389. and a.YEAR &lt;= #{endYear}
  390. </if>
  391. <if test="companys != null">
  392. and a.COMPANY_ID in
  393. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  394. #{item}
  395. </foreach>
  396. </if>
  397. <if test="scale != null">
  398. and a.PROJECT_SCALE in
  399. <foreach item="item" index="index" collection="scale" open="(" close=")" separator=",">
  400. #{item}
  401. </foreach>
  402. </if>
  403. <if test="category != null">
  404. and a.CATEGORY in
  405. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  406. #{item}
  407. </foreach>
  408. </if>
  409. union all
  410. </if>
  411. </foreach>
  412. select null as COMPANY_ID,null as COMPANY,null as ROAD_ID,null as ROAD,null as type,null AS scale,null as CATEGORY ,null as cost
  413. </sql>
  414. <sql id="compByscale">
  415. <foreach item="tabletypeitem" collection="tabletype">
  416. <if test="tabletypeitem == 'prevention'">
  417. select a.COMPANY,a.COMPANY_ID,a.ROAD_ID,a.ROAD,'prevention' as type,
  418. a.PROJECT_SCALE as scale,a.CATEGORY,b.ACTUAL_COST as cost
  419. from highway_prevention_project_dettable a left join monthly_prevention_completion b
  420. on a.YEAR = b.YEAR and a.COMPANY_ID = b.COMPANY_ID and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  421. where 1=1
  422. <if test="company != '' and company != null">
  423. and a.COMPANY = #{company}
  424. </if>
  425. <if test="startYear != '' and startYear != null">
  426. and a.YEAR &gt;= #{startYear}
  427. </if>
  428. <if test="endYear != '' and endYear != null">
  429. and a.YEAR &lt;= #{endYear}
  430. </if>
  431. <if test="companys != null">
  432. and a.COMPANY_ID in
  433. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  434. #{item}
  435. </foreach>
  436. </if>
  437. <if test="scale != null">
  438. and a.PROJECT_SCALE in
  439. <foreach item="item" index="index" collection="scale" open="(" close=")" separator=",">
  440. #{item}
  441. </foreach>
  442. </if>
  443. <if test="category != null">
  444. and a.CATEGORY in
  445. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  446. #{item}
  447. </foreach>
  448. </if>
  449. union all
  450. </if>
  451. <if test="tabletypeitem == 'repair'">
  452. select a.COMPANY,a.COMPANY_ID,a.ROAD_ID,a.ROAD,'repair' as type,
  453. a.PROJECT_SCALE as scale,a.CATEGORY,b.ACTUAL_COST as cost
  454. from highway_repair_project_dettable a left join monthly_repair_completion b
  455. on a.YEAR = b.YEAR and a.COMPANY_ID = b.COMPANY_ID and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  456. where 1=1
  457. <if test="company != '' and company != null">
  458. and a.COMPANY = #{company}
  459. </if>
  460. <if test="startYear != '' and startYear != null">
  461. and a.YEAR &gt;= #{startYear}
  462. </if>
  463. <if test="endYear != '' and endYear != null">
  464. and a.YEAR &lt;= #{endYear}
  465. </if>
  466. <if test="companys != null">
  467. and a.COMPANY_ID in
  468. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  469. #{item}
  470. </foreach>
  471. </if>
  472. <if test="scale != null">
  473. and a.PROJECT_SCALE in
  474. <foreach item="item" index="index" collection="scale" open="(" close=")" separator=",">
  475. #{item}
  476. </foreach>
  477. </if>
  478. <if test="category != null">
  479. and a.CATEGORY in
  480. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  481. #{item}
  482. </foreach>
  483. </if>
  484. union all
  485. </if>
  486. </foreach>
  487. select null as COMPANY_ID,null as COMPANY,null as ROAD_ID,null as ROAD,null as type,null AS scale,null as CATEGORY ,null as cost
  488. </sql>
  489. <sql id="plan">
  490. <foreach item="tabletypeitem" collection="tabletype">
  491. <if test="tabletypeitem == 'daily'">
  492. <foreach item="c" collection="category">
  493. <if test="c == '路基'">
  494. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'daily' as type,'路基' as CATEGORY,
  495. CASE WHEN isnull(SUBGRADE_AUDIT_FEE) THEN SUBGRADE_PLAN_COST ELSE SUBGRADE_AUDIT_FEE END as cost
  496. from highway_daily_plan_statable a
  497. where 1=1
  498. <if test="company != '' and company != null">
  499. and a.COMPANY = #{company}
  500. </if>
  501. <if test="startYear != '' and startYear != null">
  502. and a.YEAR &gt;= #{startYear}
  503. </if>
  504. <if test="endYear != '' and endYear != null">
  505. and a.YEAR &lt;= #{endYear}
  506. </if>
  507. <if test="companys != null">
  508. and a.COMPANY_ID in
  509. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  510. #{item}
  511. </foreach>
  512. </if>
  513. union all
  514. </if>
  515. <if test="c == '路面'">
  516. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'daily' as type,'路面' as CATEGORY,
  517. CASE WHEN isnull(PAVEMENT_AUDIT_FEE) THEN PAVEMENT_PLAN_COST ELSE PAVEMENT_AUDIT_FEE END as cost
  518. from highway_daily_plan_statable a
  519. where 1=1
  520. <if test="company != '' and company != null">
  521. and a.COMPANY = #{company}
  522. </if>
  523. <if test="startYear != '' and startYear != null">
  524. and a.YEAR &gt;= #{startYear}
  525. </if>
  526. <if test="endYear != '' and endYear != null">
  527. and a.YEAR &lt;= #{endYear}
  528. </if>
  529. <if test="companys != null">
  530. and a.COMPANY_ID in
  531. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  532. #{item}
  533. </foreach>
  534. </if>
  535. union all
  536. </if>
  537. <if test="c == '桥梁'">
  538. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'daily' as type,'桥梁' as CATEGORY,
  539. CASE WHEN isnull(BRIDGE_AUDIT_FEE) THEN BRIDGE_PLAN_COST ELSE BRIDGE_AUDIT_FEE END as cost
  540. from highway_daily_plan_statable a
  541. where 1=1
  542. <if test="company != '' and company != null">
  543. and a.COMPANY = #{company}
  544. </if>
  545. <if test="startYear != '' and startYear != null">
  546. and a.YEAR &gt;= #{startYear}
  547. </if>
  548. <if test="endYear != '' and endYear != null">
  549. and a.YEAR &lt;= #{endYear}
  550. </if>
  551. <if test="companys != null">
  552. and a.COMPANY_ID in
  553. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  554. #{item}
  555. </foreach>
  556. </if>
  557. union all
  558. </if>
  559. <if test="c == '涵洞通道'">
  560. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'daily' as type,'涵洞通道' as CATEGORY,
  561. CASE WHEN isnull(CULVERT_AUDIT_FEE) THEN CULVERT_PLAN_COST ELSE CULVERT_AUDIT_FEE END as cost
  562. from highway_daily_plan_statable a
  563. where 1=1
  564. <if test="company != '' and company != null">
  565. and a.COMPANY = #{company}
  566. </if>
  567. <if test="startYear != '' and startYear != null">
  568. and a.YEAR &gt;= #{startYear}
  569. </if>
  570. <if test="endYear != '' and endYear != null">
  571. and a.YEAR &lt;= #{endYear}
  572. </if>
  573. <if test="companys != null">
  574. and a.COMPANY_ID in
  575. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  576. #{item}
  577. </foreach>
  578. </if>
  579. union all
  580. </if>
  581. <if test="c == '隧道'">
  582. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'daily' as type,'隧道' as CATEGORY,
  583. CASE WHEN isnull(TUNNEL_AUDIT_FEE) THEN TUNNEL_PLAN_COST ELSE TUNNEL_AUDIT_FEE END as cost
  584. from highway_daily_plan_statable a
  585. where 1=1
  586. <if test="company != '' and company != null">
  587. and a.COMPANY = #{company}
  588. </if>
  589. <if test="startYear != '' and startYear != null">
  590. and a.YEAR &gt;= #{startYear}
  591. </if>
  592. <if test="endYear != '' and endYear != null">
  593. and a.YEAR &lt;= #{endYear}
  594. </if>
  595. <if test="companys != null">
  596. and a.COMPANY_ID in
  597. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  598. #{item}
  599. </foreach>
  600. </if>
  601. union all
  602. </if>
  603. <if test="c == '交安设施'">
  604. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'daily' as type,'交安设施' as CATEGORY,
  605. CASE WHEN isnull(SAFE_AUDIT_FEE) THEN SAFE_PLAN_COST ELSE SAFE_AUDIT_FEE END as cost
  606. from highway_daily_plan_statable a
  607. where 1=1
  608. <if test="company != '' and company != null">
  609. and a.COMPANY = #{company}
  610. </if>
  611. <if test="startYear != '' and startYear != null">
  612. and a.YEAR &gt;= #{startYear}
  613. </if>
  614. <if test="endYear != '' and endYear != null">
  615. and a.YEAR &lt;= #{endYear}
  616. </if>
  617. <if test="companys != null">
  618. and a.COMPANY_ID in
  619. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  620. #{item}
  621. </foreach>
  622. </if>
  623. union all
  624. </if>
  625. <if test="c == '沿线设施'">
  626. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'daily' as type,'沿线设施' as CATEGORY,
  627. CASE WHEN isnull(LINE_AUDIT_FEE) THEN LINE_PLAN_COST ELSE LINE_AUDIT_FEE END as cost
  628. from highway_daily_plan_statable a
  629. where 1=1
  630. <if test="company != '' and company != null">
  631. and a.COMPANY = #{company}
  632. </if>
  633. <if test="startYear != '' and startYear != null">
  634. and a.YEAR &gt;= #{startYear}
  635. </if>
  636. <if test="endYear != '' and endYear != null">
  637. and a.YEAR &lt;= #{endYear}
  638. </if>
  639. <if test="companys != null">
  640. and a.COMPANY_ID in
  641. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  642. #{item}
  643. </foreach>
  644. </if>
  645. union all
  646. </if>
  647. <if test="c == '绿化'">
  648. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'daily' as type,'绿化' as CATEGORY,
  649. CASE WHEN isnull(GREEN_AUDIT_FEE) THEN GREEN_PLAN_COST ELSE GREEN_AUDIT_FEE END as cost
  650. from highway_daily_plan_statable a
  651. where 1=1
  652. <if test="company != '' and company != null">
  653. and a.COMPANY = #{company}
  654. </if>
  655. <if test="startYear != '' and startYear != null">
  656. and a.YEAR &gt;= #{startYear}
  657. </if>
  658. <if test="endYear != '' and endYear != null">
  659. and a.YEAR &lt;= #{endYear}
  660. </if>
  661. <if test="companys != null">
  662. and a.COMPANY_ID in
  663. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  664. #{item}
  665. </foreach>
  666. </if>
  667. union all
  668. </if>
  669. <if test="c == '清扫保洁'">
  670. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'daily' as type,'清扫保洁' as CATEGORY,
  671. CASE WHEN isnull(CLEAN_AUDIT_FEE) THEN CLEAN_PLAN_COST ELSE CLEAN_AUDIT_FEE END as cost
  672. from highway_daily_plan_statable a
  673. where 1=1
  674. <if test="company != '' and company != null">
  675. and a.COMPANY = #{company}
  676. </if>
  677. <if test="startYear != '' and startYear != null">
  678. and a.YEAR &gt;= #{startYear}
  679. </if>
  680. <if test="endYear != '' and endYear != null">
  681. and a.YEAR &lt;= #{endYear}
  682. </if>
  683. <if test="companys != null">
  684. and a.COMPANY_ID in
  685. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  686. #{item}
  687. </foreach>
  688. </if>
  689. union all
  690. </if>
  691. <if test="c == '巡查检查'">
  692. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'daily' as type,'巡查检查' as CATEGORY,
  693. CASE WHEN isnull(PATROL_AUDIT_FEE) THEN PATROL_PLAN_COST ELSE PATROL_AUDIT_FEE END as cost
  694. from highway_daily_plan_statable a
  695. where 1=1
  696. <if test="company != '' and company != null">
  697. and a.COMPANY = #{company}
  698. </if>
  699. <if test="startYear != '' and startYear != null">
  700. and a.YEAR &gt;= #{startYear}
  701. </if>
  702. <if test="endYear != '' and endYear != null">
  703. and a.YEAR &lt;= #{endYear}
  704. </if>
  705. <if test="companys != null">
  706. and a.COMPANY_ID in
  707. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  708. #{item}
  709. </foreach>
  710. </if>
  711. union all
  712. </if>
  713. <if test="c == '养护车辆设备'">
  714. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'daily' as type,'养护车辆设备' as CATEGORY,
  715. CASE WHEN isnull(CAR_AUDIT_FEE) THEN CAR_PLAN_COST ELSE CAR_AUDIT_FEE END as cost
  716. from highway_daily_plan_statable a
  717. where 1=1
  718. <if test="company != '' and company != null">
  719. and a.COMPANY = #{company}
  720. </if>
  721. <if test="startYear != '' and startYear != null">
  722. and a.YEAR &gt;= #{startYear}
  723. </if>
  724. <if test="endYear != '' and endYear != null">
  725. and a.YEAR &lt;= #{endYear}
  726. </if>
  727. <if test="companys != null">
  728. and a.COMPANY_ID in
  729. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  730. #{item}
  731. </foreach>
  732. </if>
  733. union all
  734. </if>
  735. <if test="c == '应急保通'">
  736. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'daily' as type,'应急保通' as CATEGORY,
  737. CASE WHEN isnull(EMERGENCY_AUDIT_FEE) THEN EMERGENCY_PLAN_COST ELSE EMERGENCY_AUDIT_FEE END as cost
  738. from highway_daily_plan_statable a
  739. where 1=1
  740. <if test="company != '' and company != null">
  741. and a.COMPANY = #{company}
  742. </if>
  743. <if test="startYear != '' and startYear != null">
  744. and a.YEAR &gt;= #{startYear}
  745. </if>
  746. <if test="endYear != '' and endYear != null">
  747. and a.YEAR &lt;= #{endYear}
  748. </if>
  749. <if test="companys != null">
  750. and a.COMPANY_ID in
  751. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  752. #{item}
  753. </foreach>
  754. </if>
  755. union all
  756. </if>
  757. </foreach>
  758. </if>
  759. <if test="tabletypeitem == 'prevention'">
  760. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'prevention' as type,CATEGORY,
  761. CASE WHEN isnull(AUDIT_FEE) THEN TOTAL_COST ELSE AUDIT_FEE END as cost
  762. from highway_prevention_project_dettable a
  763. where 1=1
  764. <if test="company != '' and company != null">
  765. and a.COMPANY = #{company}
  766. </if>
  767. <if test="startYear != '' and startYear != null">
  768. and a.YEAR &gt;= #{startYear}
  769. </if>
  770. <if test="endYear != '' and endYear != null">
  771. and a.YEAR &lt;= #{endYear}
  772. </if>
  773. <if test="companys != null">
  774. and a.COMPANY_ID in
  775. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  776. #{item}
  777. </foreach>
  778. </if>
  779. <if test="category != null">
  780. and a.CATEGORY in
  781. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  782. #{item}
  783. </foreach>
  784. </if>
  785. union all
  786. </if>
  787. <if test="tabletypeitem == 'repair'">
  788. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'repair' as type,CATEGORY,
  789. CASE WHEN isnull(AUDIT_FEE) THEN TOTAL_COST ELSE AUDIT_FEE END as cost
  790. from highway_repair_project_dettable a
  791. where 1=1
  792. <if test="company != '' and company != null">
  793. and a.COMPANY = #{company}
  794. </if>
  795. <if test="startYear != '' and startYear != null">
  796. and a.YEAR &gt;= #{startYear}
  797. </if>
  798. <if test="endYear != '' and endYear != null">
  799. and a.YEAR &lt;= #{endYear}
  800. </if>
  801. <if test="companys != null">
  802. and a.COMPANY_ID in
  803. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  804. #{item}
  805. </foreach>
  806. </if>
  807. <if test="category != null">
  808. and a.CATEGORY in
  809. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  810. #{item}
  811. </foreach>
  812. </if>
  813. union all
  814. </if>
  815. <if test="tabletypeitem == 'special'">
  816. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'special' as type,CATEGORY,
  817. CASE WHEN isnull(AUDIT_FEE) THEN TOTAL_COST ELSE AUDIT_FEE END as cost
  818. from highway_special_project_dettable a
  819. where 1=1
  820. <if test="company != '' and company != null">
  821. and a.COMPANY = #{company}
  822. </if>
  823. <if test="startYear != '' and startYear != null">
  824. and a.YEAR &gt;= #{startYear}
  825. </if>
  826. <if test="endYear != '' and endYear != null">
  827. and a.YEAR &lt;= #{endYear}
  828. </if>
  829. <if test="companys != null">
  830. and a.COMPANY_ID in
  831. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  832. #{item}
  833. </foreach>
  834. </if>
  835. <if test="category != null">
  836. and a.CATEGORY in
  837. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  838. #{item}
  839. </foreach>
  840. </if>
  841. union all
  842. </if>
  843. <if test="tabletypeitem == 'emergency'">
  844. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'emergency' as type,CATEGORY,
  845. CASE WHEN isnull(AUDIT_FEE) THEN TOTAL_COST ELSE AUDIT_FEE END as cost
  846. from highway_emergency_project_dettable a
  847. where 1=1
  848. <if test="company != '' and company != null">
  849. and a.COMPANY = #{company}
  850. </if>
  851. <if test="startYear != '' and startYear != null">
  852. and a.YEAR &gt;= #{startYear}
  853. </if>
  854. <if test="endYear != '' and endYear != null">
  855. and a.YEAR &lt;= #{endYear}
  856. </if>
  857. <if test="companys != null">
  858. and a.COMPANY_ID in
  859. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  860. #{item}
  861. </foreach>
  862. </if>
  863. <if test="category != null">
  864. and a.CATEGORY in
  865. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  866. #{item}
  867. </foreach>
  868. </if>
  869. union all
  870. </if>
  871. <if test="tabletypeitem == 'test'">
  872. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'test' as type,CATEGORY,
  873. CASE WHEN isnull(AUDIT_FEE) THEN TOTAL_COST ELSE AUDIT_FEE END as cost
  874. from highway_test_project_dettable a
  875. where 1=1
  876. <if test="company != '' and company != null">
  877. and a.COMPANY = #{company}
  878. </if>
  879. <if test="startYear != '' and startYear != null">
  880. and a.YEAR &gt;= #{startYear}
  881. </if>
  882. <if test="endYear != '' and endYear != null">
  883. and a.YEAR &lt;= #{endYear}
  884. </if>
  885. <if test="companys != null">
  886. and a.COMPANY_ID in
  887. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  888. #{item}
  889. </foreach>
  890. </if>
  891. <if test="category != null">
  892. and a.CATEGORY in
  893. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  894. #{item}
  895. </foreach>
  896. </if>
  897. union all
  898. </if>
  899. <if test="tabletypeitem == 'scientific'">
  900. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'scientific' as type,CATEGORY,
  901. CASE WHEN isnull(AUDIT_FEE) THEN year_cost ELSE AUDIT_FEE END as cost
  902. from highway_scientific_project_dettable a
  903. where 1=1
  904. <if test="company != '' and company != null">
  905. and a.COMPANY = #{company}
  906. </if>
  907. <if test="startYear != '' and startYear != null">
  908. and a.YEAR &gt;= #{startYear}
  909. </if>
  910. <if test="endYear != '' and endYear != null">
  911. and a.YEAR &lt;= #{endYear}
  912. </if>
  913. <if test="companys != null">
  914. and a.COMPANY_ID in
  915. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  916. #{item}
  917. </foreach>
  918. </if>
  919. <if test="category != null">
  920. and a.CATEGORY in
  921. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  922. #{item}
  923. </foreach>
  924. </if>
  925. union all
  926. </if>
  927. <if test="tabletypeitem == 'equipment'">
  928. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'equipment' as type,'noCategory' as CATEGORY,
  929. CASE WHEN isnull(AUDIT_FEE) THEN project_cost ELSE AUDIT_FEE END as cost
  930. from highway_equipment_overhaul_project_dettable a
  931. where 1=1
  932. <if test="company != '' and company != null">
  933. and a.COMPANY = #{company}
  934. </if>
  935. <if test="startYear != '' and startYear != null">
  936. and a.YEAR &gt;= #{startYear}
  937. </if>
  938. <if test="endYear != '' and endYear != null">
  939. and a.YEAR &lt;= #{endYear}
  940. </if>
  941. <if test="companys != null">
  942. and a.COMPANY_ID in
  943. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  944. #{item}
  945. </foreach>
  946. </if>
  947. union all
  948. </if>
  949. <if test="tabletypeitem == 'reserve'">
  950. select COMPANY_ID,COMPANY,ROAD_ID,ROAD,'reserve' as type,'noCategory' as CATEGORY,
  951. CASE WHEN isnull(AUDIT_FEE) THEN TOTAL_COST ELSE AUDIT_FEE END as cost
  952. from highway_reserve_fees_sumtable_total a
  953. where 1=1
  954. <if test="company != '' and company != null">
  955. and a.COMPANY = #{company}
  956. </if>
  957. <if test="startYear != '' and startYear != null">
  958. and a.YEAR &gt;= #{startYear}
  959. </if>
  960. <if test="endYear != '' and endYear != null">
  961. and a.YEAR &lt;= #{endYear}
  962. </if>
  963. <if test="companys != null">
  964. and a.COMPANY_ID in
  965. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  966. #{item}
  967. </foreach>
  968. </if>
  969. union all
  970. </if>
  971. </foreach>
  972. select null as COMPANY_ID,null as COMPANY,null as ROAD_ID,null as ROAD,null as type,null as CATEGORY ,null as cost
  973. </sql>
  974. <sql id="comp">
  975. <foreach item="tabletypeitem" collection="tabletype">
  976. <if test="tabletypeitem == 'daily'">
  977. select * from(
  978. select COMPANY,COMPANY_ID,ROAD_ID,ROAD,'daily' as type,
  979. CASE
  980. WHEN (type = 'SUBGRADE_COST') THEN '路基'
  981. WHEN (type = 'PAVEMENT_COST') THEN '路面'
  982. WHEN (type = 'BRIDGE_COST') THEN '桥梁'
  983. WHEN (type = 'CULVERT_COST') THEN '涵洞通道'
  984. WHEN (type = 'TUNNEL_COST') THEN '隧道'
  985. WHEN (type = 'SAFE_COST') THEN '交安设施'
  986. WHEN (type = 'LINE_COST') THEN '沿线设施'
  987. WHEN (type = 'GREEN_COST') THEN '绿化'
  988. WHEN (type = 'CLEAN_COST') THEN '清扫保洁'
  989. WHEN (type = 'PATROL_COST') THEN '巡查检查'
  990. WHEN (type = 'CAR_COST') THEN '养护车辆设备'
  991. WHEN (type = 'EMERGENCY_COST') THEN '应急保通'
  992. END as CATEGORY,
  993. ACTUAL_COST as cost
  994. from monthly_daily_completion a
  995. where 1=1
  996. <if test="company != '' and company != null">
  997. and a.COMPANY = #{company}
  998. </if>
  999. <if test="startYear != '' and startYear != null">
  1000. and a.YEAR &gt;= #{startYear}
  1001. </if>
  1002. <if test="endYear != '' and endYear != null">
  1003. and a.YEAR &lt;= #{endYear}
  1004. </if>
  1005. <if test="companys != null">
  1006. and a.COMPANY_ID in
  1007. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  1008. #{item}
  1009. </foreach>
  1010. </if>
  1011. )a
  1012. <if test="category != null">
  1013. where CATEGORY in
  1014. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  1015. #{item}
  1016. </foreach>
  1017. </if>
  1018. union all
  1019. </if>
  1020. <if test="tabletypeitem == 'prevention'">
  1021. select a.COMPANY,a.COMPANY_ID,a.ROAD_ID,a.ROAD,'prevention' as type,a.CATEGORY,b.ACTUAL_COST as cost
  1022. from highway_prevention_project_dettable a left join monthly_prevention_completion b
  1023. on a.YEAR = b.YEAR and a.COMPANY_ID = b.COMPANY_ID and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  1024. where 1=1
  1025. <if test="company != '' and company != null">
  1026. and a.COMPANY = #{company}
  1027. </if>
  1028. <if test="startYear != '' and startYear != null">
  1029. and a.YEAR &gt;= #{startYear}
  1030. </if>
  1031. <if test="endYear != '' and endYear != null">
  1032. and a.YEAR &lt;= #{endYear}
  1033. </if>
  1034. <if test="companys != null">
  1035. and a.COMPANY_ID in
  1036. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  1037. #{item}
  1038. </foreach>
  1039. </if>
  1040. <if test="category != null">
  1041. and a.CATEGORY in
  1042. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  1043. #{item}
  1044. </foreach>
  1045. </if>
  1046. union all
  1047. </if>
  1048. <if test="tabletypeitem == 'repair'">
  1049. select a.COMPANY,a.COMPANY_ID,a.ROAD_ID,a.ROAD,'repair' as type,a.CATEGORY,b.ACTUAL_COST as cost
  1050. from highway_repair_project_dettable a left join monthly_repair_completion b
  1051. on a.YEAR = b.YEAR and a.COMPANY_ID = b.COMPANY_ID and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  1052. where 1=1
  1053. <if test="company != '' and company != null">
  1054. and a.COMPANY = #{company}
  1055. </if>
  1056. <if test="startYear != '' and startYear != null">
  1057. and a.YEAR &gt;= #{startYear}
  1058. </if>
  1059. <if test="endYear != '' and endYear != null">
  1060. and a.YEAR &lt;= #{endYear}
  1061. </if>
  1062. <if test="companys != null">
  1063. and a.COMPANY_ID in
  1064. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  1065. #{item}
  1066. </foreach>
  1067. </if>
  1068. <if test="category != null">
  1069. and a.CATEGORY in
  1070. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  1071. #{item}
  1072. </foreach>
  1073. </if>
  1074. union all
  1075. </if>
  1076. <if test="tabletypeitem == 'special'">
  1077. select a.COMPANY,a.COMPANY_ID,a.ROAD_ID,a.ROAD,'special' as type,a.CATEGORY,b.ACTUAL_COST as cost
  1078. from highway_special_project_dettable a left join monthly_special_completion b
  1079. on a.YEAR = b.YEAR and a.COMPANY_ID = b.COMPANY_ID and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  1080. where 1=1
  1081. <if test="company != '' and company != null">
  1082. and a.COMPANY = #{company}
  1083. </if>
  1084. <if test="startYear != '' and startYear != null">
  1085. and a.YEAR &gt;= #{startYear}
  1086. </if>
  1087. <if test="endYear != '' and endYear != null">
  1088. and a.YEAR &lt;= #{endYear}
  1089. </if>
  1090. <if test="companys != null">
  1091. and a.COMPANY_ID in
  1092. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  1093. #{item}
  1094. </foreach>
  1095. </if>
  1096. <if test="category != null">
  1097. and a.CATEGORY in
  1098. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  1099. #{item}
  1100. </foreach>
  1101. </if>
  1102. union all
  1103. </if>
  1104. <if test="tabletypeitem == 'emergency'">
  1105. select a.COMPANY,a.COMPANY_ID,a.ROAD_ID,a.ROAD,'emergency' as type,a.CATEGORY,b.ACTUAL_COST as cost
  1106. from highway_emergency_project_dettable a left join monthly_emergency_completion b
  1107. on a.YEAR = b.YEAR and a.COMPANY_ID = b.COMPANY_ID and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  1108. where 1=1
  1109. <if test="company != '' and company != null">
  1110. and a.COMPANY = #{company}
  1111. </if>
  1112. <if test="startYear != '' and startYear != null">
  1113. and a.YEAR &gt;= #{startYear}
  1114. </if>
  1115. <if test="endYear != '' and endYear != null">
  1116. and a.YEAR &lt;= #{endYear}
  1117. </if>
  1118. <if test="companys != null">
  1119. and a.COMPANY_ID in
  1120. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  1121. #{item}
  1122. </foreach>
  1123. </if>
  1124. <if test="category != null">
  1125. and a.CATEGORY in
  1126. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  1127. #{item}
  1128. </foreach>
  1129. </if>
  1130. union all
  1131. </if>
  1132. <if test="tabletypeitem == 'test'">
  1133. select a.COMPANY,a.COMPANY_ID,a.ROAD_ID,a.ROAD,'test' as type,a.CATEGORY,b.ACTUAL_COST as cost
  1134. from highway_test_project_dettable a left join monthly_test_project_completion b
  1135. on a.YEAR = b.YEAR and a.COMPANY_ID = b.COMPANY_ID and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  1136. where 1=1
  1137. <if test="company != '' and company != null">
  1138. and a.COMPANY = #{company}
  1139. </if>
  1140. <if test="startYear != '' and startYear != null">
  1141. and a.YEAR &gt;= #{startYear}
  1142. </if>
  1143. <if test="endYear != '' and endYear != null">
  1144. and a.YEAR &lt;= #{endYear}
  1145. </if>
  1146. <if test="companys != null">
  1147. and a.COMPANY_ID in
  1148. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  1149. #{item}
  1150. </foreach>
  1151. </if>
  1152. <if test="category != null">
  1153. and a.CATEGORY in
  1154. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  1155. #{item}
  1156. </foreach>
  1157. </if>
  1158. union all
  1159. </if>
  1160. <if test="tabletypeitem == 'scientific'">
  1161. select a.COMPANY,a.COMPANY_ID,a.ROAD_ID,a.ROAD,'scientific' as type,a.CATEGORY,b.ACTUAL_COST as cost
  1162. from highway_scientific_project_dettable a left join monthly_scientific_project_completion b
  1163. on a.YEAR = b.YEAR and a.COMPANY_ID = b.COMPANY_ID and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  1164. where 1=1
  1165. <if test="company != '' and company != null">
  1166. and a.COMPANY = #{company}
  1167. </if>
  1168. <if test="startYear != '' and startYear != null">
  1169. and a.YEAR &gt;= #{startYear}
  1170. </if>
  1171. <if test="endYear != '' and endYear != null">
  1172. and a.YEAR &lt;= #{endYear}
  1173. </if>
  1174. <if test="companys != null">
  1175. and a.COMPANY_ID in
  1176. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  1177. #{item}
  1178. </foreach>
  1179. </if>
  1180. <if test="category != null">
  1181. and a.CATEGORY in
  1182. <foreach item="item" index="index" collection="category" open="(" close=")" separator=",">
  1183. #{item}
  1184. </foreach>
  1185. </if>
  1186. union all
  1187. </if>
  1188. <if test="tabletypeitem == 'equipment'">
  1189. select a.COMPANY,a.COMPANY_ID,a.ROAD_ID,a.ROAD,'equipment' as type,'noCategory' as CATEGORY,b.ACTUAL_COST as cost
  1190. from highway_equipment_overhaul_project_dettable a left join monthly_equipment_overhaul_completion b
  1191. on a.YEAR = b.YEAR and a.COMPANY_ID = b.COMPANY_ID and a.ROAD_ID = b.ROAD_ID and a.PROJECT_NAME = b.PROJECT_NAME
  1192. where 1=1
  1193. <if test="company != '' and company != null">
  1194. and a.COMPANY = #{company}
  1195. </if>
  1196. <if test="startYear != '' and startYear != null">
  1197. and a.YEAR &gt;= #{startYear}
  1198. </if>
  1199. <if test="endYear != '' and endYear != null">
  1200. and a.YEAR &lt;= #{endYear}
  1201. </if>
  1202. <if test="companys != null">
  1203. and a.COMPANY_ID in
  1204. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  1205. #{item}
  1206. </foreach>
  1207. </if>
  1208. union all
  1209. </if>
  1210. <if test="tabletypeitem == 'reserve'">
  1211. select a.COMPANY,a.COMPANY_ID,a.ROAD_ID,a.ROAD,'reserve' as type,'noCategory' as CATEGORY,b.ACTUAL_COST as cost
  1212. from highway_reserve_fees_sumtable_total a left join highway_reserve_fees_sumtable b
  1213. on a.YEAR = b.YEAR and a.COMPANY_ID = b.COMPANY_ID and a.ROAD_ID = b.ROAD_ID
  1214. where 1=1
  1215. <if test="company != '' and company != null">
  1216. and a.COMPANY = #{company}
  1217. </if>
  1218. <if test="startYear != '' and startYear != null">
  1219. and a.YEAR &gt;= #{startYear}
  1220. </if>
  1221. <if test="endYear != '' and endYear != null">
  1222. and a.YEAR &lt;= #{endYear}
  1223. </if>
  1224. <if test="companys != null">
  1225. and a.COMPANY_ID in
  1226. <foreach item="item" index="index" collection="companys" open="(" close=")" separator=",">
  1227. #{item}
  1228. </foreach>
  1229. </if>
  1230. union all
  1231. </if>
  1232. </foreach>
  1233. select null as COMPANY_ID,null as COMPANY,null as ROAD_ID,null as ROAD,null as type,null as CATEGORY ,null as cost
  1234. </sql>
  1235. </mapper>