@ -970,6 +970,132 @@ namespace ICSSoft.DataProject
}
#endregion
#region 料架信息
/// <summary>
/// 料架验证
/// </summary>
/// <param name="JsonData"></param>
/// <returns></returns>
public static Result ContainerCheck ( ICSContainerInfo JsonData )
{
var language = LanguageHelper . GetName ( "WMSAPIInfo" ) ;
DataTable table = new DataTable ( ) ;
string msg = "" ;
using ( SqlConnection conn = new System . Data . SqlClient . SqlConnection ( connString ) )
{
conn . Open ( ) ;
SqlCommand cmd = new SqlCommand ( ) ;
cmd . Connection = conn ;
try
{
string TransType = JsonData . TransType ;
string ContainerID = "" ;
if ( String . IsNullOrEmpty ( JsonData . ContainerCode ) )
{
msg = string . Format ( language . GetNameByCode ( "WMSAPIInfo007" ) ) ; //"传入数据为空!"
}
if ( String . IsNullOrEmpty ( JsonData . WorkPoint ) )
{
msg = string . Format ( language . GetNameByCode ( "WMSAPIInfo004" ) ) ; //"站点不能为空!"
}
if ( TransType ! = TransTypeEnum . ContainerBind . GetDescription ( ) & & TransType ! = TransTypeEnum . ContainerUnBind . GetDescription ( ) )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo199" ) ) ; //"操作类型错误!"
}
string chksql = @ "select ID,ContainerCode from ICSContainer
where ContainerCode = ' { 0 } ' AND WorkPoint = ' { 1 } ' ";
chksql = string . Format ( chksql , JsonData . ContainerCode , JsonData . WorkPoint ) ;
DataTable chkdt = DBHelper . SQlReturnData ( chksql , cmd ) ;
if ( chkdt . Rows . Count = = 0 )
{
msg = string . Format ( language . GetNameByCode ( "WMSAPIInfo195" ) , JsonData . ContainerCode ) ; //"容器不存在!"
}
else
{
ContainerID = chkdt . Rows [ 0 ] [ "ID" ] . ToString ( ) ;
}
if ( TransType = = TransTypeEnum . ContainerBind . GetDescription ( ) )
{
chksql = @ " select C.LotNo from ICSContainer A
INNER JOIN ICSContainerLot B ON B . ContainerID = A . ID AND B . WorkPoint = A . WorkPoint
INNER JOIN ICSWareHouseLotInfo C ON C . LotNo = B . LotNo AND C . WorkPoint = B . WorkPoint
WHERE A . ContainerCode = ' { 0 } ' AND A . WorkPoint = ' { 1 } ' ";
chksql = string . Format ( chksql , JsonData . ContainerCode , JsonData . WorkPoint ) ;
chkdt = DBHelper . SQlReturnData ( chksql , cmd ) ;
if ( chkdt . Rows . Count ! = 0 )
{
msg = string . Format ( language . GetNameByCode ( "WMSAPIInfo196" ) , JsonData . ContainerCode ) ; //"容器已入库!"
}
}
else
{
chksql = @ "select LotNo from ICSContainerLot
where ContainerID = ' { 0 } ' AND WorkPoint = ' { 1 } ' ";
chksql = string . Format ( chksql , ContainerID , JsonData . WorkPoint ) ;
chkdt = DBHelper . SQlReturnData ( chksql , cmd ) ;
if ( chkdt . Rows . Count = = 0 )
{
msg = string . Format ( language . GetNameByCode ( "WMSAPIInfo200" ) , JsonData . ContainerCode ) ; //"容器未绑定条码!"
}
else
{
string sql = @ "SELECT a.ID,
con . ContainerCode ,
con . ContainerName ,
a . LotNo ,
a . InvCode ,
inv . InvName ,
inv . InvStd ,
a . Quantity
FROM ICSWareHouseLotInfo a
LEFT JOIN ICSContainerLot conlot ON a . LotNo = conlot . LotNo AND a . WorkPoint = conlot . WorkPoint
LEFT JOIN ICSContainer con ON conlot . ContainerID = con . ID AND conlot . WorkPoint = con . WorkPoint
INNER JOIN ICSInventory inv ON a . InvCode = inv . InvCode AND a . WorkPoint = inv . WorkPoint
WHERE bom . ContainerCode = ' { 0 } ' AND a . WorkPoint = ' { 1 } ' ";
sql = string . Format ( sql , JsonData . ContainerCode , JsonData . WorkPoint ) ;
log . Info ( "条码sql:" + sql ) ;
table = DBHelper . SQlReturnData ( sql , cmd ) ;
}
}
Result res = new Result ( ) ;
if ( msg = = "" )
{
if ( TransType = = TransTypeEnum . ContainerBind . GetDescription ( ) )
{
res . Success = true ;
res . Message = msg ; // "接口调用成功!";
}
else
{
res . Success = true ;
res . Message = msg ; // "接口调用成功!";
res . Data = table ;
}
}
else
{
res . Success = false ;
res . Message = msg ; // "返回错误信息!";
}
return res ;
}
catch ( Exception ex )
{
log . Error ( ex . Message ) ;
throw new Exception ( ex . Message ) ;
}
finally
{
if ( conn . State = = ConnectionState . Open )
{
conn . Close ( ) ;
}
conn . Dispose ( ) ;
}
}
}
#endregion
#region 条码信息
/// <summary>
/// 条码信息
@ -1694,6 +1820,25 @@ namespace ICSSoft.DataProject
LEFT JOIN ( SELECT EATTRIBUTE1 AS LotNo , WorkPoint , EATTRIBUTE1 + '-' + CAST ( ( MAX ( CAST ( SUBSTRING ( LotNo , CHARINDEX ( '-' , LotNo ) + 1 , LEN ( LotNo ) - CHARINDEX ( '-' , LotNo ) ) AS INT ) ) + 1 ) AS VARCHAR ) AS SplitLotNo FROM ICSInventoryLot GROUP BY EATTRIBUTE1 , WorkPoint ) split ON a . LotNo = split . LotNo AND a . WorkPoint = split . WorkPoint
LEFT JOIN ICSInventoryBatchEnable invBat ON a . InvCode = invBat . InvCode AND a . WarehouseCode = invBat . WHCode AND a . WorkPoint = invBat . WorkPoint ";
}
else if ( TransType = = TransTypeEnum . LOTInfoGet . GetDescription ( ) )
{
sql = @ "IF EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' AND a.Quantity>0)
BEGIN
RAISERROR ( ' " + string.Format(language.GetNameByCode(" WMSAPIInfo039 "), " { 2 } ") + @" ' , 1 6 , 1 ) ;
RETURN
END
IF NOT EXISTS ( SELECT a . ID FROM ICSInventoryLot a WHERE a . LotNo = ' { 2 } ' AND a . WorkPoint = ' { 3 } ' )
BEGIN
RAISERROR ( ' " + string.Format(language.GetNameByCode(" WMSAPIInfo038 "), " { 2 } ") + @" ' , 1 6 , 1 ) ;
RETURN
END
" + sql;
columns = @"a.Quantity," ;
tableName = @ " ICSInventoryLot a
INNER JOIN ICSExtension ext ON ext . ID = a . ExtensionID AND ext . WorkPoint = a . WorkPoint ";
}
//出库条码
else if ( isOut )
{
@ -1862,11 +2007,13 @@ namespace ICSSoft.DataProject
{ //生产退料
columnsWHCODE = @ "(SELECT negg.WHCODE FROM ICSMOApplyNegDetail neg LEFT JOIN ICSMOApplyNeg negg ON neg.ApplyNegCode=negg.ApplyNegCode
WHERE lotdd . TransCode = neg . ApplyNegCode AND lotdd . TransSequence = neg . Sequence AND lotdd . WorkPoint = neg . WorkPoint and negg . Type = '1' ) AS WHCode ";
} else if ( LotType . Equals ( "2" ) )
}
else if ( LotType . Equals ( "2" ) )
{ //委外退料
columnsWHCODE = @ "(SELECT negg.WHCODE FROM ICSOApplyNegDetail neg LEFT JOIN ICSOApplyNeg negg ON neg.OApplyNegCode=negg.OApplyNegCode
WHERE lotdd . TransCode = neg . OApplyNegCode AND lotdd . TransSequence = neg . Sequence AND lotdd . WorkPoint = neg . WorkPoint and negg . Type = '1' ) AS WHCode ";
} else if ( LotType . Equals ( "3" ) )
}
else if ( LotType . Equals ( "3" ) )
{ //工单
columnsWHCODE = @"(SELECT a.WHCode FROM ICSMO a WHERE a.MOCode=lotdd.TransCode AND a.Sequence=lotdd.TransSequence AND a.WorkPoint=lotdd.WorkPoint) AS WHCode" ;
}
@ -6185,6 +6332,79 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer
}
#endregion
#region 料架条码绑定/解绑
/// <summary>
/// 料架条码绑定
/// </summary>
/// <param name="JsonData"></param>
/// <returns></returns>
public static Result ContainerBindCreate ( List < ICSContainerBind > JsonData )
{
var language = LanguageHelper . GetName ( "WMSAPIInfo" ) ;
DataTable table = new DataTable ( ) ;
string msg = "" ;
using ( SqlConnection conn = new System . Data . SqlClient . SqlConnection ( connString ) )
{
conn . Open ( ) ;
SqlCommand cmd = new SqlCommand ( ) ;
cmd . Connection = conn ;
try
{
foreach ( ICSContainerBind item in JsonData )
{
string TransType = item . TransType ;
if ( JsonData . Count < = 0 )
{
msg = string . Format ( language . GetNameByCode ( "WMSAPIInfo007" ) ) ; //"传入数据为空!"
}
if ( String . IsNullOrEmpty ( item . WorkPoint ) )
{
msg = string . Format ( language . GetNameByCode ( "WMSAPIInfo004" ) ) ; //"站点不能为空!"
}
if ( String . IsNullOrEmpty ( item . LotNo ) )
{
msg = string . Format ( language . GetNameByCode ( "WMSAPIInfo005" ) ) ; //"条码不能为空!"
}
if ( String . IsNullOrEmpty ( item . ContainerCode ) )
{
msg = string . Format ( language . GetNameByCode ( "WMSAPIInfo197" ) ) ; //"料架不能为空!"
}
if ( TransType ! = TransTypeEnum . ContainerBind . GetDescription ( ) & & TransType ! = TransTypeEnum . ContainerUnBind . GetDescription ( ) )
{
msg = string . Format ( language . GetNameByCode ( "WMSAPIInfo199" ) ) ; //"操作类型错误!"
}
if ( TransType = = TransTypeEnum . ContainerBind . GetDescription ( ) )
{
//料架条码绑定
ICSWareHouseLotInfoService . ContainerBind ( item . LotNo , item . ContainerCode , item . ContainerType , item . User , item . WorkPoint , cmd , language ) ;
}
else
{
//料架条码解绑
ICSWareHouseLotInfoService . ContainerUnBind ( item . ContainerCode , item . WorkPoint , cmd , language ) ;
}
}
Result res = new Result ( ) ;
res . Success = true ;
res . Message = msg ; // "接口调用成功!";
return res ;
}
catch ( Exception ex )
{
log . Error ( ex . Message ) ;
throw new Exception ( ex . Message ) ;
}
finally
{
if ( conn . State = = ConnectionState . Open )
{
conn . Close ( ) ;
}
conn . Dispose ( ) ;
}
}
}
#endregion
}
}