From 048ef193e8c772e1cb166d1f1d7b5c75a537aace Mon Sep 17 00:00:00 2001 From: "ruoxing.wang" <88384874@qq.com> Date: Wed, 20 Nov 2024 15:40:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=96=B7=E6=B6=82=E8=B0=83=E6=95=B4=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MESClassLibrary/DAL/Check/InspectResultDAL.cs | 2 +- MESWebSite/Manage/AnalysisApi.aspx.cs | 10 +- PaintingPC/FrmQuality.cs | 122 ++++--- PaintingPC/Function.cs | 28 +- PaintingScreen/Handler/Function.cs | 123 ++----- WebService/Function.cs | 324 +++++++++++++----- WebService/Model/WMS03Model.cs | 1 + WebService/WMSWebService.asmx.cs | 4 +- 8 files changed, 374 insertions(+), 240 deletions(-) diff --git a/MESClassLibrary/DAL/Check/InspectResultDAL.cs b/MESClassLibrary/DAL/Check/InspectResultDAL.cs index 7842b3d..e5be243 100644 --- a/MESClassLibrary/DAL/Check/InspectResultDAL.cs +++ b/MESClassLibrary/DAL/Check/InspectResultDAL.cs @@ -191,7 +191,7 @@ namespace MESClassLibrary.DAL.Check { string sql = "select * FROM[dbo].[tb_InspectResult] "; - sql += " where barcode is not null and productInfo!='' and productInfo is not null and createTime>='" + StartTime + "' and createTime<='" + EndTime + "' and inspectResult in ('[合格]','[抛光]','[报废]') and substring(productInfo,1,1) != ',' "; + sql += " where barcode is not null and productInfo!='' and productInfo is not null and createTime>='" + StartTime + "' and createTime<='" + EndTime + "' and inspectResult in ('合格','抛光','报废') and substring(productInfo,1,1) != ',' "; if (!string.IsNullOrEmpty(side)) { if ("A侧".Equals(side)) diff --git a/MESWebSite/Manage/AnalysisApi.aspx.cs b/MESWebSite/Manage/AnalysisApi.aspx.cs index b5bef5d..0cc9abe 100644 --- a/MESWebSite/Manage/AnalysisApi.aspx.cs +++ b/MESWebSite/Manage/AnalysisApi.aspx.cs @@ -115,7 +115,7 @@ namespace MESWebSite.Manage if (t != null && t.Count > 0) { - double r = (double)t.Where(p => p.inspectResult.Equals("[合格]")).Count() / (double)t.Count; + double r = (double)t.Where(p => p.inspectResult.Equals("合格")).Count() / (double)t.Count; data.Add(Math.Round(r * 100, 2).ToString()); } else @@ -136,7 +136,7 @@ namespace MESWebSite.Manage if (t != null && t.Count > 0) { - double r = (double)t.Where(p => p.inspectResult.Equals("[合格]")).Count() / (double)t.Count; + double r = (double)t.Where(p => p.inspectResult.Equals("合格")).Count() / (double)t.Count; data.Add(Math.Round(r * 100, 2).ToString()); } else @@ -158,7 +158,7 @@ namespace MESWebSite.Manage if (t != null && t.Count > 0) { - double r = (double)t.Where(p => p.inspectResult.Equals("[合格]")).Count() / (double)t.Count; + double r = (double)t.Where(p => p.inspectResult.Equals("合格")).Count() / (double)t.Count; data.Add(Math.Round(r * 100, 2).ToString()); } else @@ -261,7 +261,7 @@ namespace MESWebSite.Manage colorList.Add(pinfo, 0); } - if ("[合格]".Equals(item.inspectResult)) + if ("合格".Equals(item.inspectResult)) { colorList[pinfo] = colorList[pinfo] + 1; } @@ -308,7 +308,7 @@ namespace MESWebSite.Manage if (info.Count() > 0) { cnum = info.Count(); - num = info.Where(p => p.inspectResult.Equals("[合格]")).Count(); + num = info.Where(p => p.inspectResult.Equals("合格")).Count(); r = num / cnum; listModel.Add(Math.Round(r * 100, 2).ToString() + "%"); } diff --git a/PaintingPC/FrmQuality.cs b/PaintingPC/FrmQuality.cs index a0633e5..c94f5b8 100644 --- a/PaintingPC/FrmQuality.cs +++ b/PaintingPC/FrmQuality.cs @@ -290,14 +290,14 @@ namespace PaintingPC ClearControlColor(SetControlGroup()); btnAbt.BackColor = Color.Red; - string lastRst = GetLastInspectRst(txtBarCode.Text.Trim()); - if (lastRst.Contains("合格")) - { - MessageBox.Show("条码已判定为合格,无需重复判定"); - Clear(); - return; - } - SaveRst("合格", colorName, partName); + //string lastRst = GetLastInspectRst(txtBarCode.Text.Trim()); + //if (lastRst.Contains("合格")) + //{ + // MessageBox.Show("条码已判定为合格,无需重复判定"); + // Clear(); + // return; + //} + SaveRst("合格", colorName, partName,1); } void Clear() @@ -331,14 +331,16 @@ namespace PaintingPC string partName = string.Empty; if (CheckColor(ref colorName, ref partName) == false) return; #endregion - string lastRst = GetLastInspectRst(txtBarCode.Text.Trim()); - if (lastRst.Contains("其它")) + + int cs = Function.OtherTimes(txtBarCode.Text.Trim()); + if (cs > 0) { - MessageBox.Show("条码已判定为其它,无需重复判定"); + MessageBox.Show("条码"+ txtBarCode.Text.Trim() + "已存在判定为其它的记录,只允许判定1次."); + ShowHint("条码" + txtBarCode.Text.Trim() + "已存在判定为其它的记录,只允许判定1次."); Clear(); return; - } - SaveRst("其它", colorName, partName); + } + SaveRst("其它", colorName, partName,8); } /// @@ -358,10 +360,11 @@ namespace PaintingPC if (MessageBox.Show($"确认对[{txtBarCode.Text}]进行返喷操作?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; ShowHint(""); string barcode = Function.UniteBarCodeToOne(txtBarCode.Text.Trim()); - int cs = Function.YiDaMoCiShu(barcode); - if (cs > 1) - cs = 1; - int keHuiPen = Function.keHuiPen(barcode); + int cs = Function.YiDaMoCiShu(barcode); //记录中已返喷次数 + + int keHuiPen = Function.keHuiPen(barcode); //基础数据中,可返喷次数 + if (keHuiPen > 1) + keHuiPen = 1; if (keHuiPen > 0 && cs < keHuiPen) { @@ -381,24 +384,24 @@ namespace PaintingPC ClearControlColor(SetControlGroup()); btnRepair.BackColor = Color.Yellow; - string lastRst = GetLastInspectRst(txtBarCode.Text.Trim()); - if (lastRst.Contains("打磨")) - { - ShowHint("条码已判定为返喷,无需重复判定"); - MessageBox.Show("条码已判定为返喷,无需重复判定"); - Clear(); - return; - } + //string lastRst = GetLastInspectRst(txtBarCode.Text.Trim()); + //if (lastRst.Contains("打磨")) + //{ + // ShowHint("条码已判定为返喷,无需重复判定"); + // MessageBox.Show("条码已判定为返喷,无需重复判定"); + // Clear(); + // return; + //} - string s = _isWmsQuality == false ? "打磨" : "WMS打磨"; + string s = _isWmsQuality == false ? "打磨" : "打磨WMS"; - SaveRst(s, colorName, partName); + SaveRst(s, colorName, partName,9); } else { - ShowHint("根据该零件可回喷次数设置,不能判定为打磨或已超过打磨次数!"); - MessageBox.Show("根据该零件可回喷次数设置,不能判定为打磨或已超过打磨次数!"); + ShowHint("根据该零件可回喷次数设置,不能判定为返喷或已超过返喷次数!"); + MessageBox.Show("根据该零件可回喷次数设置,不能判定为返喷或已超过返喷次数!"); Clear(); return; } @@ -441,30 +444,37 @@ namespace PaintingPC if (CheckColor(ref colorName, ref partName) == false) return; #endregion - string lastRst = GetLastInspectRst(txtBarCode.Text.Trim()); - if (lastRst.Contains("合格")) - { - MessageBox.Show("条码已判定为合格,无法重新判定为报废"); - Clear(); - return; - } - if (lastRst.Contains("报废")) - { - MessageBox.Show("条码已判定为报废,无需重复报废"); - Clear(); - return; - } + //string lastRst = GetLastInspectRst(txtBarCode.Text.Trim()); + //if (lastRst.Contains("合格")) + //{ + // MessageBox.Show("条码已判定为合格,无法重新判定为报废"); + // Clear(); + // return; + //} + //if (lastRst.Contains("报废")) + //{ + // MessageBox.Show("条码已判定为报废,无需重复报废"); + // Clear(); + // return; + //} ClearControlColor(SetControlGroup()); btnAbt.BackColor = Color.Red; - SaveRst("报废", colorName, partName); + SaveRst("报废", colorName, partName,0); } }); } - void SaveRst(string state, string colorName, string partName) + /// + /// + /// + /// + /// + /// + /// 0-不合格;1-合格;9-返喷 8-其他 + void SaveRst(string state, string colorName, string partName,int isOK) { //保存 @@ -474,14 +484,14 @@ namespace PaintingPC { if (!string.IsNullOrEmpty(id)) { - bool rst = SendToWms(txtBarCode.Text.Trim(), 1); + bool rst = SendToWms(txtBarCode.Text.Trim(), isOK); if (rst == false) { DeleteRepectRst(id); } else { - ShowHint("操作成功",true); + ShowHint(txtBarCode.Text.Trim()+"操作成功",true); Clear(); } } @@ -641,7 +651,7 @@ namespace PaintingPC model1.position = labProPosition.Text; model1.stationNo = labStation.Text; model1.workClass = labWorkClass.Text; - model1.inspectResult = "[" + inspectResult + "]"; + model1.inspectResult =inspectResult; model1.damnPosition = position; model1.reason = reason; model1.remark3 = paintId; @@ -947,14 +957,28 @@ namespace PaintingPC if (dtInspect != null && dtInspect.Rows.Count > 0) { List list = dtInspect.AsEnumerable().Where(p => p.Field("inspectResult").Contains("打磨")).ToList(); + string state = string.Empty; if (list.Count > 0) { - lableFP.Text = "存在返喷状态"; + state = "返喷"; } List list2 = dtInspect.AsEnumerable().Where(p => p.Field("inspectResult").Contains("其它")).ToList(); if (list2.Count > 0) { - lableFP.Text = "存在其它状态"; + if(list2.Where(p=> p.Field("inspectResult")=="其它WMS").Count() > 0) + { + state = state + ",其它WMS"; + } + if (list2.Where(p => p.Field("inspectResult") == "其它").Count() > 0) + { + state = state + ",其它"; + } + + } + + if (!string.IsNullOrEmpty(state)) + { + lableFP.Text = "存在[" + state + "]状态"; } _carType = dtInspect.Rows[0]["CarType"].ToString().Trim(); diff --git a/PaintingPC/Function.cs b/PaintingPC/Function.cs index 32c2a87..1395aab 100644 --- a/PaintingPC/Function.cs +++ b/PaintingPC/Function.cs @@ -1177,7 +1177,7 @@ namespace PaintingPC select count(0) from tb_InspectResult where barcode = '" + barcode + @"' - and inspectResult like '%打磨%' + and inspectResult like '打磨%' "; object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null); @@ -1192,6 +1192,30 @@ namespace PaintingPC } return res; } + public static int OtherTimes(string barcode) + { + int res = 0; + try + { + string sql = @" + select count(0) + from tb_InspectResult + where barcode = '" + barcode + @"' + and inspectResult = '其它' + "; + + object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null); + if (aa != null) + { + res = Convert.ToInt32(aa.ToString()); + } + } + catch (Exception ex) + { + LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); + } + return res; + } public static int keHuiPen(string barcode) { @@ -1379,7 +1403,7 @@ namespace PaintingPC if (aa != null) { string result = aa.ToString(); - if (aa == "[合格]") + if (aa.ToString() == "合格") { res = true; } diff --git a/PaintingScreen/Handler/Function.cs b/PaintingScreen/Handler/Function.cs index 70e246b..97b5948 100644 --- a/PaintingScreen/Handler/Function.cs +++ b/PaintingScreen/Handler/Function.cs @@ -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 diff --git a/WebService/Function.cs b/WebService/Function.cs index 4cde5b0..0fad5c5 100644 --- a/WebService/Function.cs +++ b/WebService/Function.cs @@ -975,6 +975,7 @@ namespace Webservice wmsM.ReadTime = null; wmsM.Remark = ""; wmsM.Repaint = repaint.ToString(); + wmsM.ColorName = colorName; #region 产线及工厂ID LogHelper.WriteSysLogBase("【添加产线ID】barcode:" + barcode, MethodBase.GetCurrentMethod().Name); @@ -1023,9 +1024,7 @@ namespace Webservice string res = string.Empty; try { - WebService.WebReference.JsonService webService = new WebService.WebReference.JsonService(); - webService.Url = ConfigurationManager.AppSettings["WMSWebServiceURL"].ToString(); - webService.Timeout = 1200000; + WebService.WebReference.JsonService webService = GetWebService(); string jsonParam = " [{\"ServiceType\":\"AddMesData\",\"OperName\":\"ADMIN\"}]"; string strJson = "[25," + JSONTools.ScriptSerialize>(list) + "]"; @@ -1103,17 +1102,32 @@ namespace Webservice } } /// + /// WMS是否移库,true:未移库允许报废转合格 false:已经移库,无法操作报废转合格 + /// + /// + /// + static bool GetWmsCompleteState(string sjBarCode) + { + string jsonParam = " [{\"ServiceType\":\"GetMesData\",\"BarCode\":\""+sjBarCode+"\"}]"; + WebService.WebReference.JsonService webService = GetWebService(); + + string rst = webService.GetData(jsonParam); + + return true; + } + /// /// 是否允许发送给wms 是否质检等判断 /// /// - /// 0-不合格;1-合格 9-返喷 + /// 0-不合格;1-合格 9-返喷 8-其它 + /// pRepaint 只存在返喷 Repaint =1 只存在其它 Repaint =3 既存在返喷又存在其它 Repaint =4 /// static bool AllowSendToWms(string oneBarCode, int state, ref int pRepaint,ref string errorMssg ,ref string paintColor, ref string colorName, ref string productName,ref string carType) { if (string.IsNullOrEmpty(oneBarCode)) return false; - DataTable inspectTable = GetInspectResultTable($"{oneBarCode}",ref paintColor); + DataTable inspectTable = GetInspectResultTable($"{oneBarCode}"); if (inspectTable.Rows.Count == 0) { errorMssg = "没有进行质量判定,不能入库"; @@ -1122,103 +1136,250 @@ namespace Webservice colorName = inspectTable.Rows[0]["remark1"].ToString(); productName = inspectTable.Rows[0]["remark2"].ToString(); carType = inspectTable.Rows[0]["CarType"].ToString(); - paintColor = GetPaintLU(oneBarCode.Substring(0, 10), inspectTable.Rows[0]["remark1"].ToString()); + paintColor = inspectTable.Rows[0]["remark1"].ToString(); //返喷状态 int rePaint = GetRepainState(inspectTable); pRepaint = rePaint; - //不合格0 有报工记录不能重发 - if (state == 0) + + string lastState = string.Empty; + if (inspectTable.Rows.Count > 1) { - //if (inspectTable.Rows[0]["inspectResult"].ToString().Contains("报废") == false) //当前状态不是报废 - //{ - // errorMssg = $"条码[{oneBarCode}]质检记录是[{inspectTable.Rows[0]["inspectResult"].ToString()}]状态,无法报废报工."; - // return false; - //} - //else - if (rePaint == 0) + lastState = inspectTable.Rows[1]["inspectResult"].ToString(); + } + //返喷状态 + pRepaint = GetRapaintState(inspectTable); + + //合格 1 最近一条是报废记录,可以重发. 否则不可以. + if (state == 1) + { + + + //第一次合格 + if (string.IsNullOrEmpty(lastState)) + { + return true; + } + else { - if (IsStockInAll(oneBarCode)) + //上一次是合格 + if (lastState.Contains("合格")) + { + errorMssg = $"条码[{oneBarCode}]已判定[合格],不需要重复判定为[合格]."; + return false; + } + else if (lastState.Contains("报废")) { - errorMssg = $"条码[{oneBarCode}]已报工,不能重新报工."; + errorMssg = $"条码[{oneBarCode}]已判定[报废],不能重新判定[合格]."; return false; } + else + { + return true; + } + } + #region 原来的 + + //if (inspectTable.Rows.Count > 1) //有多条记录,判定前一条记录状态. 若只有一条记录,就是允许的 + //{ + // if (rePaint == 0) //没返喷的合格, + // { + // if (IsStockInAll(oneBarCode)) + // { + // string lastRst = inspectTable.Rows[1]["inspectResult"].ToString(); + // if (lastRst.Contains("报废")) //允许报废转合格 + // { + // errorMssg = $"条码[{oneBarCode}]已报废,不能重新报工."; + // return false; + // } + // errorMssg = $"条码[{oneBarCode}]已报工,不能重新报工."; + // return false; + // } + // } + // else //存在返喷的合格 + // { + // if (IsStockInAll(oneBarCode, true)) + // { + // string lastRst = inspectTable.Rows[1]["inspectResult"].ToString(); + // if (lastRst.Contains("报废")) //允许报废转合格 + // { + // return true; + // } + // if (lastRst.Contains("打磨")) //允许返喷二次判定为合格 + // { + // return true; + // } + // if (lastRst.Contains("其它")) //允许其他转合格 + // { + // return true; + // } + // errorMssg = $"条码[{oneBarCode}]存在返喷报工,不能重新报工." + inspectTable.Rows.Count + "[" + inspectTable.Rows[0]["ID"].ToString(); + // return false; + // } + // } + //} + #endregion + + + } - if (inspectTable.Rows.Count > 1) + //不合格报废0 有报工记录不能重发 + else if (state == 0) + { + + //第一次操作 + if (string.IsNullOrEmpty(lastState)) + { + return true; + } + //上次合格,这次转报废,需要wms给true + if (lastState.Contains("合格")) { - if (inspectTable.Rows[1]["inspectResult"].ToString().Contains("报废"))//只要上一次为报废,就不能进行任何一项其他判定 + bool wmsAllow = GetWmsCompleteState(oneBarCode); + if(wmsAllow == false) { - errorMssg = $"条码[{oneBarCode}]已报废,不能重新报工."; + errorMssg = $"条码[{oneBarCode}]在Wms已移库,不允许重新判定为[报废]."; return false; } - else if (inspectTable.Rows[0]["inspectResult"].ToString().Contains("其它") && inspectTable.Rows[1]["inspectResult"].ToString().Contains("其它")) + else { - errorMssg = $"条码[{oneBarCode}]已经存在其它状态,不能重新判定为其它状态."; - return false; + return true; } - else if (inspectTable.Rows[0]["inspectResult"].ToString().Contains("打磨") && inspectTable.Rows[1]["inspectResult"].ToString().Contains("打磨")) + } + if (lastState.Contains("报废")) + { + errorMssg = $"条码[{oneBarCode}]已报废,不需要重复判定为[报废]."; + return false; + } + + return true; + + //if (rePaint == 0) + //{ + // if (IsStockInAll(oneBarCode)) + // { + // errorMssg = $"条码[{oneBarCode}]已报工,不能重新报工."; + // return false; + // } + //} + + //if (inspectTable.Rows.Count > 1) + //{ + // if (inspectTable.Rows[1]["inspectResult"].ToString().Contains("报废"))//只要上一次为报废,就不能进行任何一项其他判定 + // { + // errorMssg = $"条码[{oneBarCode}]已报废,不能重新报工."; + // return false; + // } + // else if (inspectTable.Rows[0]["inspectResult"].ToString().Contains("其它") && inspectTable.Rows[1]["inspectResult"].ToString().Contains("其它")) + // { + // errorMssg = $"条码[{oneBarCode}]已经存在其它状态,不能重新判定为其它状态."; + // return false; + // } + // else if (inspectTable.Rows[0]["inspectResult"].ToString().Contains("打磨") && inspectTable.Rows[1]["inspectResult"].ToString().Contains("打磨")) + // { + // errorMssg = $"条码[{oneBarCode}]已经存在返喷状态,不能重新判定为返喷状态."; + // return false; + // } + //} + + + } + + //其它状态 + else if(state == 8) + { + //第一次合格 + if (string.IsNullOrEmpty(lastState)) + { + return true; + } + //上次合格,这次转其它,需要wms给true + if (lastState.Contains("合格")) + { + bool wmsAllow = GetWmsCompleteState(oneBarCode); + if (wmsAllow == false) { - errorMssg = $"条码[{oneBarCode}]已经存在返喷状态,不能重新判定为返喷状态."; + errorMssg = $"条码[{oneBarCode}]在Wms已移库,不允许重新判定为[其它]."; return false; } + else + { + return true; + } } - - + else if (lastState.Contains("报废")) + { + errorMssg = $"条码[{oneBarCode}]已判定[报废],不能重新判定[其它]."; + return false; + } + if (lastState.Contains("其它")) + { + errorMssg = $"条码[{oneBarCode}]已判定为[其它],不需要重复判定为[其它]."; + return false; + } + } - //合格 1 最近一条是报废记录,可以重发. 否则不可以. - else if (state == 1) - { - //if(inspectTable.Rows[0]["inspectResult"].ToString().Contains("合格") ==false) - //{ - // errorMssg = $"条码[{oneBarCode}]质检记录是[{inspectTable.Rows[0]["inspectResult"].ToString()}]状态,无法合格报工."; - // return false; - //} - if(inspectTable.Rows.Count > 1) //有多条记录,判定前一条记录状态. 若只有一条记录,就是允许的 + else if(state == 9) + { + //第一次合格 + if (string.IsNullOrEmpty(lastState)) + { + return true; + } + //上次合格,这次转报废,需要wms给true + if (lastState.Contains("合格")) { - if (rePaint == 0) //没返喷的合格, + bool wmsAllow = GetWmsCompleteState(oneBarCode); + if (wmsAllow == false) { - if (IsStockInAll(oneBarCode)) - { - string lastRst = inspectTable.Rows[1]["inspectResult"].ToString(); - if (lastRst.Contains("报废")) //允许报废转合格 - { - errorMssg = $"条码[{oneBarCode}]已报废,不能重新报工."; - return false; - } - errorMssg = $"条码[{oneBarCode}]已报工,不能重新报工."; - return false; - } + errorMssg = $"条码[{oneBarCode}]在Wms已移库,不允许重新判定为[返喷]."; + return false; } - else //存在返喷的合格 + else { - if (IsStockInAll(oneBarCode, true)) - { - string lastRst = inspectTable.Rows[1]["inspectResult"].ToString(); - if (lastRst.Contains("报废")) //允许报废转合格 - { - return true; - } - if (lastRst.Contains("打磨")) //允许返喷二次判定为合格 - { - return true; - } - if (lastRst.Contains("其它")) //允许其他转合格 - { - return true; - } - errorMssg = $"条码[{oneBarCode}]存在返喷报工,不能重新报工." + inspectTable.Rows.Count + "[" + inspectTable.Rows[0]["ID"].ToString(); - return false; - } + return true; } } - + else if (lastState.Contains("报废")) + { + errorMssg = $"条码[{oneBarCode}]已判定[报废],不能重新判定[返喷]."; + return false; + } + if (lastState.Contains("打磨") ) + { + errorMssg = $"条码[{oneBarCode}]已判定为[返喷],不需要重复判定为[返喷]."; + return false; + } } - - return true; } - + /// + /// 返喷状态 只存在返喷 Repaint =1 只存在其它 Repaint =3 既存在返喷又存在其它 Repaint =4 + /// + /// + /// + static int GetRapaintState(DataTable inspectTable) + { + int rePaintCount = inspectTable.AsEnumerable().Count(p => p.Field("inspectResult").Contains("返喷")); + int reOtherCount = inspectTable.AsEnumerable().Count(p => p.Field("inspectResult").Contains("其它")); + if(rePaintCount>0 && reOtherCount > 0) + { + return 4; + } + else if (rePaintCount > 0) + { + return 1; + } + else if (reOtherCount > 0) + { + return 3; + } + else + { + return 0; + } + } /// /// 计算返喷状态 线边返喷=1,库房判定返喷=2 其它状态=9 正常=0 /// @@ -1230,7 +1391,7 @@ namespace Webservice List paintRows = inspectTable.AsEnumerable().Where(p => p.Field("inspectResult").Contains("打磨")).ToList(); if (paintRows.Count > 0) { - List wmsPaintRows = paintRows.Where(p => p.Field("inspectResult").Contains("WMS打磨")).ToList(); + List wmsPaintRows = paintRows.Where(p => p.Field("inspectResult").Contains("打磨WMS")).ToList(); if (wmsPaintRows.Count > 0) { rePaint = 2; @@ -1312,7 +1473,7 @@ namespace Webservice } } - public static bool IsStockInAll(string barcode,bool isRepaint = false) + public static bool IsStockInAll(string barcode, bool isRepaint = false) { try { @@ -1375,7 +1536,7 @@ namespace Webservice if (dt != null && dt.Rows.Count > 0) { string inspectResult = dt.Rows[0]["inspectResult"].ToString().Trim(); - if ("[合格]" == inspectResult) //合格报工 + if ("合格" == inspectResult) //合格报工 { return true; } @@ -1440,7 +1601,7 @@ namespace Webservice /// /// /// - static DataTable GetInspectResultTable(string oneBarCode, ref string paintCode ) + static DataTable GetInspectResultTable(string oneBarCode ) { string sql = ""; if (oneBarCode.Contains(".")) @@ -2327,9 +2488,7 @@ namespace Webservice #region 调用WMS Web Service - WebService.WebReference.JsonService webService = new WebService.WebReference.JsonService(); - webService.Url = ConfigurationManager.AppSettings["WMSWebServiceURL"].ToString(); - webService.Timeout = 1200000; + WebService.WebReference.JsonService webService = GetWebService(); string jsonParam = " [{\"ServiceType\":\"AddMesData\",\"OperName\":\"ADMIN\"}]"; //string strJson = "[55," + JSONTools.ScriptSerialize>(list) + "]"; @@ -2576,5 +2735,14 @@ namespace Webservice } #endregion + + static WebService.WebReference.JsonService GetWebService() + { + WebService.WebReference.JsonService webService = new WebService.WebReference.JsonService(); + webService.Url = ConfigurationManager.AppSettings["WMSWebServiceURL"].ToString(); + webService.Timeout = 1200000; + return webService; + + } } } \ No newline at end of file diff --git a/WebService/Model/WMS03Model.cs b/WebService/Model/WMS03Model.cs index 736afa4..a139b7d 100644 --- a/WebService/Model/WMS03Model.cs +++ b/WebService/Model/WMS03Model.cs @@ -76,5 +76,6 @@ namespace WebService.Model /// 返喷状态 0:未返喷 1:喷涂线边返喷 2:物流仓库返喷 /// public string Repaint { get; set; } + public string ColorName { get; set; } } } \ No newline at end of file diff --git a/WebService/WMSWebService.asmx.cs b/WebService/WMSWebService.asmx.cs index 89d25df..f8f3a0a 100644 --- a/WebService/WMSWebService.asmx.cs +++ b/WebService/WMSWebService.asmx.cs @@ -94,7 +94,7 @@ namespace Webservice /// 喷涂报废接口 /// /// 条码号:A2048856739-P.190605.0008(二维码) - /// 0-不合格;1-合格; + /// 0-不合格;1-合格;9-返喷 8-其他 [WebMethod] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] public bool WMSSprayingForCS(string barcode, int isOK, out string errorReason) @@ -351,7 +351,7 @@ namespace Webservice InModel.position = "手持设备"; InModel.stationNo = "S20"; InModel.workClass = Function.GetWorkClass(); - InModel.inspectResult = "[合格]"; + InModel.inspectResult = "合格"; InModel.productInfo = Function.GetProductInfo(barcode); InModel.InspectTimes = InspectTimes; InModel.productOption = "";