using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using Rhea.Common;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel.Design;
|
using System.Linq;
|
using System.Security.Policy;
|
using System.Text;
|
using System.Threading.Tasks;
|
using Tiger.Model;
|
using Tiger.Model.Minsun;
|
using Tiger.IBusiness;
|
|
namespace Tiger.Business.WMS
|
{
|
public partial class ErpT100
|
{
|
|
/// <summary>
|
/// 从T100获取供应商接口
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public T100ActionResult<resultStd_data<VenderParameterR>> GetVenderInfo(VenderInputParameter input)
|
{
|
var t100Action = new T100Action<actionStd_data<VenderParameter>>
|
{
|
key = Guid.NewGuid().ToString("N"),
|
type = "sync",
|
host = new host
|
{
|
prod = "MES",
|
ip = "",
|
lang = "zh_CN",
|
acct = "tiptop",
|
timestamp = DateTime.Now.ToString("yyyyMMddHHMMssfff"),
|
},
|
datakey = input.datakey,
|
service = new Service
|
{
|
ip = "",
|
prod = "T100",
|
id = "topprd",
|
name = "wms_erp_wms_getven"
|
},
|
payload = new PayloadData<actionStd_data<VenderParameter>>
|
{
|
std_data = new actionStd_data<VenderParameter>
|
{
|
parameter = input.parameter
|
}
|
}
|
};
|
var requestJson = JsonConvert.SerializeObject(t100Action);
|
var response = HttpHelper.PostAsync(t100Url, requestJson).Result;
|
var result = JsonConvert.DeserializeObject<T100ActionResult<resultStd_data<VenderParameterR>>>(response.Message);
|
return result;
|
}
|
|
public ApiAction GetVenderInfoToDDL(iVenderParams input)
|
{
|
var action = new ApiAction();
|
try
|
{
|
var t100Res = GetVenderInfo(new VenderInputParameter
|
{
|
parameter = new VenderParameter
|
{
|
site = input.company,
|
startdt = input.startDate,
|
enddt = input.endDate
|
},
|
datakey = new Datakey
|
{
|
EntId = ApiConfig.IsTestServer ? "108" : "88",
|
CompanyId = input.company
|
}
|
});
|
if (t100Res.payload.std_data.execution.code == "0")
|
{
|
var list = t100Res.payload.std_data.parameter.@return;
|
action.Data = list;
|
List<BAS_SUPPLIER> suppliers = new List<BAS_SUPPLIER>();
|
var allList = Biz.Db.Queryable<BAS_SUPPLIER>().Where(x => x.AUTH_ORG == input.company).ToList();
|
foreach (var item in list)
|
{
|
var query = allList.Where(x => x.SUPP_CODE == item.pmab001).FirstOrDefault();
|
BAS_SUPPLIER entity = query ?? new BAS_SUPPLIER()
|
{
|
SUPP_CODE = item.pmab001,
|
SUPP_NAME_CN = item.pmaal003,
|
AUTH_ORG = input.company
|
};
|
suppliers.Add(entity);
|
}
|
var db = Business.Biz.Db;
|
//数据库处理操作
|
if (action.IsSuccessed)
|
{
|
action.Message = $"供应商信息同步成功";
|
var dbTran = db.UseTran(() =>
|
{
|
db.Storageable(suppliers, "Interface").ExecuteCommand();
|
|
});
|
if (!dbTran.IsSuccess)
|
{
|
action.CatchExceptionWithLog(dbTran.ErrorException, $"数据处理失败");
|
}
|
}
|
}
|
else
|
{
|
action.IsSuccessed = false;
|
action.Message = $"T100返回信息错误:{t100Res.payload.std_data.execution.description}";
|
}
|
|
}
|
catch (Exception ex)
|
{
|
action.CatchExceptionWithLog(ex, $"数据处理失败");
|
}
|
return action;
|
}
|
}
|
}
|