diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs index 8d08b59..5c7d189 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs @@ -2890,24 +2890,15 @@ namespace ICSSoft.DataProject RETURN END IF NOT EXISTS (SELECT * FROM ICSContainerLot WHERE ContainerID= - (SELECT ID FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}')) (SELECT ID FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}') AND LotNo='{0}') BEGIN - update ICSContainer set LocationCode='{4}',EATTRIBUTE1='已绑定' where ContainerCode='{1}' AND WorkPoint='{2}' -- update ICSContainer set EATTRIBUTE1='已绑定' where ContainerCode='{1}' AND WorkPoint='{2}' INSERT INTO ICSContainerLot (ID,ContainerID,LotNo,MUSER,MUSERName,WorkPoint,MTIME,EATTRIBUTE1) SELECT NEWID(),ID,'{0}','{3}' - ,(SELECT F_RealName FROM Sys_SRM_User WHERE F_Account='{3}' AND F_Location='{2}'),'{2}',GETDATE(),'{4}' FROM ICSContainer ,(SELECT F_RealName FROM Sys_SRM_User WHERE F_Account='{3}' AND F_Location='{2}'),'{2}',GETDATE(),'' FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}' END - ELSE - BEGIN - update ICSContainer set LocationCode='{4}',EATTRIBUTE1='已绑定' where ContainerCode='{1}' AND WorkPoint='{2}' - UPDATE ICSContainerLot SET LotNo='{0}' WHERE ContainerID= - (SELECT ID FROM ICSContainer WHERE ContainerCode='{1}' AND WorkPoint='{2}') - END -- ELSE -- BEGIN -- update ICSContainer set LocationCode='{4}',EATTRIBUTE1='已绑定' where ContainerCode='{1}' AND WorkPoint='{2}' @@ -3722,5 +3713,97 @@ namespace ICSSoft.DataProject throw new Exception(ex.Message); } } + /// + /// 料架单据绑定 + /// + /// + /// + /// + /// + /// + /// + public static void ContainerTransCodeBind(List tranCodes, string containerCode, string User, SqlCommand cmd, Dictionary language) + { + try + { + + string sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{1}' ) + BEGIN + RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{1}") + @"',16,1); + RETURN + END + + IF NOT EXISTS(SELECT ID FROM ICSContainer WHERE ContainerCode='{0}' ) + BEGIN + RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo473"), "", "{0}") + @"',16,1); + RETURN + END; + SELECT top 1 Desks FROM ICSMOApply WHERE ApplyCode='{2}' + "; + sql = string.Format(sql, containerCode, User, tranCodes.FirstOrDefault()); + + var table = DBHelper.SQlReturnData(sql, cmd); + if (table.Rows.Count<=0) + { + throw new Exception("单据对应的工位不存在,操作失败"); + } + foreach (string tranCode in tranCodes) + { + string sqlCheck = @"IF NOT EXISTS(select ID from ICSWareHouseLotInfoLog where TransType='15' AND TransCode='{0}') + BEGIN + RAISERROR('" + language.GetNameByCode("WMSAPIInfo478") + @"',16,1); + RETURN + END; + IF NOT EXISTS( SELECT ID FROM ICSMOApply WHERE ApplyCode='{0}' AND Desks='{1}') + BEGIN + RAISERROR('"+language.GetNameByCode("WMSAPIInfo477") + @"',16,1); + RETURN + END; + IF EXISTS(select ID from ICSContainerReceiptsNumber where ContainerCode='{2}' AND TransCode='{0}') + BEGIN + RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo479"), "{0}","{2}") + @"',16,1); + RETURN + END; + INSERT INTO ICSContainerReceiptsNumber SELECT NEWID(),'{0}','{2}',F_Account,F_RealName,GETDATE(),NULL,NULL,NULL,NULL,NULL FROM Sys_SRM_User WHERE F_Account='{3}' "; + sqlCheck= string.Format(sqlCheck, tranCode, table.Rows[0]["Desks"].ToString(),containerCode, User); + if (!DBHelper.ExecuteNonQuery(sqlCheck, cmd)) + { + throw new Exception("单据新增失败"); + } + } + } + catch (Exception ex) + { + throw ex; + } + } + /// + /// 根据条码获取仓库和区域信息 + /// + /// + /// + public static DataTable GetWHCodeArea(string LotNo,SqlCommand cmd) + { + try + { + string check = $@"SELECT C.WHCode,C.LocationCode FROM ICSInventoryLotDetail A + INNER JOIN ICSDeliveryNotice B ON B.DNCode=A.TransCode AND B.Sequence=A.TransSequence AND B.WorkPoint=A.WorkPoint + INNER JOIN ICSInventoryDetail C ON C.INVCode=B.InvCode AND C.WHCode=B.WHCode AND C.WorkPoint=B.WorkPoint + WHERE A.LotNo='{LotNo}' + UNION ALL + SELECT C.WHCode,C.LocationCode FROM ICSInventoryLotDetail A + INNER JOIN ICSMOApplyNegDetail B ON B.ApplyNegCode=A.TransCode AND B.Sequence=A.TransSequence AND B.WorkPoint=A.WorkPoint + INNER JOIN ICSInventoryDetail C ON C.INVCode=B.InvCode AND C.WHCode=B.WHCode AND C.WorkPoint=B.WorkPoint + WHERE A.LotNo='{LotNo}'"; + var table = DBHelper.SQlReturnData(check, cmd); + return table; + + } + catch (Exception ex) + { + throw ex; + } + } + } } diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.Entity/ICSSoft.Entity.csproj b/ICSSoft.WMS.WebAPI/ICSSoft.Entity/ICSSoft.Entity.csproj index 26a48f0..9708e69 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.Entity/ICSSoft.Entity.csproj +++ b/ICSSoft.WMS.WebAPI/ICSSoft.Entity/ICSSoft.Entity.csproj @@ -53,10 +53,11 @@ - + + @@ -68,6 +69,7 @@ +