diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSManufactureService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSManufactureService.cs index 673df75..5b8d981 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSManufactureService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSManufactureService.cs @@ -805,7 +805,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 @@ -840,7 +840,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); } } @@ -850,6 +850,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 bc7012f..3449f96 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSOutsourcingService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSOutsourcingService.cs @@ -894,7 +894,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 @@ -929,10 +929,12 @@ namespace ICSSoft.DataProject foreach (var details in resdetails) { JObject dets = (JObject)details; + string allcol = jo["cWhCode"].ToString() + det["ProjectCode"].ToString() + det["BatchCode"].ToString() + det["Version"].ToString() + det["Brand"].ToString() + det["cFree1"].ToString() + det["cFree2"].ToString() + det["cFree3"].ToString() + det["cFree4"].ToString() + det["cFree5"].ToString() + det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString(); - 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(), allcol, cmd, language); + } } } @@ -941,6 +943,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 38362f0..353b5a2 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)) @@ -517,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; + } } @@ -917,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}') @@ -983,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}'"; @@ -1013,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}' @@ -1022,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) @@ -1092,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 , @@ -1108,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"));//"库存更新失败!"); + } } }