From ab780f99454e132e717f8fde35eb2b5a1d632b9b Mon Sep 17 00:00:00 2001 From: xuli Date: Fri, 12 Apr 2024 15:45:17 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=9C=8B=E6=9D=BF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NFine.Application/SRM/WatchPanelApp.cs | 239 +++++++++++++++---------- 1 file changed, 143 insertions(+), 96 deletions(-) diff --git a/NFine.Application/SRM/WatchPanelApp.cs b/NFine.Application/SRM/WatchPanelApp.cs index a180946..81565be 100644 --- a/NFine.Application/SRM/WatchPanelApp.cs +++ b/NFine.Application/SRM/WatchPanelApp.cs @@ -1129,66 +1129,99 @@ select * from ( string 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')) 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 工序结束状态, -SUM(DATEDIFF(MINUTE, B.BeginDateTime, B.EndDateTime)) as '报工时长', -isnull(SUM(DATEDIFF(MINUTE, B.BeginDateTime, B.EndDateTime))-ISNULL(xx.[暂停时长],0),'') AS 有效时间, -xx.[暂停时长], + DATEDIFF(MINUTE, B.BeginDateTime, B.EndDateTime) as '报工时长', 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 报工人, +isnull(CONVERT(VARCHAR,B.EndDateTime,120),'') 完工时间 ,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 , pp.BeginTime 开始时间, -pp.EndTime 结束时间, -SUM(DATEDIFF(MINUTE, PP.BeginTime, PP.EndTime)) as '暂停时长' , -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 销售车号,物料编码,报工人 +pp.EndTime 结束时间, +isnull(vv.EnumText,'') 暂停原因 , +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 销售车号, 物料编码, 物料名称 , 工单号, 工序代码, 工序名称, 报工人, 工序结束状态, + DATEDIFF(MINUTE, DD.BeginDateTime, DD.EndDateTime) as '报工时长', + DATEDIFF(MINUTE, dd.BeginDateTime, dd.EndDateTime) -ISNULL(xx.[暂停时长],0) AS 有效时间, + xx.[暂停时长] 暂停时长, + DD.开工时间, + DD.完工时间, + xx.暂停开始时间 暂停开始时间, + 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')) 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 where id = '1') b on 1=1 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); return dt; } @@ -1225,48 +1258,62 @@ 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 - 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 - - 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 ) 生产状态 - 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 "; + 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 + + select distinct tso.socode 销售车辆号,convert(varchar(10),tso.plandate,120) as 客户交货期, + isnull(convert(char(4),cus.fname),'') 用户单位, inv.invname as 产品名称 + into #TempSSCC + from + 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.invcode=tmo.molotcode + where tso.status = 'C' and tmo.id in(select moid from ICSMO2ROUTE with(nolock) ) + + + 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.* + from ( + + select tso.销售车辆号, 客户交货期, 用户单位, + 产品名称, + 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 ) 生产状态 + from #TempSSCC tso + left join #tempNum tnum on tnum.销售车辆号 = tso.销售车辆号 + + ) a + "; DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "MESconnstr", null); From aebd24f64ac9e76a1d8706239bd3f7631c7b1fc3 Mon Sep 17 00:00:00 2001 From: xuli Date: Fri, 12 Apr 2024 15:54:47 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=9C=8B=E6=9D=BF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NFine.Application/SRM/WatchPanelApp.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/NFine.Application/SRM/WatchPanelApp.cs b/NFine.Application/SRM/WatchPanelApp.cs index 81565be..5de9e9d 100644 --- a/NFine.Application/SRM/WatchPanelApp.cs +++ b/NFine.Application/SRM/WatchPanelApp.cs @@ -1147,7 +1147,7 @@ select * from ( 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 工序结束状态, - DATEDIFF(MINUTE, B.BeginDateTime, B.EndDateTime) as '报工时长', + ISNULL(DATEDIFF(MINUTE, B.BeginDateTime, B.EndDateTime) ,0) as '报工时长', isnull(CONVERT(VARCHAR,B.BeginDateTime,120),'') 开工时间, isnull(CONVERT(VARCHAR,B.EndDateTime,120),'') 完工时间 ,A.ID,B.ID DetailID,B.BeginDateTime,B.EndDateTime @@ -1192,13 +1192,13 @@ FROM #TempXXXXX HH GROUP BY DetailID SELECT 销售车号, 物料编码, 物料名称 , 工单号, 工序代码, 工序名称, 报工人, 工序结束状态, - DATEDIFF(MINUTE, DD.BeginDateTime, DD.EndDateTime) as '报工时长', - DATEDIFF(MINUTE, dd.BeginDateTime, dd.EndDateTime) -ISNULL(xx.[暂停时长],0) AS 有效时间, - xx.[暂停时长] 暂停时长, + 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.完工时间, - xx.暂停开始时间 暂停开始时间, - xx.暂停结束时间 暂停结束时间, + ISNULL(xx.暂停开始时间 ,'') 暂停开始时间, + ISNULL(xx.暂停结束时间,'') 暂停结束时间, isnull(xx.[暂停原因],'') 暂停原因 , case when 暂停开始时间 is not null and 暂停结束时间 is null then '暂停中' else '' end 暂停状态 FROM #TempCCDD_Tt DD @@ -1266,7 +1266,7 @@ ORDER BY 销售车号, 物料编码 ,报工人 asc drop table #TempMOCCOM select distinct tso.socode 销售车辆号,convert(varchar(10),tso.plandate,120) as 客户交货期, - isnull(convert(char(4),cus.fname),'') 用户单位, inv.invname as 产品名称 + isnull(convert(char(4),cus.fname),'') 用户单位, ISNULL(inv.invname,'') as 产品名称 into #TempSSCC from icsso tso with(nolock) @@ -1307,8 +1307,9 @@ ORDER BY 销售车号, 物料编码 ,报工人 asc select tso.销售车辆号, 客户交货期, 用户单位, 产品名称, - 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 ) 生产状态 + 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.销售车辆号 From a933b5c0cbc0b2d3857fe5af1c13caa597416055 Mon Sep 17 00:00:00 2001 From: xuli Date: Tue, 16 Apr 2024 13:48:19 +0800 Subject: [PATCH 3/4] bug --- NFine.Application/SRM/WatchPanelApp.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NFine.Application/SRM/WatchPanelApp.cs b/NFine.Application/SRM/WatchPanelApp.cs index 5de9e9d..0ea7e8a 100644 --- a/NFine.Application/SRM/WatchPanelApp.cs +++ b/NFine.Application/SRM/WatchPanelApp.cs @@ -1272,7 +1272,7 @@ ORDER BY 销售车号, 物料编码 ,报工人 asc 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.invcode=tmo.molotcode + left join ICSINVENTORY inv with(nolock) on inv.invcode=tmo.itemcode where tso.status = 'C' and tmo.id in(select moid from ICSMO2ROUTE with(nolock) ) From cb1bc2f4bce3c432f7b6c37f02f78fb49c5a614a Mon Sep 17 00:00:00 2001 From: xuli Date: Tue, 16 Apr 2024 16:51:45 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NFine.Application/SRM/WatchPanelApp.cs | 33 +++++++++++++++++++------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/NFine.Application/SRM/WatchPanelApp.cs b/NFine.Application/SRM/WatchPanelApp.cs index 0ea7e8a..2906320 100644 --- a/NFine.Application/SRM/WatchPanelApp.cs +++ b/NFine.Application/SRM/WatchPanelApp.cs @@ -1148,8 +1148,8 @@ SELECT C.molotcode as 销售车号,C.ITEMCODE 物料编码,dd.INVNAME 物料 a.OPCODE 工序代码,ppp.opname 工序名称,us.UserName 报工人,B.UserCodeBegin, CASE WHEN A.ACTIONRESULT='COLLECT_BEGIN' then '----生产中----' WHEN A.ACTIONRESULT='COLLECT_END' then '----已结束----' end as 工序结束状态, ISNULL(DATEDIFF(MINUTE, B.BeginDateTime, B.EndDateTime) ,0) as '报工时长', -isnull(CONVERT(VARCHAR,B.BeginDateTime,120),'') 开工时间, -isnull(CONVERT(VARCHAR,B.EndDateTime,120),'') 完工时间 ,A.ID,B.ID DetailID,B.BeginDateTime,B.EndDateTime +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) @@ -1164,8 +1164,8 @@ ORDER BY C.molotcode, C.ITEMCODE , us.UserName asc SELECT A.id, PP.Usercode , -pp.BeginTime 开始时间, -pp.EndTime 结束时间, +isnull(CONVERT(varchar(19), pp.BeginTime, 21),'') 开始时间, +isnull( CONVERT(varchar(19), pp.EndTime, 21) ,'') 结束时间, isnull(vv.EnumText,'') 暂停原因 , DATEDIFF(MINUTE, PP.BeginTime, PP.EndTime) 暂停时长 into #TempFFF @@ -1264,17 +1264,31 @@ ORDER BY 销售车号, 物料编码 ,报工人 asc 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 distinct tso.socode 销售车辆号,convert(varchar(10),tso.plandate,120) as 客户交货期, - isnull(convert(char(4),cus.fname),'') 用户单位, ISNULL(inv.invname,'') as 产品名称 + isnull(convert(char(4),cus.fname),'') 用户单位--, -- ISNULL(inv.invname,'') as 产品名称 into #TempSSCC from 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.invcode=tmo.itemcode + -- 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 @@ -1302,11 +1316,11 @@ ORDER BY 销售车号, 物料编码 ,报工人 asc - select row_number() over (order by a.客户交货期,a.销售车辆号)as 序号, a.* + 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 生产状态 @@ -1314,6 +1328,7 @@ ORDER BY 销售车号, 物料编码 ,报工人 asc left join #tempNum tnum on tnum.销售车辆号 = tso.销售车辆号 ) a +left join #Tempcccc cc on a.销售车辆号=cc.销售车辆号 "; DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "MESconnstr", null);