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.
128 lines
5.7 KiB
128 lines
5.7 KiB
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
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;
|
|
|
|
namespace NFine.Application.WMS
|
|
{
|
|
public class ICSAPISendApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
private static string userId = ConfigurationManager.ConnectionStrings["userId"].ConnectionString;
|
|
private static string password = ConfigurationManager.ConnectionStrings["password"].ConnectionString;
|
|
private static string OCMUrl = ConfigurationManager.ConnectionStrings["OCMUrl"].ConnectionString;
|
|
|
|
/// <summary>
|
|
/// 重新上传(咖博士)
|
|
/// </summary>
|
|
/// <param name="ids"></param>
|
|
/// <returns></returns>
|
|
public string Upload(string ids)
|
|
{
|
|
string msg = "";
|
|
try
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
ids = ids.TrimEnd(',');
|
|
string updatesql=string.Empty;
|
|
//获取需要重新上传的数据
|
|
string sql = $"SELECT ID,URL,Param FROM ICSAPI WHERE ID in ({ids}) AND Status='0' AND WorkPoint='{WorkPoint}' ;";
|
|
var dt = SqlHelper.CmdExecuteDataTable(sql);
|
|
if (dt.Rows.Count<=0)
|
|
{
|
|
throw new Exception("请选择上传失败的数据!");
|
|
}
|
|
for (int i=0;i< dt.Rows.Count;i++)
|
|
{
|
|
string id = dt.Rows[i]["ID"].ToString();
|
|
string url = dt.Rows[i]["URL"].ToString();
|
|
string param = dt.Rows[i]["Param"].ToString();
|
|
string newID = PublicMethod.GetNewid();
|
|
//获取token
|
|
//string token=GetTokenInfermation();
|
|
|
|
|
|
string token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ7XCJwcm9maWxlXCI6e1wiYWJqdHlwZVwiOlwiMDAxXCIsXCJjX29ialwiOlwiYWRtaW5cIixcImlzRmlyc3RMb2dpblwiOlwiTlwiLFwicHJpbWVyS2V5XCI6XCJXTVNhZG1pblwiLFwiY19wZXJfbjFcIjpcIueuoeeQhuWRmFwiLFwiY191c2VyXCI6XCJXTVNhZG1pblwiLFwiY19lbnRcIjo2NjIsXCJjX29ianR5cGVcIjpcIjFcIixcImNfbGFuY19uMVwiOlwi566A5L2T5Lit5paHXCIsXCJhYmptdGVsXCI6XCIzMTNcIixcImNfbGFuZ1wiOlwiemhfQ05cIixcImNfb3JnXCI6XCIxMDAwMDFcIixcImNfY3VyclwiOlwiQ05ZXCIsXCJjX2RlcHRcIjpcIkNGMDAwMFwiLFwiY191c2VyX24xXCI6XCJXTVNhZG1pblwiLFwiY19wZXJcIjpcImFkbWluXCIsXCJjX29yZ19uMVwiOlwi5ZKW5Y2a5aOr546v5aKDXCJ9fSIsImlhdCI6MTczMDQ1MTM0NywianRpIjoiYWM1YmJiM2EtNWYyZi00YzY1LWE1NWYtNTVkYTA3MTRmNTdlIn0.QzMtW4hL7VlBzPl0tz3FfbU-KMFuLvsKYUhYc6nsZNUlA94_utMjRSyZWw5arKbXfm1Ntk99wgpMMojP8KZQbA";
|
|
System.Net.WebHeaderCollection webHeader = new System.Net.WebHeaderCollection();
|
|
webHeader.Add("Token", token);
|
|
webHeader.Add("program-code", "fxdi055");
|
|
#region 分销接口
|
|
string resultStr = PublicMethod.HttpPost("销售出库", url, param, webHeader);
|
|
var resultData = (JObject)JsonConvert.DeserializeObject(resultStr);
|
|
string status = "0";
|
|
string oldStatus = "2";
|
|
if (resultData["statusDescription"].ToString() == "OK" && Convert.ToBoolean(resultData["response"]["success"]))
|
|
{
|
|
status = "1";
|
|
oldStatus = "3";
|
|
}
|
|
#endregion
|
|
updatesql += $"INSERT INTO [ICSAPI] ([ID],[SourceID], [Url], [Token], [Param], [Result], [Status], [MUSER], [MUSERName], [MTIME], [WorkPoint]) VALUES ('{newID}','{id}', '{url}', '{token}', '{param}', '{resultStr}', '{status}', '{MUSER}', '{MUSERNAME}', GETDATE(), '{WorkPoint}');" +
|
|
$"UPDATE ICSAPI SET SourceID='{newID}',Status='{oldStatus}' WHERE ID='{id}' ";
|
|
}
|
|
int count=SqlHelper.CmdExecuteNonQuery(updatesql);
|
|
if (count <= 0)
|
|
{
|
|
msg = $"更新数据失败";
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 获取token的方法
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static string GetTokenInfermation()
|
|
{
|
|
try
|
|
{
|
|
var Input = new
|
|
{
|
|
param = new
|
|
{
|
|
userId,
|
|
password,
|
|
ent = 662,
|
|
language = "zh_CN",
|
|
scend = false,
|
|
ati = ""
|
|
}
|
|
};
|
|
string Inputstr = JsonConvert.SerializeObject(Input);
|
|
string resultStr = PublicMethod.HttpPost("销售出库获取Token", OCMUrl + "A/ILoginService/login", Inputstr);
|
|
JObject resultData = (JObject)JsonConvert.DeserializeObject(resultStr);
|
|
if (resultData["statusDescription"].ToString() == "OK")
|
|
{
|
|
return resultData["response"]["token"].ToString();
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("获取Tocken失败");
|
|
}
|
|
}
|
|
catch (System.Net.WebException ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|