<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "对基础信息实绩操作">
	
	<query id = "ComBaseProcesscost.query" desc = "获取产线工序费用信息">
	<![CDATA[


	]]>
	</query>
<query id = "ComBaseProcesscost.isave" desc = "新增产线工序费用信息">
	<![CDATA[
  INSERT INTO COST_BASE_PROCESSCOST(
        PLINE_CODE,
        PLINE_NAME,
        PROCESS_CODE,
        PROCESS_DESC,
        YEAR,
        MONTH_1,
        MONTH_2,
        MONTH_3,
        MONTH_4,
        MONTH_5,
        MONTH_6,
        MONTH_7,
        MONTH_8,
        MONTH_9,
        MONTH_10,
        MONTH_11,
        MONTH_12,
        CREATE_NAME,
        CREATE_TIME,
        MEMO)
 VALUES( 
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#PROCESS_CODE#',
        '#PROCESS_DESC#',
        '#YEAR#',
        '#MONTH1#',
        '#MONTH2#',
        '#MONTH3#',
        '#MONTH4#',
        '#MONTH5#',
        '#MONTH6#',
        '#MONTH7#',
        '#MONTH8#',
        '#MONTH9#',
        '#MONTH10#',
        '#MONTH11#',
        '#MONTH12#',
        '#CREATE_NAME#',
        SYSDATE,
        '#MEMO#')
	]]>
	</query>
	<query id = "ComBaseProcesscost.usave" desc = "修改产线工序费用信息">
	<![CDATA[
   UPDATE COST_BASE_PROCESSCOST T
   SET 
        T.PLINE_CODE = '#PLINE_CODE#',
        T.PLINE_NAME = '#PLINE_NAME#',
        T.PROCESS_CODE = '#PROCESS_CODE#',
        T.PROCESS_DESC = '#PROCESS_DESC#',
        T.YEAR = '#YEAR#',
        T.MONTH_1 = '#MONTH1#',
        T.MONTH_2 = '#MONTH2#',
        T.MONTH_3 = '#MONTH3#',
        T.MONTH_4 = '#MONTH4#',
        T.MONTH_5 = '#MONTH5#',
        T.MONTH_6 = '#MONTH6#',
        T.MONTH_7 = '#MONTH7#',
        T.MONTH_8 = '#MONTH8#',
        T.MONTH_9 = '#MONTH9#',
        T.MONTH_10 = '#MONTH10#',
        T.MONTH_11 = '#MONTH11#',
        T.MONTH_12 = '#MONTH12#',
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.MEMO = '#MEMO#'
 WHERE 1=1 
       
	]]>
	</query>
	<query id = "ComBaseProcesscost.delete" desc = "删除产线工序费用信息">
	<![CDATA[
    UPDATE COST_BASE_PROCESSCOST T
   SET 
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.DELETE_NAME = '#DELETE_NAME#',
        T.DELETE_TIME = SYSDATE,
        T.VALIDFLAG = '0'
 WHERE
T.PLINE_CODE = '#PLINE_CODE#'
AND T.YEAR = '#YEAR#'
       
	]]>
	</query>
	<query id = "ComBaseProcesscost.resume" desc = "恢复产线工序费用信息">
	<![CDATA[
    UPDATE COST_BASE_PROCESSCOST T
   SET 
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.DELETE_NAME = '',
        T.DELETE_TIME = '',
        T.VALIDFLAG = '1'
 WHERE
T.PLINE_CODE = '#PLINE_CODE#'
AND T.YEAR = '#YEAR#'
       
	]]>
	</query>
	
	<query id = "ComBaseProcesscost.querynum" desc = "获取断面信息">
	<![CDATA[
SELECT COUNT(*) 
FROM COST_BASE_PROCESSCOST T 
WHERE 1=1
	]]>
	</query>
	<query id = "ComBaseProcesscost.queryMonthone" desc = "获取断面信息">
	<![CDATA[

SELECT T.PLINE_CODE,T.PLINE_NAME,SUM(T.WEIGTH_S) WEIGTH_S  ,T.PRO_MONTH
FROM 
(
SELECT ZJ.PLINE_CODE,ZJ.PLINE_NAME,ZJ.PLAN_WT_S WEIGTH_S,ZJ.PRO_MONTH
FROM PLN_ORDER_CAST_S ZJ WHERE ZJ.PRO_MONTH LIKE '%'||{0}||'%'  -- 铸机
UNION ALL 
SELECT DL.PLINE_CODE_A,DL.PLINE_NAME_A,DL.PLAN_WT_S WEIGTH_S,DL.PRO_MONTH
FROM PLN_ORDER_CAST_S DL WHERE DL.PRO_MONTH LIKE '%'||{0}||'%'  -- 电炉
UNION ALL 
SELECT DBK.PLINE_CODE,DBK.PLINE_NAME,DBK.WEIGTH_S,DBK.PRO_MONTH
FROM PLN_ORDER_DBK_S DBK -- 墩拔扩
WHERE DBK.PRO_MONTH LIKE '%'||{0}||'%' 
UNION ALL 
SELECT DZ.PLINE_CODE,DZ.PLINE_NAME,DZ.WEIGTH_S,DZ.PRO_MONTH
FROM PLN_ORDER_DZ_S DZ -- 锻造
WHERE DZ.PRO_MONTH LIKE '%'||{0}||'%' 
UNION ALL 
SELECT JGX.PLINE_CODE,JGX.PLINE_NAME,JGX.WEIGTH_S,JGX.PRO_MONTH
FROM PLN_ORDER_JGX_S JGX -- 加工线
WHERE JGX.PRO_MONTH LIKE '%'||{0}||'%' 
UNION ALL 
SELECT RCL.PLINE_CODE,RCL.PLINE_NAME,RCL.WEIGTH_S,RCL.PRO_MONTH
FROM PLN_ORDER_RCL_S RCL -- 热处理
WHERE RCL.PRO_MONTH LIKE '%'||{0}||'%' 
UNION ALL 
SELECT ZG.PLINE_CODE,ZG.PLINE_NAME,ZG.WEIGTH_S,ZG.PRO_MONTH
FROM PLN_ORDER_ZG_S ZG -- 扎管
WHERE ZG.PRO_MONTH LIKE '%'||{0}||'%'  
) T
GROUP BY T.PLINE_CODE,T.PLINE_NAME,T.PRO_MONTH
ORDER BY T.PLINE_CODE 

	]]>
	</query>
	<query id = "ComBaseProcesscost.queryprice" desc = "获取断面信息">
	<![CDATA[
SELECT T.PLINE_CODE,T.PLINE_NAME,T.SCHEDULE_MIN,T.SCHEDULE_MAX,T.COST_PRICE 
FROM COST_BASE_PROCESSCOST_C T
WHERE T.VALIDFLAG='1' 
	]]>
	</query>
	<query id = "ComBaseProcesscost.querydaxiao" desc = "获取断面信息">
	<![CDATA[
SELECT PC.PLINE_CODE,PC.PLINE_NAME,MIN(PC.SCHEDULE_MIN) XIAO, MAX(PC.SCHEDULE_MAX) DA
 FROM COST_BASE_PROCESSCOST_C PC 
 WHERE PC.VALIDFLAG='1' 
 GROUP BY PC.PLINE_CODE,PC.PLINE_NAME
	]]>
	</query>
	<query id = "ComBaseProcesscost.queryjiage" desc = "获取断面信息">
	<![CDATA[
select test.cost_price from (select t.cost_price
from cost_base_processcost_c t 
JOIN (SELECT MAX(A.SCHEDULE_MAX) max
FROM cost_base_processcost_c A 
WHERE A.PLINE_CODE={0}) B
on  b.max<{1}
where t.pline_code={0}
and t.schedule_max<{1} 
ORDER BY T.SCHEDULE_MAX DESC ) test where ROWNUM =1
union all 
select test.cost_price from (select t.cost_price
from cost_base_processcost_c t 
JOIN (SELECT min(A.Schedule_Min) min
FROM cost_base_processcost_c A 
WHERE A.PLINE_CODE={0}) B
on  b.min>{1}
where t.pline_code={0}
and t.schedule_min>{1} 
ORDER BY T.Schedule_Min  ) test where ROWNUM =1
union all 
select ex.cost_price from (select t.cost_price 
from cost_base_processcost_c t 
where t.pline_code={0} and t.schedule_max>{1} and t.schedule_min<{1}
order by t.schedule_min desc ) ex where rownum=1
	]]>
	</query>
	<query id = "ComBaseProcesscost.queryall" desc = "获取断面信息">
	<![CDATA[
select z.pline_code PCODE, z.pline_name PNAME, z.process_code, z.process_desc, x.*
  from com_base_pline z,
       ( --轧管
        select t1.*,
                M01 * P01 + F01 H01,--汇总后总额
                M02 * P02 + F02 H02,
                M03 * P03 + F03 H03,
                M04 * P04 + F04 H04,
                M05 * P05 + F05 H05,
                M06 * P06 + F06 H06,
                M07 * P07 + F07 H07,
                M08 * P08 + F08 H08,
                M09 * P09 + F09 H09,
                M10 * P10 + F10 H10,
                M11 * P11 + F11 H11,
                M12 * P12 + F12 H12,
                M01 * P01  B01,
                M02 * P02  B02,
                M03 * P03  B03,
                M04 * P04  B04,
                M05 * P05  B05,
                M06 * P06  B06,
                M07 * P07  B07,
                M08 * P08  B08,
                M09 * P09  B09,
                M10 * P10  B10,
                M11 * P11  B11,
                M12 * P12  B12
          from (select t.*,
                        nvl(v.month_1, 0) F01,--分摊总额
                        nvl(v.month_2, 0) F02,
                        nvl(v.month_3, 0) F03,
                        nvl(v.month_4, 0) F04,
                        nvl(v.month_5, 0) F05,
                        nvl(v.month_6, 0) F06,
                        nvl(v.month_7, 0) F07,
                        nvl(v.month_8, 0) F08,
                        nvl(v.month_9, 0) F09,
                        nvl(v.month_10, 0) F10,
                        nvl(v.month_11, 0) F11,
                        nvl(v.month_12, 0) F12,
                        (nvl(v.month_1, 0) + nvl(v.month_2, 0) +
                        nvl(v.month_3, 0) + nvl(v.month_4, 0) +
                        nvl(v.month_5, 0) + nvl(v.month_6, 0) +
                        nvl(v.month_7, 0) + nvl(v.month_8, 0) +
                        nvl(v.month_9, 0) + nvl(v.month_10, 0) +
                        nvl(v.month_11, 0) + nvl(v.month_12, 0)) SUM_F,
                        (select nvl(max(a.cost_price), 0)
                           from COST_BASE_PROCESSCOST_C a
                          where a.validflag = '1'
                            and t.pline_code = a.pline_code
                            and t.M01 between a.schedule_min and a.schedule_max) P01,--单项值
                        (select nvl(max(a.cost_price), 0)
                           from COST_BASE_PROCESSCOST_C a
                          where a.validflag = '1'
                            and t.pline_code = a.pline_code
                            and t.M02 between a.schedule_min and a.schedule_max) P02,
                        (select nvl(max(a.cost_price), 0)
                           from COST_BASE_PROCESSCOST_C a
                          where a.validflag = '1'
                            and t.pline_code = a.pline_code
                            and t.M03 between a.schedule_min and a.schedule_max) P03,
                        (select nvl(max(a.cost_price), 0)
                           from COST_BASE_PROCESSCOST_C a
                          where a.validflag = '1'
                            and t.pline_code = a.pline_code
                            and t.M04 between a.schedule_min and a.schedule_max) P04,
                        (select nvl(max(a.cost_price), 0)
                           from COST_BASE_PROCESSCOST_C a
                          where a.validflag = '1'
                            and t.pline_code = a.pline_code
                            and t.M05 between a.schedule_min and a.schedule_max) P05,
                        (select nvl(max(a.cost_price), 0)
                           from COST_BASE_PROCESSCOST_C a
                          where a.validflag = '1'
                            and t.pline_code = a.pline_code
                            and t.M06 between a.schedule_min and a.schedule_max) P06,
                        (select nvl(max(a.cost_price), 0)
                           from COST_BASE_PROCESSCOST_C a
                          where a.validflag = '1'
                            and t.pline_code = a.pline_code
                            and t.M07 between a.schedule_min and a.schedule_max) P07,
                        (select nvl(max(a.cost_price), 0)
                           from COST_BASE_PROCESSCOST_C a
                          where a.validflag = '1'
                            and t.pline_code = a.pline_code
                            and t.M08 between a.schedule_min and a.schedule_max) P08,
                        (select nvl(max(a.cost_price), 0)
                           from COST_BASE_PROCESSCOST_C a
                          where a.validflag = '1'
                            and t.pline_code = a.pline_code
                            and t.M09 between a.schedule_min and a.schedule_max) P09,
                        (select nvl(max(a.cost_price), 0)
                           from COST_BASE_PROCESSCOST_C a
                          where a.validflag = '1'
                            and t.pline_code = a.pline_code
                            and t.M10 between a.schedule_min and a.schedule_max) P10,
                        (select nvl(max(a.cost_price), 0)
                           from COST_BASE_PROCESSCOST_C a
                          where a.validflag = '1'
                            and t.pline_code = a.pline_code
                            and t.M11 between a.schedule_min and a.schedule_max) P11,
                        (select nvl(max(a.cost_price), 0)
                           from COST_BASE_PROCESSCOST_C a
                          where a.validflag = '1'
                            and t.pline_code = a.pline_code
                            and t.M12 between a.schedule_min and a.schedule_max) P12,
                             v.create_name,v.create_time,v.update_name,v.update_time,v.delete_name,v.delete_time,
                             DECODE(V.VALIDFLAG,'1','有效','0','无效') VALIDFLAG,v.memo
				from (select a1.PLINE_CODE,{0} Year_,a2.M01,a2.M02,a2.M03,a2.M04,a2.M05,a2.M06,a2.M07,a2.M08,a2.M09,a2.M10,a2.M11,a2.M12 from 
                      (select PLINE_CODE from com_base_pline  where VALIDFLAG = '1' and PROCESS_CODE = 'D') a1,			 
                    (select PLINE_CODE,
                                nvl(sum(case pro_month
                                          when '01' then
                                           WEIGTH_S
                                        end),
                                    0) as M01,
                                nvl(sum(case pro_month
                                          when '02' then
                                           WEIGTH_S
                                        end),
                                    0) as M02,
                                nvl(sum(case pro_month
                                          when '03' then
                                           WEIGTH_S
                                        end),
                                    0) as M03,
                                nvl(sum(case pro_month
                                          when '04' then
                                           WEIGTH_S
                                        end),
                                    0) as M04,
                                nvl(sum(case pro_month
                                          when '05' then
                                           WEIGTH_S
                                        end),
                                    0) as M05,
                                nvl(sum(case pro_month
                                          when '06' then
                                           WEIGTH_S
                                        end),
                                    0) as M06,
                                nvl(sum(case pro_month
                                          when '07' then
                                           WEIGTH_S
                                        end),
                                    0) as M07,
                                nvl(sum(case pro_month
                                          when '08' then
                                           WEIGTH_S
                                        end),
                                    0) as M08,
                                nvl(sum(case pro_month
                                          when '09' then
                                           WEIGTH_S
                                        end),
                                    0) as M09,
                                nvl(sum(case pro_month
                                          when '10' then
                                           WEIGTH_S
                                        end),
                                    0) as M10,
                                nvl(sum(case pro_month
                                          when '11' then
                                           WEIGTH_S
                                        end),
                                    0) as M11,
                                nvl(sum(case pro_month
                                          when '12' then
                                           WEIGTH_S
                                        end),
                                    0) as M12
                           from (SELECT ZJ.d_pline  PLINE_CODE,
                                        sum(ZJ.weigth_s_d  ) WEIGTH_S,
                                        substr(ZJ.year_month , -2, 2) PRO_MONTH
                                   FROM cost_calculation_d ZJ
                                  WHERE ZJ.year_month LIKE '%' || {0} || '%'
                                  GROUP BY ZJ.d_pline, ZJ.year_month
                                  order by d_pline, year_month) t
                          group by PLINE_CODE) a2 where a1.PLINE_CODE = a2.PLINE_CODE(+)) t,
                        (select b.*
                           from COST_BASE_PROCESSCOST b
                          where b.validflag = '1') v
                  where t.pline_code = v.pline_code(+)
                    and t.year_ = v.Year(+)) T1
        
        union all
        --热处理
         (select t1.*,
                 M01 * P01 + F01 H01,
                 M02 * P02 + F02 H02,
                 M03 * P03 + F03 H03,
                 M04 * P04 + F04 H04,
                 M05 * P05 + F05 H05,
                 M06 * P06 + F06 H06,
                 M07 * P07 + F07 H07,
                 M08 * P08 + F08 H08,
                 M09 * P09 + F09 H09,
                 M10 * P10 + F10 H10,
                 M11 * P11 + F11 H11,
                 M12 * P12 + F12 H12,
                M01 * P01  B01,
                M02 * P02  B02,
                M03 * P03  B03,
                M04 * P04  B04,
                M05 * P05  B05,
                M06 * P06  B06,
                M07 * P07  B07,
                M08 * P08  B08,
                M09 * P09  B09,
                M10 * P10  B10,
                M11 * P11  B11,
                M12 * P12  B12
            from (select t.*,
                         nvl(v.month_1, 0) F01,
                         nvl(v.month_2, 0) F02,
                         nvl(v.month_3, 0) F03,
                         nvl(v.month_4, 0) F04,
                         nvl(v.month_5, 0) F05,
                         nvl(v.month_6, 0) F06,
                         nvl(v.month_7, 0) F07,
                         nvl(v.month_8, 0) F08,
                         nvl(v.month_9, 0) F09,
                         nvl(v.month_10, 0) F10,
                         nvl(v.month_11, 0) F11,
                         nvl(v.month_12, 0) F12,
                         (nvl(v.month_1, 0) + nvl(v.month_2, 0) +
                         nvl(v.month_3, 0) + nvl(v.month_4, 0) +
                         nvl(v.month_5, 0) + nvl(v.month_6, 0) +
                         nvl(v.month_7, 0) + nvl(v.month_8, 0) +
                         nvl(v.month_9, 0) + nvl(v.month_10, 0) +
                         nvl(v.month_11, 0) + nvl(v.month_12, 0)) SUM_F,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M01 between a.schedule_min and a.schedule_max) P01,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M02 between a.schedule_min and a.schedule_max) P02,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M03 between a.schedule_min and a.schedule_max) P03,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M04 between a.schedule_min and a.schedule_max) P04,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M05 between a.schedule_min and a.schedule_max) P05,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M06 between a.schedule_min and a.schedule_max) P06,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M07 between a.schedule_min and a.schedule_max) P07,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M08 between a.schedule_min and a.schedule_max) P08,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M09 between a.schedule_min and a.schedule_max) P09,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M10 between a.schedule_min and a.schedule_max) P10,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M11 between a.schedule_min and a.schedule_max) P11,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M12 between a.schedule_min and a.schedule_max) P12,
                             v.create_name,v.create_time,v.update_name,v.update_time,v.delete_name,v.delete_time,
                             DECODE(V.VALIDFLAG,'1','有效','0','无效') VALIDFLAG,v.memo
                    from (select a1.PLINE_CODE,{0} Year_,a2.M01,a2.M02,a2.M03,a2.M04,a2.M05,a2.M06,a2.M07,a2.M08,a2.M09,a2.M10,a2.M11,a2.M12 from 
                      (select PLINE_CODE from com_base_pline  where VALIDFLAG = '1' and PROCESS_CODE = 'F') a1,			 
                    (select PLINE_CODE,
                                nvl(sum(case pro_month
                                           when '01' then
                                            WEIGTH_S
                                         end),
                                     0) as M01,
                                 nvl(sum(case pro_month
                                           when '02' then
                                            WEIGTH_S
                                         end),
                                     0) as M02,
                                 nvl(sum(case pro_month
                                           when '03' then
                                            WEIGTH_S
                                         end),
                                     0) as M03,
                                 nvl(sum(case pro_month
                                           when '04' then
                                            WEIGTH_S
                                         end),
                                     0) as M04,
                                 nvl(sum(case pro_month
                                           when '05' then
                                            WEIGTH_S
                                         end),
                                     0) as M05,
                                 nvl(sum(case pro_month
                                           when '06' then
                                            WEIGTH_S
                                         end),
                                     0) as M06,
                                 nvl(sum(case pro_month
                                           when '07' then
                                            WEIGTH_S
                                         end),
                                     0) as M07,
                                 nvl(sum(case pro_month
                                           when '08' then
                                            WEIGTH_S
                                         end),
                                     0) as M08,
                                 nvl(sum(case pro_month
                                           when '09' then
                                            WEIGTH_S
                                         end),
                                     0) as M09,
                                 nvl(sum(case pro_month
                                           when '10' then
                                            WEIGTH_S
                                         end),
                                     0) as M10,
                                 nvl(sum(case pro_month
                                           when '11' then
                                            WEIGTH_S
                                         end),
                                     0) as M11,
                                 nvl(sum(case pro_month
                                           when '12' then
                                            WEIGTH_S
                                         end),
                                     0) as M12
                            from (SELECT ZJ.f_pline  PLINE_CODE,
                                         sum(ZJ.weigth_s_f ) WEIGTH_S,
                                         substr(ZJ.year_month , -2, 2) PRO_MONTH
                                    FROM cost_calculation_f ZJ
                                   WHERE ZJ.year_month  LIKE '%' || {0} || '%'
                                   GROUP BY ZJ.f_pline , ZJ.year_month 
                                   order by f_pline , year_month ) t
                          group by PLINE_CODE) a2 where a1.PLINE_CODE = a2.PLINE_CODE(+)) t,
                         (select b.*
                            from COST_BASE_PROCESSCOST b
                           where b.validflag = '1') v
                   where t.pline_code = v.pline_code(+)
                     and t.year_ = v.Year(+)) T1)
       union all
        --电炉
         (select t1.*,
                 M01 * P01 + F01 H01,
                 M02 * P02 + F02 H02,
                 M03 * P03 + F03 H03,
                 M04 * P04 + F04 H04,
                 M05 * P05 + F05 H05,
                 M06 * P06 + F06 H06,
                 M07 * P07 + F07 H07,
                 M08 * P08 + F08 H08,
                 M09 * P09 + F09 H09,
                 M10 * P10 + F10 H10,
                 M11 * P11 + F11 H11,
                 M12 * P12 + F12 H12,
                M01 * P01  B01,
                M02 * P02  B02,
                M03 * P03  B03,
                M04 * P04  B04,
                M05 * P05  B05,
                M06 * P06  B06,
                M07 * P07  B07,
                M08 * P08  B08,
                M09 * P09  B09,
                M10 * P10  B10,
                M11 * P11  B11,
                M12 * P12  B12
            from (select t.*,
                         nvl(v.month_1, 0) F01,
                         nvl(v.month_2, 0) F02,
                         nvl(v.month_3, 0) F03,
                         nvl(v.month_4, 0) F04,
                         nvl(v.month_5, 0) F05,
                         nvl(v.month_6, 0) F06,
                         nvl(v.month_7, 0) F07,
                         nvl(v.month_8, 0) F08,
                         nvl(v.month_9, 0) F09,
                         nvl(v.month_10, 0) F10,
                         nvl(v.month_11, 0) F11,
                         nvl(v.month_12, 0) F12,
                         (nvl(v.month_1, 0) + nvl(v.month_2, 0) +
                         nvl(v.month_3, 0) + nvl(v.month_4, 0) +
                         nvl(v.month_5, 0) + nvl(v.month_6, 0) +
                         nvl(v.month_7, 0) + nvl(v.month_8, 0) +
                         nvl(v.month_9, 0) + nvl(v.month_10, 0) +
                         nvl(v.month_11, 0) + nvl(v.month_12, 0)) SUM_F,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M01 between a.schedule_min and a.schedule_max) P01,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M02 between a.schedule_min and a.schedule_max) P02,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M03 between a.schedule_min and a.schedule_max) P03,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M04 between a.schedule_min and a.schedule_max) P04,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M05 between a.schedule_min and a.schedule_max) P05,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M06 between a.schedule_min and a.schedule_max) P06,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M07 between a.schedule_min and a.schedule_max) P07,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M08 between a.schedule_min and a.schedule_max) P08,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M09 between a.schedule_min and a.schedule_max) P09,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M10 between a.schedule_min and a.schedule_max) P10,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M11 between a.schedule_min and a.schedule_max) P11,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M12 between a.schedule_min and a.schedule_max) P12,
                             v.create_name,v.create_time,v.update_name,v.update_time,v.delete_name,v.delete_time,
                             DECODE(V.VALIDFLAG,'1','有效','0','无效') VALIDFLAG,v.memo
                    from (select a1.PLINE_CODE,{0} Year_,a2.M01,a2.M02,a2.M03,a2.M04,a2.M05,a2.M06,a2.M07,a2.M08,a2.M09,a2.M10,a2.M11,a2.M12 from 
                      (select PLINE_CODE from com_base_pline  where VALIDFLAG = '1' and PROCESS_CODE = 'A') a1,			 
                    (select PLINE_CODE,
                                nvl(sum(case pro_month
                                           when '01' then
                                            WEIGTH_S
                                         end),
                                     0) as M01,
                                 nvl(sum(case pro_month
                                           when '02' then
                                            WEIGTH_S
                                         end),
                                     0) as M02,
                                 nvl(sum(case pro_month
                                           when '03' then
                                            WEIGTH_S
                                         end),
                                     0) as M03,
                                 nvl(sum(case pro_month
                                           when '04' then
                                            WEIGTH_S
                                         end),
                                     0) as M04,
                                 nvl(sum(case pro_month
                                           when '05' then
                                            WEIGTH_S
                                         end),
                                     0) as M05,
                                 nvl(sum(case pro_month
                                           when '06' then
                                            WEIGTH_S
                                         end),
                                     0) as M06,
                                 nvl(sum(case pro_month
                                           when '07' then
                                            WEIGTH_S
                                         end),
                                     0) as M07,
                                 nvl(sum(case pro_month
                                           when '08' then
                                            WEIGTH_S
                                         end),
                                     0) as M08,
                                 nvl(sum(case pro_month
                                           when '09' then
                                            WEIGTH_S
                                         end),
                                     0) as M09,
                                 nvl(sum(case pro_month
                                           when '10' then
                                            WEIGTH_S
                                         end),
                                     0) as M10,
                                 nvl(sum(case pro_month
                                           when '11' then
                                            WEIGTH_S
                                         end),
                                     0) as M11,
                                 nvl(sum(case pro_month
                                           when '12' then
                                            WEIGTH_S
                                         end),
                                     0) as M12
                            from (SELECT ZJ.a_pline  PLINE_CODE,
                                         sum(ZJ.weigth_s_a ) WEIGTH_S,
                                         substr(ZJ.year_month , -2, 2) PRO_MONTH
                                    FROM cost_calculation_a ZJ
                                   WHERE ZJ.year_month  LIKE '%' || {0} || '%'
                                   GROUP BY ZJ.a_pline , ZJ.year_month 
                                   order by a_pline , year_month ) t
                           group by PLINE_CODE ) a2 where a1.PLINE_CODE = a2.PLINE_CODE(+) ) t,
                         (select b.*
                            from COST_BASE_PROCESSCOST b
                           where b.validflag = '1') v
                   where t.pline_code = v.pline_code(+)
                     and t.year_ = v.Year(+)) T1) 
        union all
        --铸机
         (select t1.*,
                 M01 * P01 + F01 H01,
                 M02 * P02 + F02 H02,
                 M03 * P03 + F03 H03,
                 M04 * P04 + F04 H04,
                 M05 * P05 + F05 H05,
                 M06 * P06 + F06 H06,
                 M07 * P07 + F07 H07,
                 M08 * P08 + F08 H08,
                 M09 * P09 + F09 H09,
                 M10 * P10 + F10 H10,
                 M11 * P11 + F11 H11,
                 M12 * P12 + F12 H12,
                M01 * P01  B01,
                M02 * P02  B02,
                M03 * P03  B03,
                M04 * P04  B04,
                M05 * P05  B05,
                M06 * P06  B06,
                M07 * P07  B07,
                M08 * P08  B08,
                M09 * P09  B09,
                M10 * P10  B10,
                M11 * P11  B11,
                M12 * P12  B12
            from (select t.*,
                         nvl(v.month_1, 0) F01,
                         nvl(v.month_2, 0) F02,
                         nvl(v.month_3, 0) F03,
                         nvl(v.month_4, 0) F04,
                         nvl(v.month_5, 0) F05,
                         nvl(v.month_6, 0) F06,
                         nvl(v.month_7, 0) F07,
                         nvl(v.month_8, 0) F08,
                         nvl(v.month_9, 0) F09,
                         nvl(v.month_10, 0) F10,
                         nvl(v.month_11, 0) F11,
                         nvl(v.month_12, 0) F12,
                         (nvl(v.month_1, 0) + nvl(v.month_2, 0) +
                         nvl(v.month_3, 0) + nvl(v.month_4, 0) +
                         nvl(v.month_5, 0) + nvl(v.month_6, 0) +
                         nvl(v.month_7, 0) + nvl(v.month_8, 0) +
                         nvl(v.month_9, 0) + nvl(v.month_10, 0) +
                         nvl(v.month_11, 0) + nvl(v.month_12, 0)) SUM_F,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M01 between a.schedule_min and a.schedule_max) P01,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M02 between a.schedule_min and a.schedule_max) P02,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M03 between a.schedule_min and a.schedule_max) P03,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M04 between a.schedule_min and a.schedule_max) P04,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M05 between a.schedule_min and a.schedule_max) P05,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M06 between a.schedule_min and a.schedule_max) P06,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M07 between a.schedule_min and a.schedule_max) P07,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M08 between a.schedule_min and a.schedule_max) P08,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M09 between a.schedule_min and a.schedule_max) P09,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M10 between a.schedule_min and a.schedule_max) P10,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M11 between a.schedule_min and a.schedule_max) P11,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M12 between a.schedule_min and a.schedule_max) P12,
                             v.create_name,v.create_time,v.update_name,v.update_time,v.delete_name,v.delete_time,
                             DECODE(V.VALIDFLAG,'1','有效','0','无效') VALIDFLAG,v.memo
                    from (select a1.PLINE_CODE,{0} Year_,a2.M01,a2.M02,a2.M03,a2.M04,a2.M05,a2.M06,a2.M07,a2.M08,a2.M09,a2.M10,a2.M11,a2.M12 from 
                      (select PLINE_CODE from com_base_pline  where VALIDFLAG = '1' and PROCESS_CODE = 'B') a1,			 
                    (select PLINE_CODE,
                                nvl(sum(case pro_month
                                           when '01' then
                                            WEIGTH_S
                                         end),
                                     0) as M01,
                                 nvl(sum(case pro_month
                                           when '02' then
                                            WEIGTH_S
                                         end),
                                     0) as M02,
                                 nvl(sum(case pro_month
                                           when '03' then
                                            WEIGTH_S
                                         end),
                                     0) as M03,
                                 nvl(sum(case pro_month
                                           when '04' then
                                            WEIGTH_S
                                         end),
                                     0) as M04,
                                 nvl(sum(case pro_month
                                           when '05' then
                                            WEIGTH_S
                                         end),
                                     0) as M05,
                                 nvl(sum(case pro_month
                                           when '06' then
                                            WEIGTH_S
                                         end),
                                     0) as M06,
                                 nvl(sum(case pro_month
                                           when '07' then
                                            WEIGTH_S
                                         end),
                                     0) as M07,
                                 nvl(sum(case pro_month
                                           when '08' then
                                            WEIGTH_S
                                         end),
                                     0) as M08,
                                 nvl(sum(case pro_month
                                           when '09' then
                                            WEIGTH_S
                                         end),
                                     0) as M09,
                                 nvl(sum(case pro_month
                                           when '10' then
                                            WEIGTH_S
                                         end),
                                     0) as M10,
                                 nvl(sum(case pro_month
                                           when '11' then
                                            WEIGTH_S
                                         end),
                                     0) as M11,
                                 nvl(sum(case pro_month
                                           when '12' then
                                            WEIGTH_S
                                         end),
                                     0) as M12
                            from (SELECT ZJ.b_pline  PLINE_CODE,
                                         sum(ZJ.weigth_s_b ) WEIGTH_S,
                                         substr(ZJ.year_month , -2, 2) PRO_MONTH
                                    FROM cost_calculation_a ZJ
                                   WHERE ZJ.year_month  LIKE '%' || {0} || '%'
                                   GROUP BY ZJ.b_pline , ZJ.year_month 
                                   order by b_pline , year_month ) t
                           group by PLINE_CODE ) a2 where a1.PLINE_CODE = a2.PLINE_CODE(+) ) t,
                         (select b.*
                            from COST_BASE_PROCESSCOST b
                           where b.validflag = '1') v
                   where t.pline_code = v.pline_code(+)
                     and t.year_ = v.Year(+)) T1)
        
        union all
        --锻造
         (select t1.*,
                 M01 * P01 + F01 H01,
                 M02 * P02 + F02 H02,
                 M03 * P03 + F03 H03,
                 M04 * P04 + F04 H04,
                 M05 * P05 + F05 H05,
                 M06 * P06 + F06 H06,
                 M07 * P07 + F07 H07,
                 M08 * P08 + F08 H08,
                 M09 * P09 + F09 H09,
                 M10 * P10 + F10 H10,
                 M11 * P11 + F11 H11,
                 M12 * P12 + F12 H12,
                M01 * P01  B01,
                M02 * P02  B02,
                M03 * P03  B03,
                M04 * P04  B04,
                M05 * P05  B05,
                M06 * P06  B06,
                M07 * P07  B07,
                M08 * P08  B08,
                M09 * P09  B09,
                M10 * P10  B10,
                M11 * P11  B11,
                M12 * P12  B12
            from (select t.*,
                         nvl(v.month_1, 0) F01,
                         nvl(v.month_2, 0) F02,
                         nvl(v.month_3, 0) F03,
                         nvl(v.month_4, 0) F04,
                         nvl(v.month_5, 0) F05,
                         nvl(v.month_6, 0) F06,
                         nvl(v.month_7, 0) F07,
                         nvl(v.month_8, 0) F08,
                         nvl(v.month_9, 0) F09,
                         nvl(v.month_10, 0) F10,
                         nvl(v.month_11, 0) F11,
                         nvl(v.month_12, 0) F12,
                         (nvl(v.month_1, 0) + nvl(v.month_2, 0) +
                         nvl(v.month_3, 0) + nvl(v.month_4, 0) +
                         nvl(v.month_5, 0) + nvl(v.month_6, 0) +
                         nvl(v.month_7, 0) + nvl(v.month_8, 0) +
                         nvl(v.month_9, 0) + nvl(v.month_10, 0) +
                         nvl(v.month_11, 0) + nvl(v.month_12, 0)) SUM_F,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M01 between a.schedule_min and a.schedule_max) P01,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M02 between a.schedule_min and a.schedule_max) P02,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M03 between a.schedule_min and a.schedule_max) P03,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M04 between a.schedule_min and a.schedule_max) P04,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M05 between a.schedule_min and a.schedule_max) P05,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M06 between a.schedule_min and a.schedule_max) P06,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M07 between a.schedule_min and a.schedule_max) P07,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M08 between a.schedule_min and a.schedule_max) P08,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M09 between a.schedule_min and a.schedule_max) P09,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M10 between a.schedule_min and a.schedule_max) P10,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M11 between a.schedule_min and a.schedule_max) P11,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M12 between a.schedule_min and a.schedule_max) P12,
                             v.create_name,v.create_time,v.update_name,v.update_time,v.delete_name,v.delete_time,
                             DECODE(V.VALIDFLAG,'1','有效','0','无效') VALIDFLAG,v.memo
                    from (select a1.PLINE_CODE,{0} Year_,a2.M01,a2.M02,a2.M03,a2.M04,a2.M05,a2.M06,a2.M07,a2.M08,a2.M09,a2.M10,a2.M11,a2.M12 from 
                      (select PLINE_CODE from com_base_pline  where VALIDFLAG = '1' and PROCESS_CODE = 'C') a1,			 
                    (select PLINE_CODE,
                                nvl(sum(case pro_month
                                           when '01' then
                                            WEIGTH_S
                                         end),
                                     0) as M01,
                                 nvl(sum(case pro_month
                                           when '02' then
                                            WEIGTH_S
                                         end),
                                     0) as M02,
                                 nvl(sum(case pro_month
                                           when '03' then
                                            WEIGTH_S
                                         end),
                                     0) as M03,
                                 nvl(sum(case pro_month
                                           when '04' then
                                            WEIGTH_S
                                         end),
                                     0) as M04,
                                 nvl(sum(case pro_month
                                           when '05' then
                                            WEIGTH_S
                                         end),
                                     0) as M05,
                                 nvl(sum(case pro_month
                                           when '06' then
                                            WEIGTH_S
                                         end),
                                     0) as M06,
                                 nvl(sum(case pro_month
                                           when '07' then
                                            WEIGTH_S
                                         end),
                                     0) as M07,
                                 nvl(sum(case pro_month
                                           when '08' then
                                            WEIGTH_S
                                         end),
                                     0) as M08,
                                 nvl(sum(case pro_month
                                           when '09' then
                                            WEIGTH_S
                                         end),
                                     0) as M09,
                                 nvl(sum(case pro_month
                                           when '10' then
                                            WEIGTH_S
                                         end),
                                     0) as M10,
                                 nvl(sum(case pro_month
                                           when '11' then
                                            WEIGTH_S
                                         end),
                                     0) as M11,
                                 nvl(sum(case pro_month
                                           when '12' then
                                            WEIGTH_S
                                         end),
                                     0) as M12
                            from (SELECT ZJ.c_pline  PLINE_CODE,
                                         sum(ZJ.weigth_s_c ) WEIGTH_S,
                                         substr(ZJ.year_month , -2, 2) PRO_MONTH
                                    FROM cost_calculation_a ZJ
                                   WHERE ZJ.year_month  LIKE '%' || {0} || '%'
                                   GROUP BY ZJ.c_pline , ZJ.year_month 
                                   order by c_pline , year_month ) t
                           group by PLINE_CODE ) a2 where a1.PLINE_CODE = a2.PLINE_CODE(+) ) t,
                         (select b.*
                            from COST_BASE_PROCESSCOST b
                           where b.validflag = '1') v
                   where t.pline_code = v.pline_code(+)
                     and t.year_ = v.Year(+)) T1)
        
        union all
        --镦拨扩
         (select t1.*,
                 M01 * P01 + F01 H01,
                 M02 * P02 + F02 H02,
                 M03 * P03 + F03 H03,
                 M04 * P04 + F04 H04,
                 M05 * P05 + F05 H05,
                 M06 * P06 + F06 H06,
                 M07 * P07 + F07 H07,
                 M08 * P08 + F08 H08,
                 M09 * P09 + F09 H09,
                 M10 * P10 + F10 H10,
                 M11 * P11 + F11 H11,
                 M12 * P12 + F12 H12,
                M01 * P01  B01,
                M02 * P02  B02,
                M03 * P03  B03,
                M04 * P04  B04,
                M05 * P05  B05,
                M06 * P06  B06,
                M07 * P07  B07,
                M08 * P08  B08,
                M09 * P09  B09,
                M10 * P10  B10,
                M11 * P11  B11,
                M12 * P12  B12
            from (select t.*,
                         nvl(v.month_1, 0) F01,
                         nvl(v.month_2, 0) F02,
                         nvl(v.month_3, 0) F03,
                         nvl(v.month_4, 0) F04,
                         nvl(v.month_5, 0) F05,
                         nvl(v.month_6, 0) F06,
                         nvl(v.month_7, 0) F07,
                         nvl(v.month_8, 0) F08,
                         nvl(v.month_9, 0) F09,
                         nvl(v.month_10, 0) F10,
                         nvl(v.month_11, 0) F11,
                         nvl(v.month_12, 0) F12,
                         (nvl(v.month_1, 0) + nvl(v.month_2, 0) +
                         nvl(v.month_3, 0) + nvl(v.month_4, 0) +
                         nvl(v.month_5, 0) + nvl(v.month_6, 0) +
                         nvl(v.month_7, 0) + nvl(v.month_8, 0) +
                         nvl(v.month_9, 0) + nvl(v.month_10, 0) +
                         nvl(v.month_11, 0) + nvl(v.month_12, 0)) SUM_F,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M01 between a.schedule_min and a.schedule_max) P01,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M02 between a.schedule_min and a.schedule_max) P02,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M03 between a.schedule_min and a.schedule_max) P03,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M04 between a.schedule_min and a.schedule_max) P04,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M05 between a.schedule_min and a.schedule_max) P05,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M06 between a.schedule_min and a.schedule_max) P06,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M07 between a.schedule_min and a.schedule_max) P07,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M08 between a.schedule_min and a.schedule_max) P08,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M09 between a.schedule_min and a.schedule_max) P09,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M10 between a.schedule_min and a.schedule_max) P10,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M11 between a.schedule_min and a.schedule_max) P11,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M12 between a.schedule_min and a.schedule_max) P12,
                             v.create_name,v.create_time,v.update_name,v.update_time,v.delete_name,v.delete_time,
                             DECODE(V.VALIDFLAG,'1','有效','0','无效') VALIDFLAG,v.memo
                    from (select a1.PLINE_CODE,{0} Year_,a2.M01,a2.M02,a2.M03,a2.M04,a2.M05,a2.M06,a2.M07,a2.M08,a2.M09,a2.M10,a2.M11,a2.M12 from 
                      (select PLINE_CODE from com_base_pline  where VALIDFLAG = '1' and PROCESS_CODE = 'E') a1,			 
                    (select PLINE_CODE,
                                nvl(sum(case pro_month
                                           when '01' then
                                            WEIGTH_S
                                         end),
                                     0) as M01,
                                 nvl(sum(case pro_month
                                           when '02' then
                                            WEIGTH_S
                                         end),
                                     0) as M02,
                                 nvl(sum(case pro_month
                                           when '03' then
                                            WEIGTH_S
                                         end),
                                     0) as M03,
                                 nvl(sum(case pro_month
                                           when '04' then
                                            WEIGTH_S
                                         end),
                                     0) as M04,
                                 nvl(sum(case pro_month
                                           when '05' then
                                            WEIGTH_S
                                         end),
                                     0) as M05,
                                 nvl(sum(case pro_month
                                           when '06' then
                                            WEIGTH_S
                                         end),
                                     0) as M06,
                                 nvl(sum(case pro_month
                                           when '07' then
                                            WEIGTH_S
                                         end),
                                     0) as M07,
                                 nvl(sum(case pro_month
                                           when '08' then
                                            WEIGTH_S
                                         end),
                                     0) as M08,
                                 nvl(sum(case pro_month
                                           when '09' then
                                            WEIGTH_S
                                         end),
                                     0) as M09,
                                 nvl(sum(case pro_month
                                           when '10' then
                                            WEIGTH_S
                                         end),
                                     0) as M10,
                                 nvl(sum(case pro_month
                                           when '11' then
                                            WEIGTH_S
                                         end),
                                     0) as M11,
                                 nvl(sum(case pro_month
                                           when '12' then
                                            WEIGTH_S
                                         end),
                                     0) as M12
                            from (SELECT ZJ.e_pline  PLINE_CODE,
                                         sum(ZJ.weigth_s_e ) WEIGTH_S,
                                         substr(ZJ.year_month , -2, 2) PRO_MONTH
                                    FROM cost_calculation_e ZJ
                                   WHERE ZJ.year_month  LIKE '%' || {0} || '%'
                                   GROUP BY ZJ.e_pline , ZJ.year_month 
                                   order by e_pline , year_month ) t
                           group by PLINE_CODE ) a2 where a1.PLINE_CODE = a2.PLINE_CODE(+) ) t,
                         (select b.*
                            from COST_BASE_PROCESSCOST b
                           where b.validflag = '1') v
                   where t.pline_code = v.pline_code(+)
                     and t.year_ = v.Year(+)) T1)
        
        union all
        --加工
         (select t1.*,
                 M01 * P01 + F01 H01,
                 M02 * P02 + F02 H02,
                 M03 * P03 + F03 H03,
                 M04 * P04 + F04 H04,
                 M05 * P05 + F05 H05,
                 M06 * P06 + F06 H06,
                 M07 * P07 + F07 H07,
                 M08 * P08 + F08 H08,
                 M09 * P09 + F09 H09,
                 M10 * P10 + F10 H10,
                 M11 * P11 + F11 H11,
                 M12 * P12 + F12 H12,
                M01 * P01  B01,
                M02 * P02  B02,
                M03 * P03  B03,
                M04 * P04  B04,
                M05 * P05  B05,
                M06 * P06  B06,
                M07 * P07  B07,
                M08 * P08  B08,
                M09 * P09  B09,
                M10 * P10  B10,
                M11 * P11  B11,
                M12 * P12  B12
            from (select t.*,
                         nvl(v.month_1, 0) F01,
                         nvl(v.month_2, 0) F02,
                         nvl(v.month_3, 0) F03,
                         nvl(v.month_4, 0) F04,
                         nvl(v.month_5, 0) F05,
                         nvl(v.month_6, 0) F06,
                         nvl(v.month_7, 0) F07,
                         nvl(v.month_8, 0) F08,
                         nvl(v.month_9, 0) F09,
                         nvl(v.month_10, 0) F10,
                         nvl(v.month_11, 0) F11,
                         nvl(v.month_12, 0) F12,
                         (nvl(v.month_1, 0) + nvl(v.month_2, 0) +
                         nvl(v.month_3, 0) + nvl(v.month_4, 0) +
                         nvl(v.month_5, 0) + nvl(v.month_6, 0) +
                         nvl(v.month_7, 0) + nvl(v.month_8, 0) +
                         nvl(v.month_9, 0) + nvl(v.month_10, 0) +
                         nvl(v.month_11, 0) + nvl(v.month_12, 0)) SUM_F,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M01 between a.schedule_min and a.schedule_max) P01,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M02 between a.schedule_min and a.schedule_max) P02,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M03 between a.schedule_min and a.schedule_max) P03,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M04 between a.schedule_min and a.schedule_max) P04,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M05 between a.schedule_min and a.schedule_max) P05,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M06 between a.schedule_min and a.schedule_max) P06,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M07 between a.schedule_min and a.schedule_max) P07,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M08 between a.schedule_min and a.schedule_max) P08,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M09 between a.schedule_min and a.schedule_max) P09,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M10 between a.schedule_min and a.schedule_max) P10,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M11 between a.schedule_min and a.schedule_max) P11,
                         (select nvl(max(a.cost_price), 0)
                            from COST_BASE_PROCESSCOST_C a
                           where a.validflag = '1'
                             and t.pline_code = a.pline_code
                             and t.M12 between a.schedule_min and a.schedule_max) P12,
                             v.create_name,v.create_time,v.update_name,v.update_time,v.delete_name,v.delete_time,
                             DECODE(V.VALIDFLAG,'1','有效','0','无效') VALIDFLAG,v.memo
                    from (select a1.PLINE_CODE,{0} Year_,a2.M01,a2.M02,a2.M03,a2.M04,a2.M05,a2.M06,a2.M07,a2.M08,a2.M09,a2.M10,a2.M11,a2.M12 from 
                      (select PLINE_CODE from com_base_pline  where VALIDFLAG = '1' and PROCESS_CODE = 'G') a1,			 
                    (select PLINE_CODE,
                                nvl(sum(case pro_month
                                           when '01' then
                                            WEIGTH_S
                                         end),
                                     0) as M01,
                                 nvl(sum(case pro_month
                                           when '02' then
                                            WEIGTH_S
                                         end),
                                     0) as M02,
                                 nvl(sum(case pro_month
                                           when '03' then
                                            WEIGTH_S
                                         end),
                                     0) as M03,
                                 nvl(sum(case pro_month
                                           when '04' then
                                            WEIGTH_S
                                         end),
                                     0) as M04,
                                 nvl(sum(case pro_month
                                           when '05' then
                                            WEIGTH_S
                                         end),
                                     0) as M05,
                                 nvl(sum(case pro_month
                                           when '06' then
                                            WEIGTH_S
                                         end),
                                     0) as M06,
                                 nvl(sum(case pro_month
                                           when '07' then
                                            WEIGTH_S
                                         end),
                                     0) as M07,
                                 nvl(sum(case pro_month
                                           when '08' then
                                            WEIGTH_S
                                         end),
                                     0) as M08,
                                 nvl(sum(case pro_month
                                           when '09' then
                                            WEIGTH_S
                                         end),
                                     0) as M09,
                                 nvl(sum(case pro_month
                                           when '10' then
                                            WEIGTH_S
                                         end),
                                     0) as M10,
                                 nvl(sum(case pro_month
                                           when '11' then
                                            WEIGTH_S
                                         end),
                                     0) as M11,
                                 nvl(sum(case pro_month
                                           when '12' then
                                            WEIGTH_S
                                         end),
                                     0) as M12
                            from (SELECT ZJ.g_pline PLINE_CODE,
                                         sum(ZJ.weigth_s_g ) WEIGTH_S,
                                         substr(ZJ.year_month , -2, 2) PRO_MONTH
                                    FROM cost_calculation_g ZJ
                                   WHERE ZJ.year_month  LIKE '%' || {0} || '%'
                                   GROUP BY ZJ.g_pline , ZJ.year_month 
                                   order by g_pline , year_month ) t
                           group by PLINE_CODE ) a2 where a1.PLINE_CODE = a2.PLINE_CODE(+) ) t,
                         (select b.*
                            from COST_BASE_PROCESSCOST b
                           where b.validflag = '1') v
                   where t.pline_code = v.pline_code(+)
                     and t.year_ = v.Year(+)) T1)) x
 where z.validflag = '1'
   and z.pline_code = x.pline_code(+)
 order by z.process_code, z.pline_code
	]]>
	</query>
</queryMap>