|
|
|
@ -1217,8 +1217,6 @@ ORDER BY 销售车号,物料编码,报工人 |
|
|
|
string where1 = ""; |
|
|
|
|
|
|
|
string SqlText = ""; |
|
|
|
|
|
|
|
|
|
|
|
SqlText = @" --socode销售车辆号 monum工单总行 wipnum报告结束数量 wipbnum报告的数量含开工中
|
|
|
|
select tmo.socode,tmo.monum,isnull(wip.wipnum ,0) as wipnum , isnull(wipb.num ,0) as wipbnum |
|
|
|
into #tempNum |
|
|
|
@ -1233,8 +1231,8 @@ ORDER BY 销售车号,物料编码,报工人 |
|
|
|
select tso.socode ,count(*) as wipnum from |
|
|
|
icsso tso |
|
|
|
left join (select mocode,molotcode from icsmo group by mocode,molotcode) tmo on tso.socode = tmo.molotcode |
|
|
|
LEFT JOIN ICSLOTONWIP wip on tmo.mocode = wip.mocode |
|
|
|
where wip.actionresult='COLLECT_END' |
|
|
|
LEFT JOIN ICSLOTSIMULATION wip on tmo.mocode = wip.mocode |
|
|
|
where wip.iscom='1' |
|
|
|
group by tso.socode |
|
|
|
) wip on tmo.socode = wip.socode |
|
|
|
left join |
|
|
|
@ -1248,15 +1246,16 @@ ORDER BY 销售车号,物料编码,报工人 |
|
|
|
) wipb on tmo.socode = wipb.socode |
|
|
|
|
|
|
|
select row_number() over (order by a.客户交货期,a.销售车辆号)as 序号, a.* from ( |
|
|
|
select distinct tso.socode 销售车辆号,tso.plandate as 客户交货期, isnull(convert(varchar(2),cus.fname),'') 用户单位, |
|
|
|
select distinct tso.socode 销售车辆号,tso.plandate as 客户交货期, isnull(convert(char(4),cus.fname),'') 用户单位, |
|
|
|
inv.invname as 产品名称, |
|
|
|
concat(cast(cast(tnum.wipnum * 1.0 / tnum.monum as decimal(18,3))* 100 as decimal(18,1)),'%') 进度, |
|
|
|
(case when tnum.wipnum/tnum.monum =1 then '已完工' when tnum.wipbnum >0 then '开工中' else '未开工' end ) 生产状态 |
|
|
|
from |
|
|
|
icsso tso |
|
|
|
left join ICSCustomer cus on tso.cusid = cus.ID |
|
|
|
left join ICSCustomer cus on tso.cusid = cus.FCUSTID |
|
|
|
left join icsmo tmo on tso.socode = tmo.molotcode |
|
|
|
left join #tempNum tnum on tnum.socode = tso.socode |
|
|
|
left join ICSINVENTORY inv on inv.invcode = tmo.itemcode |
|
|
|
left join ICSINVENTORY inv on inv.invstd LIKE '%'+'.'+tmo.molotcode |
|
|
|
where tso.status = 'C' and tmo.id in(select moid from ICSMO2ROUTE)) a |
|
|
|
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempNum')) |
|
|
|
drop table #tempNum ";
|
|
|
|
@ -1290,20 +1289,20 @@ ORDER BY 销售车号,物料编码,报工人 |
|
|
|
group by tso.socode |
|
|
|
) tmo |
|
|
|
left join ( |
|
|
|
select tso.socode ,count(*) as wipnum,wip.EndTime from |
|
|
|
select tso.socode ,count(*) as wipnum,min(wip.EndTime) EndTime from |
|
|
|
icsso tso |
|
|
|
left join (select mocode,molotcode from icsmo group by mocode,molotcode) tmo on tso.socode = tmo.molotcode |
|
|
|
LEFT JOIN ICSLOTONWIP wip on tmo.mocode = wip.mocode |
|
|
|
where wip.actionresult='COLLECT_END' |
|
|
|
group by tso.socode,wip.EndTime |
|
|
|
LEFT JOIN ICSLOTSIMULATION wip on tmo.mocode = wip.mocode |
|
|
|
where wip.iscom='1' |
|
|
|
group by tso.socode |
|
|
|
) wip on tmo.socode = wip.socode |
|
|
|
|
|
|
|
select * into #tempData from( |
|
|
|
select isnull(mpproduct,0) as 上月度生产 from ICSZXBoardPlan |
|
|
|
where moth = CONVERT(CHAR(10),DATEADD(month,0,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120) )a --此部分为上月数据 |
|
|
|
where moth = CONVERT(CHAR(10),DATEADD(month,-1,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120) )a --此部分为上月数据 |
|
|
|
left join ( |
|
|
|
select isnull(mpproduct,0) as 前月度生产 from ICSZXBoardPlan |
|
|
|
where moth = CONVERT(CHAR(10),DATEADD(month,-1,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120) ) b on 1=1 --此部分为前月数据 |
|
|
|
where moth = CONVERT(CHAR(10),DATEADD(month,-2,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120) ) b on 1=1 --此部分为前月数据 |
|
|
|
left join ( |
|
|
|
select count(*) 上月完成 from #tempNum t where t.wipnum = t.monum and t.EndTime between |
|
|
|
CONVERT(CHAR(10),DATEADD(month,-1,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120) |
|
|
|
@ -1315,10 +1314,14 @@ ORDER BY 销售车号,物料编码,报工人 |
|
|
|
|
|
|
|
select isnull(上月度生产,'0') 上月度生产 , isnull(上月完成,'0') 上月完成, |
|
|
|
isnull(前月度生产,'0') 前月度生产 , isnull(前月完成,'0') 前月完成, |
|
|
|
case when isnull(上月度生产,0) = 0 then 0 else |
|
|
|
convert(decimal(10,2),isnull(上月度生产,0))*1.0/isnull(convert(decimal(10,2),case when 上月完成 = 0 then 1 else 上月完成 end),1) end 上月比, |
|
|
|
case when isnull(前月度生产,0) = 0 then 0 else |
|
|
|
convert(decimal(10,2),isnull(前月度生产,0))*1.0/isnull(convert(decimal(10,2),case when 上月完成 = 0 then 1 else 上月完成 end),1) end 前月比, |
|
|
|
--case when isnull(上月度生产,0) = 0 then 0 else |
|
|
|
--convert(decimal(10,2),isnull(上月度生产,0))*1.0/isnull(convert(decimal(10,2),case when 上月完成 = 0 then 1 else 上月完成 end),1) end 上月比, |
|
|
|
--case when isnull(前月度生产,0) = 0 then 0 else |
|
|
|
--convert(decimal(10,2),isnull(前月度生产,0))*1.0/isnull(convert(decimal(10,2),case when 前月完成 = 0 then 1 else 前月完成 end),1) end 前月比, |
|
|
|
case when isnull(上月完成,0) = 0 then 0 else |
|
|
|
convert(decimal(10,2),isnull(上月完成,0))*1.0/isnull(convert(decimal(10,2),case when 上月度生产 = 0 then 1 else 上月度生产 end),1) end 上月比, |
|
|
|
case when isnull(前月完成,0) = 0 then 0 else |
|
|
|
convert(decimal(10,2),isnull(前月完成,0))*1.0/isnull(convert(decimal(10,2),case when 前月度生产 = 0 then 1 else 前月度生产 end),1) end 前月比, |
|
|
|
month(DATEADD(month,-1,DATEADD(dd,-DAY(GETDATE())+1,GETDATE()))) 上月, |
|
|
|
month(DATEADD(month,-2,DATEADD(dd,-DAY(GETDATE())+1,GETDATE()))) 前月 |
|
|
|
from #tempData |
|
|
|
|