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 { /// /// 从T100获取供应商接口 /// /// /// public T100ActionResult> GetVenderInfo(VenderInputParameter input) { var t100Action = new T100Action> { 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> { std_data = new actionStd_data { parameter = input.parameter } } }; var requestJson = JsonConvert.SerializeObject(t100Action); var response = HttpHelper.PostAsync(t100Url, requestJson).Result; var result = JsonConvert.DeserializeObject>>(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 suppliers = new List(); var allList = Biz.Db.Queryable().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; } } }