@ -1963,7 +1963,7 @@ a.ExtensionID
tableName = @"ICSCheck a " ;
where = @" a.WorkPoint='{1}' " ;
where = @" a.WorkPoint='{1}' and a.Status='1' " ;
}
#endregion
where = string . Format ( where , JsonData . TransCode , JsonData . WorkPoint ) ;
@ -10586,17 +10586,69 @@ END";
{
string lots = string . Empty ;
string sql = string . Empty ;
DataTable dtLotno = new DataTable ( ) ;
int result = 0 ;
string Identification = Guid . NewGuid ( ) . ToString ( ) ;
foreach ( var item in JsonData )
{
sql = @ "SELECT b.LotNo FROM ICSCheck a
INNER JOIN ICSWareHouseLotInfo b ON SUBSTRING ( b . LocationCode , 1 , LEN ( a . SelectLevel ) ) = a . SelectLevel
INNER JOIN ICSWarehouse c on b . WarehouseCode = c . WarehouseCode and b . WorkPoint = c . WorkPoint
where a . CheckCode = ' { 0 } ' and a . WorkPoint = ' { 1 } ' ";
sql = string . Format ( sql , item . CheckCode , item . WorkPoint ) ;
dtLotno = DBHelper . SQlReturnData ( sql , cmd ) ;
//创建盘点单
foreach ( var itemInfo in item . detail )
{
for ( int i = dtLotno . Rows . Count - 1 ; i > = 0 ; i - - )
{
string lotNo = dtLotno . Rows [ i ] [ "LotNo" ] . ToString ( ) ;
// 判断当前 itemInfo.LotNo 是否包含在 dtLotno 中
if ( lotNo . Equals ( itemInfo . LotNo ) )
{
// 移除该行记录
dtLotno . Rows . RemoveAt ( i ) ;
}
}
ICSWareHouseLotInfoService . WareHouseLotInfoUpdate ( Identification , item . CheckCode , "" , itemInfo . LotNo , itemInfo . ActualQuantity , item . User , item . WorkPoint , TransTypeEnum . Check . GetDescription < DBValue > ( ) , item . CheckKind , cmd , language ) ;
lots + = "'" + itemInfo . LotNo + item . WorkPoint + "'," ;
}
for ( int i = 0 ; i < dtLotno . Rows . Count ; i + + )
{
///更新库存
sql = @"UPDATE ICSWareHouseLotInfo SET Quantity=0 WHERE LotNo='{0}' AND WorkPoint='{1}'" ;
sql = string . Format ( sql , dtLotno . Rows [ i ] [ "LotNo" ] . ToString ( ) , item . WorkPoint ) ;
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo168" ) ) ; //"库存更新失败!");
}
///添加日志
sql = @ "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 } ',' { 4 } ',' { 5 } ' , a . LotNo , a . InvCode ,
a . WarehouseCode , a . LocationCode , ' ',' ' , a . Quantity ,
' { 8 } ',' 0 ',' { 6 } ',' { 7 } ',' 0 ',' ' ,
' ',' ',' ' , f . F_Account , f . F_RealName ,
SYSDATETIME ( ) , a . WorkPoint , ' '
FROM ICSWareHouseLotInfo a
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 , dtLotno . Rows [ i ] [ "LotNo" ] . ToString ( ) , item . WorkPoint , item . User , Identification , item . CheckCode , "" , 8 , TransTypeEnum . LOTCheckAfter . GetDescription < DBValue > ( ) , item . CheckKind ) ;
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo166" ) ) ;
}
}
if ( string . IsNullOrWhiteSpace ( lots ) )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo005" ) ) ; //"请传入条码信息!");
@ -17432,18 +17484,69 @@ a.ExtensionID
item . TransCode = trans [ 1 ] ;
}
#region 销售出库
else if ( TransType = = TransTypeEnum . SalesShipmentDoc . GetDescription ( )
| | TransType = = TransTypeEnum . MOIssueDoc . GetDescription ( )
| | TransType = = TransTypeEnum . OutsourcingIssueDoc . GetDescription ( ) )
else if ( TransType = = TransTypeEnum . SalesShipmentDoc . GetDescription ( ) )
{
BusinessCode = TransTypeEnum . SalesShipmentDoc . GetDescription < DBValue > ( ) ;
//更新源头单据数量
pikTbLogsql + = string . Format ( @ " update b set b.LockQuantity=convert(decimal(18,6),b.LockQuantity)-convert(decimal(18,6),c.Quantity )
from dbo . ICSWareHouseLotInfo b
inner join ( select sum ( Quantity ) as Quantity , LotNo from ICSWareHouseLotInfolog where TransCode = ' { 0 } ' AND TransSequence = ' { 1 } ' and TransType = ' 1 5 ' and WorkPoint = ' { 2 } ' group by LotNo ) c
on c . LotNo = b . LotNo ", item.TransCode, item.TransSequence,item.WorkPoint);
pikTbLogsql + = string . Format ( @ " IF EXISTS(SELECT * FROM ICSSDN b
where b . SDNCode = ' { 0 } ' AND b . workpoint = ' { 1 } ' and b . SDNQuantity > 0 )
BEGIN
RAISERROR ( ' 选 中 单 据 { 0 } 已 经 发 过 料 , 不 能 回 撤 拣 料 , 请 先 确 认 ! ' , 1 6 , 1 ) ;
RETURN
END
delete ICSMOPickMerge from ICSMOPickMerge a
LEFT JOIN ICSSDN b on a . SourceID = b . id and a . WorkPoint = b . WorkPoint
where b . SDNCode = ' { 0 } ' AND b . workpoint = ' { 1 } ' ", item.TransCode, item.WorkPoint);
if ( ! DBHelper . ExecuteNonQuery ( pikTbLogsql , cmd ) )
{
throw new Exception ( "回撤拣料失败!" ) ;
}
}
#endregion
#region 生产发料
else if ( TransType = = TransTypeEnum . MOIssueDoc . GetDescription ( ) )
{
BusinessCode = TransTypeEnum . MOIssueDoc . GetDescription < DBValue > ( ) ;
//更新源头单据数量
pikTbLogsql + = string . Format ( @ "IF EXISTS(SELECT * FROM ICSMO b
INNER join ICSMOPick c on c . MODetailID = b . MODetailID and c . WorkPoint = b . WorkPoint
where b . MOCode = ' { 0 } ' AND b . workpoint = ' { 1 } ' and c . IssueQuantity > 0 )
BEGIN
RAISERROR ( ' 选 中 单 据 { 0 } 已 经 发 过 料 , 不 能 回 撤 拣 料 , 请 先 确 认 ! ' , 1 6 , 1 ) ;
RETURN
END
delete ICSMOPickMerge from ICSMOPickMerge a
INNER join ICSMOPick c on a . SourceID = c . id and a . WorkPoint = c . WorkPoint
LEFT JOIN ICSMO b on c . MODetailID = b . MODetailID and c . WorkPoint = b . WorkPoint and b . MOStatus < > '3'
where b . MOCode = ' { 0 } ' AND b . workpoint = ' { 1 } ' ", item.TransCode, item.WorkPoint);
if ( ! DBHelper . ExecuteNonQuery ( pikTbLogsql , cmd ) )
{
throw new Exception ( "回撤拣料失败!" ) ;
}
}
#endregion
#region 委外发料
else if ( TransType = = TransTypeEnum . OutsourcingIssueDoc . GetDescription ( ) )
{
BusinessCode = TransTypeEnum . OutsourcingIssueDoc . GetDescription < DBValue > ( ) ;
//更新源头单据数量
pikTbLogsql + = string . Format ( @ " IF EXISTS(SELECT * FROM ICSOutsourcingOrder b
INNER join ICSOOPick c on c . OODetailID = b . OODetailID and c . WorkPoint = b . WorkPoint
where b . OOCode = ' { 0 } ' AND b . workpoint = ' { 1 } ' and c . IssueQuantity > 0 )
BEGIN
RAISERROR ( ' 选 中 单 据 { 0 } 已 经 发 过 料 , 不 能 回 撤 拣 料 , 请 先 确 认 ! ' , 1 6 , 1 ) ;
RETURN
END
delete ICSMOPickMerge from ICSMOPickMerge a
INNER join ICSOOPick c on a . SourceID = c . id and a . WorkPoint = c . WorkPoint
LEFT JOIN ICSOutsourcingOrder b on c . OODetailID = b . OODetailID and c . WorkPoint = b . WorkPoint
where b . OOCode = ' { 0 } ' AND b . workpoint = ' { 1 } ' ", item.TransCode, item.WorkPoint);
pikTbLogsql + = string . Format ( @" delete dbo.ICSWareHouseLotInfoLog where TransCode ='{0}' AND TransSequence='{1}' and TransType='15' and WorkPoint='{2}'" , item . TransCode , item . TransSequence , item . WorkPoint ) ;
if ( ! DBHelper . ExecuteNonQuery ( pikTbLogsql , cmd ) )
{
throw new Exception ( "回撤拣料失败!" ) ;
xxxxxxxxxx