MonthProgressMapper.xml 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  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="MonthProgressMapper">
  4. <!--表名 -->
  5. <sql id="tableName">
  6. tb_annualplan
  7. </sql>
  8. <!-- 字段 -->
  9. <sql id="Field">
  10. NAME,
  11. CTIME,
  12. MTIME,
  13. STATUS,
  14. ANNUALPLAN_ID
  15. </sql>
  16. <!-- 字段值 -->
  17. <sql id="FieldValue">
  18. #{NAME},
  19. #{CTIME},
  20. #{MTIME},
  21. #{STATUS},
  22. #{ANNUALPLAN_ID}
  23. </sql>
  24. <!-- 字段 -->
  25. <sql id="Fields">
  26. NAME,
  27. CTIME,
  28. MTIME,
  29. STATUS
  30. </sql>
  31. <!-- 字段值 -->
  32. <sql id="FieldValues">
  33. #{NAME},
  34. #{CTIME},
  35. #{MTIME},
  36. #{STATUS}
  37. </sql>
  38. <!--子表格类型 -->
  39. <sql id="tableType">
  40. ${TABLETYPE}
  41. </sql>
  42. <!-- 子表格字段 -->
  43. <sql id="tableField">
  44. serialNumber,
  45. road,
  46. designKm,
  47. careKm,
  48. dailyDesign,
  49. dailyComplete,
  50. dailyProportion,
  51. dailyKm,
  52. preventionDesign,
  53. preventionComplete,
  54. preventionProportion,
  55. preventionKm,
  56. minorRepairDesign,
  57. minorRepairComplete,
  58. minorRepairProportion,
  59. middleRepairDesign,
  60. middleRepairComplete,
  61. middleRepairProportion,
  62. overhaulDesign,
  63. overhaulComplete,
  64. overhaulProportion,
  65. specialDesign,
  66. specialComplete,
  67. specialProportion,
  68. testDesign,
  69. testComplete,
  70. testProportion,
  71. scientificDesign,
  72. scientificComplete,
  73. scientificProportion,
  74. deviceDesign,
  75. deviceComplete,
  76. deviceProportion,
  77. reserveDesign,
  78. reserveComplete,
  79. reserveProportion,
  80. totalDesign,
  81. totalComplete,
  82. totalProportion
  83. </sql>
  84. <!-- 新增-->
  85. <insert id="saveAnnualPlan" parameterType="pd">
  86. insert into
  87. <include refid="tableName"></include>
  88. (
  89. <include refid="Fields"></include>
  90. ) values (
  91. <include refid="FieldValues"></include>
  92. )
  93. </insert>
  94. <!-- 删除-->
  95. <delete id="delete" parameterType="pd">
  96. delete from
  97. <include refid="tableName"></include>
  98. where
  99. ANNUALPLAN_ID = #{ANNUALPLAN_ID}
  100. </delete>
  101. <!-- 修改 -->
  102. <update id="edit" parameterType="pd">
  103. update
  104. <include refid="tableName"></include>
  105. set
  106. NAME = #{NAME},
  107. FDESCRIBE = #{FDESCRIBE},
  108. PRICE = #{PRICE},
  109. ATTACHED_ID = ATTACHED_ID
  110. where
  111. ATTACHED_ID = #{ATTACHED_ID}
  112. </update>
  113. <!-- 显示子表格内容 -->
  114. <select id="showTableRecod" parameterType="pd" resultType="pd">
  115. select
  116. <include refid="tableField"></include>
  117. from
  118. <include refid="tableType"></include>
  119. where
  120. YEAR = #{YEAR} AND COMPANY=#{COMPANY}
  121. </select>
  122. <!-- 通过报告id获取相关报表列表 -->
  123. <select id="findReportById" parameterType="pd" resultType="pd">
  124. select
  125. ANNUAL_REPORT_ID, ANNUALPLAN_ID, ANNUAL_REPORT_NAME, STATUS
  126. from
  127. relation_annualPlan_report
  128. where
  129. annualPlan_ID = #{ANNUALPLAN_ID}
  130. </select>
  131. <!-- 通过报告id获取相关表格列表 -->
  132. <select id="findTableById" parameterType="pd" resultType="pd">
  133. select
  134. CONCAT (TABLEYEAR, TABLECOMPANY, TABLENAME) as NAME, CTIME, MTIME, STATUS, TABLETYPE
  135. from
  136. relation_annualPlan_table
  137. where
  138. annualPlanID = #{ANNUALPLAN_ID}
  139. </select>
  140. <!-- 通过报告id获取相关表格列表 -->
  141. <select id="getReportType" parameterType="pd" resultType="pd">
  142. select
  143. ID, reportType
  144. from
  145. tb_reportinfo
  146. </select>
  147. <!-- 列表 -->
  148. <select id="datalistPage" parameterType="page" resultType="pd">
  149. select
  150. <include refid="Field"></include>
  151. from
  152. <include refid="tableName"></include>
  153. where 1=1
  154. <if test="pd.keywords!= null and pd.keywords != ''"><!-- 关键词检索 -->
  155. and
  156. (
  157. NAME LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  158. )
  159. </if>
  160. </select>
  161. <select id="saveData" parameterType="pd">
  162. replace into examine_results (COMPANY,COMPANY_ID,YEAR,BZZL) values
  163. (
  164. #{COMPANY_NAME}, #{COMPANY_ID},#{YEAR}, #{BPOINT}
  165. )
  166. </select>
  167. <!-- 列表(全部) -->
  168. <select id="listAll" parameterType="pd" resultType="pd">
  169. select
  170. <include refid="Field"></include>
  171. from
  172. <include refid="tableName"></include>
  173. </select>
  174. <!-- 批量删除 -->
  175. <delete id="deleteAll" parameterType="String">
  176. delete from
  177. <include refid="tableName"></include>
  178. where
  179. ATTACHED_ID in
  180. <foreach item="item" index="index" collection="array" open="(" separator="," close=")">
  181. #{item}
  182. </foreach>
  183. </delete>
  184. <!-- 通过roleid获取角色名 -->
  185. <select id="getRoleName" parameterType="String" resultType="String">
  186. select
  187. ROLE_NAME
  188. from
  189. sys_role
  190. where ROLE_ID = #{roleID}
  191. </select>
  192. <!-- 通过username获取路公司和路段信息 -->
  193. <select id="getCompanyAndRoad" parameterType="String" resultType="pd">
  194. select
  195. COMPANY, ROAD, ROLE_ID
  196. from
  197. sys_user
  198. where USERNAME = #{username}
  199. </select>
  200. <!-- 通过路公司名称获取路公司ID -->
  201. <select id="getCompanyid" parameterType="String" resultType="String">
  202. select
  203. BIANMA
  204. from
  205. oa_department
  206. where NAME = #{company}
  207. </select>
  208. <!-- 通过月报表相关数据 -->
  209. <select id="getdata" parameterType="pd" resultType="pd">
  210. select a.*,b.status from (
  211. select DISTINCT * from(
  212. select h.COMPANY_ID,h.COMPANY,h.ROAD_ID,h.ROAD,h.YEAR,h.PROJECT_NAME,
  213. h.CATEGORY,h.PROJECT_SCALE,h.QUANTITIES,h.PROJECT_COST,IFNULL(h.AUDIT_FEE,h.PROJECT_COST) as AUDIT_FEE,h.OTHER_MATTER,
  214. h.SJWCGCL as ACTUAL_QUANTITIES,h.AUDIT_MAKER,
  215. m.ACTUAL_QUANTITIES_1,m.ACTUAL_COST_1,m.PAY_COST_1,m.RATIO_1,m.ACTUAL_QUANTITIES_2,m.ACTUAL_COST_2,m.PAY_COST_2,m.RATIO_2,m.ACTUAL_QUANTITIES_3,m.ACTUAL_COST_3,m.PAY_COST_3,m.RATIO_3,
  216. m.ACTUAL_QUANTITIES_4,m.ACTUAL_COST_4,m.PAY_COST_4,m.RATIO_4,m.ACTUAL_QUANTITIES_5,m.ACTUAL_COST_5,m.PAY_COST_5,m.RATIO_5,m.ACTUAL_QUANTITIES_6,m.ACTUAL_COST_6,m.PAY_COST_6,m.RATIO_6,
  217. m.ACTUAL_QUANTITIES_7,m.ACTUAL_COST_7,m.PAY_COST_7,m.RATIO_7,m.ACTUAL_QUANTITIES_8,m.ACTUAL_COST_8,m.PAY_COST_8,m.RATIO_8,m.ACTUAL_QUANTITIES_9,m.ACTUAL_COST_9,m.PAY_COST_9,m.RATIO_9,
  218. m.ACTUAL_QUANTITIES_10,m.ACTUAL_COST_10,m.PAY_COST_10,m.RATIO_10,m.ACTUAL_QUANTITIES_11,m.ACTUAL_COST_11,m.PAY_COST_11,m.RATIO_11,m.ACTUAL_QUANTITIES_12,m.ACTUAL_COST_12,m.PAY_COST_12,m.RATIO_12,
  219. m.PLAN_COST_1,m.PLAN_QUANTITIES_1,m.PLAN_COST_2,m.PLAN_QUANTITIES_2,m.PLAN_COST_3,m.PLAN_QUANTITIES_3,
  220. m.PLAN_COST_4,m.PLAN_QUANTITIES_4,m.PLAN_COST_5,m.PLAN_QUANTITIES_5,m.PLAN_COST_6,m.PLAN_QUANTITIES_6,
  221. m.PLAN_COST_7,m.PLAN_QUANTITIES_7,m.PLAN_COST_8,m.PLAN_QUANTITIES_8,m.PLAN_COST_9,m.PLAN_QUANTITIES_9,
  222. m.PLAN_COST_10,m.PLAN_QUANTITIES_10,m.PLAN_COST_11,m.PLAN_QUANTITIES_11,m.PLAN_COST_12,m.PLAN_QUANTITIES_12
  223. from ${planTable} h
  224. left join (
  225. select yb.COMPANY_ID,yb.ROAD_ID,yb.YEAR,yb.PROJECT_NAME
  226. ,max(ACTUAL_QUANTITIES_1) as ACTUAL_QUANTITIES_1,max(ACTUAL_COST_1) as ACTUAL_COST_1,max(PAY_COST_1) as PAY_COST_1,max(RATIO_1) as RATIO_1
  227. ,max(ACTUAL_QUANTITIES_2) as ACTUAL_QUANTITIES_2,max(ACTUAL_COST_2) as ACTUAL_COST_2,max(PAY_COST_2) as PAY_COST_2,max(RATIO_2) as RATIO_2
  228. ,max(ACTUAL_QUANTITIES_3) as ACTUAL_QUANTITIES_3,max(ACTUAL_COST_3) as ACTUAL_COST_3,max(PAY_COST_3) as PAY_COST_3,max(RATIO_3) as RATIO_3
  229. ,max(ACTUAL_QUANTITIES_4) as ACTUAL_QUANTITIES_4,max(ACTUAL_COST_4) as ACTUAL_COST_4,max(PAY_COST_4) as PAY_COST_4,max(RATIO_4) as RATIO_4
  230. ,max(ACTUAL_QUANTITIES_5) as ACTUAL_QUANTITIES_5,max(ACTUAL_COST_5) as ACTUAL_COST_5,max(PAY_COST_5) as PAY_COST_5,max(RATIO_5) as RATIO_5
  231. ,max(ACTUAL_QUANTITIES_6) as ACTUAL_QUANTITIES_6,max(ACTUAL_COST_6) as ACTUAL_COST_6,max(PAY_COST_6) as PAY_COST_6,max(RATIO_6) as RATIO_6
  232. ,max(ACTUAL_QUANTITIES_7) as ACTUAL_QUANTITIES_7,max(ACTUAL_COST_7) as ACTUAL_COST_7,max(PAY_COST_7) as PAY_COST_7,max(RATIO_7) as RATIO_7
  233. ,max(ACTUAL_QUANTITIES_8) as ACTUAL_QUANTITIES_8,max(ACTUAL_COST_8) as ACTUAL_COST_8,max(PAY_COST_8) as PAY_COST_8,max(RATIO_8) as RATIO_8
  234. ,max(ACTUAL_QUANTITIES_9) as ACTUAL_QUANTITIES_9,max(ACTUAL_COST_9) as ACTUAL_COST_9,max(PAY_COST_9) as PAY_COST_9,max(RATIO_9) as RATIO_9
  235. ,max(ACTUAL_QUANTITIES_10) as ACTUAL_QUANTITIES_10,max(ACTUAL_COST_10) as ACTUAL_COST_10,max(PAY_COST_10) as PAY_COST_10,max(RATIO_10) as RATIO_10
  236. ,max(ACTUAL_QUANTITIES_11) as ACTUAL_QUANTITIES_11,max(ACTUAL_COST_11) as ACTUAL_COST_11,max(PAY_COST_11) as PAY_COST_11,max(RATIO_11) as RATIO_11
  237. ,max(ACTUAL_QUANTITIES_12) as ACTUAL_QUANTITIES_12,max(ACTUAL_COST_12) as ACTUAL_COST_12,max(PAY_COST_12) as PAY_COST_12,max(RATIO_12) as RATIO_12
  238. ,max(PLAN_COST_1) as PLAN_COST_1,max(PLAN_QUANTITIES_1) as PLAN_QUANTITIES_1
  239. ,max(PLAN_COST_2) as PLAN_COST_2,max(PLAN_QUANTITIES_2) as PLAN_QUANTITIES_2
  240. ,max(PLAN_COST_3) as PLAN_COST_3,max(PLAN_QUANTITIES_3) as PLAN_QUANTITIES_3
  241. ,max(PLAN_COST_4) as PLAN_COST_4,max(PLAN_QUANTITIES_4) as PLAN_QUANTITIES_4
  242. ,max(PLAN_COST_5) as PLAN_COST_5,max(PLAN_QUANTITIES_5) as PLAN_QUANTITIES_5
  243. ,max(PLAN_COST_6) as PLAN_COST_6,max(PLAN_QUANTITIES_6) as PLAN_QUANTITIES_6
  244. ,max(PLAN_COST_7) as PLAN_COST_7,max(PLAN_QUANTITIES_7) as PLAN_QUANTITIES_7
  245. ,max(PLAN_COST_8) as PLAN_COST_8,max(PLAN_QUANTITIES_8) as PLAN_QUANTITIES_8
  246. ,max(PLAN_COST_9) as PLAN_COST_9,max(PLAN_QUANTITIES_9) as PLAN_QUANTITIES_9
  247. ,max(PLAN_COST_10) as PLAN_COST_10,max(PLAN_QUANTITIES_10) as PLAN_QUANTITIES_10
  248. ,max(PLAN_COST_11) as PLAN_COST_11,max(PLAN_QUANTITIES_11) as PLAN_QUANTITIES_11
  249. ,max(PLAN_COST_12) as PLAN_COST_12,max(PLAN_QUANTITIES_12) as PLAN_QUANTITIES_12
  250. from(
  251. select *
  252. ,case when month=1 then PLAN_COST else null end PLAN_COST_1
  253. ,case when month=1 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_1
  254. ,case when month=2 then PLAN_COST else null end PLAN_COST_2
  255. ,case when month=2 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_2
  256. ,case when month=3 then PLAN_COST else null end PLAN_COST_3
  257. ,case when month=3 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_3
  258. ,case when month=4 then PLAN_COST else null end PLAN_COST_4
  259. ,case when month=4 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_4
  260. ,case when month=5 then PLAN_COST else null end PLAN_COST_5
  261. ,case when month=5 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_5
  262. ,case when month=6 then PLAN_COST else null end PLAN_COST_6
  263. ,case when month=6 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_6
  264. ,case when month=7 then PLAN_COST else null end PLAN_COST_7
  265. ,case when month=7 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_7
  266. ,case when month=8 then PLAN_COST else null end PLAN_COST_8
  267. ,case when month=8 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_8
  268. ,case when month=9 then PLAN_COST else null end PLAN_COST_9
  269. ,case when month=9 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_9
  270. ,case when month=10 then PLAN_COST else null end PLAN_COST_10
  271. ,case when month=10 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_10
  272. ,case when month=11 then PLAN_COST else null end PLAN_COST_11
  273. ,case when month=11 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_11
  274. ,case when month=12 then PLAN_COST else null end PLAN_COST_12
  275. ,case when month=12 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_12
  276. from monthly_plan_record
  277. where PROJECT_TYPE = #{planTable} and YEAR = #{YEAR}
  278. <if test="ROADS != null and ROADS != ''">
  279. AND ROAD IN
  280. <foreach collection="ROADS" item="ROADS" index="index"
  281. open="(" close=")" separator=",">
  282. #{ROADS}
  283. </foreach>
  284. </if>
  285. )yb left join (
  286. select *
  287. ,case when month=1 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_1
  288. ,case when month=1 then ACTUAL_COST else null end ACTUAL_COST_1
  289. ,case when month=1 then PAY_COST else null end PAY_COST_1
  290. ,case when month=1 then RATIO else null end RATIO_1
  291. ,case when month=2 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_2
  292. ,case when month=2 then ACTUAL_COST else null end ACTUAL_COST_2
  293. ,case when month=2 then PAY_COST else null end PAY_COST_2
  294. ,case when month=2 then RATIO else null end RATIO_2
  295. ,case when month=3 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_3
  296. ,case when month=3 then ACTUAL_COST else null end ACTUAL_COST_3
  297. ,case when month=3 then PAY_COST else null end PAY_COST_3
  298. ,case when month=3 then RATIO else null end RATIO_3
  299. ,case when month=4 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_4
  300. ,case when month=4 then ACTUAL_COST else null end ACTUAL_COST_4
  301. ,case when month=4 then PAY_COST else null end PAY_COST_4
  302. ,case when month=4 then RATIO else null end RATIO_4
  303. ,case when month=5 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_5
  304. ,case when month=5 then ACTUAL_COST else null end ACTUAL_COST_5
  305. ,case when month=5 then PAY_COST else null end PAY_COST_5
  306. ,case when month=5 then RATIO else null end RATIO_5
  307. ,case when month=6 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_6
  308. ,case when month=6 then ACTUAL_COST else null end ACTUAL_COST_6
  309. ,case when month=6 then PAY_COST else null end PAY_COST_6
  310. ,case when month=6 then RATIO else null end RATIO_6
  311. ,case when month=7 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_7
  312. ,case when month=7 then ACTUAL_COST else null end ACTUAL_COST_7
  313. ,case when month=7 then PAY_COST else null end PAY_COST_7
  314. ,case when month=7 then RATIO else null end RATIO_7
  315. ,case when month=8 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_8
  316. ,case when month=8 then ACTUAL_COST else null end ACTUAL_COST_8
  317. ,case when month=8 then PAY_COST else null end PAY_COST_8
  318. ,case when month=8 then RATIO else null end RATIO_8
  319. ,case when month=9 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_9
  320. ,case when month=9 then ACTUAL_COST else null end ACTUAL_COST_9
  321. ,case when month=9 then PAY_COST else null end PAY_COST_9
  322. ,case when month=9 then RATIO else null end RATIO_9
  323. ,case when month=10 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_10
  324. ,case when month=10 then ACTUAL_COST else null end ACTUAL_COST_10
  325. ,case when month=10 then PAY_COST else null end PAY_COST_10
  326. ,case when month=10 then RATIO else null end RATIO_10
  327. ,case when month=11 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_11
  328. ,case when month=11 then ACTUAL_COST else null end ACTUAL_COST_11
  329. ,case when month=11 then PAY_COST else null end PAY_COST_11
  330. ,case when month=11 then RATIO else null end RATIO_11
  331. ,case when month=12 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_12
  332. ,case when month=12 then ACTUAL_COST else null end ACTUAL_COST_12
  333. ,case when month=12 then PAY_COST else null end PAY_COST_12
  334. ,case when month=12 then RATIO else null end RATIO_12
  335. from ${type}
  336. where YEAR = #{YEAR}
  337. )mpr on yb.YEAR = mpr.YEAR and yb.COMPANY_ID = mpr.COMPANY_ID and yb.ROAD_ID = mpr.ROAD_ID
  338. and yb.PROJECT_NAME = mpr.PROJECT_NAME
  339. group by yb.YEAR,yb.COMPANY_ID,yb.ROAD_ID,yb.PROJECT_NAME
  340. ) m
  341. on h.YEAR = m.YEAR and h.COMPANY_ID = m.COMPANY_ID and h.ROAD_ID = m.ROAD_ID and h.PROJECT_NAME = m.PROJECT_NAME
  342. where h.YEAR = #{YEAR}
  343. order by CATEGORY, PROJECT_NAME
  344. )e
  345. order by COMPANY_ID, ROAD_ID desc
  346. )a left join annual_plan_list b on a.year=b.year and a.company_id=b.company_id where b.STATUS='审批通过'
  347. </select>
  348. <!-- 列表 -->
  349. <select id="getCompPlanList" parameterType="page" resultType="String">
  350. select
  351. distinct YEAR
  352. from
  353. annual_plan_list
  354. WHERE STATUS='审批通过'
  355. <if test="COMPANY != null">
  356. AND COMPANY_NAME=#{COMPANY}
  357. </if>
  358. ORDER BY YEAR DESC
  359. </select>
  360. <!-- 通过试验检测、设备大修月报表相关数据 -->
  361. <select id="getTestdata" parameterType="pd" resultType="pd">
  362. select a.*,b.status from (
  363. select DISTINCT * from(
  364. select h.COMPANY_ID,h.COMPANY,h.ROAD_ID,h.ROAD,h.YEAR,h.PROJECT_NAME,
  365. h.CATEGORY,h.CONTENT,h.PROJECT_COST,
  366. IFNULL(h.AUDIT_FEE,h.PROJECT_COST) as AUDIT_FEE,h.AUDIT_MAKER,h.XMWCQKSM as ACTUAL_QUANTITIES,
  367. m.ACTUAL_QUANTITIES_1,m.ACTUAL_COST_1,m.PAY_COST_1,m.RATIO_1,m.ACTUAL_QUANTITIES_2,m.ACTUAL_COST_2,m.PAY_COST_2,m.RATIO_2,m.ACTUAL_QUANTITIES_3,m.ACTUAL_COST_3,m.PAY_COST_3,m.RATIO_3,
  368. m.ACTUAL_QUANTITIES_4,m.ACTUAL_COST_4,m.PAY_COST_4,m.RATIO_4,m.ACTUAL_QUANTITIES_5,m.ACTUAL_COST_5,m.PAY_COST_5,m.RATIO_5,m.ACTUAL_QUANTITIES_6,m.ACTUAL_COST_6,m.PAY_COST_6,m.RATIO_6,
  369. m.ACTUAL_QUANTITIES_7,m.ACTUAL_COST_7,m.PAY_COST_7,m.RATIO_7,m.ACTUAL_QUANTITIES_8,m.ACTUAL_COST_8,m.PAY_COST_8,m.RATIO_8,m.ACTUAL_QUANTITIES_9,m.ACTUAL_COST_9,m.PAY_COST_9,m.RATIO_9,
  370. m.ACTUAL_QUANTITIES_10,m.ACTUAL_COST_10,m.PAY_COST_10,m.RATIO_10,m.ACTUAL_QUANTITIES_11,m.ACTUAL_COST_11,m.PAY_COST_11,m.RATIO_11,m.ACTUAL_QUANTITIES_12,m.ACTUAL_COST_12,m.PAY_COST_12,m.RATIO_12,
  371. m.PLAN_COST_1,m.PLAN_QUANTITIES_1,m.PLAN_COST_2,m.PLAN_QUANTITIES_2,m.PLAN_COST_3,m.PLAN_QUANTITIES_3,
  372. m.PLAN_COST_4,m.PLAN_QUANTITIES_4,m.PLAN_COST_5,m.PLAN_QUANTITIES_5,m.PLAN_COST_6,m.PLAN_QUANTITIES_6,
  373. m.PLAN_COST_7,m.PLAN_QUANTITIES_7,m.PLAN_COST_8,m.PLAN_QUANTITIES_8,m.PLAN_COST_9,m.PLAN_QUANTITIES_9,
  374. m.PLAN_COST_10,m.PLAN_QUANTITIES_10,m.PLAN_COST_11,m.PLAN_QUANTITIES_11,m.PLAN_COST_12,m.PLAN_QUANTITIES_12
  375. from ${planTable} h
  376. left join (
  377. select yb.COMPANY_ID,yb.ROAD_ID,yb.YEAR,yb.PROJECT_NAME
  378. ,max(ACTUAL_QUANTITIES_1) as ACTUAL_QUANTITIES_1,max(ACTUAL_COST_1) as ACTUAL_COST_1,max(PAY_COST_1) as PAY_COST_1,max(RATIO_1) as RATIO_1
  379. ,max(ACTUAL_QUANTITIES_2) as ACTUAL_QUANTITIES_2,max(ACTUAL_COST_2) as ACTUAL_COST_2,max(PAY_COST_2) as PAY_COST_2,max(RATIO_2) as RATIO_2
  380. ,max(ACTUAL_QUANTITIES_3) as ACTUAL_QUANTITIES_3,max(ACTUAL_COST_3) as ACTUAL_COST_3,max(PAY_COST_3) as PAY_COST_3,max(RATIO_3) as RATIO_3
  381. ,max(ACTUAL_QUANTITIES_4) as ACTUAL_QUANTITIES_4,max(ACTUAL_COST_4) as ACTUAL_COST_4,max(PAY_COST_4) as PAY_COST_4,max(RATIO_4) as RATIO_4
  382. ,max(ACTUAL_QUANTITIES_5) as ACTUAL_QUANTITIES_5,max(ACTUAL_COST_5) as ACTUAL_COST_5,max(PAY_COST_5) as PAY_COST_5,max(RATIO_5) as RATIO_5
  383. ,max(ACTUAL_QUANTITIES_6) as ACTUAL_QUANTITIES_6,max(ACTUAL_COST_6) as ACTUAL_COST_6,max(PAY_COST_6) as PAY_COST_6,max(RATIO_6) as RATIO_6
  384. ,max(ACTUAL_QUANTITIES_7) as ACTUAL_QUANTITIES_7,max(ACTUAL_COST_7) as ACTUAL_COST_7,max(PAY_COST_7) as PAY_COST_7,max(RATIO_7) as RATIO_7
  385. ,max(ACTUAL_QUANTITIES_8) as ACTUAL_QUANTITIES_8,max(ACTUAL_COST_8) as ACTUAL_COST_8,max(PAY_COST_8) as PAY_COST_8,max(RATIO_8) as RATIO_8
  386. ,max(ACTUAL_QUANTITIES_9) as ACTUAL_QUANTITIES_9,max(ACTUAL_COST_9) as ACTUAL_COST_9,max(PAY_COST_9) as PAY_COST_9,max(RATIO_9) as RATIO_9
  387. ,max(ACTUAL_QUANTITIES_10) as ACTUAL_QUANTITIES_10,max(ACTUAL_COST_10) as ACTUAL_COST_10,max(PAY_COST_10) as PAY_COST_10,max(RATIO_10) as RATIO_10
  388. ,max(ACTUAL_QUANTITIES_11) as ACTUAL_QUANTITIES_11,max(ACTUAL_COST_11) as ACTUAL_COST_11,max(PAY_COST_11) as PAY_COST_11,max(RATIO_11) as RATIO_11
  389. ,max(ACTUAL_QUANTITIES_12) as ACTUAL_QUANTITIES_12,max(ACTUAL_COST_12) as ACTUAL_COST_12,max(PAY_COST_12) as PAY_COST_12,max(RATIO_12) as RATIO_12
  390. ,max(PLAN_COST_1) as PLAN_COST_1,max(PLAN_QUANTITIES_1) as PLAN_QUANTITIES_1
  391. ,max(PLAN_COST_2) as PLAN_COST_2,max(PLAN_QUANTITIES_2) as PLAN_QUANTITIES_2
  392. ,max(PLAN_COST_3) as PLAN_COST_3,max(PLAN_QUANTITIES_3) as PLAN_QUANTITIES_3
  393. ,max(PLAN_COST_4) as PLAN_COST_4,max(PLAN_QUANTITIES_4) as PLAN_QUANTITIES_4
  394. ,max(PLAN_COST_5) as PLAN_COST_5,max(PLAN_QUANTITIES_5) as PLAN_QUANTITIES_5
  395. ,max(PLAN_COST_6) as PLAN_COST_6,max(PLAN_QUANTITIES_6) as PLAN_QUANTITIES_6
  396. ,max(PLAN_COST_7) as PLAN_COST_7,max(PLAN_QUANTITIES_7) as PLAN_QUANTITIES_7
  397. ,max(PLAN_COST_8) as PLAN_COST_8,max(PLAN_QUANTITIES_8) as PLAN_QUANTITIES_8
  398. ,max(PLAN_COST_9) as PLAN_COST_9,max(PLAN_QUANTITIES_9) as PLAN_QUANTITIES_9
  399. ,max(PLAN_COST_10) as PLAN_COST_10,max(PLAN_QUANTITIES_10) as PLAN_QUANTITIES_10
  400. ,max(PLAN_COST_11) as PLAN_COST_11,max(PLAN_QUANTITIES_11) as PLAN_QUANTITIES_11
  401. ,max(PLAN_COST_12) as PLAN_COST_12,max(PLAN_QUANTITIES_12) as PLAN_QUANTITIES_12
  402. from (
  403. select *
  404. ,case when month=1 then PLAN_COST else null end PLAN_COST_1
  405. ,case when month=1 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_1
  406. ,case when month=2 then PLAN_COST else null end PLAN_COST_2
  407. ,case when month=2 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_2
  408. ,case when month=3 then PLAN_COST else null end PLAN_COST_3
  409. ,case when month=3 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_3
  410. ,case when month=4 then PLAN_COST else null end PLAN_COST_4
  411. ,case when month=4 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_4
  412. ,case when month=5 then PLAN_COST else null end PLAN_COST_5
  413. ,case when month=5 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_5
  414. ,case when month=6 then PLAN_COST else null end PLAN_COST_6
  415. ,case when month=6 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_6
  416. ,case when month=7 then PLAN_COST else null end PLAN_COST_7
  417. ,case when month=7 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_7
  418. ,case when month=8 then PLAN_COST else null end PLAN_COST_8
  419. ,case when month=8 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_8
  420. ,case when month=9 then PLAN_COST else null end PLAN_COST_9
  421. ,case when month=9 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_9
  422. ,case when month=10 then PLAN_COST else null end PLAN_COST_10
  423. ,case when month=10 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_10
  424. ,case when month=11 then PLAN_COST else null end PLAN_COST_11
  425. ,case when month=11 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_11
  426. ,case when month=12 then PLAN_COST else null end PLAN_COST_12
  427. ,case when month=12 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_12
  428. from monthly_plan_record
  429. where PROJECT_TYPE = #{planTable} and YEAR = #{YEAR}
  430. )yb
  431. left join (
  432. select *
  433. ,case when month=1 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_1
  434. ,case when month=1 then ACTUAL_COST else null end ACTUAL_COST_1
  435. ,case when month=1 then PAY_COST else null end PAY_COST_1
  436. ,case when month=1 then RATIO else null end RATIO_1
  437. ,case when month=2 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_2
  438. ,case when month=2 then ACTUAL_COST else null end ACTUAL_COST_2
  439. ,case when month=2 then PAY_COST else null end PAY_COST_2
  440. ,case when month=2 then RATIO else null end RATIO_2
  441. ,case when month=3 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_3
  442. ,case when month=3 then ACTUAL_COST else null end ACTUAL_COST_3
  443. ,case when month=3 then PAY_COST else null end PAY_COST_3
  444. ,case when month=3 then RATIO else null end RATIO_3
  445. ,case when month=4 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_4
  446. ,case when month=4 then ACTUAL_COST else null end ACTUAL_COST_4
  447. ,case when month=4 then PAY_COST else null end PAY_COST_4
  448. ,case when month=4 then RATIO else null end RATIO_4
  449. ,case when month=5 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_5
  450. ,case when month=5 then ACTUAL_COST else null end ACTUAL_COST_5
  451. ,case when month=5 then PAY_COST else null end PAY_COST_5
  452. ,case when month=5 then RATIO else null end RATIO_5
  453. ,case when month=6 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_6
  454. ,case when month=6 then ACTUAL_COST else null end ACTUAL_COST_6
  455. ,case when month=6 then PAY_COST else null end PAY_COST_6
  456. ,case when month=6 then RATIO else null end RATIO_6
  457. ,case when month=7 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_7
  458. ,case when month=7 then ACTUAL_COST else null end ACTUAL_COST_7
  459. ,case when month=7 then PAY_COST else null end PAY_COST_7
  460. ,case when month=7 then RATIO else null end RATIO_7
  461. ,case when month=8 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_8
  462. ,case when month=8 then ACTUAL_COST else null end ACTUAL_COST_8
  463. ,case when month=8 then PAY_COST else null end PAY_COST_8
  464. ,case when month=8 then RATIO else null end RATIO_8
  465. ,case when month=9 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_9
  466. ,case when month=9 then ACTUAL_COST else null end ACTUAL_COST_9
  467. ,case when month=9 then PAY_COST else null end PAY_COST_9
  468. ,case when month=9 then RATIO else null end RATIO_9
  469. ,case when month=10 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_10
  470. ,case when month=10 then ACTUAL_COST else null end ACTUAL_COST_10
  471. ,case when month=10 then PAY_COST else null end PAY_COST_10
  472. ,case when month=10 then RATIO else null end RATIO_10
  473. ,case when month=11 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_11
  474. ,case when month=11 then ACTUAL_COST else null end ACTUAL_COST_11
  475. ,case when month=11 then PAY_COST else null end PAY_COST_11
  476. ,case when month=11 then RATIO else null end RATIO_11
  477. ,case when month=12 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_12
  478. ,case when month=12 then ACTUAL_COST else null end ACTUAL_COST_12
  479. ,case when month=12 then PAY_COST else null end PAY_COST_12
  480. ,case when month=12 then RATIO else null end RATIO_12
  481. from ${type}
  482. where YEAR = #{YEAR}
  483. )mpr on yb.YEAR = mpr.YEAR and yb.COMPANY_ID = mpr.COMPANY_ID and yb.ROAD_ID = mpr.ROAD_ID
  484. and yb.PROJECT_NAME = mpr.PROJECT_NAME
  485. group by yb.YEAR,yb.COMPANY_ID,yb.ROAD_ID,yb.PROJECT_NAME
  486. ) m
  487. on h.YEAR = m.YEAR and h.COMPANY_ID = m.COMPANY_ID and h.ROAD_ID = m.ROAD_ID and h.PROJECT_NAME = m.PROJECT_NAME
  488. where h.YEAR = #{YEAR}
  489. )e
  490. order by COMPANY_ID, ROAD_ID desc
  491. )a left join annual_plan_list b on a.year=b.year and a.company_id=b.company_id where b.STATUS='审批通过'
  492. </select>
  493. <!-- 通过科研月报表相关数据 -->
  494. <select id="getScidata" parameterType="pd" resultType="pd">
  495. select a.*,b.status from (
  496. select DISTINCT * from(
  497. select h.COMPANY_ID,h.COMPANY,h.ROAD_ID,h.ROAD,h.YEAR,h.PROJECT_NAME,
  498. h.CATEGORY,h.CONTENT,h.YEAR_COST as PROJECT_COST ,IFNULL(h.AUDIT_FEE,h.YEAR_COST) as AUDIT_FEE,h.MATTER_YEAR,h.MATTER_NEW_CARRY,h.MATTER_CONSULT,
  499. h.XMWCQKSM as ACTUAL_QUANTITIES,
  500. m.ACTUAL_QUANTITIES_1,m.ACTUAL_COST_1,m.PAY_COST_1,m.RATIO_1,m.ACTUAL_QUANTITIES_2,m.ACTUAL_COST_2,m.PAY_COST_2,m.RATIO_2,m.ACTUAL_QUANTITIES_3,m.ACTUAL_COST_3,m.PAY_COST_3,m.RATIO_3,
  501. m.ACTUAL_QUANTITIES_4,m.ACTUAL_COST_4,m.PAY_COST_4,m.RATIO_4,m.ACTUAL_QUANTITIES_5,m.ACTUAL_COST_5,m.PAY_COST_5,m.RATIO_5,m.ACTUAL_QUANTITIES_6,m.ACTUAL_COST_6,m.PAY_COST_6,m.RATIO_6,
  502. m.ACTUAL_QUANTITIES_7,m.ACTUAL_COST_7,m.PAY_COST_7,m.RATIO_7,m.ACTUAL_QUANTITIES_8,m.ACTUAL_COST_8,m.PAY_COST_8,m.RATIO_8,m.ACTUAL_QUANTITIES_9,m.ACTUAL_COST_9,m.PAY_COST_9,m.RATIO_9,
  503. m.ACTUAL_QUANTITIES_10,m.ACTUAL_COST_10,m.PAY_COST_10,m.RATIO_10,m.ACTUAL_QUANTITIES_11,m.ACTUAL_COST_11,m.PAY_COST_11,m.RATIO_11,m.ACTUAL_QUANTITIES_12,m.ACTUAL_COST_12,m.PAY_COST_12,m.RATIO_12
  504. from ${planTable} h
  505. left join (
  506. select yb.COMPANY_ID,yb.ROAD_ID,yb.YEAR,yb.PROJECT_NAME
  507. ,max(ACTUAL_QUANTITIES_1) as ACTUAL_QUANTITIES_1,max(ACTUAL_COST_1) as ACTUAL_COST_1,max(PAY_COST_1) as PAY_COST_1,max(RATIO_1) as RATIO_1
  508. ,max(ACTUAL_QUANTITIES_2) as ACTUAL_QUANTITIES_2,max(ACTUAL_COST_2) as ACTUAL_COST_2,max(PAY_COST_2) as PAY_COST_2,max(RATIO_2) as RATIO_2
  509. ,max(ACTUAL_QUANTITIES_3) as ACTUAL_QUANTITIES_3,max(ACTUAL_COST_3) as ACTUAL_COST_3,max(PAY_COST_3) as PAY_COST_3,max(RATIO_3) as RATIO_3
  510. ,max(ACTUAL_QUANTITIES_4) as ACTUAL_QUANTITIES_4,max(ACTUAL_COST_4) as ACTUAL_COST_4,max(PAY_COST_4) as PAY_COST_4,max(RATIO_4) as RATIO_4
  511. ,max(ACTUAL_QUANTITIES_5) as ACTUAL_QUANTITIES_5,max(ACTUAL_COST_5) as ACTUAL_COST_5,max(PAY_COST_5) as PAY_COST_5,max(RATIO_5) as RATIO_5
  512. ,max(ACTUAL_QUANTITIES_6) as ACTUAL_QUANTITIES_6,max(ACTUAL_COST_6) as ACTUAL_COST_6,max(PAY_COST_6) as PAY_COST_6,max(RATIO_6) as RATIO_6
  513. ,max(ACTUAL_QUANTITIES_7) as ACTUAL_QUANTITIES_7,max(ACTUAL_COST_7) as ACTUAL_COST_7,max(PAY_COST_7) as PAY_COST_7,max(RATIO_7) as RATIO_7
  514. ,max(ACTUAL_QUANTITIES_8) as ACTUAL_QUANTITIES_8,max(ACTUAL_COST_8) as ACTUAL_COST_8,max(PAY_COST_8) as PAY_COST_8,max(RATIO_8) as RATIO_8
  515. ,max(ACTUAL_QUANTITIES_9) as ACTUAL_QUANTITIES_9,max(ACTUAL_COST_9) as ACTUAL_COST_9,max(PAY_COST_9) as PAY_COST_9,max(RATIO_9) as RATIO_9
  516. ,max(ACTUAL_QUANTITIES_10) as ACTUAL_QUANTITIES_10,max(ACTUAL_COST_10) as ACTUAL_COST_10,max(PAY_COST_10) as PAY_COST_10,max(RATIO_10) as RATIO_10
  517. ,max(ACTUAL_QUANTITIES_11) as ACTUAL_QUANTITIES_11,max(ACTUAL_COST_11) as ACTUAL_COST_11,max(PAY_COST_11) as PAY_COST_11,max(RATIO_11) as RATIO_11
  518. ,max(ACTUAL_QUANTITIES_12) as ACTUAL_QUANTITIES_12,max(ACTUAL_COST_12) as ACTUAL_COST_12,max(PAY_COST_12) as PAY_COST_12,max(RATIO_12) as RATIO_12
  519. from(
  520. select *
  521. ,case when month=1 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_1
  522. ,case when month=1 then ACTUAL_COST else null end ACTUAL_COST_1
  523. ,case when month=1 then PAY_COST else null end PAY_COST_1
  524. ,case when month=1 then RATIO else null end RATIO_1
  525. ,case when month=2 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_2
  526. ,case when month=2 then ACTUAL_COST else null end ACTUAL_COST_2
  527. ,case when month=2 then PAY_COST else null end PAY_COST_2
  528. ,case when month=2 then RATIO else null end RATIO_2
  529. ,case when month=3 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_3
  530. ,case when month=3 then ACTUAL_COST else null end ACTUAL_COST_3
  531. ,case when month=3 then PAY_COST else null end PAY_COST_3
  532. ,case when month=3 then RATIO else null end RATIO_3
  533. ,case when month=4 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_4
  534. ,case when month=4 then ACTUAL_COST else null end ACTUAL_COST_4
  535. ,case when month=4 then PAY_COST else null end PAY_COST_4
  536. ,case when month=4 then RATIO else null end RATIO_4
  537. ,case when month=5 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_5
  538. ,case when month=5 then ACTUAL_COST else null end ACTUAL_COST_5
  539. ,case when month=5 then PAY_COST else null end PAY_COST_5
  540. ,case when month=5 then RATIO else null end RATIO_5
  541. ,case when month=6 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_6
  542. ,case when month=6 then ACTUAL_COST else null end ACTUAL_COST_6
  543. ,case when month=6 then PAY_COST else null end PAY_COST_6
  544. ,case when month=6 then RATIO else null end RATIO_6
  545. ,case when month=7 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_7
  546. ,case when month=7 then ACTUAL_COST else null end ACTUAL_COST_7
  547. ,case when month=7 then PAY_COST else null end PAY_COST_7
  548. ,case when month=7 then RATIO else null end RATIO_7
  549. ,case when month=8 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_8
  550. ,case when month=8 then ACTUAL_COST else null end ACTUAL_COST_8
  551. ,case when month=8 then PAY_COST else null end PAY_COST_8
  552. ,case when month=8 then RATIO else null end RATIO_8
  553. ,case when month=9 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_9
  554. ,case when month=9 then ACTUAL_COST else null end ACTUAL_COST_9
  555. ,case when month=9 then PAY_COST else null end PAY_COST_9
  556. ,case when month=9 then RATIO else null end RATIO_9
  557. ,case when month=10 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_10
  558. ,case when month=10 then ACTUAL_COST else null end ACTUAL_COST_10
  559. ,case when month=10 then PAY_COST else null end PAY_COST_10
  560. ,case when month=10 then RATIO else null end RATIO_10
  561. ,case when month=11 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_11
  562. ,case when month=11 then ACTUAL_COST else null end ACTUAL_COST_11
  563. ,case when month=11 then PAY_COST else null end PAY_COST_11
  564. ,case when month=11 then RATIO else null end RATIO_11
  565. ,case when month=12 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_12
  566. ,case when month=12 then ACTUAL_COST else null end ACTUAL_COST_12
  567. ,case when month=12 then PAY_COST else null end PAY_COST_12
  568. ,case when month=12 then RATIO else null end RATIO_12
  569. from ${type}
  570. where YEAR = #{YEAR}
  571. )yb group by yb.YEAR,yb.COMPANY_ID,yb.ROAD_ID,yb.PROJECT_NAME
  572. ) m
  573. on h.YEAR = m.YEAR and h.COMPANY_ID = m.COMPANY_ID and h.ROAD_ID = m.ROAD_ID and h.PROJECT_NAME = m.PROJECT_NAME
  574. where h.YEAR = #{YEAR}
  575. )e
  576. order by COMPANY_ID, ROAD_ID desc
  577. )a left join annual_plan_list b on a.year=b.year and a.company_id=b.company_id where b.STATUS='审批通过'
  578. </select>
  579. <!-- 根据年份查询养护计划考核 -->
  580. <select id="queryExamineResultByYear" parameterType="pd" resultType="pd">
  581. SELECT
  582. e.*,
  583. (IFNULL(WCL, 0) +
  584. IFNULL(SBJSL, 0) +
  585. IFNULL(BZZL, 0)) AS 'total_score'
  586. FROM
  587. examine_results e
  588. WHERE
  589. `YEAR` = #{year}
  590. </select>
  591. <!-- 根据年份删除养护计划考核 -->
  592. <delete id="deleExamineResultByYear" parameterType="String">
  593. DELETE
  594. FROM
  595. examine_results
  596. WHERE
  597. `YEAR` = #{year}
  598. </delete>
  599. <!-- 批量新增养护计划考核 -->
  600. <insert id="batchSaveExamineResult" parameterType="pd">
  601. insert into examine_results
  602. (
  603. COMPANY,
  604. COMPANY_ID,
  605. YEAR,
  606. BZZL
  607. )
  608. values
  609. <foreach collection ="list" item="item" separator =",">
  610. (
  611. #{item.COMPANY},
  612. #{item.COMPANY_ID},
  613. #{item.YEAR},
  614. #{item.BZZL}
  615. )
  616. </foreach >
  617. </insert>
  618. <!-- 查询养护计划考核 -->
  619. <select id="queryCompanyExamineResult" parameterType="pd" resultType="pd">
  620. SELECT
  621. o.BIANMA AS 'COMPANY_ID',
  622. o.NAME AS 'COMPANY',
  623. YEAR,
  624. BZZL
  625. FROM
  626. oa_department o
  627. LEFT JOIN examine_results r ON o.BIANMA = r.company_id AND r.year = #{year}
  628. WHERE o.parent_id = '0'
  629. ORDER BY (o.BIANMA+0) ASC
  630. </select>
  631. <!-- 查询公司完成率 -->
  632. <select id="queryWcl" parameterType="pd" resultType="pd">
  633. SELECT
  634. PCOMPANY_ID,
  635. PCOMPANY,
  636. (
  637. (
  638. SUM(IFNULL(DAILY_COMPLETE, 0)) +
  639. SUM(IFNULL(MINOR_PREVENTION_COMPLETE,0)) +
  640. SUM(IFNULL(MIDDLE_PREVENTION_COMPLETE,0)) +
  641. SUM(IFNULL(OVERHAUL_PREVENTION_COMPLETE,0)) +
  642. SUM(IFNULL(MINOR_REPAIR_COMPLETE, 0)) +
  643. SUM(IFNULL(MIDDLE_REPAIR_COMPLETE, 0)) +
  644. SUM(IFNULL(OVERHAUL_COMPLETE, 0)) +
  645. SUM(IFNULL(SPECIAL_COMPLETE, 0)) +
  646. SUM(IFNULL(TEST_COMPLETE, 0)) +
  647. SUM(IFNULL(SCIENTIFIC_COMPLETE, 0)) +
  648. SUM(IFNULL(DEVICE_COMPLETE, 0)) +
  649. SUM(IFNULL(RESERVE_COMPLETE, 0)) +
  650. SUM(IFNULL(EMERGENCY_COMPLETE,0))
  651. ) /
  652. (
  653. SUM(IFNULL(DAILY_DESIGN, 0)) +
  654. SUM(IFNULL(MINOR_PREVENTION_DESIGN, 0)) +
  655. SUM(IFNULL(MIDDLE_PREVENTION_DESIGN, 0)) +
  656. SUM(IFNULL(OVERHAUL_PREVENTION_DESIGN,0)) +
  657. SUM(IFNULL(MINOR_REPAIR_DESIGN, 0)) +
  658. SUM(IFNULL(MIDDLE_REPAIR_DESIGN, 0)) +
  659. SUM(IFNULL(OVERHAUL_DESIGN, 0)) +
  660. SUM(IFNULL(SPECIAL_DESIGN, 0)) +
  661. SUM(IFNULL(TEST_DESIGN, 0)) +
  662. SUM(IFNULL(SCIENTIFIC_DESIGN, 0)) +
  663. SUM(IFNULL(DEVICE_DESIGN, 0)) +
  664. SUM(IFNULL(RESERVE_DESIGN, 0)) +
  665. SUM(IFNULL(EMERGENCY_DESIGN,0))
  666. )
  667. ) AS 'WCL'
  668. FROM
  669. annual_comp_sumtable_view
  670. WHERE `YEAR` = #{year}
  671. GROUP BY
  672. PCOMPANY_ID,
  673. PCOMPANY
  674. </select>
  675. <!-- 查询上报及时率 -->
  676. <select id="querySbjsl" parameterType="pd" resultType="pd">
  677. SELECT
  678. p.*, s.sptime,
  679. CASE
  680. WHEN DATEDIFF(s.sptime, p.TJTIME) >= 0 THEN 5
  681. WHEN DATEDIFF(s.sptime, p.TJTIME) >= -7 THEN 3
  682. ELSE 1 END AS 'SBJSL'
  683. FROM
  684. annual_plan_list p
  685. LEFT JOIN sptime s ON p.`YEAR` = s.`YEAR`
  686. WHERE
  687. p.`YEAR` = #{year}
  688. AND TJTIME IS NOT NULL
  689. </select>
  690. <!-- 查询年度计划 -->
  691. <select id="queryAnnualPlanYear" parameterType="pd" resultType="pd" >
  692. SELECT
  693. DISTINCT
  694. `YEAR` AS 'year'
  695. FROM
  696. annual_plan_list
  697. ORDER BY
  698. YEAR DESC
  699. </select>
  700. <select id="getCompanyRoadList" parameterType="pd" resultType="pd">
  701. select * from ${table} ORDER BY (BIANMA+0) ASC
  702. </select>
  703. </mapper>