@ -20,6 +20,25 @@ namespace ICSSoft.DataProject
{
{
private static log4net . ILog log = log4net . LogManager . GetLogger ( System . Reflection . MethodBase . GetCurrentMethod ( ) . DeclaringType ) ;
private static log4net . ILog log = log4net . LogManager . GetLogger ( System . Reflection . MethodBase . GetCurrentMethod ( ) . DeclaringType ) ;
/// <summary>
/// 分批
/// </summary>
/// <param name="Identification"></param>
/// <param name="TransCode"></param>
/// <param name="TransSequence"></param>
/// <param name="LotNo"></param>
/// <param name="Quantity"></param>
/// <param name="User"></param>
/// <param name="WorkPoint"></param>
/// <param name="TransType"></param>
/// <param name="BusinessCode"></param>
/// <param name="cmd"></param>
public static void WareHouseLotInfoInBatches ( string Identification , string TransCode , string TransSequence , string LotNo , string Quantity , string User ,
string WorkPoint , string TransType , string BusinessCode , SqlCommand cmd , Dictionary < string , string > language , string MergeID = "" )
{
}
/// <summary>
/// <summary>
/// 添加库存
/// 添加库存
/// </summary>
/// </summary>
@ -133,6 +152,11 @@ namespace ICSSoft.DataProject
public static void WareHouseLotInfoDown ( string Identification , string TransCode , string TransSequence , string LotNo , string Quantity , string User ,
public static void WareHouseLotInfoDown ( string Identification , string TransCode , string TransSequence , string LotNo , string Quantity , string User ,
string WorkPoint , string TransType , string BusinessCode , SqlCommand cmd , Dictionary < string , string > language , string MergeID = "" )
string WorkPoint , string TransType , string BusinessCode , SqlCommand cmd , Dictionary < string , string > language , string MergeID = "" )
{
{
String LotEnable = "" ;
String PrintEnable = "" ;
string lotstr = "" ;
int result = 0 ;
List < string > NewBarCodeList = new List < string > ( ) ;
try
try
{
{
///更新库存
///更新库存
@ -149,6 +173,116 @@ namespace ICSSoft.DataProject
{
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo168" ) ) ; //"库存更新失败!");
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo168" ) ) ; //"库存更新失败!");
}
}
//检验是否分批
sql = @ "SELECT b.LotEnable,b.PrintEnable FROM ICSInventoryLot a
LEFT JOIN ICSInventory b ON a . InvCode = b . InvCode AND a . WorkPoint = b . WorkPoint
where a . LotNo = ' { 0 } ' and a . WorkPoint = ' { 1 } '
";
sql = string . Format ( sql , LotNo , WorkPoint ) ;
DataTable dt = DBHelper . SQlReturnData ( sql , cmd ) ;
if ( dt . Rows . Count = = 0 )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo369" ) ) ;
}
else
{
LotEnable = dt . Rows [ 0 ] [ "LotEnable" ] . ToString ( ) ;
PrintEnable = dt . Rows [ 0 ] [ "PrintEnable" ] . ToString ( ) ;
}
if ( ! LotEnable . Equals ( "False" ) )
{
#region 获取分批后的条码(lotstr)
sql = @ "SELECT TOP 1 LotNO FROM ICSInventoryLot WHERE EATTRIBUTE1='{0}' AND WorkPoint='{1}'
ORDER BY CAST ( SUBSTRING ( LotNO , ( LEN ( LotNO ) - CHARINDEX ( '-' , REVERSE ( LotNO ) ) + 1 ) + 1 , CHARINDEX ( '-' , REVERSE ( LotNO ) ) - 1 ) AS INT ) DESC ";
sql = string . Format ( sql , LotNo , WorkPoint ) ;
dt = DBHelper . SQlReturnData ( sql , cmd ) ;
if ( dt . Rows . Count = = 0 )
{
lotstr = LotNo + "-" + 1 ;
}
else
{
lotstr = LotNo + "-" + ( Convert . ToInt32 ( dt . Rows [ 0 ] [ "LotNO" ] . ToString ( ) . Split ( '-' ) [ dt . Rows [ 0 ] [ "LotNO" ] . ToString ( ) . Split ( '-' ) . Length - 1 ] ) + 1 ) . ToString ( ) ;
}
NewBarCodeList . Add ( lotstr ) ; //将分批后新条码添加到新集合
#endregion
#region 将分批后的条码记录插入条码表,库存表及日志表并将原条码库存数量清零
sql = @ "INSERT INTO ICSInventoryLot(ID,LotNo,InvCode,ProductDate,ExpirationDate,
Quantity , Amount , ExtensionID , Type , PrintTimes ,
LastPrintUser , LastPrintTime , MUSER , MUSERName , MTIME ,
WorkPoint , EATTRIBUTE1 )
SELECT TOP 1 NEWID ( ) , ' { 0 } ' , a . InvCode , a . ProductDate , a . ExpirationDate ,
' { 2 } ' , a . Amount , a . ExtensionID , a . Type , a . PrintTimes ,
a . LastPrintUser , a . LastPrintTime , a . MUSER , a . MUSERName , GETDATE ( ) ,
a . WorkPoint , ' { 1 } '
From ICSInventoryLot a
where a . LotNo = ' { 1 } ' and a . WorkPoint = ' { 3 } ' ";
sql = string . Format ( sql , lotstr , LotNo , Quantity , WorkPoint ) ;
cmd . CommandText = sql ;
result = cmd . ExecuteNonQuery ( ) ;
if ( result < = 0 )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo195" ) ) ; //条码分批后条码表存入失败!
}
sql = @ "INSERT INTO ICSWareHouseLotInfo(ID,LotNO,WarehouseCode,LocationCode,InvCode,Quantity,InDate,LockQuantity,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1)
select NEWID ( ) , ' { 0 } ' , WarehouseCode , LocationCode , InvCode , ' { 2 } ' , InDate , LockQuantity
, MUSER , MUSERName , GETDATE ( ) , ' { 3 } ',' '
from ICSWareHouseLotInfo
where LotNO = ' { 1 } ' AND WorkPoint = ' { 3 } ' ";
sql = string . Format ( sql , lotstr , LotNo , Quantity , WorkPoint ) ;
cmd . CommandText = sql ;
result = cmd . ExecuteNonQuery ( ) ;
if ( result < = 0 )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo196" ) ) ; //条码分批后库存表存入失败!
}
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 , LogID )
SELECT NEWID ( ) , ' { 3 } ',' { 4 } ',' { 5 } ' , a . LotNo , a . InvCode ,
c . WarehouseCode , c . LocationCode , ' ',' ',' { 6 } ' ,
' ',' 0 ',' 1 0 5 ',' { 8 } ',' 0 ',' ' ,
' ',' ',' ' , f . F_Account , f . F_RealName ,
SYSDATETIME ( ) , a . WorkPoint , ' { 1 0 } ',' { 9 } '
FROM ICSInventoryLot a
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 , LotNo , WorkPoint , User , Identification , TransCode , TransSequence , Quantity , TransType , BusinessCode , MergeID , lotstr ) ;
cmd . CommandText = sql ;
result = cmd . ExecuteNonQuery ( ) ;
if ( result < = 0 )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo197" ) ) ; //条码分批后库存日志表存入失败!
}
//sql = @"update ICSWareHouseLotInfo set Quantity-={2}
// where LotNO='{0}' AND WorkPoint='{1}'";
//sql = string.Format(sql, LotNo, WorkPoint, Quantity);
//cmd.CommandText = sql;
//result = cmd.ExecuteNonQuery();
//if (result <= 0)
//{
// throw new Exception(language.GetNameByCode("WMSAPIInfo198"));//条码分批后库存表原条码数量更新失败!
//}
//if (PrintEnable.Equals("1"))
//{
// sql = @"select A.LotNO AS OLDLotNo , C.LotQty AS OLDLotQty, A.eattribute1 as LotNO, B.LotQty AS LotQty ,b.ItemCODE,d.INVSTD,d.INVNAME,b.MTIME,d.INVUOM,b.VenderLotNO,b.TransNO
// from ICSWareHouseLotInfolog A
// left join ICSInventoryLot B on A.eattribute1=B.LotNO and a.WorkPoint=b.WorkPoint
// left join ICSWareHouseLotInfo C ON A.LotNO=C.LotNO and a.WorkPoint=c.WorkPoint
// left join ICSInventory D on b.INVCODE=d.INVCODE and b.WorkPoint=d.WorkPoint
// where a.transtype ='105'
// and A.lotno like'{0}%' and a.workpoint='{1}' and a.eattribute1='{2}'
// ";
// sql = string.Format(sql, LotNo, WorkPoint, lotstr);
//}
///添加日志
///添加日志
sql = @ "IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
sql = @ "IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
BEGIN
BEGIN
@ -177,6 +311,45 @@ namespace ICSSoft.DataProject
{
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo166" ) ) ;
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo166" ) ) ;
}
}
#endregion
}
else
{
NewBarCodeList . Add ( LotNo ) ;
///添加日志
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 } ") + @" ' , 1 6 , 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 , MergeID )
SELECT NEWID ( ) , ' { 3 } ',' { 4 } ',' { 5 } ' , a . LotNo , a . InvCode ,
c . WarehouseCode , c . LocationCode , ' ',' ',' { 6 } ' ,
' ',' 0 ',' { 7 } ',' { 8 } ',' 0 ',' ' ,
' ',' ',' ' , f . F_Account , f . F_RealName ,
SYSDATETIME ( ) , a . WorkPoint , ' ',' { 9 } '
FROM ICSInventoryLot a
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 , LotNo , WorkPoint , User , Identification , TransCode , TransSequence , Quantity , TransType , BusinessCode , MergeID ) ;
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo166" ) ) ;
}
}
}
}
catch ( Exception )
catch ( Exception )
{
{