From 8b7df2039d2060c72c0b58a27c8767c3831581fe Mon Sep 17 00:00:00 2001 From: FoxV Date: Mon, 26 Sep 2022 19:20:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?1.=E7=94=9F=E4=BA=A7/=E5=A7=94=E5=A4=96?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E7=BB=99ERP=E4=BC=A0=E5=80=BC=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AD=90=E4=BB=B6=E5=BA=93=E4=BD=8D=202.=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=96=99=E5=93=81=E7=AE=A1=E6=8E=A7=E6=9D=A1=E7=A0=81?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ICSManufactureService.cs | 5 +- .../ICSOutsourcingService.cs | 5 +- .../ICSWareHouseLotInfoService.cs | 47 ++++++++++++++++--- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSManufactureService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSManufactureService.cs index 6f983ca..825ad46 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSManufactureService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSManufactureService.cs @@ -798,7 +798,7 @@ namespace ICSSoft.DataProject SELECT Costre,Costre2,TransSequence,Sequence,InvCode,Quantity,Amount,MODetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 FROM #TempERP - SELECT c.MODetailID AS Costre2,a.TransCode,a.TransSequence AS Sequence,a.InvCode,a.Quantity,c.Amount,c.PickID,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand,ISNULL(ext.cFree1, '') AS cFree1,ISNULL(ext.cFree2, '') AS cFree2,ISNULL(ext.cFree3, '') AS cFree3,ISNULL(ext.cFree4, '') AS cFree4,ISNULL(ext.cFree5, '') AS cFree5,ISNULL(ext.cFree6, '') AS cFree6,ISNULL(ext.cFree7, '') AS cFree7,ISNULL(ext.cFree8, '') AS cFree8,ISNULL(ext.cFree9, '') AS cFree9,ISNULL(ext.cFree10, '') AS cFree10 + SELECT c.WHCode,c.MODetailID AS Costre2,a.TransCode,a.TransSequence AS Sequence,a.InvCode,c.Quantity/b.Quantity*a.Quantity as Quantity,c.Amount,c.PickID,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand,ISNULL(ext.cFree1, '') AS cFree1,ISNULL(ext.cFree2, '') AS cFree2,ISNULL(ext.cFree3, '') AS cFree3,ISNULL(ext.cFree4, '') AS cFree4,ISNULL(ext.cFree5, '') AS cFree5,ISNULL(ext.cFree6, '') AS cFree6,ISNULL(ext.cFree7, '') AS cFree7,ISNULL(ext.cFree8, '') AS cFree8,ISNULL(ext.cFree9, '') AS cFree9,ISNULL(ext.cFree10, '') AS cFree10 FROM ICSWareHouseLotInfoLog a INNER JOIN ICSMO b ON b.MOCode=a.TransCode AND b.WorkPoint=a.WorkPoint INNER JOIN ICSMOPick c ON c.MODetailID=b.MODetailID AND c.WorkPoint=b.WorkPoint AND a.TransSequence=b.Sequence+'~'+c.Sequence @@ -833,7 +833,7 @@ namespace ICSSoft.DataProject foreach (var details in resdetails) { JObject dets = (JObject)details; - ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["MODetailID"].ToString(), Identification, det["ERPID"].ToString(), + ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["MODetailID"].ToString(), Identification, dets["ERPID"].ToString(), dets["ERPDetailID"].ToString(), dets["MRCVCode"].ToString(), dets["Sequence"].ToString(), cmd, language); } } @@ -843,6 +843,7 @@ namespace ICSSoft.DataProject { log.Debug(ex.ToString()); log.Debug(resultStr); + throw new Exception(language.GetNameByCode("WMSAPIInfo200") + ex); } } else diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSOutsourcingService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSOutsourcingService.cs index 1c75399..11683df 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSOutsourcingService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSOutsourcingService.cs @@ -887,7 +887,7 @@ namespace ICSSoft.DataProject SELECT DISTINCT Costre,WorkPoint,VenCode,WarehouseCode AS WHCode,OOCode,ODNCode,MUSER AS [User],SYSDATETIME() AS MTime,Enable,UpdateTodoQuantity,CompleteVerification FROM #TempERP SELECT Costre,Costre2,Sequence,ODNSequence,InvCode,Quantity,Amount,OODetailID,Currency,UnitPrice,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 FROM #TempERP - SELECT c.OODetailID AS Costre2,a.TransCode,a.TransSequence AS Sequence,a.InvCode,a.Quantity,c.Amount,c.PickID,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand,ISNULL(ext.cFree1, '') AS cFree1,ISNULL(ext.cFree2, '') AS cFree2,ISNULL(ext.cFree3, '') AS cFree3,ISNULL(ext.cFree4, '') AS cFree4,ISNULL(ext.cFree5, '') AS cFree5,ISNULL(ext.cFree6, '') AS cFree6,ISNULL(ext.cFree7, '') AS cFree7,ISNULL(ext.cFree8, '') AS cFree8,ISNULL(ext.cFree9, '') AS cFree9,ISNULL(ext.cFree10, '') AS cFree10 + SELECT c.WHCode,c.OODetailID AS Costre2,a.TransCode,a.TransSequence AS Sequence,a.InvCode,c.Quantity/b.Quantity*a.Quantity as Quantity,c.Amount,c.PickID,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand,ISNULL(ext.cFree1, '') AS cFree1,ISNULL(ext.cFree2, '') AS cFree2,ISNULL(ext.cFree3, '') AS cFree3,ISNULL(ext.cFree4, '') AS cFree4,ISNULL(ext.cFree5, '') AS cFree5,ISNULL(ext.cFree6, '') AS cFree6,ISNULL(ext.cFree7, '') AS cFree7,ISNULL(ext.cFree8, '') AS cFree8,ISNULL(ext.cFree9, '') AS cFree9,ISNULL(ext.cFree10, '') AS cFree10 FROM ICSWareHouseLotInfoLog a INNER JOIN ICSOutsourcingOrder b ON b.OOCode=a.TransCode AND b.WorkPoint=a.WorkPoint INNER JOIN ICSOOPick c ON c.OODetailID=b.OODetailID AND c.WorkPoint=b.WorkPoint AND a.TransSequence=b.Sequence+'~'+c.Sequence @@ -922,7 +922,7 @@ namespace ICSSoft.DataProject foreach (var details in resdetails) { JObject dets = (JObject)details; - ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["OODetailID"].ToString(), Identification, det["ERPID"].ToString(), + ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["OODetailID"].ToString(), Identification, dets["ERPID"].ToString(), dets["ERPDetailID"].ToString(), dets["MRCVCode"].ToString(), dets["Sequence"].ToString(), cmd, language); } } @@ -932,6 +932,7 @@ namespace ICSSoft.DataProject { log.Debug(ex.ToString()); log.Debug(resultStr); + throw new Exception(language.GetNameByCode("WMSAPIInfo200") + ex); } } else diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs index e593499..280715d 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs @@ -178,10 +178,10 @@ namespace ICSSoft.DataProject SELECT c.MOCode AS TransCode, a.MODetailID AS DetailID, - a.InvCode, - b.InvName, - b.InvStd, - a.Quantity, + a.InvCode, + b.InvName, + b.InvStd, + a.Quantity, a.Amount, a.Sequence AS TransSequence, a.IssueQuantity, @@ -478,8 +478,43 @@ namespace ICSSoft.DataProject if (mode.itemCode.Equals("ControlMode02")) { //查询是否存在料品管控的条码 - string jsonStrNew = ICSControlModeService.QueryLotNo(jointLotNo, WorkPoint); - List modelNew = JsonConvert.DeserializeObject>(jsonStrNew); + string sqlStrNew = @"SELECT a.ID, + con.ContainerCode, + con.ContainerName, + a.LotNo, + a.InvCode, + inv.InvName, + inv.InvStd, + inv.InvUnit,-- {0} + inv.AmountUnit, + ext.ID AS ExtensionID, + ext.ProjectCode, + ext.Version, + ext.BatchCode, + ext.Brand, + ext.cFree1, + ext.cFree2, + ext.cFree3, + ext.cFree4, + ext.cFree5, + ext.cFree6, + ext.cFree7, + ext.cFree8, + ext.cFree9, + ext.cFree10, + a.MUSER AS [ USER ], + a.MTIME AS [ MTime ] + FROM + ICSInventoryLot a + LEFT JOIN ICSContainerLot conlot ON a.LotNo = conlot.LotNo AND a.WorkPoint = conlot.WorkPoint + LEFT JOIN ICSContainer con ON conlot.ContainerID = con.ID AND conlot.WorkPoint = con.WorkPoint + INNER JOIN ICSInventory inv ON a.InvCode = inv.InvCode AND a.WorkPoint = inv.WorkPoint + INNER JOIN ICSExtension ext ON a.ExtensionID = ext.ID AND a.WorkPoint = ext.WorkPoint + WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'"; + sqlStrNew = string.Format(sqlStrNew, jointLotNo, WorkPoint); + DataTable table = DBHelper.SQlReturnData(sqlStrNew, cmd); + string json = JsonConvert.SerializeObject(table); + List modelNew = JsonConvert.DeserializeObject>(json); //当不存在料品管控条码时,生成新条码 if (!(modelNew.Count > 0)) From d23a39640f1e2d554745e12d9429b3ca891699c1 Mon Sep 17 00:00:00 2001 From: FoxV Date: Tue, 27 Sep 2022 10:09:15 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=96=99=E5=93=81=E7=AE=A1=E6=8E=A7?= =?UTF-8?q?=E6=9D=A1=E7=A0=81=E5=B7=B2=E5=AD=98=E5=9C=A8=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E8=B0=83=E7=94=A8=E5=90=88=E6=89=B9=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ICSWareHouseLotInfoService.cs | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs index 2a264c3..7e1cbe2 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs @@ -552,12 +552,61 @@ namespace ICSSoft.DataProject throw new Exception(language.GetNameByCode("WMSAPIInfo166")); } } - //当存在料品管控条码时,执行合批 + //当存在料品管控条码时,直接将数量叠加 else { - LotNoMode lotNoMode = modelNew[0]; - WareHouseLotInfoMerge(Identification,jointLotNo, LotNo, Quantity,User,WorkPoint,TransType,BusinessCode,cmd,language); + try + { + ///更新目标条码库存 + sql = @" + IF NOT EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}') + BEGIN + RAISERROR('" + language.GetNameByCode("WMSAPIInfo171") + @"',16,1); + RETURN + END + UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)+'{2}' WHERE LotNo='{0}' AND WorkPoint='{1}' + "; + sql = string.Format(sql, jointLotNo, WorkPoint, Quantity); + + if (!DBHelper.ExecuteNonQuery(sql, cmd)) + { + throw new Exception(language.GetNameByCode("WMSAPIInfo169"));//"目标条码库存更新失败!"); + } + + ///添加日志 + sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}') + BEGIN + RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{2}") + @"',16,1); + RETURN + END + + INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode, + FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity, + Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID, + ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName, + MTIME,WorkPoint,EATTRIBUTE1) + SELECT NEWID(),'{3}',b.TransCode,b.TransSequence,a.LotNo ,a.InvCode , + '','',c.WarehouseCode,c.LocationCode,c.Quantity, + '','0','{4}','{5}','0','', + '','','',f.F_Account ,f.F_RealName , + SYSDATETIME() ,a.WorkPoint ,'' + FROM ICSInventoryLot a + INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint + INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.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}' + "; + sql = string.Format(sql, jointLotNo, WorkPoint, User, Identification, TransType, BusinessCode); + if (!DBHelper.ExecuteNonQuery(sql, cmd)) + { + throw new Exception(language.GetNameByCode("WMSAPIInfo166")); + } + } + catch (Exception) + { + throw; + } } 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 3/3] =?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"));//"库存更新失败!"); + } } }