@ -57,7 +57,7 @@ namespace PaintingScreen.Handler
SELECT COUNT ( DISTINCT barcode ) num , productInfo
INTO # a
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE InspectTimes = '1' AND " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' [ 合 格 ] ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
WHERE InspectTimes = '1' AND " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' 合 格 ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo
ORDER BY productInfo DESC
@ -65,7 +65,7 @@ namespace PaintingScreen.Handler
SELECT COUNT ( DISTINCT barcode ) num , productInfo
INTO # b
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' [ 合 格 ] ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' 合 格 ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo
ORDER BY productInfo DESC
@ -73,7 +73,7 @@ namespace PaintingScreen.Handler
SELECT COUNT ( DISTINCT barcode ) num , productInfo
INTO # c
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult in ( ' [ 合 格 ] ',' [ 抛 光 ] ',' 报 废 ' ) AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult in ( ' 合 格 ',' 抛 光 ',' 报 废 ' ) AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo
ORDER BY productInfo DESC
@ -111,55 +111,14 @@ namespace PaintingScreen.Handler
string res = "" ;
try
{
#region 2019-08-06 注销:客户要求改变总合格率算法,使用总数-报废数,而不是实时合格数计算
// string sql = @"
// -- 一次合格数
// SELECT COUNT(DISTINCT barcode) num, productInfo
// INTO #a
// FROM [BBMPT].[dbo].[tb_InspectResult]
// WHERE InspectTimes = '1' AND " + GetQueryTime() + @" AND productInfo != '' AND inspectResult = '[合格]' AND SUBSTRING(productInfo,1,1) != ','
// GROUP BY productInfo
// ORDER BY productInfo DESC
//
// -- 总合格数
// SELECT COUNT(DISTINCT barcode) num, productInfo
// INTO #b
// FROM [BBMPT].[dbo].[tb_InspectResult]
// WHERE " + GetQueryTime() + @" AND productInfo != '' AND inspectResult = '[合格]' AND SUBSTRING(productInfo,1,1) != ','
// GROUP BY productInfo
// ORDER BY productInfo DESC
//
// --总下线数
// SELECT COUNT(DISTINCT barcode) num, productInfo
// INTO #c
// FROM [BBMPT].[dbo].[tb_InspectResult]
// WHERE " + GetQueryTime() + @" AND productInfo != '' AND inspectResult in ('[合格]','[抛光]','报废') AND SUBSTRING(productInfo,1,1) != ','
// GROUP BY productInfo
// ORDER BY productInfo DESC
//
// --合并临时表
// SELECT SUM(ISNULL(c.num,0)) sumNum, SUM(ISNULL(a.num,0)) oncePassNum
// ,CONVERT(VARCHAR(20),ROUND(100*(SUM(ISNULL(a.num,0))/CONVERT(float,SUM(ISNULL(c.num,0)))),2))+'%' oncePassRate
// ,SUM(ISNULL(b.num,0)) sumPassNum
// ,CONVERT(VARCHAR(20),ROUND(100*(SUM(ISNULL(b.num,0))/CONVERT(float,SUM(ISNULL(c.num,0)))),2))+'%' sumPassRate
// FROM #c c
// LEFT JOIN #a a
// ON c.productInfo = a.productInfo
// LEFT JOIN #b b
// ON c.productInfo = b.productInfo
//
// DROP TABLE #a;
// DROP TABLE #b;
// DROP TABLE #c;
// ";
#endregion
string sql = @ "
- - 一 次 合 格 数
SELECT COUNT ( DISTINCT barcode ) num , productInfo
INTO # a
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE InspectTimes = '1' AND " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' [ 合 格 ] ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
WHERE InspectTimes = '1' AND " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' 合 格 ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo
ORDER BY productInfo DESC
@ -167,7 +126,7 @@ namespace PaintingScreen.Handler
SELECT COUNT ( DISTINCT barcode ) num , productInfo
INTO # b
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' [ 合 格 ] ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' 合 格 ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo
ORDER BY productInfo DESC
@ -177,14 +136,14 @@ namespace PaintingScreen.Handler
SELECT num , productInfo FROM
( SELECT COUNT ( DISTINCT barcode ) num , productInfo
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' [ 报 废 ] '
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' 报 废 '
AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo ) a
UNION
SELECT * FROM ( SELECT COUNT ( DISTINCT barcode ) num , productInfo
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE " + GetQueryTime() + @" AND productInfo ! = ' '
AND stationNo = ' S10 ' AND inspectResult < > ' [ 合 格 ] '
AND stationNo = ' S10 ' AND inspectResult < > ' 合 格 '
AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo ) b
) aa
@ -194,7 +153,7 @@ namespace PaintingScreen.Handler
SELECT COUNT ( DISTINCT barcode ) num , productInfo
INTO # c
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult in ( ' [ 合 格 ] ',' [ 抛 光 ] ',' 报 废 ' ) AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult in ( ' 合 格 ',' 抛 光 ',' 报 废 ' ) AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo
ORDER BY productInfo DESC
@ -308,7 +267,7 @@ namespace PaintingScreen.Handler
SELECT COUNT ( DISTINCT barcode ) num , productInfo
INTO # a
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE InspectTimes = '1' AND " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' [ 合 格 ] ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
WHERE InspectTimes = '1' AND " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' 合 格 ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo
ORDER BY productInfo DESC ;
@ -316,7 +275,7 @@ namespace PaintingScreen.Handler
SELECT COUNT ( DISTINCT barcode ) num , productInfo
INTO # b
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' [ 合 格 ] ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' 合 格 ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo
ORDER BY productInfo DESC ;
@ -324,7 +283,7 @@ namespace PaintingScreen.Handler
SELECT COUNT ( DISTINCT barcode ) num , productInfo
INTO # c
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult in ( ' [ 合 格 ] ',' [ 抛 光 ] ',' [ 报 废 ] ' ) AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult in ( ' 合 格 ',' 抛 光 ',' 报 废 ' ) AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo
ORDER BY productInfo DESC ;
@ -466,7 +425,7 @@ namespace PaintingScreen.Handler
SELECT COUNT ( DISTINCT barcode ) num , productInfo
INTO # a
FROM [ tb_InspectResult ]
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' [ 合 格 ] ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' 合 格 ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo
ORDER BY productInfo DESC ;
@ -474,7 +433,7 @@ namespace PaintingScreen.Handler
SELECT COUNT ( DISTINCT barcode ) num , productInfo
INTO # b
FROM [ tb_InspectResult ]
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult in ( ' [ 合 格 ] ',' [ 抛 光 ] ',' [ 报 废 ] ' ) AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult in ( ' 合 格 ',' 抛 光 ',' 报 废 ' ) AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo
ORDER BY productInfo DESC ;
@ -572,56 +531,14 @@ namespace PaintingScreen.Handler
string res = "" ;
try
{
#region 2019-08-06 注销:客户要求改变总合格率算法,使用总数-报废数,而不是实时合格数计算
// string sql = @"
// -- 一次合格数
// SELECT COUNT(DISTINCT barcode) num, productInfo
// INTO #a
// FROM [BBMPT].[dbo].[tb_InspectResult]
// WHERE InspectTimes = '1' AND " + GetQueryTime() + @" AND productInfo != '' AND inspectResult = '[合格]' AND SUBSTRING(productInfo,1,1) != ','
// GROUP BY productInfo
// ORDER BY productInfo DESC
//
// -- 总合格数
// SELECT COUNT(DISTINCT barcode) num, productInfo
// INTO #b
// FROM [BBMPT].[dbo].[tb_InspectResult]
// WHERE " + GetQueryTime() + @" AND productInfo != '' AND inspectResult = '[合格]' AND SUBSTRING(productInfo,1,1) != ','
// GROUP BY productInfo
// ORDER BY productInfo DESC
//
// --总下线数
// SELECT COUNT(DISTINCT barcode) num, productInfo
// INTO #c
// FROM [BBMPT].[dbo].[tb_InspectResult]
// WHERE " + GetQueryTime() + @" AND productInfo != '' AND inspectResult in ('[合格]','[抛光]','报废') AND SUBSTRING(productInfo,1,1) != ','
// GROUP BY productInfo
// ORDER BY productInfo DESC
//
// --合并临时表
// SELECT SUM(ISNULL(c.num,0)) sumNum, SUM(ISNULL(a.num,0)) oncePassNum
// ,CONVERT(VARCHAR(20),ROUND(100*(SUM(ISNULL(a.num,0))/CONVERT(float,SUM(ISNULL(c.num,0)))),2))+'%' oncePassRate
// ,SUM(ISNULL(b.num,0)) sumPassNum
// ,CONVERT(VARCHAR(20),ROUND(100*(SUM(ISNULL(b.num,0))/CONVERT(float,SUM(ISNULL(c.num,0)))),2))+'%' sumPassRate
// FROM #c c
// LEFT JOIN #a a
// ON c.productInfo = a.productInfo
// LEFT JOIN #b b
// ON c.productInfo = b.productInfo
//
// DROP TABLE #a;
// DROP TABLE #b;
// DROP TABLE #c;
// ";
#endregion
string sql = @ "
- - 一 次 合 格 数
SELECT COUNT ( DISTINCT barcode ) num , productInfo
INTO # a
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE InspectTimes = '1' AND " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' [ 合 格 ] ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
WHERE InspectTimes = '1' AND " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' 合 格 ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo
ORDER BY productInfo DESC
@ -629,7 +546,7 @@ namespace PaintingScreen.Handler
SELECT COUNT ( DISTINCT barcode ) num , productInfo
INTO # b
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' [ 合 格 ] ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' 合 格 ' AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo
ORDER BY productInfo DESC
@ -639,14 +556,14 @@ namespace PaintingScreen.Handler
SELECT num , productInfo FROM
( SELECT COUNT ( DISTINCT barcode ) num , productInfo
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' [ 报 废 ] '
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult = ' 报 废 '
AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo ) a
UNION
SELECT * FROM ( SELECT COUNT ( DISTINCT barcode ) num , productInfo
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE " + GetQueryTime() + @" AND productInfo ! = ' '
AND stationNo = ' S10 ' AND inspectResult < > ' [ 合 格 ] '
AND stationNo = ' S10 ' AND inspectResult < > ' 合 格 '
AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo ) b
) aa
@ -656,7 +573,7 @@ namespace PaintingScreen.Handler
SELECT COUNT ( DISTINCT barcode ) num , productInfo
INTO # c
FROM [ BBMPT ] . [ dbo ] . [ tb_InspectResult ]
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult in ( ' [ 合 格 ] ',' [ 抛 光 ] ',' 报 废 ' ) AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
WHERE " + GetQueryTime() + @" AND productInfo ! = ' ' AND inspectResult in ( ' 合 格 ',' 抛 光 ',' 报 废 ' ) AND SUBSTRING ( productInfo , 1 , 1 ) ! = ','
GROUP BY productInfo
ORDER BY productInfo DESC