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.
217 lines
8.8 KiB
217 lines
8.8 KiB
using Newtonsoft.Json.Linq;
|
|
using Newtonsoft.Json;
|
|
using NFine.Data.Extensions;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using NFine.Repository;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.IO;
|
|
using System.Net;
|
|
using NFine.Code;
|
|
using System.Data.Common;
|
|
|
|
namespace NFine.Application.WMS
|
|
{
|
|
public class ICSOOPickApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
|
|
public static DataTable Invmes = new DataTable();
|
|
/// <summary>
|
|
/// 委外备料查询
|
|
/// </summary>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetOOPickApplyNeg(ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select a.ID
|
|
,a.OODetailID
|
|
,b.OOCode
|
|
,a.PickID
|
|
,a.ParentPickID
|
|
,a.ParentQuantity
|
|
,a.ParentAmount
|
|
,a.Sequence
|
|
,a.InvCode
|
|
,a.Quantity
|
|
,a.Amount
|
|
,a.IssueQuantity
|
|
,a.WHCode
|
|
,a.SupplyType
|
|
,a.ExtensionID
|
|
,a.MUSER
|
|
,a.MUSERName
|
|
,a.MTIME
|
|
,a.WorkPoint from ICSOOPick a
|
|
left join ICSOutsourcingOrder b on a.OODetailID = b.ID";
|
|
sql = string.Format(sql);
|
|
DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
/// <summary>
|
|
/// 委外备料删除
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
public string DeleteOOPickApplyNeg(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
|
|
sql += string.Format(@"DELETE FROM dbo.ICSOOPick WHERE Id IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
//sql += string.Format(@"DELETE FROM dbo.ICSMOApplyNegDetail WHERE ApplyNegCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 选择表格—委外订单行选择
|
|
/// </summary>
|
|
/// <param name="ID"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetINV(string OOCode, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
DataTable table = new DataTable();
|
|
string wherestr = "";
|
|
if (!string.IsNullOrEmpty(OOCode))
|
|
{
|
|
wherestr += " and a.OOCode like '%" + OOCode + "%'";
|
|
}
|
|
string sql = @"select a.ID,a.OOCode,a.Sequence,a.InvCode,a.Quantity,b.InvName,a.Status,a.InQuantity,e.VenName,g.DepName,isnull(p.Quantity,0) as PickQuantity,a.UnitPrice,a.Currency
|
|
from ICSOutsourcingOrder a
|
|
join ICSInventory b on a.InvCode = b.InvCode
|
|
left join ICSVendor e on a.VenCode = e.VenCode and a.WorkPoint = e.WorkPoint
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
left join ICSDepartment g on a.DepCode = g.DepCode and a.WorkPoint = g.WorkPoint
|
|
left join ICSOOPick p on a.OOCode = p.OODetailID and a.WorkPoint = p.WorkPoint
|
|
where a.Status != 3 and a.WorkPoint = '" + WorkPoint + "'" + wherestr;
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
|
|
}
|
|
public void ClearTemp()
|
|
{
|
|
Invmes.Rows.Clear();
|
|
}
|
|
public DataTable GetICSOOPickReturnTemporary(string ID)
|
|
{
|
|
string sql = @"select a.ID,a.OODetailID as OOID,a.Sequence,a.InvCode,a.Quantity,a.WHCode,a.MUSERName,a.MTIME,b.OOCode
|
|
,b.Quantity as OOQuantity,b.Sequence as OOSequence,c.InvName
|
|
from ICSOOPick a
|
|
join ICSOutsourcingOrder b on a.OODetailID = b.ID
|
|
join ICSInventory c on a.InvCode = c.InvCode and a.WorkPoint = c.WorkPoint
|
|
where a.ID in (" + ID + ") ";
|
|
DataTable table = Repository().FindDataSetBySql(sql).Tables[0];
|
|
DataTable dtCloned = table.Clone();
|
|
foreach (DataColumn col in dtCloned.Columns)
|
|
{
|
|
col.DataType = typeof(string);
|
|
}
|
|
foreach (DataRow row in table.Rows)
|
|
{
|
|
DataRow newrow = dtCloned.NewRow();
|
|
foreach (DataColumn column in dtCloned.Columns)
|
|
{
|
|
newrow[column.ColumnName] = row[column.ColumnName].ToString();
|
|
|
|
}
|
|
dtCloned.Rows.Add(newrow);
|
|
}
|
|
if (Invmes.Rows.Count > 0)
|
|
{
|
|
dtCloned.Merge(Invmes, false);
|
|
}
|
|
return dtCloned;
|
|
}
|
|
/// <summary>
|
|
/// 新增
|
|
/// </summary>
|
|
/// <param name="ICSASN"></param>
|
|
/// <returns></returns>
|
|
public string SaveICSOOPickAppApplyNeg(string ICSASN)
|
|
{
|
|
string msg = "";
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "OOPick/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;
|
|
}
|
|
/// <summary>
|
|
/// 修改
|
|
/// </summary>
|
|
/// <param name="ICSASN"></param>
|
|
/// <returns></returns>
|
|
public string UpdateICSOOPickApplyNeg(string ICSASN)
|
|
{
|
|
string msg = "";
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "OOPick/Update";
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// 接口api解析
|
|
/// </summary>
|
|
/// <param name="url"></param>
|
|
/// <param name="body"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|