From cca18444b12ea94690538254d733ccbf78b351a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=86=E6=99=94?= Date: Thu, 11 May 2023 17:34:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=BD=E5=A8=81=E9=87=87=E8=B4=AD=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E8=B4=A7=E6=9F=9C=E5=9B=9E=E5=86=99=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ICSSoft.DataProject/ICSSubmitService.cs | 54 ++++++------- .../ICSWareHouseLotInfoService.cs | 80 +++++-------------- .../ICSSoft.Entity/LOTStockDownHGModel.cs | 4 + 3 files changed, 49 insertions(+), 89 deletions(-) diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs index 718d000..4bd0388 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs @@ -2292,7 +2292,7 @@ namespace ICSSoft.DataProject INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint LEFT JOIN ICSInventoryLotDetail lotdd ON lotdd.LotNo=a.LotNo AND a.WorkPoint=lotdd.WorkPoint LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint"; - LotDetail = $@" LEFT JOIN ICSInventoryDetail detail ON inv.InvCode= detail.INVCode AND detail.WHCode ={columnsWHCODE.Replace("AS WHCode"," ")} + LotDetail = $@" LEFT JOIN ICSInventoryDetail detail ON inv.InvCode= detail.INVCode AND detail.WHCode ={columnsWHCODE.Replace("AS WHCode", " ")} AND a.WorkPoint= detail.WorkPoint "; con = " detail.LocationCode AS Area, "; @@ -2358,13 +2358,13 @@ namespace ICSSoft.DataProject if (TransType == TransTypeEnum.LocationSeatch.GetDescription()) { - Losql = string.Format(Losql, columns, tableName, JsonData.Code, JsonData.WorkPoint,LotDetail,con); + Losql = string.Format(Losql, columns, tableName, JsonData.Code, JsonData.WorkPoint, LotDetail, con); table = DBHelper.SQlReturnData(Losql, cmd); } else { - sql = string.Format(sql, columns, tableName, JsonData.Code, JsonData.WorkPoint,LotDetail,con); + sql = string.Format(sql, columns, tableName, JsonData.Code, JsonData.WorkPoint, LotDetail, con); log.Info("条码sql:" + sql); table = DBHelper.SQlReturnData(sql, cmd); } @@ -3367,8 +3367,8 @@ namespace ICSSoft.DataProject ICSPurchaseService.DeliveryNoticeIn(itemInfo.STO_EFF_SUB1, itemInfo.STO_QTAR, JsonData.DATA.EXP_ORDINI[0].ORD_CLIENTE, cmd, language); BusinessCode = TransTypeEnum.DeliveryNotice.GetDescription(); //入库 - ICSWareHouseLotInfoService.WareHouseLotInfoUpForHG(Identification, itemInfo.LocationCode, itemInfo.STO_EFF_SUB1, itemInfo.STO_QTAR, - itemInfo.STO_EXE_OPERATORE, JsonData.DATA.EXP_ORDINI[0].ORD_CLIENTE, "2", BusinessCode, cmd, language); + ICSWareHouseLotInfoService.WareHouseLotInfoUpForHG(Identification, itemInfo.STO_EFF_SUB1, itemInfo.STO_QTAR, + itemInfo.STO_EXE_OPERATORE, JsonData.DATA.EXP_ORDINI[0].ORD_CLIENTE, itemInfo.STO_CORRIDOIO, "2", BusinessCode, cmd, language); } } #endregion @@ -7204,12 +7204,12 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer if (string.IsNullOrEmpty(JsonData.TransCode)) { throw new Exception(language.GetNameByCode("WMSAPIInfo001"));//"单据号不能为空!" - } + } else if (string.IsNullOrEmpty(JsonData.WorkPoint)) { throw new Exception(language.GetNameByCode("WMSAPIInfo004"));//"站点不能为空!" } - string information =String.Format( language.GetNameByCode("WMSAPIInfo035"),"","","", JsonData.TransCode); + string information = String.Format(language.GetNameByCode("WMSAPIInfo035"), "", "", "", JsonData.TransCode); #region SLQ string sql = $@"IF NOT EXISTS(SELECT a.ID FROM ICSMTDOC a WHERE a.MTDOCCode= '{JsonData.TransCode}' AND a.WorkPoint= '{JsonData.WorkPoint}') @@ -7307,31 +7307,31 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer { string TransType = string.Empty; string Identification = Guid.NewGuid().ToString(); - StringBuilder sql =new StringBuilder(); + StringBuilder sql = new StringBuilder(); foreach (var item in JsonData) { - foreach (var data in item.DetailModels) - { - //修改源头单据 - ICSWareHouseService.MTDoc(item.TransCode, item.TransSequence, data.Quantity, item.WorkPoint, cmd, language); - TransType = item.Type; - //单据类型 12:按单转移 13:按物料转移 - if (TransType=="13") + foreach (var data in item.DetailModels) { - //形态转换 - sql.Append($@"UPDATE ICSWareHouseLotInfo SET InvCode='{item.AfterInvCode}' WHERE LotNo='{data.LotNo}' AND WorkPoint='{item.WorkPoint}' AND InvCode='{item.BeforInvCode}' AND WarehouseCode='{item.WHCode}'; + //修改源头单据 + ICSWareHouseService.MTDoc(item.TransCode, item.TransSequence, data.Quantity, item.WorkPoint, cmd, language); + TransType = item.Type; + //单据类型 12:按单转移 13:按物料转移 + if (TransType == "13") + { + //形态转换 + sql.Append($@"UPDATE ICSWareHouseLotInfo SET InvCode='{item.AfterInvCode}' WHERE LotNo='{data.LotNo}' AND WorkPoint='{item.WorkPoint}' AND InvCode='{item.BeforInvCode}' AND WarehouseCode='{item.WHCode}'; UPDATE ICSWareHouseLotInfoLog SET InvCode='' WHERE LotNo='{data.LotNo}' AND WorkPoint='{item.WorkPoint}' AND InvCode='{item.BeforInvCode}' ; UPDATE ICSInventoryLot SET InvCode='{item.AfterInvCode}' WHERE LotNo='{data.LotNo}' AND InvCode='{item.BeforInvCode}' AND WorkPoint='{item.WorkPoint}' AND ExtensionID='{item.BeforExtensionID}';"); - - } - else if (TransType == "12") - { - sql.Append($@"UPDATE ICSInventoryLot SET ExtensionID='{item.AfterExtensionID}' WHERE LotNo='{data.LotNo}' AND InvCode='{item.BeforInvCode}' AND WorkPoint='{item.WorkPoint}' AND ExtensionID='{item.BeforExtensionID}';"); - } - else - { - throw new Exception("单据类型不存在"); - } + + } + else if (TransType == "12") + { + sql.Append($@"UPDATE ICSInventoryLot SET ExtensionID='{item.AfterExtensionID}' WHERE LotNo='{data.LotNo}' AND InvCode='{item.BeforInvCode}' AND WorkPoint='{item.WorkPoint}' AND ExtensionID='{item.BeforExtensionID}';"); + } + else + { + throw new Exception("单据类型不存在"); + } } } DataTable table = DBHelper.SQlReturnData(sql.ToString(), cmd); diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs index 0d9a277..44e4c11 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs @@ -543,89 +543,45 @@ namespace ICSSoft.DataProject /// /// /// - public static void WareHouseLotInfoUpForHG(string Identification, string LocationCode, string LotNo, string Quantity, string User, - string WorkPoint, string TransType, string BusinessCode, SqlCommand cmd, Dictionary language) + public static void WareHouseLotInfoUpForHG(string Identification, string LotNo, string Quantity, string User, + string WorkPoint, string HGCode, string TransType, string BusinessCode, SqlCommand cmd, Dictionary language) { try { - + string LocationCode = ""; + string WHCode = ""; #region 正常入库 - #region 根据物料判断条码需要入库的仓库及库位 - string chksql = @"SELECT TOP 1 LocationCode FROM ICSLocation WHERE Region = - (select C.LocationCode from ICSInventory A - LEFT JOIN ICSInventoryLot B ON B.InvCode=A.InvCode AND B.WorkPoint=A.WorkPoint - INNER JOIN ICSInventoryDetail C ON C.INVCode=A.InvCode AND C.WorkPoint=A.WorkPoint - WHERE B.LotNo='{0}' AND B.WorkPoint='{1}' - AND C.WHCode=(select WHCode from ICSInventoryLotDetail lot - INNER JOIN ICSDeliveryNotice doc on doc.DNCode=lot.TransCode and doc.Sequence=lot.TransSequence and doc.WorkPoint=lot.WorkPoint - where lot.LotNo='{0}' and lot.WorkPoint='{1}')) AND WorkPoint='{1}'"; - chksql = string.Format(chksql, LotNo, WorkPoint); + #region 根据传入的货柜机器号找到对应的入库库位和仓库 + string chksql = @"select F_Define2 AS BinCode,C.WarehouseCode AS WHCode from Sys_SRM_ItemsDetail A + LEFT JOIN ICSLocation B ON B.LocationCode=A.F_Define2 AND B.WorkPoint=A.F_Define4 + LEFT JOIN ICSWarehouse C ON C.ID=B.WHID AND C.WorkPoint=B.WorkPoint + where F_Define1='{0}' AND F_ItemName='HG_Location' AND F_Define4='{1}'"; + chksql = string.Format(chksql, HGCode, WorkPoint); DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd); if (chkdt.Rows.Count == 0) { - throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo214"), LotNo)); + throw new Exception("传入货柜机器号:" + HGCode + "没有维护对应的WMS入库库位!"); ; } else { - LocationCode = chkdt.Rows[0]["LocationCode"].ToString(); + LocationCode = chkdt.Rows[0]["BinCode"].ToString(); + WHCode = chkdt.Rows[0]["WHCode"].ToString(); } #endregion ///添加库存(原条码退回,更新库存;新条码直接入库) //stirng locationcode = ""; string sql = string.Empty; - string locationcode = ""; sql = @"IF EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}') BEGIN RAISERROR('" + language.GetNameByCode("WMSAPIInfo164") + @"',16,1); RETURN END "; - sql += @" - IF EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}') - BEGIN - IF EXISTS(SELECT a.LotNO FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.Quantity=0) - BEGIN - UPDATE a SET a.Quantity=ISNULL(a.Quantity,0)+'{3}',WarehouseCode=e.WarehouseCode,LocationCode=d.LocationCode - From ICSWareHouseLotInfo a - INNER JOIN ICSLocation d ON d.LocationCode='{4}' AND a.WorkPoint=d.WorkPoint - INNER JOIN ICSWarehouse e ON d.WHID=e.ID AND d.WorkPoint=e.WorkPoint - WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' - END - ELSE IF EXISTS(SELECT a.LotNO FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.LocationCode='{4}') - BEGIN - UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)+'{3}' - WHERE LotNo='{0}' AND WorkPoint='{1}' - END - ELSE IF('" + locationcode + @"' != '{4}') - BEGIN - RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo395"), "{4}", locationcode) + @"', 16, 1); - RETURN - END - END - ELSE - BEGIN - IF EXISTS(SELECT il.InvCode FROM ICSInventoryLocation il - INNER JOIN ICSInventoryLot a ON a.InvCode=il.InvCode AND a.WorkPoint=il.WorkPoint - WHERE il.Enable='1' AND a.LotNo='{0}' AND a.WorkPoint='{1}') - BEGIN - IF NOT EXISTS(SELECT il.InvCode FROM ICSInventoryLocation il - INNER JOIN ICSInventoryLot a ON a.InvCode=il.InvCode AND a.WorkPoint=il.WorkPoint - WHERE il.Enable='1' AND a.LotNo='{0}' AND a.WorkPoint='{1}' AND il.LocationCode='{4}') - BEGIN - RAISERROR('" + language.GetNameByCode("WMSAPIInfo180") + @"',16,1); - RETURN - END - END - INSERT INTO ICSWareHouseLotInfo(ID,LotNO,WarehouseCode,LocationCode,InvCode,Quantity,InDate,LockQuantity,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1) - SELECT NEWID(),a.LotNo ,e.WarehouseCode,d.LocationCode,a.InvCode ,'{3}',SYSDATETIME(),'0','{2}','{2}',SYSDATETIME() ,a.WorkPoint ,'' + sql += @" INSERT INTO ICSWareHouseLotInfo(ID,LotNO,WarehouseCode,LocationCode,InvCode,Quantity,InDate,LockQuantity,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1) + SELECT NEWID(),a.LotNo ,'{4}','{5}',a.InvCode ,'{3}',SYSDATETIME(),'0','{2}','{2}',SYSDATETIME() ,a.WorkPoint ,'' FROM ICSInventoryLot a INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint - --INNER JOIN ICSOApplyNegDetail c ON b.TransCode=c.OApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint - INNER JOIN ICSLocation d ON d.LocationCode='{4}' AND a.WorkPoint=d.WorkPoint - INNER JOIN ICSWarehouse e ON d.WHID=e.ID AND d.WorkPoint=e.WorkPoint - --INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location - WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' - END"; - sql = string.Format(sql, LotNo, WorkPoint, User, Quantity, LocationCode); + WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'"; + sql = string.Format(sql, LotNo, WorkPoint, User, Quantity, WHCode, LocationCode); if (!DBHelper.ExecuteNonQuery(sql, cmd)) { @@ -2490,7 +2446,7 @@ namespace ICSSoft.DataProject /// /// /// - public static void ContainerBind(string LotNo, string ContainerCode, string ContainerType, string LocationCode,string RecomendBinCode, string User, string WorkPoint, SqlCommand cmd, Dictionary language) + public static void ContainerBind(string LotNo, string ContainerCode, string ContainerType, string LocationCode, string RecomendBinCode, string User, string WorkPoint, SqlCommand cmd, Dictionary language) { try { diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.Entity/LOTStockDownHGModel.cs b/ICSSoft.WMS.WebAPI/ICSSoft.Entity/LOTStockDownHGModel.cs index 7636f5c..3454c4a 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.Entity/LOTStockDownHGModel.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.Entity/LOTStockDownHGModel.cs @@ -71,6 +71,10 @@ namespace ICSSoft.Entity /// public string STO_EFF_QTA { get; set; }//CurrentQuantity /// + /// 货柜机器号(货柜编码) + /// + public string STO_CORRIDOIO { get; set; } + /// /// 辅计量数量 /// public string CurrentAmount { get; set; }