From 808fbd0e1cb00abd71e601736c32d1f6cd805563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=92=E6=9E=97=E6=9D=B0?= <1205395967@qq.com> Date: Tue, 27 Sep 2022 17:47:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=8B=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ICSWareHouseLotInfoService.cs | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs index 7e1cbe2..e8b88dd 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs @@ -1001,6 +1001,20 @@ namespace ICSSoft.DataProject } if (!LotEnable.Equals("False")) { + ///更新库存 + sql = @"UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)-'{2}' WHERE LotNo='{0}' AND WorkPoint='{1}' + + IF EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND Quantity<0) + BEGIN + RAISERROR('" + language.GetNameByCode("WMSAPIInfo167") + @"',16,1); + RETURN + END"; + sql = string.Format(sql, LotNo, WorkPoint, Quantity); + + if (!DBHelper.ExecuteNonQuery(sql, cmd)) + { + throw new Exception(language.GetNameByCode("WMSAPIInfo168"));//"库存更新失败!"); + } ///分批前添加日志 sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}') @@ -1067,7 +1081,7 @@ namespace ICSSoft.DataProject } #endregion sql = @"INSERT INTO ICSWareHouseLotInfo(ID,LotNO,WarehouseCode,LocationCode,InvCode,Quantity,InDate,LockQuantity,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1) - select NEWID(),'{0}',WarehouseCode,LocationCode,InvCode,'0',InDate,LockQuantity + select NEWID(),'{0}',WarehouseCode,LocationCode,InvCode,'{2}',InDate,LockQuantity ,MUSER,MUSERName,GETDATE(),'{3}','' from ICSWareHouseLotInfo where LotNO='{1}' AND WorkPoint='{3}'"; @@ -1097,7 +1111,7 @@ namespace ICSSoft.DataProject ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName, MTIME,WorkPoint,EATTRIBUTE1,LogID) SELECT NEWID(),'{3}','{4}','{5}','{10}' ,a.InvCode , - c.WarehouseCode,c.LocationCode,'','','{6}', + c.WarehouseCode,c.LocationCode,'{11}','{12}','{6}', '','0','{7}','{8}','0','', '','','',f.F_Account ,f.F_RealName , SYSDATETIME() ,a.WorkPoint ,'','{9}' @@ -1106,7 +1120,7 @@ namespace ICSSoft.DataProject 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}' "; - sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransCode, TransSequence, Quantity, TransType, BusinessCode, MergeID, lotstr); + sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransCode, TransSequence, Quantity, TransType, BusinessCode, MergeID, lotstr, WarehouseCode, LocationCode); cmd.CommandText = sql; result = cmd.ExecuteNonQuery(); if (result <= 0) @@ -1176,7 +1190,7 @@ namespace ICSSoft.DataProject Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID, ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName, MTIME,WorkPoint,EATTRIBUTE1,MergeID) - SELECT NEWID(),'{3}','','',a.LotNo ,a.InvCode , + SELECT NEWID(),'{3}','{4}','{5}',a.LotNo ,a.InvCode , c.WarehouseCode,c.LocationCode,'{9}','{10}',{6}, '','0','{7}','{8}','0','', '','','',f.F_Account ,f.F_RealName , @@ -1192,6 +1206,21 @@ namespace ICSSoft.DataProject { throw new Exception(language.GetNameByCode("WMSAPIInfo166")); } + + ///更新库存 + sql = @"UPDATE ICSWareHouseLotInfo SET WareHouseCode='{2}',LocationCode='{3}' WHERE LotNo='{0}' AND WorkPoint='{1}' + + IF EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND Quantity<0) + BEGIN + RAISERROR('" + language.GetNameByCode("WMSAPIInfo167") + @"',16,1); + RETURN + END"; + sql = string.Format(sql, LotNo, WorkPoint, WarehouseCode, LocationCode); + + if (!DBHelper.ExecuteNonQuery(sql, cmd)) + { + throw new Exception(language.GetNameByCode("WMSAPIInfo168"));//"库存更新失败!"); + } } }