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.
 
 
 
 
 

208 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 OMAYMoOutboundApp : RepositoryFactory<ICSVendor>
{
public DataTable GetMoInfo( 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 MOCode desc) AS ID,a.MOCode,a.DepName from
(select distinct a.MOCode,b.DepName from dbo.ICSMO a
inner join ICSDepartment b on a.DepCode=b.DepCode and a.WorkPoint=b.WorkPoint where a.ApsStatus='Y')a where 1=1 ";
if (!string.IsNullOrEmpty(Code))
{
sql += " and a.MOCode 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 GetMosByCode(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.MOCode,a.Sequence,a.InvCode,b.InvName,b.InvDesc,b.InvUnit,b.InvStd,a.Quantity,a.Amount,a.MODetailID,c.DepName from dbo.ICSMO a
left join dbo.ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
inner join ICSDepartment c on a.DepCode=c.DepCode and a.WorkPoint=c.WorkPoint ";
sql += " WHERE 1=1 and a.MOCode='"+ 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,b.EATTRIBUTE1,a.Amount 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.EATTRIBUTE1 <> '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 OutboundShipments(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);
}
}
}
}