SELECT
SZ.ShangZhouID as 上机ID,
Case when PC.Type=0 and SZ.WarpPiecing=1 then '接经' when PC.Type=0 and SZ.WarpPiecing=0 then '上轴' when PC.Type=1 then '换品种' when PC.Type=2 then '换纬纱' when PC.Type=3 then '处理布开始' when PC.Type=4 then '处理布结束' end 类别,
MC.MachineName as 机台号,
PD.ProductName as 品名,
PD.JingShaPiHao as 经纱批号,
SZ.starttime as 上机日期,
PD.WeiShaPiHao as 纬纱批号,
W.WProductName as 原料名称,
PD.FuKuan as 上机幅宽,
FK.JSFK as 机上幅宽,
Case when FK.JSFK<>0 then '+ '+ CAST(ABS(pd.FuKuan-FK.JSFK) AS VARCHAR(10)) when FK.JSFK=0 then '' else '' end as 误差
FROM ProductChange PC
INNER JOIN Machine MC ON PC.MachineID = MC.MachineID
INNER JOIN Z_SY_MC MC1 ON MC1.MachineName=MC.MachineName
INNER JOIN Product PD ON PD.ProductID = PC.ProductID
INNER JOIN tDept DP on DP.DeptID=MC.DeptID
INNER JOIN ShangZhou SZ ON SZ.ShangZhouID = PC.ShangZhouID
Left JOIN tcGroupName GN1 ON GN1.GroupID=MC.GroupID1
LEFT OUTER JOIN (select * from [NT_Wv8SS_2015].[dbo].CrftwrkMTB_Inf) W ON PD.ProductNo=W.Batch
LEFT OUTER JOIN Z_SY_FK FK on sz.ShangZhouID=Fk.ShangZhouID
where PC.ChangeTime>=#开始 and PC.ChangeTime<#结束
and case when PC.Type=0 and SZ.WarpPiecing=1 then '接经' when PC.Type=0 and SZ.WarpPiecing=0 then '上轴' when PC.Type=1 then '换品种' when PC.Type=2 then '换纬纱' when PC.Type=3 then '处理布开始' when PC.Type=4 then '处理布结束' end='上轴'
and SZ.WarpPiecing=0
and (W.WProductName like '%T8%' or W.WProductName like '%T400%' or PD.ProductName like '%75X150全消光斜纹%' or PD.ProductName like '%150D小斜纹%' or PD.ProductName like '%450X450全弹%' or PD.ProductName like '%150全弹窄%' or PD.ProductName like '%磨毛斜桃%')
group by
SZ.ShangZhouID,
case when PC.Type=0 and SZ.WarpPiecing=1 then '接经' when PC.Type=0 and SZ.WarpPiecing=0 then '上轴' when PC.Type=1 then '换品种' when PC.Type=2 then '换纬纱' when PC.Type=3 then '处理布开始' when PC.Type=4 then '处理布结束' end,
MC.MachineName,
PD.ProductName,
PD.JingShaPiHao,
SZ.starttime,
PD.WeiShaPiHao,
W.WProductName,
pd.FuKuan,
FK.JSFK,
MC1.WeaverSet2
Order by
#排序