diff --git a/WebService/Function.cs b/WebService/Function.cs index 98f33f8..1d67c65 100644 --- a/WebService/Function.cs +++ b/WebService/Function.cs @@ -789,7 +789,22 @@ namespace Webservice return res; } } - + public static DataTable GetLineIDByStation(string stationNo) + { + DataTable res = new DataTable(); + try + { + string sql = @" select lineName from tb_Line a,tb_Station b where a.LineID = b.LineID and b.StationNo='"+ stationNo + "' "; + res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); + return res; + } + catch (Exception ex) + { + LogHelper.WriteLogManager(ex); + LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); + return res; + } + } /// /// 根据产线ID查询工厂ID /// lx 20190610 @@ -917,7 +932,8 @@ namespace Webservice string msg = string.Empty; string position = string.Empty; string reason = string.Empty; - if (AllowSendToWms(barcode,isPass, ref repaint,ref msg,ref lu_code, ref colorName, ref productName, ref carType,ref position,ref reason) == false) + string LineID = string.Empty; + if (AllowSendToWms(barcode,isPass, ref repaint,ref msg,ref lu_code, ref colorName, ref productName, ref carType,ref position,ref reason,ref LineID) == false) { model.Result = "0"; model.ResultType = "Result"; @@ -972,7 +988,7 @@ namespace Webservice wmsM.IsOk = isPass; wmsM.Ok_Status = isPass.ToString(); wmsM.FactoryId = 0; - wmsM.LineId = 0; + wmsM.LineId = int.Parse( LineID); wmsM.WmsRead = 1; wmsM.ReadTime = null; wmsM.Remark = ""; @@ -986,10 +1002,10 @@ namespace Webservice LogHelper.WriteSysLogBase("【添加产线ID】barcode:" + barcode, MethodBase.GetCurrentMethod().Name); - string lineid = ConfigurationManager.AppSettings["LineID"].ToString().Trim(); - int lineId = 0; - Int32.TryParse(lineid, out lineId); - wmsM.LineId = lineId; + //string lineid = ConfigurationManager.AppSettings["LineID"].ToString().Trim(); + //int lineId = 0; + //Int32.TryParse(lineid, out lineId); + //wmsM.LineId = lineId; #endregion @@ -1170,11 +1186,11 @@ namespace Webservice /// pRepaint 只存在返喷 Repaint =1 只存在其它 Repaint =3 既存在返喷又存在其它 Repaint =4 /// static bool AllowSendToWms(string oneBarCode, int state, - ref int pRepaint,ref string errorMssg ,ref string lu_Code, ref string colorName, ref string productName,ref string carType,ref string position,ref string reason) + ref int pRepaint,ref string errorMssg ,ref string lu_Code, ref string colorName, ref string productName,ref string carType,ref string position,ref string reason,ref string lineID) { if (string.IsNullOrEmpty(oneBarCode)) return false; - string lineid = ConfigurationManager.AppSettings["LineID"].ToString().Trim(); + //string lineid = ConfigurationManager.AppSettings["LineID"].ToString().Trim(); DataTable inspectTable = GetInspectResultTable($"{oneBarCode}"); if (inspectTable.Rows.Count == 0) @@ -1185,6 +1201,18 @@ namespace Webservice colorName = inspectTable.Rows[0]["remark1"].ToString(); productName = inspectTable.Rows[0]["remark2"].ToString(); carType = inspectTable.Rows[0]["CarType"].ToString(); + string stationNo = inspectTable.Rows[0]["stationNo"].ToString(); + DataTable stationTable = GetLineIDByStation(stationNo); + if (stationTable.Rows.Count > 0) + { + lineID = stationTable.Rows[0]["lineName"].ToString(); + } + else + { + errorMssg = $"塑件码[{oneBarCode}]在喷涂下线表的工位[{stationNo}],在基础数据[产线]中没有找到产线编号,不能入库"; + return false; + } + position = inspectTable.Rows[0]["position"].ToString(); if(position == "下线一检") { @@ -1215,10 +1243,30 @@ namespace Webservice //因为客户端先插入,再调用接口,因此取第二条为前置状态 直接访问接口是,应该取第一条进行测试 string lastState = string.Empty; + string lastStation = string.Empty; if (inspectTable.Rows.Count > 1) { lastState = inspectTable.Rows[1]["inspectResult"].ToString(); + lastStation = inspectTable.Rows[1]["stationNo"].ToString(); } + if(lastState == "合格") + { + if(lastStation != inspectTable.Rows[0]["stationNo"].ToString()) + { + lastState = ""; + } + } + //string lastOkState = string.Empty; + //if (inspectTable.Rows.Count > 0) + //{ + // string currentStation = inspectTable.Rows[0]["stationNo"].ToString(); + // List ll = inspectTable.AsEnumerable().Where(p => p.Field("stationNo") == currentStation).ToList(); + // if (inspectTable.Rows.Count > 1) + // { + // lastOkState = ll[1]["inspectResult"].ToString(); + // } + //} + //返喷状态 int rePaint = GetRepaintStateNew(inspectTable); pRepaint = rePaint; @@ -1269,7 +1317,7 @@ namespace Webservice if (lastState.Contains("合格")) { string wmsMsg = string.Empty; - bool wmsAllow = GetWmsCompleteState(oneBarCode, lineid, ref wmsMsg); + bool wmsAllow = GetWmsCompleteState(oneBarCode, lineID, ref wmsMsg); if (wmsAllow == false) { if (string.IsNullOrEmpty(wmsMsg)) @@ -1310,7 +1358,7 @@ namespace Webservice if (lastState.Contains("合格")) { string wmsMsg = string.Empty; - bool wmsAllow = GetWmsCompleteState(oneBarCode, lineid, ref wmsMsg); + bool wmsAllow = GetWmsCompleteState(oneBarCode, lineID, ref wmsMsg); if (wmsAllow == false) { if (string.IsNullOrEmpty(wmsMsg)) @@ -1352,7 +1400,7 @@ namespace Webservice if (lastState.Contains("合格")) { string wmsMsg = string.Empty; - bool wmsAllow = GetWmsCompleteState(oneBarCode, lineid, ref wmsMsg); + bool wmsAllow = GetWmsCompleteState(oneBarCode, lineID, ref wmsMsg); if (wmsAllow == false) { if (string.IsNullOrEmpty(wmsMsg))