You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
169 lines
6.4 KiB
169 lines
6.4 KiB
using NFine.Code;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using NFine.Repository;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Common;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Newtonsoft.Json.Linq;
|
|
using Newtonsoft.Json;
|
|
using NFine.Application.WMS;
|
|
using System.Configuration;
|
|
using NFine.Data.Extensions;
|
|
using System.IO;
|
|
using System.Net;
|
|
|
|
namespace NFine.Application.OMAY
|
|
{
|
|
public class ICSInvCodeHCApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
|
|
//包装容器关联条码
|
|
public DataTable GetSendContainerLot(ref Pagination jqgridparam, string queryJson)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select top 0 a.ID, a.LotNo,a.InvCode,'' AS LocationCode,'' AS WarehouseCode,a.Quantity,'' as LogID from ICSInventoryLot a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint";
|
|
|
|
sql = string.Format(sql);
|
|
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
public object GetLotInfo(string keyValue)
|
|
{
|
|
|
|
string LotNo = string.Empty;
|
|
string ID = string.Empty;
|
|
string InvCode = string.Empty;
|
|
decimal Quantity = 0;
|
|
string msg = "";
|
|
string LogID=string.Empty;
|
|
string LocationCode=string.Empty;
|
|
string WHCode=string.Empty;
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "BarCodeInformation/Get";
|
|
string result =HttpPost(APIURL, keyValue);
|
|
JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
|
|
string MessAge = Obj["Message"].ToString();
|
|
string Success = Obj["Success"].ToString();
|
|
|
|
if (Success.ToUpper() == "FALSE")
|
|
{
|
|
msg = MessAge;
|
|
}
|
|
else
|
|
{
|
|
if (msg == "")
|
|
{
|
|
//JObject dataObj = JObject.Parse(Obj["Data"].ToString());
|
|
//AvailQty = decimal.Parse(dataObj["AvailQty"].ToString());
|
|
//AllQty = decimal.Parse(dataObj["AllQty"].ToString());
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(Obj["Data"].ToString());
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
//var aa= jo["min_lotqty"].ToString();
|
|
ID = jo["ID"].ToString();
|
|
LotNo = jo["LotNo"].ToString();
|
|
InvCode = jo["InvCode"].ToString();
|
|
Quantity = Convert.ToDecimal( jo["Quantity"].ToString());
|
|
LogID = jo["LogID"].ToString();
|
|
LocationCode = jo["LocationCode"].ToString();
|
|
WHCode = jo["WHCode"].ToString();
|
|
}
|
|
}
|
|
}
|
|
var Header = new
|
|
{
|
|
msg = msg,
|
|
LotNo = LotNo,
|
|
ID = ID,
|
|
InvCode = InvCode,
|
|
Quantity = Quantity,
|
|
LogID= LogID,
|
|
LocationCode = LocationCode,
|
|
};
|
|
return Header;
|
|
}
|
|
public object GetLotLocationCode(string keySendLocationCode)
|
|
{
|
|
string WarehouseCode = string.Empty;
|
|
string msg = "";
|
|
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "LocationAM/Get";
|
|
string result2 = HttpPost(APIURL, keySendLocationCode);
|
|
JObject Obj2 = (JObject)JsonConvert.DeserializeObject(result2);//或者JObject jo = JObject.Parse(jsonText);
|
|
string MessAge2 = Obj2["Message"].ToString();
|
|
string Success2 = Obj2["Success"].ToString();
|
|
|
|
if (Success2.ToUpper() == "FALSE")
|
|
{
|
|
msg = MessAge2;
|
|
}
|
|
else
|
|
{
|
|
if (msg == "")
|
|
{
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(Obj2["Data"].ToString());
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
//var aa= jo["min_lotqty"].ToString();
|
|
WarehouseCode = jo["WarehouseCode"].ToString();
|
|
|
|
}
|
|
}
|
|
}
|
|
var Header = new
|
|
{
|
|
msg = msg,
|
|
WarehouseCode = WarehouseCode
|
|
};
|
|
return Header;
|
|
}
|
|
public string BindingICSInvCodeHC(string ICSASN)
|
|
{
|
|
string msg = "";
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "LOTStockUpAM/Create";
|
|
string result = DeciliterApp.HttpPost(APIURL, ICSASN);
|
|
JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
|
|
string MessAge = Obj["Message"].ToString();
|
|
string Success = Obj["Success"].ToString();
|
|
if (Success.ToUpper() == "FALSE")
|
|
{
|
|
msg = MessAge;
|
|
}
|
|
return msg;
|
|
}
|
|
//接口api解析
|
|
public static string HttpPost(string url, string body)
|
|
|
|
{
|
|
try
|
|
{
|
|
Encoding encoding = Encoding.UTF8;
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
|
request.Method = "POST";
|
|
request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
|
|
request.ContentType = "application/json; charset=utf-8";
|
|
|
|
byte[] buffer = encoding.GetBytes(body);
|
|
request.ContentLength = buffer.Length;
|
|
request.GetRequestStream().Write(buffer, 0, buffer.Length);
|
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
|
|
{
|
|
return reader.ReadToEnd();
|
|
}
|
|
}
|
|
catch (WebException ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|