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.
402 lines
16 KiB
402 lines
16 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 Newtonsoft.Json.Linq;
|
|
using System.Net;
|
|
using System.IO;
|
|
|
|
namespace NFine.Application.WMS
|
|
{
|
|
public class WWProductionRAFMRApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
public static DataTable WWPRInvmes = new DataTable();
|
|
public DataTable GetICSOApplyNeg(ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" select a.ID,a.OApplyNegCode,a.WHCode,b.WarehouseName,a.Status,a.Type,a.Memo,a.CreatePerson,a.CreateDateTime,a.MUSER,a.MUSERName
|
|
from ICSOApplyNeg a
|
|
left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
where a.Type='2'";
|
|
sql = string.Format(sql);
|
|
DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
public DataTable GetICSOApplyNegDetail(string OApplyNegCode, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select ID,OApplyNegCode,Sequence,SourceDetailID,InvCode,Quantity,Amount,IssueNegQuantity,ExtensionID,MUSER,MUSERName,MTIME from ICSOApplyNegDetail
|
|
WHERE OApplyNegCode='" + OApplyNegCode + "' ";
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
public string DeleteICSMOApplyNeg(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.ICSOApplyNeg WHERE OApplyNegCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
sql += string.Format(@"DELETE FROM dbo.ICSOApplyNegDetail WHERE OApplyNegCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
public DataTable GetICSReturnTemporary(string rfqno)
|
|
{
|
|
string sql = @"SELECT
|
|
a.OApplyNegCode,
|
|
a.InvCode,
|
|
a.Quantity,
|
|
a.Amount,
|
|
a.SourceDetailID as ZJID,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
a.IssueNegQuantity,
|
|
a.ExtensionID,
|
|
'' as tuinum
|
|
FROM
|
|
ICSOApplyNegDetail a
|
|
LEFT JOIN ICSInventory b ON a.InvCode = b.InvCode and a.WorkPoint=b.WorkPoint where a.OApplyNegCode='" + rfqno + "'";
|
|
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 (WWPRInvmes.Rows.Count > 0)
|
|
{
|
|
dtCloned.Merge(WWPRInvmes, false);
|
|
}
|
|
return dtCloned;
|
|
}
|
|
|
|
public DataTable GetINV(string invcode, 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(invcode))
|
|
{
|
|
wherestr += " and a.InvCode like '%" + invcode + "'%";
|
|
}
|
|
string sql = @" SELECT
|
|
a.ApplyDetailID AS ZJID,
|
|
a.ApplyCode,
|
|
a.Sequence AS MuHang,
|
|
a.InvCode,
|
|
a.Quantity,
|
|
a.Amount,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
a.IssueQuantity,
|
|
a.ExtensionID,
|
|
isnull(d.Quantity, 0) as tuinum
|
|
FROM ICSOApply a
|
|
LEFT JOIN ICSInventory b ON a.InvCode = b.InvCode AND a.WorkPoint = b.WorkPoint
|
|
LEFT JOIN (select a.SourceDetailID, a.WorkPoint, sum(a.Quantity) as Quantity FROM ICSOApplyNegDetail a
|
|
left join ICSOApplyNeg b ON a.OApplyNegCode=b.OApplyNegCode AND a.WorkPoint=b.WorkPoint
|
|
where b.Type='2' GROUP BY a.SourceDetailID, a.WorkPoint) d ON a.ApplyDetailID = d.SourceDetailID AND a.WorkPoint = d.WorkPoint
|
|
where a.IssueQuantity > 0 and a.WorkPoint = '{0}' ";
|
|
sql = string.Format(sql, WorkPoint);
|
|
sql = sql + wherestr;
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
|
|
}
|
|
|
|
|
|
public void AddMOApplyNegTemp(string json)
|
|
{
|
|
var data = json.ToJObject();
|
|
if (WWPRInvmes.Columns.Count <= 0)
|
|
{
|
|
WWPRInvmes.Columns.Add("ZJID", typeof(string));
|
|
WWPRInvmes.Columns.Add("InvCode", typeof(string));
|
|
WWPRInvmes.Columns.Add("INVNAME", typeof(string));
|
|
WWPRInvmes.Columns.Add("InvStd", typeof(string));
|
|
WWPRInvmes.Columns.Add("InvUnit", typeof(string));
|
|
WWPRInvmes.Columns.Add("Quantity", typeof(string));
|
|
WWPRInvmes.Columns.Add("Amount", typeof(string));
|
|
WWPRInvmes.Columns.Add("IssueNegQuantity", typeof(string));
|
|
WWPRInvmes.Columns.Add("ExtensionID", typeof(string));
|
|
WWPRInvmes.Columns.Add("ID", typeof(string));
|
|
WWPRInvmes.Columns.Add("TLZID", typeof(string));
|
|
WWPRInvmes.Columns.Add("tuinum", typeof(string));
|
|
|
|
}
|
|
string usercode = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
DataRow newrow = WWPRInvmes.NewRow();
|
|
newrow["ZJID"] = data["ZJID"];
|
|
newrow["InvName"] = data["InvName"];
|
|
newrow["InvCode"] = data["InvCode"];
|
|
newrow["InvStd"] = data["InvStd"];
|
|
newrow["InvUnit"] = data["InvUnit"];
|
|
newrow["Amount"] = data["Amount"];
|
|
newrow["IssueNegQuantity"] = data["IssueNegQuantity"];
|
|
newrow["ExtensionID"] = data["ExtensionID"];
|
|
newrow["Quantity"] = "0";
|
|
newrow["ID"] = data["ID"];
|
|
newrow["TLZID"] = data["TLZID"];
|
|
newrow["tuinum"] = data["tuinum"];
|
|
WWPRInvmes.Rows.Add(newrow);
|
|
|
|
}
|
|
|
|
public void ClearTemp()
|
|
{
|
|
WWPRInvmes.Rows.Clear();
|
|
}
|
|
|
|
|
|
public string SaveICSMOApplyNeg(string ICSASN)
|
|
{
|
|
string msg = "";
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "OutsourcingIssueDoNegativeApply/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;
|
|
}
|
|
|
|
|
|
public DataTable GetICSMOApplyNegDetailTemp(string OApplyNegCode)
|
|
{
|
|
string sql = @"SELECT
|
|
a.ID,
|
|
a.ID as TLZID,
|
|
a.OApplyNegCode,
|
|
a.InvCode,
|
|
a.Quantity,
|
|
a.Amount,
|
|
a.SourceDetailID as ZJID,
|
|
b.InvName,
|
|
b.InvStd,
|
|
b.InvUnit,
|
|
c.IssueQuantity AS IssueNegQuantity,
|
|
a.ExtensionID,
|
|
isnull(d.Quantity,0) as tuinum
|
|
FROM
|
|
ICSOApplyNegDetail a
|
|
left join ICSOApply c on c.ApplyDetailID=a.SourceDetailID AND c.WorkPoint=a.WorkPoint
|
|
LEFT JOIN ICSInventory b ON a.InvCode = b.InvCode and a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN (select SourceDetailID,WorkPoint,sum(Quantity) as Quantity FROM ICSOApplyNegDetail GROUP BY SourceDetailID,WorkPoint) d
|
|
ON a.SourceDetailID = d.SourceDetailID AND a.WorkPoint = d.WorkPoint
|
|
where a.OApplyNegCode='" + OApplyNegCode + "'";
|
|
DataTable table = Repository().FindDataSetBySql(sql).Tables[0];
|
|
if (WWPRInvmes == null || WWPRInvmes.Columns.Count <= 0)
|
|
WWPRInvmes = table.Clone();
|
|
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 (WWPRInvmes.Rows.Count > 0)
|
|
{
|
|
//dtCloned.Merge(WWInvmes, false);
|
|
foreach (DataRow data in WWPRInvmes.Rows)
|
|
{
|
|
|
|
var info = dtCloned.Select(string.Format("TLZID='{0}'", data["TLZID"]));
|
|
if (info != null && info.Length > 0)
|
|
{
|
|
info[0]["ZJID"] = data["ZJID"];
|
|
info[0]["InvName"] = data["InvName"];
|
|
info[0]["InvCode"] = data["InvCode"];
|
|
info[0]["InvStd"] = data["InvStd"];
|
|
info[0]["InvUnit"] = data["InvUnit"];
|
|
info[0]["Amount"] = data["Amount"];
|
|
info[0]["Quantity"] = 0;
|
|
info[0]["IssueNegQuantity"] = data["IssueNegQuantity"];
|
|
info[0]["ExtensionID"] = data["ExtensionID"];
|
|
info[0]["tuinum"] = data["tuinum"];
|
|
}
|
|
else
|
|
{
|
|
DataRow newrow = dtCloned.NewRow();
|
|
newrow["ZJID"] = data["ZJID"];
|
|
newrow["InvName"] = data["InvName"];
|
|
newrow["InvCode"] = data["InvCode"];
|
|
newrow["InvStd"] = data["InvStd"];
|
|
newrow["InvUnit"] = data["InvUnit"];
|
|
newrow["Amount"] = data["Amount"];
|
|
newrow["Quantity"] = 0;
|
|
newrow["ID"] = data["ID"];
|
|
newrow["TLZID"] = data["TLZID"];
|
|
newrow["IssueNegQuantity"] = data["IssueNegQuantity"];
|
|
newrow["ExtensionID"] = data["ExtensionID"];
|
|
newrow["tuinum"] = data["tuinum"];
|
|
dtCloned.Rows.Add(newrow);
|
|
}
|
|
}
|
|
}
|
|
return dtCloned;
|
|
}
|
|
|
|
|
|
public string UpdateICSMOApplyNeg(string ICSASN)
|
|
{
|
|
string msg = "";
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "OutsourcingIssueDoNegativeApply/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;
|
|
}
|
|
|
|
|
|
|
|
public string AuditICSMOApplyNeg(string ICSASN)
|
|
{
|
|
string msg = "";
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "OutsourcingIssueDoNegativeApply/Approve";
|
|
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;
|
|
}
|
|
|
|
|
|
public void UpdateMOApplyNegTemp(string json)
|
|
{
|
|
var data = json.ToJObject();
|
|
string usercode = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
var info = WWPRInvmes.Select(string.Format("TLZID='{0}'", data["TLZID"]));
|
|
if (info != null && info.Length > 0)
|
|
{
|
|
info[0]["ZJID"] = data["ZJID"];
|
|
|
|
info[0]["InvName"] = data["InvName"];
|
|
info[0]["InvCode"] = data["InvCode"];
|
|
info[0]["InvStd"] = data["InvStd"];
|
|
info[0]["InvUnit"] = data["InvUnit"];
|
|
info[0]["Amount"] = data["Amount"];
|
|
info[0]["IssueNegQuantity"] = data["IssueNegQuantity"];
|
|
info[0]["ExtensionID"] = data["ExtensionID"];
|
|
info[0]["tuinum"] = data["tuinum"];
|
|
info[0]["Quantity"] = 0;
|
|
}
|
|
else
|
|
{
|
|
DataRow newrow = WWPRInvmes.NewRow();
|
|
newrow["ZJID"] = data["ZJID"];
|
|
newrow["InvName"] = data["InvName"];
|
|
newrow["InvCode"] = data["InvCode"];
|
|
newrow["InvStd"] = data["InvStd"];
|
|
newrow["InvUnit"] = data["InvUnit"];
|
|
newrow["Amount"] = data["Amount"];
|
|
newrow["IssueNegQuantity"] = data["IssueNegQuantity"];
|
|
newrow["ExtensionID"] = data["ExtensionID"];
|
|
newrow["tuinum"] = data["tuinum"];
|
|
newrow["Quantity"] = 0;
|
|
newrow["ID"] = data["ID"];
|
|
newrow["TLZID"] = data["TLZID"];
|
|
WWPRInvmes.Rows.Add(newrow);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|