123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="KyxmMonthProgressMapper">
-
- <!--表名 -->
- <sql id="tableName">
- monthly_scientific_project_completion
- </sql>
-
- <!--表名 -->
- <sql id="listTableName">
- monthly_scientific_report_list
- </sql>
-
- <!--表名 -->
- <sql id="dettableTableName">
- highway_scientific_project_dettable
- </sql>
-
- <!-- 字段 -->
- <sql id="Field">
- COMPANY,
- COMPANY_ID,
- ROAD,
- ROAD_ID,
- YEAR,
- PROJECT_NAME,
- MONTH,
- ACTUAL_COST,
- PAY_COST,
- RATIO
- </sql>
- <sql id="FieldValue">
- #{item.company},
- #{item.companyId},
- #{item.road},
- #{item.roadId},
- #{item.year},
- #{item.projectName},
- #{item.month},
- #{item.actualCost},
- #{item.payCost},
- #{item.ratio}
- </sql>
-
- <!-- 查询道路项目 -->
- <select id="roadlistAll" parameterType="pd" resultType="pd">
- SELECT
- *
- FROM
- <include refid="dettableTableName"></include>
- WHERE
- YEAR = #{year}
- AND COMPANY_ID IN
- <foreach collection="companyIds" item="companyIds" index="index"
- open="(" close=")" separator=",">
- #{companyIds}
- </foreach>
- ORDER BY COMPANY_ID ASC ,ROAD_ID ASC
- </select>
-
- <!-- 列表(全部) -->
- <select id="listAll" parameterType="pd" resultType="pd">
- select
- <include refid="Field"></include>
- from
- <include refid="tableName"></include>
- WHERE
- YEAR = #{year}
- AND COMPANY_ID IN
- <foreach collection="companyIds" item="companyIds" index="index"
- open="(" close=")" separator=",">
- #{companyIds}
- </foreach>
- </select>
-
- <!--根据公司道路汇总 -->
- <select id="findSumByCompanyAndRoad" parameterType="pd" resultType="pd">
- SELECT
- COMPANY_ID,
- ROAD_ID,
- SUM(ACTUAL_COST) SUM_ACTUAL_COST,
- SUM(PAY_COST) SUM_PAY_COST,
- SUM(RATIO) SUM_RATIO
- FROM
- <include refid="tableName"></include>
- WHERE
- YEAR = #{year}
- AND COMPANY_ID IN
- <foreach collection="companyIds" item="companyIds" index="index"
- open="(" close=")" separator=",">
- #{companyIds}
- </foreach>
- GROUP BY COMPANY_ID,ROAD_ID
- </select>
-
- <!-- 批量插入 -->
- <insert id="insertBatch" parameterType="pd">
- insert into
- <include refid="tableName"></include>
- (
- <include refid="Field"></include>
- )
- values
- <foreach collection ="list" item="item" separator =",">
- (
- <include refid="FieldValue"></include>
- )
- </foreach >
- </insert>
-
- <!-- 根据年份和公司批量删除 -->
- <delete id="delByYearMonthAndCompanyId" parameterType="pd">
- delete from
- <include refid="tableName"></include>
- where
- YEAR = #{year}
- AND MONTH = #{month}
- AND COMPANY_ID IN
- <foreach collection="companyIds" item="companyIds" index="index"
- open="(" close=")" separator=",">
- #{companyIds}
- </foreach>
- </delete>
-
- <!-- 获取月度列表 -->
- <select id="getReportlist" parameterType="pd" resultType="pd">
- select
- *
- from
- <include refid="listTableName"></include>
- where
- 1=1
- <if test="keywords!= null and keywords != ''"><!-- 关键词检索 -->
- and
- (
- NAME LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
- )
- </if>
- <if test="COMPANY != null">
- and COMPANY = #{COMPANY}
- </if>
- </select>
-
- <!-- 新增月度报告-->
- <insert id="addMonthlyReport" parameterType="pd">
- insert into
- <include refid="listTableName"></include>
- (
- COMPANY, COMPANY_ID,YEAR,NAME,STATUS,CTIME, MTIME
- ) values (
- #{COMPANY}, #{COMPANY_ID}, #{YEAR}, #{NAME}, #{STATUS}, #{CTIME}, #{MTIME}
- )
- </insert>
-
- <!-- 删除月度报告-->
- <delete id="delMonthlyReport" parameterType="pd">
- delete from
- <include refid="listTableName"></include>
- where
- COMPANY_ID = #{COMPANY_ID}
- AND YEAR = #{YEAR}
- </delete>
-
- <!-- 删除月度月度完成情况-->
- <delete id="delMonthlyCompletion" parameterType="pd">
- delete from
- <include refid="tableName"></include>
- where
- COMPANY_ID = #{COMPANY_ID}
- AND YEAR = #{YEAR}
- </delete>
-
- <!-- 通过月报表相关数据 -->
- <select id="getReportInfo" parameterType="pd" resultType="pd">
- select * from(
- select
- @f:= case when @ROAD_ID2=c.ROAD_ID then '0' else '1' end flag,
- @ROAD_ID2:=c.ROAD_ID1 ROAD_ID2,
- c.*,cast(num as char)numstr
- from(
- SELECT
- @r:= case when @ROAD_ID=a.ROAD_ID then @r+1 else 1 end num,
- @ROAD_ID:=a.ROAD_ID ROAD_ID1,
- a.*
- from(
- select h.COMPANY_ID,h.COMPANY,h.ROAD_ID,h.ROAD,h.YEAR,h.PROJECT_NAME,
- 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,
- h.AUDIT_MAKER,h.XMWCQKSM as ACTUAL_QUANTITIES,
- m.ACTUAL_COST_1,m.PAY_COST_1,m.RATIO_1,m.ACTUAL_COST_2,m.PAY_COST_2,m.RATIO_2,m.ACTUAL_COST_3,m.PAY_COST_3,m.RATIO_3,
- m.ACTUAL_COST_4,m.PAY_COST_4,m.RATIO_4,m.ACTUAL_COST_5,m.PAY_COST_5,m.RATIO_5,m.ACTUAL_COST_6,m.PAY_COST_6,m.RATIO_6,
- m.ACTUAL_COST_7,m.PAY_COST_7,m.RATIO_7,m.ACTUAL_COST_8,m.PAY_COST_8,m.RATIO_8,m.ACTUAL_COST_9,m.PAY_COST_9,m.RATIO_9,
- m.ACTUAL_COST_10,m.PAY_COST_10,m.RATIO_10,m.ACTUAL_COST_11,m.PAY_COST_11,m.RATIO_11,m.ACTUAL_COST_12,m.PAY_COST_12,m.RATIO_12
- from ${subtable} h
- left join (
- select yb.COMPANY_ID,yb.ROAD_ID,yb.YEAR,yb.PROJECT_NAME
- ,max(ACTUAL_COST_1) as ACTUAL_COST_1,max(PAY_COST_1) as PAY_COST_1,max(RATIO_1) as RATIO_1
- ,max(ACTUAL_COST_2) as ACTUAL_COST_2,max(PAY_COST_2) as PAY_COST_2,max(RATIO_2) as RATIO_2
- ,max(ACTUAL_COST_3) as ACTUAL_COST_3,max(PAY_COST_3) as PAY_COST_3,max(RATIO_3) as RATIO_3
- ,max(ACTUAL_COST_4) as ACTUAL_COST_4,max(PAY_COST_4) as PAY_COST_4,max(RATIO_4) as RATIO_4
- ,max(ACTUAL_COST_5) as ACTUAL_COST_5,max(PAY_COST_5) as PAY_COST_5,max(RATIO_5) as RATIO_5
- ,max(ACTUAL_COST_6) as ACTUAL_COST_6,max(PAY_COST_6) as PAY_COST_6,max(RATIO_6) as RATIO_6
- ,max(ACTUAL_COST_7) as ACTUAL_COST_7,max(PAY_COST_7) as PAY_COST_7,max(RATIO_7) as RATIO_7
- ,max(ACTUAL_COST_8) as ACTUAL_COST_8,max(PAY_COST_8) as PAY_COST_8,max(RATIO_8) as RATIO_8
- ,max(ACTUAL_COST_9) as ACTUAL_COST_9,max(PAY_COST_9) as PAY_COST_9,max(RATIO_9) as RATIO_9
- ,max(ACTUAL_COST_10) as ACTUAL_COST_10,max(PAY_COST_10) as PAY_COST_10,max(RATIO_10) as RATIO_10
- ,max(ACTUAL_COST_11) as ACTUAL_COST_11,max(PAY_COST_11) as PAY_COST_11,max(RATIO_11) as RATIO_11
- ,max(ACTUAL_COST_12) as ACTUAL_COST_12,max(PAY_COST_12) as PAY_COST_12,max(RATIO_12) as RATIO_12
- from(
- select *
- ,case when month=1 then ACTUAL_COST else null end ACTUAL_COST_1
- ,case when month=1 then PAY_COST else null end PAY_COST_1
- ,case when month=1 then RATIO else null end RATIO_1
- ,case when month=2 then ACTUAL_COST else null end ACTUAL_COST_2
- ,case when month=2 then PAY_COST else null end PAY_COST_2
- ,case when month=2 then RATIO else null end RATIO_2
- ,case when month=3 then ACTUAL_COST else null end ACTUAL_COST_3
- ,case when month=3 then PAY_COST else null end PAY_COST_3
- ,case when month=3 then RATIO else null end RATIO_3
- ,case when month=4 then ACTUAL_COST else null end ACTUAL_COST_4
- ,case when month=4 then PAY_COST else null end PAY_COST_4
- ,case when month=4 then RATIO else null end RATIO_4
- ,case when month=5 then ACTUAL_COST else null end ACTUAL_COST_5
- ,case when month=5 then PAY_COST else null end PAY_COST_5
- ,case when month=5 then RATIO else null end RATIO_5
- ,case when month=6 then ACTUAL_COST else null end ACTUAL_COST_6
- ,case when month=6 then PAY_COST else null end PAY_COST_6
- ,case when month=6 then RATIO else null end RATIO_6
- ,case when month=7 then ACTUAL_COST else null end ACTUAL_COST_7
- ,case when month=7 then PAY_COST else null end PAY_COST_7
- ,case when month=7 then RATIO else null end RATIO_7
- ,case when month=8 then ACTUAL_COST else null end ACTUAL_COST_8
- ,case when month=8 then PAY_COST else null end PAY_COST_8
- ,case when month=8 then RATIO else null end RATIO_8
- ,case when month=9 then ACTUAL_COST else null end ACTUAL_COST_9
- ,case when month=9 then PAY_COST else null end PAY_COST_9
- ,case when month=9 then RATIO else null end RATIO_9
- ,case when month=10 then ACTUAL_COST else null end ACTUAL_COST_10
- ,case when month=10 then PAY_COST else null end PAY_COST_10
- ,case when month=10 then RATIO else null end RATIO_10
- ,case when month=11 then ACTUAL_COST else null end ACTUAL_COST_11
- ,case when month=11 then PAY_COST else null end PAY_COST_11
- ,case when month=11 then RATIO else null end RATIO_11
- ,case when month=12 then ACTUAL_COST else null end ACTUAL_COST_12
- ,case when month=12 then PAY_COST else null end PAY_COST_12
- ,case when month=12 then RATIO else null end RATIO_12
- from ${TABLETYPE}
- where YEAR = #{YEAR} and COMPANY_ID = #{COMPANY_ID}
- <if test="ROADS!= null and ROADS != ''">
- AND ROAD IN
- <foreach collection="ROADS" item="ROADS" index="index"
- open="(" close=")" separator=",">
- #{ROADS}
- </foreach>
- </if>
- )yb group by yb.YEAR,yb.COMPANY_ID,yb.ROAD_ID,yb.PROJECT_NAME
- ) m
- on h.YEAR = m.YEAR and h.COMPANY_ID = m.COMPANY_ID and h.PROJECT_NAME = m.PROJECT_NAME
- where h.YEAR = #{YEAR} and h.COMPANY_ID = #{COMPANY_ID}
- <if test="ROADS!= null and ROADS != ''">
- AND ROAD IN
- <foreach collection="ROADS" item="ROADS" index="index"
- open="(" close=")" separator=",">
- #{ROADS}
- </foreach>
- </if>
- )a
- ,(select @r:=0 ,@ROAD_ID:='',@c:=1) b
- order by COMPANY_ID,ROAD_ID,num desc
- )c
- ,(select @f:=0,@ROAD_ID2:='') d
- )e
- order by COMPANY_ID,ROAD_ID,num
- </select>
-
- <delete id="deleteMonthRecord" parameterType="pd">
- delete from ${TABLETYPE}
- where YEAR = #{YEAR} AND COMPANY_ID = #{COMPANY_ID} AND ROAD_ID = #{ROAD_ID} AND PROJECT_NAME = #{PROJECT_NAME}
- </delete>
-
- <insert id="insertMonthRecord" parameterType="pd">
- insert into ${TABLETYPE}(
- COMPANY,COMPANY_ID,ROAD,ROAD_ID,YEAR,PROJECT_NAME,MONTH,ACTUAL_COST,PAY_COST,RATIO,ACTUAL_QUANTITIES
- )values(
- #{COMPANY}, #{COMPANY_ID}, #{ROAD}, #{ROAD_ID}, #{YEAR}, #{PROJECT_NAME}, #{MONTH}, #{ACTUAL_COST}, #{PAY_COST}, #{RATIO},#{ACTUAL_QUANTITIES}
- )
- </insert>
- <update id="updateWCQKRecord" parameterType="pd">
- update ${TABLE_NAME}
- set XMWCQKSM=#{SJWCGCL}
- where YEAR = #{YEAR} AND COMPANY_ID = #{COMPANY_ID} AND ROAD_ID = #{ROAD_ID} AND PROJECT_NAME = #{PROJECT_NAME}
- </update>
- </mapper>
|