0
and y.pline_code=x.pline_code) as outputweight
,(select to_char(sum(y.qualified_wt),'FM9,999,990.000')
from v_production_d_pweight y
where y.bal_year_month=replace(substr('#today#',1,7),'-','')
and y.proc_date<=replace('#today#','-','') and qualified_wt>0
and y.pline_code=x.pline_code) as totaloutputweight
,'' as productionrate
,'' as firstgoodrate
,'' as productionrate_m
,'' as firstgoodrate_m
,y.input_d as input,y.output_d as output,y.firstgood_d as firstgood
,x.input_m as totalinput,x.output_m as totaloutput,x.firstgood_m as totalfirstgood
from v_production_d_pline a
left join (select t.pline_code,sum(t.input) as input_m,sum(t.outputweight) as outputweight_m
,sum(t.output) as output_m,sum(t.firstgood) as firstgood_m,sum(t.production) as production_m
from v_production_d_new t
where substr(t.production_date,1,7)=substr('#today#',1,7)
and t.production_date<='#today#'
group by t.pline_code) x on x.pline_code=a.pline_code
left join
(select t.pline_code,sum(t.input) as input_d
,sum(t.output) as output_d,sum(t.firstgood) as firstgood_d,sum(t.production) as production_d,sum(t.outputweight) as outputweight_d
from v_production_d_new t
where t.production_date='#today#'
group by t.pline_code) y on y.pline_code=a.pline_code
where (select sum(y.qualified_wt)
from v_production_d_pweight y
where y.bal_year_month=replace(substr('#today#',1,7),'-','')
and y.proc_date<=replace('#today#','-','') and qualified_wt>0
and y.pline_code=x.pline_code) is not null or production_m is not null
order by a.department_code_p,a.factory_code,a.pline_code;
insert into TEMP_TAB_RPT_PRODUCTION (productiondate, processcode,area,dept,plinename,production,totalproduction,
outputweight, totaloutputweight,productionrate,firstgoodrate,productionrate_m,firstgoodrate_m,input,
output, firstgood,totalinput,totaloutput,totalfirstgood)
select '#today#' as productiondate,'E' as processcode
,a.department_desc_p,a.factoryname,a.pline_name as plinename
,to_char(production_d,'FM9,999,990.000') as production
,to_char(production_m,'FM9,999,990.000') as totalproduction
,(select to_char(sum(y.qualified_wt),'FM9,999,990.000')
from v_production_e_pweight y
where y.proc_date=replace('#today#','-','')
and y.pline_code=x.pline_code) as outputweight
,(select to_char(sum(y.qualified_wt),'FM9,999,990.000')
from v_production_e_pweight y
where bal_year_month=replace(substr('#today#',1,7),'-','')
and y.proc_date<=replace('#today#','-','')
and y.pline_code=x.pline_code) as totaloutputweight
,'' as productionrate
,'' as firstgoodrate
,'' as productionrate_m
,'' as firstgoodrate_m
,y.input_d as input,y.output_d as output,y.firstgood_d as firstgood
,x.input_m as totalinput,x.output_m as totaloutput,x.firstgood_m as totalfirstgood
from v_production_e_pline a
left join
(select t.pline_code,sum(t.input) as input_m,sum(t.output_weight) as outputweight_m
,sum(t.output) as output_m,sum(t.firstgood) as firstgood_m,sum(t.production) as production_m
from v_production_e t
where substr(t.production_date,1,7)=substr('#today#',1,7)
and t.production_date<='#today#'
group by t.pline_code) x on x.pline_code=a.pline_code
left join
(select t.pline_code,sum(t.input) as input_d
,sum(t.output) as output_d,sum(t.firstgood) as firstgood_d,sum(t.production) as production_d,sum(t.output_weight) as outputweight_d
from v_production_e t
where t.production_date='#today#'
group by t.pline_code) y on y.pline_code=a.pline_code
where (select sum(y.qualified_wt)
from v_production_e_pweight y
where y.bal_year_month=replace(substr('#today#',1,7),'-','')
and y.proc_date<=replace('#today#','-','')
and y.pline_code=x.pline_code) is not null or production_m is not null
order by a.department_code_p,a.factory_code,a.pline_code;
insert into TEMP_TAB_RPT_PRODUCTION (productiondate, processcode,area,dept,plinename,production,totalproduction,
outputweight, totaloutputweight,productionrate,firstgoodrate,productionrate_m,firstgoodrate_m,input,
output, firstgood,totalinput,totaloutput,totalfirstgood)
select '#today#' as productiondate,'F' as processcode
,a.department_desc_p,a.factoryname,a.pline_name as plinename
,to_char(production_d,'FM9,999,990.000') as production
,to_char(production_m,'FM9,999,990.000') as totalproduction
,(select to_char(sum(y.qualified_wt),'FM9,999,990.000')
from v_production_f_pweight y
where proc_date=replace('#today#','-','')
and y.pline_code=x.pline_code) as outputweight
,(select to_char(sum(y.qualified_wt),'FM9,999,990.000')
from v_production_f_pweight y
where y.bal_year_month=replace(substr('#today#',1,7),'-','')
and y.proc_date<=replace('#today#','-','')
and y.pline_code=x.pline_code) as totaloutputweight
,'' as productionrate
,'' as firstgoodrate
,'' as productionrate_m
,'' as firstgoodrate_m
,y.input_d as input,y.output_d as output,y.firstgood_d as firstgood
,x.input_m as totalinput,x.output_m as totaloutput,x.firstgood_m as totalfirstgood
from v_production_f_pline a
left join
(select t.pline_code,sum(t.input) as input_m,sum(t.output_weight) as outputweight_m
,sum(t.output) as output_m,sum(t.firstgood) as firstgood_m,sum(t.production) as production_m
from v_production_f t
where substr(t.production_date,1,7)=substr('#today#',1,7)
and t.production_date<='#today#'
group by t.pline_code) x on x.pline_code=a.pline_code
left join
(select t.pline_code,sum(t.input) as input_d
,sum(t.output) as output_d,sum(t.firstgood) as firstgood_d,sum(t.production) as production_d,sum(t.output_weight) as outputweight_d
from v_production_f t
where t.production_date='#today#'
group by t.pline_code) y on y.pline_code=a.pline_code
where (select sum(y.qualified_wt)
from v_production_f_pweight y
where y.bal_year_month=replace(substr('#today#',1,7),'-','')
and y.proc_date<=replace('#today#','-','')
and y.pline_code=x.pline_code) is not null or production_m is not null
order by a.department_code_p,a.factory_code,a.pline_code;
insert into TEMP_TAB_RPT_PRODUCTION (productiondate, processcode,area,dept,plinename,production,totalproduction,
outputweight, totaloutputweight,productionrate,firstgoodrate,productionrate_m,firstgoodrate_m,input,
output, firstgood,totalinput,totaloutput,totalfirstgood)
select '#today#' as productiondate,'G' as processcode
,a.department_desc_p,a.factoryname,a.pline_name as plinename
,to_char(production_d,'FM9,999,990.000') as production
,to_char(production_m,'FM9,999,990.000') as totalproduction
,(select to_char(sum(qualified_wt),'FM9,999,990.000')
from v_production_g_pweight t --生产点
where proc_date=replace('#today#','-','')
and t.pline_code=a.pline_code) as outputweight
,(select to_char(sum(qualified_wt),'FM9,999,990.000')
from v_production_g_pweight t --生产点
where t.bal_year_month=replace(substr('#today#',1,7),'-','')
and proc_date<=replace('#today#','-','')
and t.pline_code=a.pline_code) as totaloutputweight
,'' as productionrate
,'' as firstgoodrate
,'' as productionrate_m
,'' as firstgoodrate_m
,y.input_d as input,y.output_d as output,y.firstgood_d as firstgood
,x.input_m as totalinput,x.output_m as totaloutput,x.firstgood_m as totalfirstgood
from v_production_g_pline a
left join
(select t.pline_code,sum(t.input) as input_m
,sum(t.output) as output_m,sum(t.firstgood) as firstgood_m,sum(t.production) as production_m,sum(t.output_weight) as outputweight_m
from v_production_g t
where substr(t.production_date,1,7)=substr('#today#',1,7)
and t.production_date<='#today#'
group by t.pline_code) x on x.pline_code=a.pline_code
left join
(select t.pline_code,sum(t.input) as input_d
,sum(t.output) as output_d,sum(t.firstgood) as firstgood_d,sum(t.production) as production_d,sum(t.output_weight) as outputweight_d
from v_production_g t
where t.production_date='#today#'
group by t.pline_code) y on y.pline_code=a.pline_code
where (select sum(qualified_wt)
from v_production_g_pweight t --生产点
where t.bal_year_month=replace(substr('#today#',1,7),'-','')
and proc_date<=replace('#today#','-','')
and t.pline_code=a.pline_code) is not null or production_m is not null
order by a.department_code_p,a.factory_code,a.pline_code;
commit;
end;
]]>
0
and y.pline_code=x.pline_code) as outputweight
,(select to_char(sum(y.qualified_wt),'FM9,999,990.000')
from v_production_d_pweight y
where y.bal_year_month=replace(substr('#today#',1,7),'-','')
and y.proc_date<=replace('#today#','-','') and qualified_wt>0
and y.pline_code=x.pline_code) as totaloutputweight
,'' as productionrate
,'' as firstgoodrate
,'' as productionrate_m
,'' as firstgoodrate_m
,y.input_d as input,y.output_d as output,y.firstgood_d as firstgood
,x.input_m as totalinput,x.output_m as totaloutput,x.firstgood_m as totalfirstgood
from v_production_d_pline a
left join (select t.pline_code,sum(t.input) as input_m,sum(t.outputweight) as outputweight_m
,sum(t.output) as output_m,sum(t.firstgood) as firstgood_m,sum(t.production) as production_m
from v_production_d_new t
where substr(t.production_date,1,7)=substr('#today#',1,7)
and t.production_date<='#today#'
group by t.pline_code) x on x.pline_code=a.pline_code
left join
(select t.pline_code,sum(t.input) as input_d
,sum(t.output) as output_d,sum(t.firstgood) as firstgood_d,sum(t.production) as production_d,sum(t.outputweight) as outputweight_d
from v_production_d_new t
where t.production_date='#today#'
group by t.pline_code) y on y.pline_code=a.pline_code
where (select sum(y.qualified_wt)
from v_production_d_pweight y
where y.bal_year_month=replace(substr('#today#',1,7),'-','')
and y.proc_date<=replace('#today#','-','') and qualified_wt>0
and y.pline_code=x.pline_code) is not null or production_m is not null
order by a.department_code_p,a.factory_code,a.pline_code)
union all
select * from (select '#today#' as productiondate,'E' as processcode
,a.department_desc_p,a.factoryname,a.pline_name as plinename
,to_char(production_d,'FM9,999,990.000') as production
,to_char(production_m,'FM9,999,990.000') as totalproduction
,(select to_char(sum(y.qualified_wt),'FM9,999,990.000')
from v_production_e_pweight y
where y.proc_date=replace('#today#','-','')
and y.pline_code=x.pline_code) as outputweight
,(select to_char(sum(y.qualified_wt),'FM9,999,990.000')
from v_production_e_pweight y
where bal_year_month=replace(substr('#today#',1,7),'-','')
and y.proc_date<=replace('#today#','-','')
and y.pline_code=x.pline_code) as totaloutputweight
,'' as productionrate
,'' as firstgoodrate
,'' as productionrate_m
,'' as firstgoodrate_m
,y.input_d as input,y.output_d as output,y.firstgood_d as firstgood
,x.input_m as totalinput,x.output_m as totaloutput,x.firstgood_m as totalfirstgood
from v_production_e_pline a
left join
(select t.pline_code,sum(t.input) as input_m,sum(t.output_weight) as outputweight_m
,sum(t.output) as output_m,sum(t.firstgood) as firstgood_m,sum(t.production) as production_m
from v_production_e t
where substr(t.production_date,1,7)=substr('#today#',1,7)
and t.production_date<='#today#'
group by t.pline_code) x on x.pline_code=a.pline_code
left join
(select t.pline_code,sum(t.input) as input_d
,sum(t.output) as output_d,sum(t.firstgood) as firstgood_d,sum(t.production) as production_d,sum(t.output_weight) as outputweight_d
from v_production_e t
where t.production_date='#today#'
group by t.pline_code) y on y.pline_code=a.pline_code
where (select sum(y.qualified_wt)
from v_production_e_pweight y
where y.bal_year_month=replace(substr('#today#',1,7),'-','')
and y.proc_date<=replace('#today#','-','')
and y.pline_code=x.pline_code) is not null or production_m is not null
order by a.department_code_p,a.factory_code,a.pline_code)
union all
select * from (select '#today#' as productiondate,'F' as processcode
,a.department_desc_p,a.factoryname,a.pline_name as plinename
,to_char(production_d,'FM9,999,990.000') as production
,to_char(production_m,'FM9,999,990.000') as totalproduction
,(select to_char(sum(y.qualified_wt),'FM9,999,990.000')
from v_production_f_pweight y
where proc_date=replace('#today#','-','')
and y.pline_code=x.pline_code) as outputweight
,(select to_char(sum(y.qualified_wt),'FM9,999,990.000')
from v_production_f_pweight y
where y.bal_year_month=replace(substr('#today#',1,7),'-','')
and y.proc_date<=replace('#today#','-','')
and y.pline_code=x.pline_code) as totaloutputweight
,'' as productionrate
,'' as firstgoodrate
,'' as productionrate_m
,'' as firstgoodrate_m
,y.input_d as input,y.output_d as output,y.firstgood_d as firstgood
,x.input_m as totalinput,x.output_m as totaloutput,x.firstgood_m as totalfirstgood
from v_production_f_pline a
left join
(select t.pline_code,sum(t.input) as input_m,sum(t.output_weight) as outputweight_m
,sum(t.output) as output_m,sum(t.firstgood) as firstgood_m,sum(t.production) as production_m
from v_production_f t
where substr(t.production_date,1,7)=substr('#today#',1,7)
and t.production_date<='#today#'
group by t.pline_code) x on x.pline_code=a.pline_code
left join
(select t.pline_code,sum(t.input) as input_d
,sum(t.output) as output_d,sum(t.firstgood) as firstgood_d,sum(t.production) as production_d,sum(t.output_weight) as outputweight_d
from v_production_f t
where t.production_date='#today#'
group by t.pline_code) y on y.pline_code=a.pline_code
where (select sum(y.qualified_wt)
from v_production_f_pweight y
where y.bal_year_month=replace(substr('#today#',1,7),'-','')
and y.proc_date<=replace('#today#','-','')
and y.pline_code=x.pline_code) is not null or production_m is not null
order by a.department_code_p,a.factory_code,a.pline_code)
union all
select * from (select '#today#' as productiondate,'G' as processcode
,a.department_desc_p,a.factoryname,a.pline_name as plinename
,to_char(production_d,'FM9,999,990.000') as production
,to_char(production_m,'FM9,999,990.000') as totalproduction
,(select to_char(sum(qualified_wt),'FM9,999,990.000')
from v_production_g_pweight t --生产点
where proc_date=replace('#today#','-','')
and t.pline_code=a.pline_code) as outputweight
,(select to_char(sum(qualified_wt),'FM9,999,990.000')
from v_production_g_pweight t --生产点
where t.bal_year_month=replace(substr('#today#',1,7),'-','')
and proc_date<=replace('#today#','-','')
and t.pline_code=a.pline_code) as totaloutputweight
,'' as productionrate
,'' as firstgoodrate
,'' as productionrate_m
,'' as firstgoodrate_m
,y.input_d as input,y.output_d as output,y.firstgood_d as firstgood
,x.input_m as totalinput,x.output_m as totaloutput,x.firstgood_m as totalfirstgood
from v_production_g_pline a
left join
(select t.pline_code,sum(t.input) as input_m
,sum(t.output) as output_m,sum(t.firstgood) as firstgood_m,sum(t.production) as production_m,sum(t.output_weight) as outputweight_m
from v_production_g t
where substr(t.production_date,1,7)=substr('#today#',1,7)
and t.production_date<='#today#'
group by t.pline_code) x on x.pline_code=a.pline_code
left join
(select t.pline_code,sum(t.input) as input_d
,sum(t.output) as output_d,sum(t.firstgood) as firstgood_d,sum(t.production) as production_d,sum(t.output_weight) as outputweight_d
from v_production_g t
where t.production_date='#today#'
group by t.pline_code) y on y.pline_code=a.pline_code
where (select sum(qualified_wt)
from v_production_g_pweight t --生产点
where t.bal_year_month=replace(substr('#today#',1,7),'-','')
and proc_date<=replace('#today#','-','')
and t.pline_code=a.pline_code) is not null or production_m is not null
order by a.department_code_p,a.factory_code,a.pline_code)
]]>
E