@ -1880,7 +1880,7 @@ a.ExtensionID
tableName = @ "ICSOApplyNegDetail a
INNER JOIN ICSOApplyNeg d ON a . OApplyNegCode = d . OApplyNegCode AND a . WorkPoint = d . WorkPoint ";
where = @" a.WorkPoint='{1}' AND d.Status='1 ' AND a.Quantity>a.IssueNegQuantity AND d.Type='1'" ;
where = @" a.WorkPoint='{1}' AND d.Status='2 ' AND a.Quantity>a.IssueNegQuantity AND d.Type='1'" ;
}
#endregion
#region 生产发料(合并发料)
@ -2815,6 +2815,10 @@ a.ExtensionID
zlqty = zlltable . Rows [ 0 ] [ "Quantity" ] . ToString ( ) ;
iszl = true ;
}
else
{
throw new Exception ( "该单据条码未拣配,请确认!" ) ;
}
}
}
}
@ -2847,7 +2851,7 @@ a.ExtensionID
columns = string . Format ( columns , zlqty ) ;
tableName = @ "ICSWareHouseLotInfoLog a
INNER JOIN ICSInventoryLot lot ON a . LotNo = lot . LotNo AND a . WorkPoint = lot . WorkPoint
INNER JOIN ICSInventoryLot lot ON a . LotNo = lot . LotNo AND a . WorkPoint = lot . WorkPoint and a . TransType = ' 1 5 '
INNER JOIN ICSExtension ext ON lot . ExtensionID = ext . ID AND lot . WorkPoint = ext . WorkPoint
INNER JOIN ICSWarehouse wh ON a . FromWarehouseCode = wh . WarehouseCode AND a . WorkPoint = wh . WorkPoint
INNER JOIN ICSLocation loc ON a . FromLocationCode = loc . LocationCode AND a . WorkPoint = loc . WorkPoint
@ -4128,6 +4132,19 @@ a.ExtensionID
| | TransType = = TransTypeEnum . ICSOutsourcingIssueDoNegativeIssue . GetDescription ( ) )
{
//更新源头单据数量
string chekksql = @ "select c.EATTRIBUTE1 FROM ICSOApplyNegDetail a
INNER JOIN ICSOApplyNeg d ON a . OApplyNegCode = d . OApplyNegCode AND a . WorkPoint = d . WorkPoint
INNER JOIN ICSInventory c on a . InvCode = c . InvCode and a . WorkPoint = c . WorkPoint
WHERE a . OApplyNegCode = ' { 0 } ' AND a . Sequence = ' { 3 } ' AND a . WorkPoint = ' { 1 } ' and c . AmountEnable = '1' ";
chekksql = string . Format ( chekksql , itemInfo . TransCode , item . WorkPoint , itemInfo . Quantity , itemInfo . TransSequence ) ;
DataTable dta = DBHelper . SQlReturnData ( chekksql , cmd ) ;
if ( dta . Rows . Count > 0 )
{
itemInfo . Quantity = ( decimal . Parse ( itemInfo . Quantity ) * decimal . Parse ( dta . Rows [ 0 ] [ "EATTRIBUTE1" ] . ToString ( ) ) ) . ToString ( ) ;
}
log . Debug ( "数量:" + itemInfo . Quantity ) ;
ICSOutsourcingService . OutsourcingIssueDoNegative ( TransType , itemInfo . LogID , itemInfo . LotNo , itemInfo . Quantity , item . WorkPoint , itemInfo . TransCode , itemInfo . TransSequence , cmd , language ) ;
BusinessCode = TransTypeEnum . ICSOutsourcingIssueDoNegative . GetDescription < DBValue > ( ) ;
}
@ -4181,6 +4198,7 @@ a.ExtensionID
// throw new Exception("当前扫描的条码物料和单据子件物料没有匹配的行,请确认!");
//}
string seq = itemInfo . TransSequence + "~" + drs [ 0 ] [ "Sequence" ] . ToString ( ) ;
itemInfo . TransSequence = seq ;
log . Debug ( "工单子件行号:" + seq ) ;
string chekksql = @ "select c.EATTRIBUTE1 FROM ICSMOPick a
INNER JOIN ICSMO b ON a . MODetailID = b . MODetailID AND a . WorkPoint = b . WorkPoint
@ -4492,6 +4510,106 @@ a.ExtensionID
}
/// <summary>
/// 库存调整(奥美专用)
/// </summary>BusinessCode,TransType 两个类型
/// <param name="JsonData"></param>
/// <returns></returns>
public static DataTable LOTUpdateAM ( List < LOTStockUpCreateIModel > JsonData )
{
var language = LanguageHelper . GetName ( "WMSAPIInfo" ) ;
if ( JsonData . Count < = 0 )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo007" ) ) ; //"传送数据为空!"
}
using ( SqlConnection conn = new System . Data . SqlClient . SqlConnection ( connString ) )
{
conn . Open ( ) ;
SqlTransaction sqlTran = conn . BeginTransaction ( ) ;
SqlCommand cmd = new SqlCommand ( ) ;
cmd . Transaction = sqlTran ;
cmd . Connection = conn ;
cmd . CommandTimeout = Convert . ToInt32 ( System . Configuration . ConfigurationManager . AppSettings [ "TimeOut" ] ) ;
string BusinessCode = string . Empty ;
try
{
string TransType = string . Empty ;
string sql = string . Empty ;
DataTable dtable = new DataTable ( ) ;
string TransTypeOriginal = string . Empty ; //记录不合格入库条码的原条码的类型
string Identification = Guid . NewGuid ( ) . ToString ( ) ;
foreach ( var item in JsonData )
{
TransType = "2" ;
BusinessCode = TransTypeEnum . LocationSeatch . GetDescription < DBValue > ( ) ;
if ( ! EnumHelper . HasDescriptions ( typeof ( TransTypeEnum ) , TransType ) )
{
throw new Exception ( LanguageHelper . GetNameSingle ( "WMSAPIInfo003" ) ) ; //"单据类型不存在!"
}
foreach ( var itemInfo in item . detail )
{
sql = @"UPDATE ICSWareHouseLotInfo set Quantity='{2}' WHERE lotno='{0}' AND WorkPoint='{1}'" ;
sql = string . Format ( sql , itemInfo . LotNo , item . WorkPoint , itemInfo . Quantity ) ;
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{
throw new Exception ( "库存调整失败!" ) ;
}
///添加日志
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 } ',' ',' ' , a . LotNo , a . InvCode ,
' ',' ',' ',' ',' { 6 } ' ,
' ',' 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 , itemInfo . LotNo , item . WorkPoint , item . User , Identification , TransType , BusinessCode , itemInfo . Quantity ) ;
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo166" ) ) ;
}
}
}
DataTable table = GetData ( Identification , 1 , cmd ) ;
cmd . Transaction . Commit ( ) ;
return table ;
}
catch ( Exception ex )
{
if ( cmd . Transaction ! = null )
cmd . Transaction . Rollback ( ) ;
log . Error ( ex . Message ) ;
throw new Exception ( ex . Message ) ;
}
finally
{
if ( conn . State = = ConnectionState . Open )
{
conn . Close ( ) ;
}
conn . Dispose ( ) ;
}
}
}
/// <summary>
/// 下架
/// </summary>
@ -7387,6 +7505,8 @@ END";
foreach ( var item in JsonData )
{
//获取单号
sql = @ "DECLARE @MaxNO INT,@date varchar(20)='OOIA'+SUBSTRING(CONVERT(varchar(8), GETDATE(), 112), 1, 8)
SELECT @MaxNO = SUBSTRING ( MAX ( OApplyNegCode ) , LEN ( @date ) + 1 , LEN ( MAX ( OApplyNegCode ) ) - LEN ( @date ) ) + 1 FROM ICSOApplyNeg
@ -7428,6 +7548,16 @@ END";
uniqueItems . Add ( key ) ;
string chekksql = @ "select c.EATTRIBUTE1 ICSInventory c
WHERE c . InvCode = ' { 0 } ' AND c . WorkPoint = ' { 1 } ' and c . AmountEnable = '1' ";
chekksql = string . Format ( chekksql , itemInfo . InvCode , itemInfo . WorkPoint ) ;
DataTable dta = DBHelper . SQlReturnData ( chekksql , cmd ) ;
if ( dta . Rows . Count > 0 )
{
itemInfo . Quantity = ( itemInfo . Quantity * decimal . Parse ( dta . Rows [ 0 ] [ "EATTRIBUTE1" ] . ToString ( ) ) ) ;
}
// 创建子表
sql = @ "INSERT INTO ICSOApplyNegDetail(ID,OApplyNegCode,Sequence,SourceDetailID,InvCode,
Quantity , Amount , IssueNegQuantity , ExtensionID , MUSER ,
@ -7570,15 +7700,17 @@ END";
foreach ( var itemInfo in item . detail )
{
string chekksql = @ "select c.EATTRIBUTE1 ICSInventory c
string chekksql = @ "select c.EATTRIBUTE1 from ICSInventory c
WHERE c . InvCode = ' { 0 } ' AND c . WorkPoint = ' { 1 } ' and c . AmountEnable = '1' ";
chekksql = string . Format ( chekksql , itemInfo . InvCode , itemInfo . WorkPoint ) ;
chekksql = string . Format ( chekksql , itemInfo . InvCode , item . WorkPoint ) ;
DataTable dta = DBHelper . SQlReturnData ( chekksql , cmd ) ;
if ( dta . Rows . Count > 0 )
{
itemInfo . Quantity = ( itemInfo . Quantity * decimal . Parse ( dta . Rows [ 0 ] [ "EATTRIBUTE1" ] . ToString ( ) ) ) ;
}
log . Debug ( "退料数量" + itemInfo . Quantity ) ;
string key = itemInfo . Sequence + "~" + itemInfo . InvCode ;
if ( uniqueItems . Contains ( key ) )
@ -7981,7 +8113,7 @@ END";
Code = DBHelper . ExecuteScalar ( sql , cmd ) . ToString ( ) ;
foreach ( var itemInfo in item . detail )
{
string chekksql = @ "select c.EATTRIBUTE1 ICSInventory c
string chekksql = @ "select c.EATTRIBUTE1 from ICSInventory c
WHERE c . InvCode = ' { 0 } ' AND c . WorkPoint = ' { 1 } ' and c . AmountEnable = '1' ";
chekksql = string . Format ( chekksql , itemInfo . InvCode , itemInfo . WorkPoint ) ;
DataTable dta = DBHelper . SQlReturnData ( chekksql , cmd ) ;
@ -11753,6 +11885,8 @@ END";
//1 - 不管控
//2 - 提醒
//3 - 限制
if ( dttt . Rows . Count > 0 & & dttt ! = null )
{
if ( dttt . Rows [ 0 ] [ "F_ItemName" ] . ToString ( ) = = "失效日期" )
{
sql = string . Format ( sql , LotNo , WorkPoitCode , "ISNULL(b.ExpirationDate,b.ProductDate)" , "ISNULL(y.ExpirationDate,y.ProductDate)" ) ;
@ -11765,6 +11899,12 @@ END";
{
sql = string . Format ( sql , LotNo , WorkPoitCode , "a.InDate" , "x.InDate" ) ;
}
}
else
{
sql = string . Format ( sql , LotNo , WorkPoitCode , "a.InDate" , "x.InDate" ) ;
}
if ( ! string . IsNullOrWhiteSpace ( ScanLotCode ) )
{
@ -16244,7 +16384,7 @@ a.ExtensionID
#region 原条码
if ( ScanType = = "LOTNO" )
{
sql = sql + @" AND log.BusinessCode IN('" + type + @ "') GROUP BY inv.AmountEnable,inv.LotEnable,log.ID,a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,a.WarehouseCode,
sql = sql + @" AND log.BusinessCode IN('" + type + @ "') and log.TransCode='{6}' GROUP BY inv.AmountEnable,inv.LotEnable,log.ID,a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,a.WarehouseCode,
wh . WarehouseName , a . LocationCode , loc . LocationName , CASE WHEN ( invBat . BatchEnable IS NULL AND ISNULL ( inv . BatchEnable , '0' ) = '1' ) OR ISNULL ( invBat . BatchEnable , '0' ) = '1' THEN ISNULL ( ext . BatchCode , ' ' ) ELSE ' ' END , inv . AmountUnit ,
ext . ID , ext . ProjectCode , ext . Version , ext . Brand , ext . cFree1 , ext . cFree2 , ext . cFree3 , ext . cFree4 , ext . cFree5 , ext . cFree6 , ext . cFree7 , ext . cFree8 , ext . cFree9 , ext . cFree10 , a . MUSER , a . MTIME
";
@ -16285,7 +16425,7 @@ a.ExtensionID
}
else
{
sql = sql + @" AND log.BusinessCode IN('" + type + @ "') GROUP BY inv.AmountEnable,inv.LotEnable,log.ID,a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,a.WarehouseCode,
sql = sql + @" AND log.BusinessCode IN('" + type + @ "') and log.TransCode='{6}' GROUP BY inv.AmountEnable,inv.LotEnable,log.ID,a.ID,con.ContainerCode,con.ContainerName,a.LotNo,a.InvCode,inv.InvName,inv.InvStd,inv.InvUnit,a.WarehouseCode,
wh . WarehouseName , a . LocationCode , loc . LocationName , CASE WHEN ( invBat . BatchEnable IS NULL AND ISNULL ( inv . BatchEnable , '0' ) = '1' ) OR ISNULL ( invBat . BatchEnable , '0' ) = '1' THEN ISNULL ( ext . BatchCode , ' ' ) ELSE ' ' END , inv . AmountUnit ,
ext . ID , ext . ProjectCode , ext . Version , ext . Brand , ext . cFree1 , ext . cFree2 , ext . cFree3 , ext . cFree4 , ext . cFree5 , ext . cFree6 , ext . cFree7 , ext . cFree8 , ext . cFree9 , ext . cFree10 , a . MUSER , a . MTIME
";
@ -16549,7 +16689,7 @@ a.ExtensionID
columns = string . Format ( columns , zlqty ) ;
tableName = @ "ICSWareHouseLotInfoLog a
INNER JOIN ICSInventoryLot lot ON a . LotNo = lot . LotNo AND a . WorkPoint = lot . WorkPoint
INNER JOIN ICSInventoryLot lot ON a . LotNo = lot . LotNo AND a . WorkPoint = lot . WorkPoint and a . TransType = ' 1 5 '
INNER JOIN ICSExtension ext ON lot . ExtensionID = ext . ID AND lot . WorkPoint = ext . WorkPoint
INNER JOIN ICSWarehouse wh ON a . FromWarehouseCode = wh . WarehouseCode AND a . WorkPoint = wh . WorkPoint
INNER JOIN ICSLocation loc ON a . FromLocationCode = loc . LocationCode AND a . WorkPoint = loc . WorkPoint
@ -17507,7 +17647,7 @@ a.ExtensionID
/// <summary>
/// 回撤拣配
/// 一键 回撤拣配
/// </summary>
/// <param name="JsonData"></param>
/// <returns></returns>
@ -17601,6 +17741,107 @@ a.ExtensionID
}
/// <summary>
/// 单个条码回撤拣配
/// </summary>
/// <param name="JsonData"></param>
/// <returns></returns>
public static DataTable BackPickMergeOne ( BarCodeModel JsonData )
{
String PrintEnable = "" ;
var language = LanguageHelper . GetName ( "WMSAPIInfo" ) ;
//if (JsonData.Count <= 0)
//{
// throw new Exception(language.GetNameByCode("WMSAPIInfo007"));//"传送数据为空!"
//}
List < LOTStockModelList > model = new List < LOTStockModelList > ( ) ;
DataTable printTable = new DataTable ( ) ;
using ( SqlConnection conn = new System . Data . SqlClient . SqlConnection ( connString ) )
{
conn . Open ( ) ;
SqlTransaction sqlTran = conn . BeginTransaction ( ) ;
SqlCommand cmd = new SqlCommand ( ) ;
cmd . Transaction = sqlTran ;
cmd . Connection = conn ;
cmd . CommandTimeout = Convert . ToInt32 ( System . Configuration . ConfigurationManager . AppSettings [ "TimeOut" ] ) ;
string BusinessCode = string . Empty ;
try
{
string TransType = string . Empty ;
string pikTbLogsql = "" ;
string Identification = Guid . NewGuid ( ) . ToString ( ) ;
//foreach (var item in JsonData)
//{
//TransType = item.TransType;
if ( ! EnumHelper . HasDescriptions ( typeof ( TransTypeEnum ) , JsonData . TransType ) )
{
throw new Exception ( LanguageHelper . GetNameSingle ( "WMSAPIInfo003" ) ) ; //"单据类型不存在!"
}
else if ( string . IsNullOrEmpty ( JsonData . TransCode ) )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo001" ) ) ; //"单据号不能为空!"
}
//string[] trans = item.TransCode.Split('~');
//string MergeID = "";
//if (trans.Length == 2)
//{
// MergeID = trans[0];
// item.TransCode = trans[1];
//}
#region 销售出库
else if ( JsonData . TransType = = TransTypeEnum . SalesShipmentDoc . GetDescription ( )
| | JsonData . TransType = = TransTypeEnum . MOIssueDoc . GetDescription ( )
| | JsonData . TransType = = TransTypeEnum . OutsourcingIssueDoc . GetDescription ( ) )
{
BusinessCode = TransTypeEnum . SalesShipmentDoc . GetDescription < DBValue > ( ) ;
pikTbLogsql = @ "IF NOT EXISTS(SELECT id FROM ICSWareHouseLotInfoLog where TransCode ='{0}' and lotno='{2}' and TransType='15' and WorkPoint='{1}')
BEGIN
RAISERROR ( ' 当 前 条 码 单 据 未 查 询 到 拣 配 记 录 , 请 确 认 ! ' , 1 6 , 1 ) ;
RETURN
END ";
//更新源头单据数量
pikTbLogsql + = @ " 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 lotno = ' { 2 } ' and TransType = ' 1 5 ' and WorkPoint = ' { 1 } ' group by LotNo ) c
on c . LotNo = b . LotNo ";
pikTbLogsql + = @" delete dbo.ICSWareHouseLotInfoLog where TransCode ='{0}' and lotno='{2}' and TransType='15' and WorkPoint='{1}'" ;
pikTbLogsql = string . Format ( pikTbLogsql , JsonData . TransCode , JsonData . WorkPoint , JsonData . Code ) ;
if ( ! DBHelper . ExecuteNonQuery ( pikTbLogsql , cmd ) )
{
throw new Exception ( "回撤拣料失败!" ) ;
}
}
#endregion
else
{
throw new Exception ( LanguageHelper . GetNameSingle ( "WMSAPIInfo003" ) ) ; //"单据类型不存在!"
}
//}
DataTable table = null ;
cmd . Transaction . Commit ( ) ;
return table ;
}
catch ( Exception ex )
{
if ( cmd . Transaction ! = null )
cmd . Transaction . Rollback ( ) ;
log . Error ( ex . Message ) ;
throw new Exception ( ex . Message ) ;
}
finally
{
if ( conn . State = = ConnectionState . Open )
{
conn . Close ( ) ;
}
conn . Dispose ( ) ;
}
}
}
/// <summary>
/// 回撤拣配
/// </summary>