From ce377b3144406766e24cc6174dcf5ce3eb3e4935 Mon Sep 17 00:00:00 2001 From: lilili Date: Wed, 7 Jun 2023 13:25:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=93=E5=BA=93=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ICSSoft.DataProject/ICSSubmitService.cs | 218 ++++++++++++++++++ .../Controllers/WMSBarCoreController.cs | 6 +- 2 files changed, 223 insertions(+), 1 deletion(-) diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs index 7f9e1ff..0260251 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs @@ -7673,5 +7673,223 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer } } } + + + #region 库位区域验证 + /// + /// 库位区域验证 + /// + /// + /// + public static string CheckWHCode(BarCodeCheckModel JsonData) + { + var language = LanguageHelper.GetName("WMSAPIInfo"); + using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString)) + { + conn.Open(); + SqlCommand cmd = new SqlCommand(); + cmd.Connection = conn; + try + { + if (string.IsNullOrEmpty(JsonData.TransType)) + { + throw new Exception(language.GetNameByCode("WMSAPIInfo002"));//"单据类型不能为空!" + } + else if (!EnumHelper.HasDescriptions(typeof(TransTypeEnum), JsonData.TransType)) + { + throw new Exception(language.GetNameByCode("WMSAPIInfo003"));//"单据类型不存在!" + } + else if (string.IsNullOrEmpty(JsonData.WorkPoint)) + { + throw new Exception(language.GetNameByCode("WMSAPIInfo004"));//"站点不能为空!" + } + + string TransType = JsonData.TransType; //单据类型 + var whCode = JsonData.LocationCode.Split('-').ToList(); + #region SLQ + + StringBuilder sql = new StringBuilder(); + #endregion + + string msg = ""; + //WMSAPIInfo071 + if (JsonData.TransCode==null || JsonData.TransCode=="") + { + + #region 采购入库 + var a = TransTypeEnum.DeliveryNotice.GetDescription(); + if (TransType == TransTypeEnum.DeliveryNotice.GetDescription()) + { + sql.Append ($@"SELECT a.LotNo ,d.LocationCode, c.WHCode + FROM + ICSInventoryLot a + inner JOIN ICSInventoryLotDetail b ON a.WorkPoint= b.WorkPoint + AND a.LotNo=b.LotNo + inner Join ICSInventoryDetail d ON d.INVCode=a.InvCode + AND d.WorkPoint=b.WorkPoint + inner JOIN ICSDeliveryNotice c ON c.DNCode= b.TransCode + AND c.WorkPoint= b.WorkPoint + AND c.InvCode= a.INVCode + AND c.Sequence= b.TransSequence + AND c.WHCode=d.WHCode + WHERE + b.WorkPoint= '{JsonData.WorkPoint}' + AND a.LotNo= '{JsonData.BarCode}'") ; + + + } + #endregion + + #region 生产退料 + if (TransType == TransTypeEnum.MOIssueDocNegative.GetDescription() + || TransType == TransTypeEnum.MOIssueDocNegativeApply.GetDescription() + || TransType == TransTypeEnum.MOIssueDocNegativeIssue.GetDescription()) + { + sql.Append($@"SELECT a.LotNo ,d.LocationCode, c.WHCode + FROM + ICSInventoryLot a + inner JOIN ICSInventoryLotDetail b ON a.WorkPoint= b.WorkPoint + AND a.LotNo=b.LotNo + inner Join ICSInventoryDetail d ON d.INVCode=a.InvCode + AND d.WorkPoint=b.WorkPoint + inner JOIN ICSMOApplyNegDetail c ON c.ApplyNegCode= b.TransCode + AND c.WorkPoint= b.WorkPoint + AND c.InvCode= a.INVCode + AND c.Sequence= b.TransSequence + AND c.WHCode=d.WHCode + WHERE + b.WorkPoint= '{JsonData.WorkPoint}' + AND a.LotNo= '{JsonData.BarCode}'"); + } + #endregion + + #region 销售退货 + else if (TransType == TransTypeEnum.SalesShipmentDocNegative.GetDescription()) + { + sql.Append( $@"SELECT a.LotNo ,d.LocationCode, c.WHCode + FROM + ICSInventoryLot a + inner JOIN ICSInventoryLotDetail b ON a.WorkPoint= b.WorkPoint + AND a.LotNo=b.LotNo + inner Join ICSInventoryDetail d ON d.INVCode=a.InvCode + AND d.WorkPoint=b.WorkPoint + inner JOIN ICSSDN c ON c.SDNCode= b.TransCode + AND c.WorkPoint= b.WorkPoint + AND c.InvCode= a.INVCode + AND c.Sequence= b.TransSequence + AND c.WHCode=d.WHCode + WHERE + b.WorkPoint= '{JsonData.WorkPoint}' + AND a.LotNo= '{JsonData.BarCode}'"); + + } + #endregion + + #region 其他入库 + else if (TransType == TransTypeEnum.OtherInDoc.GetDescription()) + { + sql.Append ($@"SELECT a.LotNo ,d.LocationCode, c.WHCode + FROM + ICSInventoryLot a + inner JOIN ICSInventoryLotDetail b ON a.WorkPoint= b.WorkPoint + AND a.LotNo=b.LotNo + inner Join ICSInventoryDetail d ON d.INVCode=a.InvCode + AND d.WorkPoint=b.WorkPoint + inner JOIN ICSOtherIn c ON c.InCode= b.TransCode + AND c.WorkPoint= b.WorkPoint + AND c.InvCode= a.INVCode + AND c.Sequence= b.TransSequence + AND c.WHCode=d.WHCode + WHERE + b.WorkPoint= '{JsonData.WorkPoint}' + AND a.LotNo= '{JsonData.BarCode}'"); + + } + #endregion + } + else + { + #region 销售退货-原条码 + if (TransType == TransTypeEnum.SalesReturnBack.GetDescription()) + { + sql.Append($@"SELECT a.LotNo ,d.LocationCode, c.WHCode + FROM + ICSInventoryLot a + inner Join ICSInventoryDetail d ON d.INVCode=a.InvCode + inner JOIN ICSSDN c ON c.InvCode= a.INVCode + AND c.WHCode=d.WHCode + AND c.Type='2' + WHERE + c.WorkPoint= '{JsonData.WorkPoint}' + AND a.LotNo= '{JsonData.BarCode}' + And c.SDNCode= '{JsonData.TransCode}' "); + + } + #endregion + + #region 调拨 + else if (TransType == TransTypeEnum.OneStepTransferDocIn.GetDescription()) + { + sql.Append ($@"SELECT a.LotNo ,d.LocationCode, c.ToWarehouseCode as WHCode + FROM + ICSInventoryLot a + inner Join ICSInventoryDetail d ON d.INVCode=a.InvCode + inner JOIN ICSTransfer c ON c.INVCode= a.INVCode + AND c.ToWarehouseCode=d.WHCode + WHERE + c.WorkPoint= '{JsonData.WorkPoint}' + AND a.LotNo= '{JsonData.BarCode}' + And c.TransferNO= '{JsonData.TransCode}'"); + } + #endregion + } + + var dataset=DBHelper.SQlReturnDataSet(sql.ToString(),cmd); + if (dataset.Tables.Count == 0) + { + msg = "未查到条码库位区域信息"; + return msg; + } + + DataTable table = dataset.Tables[0]; + if (table.Rows.Count == 0) + { + msg = "未查到条码库位区域信息"; + return msg; + } + for (int i=0;i< table.Rows.Count;i++) + { + //区域 + var locationCode = table.Rows[i]["LocationCode"].ToString(); + var Code= table.Rows[i]["WHCode"].ToString(); + if (Code != whCode[0]) + { + throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo466"), Code, "", JsonData.LocationCode)); + } + if (locationCode != whCode[1]&& locationCode!=null &&locationCode!="") + { + throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo465"), locationCode, "", JsonData.LocationCode)); + } + + } + msg = "验证成功"; + return msg; + } + catch (Exception ex) + { + log.Error(ex.Message); + throw new Exception(ex.Message); + } + finally + { + if (conn.State == ConnectionState.Open) + { + conn.Close(); + } + conn.Dispose(); + } + } + } + #endregion } } diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs b/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs index b6bcfc1..15ce953 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs @@ -481,7 +481,11 @@ namespace ICSSoft.WebAPI.Controllers { BarCodeCheckModel model = new BarCodeCheckModel(); model = JsonConvert.DeserializeObject(JsonData.ToString()); - //var resultStr = ICSSubmitService.TransInformationGet(model); + res.Message = ICSSubmitService.CheckWHCode(model); + if (res.Message=="验证成功") + { + res.Success = true; + } } } catch (Exception ex)