YjMonthProgressMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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="YjMonthProgressMapper">
  4. <!-- 新增月度报告-->
  5. <insert id="addMonthlyReport" parameterType="pd">
  6. insert into
  7. monthly_report_list
  8. (
  9. COMPANY, COMPANY_ID,YEAR,NAME,STATUS,CTIME, MTIME
  10. ) values (
  11. #{COMPANY}, #{COMPANY_ID}, #{YEAR}, #{NAME}, #{STATUS}, #{CTIME}, #{MTIME}
  12. )
  13. </insert>
  14. <!-- 删除-->
  15. <!-- <delete id="delete" parameterType="pd">
  16. delete from
  17. <include refid="tableName"></include>
  18. where
  19. ANNUALPLAN_ID = #{ANNUALPLAN_ID}
  20. </delete> -->
  21. <!-- 显示子表格内容 -->
  22. <select id="list" parameterType="pd" resultType="pd">
  23. select
  24. *
  25. from
  26. monthly_report_list
  27. where
  28. 1=1
  29. <if test="pd.keywords!= null and pd.keywords != ''"><!-- 关键词检索 -->
  30. and
  31. (
  32. NAME LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  33. )
  34. </if>
  35. </select>
  36. <!-- 通过username获取路公司和路段信息 -->
  37. <select id="getCompanyAndRoad" parameterType="String" resultType="pd">
  38. select
  39. COMPANY, ROAD, ROLE_ID
  40. from
  41. sys_user
  42. where USERNAME = #{username}
  43. </select>
  44. <!-- 通过路公司名称获取路公司ID -->
  45. <select id="getCompanyid" parameterType="String" resultType="String">
  46. select
  47. BIANMA
  48. from
  49. oa_department
  50. where NAME = #{company}
  51. </select>
  52. <!-- 通过roleid获取角色名 -->
  53. <select id="getRoleName" parameterType="String" resultType="String">
  54. select
  55. ROLE_NAME
  56. from
  57. sys_role
  58. where ROLE_ID = #{roleID}
  59. </select>
  60. <!-- 通过月报表相关数据 -->
  61. <select id="getReportInfo" parameterType="pd" resultType="pd">
  62. select * from(
  63. select
  64. @f:= case when @ROAD_ID2=c.ROAD_ID then '0' else '1' end flag,
  65. @ROAD_ID2:=c.ROAD_ID1 ROAD_ID2,
  66. c.*,cast(num as char)numstr
  67. from(
  68. SELECT
  69. @r:= case when @ROAD_ID=a.ROAD_ID then @r+1 else 1 end num,
  70. @ROAD_ID:=a.ROAD_ID ROAD_ID1,
  71. a.*
  72. from(
  73. select h.COMPANY_ID,h.COMPANY,h.ROAD_ID,h.ROAD,h.YEAR,h.PROJECT_NAME,h.AUDIT_MAKER,
  74. h.CATEGORY,h.PROJECT_SCALE,h.QUANTITIES,
  75. h.PROJECT_COST,
  76. IFNULL(h.AUDIT_FEE,h.PROJECT_COST) as AUDIT_FEE,
  77. h.OTHER_MATTER,h.SJWCGCL as ACTUAL_QUANTITIES,
  78. 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,
  79. 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,
  80. 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,
  81. 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,
  82. m.PLAN_COST_1,m.PLAN_QUANTITIES_1,m.PLAN_COST_2,m.PLAN_QUANTITIES_2,m.PLAN_COST_3,m.PLAN_QUANTITIES_3,
  83. m.PLAN_COST_4,m.PLAN_QUANTITIES_4,m.PLAN_COST_5,m.PLAN_QUANTITIES_5,m.PLAN_COST_6,m.PLAN_QUANTITIES_6,
  84. m.PLAN_COST_7,m.PLAN_QUANTITIES_7,m.PLAN_COST_8,m.PLAN_QUANTITIES_8,m.PLAN_COST_9,m.PLAN_QUANTITIES_9,
  85. m.PLAN_COST_10,m.PLAN_QUANTITIES_10,m.PLAN_COST_11,m.PLAN_QUANTITIES_11,m.PLAN_COST_12,m.PLAN_QUANTITIES_12
  86. from ${subtable} h
  87. left join (
  88. select yb.COMPANY_ID,yb.ROAD_ID,yb.YEAR,yb.PROJECT_NAME
  89. ,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
  90. ,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
  91. ,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
  92. ,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
  93. ,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
  94. ,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
  95. ,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
  96. ,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
  97. ,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
  98. ,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
  99. ,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
  100. ,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
  101. ,max(PLAN_COST_1) as PLAN_COST_1,max(PLAN_QUANTITIES_1) as PLAN_QUANTITIES_1
  102. ,max(PLAN_COST_2) as PLAN_COST_2,max(PLAN_QUANTITIES_2) as PLAN_QUANTITIES_2
  103. ,max(PLAN_COST_3) as PLAN_COST_3,max(PLAN_QUANTITIES_3) as PLAN_QUANTITIES_3
  104. ,max(PLAN_COST_4) as PLAN_COST_4,max(PLAN_QUANTITIES_4) as PLAN_QUANTITIES_4
  105. ,max(PLAN_COST_5) as PLAN_COST_5,max(PLAN_QUANTITIES_5) as PLAN_QUANTITIES_5
  106. ,max(PLAN_COST_6) as PLAN_COST_6,max(PLAN_QUANTITIES_6) as PLAN_QUANTITIES_6
  107. ,max(PLAN_COST_7) as PLAN_COST_7,max(PLAN_QUANTITIES_7) as PLAN_QUANTITIES_7
  108. ,max(PLAN_COST_8) as PLAN_COST_8,max(PLAN_QUANTITIES_8) as PLAN_QUANTITIES_8
  109. ,max(PLAN_COST_9) as PLAN_COST_9,max(PLAN_QUANTITIES_9) as PLAN_QUANTITIES_9
  110. ,max(PLAN_COST_10) as PLAN_COST_10,max(PLAN_QUANTITIES_10) as PLAN_QUANTITIES_10
  111. ,max(PLAN_COST_11) as PLAN_COST_11,max(PLAN_QUANTITIES_11) as PLAN_QUANTITIES_11
  112. ,max(PLAN_COST_12) as PLAN_COST_12,max(PLAN_QUANTITIES_12) as PLAN_QUANTITIES_12
  113. from(
  114. select *
  115. ,case when month=1 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_1
  116. ,case when month=1 then ACTUAL_COST else null end ACTUAL_COST_1
  117. ,case when month=1 then PAY_COST else null end PAY_COST_1
  118. ,case when month=1 then RATIO else null end RATIO_1
  119. ,case when month=2 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_2
  120. ,case when month=2 then ACTUAL_COST else null end ACTUAL_COST_2
  121. ,case when month=2 then PAY_COST else null end PAY_COST_2
  122. ,case when month=2 then RATIO else null end RATIO_2
  123. ,case when month=3 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_3
  124. ,case when month=3 then ACTUAL_COST else null end ACTUAL_COST_3
  125. ,case when month=3 then PAY_COST else null end PAY_COST_3
  126. ,case when month=3 then RATIO else null end RATIO_3
  127. ,case when month=4 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_4
  128. ,case when month=4 then ACTUAL_COST else null end ACTUAL_COST_4
  129. ,case when month=4 then PAY_COST else null end PAY_COST_4
  130. ,case when month=4 then RATIO else null end RATIO_4
  131. ,case when month=5 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_5
  132. ,case when month=5 then ACTUAL_COST else null end ACTUAL_COST_5
  133. ,case when month=5 then PAY_COST else null end PAY_COST_5
  134. ,case when month=5 then RATIO else null end RATIO_5
  135. ,case when month=6 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_6
  136. ,case when month=6 then ACTUAL_COST else null end ACTUAL_COST_6
  137. ,case when month=6 then PAY_COST else null end PAY_COST_6
  138. ,case when month=6 then RATIO else null end RATIO_6
  139. ,case when month=7 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_7
  140. ,case when month=7 then ACTUAL_COST else null end ACTUAL_COST_7
  141. ,case when month=7 then PAY_COST else null end PAY_COST_7
  142. ,case when month=7 then RATIO else null end RATIO_7
  143. ,case when month=8 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_8
  144. ,case when month=8 then ACTUAL_COST else null end ACTUAL_COST_8
  145. ,case when month=8 then PAY_COST else null end PAY_COST_8
  146. ,case when month=8 then RATIO else null end RATIO_8
  147. ,case when month=9 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_9
  148. ,case when month=9 then ACTUAL_COST else null end ACTUAL_COST_9
  149. ,case when month=9 then PAY_COST else null end PAY_COST_9
  150. ,case when month=9 then RATIO else null end RATIO_9
  151. ,case when month=10 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_10
  152. ,case when month=10 then ACTUAL_COST else null end ACTUAL_COST_10
  153. ,case when month=10 then PAY_COST else null end PAY_COST_10
  154. ,case when month=10 then RATIO else null end RATIO_10
  155. ,case when month=11 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_11
  156. ,case when month=11 then ACTUAL_COST else null end ACTUAL_COST_11
  157. ,case when month=11 then PAY_COST else null end PAY_COST_11
  158. ,case when month=11 then RATIO else null end RATIO_11
  159. ,case when month=12 then ACTUAL_QUANTITIES else null end ACTUAL_QUANTITIES_12
  160. ,case when month=12 then ACTUAL_COST else null end ACTUAL_COST_12
  161. ,case when month=12 then PAY_COST else null end PAY_COST_12
  162. ,case when month=12 then RATIO else null end RATIO_12
  163. from ${TABLETYPE}
  164. where YEAR = #{YEAR} and COMPANY_ID = #{COMPANY_ID}
  165. <if test="ROADS != null and ROADS != ''">
  166. AND ROAD IN
  167. <foreach collection="ROADS" item="ROADS" index="index"
  168. open="(" close=")" separator=",">
  169. #{ROADS}
  170. </foreach>
  171. </if>
  172. )yb
  173. left join (
  174. select *
  175. ,case when month=1 then PLAN_COST else null end PLAN_COST_1
  176. ,case when month=1 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_1
  177. ,case when month=2 then PLAN_COST else null end PLAN_COST_2
  178. ,case when month=2 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_2
  179. ,case when month=3 then PLAN_COST else null end PLAN_COST_3
  180. ,case when month=3 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_3
  181. ,case when month=4 then PLAN_COST else null end PLAN_COST_4
  182. ,case when month=4 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_4
  183. ,case when month=5 then PLAN_COST else null end PLAN_COST_5
  184. ,case when month=5 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_5
  185. ,case when month=6 then PLAN_COST else null end PLAN_COST_6
  186. ,case when month=6 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_6
  187. ,case when month=7 then PLAN_COST else null end PLAN_COST_7
  188. ,case when month=7 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_7
  189. ,case when month=8 then PLAN_COST else null end PLAN_COST_8
  190. ,case when month=8 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_8
  191. ,case when month=9 then PLAN_COST else null end PLAN_COST_9
  192. ,case when month=9 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_9
  193. ,case when month=10 then PLAN_COST else null end PLAN_COST_10
  194. ,case when month=10 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_10
  195. ,case when month=11 then PLAN_COST else null end PLAN_COST_11
  196. ,case when month=11 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_11
  197. ,case when month=12 then PLAN_COST else null end PLAN_COST_12
  198. ,case when month=12 then PLAN_QUANTITIES else null end PLAN_QUANTITIES_12
  199. from monthly_plan_record
  200. where PROJECT_TYPE = #{subtable} and YEAR = #{YEAR} and COMPANY_ID = #{COMPANY_ID}
  201. <if test="ROADS != null and ROADS != ''">
  202. AND ROAD IN
  203. <foreach collection="ROADS" item="ROADS" index="index"
  204. open="(" close=")" separator=",">
  205. #{ROADS}
  206. </foreach>
  207. </if>
  208. )mpr
  209. on yb.YEAR = mpr.YEAR and yb.COMPANY_ID = mpr.COMPANY_ID and yb.ROAD_ID = mpr.ROAD_ID
  210. and yb.PROJECT_NAME = mpr.PROJECT_NAME
  211. group by yb.YEAR,yb.COMPANY_ID,yb.ROAD_ID,yb.PROJECT_NAME
  212. ) m
  213. on h.YEAR = m.YEAR and h.COMPANY_ID = m.COMPANY_ID and h.PROJECT_NAME = m.PROJECT_NAME
  214. and h.ROAD_ID = m.ROAD_ID
  215. where h.YEAR = #{YEAR} and h.COMPANY_ID = #{COMPANY_ID}
  216. <if test="ROADS != null and ROADS != ''">
  217. AND ROAD IN
  218. <foreach collection="ROADS" item="ROADS" index="index"
  219. open="(" close=")" separator=",">
  220. #{ROADS}
  221. </foreach>
  222. </if>
  223. order by COMPANY_ID,ROAD_ID,CATEGORY, PROJECT_NAME
  224. )a
  225. ,(select @r:=0 ,@ROAD_ID:='',@c:=1) b
  226. order by COMPANY_ID,ROAD_ID,num desc
  227. )c
  228. ,(select @f:=0,@ROAD_ID2:='') d
  229. )e
  230. order by COMPANY_ID,ROAD_ID,num
  231. </select>
  232. <!-- <select id="getReportInfo" parameterType="pd" resultType="pd">
  233. select a.*, b.MONTH, b.ACTUAL_COST, b.PAY_COST, b.RATIO from highway_emergency_project_dettable a
  234. left join monthly_emergency_completion b
  235. on a.YEAR = b.YEAR and a.COMPANY_ID = b.COMPANY_ID and a.PROJECT_NAME = b.PROJECT_NAME
  236. where a.YEAR = #{YEAR} AND a.COMPANY_ID = #{COMPANY_ID}
  237. <if test="ROAD_ID != ''">
  238. and a.ROAD_ID = #{ROAD_ID}
  239. </if>
  240. </select> -->
  241. <select id="showTableRecod" parameterType="pd" resultType="pd">
  242. select COMPANY,COMPANY_ID,YEAR,ROAD,ROAD_ID,PROJECT_NAME,PROJECT_COST,PROJECT_SCALE,CATEGORY,QUANTITIES,
  243. KEY_WORDS,BASIS,DESIGN,QUALITY_PROGRESS,TOTAL_COST,OTHER_MATTER,AUDIT_FEE,AUDIT_MAKER
  244. from highway_emergency_project_dettable
  245. where YEAR = #{YEAR} AND COMPANY_ID = #{COMPANY_ID} and ROAD_ID = #{ROAD_ID} and PROJECT_NAME = #{PROJECT_NAME}
  246. </select>
  247. <select id="wordListRecorde" parameterType="pd" resultType="pd">
  248. select * from highway_emergency_project_dettable_cost
  249. where YEAR = #{YEAR} AND COMPANY_ID = #{COMPANY_ID} AND ROAD_ID = #{ROAD_ID} AND PROJECT_NAME = #{PROJECT_NAME}
  250. </select>
  251. <delete id="deleteMonthRecord" parameterType="pd">
  252. delete from ${TABLETYPE}
  253. where YEAR = #{YEAR} AND COMPANY_ID = #{COMPANY_ID} AND ROAD_ID = #{ROAD_ID} AND PROJECT_NAME = #{PROJECT_NAME}
  254. </delete>
  255. <delete id="deleteEmergencyProjectRecord" parameterType="pd">
  256. delete from highway_emergency_project_dettable
  257. where YEAR = #{YEAR} AND COMPANY_ID = #{COMPANY_ID} AND ROAD_ID = #{ROAD_ID} AND PROJECT_NAME = #{PROJECT_NAME}
  258. </delete>
  259. <delete id="deleteEmergencyProjectCostRecord" parameterType="pd">
  260. delete from highway_emergency_project_dettable_cost
  261. where YEAR = #{YEAR} AND COMPANY_ID = #{COMPANY_ID} AND ROAD_ID = #{ROAD_ID} AND PROJECT_NAME = #{PROJECT_NAME}
  262. </delete>
  263. <insert id="insertMonthRecord" parameterType="pd">
  264. insert into ${TABLETYPE}(
  265. COMPANY,COMPANY_ID,ROAD,ROAD_ID,YEAR,PROJECT_NAME,MONTH,ACTUAL_COST,PAY_COST,RATIO,ACTUAL_QUANTITIES
  266. )values(
  267. #{COMPANY}, #{COMPANY_ID}, #{ROAD}, #{ROAD_ID}, #{YEAR}, #{PROJECT_NAME}, #{MONTH}, #{ACTUAL_COST}, #{PAY_COST}, #{RATIO}, #{ACTUAL_QUANTITIES}
  268. )
  269. </insert>
  270. <update id="updateWCQKRecord" parameterType="pd">
  271. update ${TABLE_NAME}
  272. set SJWCGCL=#{SJWCGCL}
  273. where YEAR = #{YEAR} AND COMPANY_ID = #{COMPANY_ID} AND ROAD_ID = #{ROAD_ID} AND PROJECT_NAME = #{PROJECT_NAME}
  274. </update>
  275. </mapper>