Browse Source

拣料增加判断 type等于2 5 12的单据才调用货柜接口

master
陆晔 2 years ago
parent
commit
a1cac0b4ab
  1. 165
      WMS-BS/NFine.Application/WMS/PickMaterialApp.cs

165
WMS-BS/NFine.Application/WMS/PickMaterialApp.cs

@ -2030,106 +2030,109 @@ c.Sequence,
var pikTbLogTime = DateTime.Now;
string pikTbLogsql = string.Empty;
List<string> DocNoList = new List<string>();
#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++)
if (Type == "2" || Type == "12" || Type == "5")
{
string hgsql = @"select A.InvCode,A.LocationCode,B.F_Define3,C.LocationCode AS Area
#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()))
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)
{
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())
if (!DocNoList.Contains(table.Rows[i]["Code"].ToString()))
{
InspectJosnBody += "\"RIG_HOSTINF\": \"" + table.Rows[i]["Sequence"].ToString() + Count.ToString() + "\"";
Count++;
DocNoList.Add(table.Rows[i]["Code"].ToString());
}
else
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() + "\"";
Count = 1;
}
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.TrimEnd(',');
if (InspectJosnBody != "")
{
InspectJosn = InspectJosn.Replace("货柜主表区域预留", InspectJosnHead);
InspectJosn = InspectJosn.Replace("货柜子表区域预留", InspectJosnBody);
if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadERP"]))
InspectJosnBody.TrimEnd(',');
foreach (string DocNo in DocNoList)
{
string callresult = "";
#region 货柜接口调用前日志
object logID = Guid.NewGuid();
string logsql = @"insert into ICSWMS_HGLog
InspectJosnHead += "{";
InspectJosnHead += "\"ORD_ORDINE\":\"" + DocNo.TrimStart('\'').TrimEnd('\'') + "\",";
InspectJosnHead += "\"ORD_DES\":\"" + TransType + "\",";
InspectJosnHead += "\"ORD_TIPOOP\":\"P\",";
InspectJosnHead += "\"ORD_CLIENTE\":\"" + WorkPoint + "\"";
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}'
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 + "");
//}
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
}
#endregion
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')

Loading…
Cancel
Save