@ -543,89 +543,45 @@ namespace ICSSoft.DataProject
/// <param name="BusinessCode"></param>
/// <param name="cmd"></param>
/// <param name="jointLotNo"></param>
public static void WareHouseLotInfoUpForHG ( string Identification , string LocationCode , string Lo tNo , string Quantity , string User ,
string WorkPoint , string TransType , string BusinessCode , SqlCommand cmd , Dictionary < string , string > language )
public static void WareHouseLotInfoUpForHG ( string Identification , string LotNo , string Quantity , string User ,
string WorkPoint , string HGCode , string TransType , string BusinessCode , SqlCommand cmd , Dictionary < string , string > 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 ") + @" ' , 1 6 , 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) + @" ' , 1 6 , 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 ") + @" ' , 1 6 , 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
/// <param name="WorkPoint"></param>
/// <param name="cmd"></param>
/// <param name="language"></param>
public static void ContainerBind ( string LotNo , string ContainerCode , string ContainerType , string LocationCode , string RecomendBinCode , string User , string WorkPoint , SqlCommand cmd , Dictionary < string , string > language )
public static void ContainerBind ( string LotNo , string ContainerCode , string ContainerType , string LocationCode , string RecomendBinCode , string User , string WorkPoint , SqlCommand cmd , Dictionary < string , string > language )
{
try
{