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.
 
 
 
 
 

211 lines
6.5 KiB

using NFine.Data.Extensions;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using NFine.Code;
using NFine.Repository;
using System.Data.Common;
using NFine.Domain._03_Entity.SRM;
using Newtonsoft.Json;
using System.Configuration;
using System.Net;
using System.IO;
using Newtonsoft.Json.Linq;
namespace NFine.Application.OMAY
{
public class OMAYSalesDeliveryApp : RepositoryFactory<ICSVendor>
{
public DataTable GetSalesDeliveryInfo(string Code, ref Pagination jqgridparam)
{
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string UserName = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string User = UserName.Substring(0, 2);
List<DbParameter> parameter = new List<DbParameter>();
DataTable table = new DataTable();
string sql = @" select Row_Number() OVER (ORDER BY SDNCode desc) AS ID, SDNCode,CusCode,CusName,CreatePerson from (
select distinct SDNCode,CusCode,CusName,CreatePerson from ICSSDN where Type='1' ) a where 1=1 ";
if (!string.IsNullOrEmpty(Code))
{
sql += " and SDNCode like '%" + Code + "%'";
}
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
//{
// sql += " and a.DepName='" + User + "'";
//}
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
}
public DataTable GetSalesByCode(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string UserName = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string User = UserName.Substring(0, 2);
#region [SQL]
string sql = @"
select a.ID,a.SDNCode,a.Sequence,a.InvCode,b.InvName,b.InvDesc,b.InvUnit,b.InvStd,d.WarehouseName,a.Quantity,a.Amount,a.SDNQuantity,c.BatchCode
from dbo.ICSSDN a
left join dbo.ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join dbo.ICSExtension c on a.ExtensionID=c.ID and a.WorkPoint=c.WorkPoint
left join dbo.ICSWarehouse d on a.WHCode=d.WarehouseCode and a.WorkPoint=d.WorkPoint";
sql += " WHERE 1=1 and a.SDNCode='" + queryParam["Code"].ToString() + "'";
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
//{
// sql += " and c.DepName='" + User + "'";
//}
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
}
public DataTable GetMoPicksByCode(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
#region [SQL]
string sql = @" select a.ID,a.MODetailID,a.Sequence,a.InvCode,b.InvName,b.InvDesc,b.InvUnit,b.InvStd,a.Quantity,a.IssueQuantity from dbo.ICSMOPick a
left join dbo.ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint";
sql += " WHERE 1=1 and a.MODetailID='" + queryParam["MODetailID"].ToString() + "'";
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
}
public object GetLotNotInfo(string keyValue)
{
DataTable dt = new DataTable();
string msg = "";
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "AMBarCodeInformation/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 == "")
{
string Data = Obj["Data"].ToString();
dt = JsonConvert.DeserializeObject<DataTable>(Data);
// dt = dataSet.Tables[0];
}
}
var Header = new
{
msg = msg,
dt = dt,
};
return Header;
}
public string SaveSalesDelivery(string ICSASN)
{
string msg = "";
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "LOTStockDownAM/Create";
string result = 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);
}
}
}
}