Browse Source

no message

master
fyw 2 years ago
parent
commit
36cea159a1
  1. 159
      NFine.Application/SRM/WatchPanelApp.cs

159
NFine.Application/SRM/WatchPanelApp.cs

@ -1276,7 +1276,7 @@ ORDER BY 销售车号, 物料编码 ,报工人 asc
left join ICSCustomer cus with(nolock) on tso.cusid = cus.FCUSTID
left join icsmo tmo with(nolock) on tso.socode = tmo.molotcode
-- left join ICSINVENTORY inv with(nolock) on inv.invstd like tso.socode --tmo.itemcode
where tso.status = 'C' and tmo.id in(select moid from ICSMO2ROUTE with(nolock) )
where tmo.mostatus != '' and tso.status = 'C' and tmo.id in(select moid from ICSMO2ROUTE with(nolock) )
select ,
@ -1307,7 +1307,7 @@ ORDER BY 销售车号, 物料编码 ,报工人 asc
select tso. ,isnull(( select count(*)
from icsmo tmo with(nolock) where tso. = tmo.molotcode),0) monum ,
from icsmo tmo with(nolock) where tmo.mostatus != '' and tso. = tmo.molotcode),0) monum ,
isnull(CCOM.wipnum,0) wipnum ,
case when exists(select 1 from icsmo tmo where tso. = tmo.molotcode
and exists(select 1 from ICSLOTONWIP wip with(nolock) where tmo.mocode = wip.mocode and wip.actionresult!='') ) then 1 else 0 end wipbnum into #tempNum
@ -1355,6 +1355,7 @@ left join #Tempcccc cc on a.销售车辆号=cc.销售车辆号
select tso.socode ,count(*) as monum from
icsso tso
left join icsmo tmo on tso.socode = tmo.molotcode
where tmo.mostatus != ''
group by tso.socode
) tmo
left join (
@ -1365,6 +1366,7 @@ left join #Tempcccc cc on a.销售车辆号=cc.销售车辆号
where wip.iscom='1'
group by tso.socode
) wip on tmo.socode = wip.socode
where tmo.monum = wip.wipnum order by EndTime
select * into #tempData from(
select isnull(mpproduct,0) as from ICSZXBoardPlan
@ -1374,22 +1376,18 @@ left join #Tempcccc cc on a.销售车辆号=cc.销售车辆号
where moth = CONVERT(CHAR(10),DATEADD(month,0,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)
and CONVERT(CHAR(10),DATEADD(month,0,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)) c on 1=1
CONVERT(CHAR(10),DATEADD(month,0,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
and CONVERT(CHAR(10),DATEADD(month,1,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)) c on 1=1
left join (
select count(*) from #tempNum t where t.wipnum = t.monum and t.EndTime between
CONVERT(CHAR(10),DATEADD(month,0,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
and CONVERT(CHAR(10),DATEADD(month,-1,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)) d on 1=1
CONVERT(CHAR(10),DATEADD(month,-1,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
and CONVERT(CHAR(10),DATEADD(month,0,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)) d on 1=1
left join (
select count(*) from #tempNum t where t.wipnum = t.monum and t.EndTime >=
CONVERT(CHAR(10),DATEADD(month,-MONTH(GETDATE())+1,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)) e on 1=1
select isnull(,'0') , 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
@ -1480,47 +1478,49 @@ left join #Tempcccc cc on a.销售车辆号=cc.销售车辆号
select tso.socode ,count(*) as monum from
icsso tso
left join icsmo tmo on tso.socode = tmo.molotcode
where tmo.mostatus != ''
group by tso.socode
) tmo
left join (
select tso.socode ,count(*) as wipnum,min(wip.EndTime) EndTime from
select tso.socode ,count(*) as wipnum,max(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 ICSLOTSIMULATION wip on tmo.mocode = wip.mocode
where wip.iscom='1'
group by tso.socode
) wip on tmo.socode = wip.socode
where tmo.monum = wip.wipnum
select count(*) num , CONVERT(CHAR(7),DATEADD(month,0,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),111) Mont from #tempNum t
where t.wipnum = t.monum and t.EndTime between
CONVERT(CHAR(10),DATEADD(month,0,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
and CONVERT(CHAR(10),DATEADD(month,01,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
union
select count(*) num , CONVERT(CHAR(7),DATEADD(month,-1,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),111) Mont 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)
and CONVERT(CHAR(10),DATEADD(month,0,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
union
select count(*) num , CONVERT(CHAR(7),DATEADD(month,-1,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),111) Mont from #tempNum t
select count(*) num,CONVERT(CHAR(7),DATEADD(month,-2,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),111) Mont from #tempNum t
where t.wipnum = t.monum and t.EndTime between
CONVERT(CHAR(10),DATEADD(month,-2,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
and CONVERT(CHAR(10),DATEADD(month,-1,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
union
select count(*) num,CONVERT(CHAR(7),DATEADD(month,-2,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),111) Mont from #tempNum t
select count(*) num,CONVERT(CHAR(7),DATEADD(month,-3,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),111) Mont from #tempNum t
where t.wipnum = t.monum and t.EndTime between
CONVERT(CHAR(10),DATEADD(month,-3,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
and CONVERT(CHAR(10),DATEADD(month,-2,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
union
select count(*) num,CONVERT(CHAR(7),DATEADD(month,-3,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),111) Mont from #tempNum t
select count(*) num,CONVERT(CHAR(7),DATEADD(month,-4,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),111) Mont from #tempNum t
where t.wipnum = t.monum and t.EndTime between
CONVERT(CHAR(10),DATEADD(month,-4,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
and CONVERT(CHAR(10),DATEADD(month,-3,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
union
select count(*) num,CONVERT(CHAR(7),DATEADD(month,-4,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),111) Mont from #tempNum t
select count(*) num,CONVERT(CHAR(7),DATEADD(month,-5,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),111) Mont from #tempNum t
where t.wipnum = t.monum and t.EndTime between
CONVERT(CHAR(10),DATEADD(month,-5,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
and CONVERT(CHAR(10),DATEADD(month,-4,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
union
select count(*) num,CONVERT(CHAR(7),DATEADD(month,-5,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),111) Mont from #tempNum t
where t.wipnum = t.monum and t.EndTime between
CONVERT(CHAR(10),DATEADD(month,-6,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
and CONVERT(CHAR(10),DATEADD(month,-5,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),120)
order by Mont
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempNum'))
drop table #tempNum
@ -1632,64 +1632,64 @@ left join #Tempcccc cc on a.销售车辆号=cc.销售车辆号
drop table #Tcustt_TOCKQty
//--用途程表关联wip表拼出所有的检验数据
//select a.ITEMCODE,a.ROUTECODE,a.OPCODE, a.OPType AS OPTIONALOP, a.OPControlSeq,b.LOTNO,
//isnull(b.ACTIONRESULT,'~') as ACTIONRESULT,b.MOCODE,b.MOSEQ,d.molotcode into #Tcustttemp1
//from ICSITEMROUTE2OPLot a with(nolock)
//left join icslotonwip b with(nolock) on a.ITEMCODE = b.ITEMCODE and a.ROUTECODE = b.ROUTECODE and a.OPCODE = b.OPCODE
//inner join (SELECT distinct a.ITEMCODE,a.ROUTECODE
//from ICSITEMROUTE2OPLot a with(nolock)
//left join icslotonwip b with(nolock) on a.ITEMCODE = b.ITEMCODE and a.ROUTECODE = b.ROUTECODE and a.OPCODE = b.OPCODE
//WHERE b.ACTIONRESULT is not null
// ) c on a.ITEMCODE = c.ITEMCODE and a.ROUTECODE = c.ROUTECODE
//left join icsmo d with(nolock) on d.MOCODE = b.MOCODE and b.SEQ = d.MOSEQ
//order by ITEMCODE,OPControlSeq
//--把wip表里有在开工的排除
//select ITEMCODE,ROUTECODE,ACTIONRESULT into #Tcusttfilter from icslotonwip with(nolock)
//group by ITEMCODE,ROUTECODE,ACTIONRESULT HAVING COUNT(ITEMCODE) = 1 and COUNT(ROUTECODE)=1
//--找出待检的工序
//select ITEMCODE,a.ROUTECODE,OPCODE,c.MOCODE,c.MOSEQ,c.LOTNO into #TcusttDJ from #Tcustttemp1 a
//inner join
//(select min(OPControlSeq) OPControlSeq,ROUTECODE from #Tcustttemp1 where OPTIONALOP = '检验工序' and LOTNO is null--最小未检前一道结束的
//and ROUTECODE in
//(select ROUTECODE from (select max(a.OPControlSeq) OPControlSeq,a.ROUTECODE from #Tcustttemp1 a
//inner join (select min(OPControlSeq) OPControlSeq,ROUTECODE from #Tcustttemp1 where OPTIONALOP = '检验工序' and LOTNO is null group by ROUTECODE) b
//on a.ROUTECODE = b.ROUTECODE and b.OPControlSeq >a.OPControlSeq and a.ACTIONRESULT = 'COLLECT_END' group by a.ROUTECODE) a )
//GROUP BY ROUTECODE) b
//on a.ROUTECODE = b.ROUTECODE and a.OPControlSeq = b.OPControlSeq
//inner join ( select distinct mocode,MOSEQ,ROUTECODE,LOTNO from icslotonwip with(nolock) ) c
//on a.ROUTECODE =c.ROUTECODE
//where
//not EXISTS( select 1 from #Tcusttfilter f
// where f.ITEMCODE=a.ITEMCODE and f.ROUTECODE =a.ROUTECODE )
//--将数据拼接成在检和待检两部分
//--1、待检验数据 待检车辆
// select count(1) Qty into #Tcustt_TOCKQty
// from (
//select b.molotCode [销售车号] -- , dj.LOTNO [产品跟踪单], dj.OPCODE [工序代码]
//from #TcusttDJ dj
//inner join #Tcustttemp1 a on dj.ROUTECODE = a.ROUTECODE and a.OPCODE = dj.OPCODE and optionalop ='检验工序'
//inner join icsmo b with(nolock) on dj.MOCODE = b.MOCODE and dj.MOSEQ = b.MOSEQ
//inner join ICSMO2user d with(nolock) on b.mocode = d.mocode and b.moseq = d.moseq and d.opcode = dj.OPCODE
//where MONTH(d.MTIME)=MONTH(GETDATE()) and YEAR((d.MTIME)) = YEAR(GETDATE())
//union
//select c.molotCode [销售车号] --, d.LOTNO [产品跟踪单], d.OPCODE [工序代码]
//from
//(select * from ICSITEMROUTE2OP with(nolock) where optionalop ='检验工序' and routecode in(
//select DISTINCT routecode from ICSITEMROUTE2OP with(nolock) GROUP BY routecode HAVING count(*) = 1 )) a --查询只有一道工序的工艺路线
//inner JOIN ICSMO2ROUTE b with(nolock) on a.routeid = b.routeid
//inner join ICSMO c with(nolock) on c.id = b.moid
//inner join ICSMO2user d with(nolock) on c.mocode = d.mocode and c.moseq = d.moseq
//inner join ICSITEMROUTE2OPLot lot with(nolock) on lot.itemcode = a.ITEMCODE and b.ROUTECODE = lot.ROUTECODE and lot.OPCODE = d.opcode
//where not exists (select 1 from ICSLOTONWIP wip with(nolock) where wip.lotno = d.LOTNO and wip.opcode =d.OPCODE and wip.actionresult ='COLLECT_END' and MONTH(d.MTIME)=MONTH(GETDATE()) and YEAR((d.MTIME)) = YEAR(GETDATE()))
//) jj
----wip表拼出所有的检验数据
--select a.ITEMCODE,a.ROUTECODE,a.OPCODE, a.OPType AS OPTIONALOP, a.OPControlSeq,b.LOTNO,
--isnull(b.ACTIONRESULT,'~') as ACTIONRESULT,b.MOCODE,b.MOSEQ,d.molotcode into #Tcustttemp1
--from ICSITEMROUTE2OPLot a with(nolock)
--left join icslotonwip b with(nolock) on a.ITEMCODE = b.ITEMCODE and a.ROUTECODE = b.ROUTECODE and a.OPCODE = b.OPCODE
--inner join (SELECT distinct a.ITEMCODE,a.ROUTECODE
--from ICSITEMROUTE2OPLot a with(nolock)
--left join icslotonwip b with(nolock) on a.ITEMCODE = b.ITEMCODE and a.ROUTECODE = b.ROUTECODE and a.OPCODE = b.OPCODE
--WHERE b.ACTIONRESULT is not null
-- ) c on a.ITEMCODE = c.ITEMCODE and a.ROUTECODE = c.ROUTECODE
--left join icsmo d with(nolock) on d.MOCODE = b.MOCODE and b.SEQ = d.MOSEQ
--order by ITEMCODE,OPControlSeq
----wip表里有在开工的排除
--select ITEMCODE,ROUTECODE,ACTIONRESULT into #Tcusttfilter from icslotonwip with(nolock)
--group by ITEMCODE,ROUTECODE,ACTIONRESULT HAVING COUNT(ITEMCODE) = 1 and COUNT(ROUTECODE)=1
----
--select ITEMCODE,a.ROUTECODE,OPCODE,c.MOCODE,c.MOSEQ,c.LOTNO into #TcusttDJ from #Tcustttemp1 a
--inner join
--(select min(OPControlSeq) OPControlSeq,ROUTECODE from #Tcustttemp1 where OPTIONALOP = '' and LOTNO is null--
--and ROUTECODE in
--(select ROUTECODE from (select max(a.OPControlSeq) OPControlSeq,a.ROUTECODE from #Tcustttemp1 a
--inner join (select min(OPControlSeq) OPControlSeq,ROUTECODE from #Tcustttemp1 where OPTIONALOP = '' and LOTNO is null group by ROUTECODE) b
--on a.ROUTECODE = b.ROUTECODE and b.OPControlSeq >a.OPControlSeq and a.ACTIONRESULT = 'COLLECT_END' group by a.ROUTECODE) a )
--GROUP BY ROUTECODE) b
--on a.ROUTECODE = b.ROUTECODE and a.OPControlSeq = b.OPControlSeq
--inner join ( select distinct mocode,MOSEQ,ROUTECODE,LOTNO from icslotonwip with(nolock) ) c
--on a.ROUTECODE =c.ROUTECODE
--where
--not EXISTS( select 1 from #Tcusttfilter f
-- where f.ITEMCODE=a.ITEMCODE and f.ROUTECODE =a.ROUTECODE )
----
----1
-- select count(1) Qty into #Tcustt_TOCKQty
-- from (
--select b.molotCode [] -- , dj.LOTNO [], dj.OPCODE []
--from #TcusttDJ dj
--inner join #Tcustttemp1 a on dj.ROUTECODE = a.ROUTECODE and a.OPCODE = dj.OPCODE and optionalop =''
--inner join icsmo b with(nolock) on dj.MOCODE = b.MOCODE and dj.MOSEQ = b.MOSEQ
--inner join ICSMO2user d with(nolock) on b.mocode = d.mocode and b.moseq = d.moseq and d.opcode = dj.OPCODE
--where MONTH(d.MTIME)=MONTH(GETDATE()) and YEAR((d.MTIME)) = YEAR(GETDATE())
--union
--select c.molotCode [] --, d.LOTNO [], d.OPCODE []
--from
--(select * from ICSITEMROUTE2OP with(nolock) where optionalop ='' and routecode in(
--select DISTINCT routecode from ICSITEMROUTE2OP with(nolock) GROUP BY routecode HAVING count(*) = 1 )) a --线
--inner JOIN ICSMO2ROUTE b with(nolock) on a.routeid = b.routeid
--inner join ICSMO c with(nolock) on c.id = b.moid
--inner join ICSMO2user d with(nolock) on c.mocode = d.mocode and c.moseq = d.moseq
--inner join ICSITEMROUTE2OPLot lot with(nolock) on lot.itemcode = a.ITEMCODE and b.ROUTECODE = lot.ROUTECODE and lot.OPCODE = d.opcode
--where not exists (select 1 from ICSLOTONWIP wip with(nolock) where wip.lotno = d.LOTNO and wip.opcode =d.OPCODE and wip.actionresult ='COLLECT_END' and MONTH(d.MTIME)=MONTH(GETDATE()) and YEAR((d.MTIME)) = YEAR(GETDATE()))
--) jj
@ -1795,7 +1795,7 @@ left join #Tempcccc cc on a.销售车辆号=cc.销售车辆号
LEFT JOIN ICSITEMROUTE2OPLot ll with(nolock) on ll.OPCODE=a.OPCODE and ll.LotNo=a.LOTNO
WHERE ll.OPType='' and MONTH(d.MTIME)=MONTH(GETDATE()) and YEAR((d.MTIME)) = YEAR(GETDATE()) --b.MTIME>= CONVERT(varchar(7), dateadd(mm,-1,getdate()), 21) +'-01 00:00:00'
WHERE ll.OPType='' and MONTH(d.BeginTime)=MONTH(GETDATE()) and YEAR((d.BeginTime)) = YEAR(GETDATE()) --b.MTIME>= CONVERT(varchar(7), dateadd(mm,-1,getdate()), 21) +'-01 00:00:00'
and b.CKRESULT is not null
) jj
@ -1804,6 +1804,7 @@ left join #Tempcccc cc on a.销售车辆号=cc.销售车辆号
isnull((select Qty from #Tcustt_CKQty ),0) ,
isnull((select count(1) from ICSZXCheck with(nolock) where checked='0'),0) ,
isnull((select count(1) from ICSZXCheck with(nolock) where checked='1' and month>= CONVERT(varchar(7), dateadd(mm,-1,getdate()), 21) +'-01' ),0)
drop table #Tcustt_TOCKQty
drop table #temp1
drop table #DJ
drop table #yjCheck

Loading…
Cancel
Save