Browse Source

no message

master
fyw 2 years ago
parent
commit
abdc306746
  1. 253
      NFine.Application/SRM/WatchPanelApp.cs

253
NFine.Application/SRM/WatchPanelApp.cs

@ -1129,66 +1129,99 @@ select * from (
string SqlText = ""; string SqlText = "";
SqlText = @" SqlText = @"
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempCCDD_Tt'))
drop table #TempCCDD_Tt
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempCCDD')) if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempCCDD'))
drop table #TempCCDD drop table #TempCCDD
SELECT DISTINCT C.molotcode as ,C.ITEMCODE ,dd.INVNAME ,C.MOCODE ,LL.OPSEQ,
a.OPCODE ,ppp.opname ,us.UserName ,
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempFFF'))
drop table #TempFFF
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempXXXXX'))
drop table #TempXXXXX
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempZTPP'))
drop table #TempZTPP
SELECT C.molotcode as ,C.ITEMCODE ,dd.INVNAME ,C.MOCODE ,
a.OPCODE ,ppp.opname ,us.UserName ,B.UserCodeBegin,
CASE WHEN A.ACTIONRESULT='COLLECT_BEGIN' then '--------' WHEN A.ACTIONRESULT='COLLECT_END' then '--------' end as , CASE WHEN A.ACTIONRESULT='COLLECT_BEGIN' then '--------' WHEN A.ACTIONRESULT='COLLECT_END' then '--------' end as ,
SUM(DATEDIFF(MINUTE, B.BeginDateTime, B.EndDateTime)) as '',
isnull(SUM(DATEDIFF(MINUTE, B.BeginDateTime, B.EndDateTime))-ISNULL(xx.[],0),'') AS ,
xx.[],
isnull(CONVERT(VARCHAR,B.BeginDateTime,120),'') ,
isnull(CONVERT(VARCHAR,B.EndDateTime,120),'') ,
isnull(CONVERT(VARCHAR,xx. ,120),'') as ,
isnull(CONVERT(VARCHAR,xx.,120),'') as ,
isnull(xx.[],'') ,
xx.[]
into #TempCCDD
FROM ICSLOTONWIP A
LEFT JOIN ICSLOTONWIPDetail B ON A.LOTNO=B.LOTNO AND A.OPCODE=B.OPCODE
LEFT JOIN ICSOP ppp on a.OPCODE=ppp.OPCODE
LEFT JOIN ICSLOTSIMULATION nn on nn.LOTNO=A.LOTNO
LEFT JOIN Sys_User us on us.UserCode=B.UserCodeBegin
LEFT JOIN ICSMO C ON A.MOCODE=C.MOCODE AND A.MOSEQ=C.MOSEQ
LEFT JOIN ICSMO2ROUTE gg ON c.MOCODE=gg.MOCODE and gg.EATTRIBUTE1=C.MOSEQ
LEFT JOIN ICSINVENTORY dd on C.ITEMCODE=dd.INVCODE
LEFT JOIN ICSITEMROUTE2OPLot LL ON LL.LotNo=A.LOTNO AND A.OPCODE=LL.OPCODE
LEFT JOIN ICSMO2User UU ON UU.LOTNO=A.LOTNO AND UU.OPCODE=A.OPCODE AND B.ECCode=UU.CREWCODE
LEFT JOIN (SELECT DISTINCT C.molotcode as ,C.ITEMCODE ,dd.INVNAME ,gg.ROUTECODE 线 ,A.LOTNO ,
c.MOCODE ,c.MOSEQ , A.OPCODE ,us.UserName as ,
pp.BeginTime ,
pp.EndTime ,
SUM(DATEDIFF(MINUTE, PP.BeginTime, PP.EndTime)) as '' ,
ISNULL(DATEDIFF(MINUTE, B.BeginDateTime, B.EndDateTime) ,0) as '',
isnull(CONVERT(VARCHAR(19),B.BeginDateTime,21),'') ,
isnull(CONVERT(VARCHAR(19),B.EndDateTime,21),'') ,A.ID,B.ID DetailID,B.BeginDateTime,B.EndDateTime
into #TempCCDD_Tt
FROM ICSLOTONWIP A with(nolock)
LEFT JOIN ICSLOTONWIPDetail B with(nolock) ON A.LOTNO=B.LOTNO AND A.OPCODE=B.OPCODE
LEFT JOIN ICSOP ppp with(nolock) on a.OPCODE=ppp.OPCODE
LEFT JOIN Sys_User us with(nolock) on us.UserCode=B.UserCodeBegin
LEFT JOIN ICSMO C with(nolock) ON A.MOCODE=C.MOCODE AND A.MOSEQ=C.MOSEQ
LEFT JOIN ICSINVENTORY dd with(nolock) on C.ITEMCODE=dd.INVCODE
where 1=1 AND b.Type='' and a.WorkPoint='6000' and B.BeginDateTime>=DATEADD(mm, -1, getdate())
ORDER BY C.molotcode, C.ITEMCODE , us.UserName asc
SELECT A.id,
PP.Usercode ,
isnull(CONVERT(varchar(19), pp.BeginTime, 21),'') ,
isnull( CONVERT(varchar(19), pp.EndTime, 21) ,'') ,
isnull(vv.EnumText,'') , isnull(vv.EnumText,'') ,
pp.Memo
from ICSLOTONWIP A INNER JOIN ICSLOTPAUSE pp on A.Lotno=pp.lotno and A.opcode=pp.opcode
LEFT JOIN Sys_User us on us.UserCode=PP.Usercode
LEFT JOIN ICSMO C ON A.MOCODE=C.MOCODE AND A.MOSEQ=C.MOSEQ
LEFT JOIN ICSMO2ROUTE gg ON c.MOCODE=gg.MOCODE and gg.EATTRIBUTE1=C.MOSEQ
LEFT JOIN ICSINVENTORY dd on C.ITEMCODE=dd.INVCODE
LEFT JOIN ICSITEMROUTE2OPLot LL ON LL.LotNo=A.LOTNO AND A.OPCODE=LL.OPCODE
LEFT JOIN ICSMO2User UU ON UU.LOTNO=A.LOTNO AND UU.OPCODE=A.OPCODE AND pp.EATTRIBUTE1=UU.CREWCODE
LEFT JOIN Sys_EnumValues vv on vv.EnumValue=pp.RESCODE --AND vv.EnumKey='00022'
where pp.MODELCODE='' and vv.EnumKey='00022' --AND a.LOTNO=''-- and A.ACTIONRESULT = 'COLLECT_END'
GROUP BY C.molotcode,C.ITEMCODE ,dd.INVNAME ,gg.ROUTECODE, A.LOTNO,c.MOCODE ,c.MOSEQ , A.OPCODE ,us.UserName,pp.BeginTime,pp.EndTime,vv.EnumText ,
pp.Memo)
xx on xx.[]=c.MOCODE AND xx.[]=c.MOSEQ AND A.OPCODE=xx.[] AND xx.[]=us.UserName AND xx. >B.BeginDateTime
--AND xx. < B.EndDateTime
AND ISNULL(xx., '2024-02-21 17:37:02') < ISNULL(B.EndDateTime, '2025-02-21 17:37:02')
where 1=1 AND b.Type='' and a.WorkPoint='6000' and B.BeginDateTime>=DATEADD(mm, -3, getdate())
GROUP BY C.molotcode,C.ITEMCODE ,dd.INVNAME ,gg.ROUTECODE, A.LOTNO,c.MOCODE ,c.MOSEQ , A.OPCODE ,
us.UserName,xx.[],nn.ISCOM,b.MTIME,B.BeginDateTime, B.EndDateTime,xx.[],xx.[],ppp.opname,xx.[],
xx.[],A.ACTIONRESULT,LL.OPSEQ
ORDER BY C.molotcode, C.ITEMCODE ,LL.OPSEQ,us.UserName asc
SELECT *,case when is not null and is null then '' else '' end FROM #TempCCDD
WHERE CONVERT(varchar(10), , 21) =(SELECT MAX(CONVERT(varchar(10), , 21)) FROM #TempCCDD)
ORDER BY ,,
DATEDIFF(MINUTE, PP.BeginTime, PP.EndTime)
into #TempFFF
from ICSLOTONWIP A with(nolock)
INNER JOIN ICSLOTPAUSE pp with(nolock) on A.Lotno=pp.lotno and A.opcode=pp.opcode
LEFT JOIN Sys_EnumValues vv with(nolock) on vv.EnumValue=pp.RESCODE
where pp.MODELCODE='' and vv.EnumKey='00022'
and pp.BeginTime >=DATEADD(mm, -1, getdate())
SELECT DD.DetailID,XX.,xx.,xx. ,xx.
into #TempXXXXX
FROM #TempCCDD_Tt DD
LEFT JOIN #TempFFF XX ON DD.ID=XX.ID AND xx.[Usercode]=DD.UserCodeBegin AND xx. >DD.BeginDateTime
AND ISNULL(xx., '2024-02-21 17:37:02') < ISNULL(DD.EndDateTime, '2025-02-21 17:37:02')
SELECT DetailID,SUM() ,MIN() ,MAX() ,
STUFF((select',' + from (SELECT DISTINCT
FROM #TempXXXXX SS WHERE SS.DetailID=HH.DetailID ) DD for xml path('')),1,1,'')
INTO #TempZTPP
FROM #TempXXXXX HH
GROUP BY DetailID
SELECT , , , , , , , ,
ISNULL(DATEDIFF(MINUTE, DD.BeginDateTime, DD.EndDateTime) ,0) as '',
ISNULL( DATEDIFF(MINUTE, dd.BeginDateTime, dd.EndDateTime) -ISNULL(xx.[],0) ,0) AS ,
ISNULL(xx.[],0) ,
DD.,
DD.,
ISNULL(xx. ,'') ,
ISNULL(xx.,'') ,
isnull(xx.[],'') ,
case when is not null and is null then '' else '' end
FROM #TempCCDD_Tt DD
LEFT JOIN #TempZTPP xx on XX.DetailID=DD.DetailID
WHERE CONVERT(varchar(10), dd., 21) =(SELECT MAX(CONVERT(varchar(10), , 21)) FROM #TempCCDD_Tt)
ORDER BY , , asc
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempCCDD_Tt'))
drop table #TempCCDD_Tt
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempCCDD')) if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempCCDD'))
drop table #TempCCDD drop table #TempCCDD
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempFFF'))
drop table #TempFFF
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempXXXXX'))
drop table #TempXXXXX
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempZTPP'))
drop table #TempZTPP
"; ";
@ -1213,7 +1246,7 @@ ORDER BY 销售车号,物料编码,报工人
select isnull(realsaleout,0) from ICSZXBoardSaleout select isnull(realsaleout,0) from ICSZXBoardSaleout
where id = '1') b on 1=1 where id = '1') b on 1=1
left join ( select isnull(realsaleout,0) from ICSZXBoardSaleout left join ( select isnull(realsaleout,0) from ICSZXBoardSaleout
where id = '2') on 1=1 ";
where id = '2') f on 1=1 ";
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "MESconnstr", null); DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "MESconnstr", null);
return dt; return dt;
} }
@ -1225,48 +1258,78 @@ ORDER BY 销售车号,物料编码,报工人
string where1 = ""; string where1 = "";
string SqlText = ""; 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
from
(
select tso.socode ,count(*) as monum from
icsso tso
left join icsmo tmo on tso.socode = tmo.molotcode
group by tso.socode
) tmo
left join (
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 ICSLOTSIMULATION wip on tmo.mocode = wip.mocode
where wip.iscom='1'
group by tso.socode
) wip on tmo.socode = wip.socode
left join
(
select tso.socode ,count(*) as num 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!=''
group by tso.socode
) wipb on tmo.socode = wipb.socode
SqlText = @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempSSCC'))
drop table #TempSSCC
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempNum'))
drop table #tempNum
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOCCOM'))
drop table #TempMOCCOM
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#Tempcccc'))
drop table #Tempcccc
select row_number() over (order by a.,a.)as , a.* from (
select distinct tso.socode ,convert(varchar(10),tso.plandate,120) 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,0)),'%') ,
(case when tnum.wipnum/tnum.monum =1 then '' when tnum.wipbnum >0 then '' else '' end )
select distinct tso.socode ,convert(varchar(10),tso.plandate,120) as ,
isnull(convert(char(4),cus.fname),'') --, -- ISNULL(inv.invname,'') as
into #TempSSCC
from from
icsso tso
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.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 ";
icsso tso with(nolock)
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) )
select ,
into #Tempcccc from (
select ss. ,row_number() over (partition by ss.
order by case when inv.invname like '%' then 0 else 1 end ,inv.invname desc,inv.id) rn , inv.invname
from #TempSSCC ss
left join ICSINVENTORY inv on inv.invstd like '%'+ss.+'%'
) hh
where rn=1
select count(id) wipnum,molotcode
into #TempMOCCOM
FROM (SELECT id,molotcode
from (
select tmo.id, molotcode,tmo.moplanqty, wip.LOTQTY
from icsmo tmo with(nolock)
INNER join ICSLOTSIMULATION wip with(nolock) ON tmo.mocode = wip.mocode and wip.iscom='1'
and tmo.moseq=wip.moseq
where tmo.molotcode in (select distinct from #TempSSCC)
) jj
group by id,molotcode
having(max(moplanqty)<=sum(LOTQTY))
) HH
GROUP BY molotcode
select tso. ,isnull(( select count(*)
from icsmo tmo with(nolock) where 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
from ( select distinct from #TempSSCC) tso
LEFT JOIN #TempMOCCOM CCOM ON CCOM.molotcode=TSO.
select row_number() over (order by a.,a.)as , a.* ,cc.
from (
select tso., , ,
-- ,
CASE WHEN ISNULL(tnum.monum,0) =0 THEN '0%' ELSE
concat(cast(cast(tnum.wipnum * 1.0 / tnum.monum as decimal(18,3))* 100 as decimal(18,0)),'%') END ,
CASE WHEN ISNULL(tnum.monum,0) =0 THEN '' ELSE (case when tnum.wipnum/tnum.monum =1 then '' when tnum.wipbnum >0 then '' else '' end ) END
from #TempSSCC tso
left join #tempNum tnum on tnum. = tso.
) a
left join #Tempcccc cc on a.=cc.
";
DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "MESconnstr", null); DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "MESconnstr", null);

Loading…
Cancel
Save