@ -2067,106 +2067,120 @@ c.Sequence,
if ( Type = = "2" | | Type = = "12" | | Type = = "5" )
{
#region 货柜
string InspectJosn = "" ;
string InspectJosnHead = "" ;
string InspectJosnBody = "" ;
InspectJosn + = "{" ;
InspectJosn + = "\"IMP_ORDINI\":[" ;
InspectJosn + = "货柜主表区域预留" ;
InspectJosn + = "]," ;
InspectJosn + = "\"IMP_ORDINI_RIGHE\":[" ;
InspectJosn + = "货柜子表区域预留" ;
InspectJosn + = "]" ;
InspectJosn + = "}" ;
for ( int i = 0 ; i < table . Rows . Count ; i + + )
{
string hgsql = @ "select A.InvCode,A.LocationCode,B.F_Define3,C.LocationCode AS Area
from ICSWareHouseLotInfo A
INNER JOIN Sys_SRM_ItemsDetail B ON B . F_Define2 = A . LocationCode AND F_Define4 = A . WorkPoint AND F_ItemName = ' HG_Location '
INNER JOIN ICSInventoryDetail C ON C . INVCode = A . InvCode AND C . WHCode = A . WarehouseCode AND C . WorkPoint = A . WorkPoint
where A . LotNo = ' { 0 } ' AND A . WorkPoint = ' { 1 } ' ";
hgsql = string . Format ( hgsql , table . Rows [ i ] [ "LotNO" ] . ToString ( ) , WorkPoint ) ;
var hgds = Repository ( ) . FindDataSetBySql ( hgsql ) ;
if ( hgds . Tables . Count = = 0 )
return null ;
DataTable hgtable = hgds . Tables [ 0 ] ;
if ( hgtable . Rows . Count > 0 )
{
if ( ! DocNoList . Contains ( table . Rows [ i ] [ "Code" ] . ToString ( ) ) )
{
DocNoList . Add ( table . Rows [ i ] [ "Code" ] . ToString ( ) ) ;
}
InspectJosnBody + = "{" ;
InspectJosnBody + = "\"RIG_ORDINE\":\"" + table . Rows [ i ] [ "Code" ] . ToString ( ) + "\"," ;
InspectJosnBody + = "\"RIG_ARTICOLO\": \"" + hgtable . Rows [ 0 ] [ "InvCode" ] . ToString ( ) + "\"," ;
InspectJosnBody + = "\"RIG_SUB1\": \"\"," ;
InspectJosnBody + = "\"RIG_SUB2\": \"\"," ;
InspectJosnBody + = "\"RIG_ELERUOLI_GEST\": \"" + hgtable . Rows [ 0 ] [ "Area" ] . ToString ( ) + "\"," ;
InspectJosnBody + = "\"RIG_ELEBAIE\": \"" + hgtable . Rows [ 0 ] [ "F_Define3" ] . ToString ( ) + "\"," ;
InspectJosnBody + = "\"RIG_QTAR\": " + table . Rows [ i ] [ "SendQTY" ] . ToString ( ) + "," ;
if ( i = = 0 )
{
InspectJosnBody + = "\"RIG_HOSTINF\": \"" + table . Rows [ i ] [ "Sequence" ] . ToString ( ) + "\"" ;
}
else
{
if ( table . Rows [ i ] [ "Code" ] . ToString ( ) = = table . Rows [ i - 1 ] [ "Code" ] . ToString ( ) & &
table . Rows [ i ] [ "Sequence" ] . ToString ( ) = = table . Rows [ i - 1 ] [ "Sequence" ] . ToString ( ) )
{
InspectJosnBody + = "\"RIG_HOSTINF\": \"" + table . Rows [ i ] [ "Sequence" ] . ToString ( ) + Count . ToString ( ) + "\"" ;
Count + + ;
}
else
{
InspectJosnBody + = "\"RIG_HOSTINF\": \"" + table . Rows [ i ] [ "Sequence" ] . ToString ( ) + "\"" ;
Count = 1 ;
}
}
InspectJosnBody + = "}," ;
}
}
InspectJosnBody = InspectJosnBody . TrimEnd ( ',' ) ;
foreach ( string DocNo in DocNoList )
{
InspectJosnHead + = "{" ;
InspectJosnHead + = "\"ORD_ORDINE\":\"" + DocNo . TrimStart ( '\'' ) . TrimEnd ( '\'' ) + "\"," ;
InspectJosnHead + = "\"ORD_DES\":\"" + TransType + "\"," ;
InspectJosnHead + = "\"ORD_TIPOOP\":\"P\"," ;
InspectJosnHead + = "\"ORD_CLIENTE\":\"" + WorkPoint + "\"" ;
InspectJosnHead + = "}," ;
}
InspectJosnHead = InspectJosnHead . TrimEnd ( ',' ) ;
if ( InspectJosnBody ! = "" )
{
InspectJosn = InspectJosn . Replace ( "货柜主表区域预留" , InspectJosnHead ) ;
InspectJosn = InspectJosn . Replace ( "货柜子表区域预留" , InspectJosnBody ) ;
if ( Convert . ToBoolean ( System . Configuration . ConfigurationManager . AppSettings [ "UploadERP" ] ) )
{
string callresult = "" ;
#region 货柜接口调用前日志
object logID = Guid . NewGuid ( ) ;
string logsql = @ "insert into ICSWMS_HGLog
values
( ' { 0 } ' , GETDATE ( ) , ' { 1 } ',' { 2 } ',' { 3 } ',' { 4 } ',' { 5 } ' ) ";
logsql = string . Format ( logsql , logID , InspectJosn , "" , WorkPoint , MUSER , MUSERNAME ) ;
SqlHelper . CmdExecuteNonQueryLi ( logsql ) ;
#endregion
callresult = HTTPHelper . RestFulGet ( InspectJosn , postUrlStr ) ;
#region 货柜接口调用后日志
logsql = @ "update ICSWMS_HGLog set ReturnResult='{0}'
where ID = ' { 1 } ' ";
logsql = string . Format ( logsql , callresult , logID ) ;
SqlHelper . CmdExecuteNonQueryLi ( logsql ) ;
#endregion
//if (!callresult.Contains("successo"))
//{
// ICSHGResult hgresult = JsonConvert.DeserializeObject<ICSHGResult>(callresult.TrimStart('[').TrimEnd(']'));
// throw new Exception("货柜单据传输接口调用报错,主要报错信息:" + hgresult.PrimaryError + ",次要报错信息:" + hgresult.SecondaryError + "");
//}
}
}
//string InspectJosn = "";
//string InspectJosnHead = "";
//string InspectJosnBody = "";
//InspectJosn += "{";
//InspectJosn += "\"IMP_ORDINI\":[";
//InspectJosn += "货柜主表区域预留";
//InspectJosn += "],";
//InspectJosn += "\"IMP_ORDINI_RIGHE\":[";
//InspectJosn += "货柜子表区域预留";
//InspectJosn += "]";
//InspectJosn += "}";
//for (int i = 0; i < table.Rows.Count; i++)
//{
// string hgsql = @ "select A.InvCode,A.LocationCode,B.F_Define3,C.LocationCode AS Area
// from ICSWareHouseLotInfo A
// INNER JOIN Sys_SRM_ItemsDetail B ON B.F_Define2=A.LocationCode AND F_Define4=A.WorkPoint AND F_ItemName='HG_Location'
// INNER JOIN ICSInventoryDetail C ON C.INVCode=A.InvCode AND C.WHCode=A.WarehouseCode AND C.WorkPoint=A.WorkPoint
// where A.LotNo='{0}' AND A.WorkPoint='{1}' ";
// hgsql = string.Format(hgsql, table.Rows[i]["LotNO"].ToString(), WorkPoint);
// var hgds = Repository().FindDataSetBySql(hgsql);
// if (hgds.Tables.Count == 0)
// return null;
// DataTable hgtable = hgds.Tables[0];
// if (hgtable.Rows.Count > 0)
// {
// if (!DocNoList.Contains(table.Rows[i]["Code"].ToString()))
// {
// DocNoList.Add(table.Rows[i]["Code"].ToString());
// }
// InspectJosnBody += "{";
// InspectJosnBody += "\"RIG_ORDINE\":\"" + table.Rows[i]["Code"].ToString() + "\",";
// InspectJosnBody += "\"RIG_ARTICOLO\": \"" + hgtable.Rows[0]["InvCode"].ToString() + "\",";
// InspectJosnBody += "\"RIG_SUB1\": \"\",";
// InspectJosnBody += "\"RIG_SUB2\": \"\",";
// InspectJosnBody += "\"RIG_ELERUOLI_GEST\": \"" + hgtable.Rows[0]["Area"].ToString() + "\",";
// InspectJosnBody += "\"RIG_ELEBAIE\": \"" + hgtable.Rows[0]["F_Define3"].ToString() + "\",";
// InspectJosnBody += "\"RIG_QTAR\": " + table.Rows[i]["SendQTY"].ToString() + ",";
// if (i == 0)
// {
// InspectJosnBody += "\"RIG_HOSTINF\": \"" + table.Rows[i]["Sequence"].ToString() + "\"";
// }
// else
// {
// if (table.Rows[i]["Code"].ToString() == table.Rows[i - 1]["Code"].ToString() &&
// table.Rows[i]["Sequence"].ToString() = = table.Rows[i - 1]["Sequence"].ToString())
// {
// InspectJosnBody += "\"RIG_HOSTINF\": \"" + table.Rows[i]["Sequence"].ToString() + Count.ToString() + "\"";
// Count++;
// }
// else
// {
// InspectJosnBody += "\"RIG_HOSTINF\": \"" + table.Rows[i]["Sequence"].ToString() + "\"";
// Count = 1;
// }
// }
// InspectJosnBody += "},";
// }
//}
//InspectJosnBody = InspectJosnBody.TrimEnd(',');
//foreach (string DocNo in DocNoList)
//{
// InspectJosnHead += "{";
// InspectJosnHead += "\"ORD_ORDINE\":\"" + DocNo.TrimStart('\'').TrimEnd('\'') + "\",";
// InspectJosnHead += "\"ORD_DES\":\"" + TransType + "\",";
// InspectJosnHead += "\"ORD_TIPOOP\":\"P\",";
// InspectJosnHead += "\"ORD_CLIENTE\":\"" + WorkPoint + "\"";
// InspectJosnHead += "},";
//}
//InspectJosnHead = InspectJosnHead.TrimEnd(',');
//if (InspectJosnBody != "")
//{
// InspectJosn = InspectJosn.Replace("货柜主表区域预留", InspectJosnHead);
// InspectJosn = InspectJosn.Replace("货柜子表区域预留", InspectJosnBody);
// if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadERP"]))
// {
// string callresult = "";
// #region 货柜接口调用前日志
// object logID = Guid.NewGuid();
// string logsql = @ "insert into ICSWMS_HGLog
// values
// ('{0}',GETDATE(),'{1}','{2}','{3}','{4}','{5}') ";
// logsql = string.Format(logsql, logID, InspectJosn, "", WorkPoint, MUSER, MUSERNAME);
// SqlHelper.CmdExecuteNonQueryLi(logsql);
// #endregion
// callresult = HTTPHelper.RestFulGet(InspectJosn, postUrlStr);
// #region 货柜接口调用后日志
// logsql = @ "update ICSWMS_HGLog set ReturnResult='{0}'
// where ID='{1}' ";
// logsql = string.Format(logsql, callresult, logID);
// SqlHelper.CmdExecuteNonQueryLi(logsql);
// #endregion
// //if (!callresult.Contains("successo"))
// //{
// // ICSHGResult hgresult = JsonConvert.DeserializeObject<ICSHGResult>(callresult.TrimStart('[').TrimEnd(']'));
// // throw new Exception("货柜单据传输接口调用报错,主要报错信息:" + hgresult.PrimaryError + ",次要报错信息:" + hgresult.SecondaryError + "");
// //}
// }
//}
#endregion
}
// sql += 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 in ({0})and TransType='15' and WorkPoint='{1}' group by LotNo) c
//on c.LotNo =b.LotNo ", objCode.TrimEnd(','), WorkPoint);
//sql += string.Format(@" delete dbo.ICSWareHouseLotInfoLog where TransCode in({0}) and TransType='15' and WorkPoint='{1}'", objCode.TrimEnd(','), WorkPoint);
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 in ( { 0 } ) and TransType = ' 1 5 ' and WorkPoint = ' { 1 } ' group by LotNo ) c
on c . LotNo = b . LotNo
delete dbo . ICSWareHouseLotInfoLog where TransCode in ( { 0 } ) and TransType = ' 1 5 ' and WorkPoint = ' { 1 } ' ";
pikTbLogsql = string . Format ( pikTbLogsql , ID , WorkPoint ) ;
foreach ( DataRow PickLog in table . Rows )
{
pikTbLogsql + = @ " IF NOT EXISTS(SELECT TransCode FROM ICSWareHouseLotInfoLog WHERE TransCode='{1}' AND TransSequence='{2}' AND LotNo='{9}' AND WorkPoint='{8}' AND TransType='15')
@ -2191,7 +2205,52 @@ c.Sequence,
, BusinessCode , MUSER , MUSERNAME , pikTbLogTime , WorkPoint , PickLog [ "LotNO" ] . ToString ( ) ) ;
}
SqlHelper . CmdExecuteNonQueryLi ( pikTbLogsql ) ;
#region 重复性检查,如出现一个条码存在同一单据同一行重复占料的情况,删除重复行(插入时有验证,暂时注释)
//foreach (string DocCode in ID.Split(','))
//{
// string chklotno = "";
// string chktranscode = "";
// string chktranssequence = "";
// string rechksql = @"select TransCode,TransSequence,LotNo,Quantity from ICSWareHouseLotInfoLog
// where TransType='15' and TransCode={0}
// and WorkPoint='{1}'
// ORDER BY TransCode,TransSequence,LotNo";
// rechksql = string.Format(rechksql, DocCode, WorkPoint);
// var rechkds = Repository().FindDataSetBySql(rechksql);
// DataTable rechkdt = rechkds.Tables[0];
// foreach (DataRow dr in rechkdt.Rows)
// {
// if (chklotno == "")
// {
// chklotno = dr["LotNo"].ToString();
// chktranscode = dr["TransCode"].ToString();
// chktranssequence = dr["TransSequence"].ToString();
// }
// else
// {
// if (chklotno == dr["LotNo"].ToString() && chktranscode == dr["TransCode"].ToString()
// && chktranssequence == dr["TransSequence"].ToString())
// {
// string delsql = @"update ICSWareHouseLotInfo set LockQuantity-={5}
// where LotNo='{0}' and WorkPoint='{3}'
// delete from ICSWareHouseLotInfoLog
// where LotNo='{0}' and TransCode='{1}' and TransSequence='{2}'
// and WorkPoint='{3}' and Identification!='{4}'";
// delsql = string.Format(delsql, chklotno, chktranscode, chktranssequence, WorkPoint, Identification, dr["Quantity"].ToString());
// SqlHelper.CmdExecuteNonQueryLi(delsql);
// }
// else
// {
// chklotno = dr["LotNo"].ToString();
// chktranscode = dr["TransCode"].ToString();
// chktranssequence = dr["TransSequence"].ToString();
// }
// }
// }
//}
#endregion
#endregion
}
xxxxxxxxxx