using Amazon.Runtime.Internal.Util; using AngleSharp.Dom; using DS.Module.Core; using DS.Module.Core.Data; using DS.Module.Core.Extensions; using DS.Module.Core.Helpers; using DS.Module.SqlSugar; using DS.Module.UserModule; using DS.WMS.Core.Code.Entity; using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Map.Entity; using DS.WMS.Core.Op.Dtos; using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Interface; using DS.WMS.Core.System.Entity; using DS.WMS.Core.System.Interface; using Mapster; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SqlSugar; using System.Security.Policy; namespace DS.WMS.Core.Op.Method; public class SeaExportService : ISeaExportService { private readonly IServiceProvider _serviceProvider; private readonly ISqlSugarClient db; private readonly IUser user; private readonly ISaasDbService saasService; //private readonly ICrawlerDataService crawlerService; private readonly ICommonService commonService; /// /// /// /// public SeaExportService(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; db = _serviceProvider.GetRequiredService(); user = _serviceProvider.GetRequiredService(); saasService = _serviceProvider.GetRequiredService(); commonService = _serviceProvider.GetRequiredService(); //crawlerService = _serviceProvider.GetRequiredService(); } /// /// 列表 /// /// /// public DataResult> GetListByPage(PageRequest request) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); //序列化查询条件 var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); var data = tenantDb.Queryable() .Where(whereList) .Select().ToQueryPage(request.PageCondition); return data; } /// /// 编辑 /// /// /// public DataResult EditSeaExport(SeaExportReq req) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); if (req.Id == 0) { if (req.BLType != "拼箱分票" && tenantDb.Queryable().Where(x => x.MBLNO == req.MBLNO.Trim()).Any()) { return DataResult.Failed("海运出口信息主提单号已存在!", MultiLanguageConst.SeaExportMBLNOExist); } if (tenantDb.Queryable().Where(x => x.HBLNO == req.HBLNO.Trim()).Any()) { return DataResult.Failed("海运出口信息分提单号已存在!", MultiLanguageConst.SeaExportHBLNOExist); } //TODO 会计期间不允许小于已结转期间 if (req.CloseDocDate.IsNotNull() && req.CloseDocDate < req.ETD) { return DataResult.Failed("截单日期不允许小于开船日期!", MultiLanguageConst.SeaExportCloseDocDateLimit); } if (req.ClosingDate.IsNotNull() && req.ClosingDate < req.ETD) { return DataResult.Failed("截港日期不允许小于开船日期!", MultiLanguageConst.SeaExportCloseDateLimit); } var sequence = commonService.GetSequenceNext(); if (!sequence.Succeeded) { return DataResult.Failed(sequence.Message, MultiLanguageConst.SequenceSetNotExist); } var data = req.Adapt(); data.CustomerNo = sequence.Data; var entity = tenantDb.Insertable(data).ExecuteReturnEntity(); if (req.CtnInfo.Count > 0) { foreach (var item in req.CtnInfo) { var ctn = item.Adapt(); ctn.BSNO = entity.Id.ToString(); tenantDb.Insertable(ctn).ExecuteCommand(); } } return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess); } else { var info = tenantDb.Queryable().Where(x => x.Id == req.Id).First(); if ((bool)info.IsBusinessLocking) { return DataResult.Failed("海运出口信息业务已锁定!", MultiLanguageConst.SeaExportBusinessLock); } info = req.Adapt(info); //TODO 会计期间不允许小于已结转期间 if (info.CloseDocDate.IsNotNull() && info.CloseDocDate < info.ETD) { return DataResult.Failed("截单日期不允许小于开船日期!", MultiLanguageConst.SeaExportCloseDocDateLimit); } if (info.ClosingDate.IsNotNull() && info.ClosingDate < info.ETD) { return DataResult.Failed("截港日期不允许小于开船日期!", MultiLanguageConst.SeaExportCloseDateLimit); } tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand(); if (req.CtnInfo.Count > 0) { var ctnList = tenantDb.Queryable().Where(x => x.BSNO == req.Id.ToString()).ToList(); foreach (var item in req.CtnInfo) { if (item.Id == 0) { var ctn = item.Adapt(); ctn.BSNO = info.Id.ToString(); tenantDb.Insertable(ctn).ExecuteCommand(); } else { var ctn = ctnList.First(x => x.Id == item.Id); ctn = item.Adapt(ctn); tenantDb.Updateable(ctn).ExecuteCommand(); } } } return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess); } } /// /// 详情 /// /// /// public DataResult GetSeaExportInfo(string id) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var data = tenantDb.Queryable() .Where(a => a.Id == long.Parse(id)) .Select() .First(); return DataResult.Success(data, MultiLanguageConst.DataQuerySuccess); } /// /// 批量更新 /// /// /// public DataResult SeaExportBatchEdit(SeaExportBatchEditReq req) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); if (req.Ids.Count == 0) { return DataResult.Failed("海运出口批量编辑未勾选!", MultiLanguageConst.SeaExportBatchEditNoSelect); } if (tenantDb.Queryable().Where(x => !req.Ids.Contains(x.Id)).Any().IsNull()) { return DataResult.Failed("不存在的海运出口信息!", MultiLanguageConst.SeaExportExist); } if (tenantDb.Queryable().Where(x => req.Ids.Contains(x.Id) && x.IsBusinessLocking == true).Any()) { return DataResult.Failed("海运出口信息业务已锁定!", MultiLanguageConst.SeaExportBusinessLock); } if (req.AccountDate.ToString().IsNotNull()) { if (tenantDb.Queryable().Where(x => req.Ids.Contains(x.Id) && x.IsFeeLocking == true).Any()) { return DataResult.Failed("海运出口信息费用已锁定!", MultiLanguageConst.SeaExportFeeLock); } } var orderList = tenantDb.Queryable().Where(x => req.Ids.Contains(x.Id)).ToList(); var dic = req.GetPropertiesArray(); foreach (var item in orderList) { var info = item; info = req.Adapt(info); tenantDb.Updateable(info).UpdateColumns(dic).EnableDiffLogEvent().ExecuteCommand(); } return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess); } /// /// 业务单据单票复制 /// /// 业务Id /// public DataResult SeaExportCopy(string id) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var info = tenantDb.Queryable().Where(x => x.Id == long.Parse(id)).First(); if (info.IsNullOrEmpty()) { return DataResult.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist); } //获取表单复制模板 var template = tenantDb.Queryable().Where(x => x.PermissionId == 1772509201441099776).First(); var sequence = commonService.GetSequenceNext(); if (!sequence.Succeeded) { return DataResult.Failed(sequence.Message, MultiLanguageConst.SequenceSetNotExist); } var data = new SeaExport(); if (template.IsNullOrEmpty()) { data = info.Adapt(data); data.Id = 0; data.ParentId = 0; data.IsBusinessLocking = false; data.IsFeeLocking = false; data.CustomerNo = sequence.Data; var entity = tenantDb.Insertable(data).ExecuteReturnEntity(); return DataResult.Successed("复制成功!", entity.Id, MultiLanguageConst.DataCopySuccess); } else { data = info.Adapt(data); data.Id = 0; data.ParentId = 0; data.IsBusinessLocking = false; data.IsFeeLocking = false; data.CustomerNo = sequence.Data; var list0 = template.CopyFields.Split(","); var list1 = new List(); foreach (var item in list0) { list1.Add(item.ToUpperCamelCase()); } list1.Add("IsBusinessLocking"); list1.Add("IsFeeLocking"); list1.Add("CustomerNo"); var insertColumns = list1.ToArray(); //insertColumns.AddRange(["Id", "ParentId", "IsBusinessLocking", "IsFeeLocking", "CustomerNo"]); var entity = tenantDb.Insertable(data).InsertColumns(insertColumns).ExecuteReturnEntity(); return DataResult.Successed("复制成功!", entity.Id, MultiLanguageConst.DataCopySuccess); } } #region 删除 /// /// 业务单据删除 /// /// 业务Id /// public DataResult SeaExportDel(string id) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var info = tenantDb.Queryable().Where(x => x.Id == long.Parse(id)).First(); if (info.IsNullOrEmpty()) { return DataResult.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist); } if (tenantDb.Queryable().Where(x => x.ParentId == long.Parse(id)).Any()) { return DataResult.Failed("海运出口存在分票信息,不能删除!", MultiLanguageConst.SeaExportPartExist); } if (tenantDb.Queryable().Where(x => x.BusinessId == long.Parse(id)).Any()) { return DataResult.Failed("海运出口存在费用信息,不能删除!", MultiLanguageConst.SeaExportFeeExist); } if ((bool)info.IsBusinessLocking) { return DataResult.Failed("海运出口信息业务已锁定!", MultiLanguageConst.SeaExportBusinessLock); } if ((bool)info.IsFeeLocking) { return DataResult.Failed("海运出口信息费用已锁定!", MultiLanguageConst.SeaExportFeeLock); } info.Deleted = true; info.DeleteTime = DateTime.Now; info.DeleteBy = long.Parse(user.UserId); tenantDb.Updateable(info).ExecuteCommand(); //tenantDb.Deleteable(info).IsLogic().ExecuteCommand("Deleted"); return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess); } /// /// 业务单据删除 /// /// 业务Ids /// public DataResult SeaExportBatchDel(IdModel req) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); if (req.Ids.Length == 0) { return DataResult.Failed("海运出口批量操作未勾选!", MultiLanguageConst.SeaExportBatchOpNoSelect); } if (tenantDb.Queryable().Where(x => req.Ids.Contains(x.Id)).Any().IsNull()) { return DataResult.Failed("不存在的海运出口信息!", MultiLanguageConst.SeaExportExist); } if (tenantDb.Queryable().Where(x => req.Ids.Contains(x.Id) && x.IsBusinessLocking == true).Any()) { return DataResult.Failed("海运出口信息业务已锁定!", MultiLanguageConst.SeaExportBusinessLock); } if (tenantDb.Queryable().Where(x => req.Ids.Contains(x.Id) && x.IsFeeLocking == true).Any()) { return DataResult.Failed("海运出口信息费用已锁定!", MultiLanguageConst.SeaExportFeeLock); } if (tenantDb.Queryable().Where(x => req.Ids.Contains(x.ParentId)).Any()) { return DataResult.Failed("海运出口存在分票信息,不能删除!", MultiLanguageConst.SeaExportPartExist); } if (tenantDb.Queryable().Where(x => req.Ids.Contains(x.BusinessId)).Any()) { return DataResult.Failed("海运出口存在费用信息,不能删除!", MultiLanguageConst.SeaExportFeeExist); } var list = tenantDb.Queryable().Where(x => req.Ids.Contains(x.Id)).ToList(); //tenantDb.Deleteable(list).IsLogic().ExecuteCommand("Deleted"); //tenantDb.Deleteable(list).IsLogic().ExecuteCommand("Deleted"); foreach (var item in list) { item.Deleted = true; item.DeleteTime = DateTime.Now; item.DeleteBy = long.Parse(user.UserId); tenantDb.Updateable(item).ExecuteCommand(); } return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess); } #endregion #region 费用锁定 业务锁定 /// /// 业务锁定 /// /// 业务Id /// public DataResult SeaExportBusinessLook(string id) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var info = tenantDb.Queryable().Where(x => x.Id == long.Parse(id)).First(); if (info.IsNullOrEmpty()) { return DataResult.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist); } if ((bool)info.IsBusinessLocking) { return DataResult.Failed("海运出口信息业务已锁定!", MultiLanguageConst.SeaExportBusinessLock); } info.IsBusinessLocking = true; tenantDb.Updateable(info).ExecuteCommand(); return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess); } /// /// 费用锁定 /// /// 业务Id /// public DataResult SeaExportFeeLook(string id) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var info = tenantDb.Queryable().Where(x => x.Id == long.Parse(id)).First(); if (info.IsNullOrEmpty()) { return DataResult.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist); } if ((bool)info.IsFeeLocking) { return DataResult.Failed("海运出口信息费用已锁定!", MultiLanguageConst.SeaExportFeeLock); } info.IsFeeLocking = true; tenantDb.Updateable(info).ExecuteCommand(); return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess); } /// /// 业务解锁 /// /// 业务Id /// public DataResult SeaExportBusinessUnLook(string id) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var info = tenantDb.Queryable().Where(x => x.Id == long.Parse(id)).First(); if (info.IsNullOrEmpty()) { return DataResult.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist); } if (!(bool)info.IsBusinessLocking) { return DataResult.Failed("海运出口信息业务锁定已解锁!", MultiLanguageConst.SeaExportBusinessUnLock); } info.IsBusinessLocking = false; tenantDb.Updateable(info).ExecuteCommand(); return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess); } /// /// 费用解锁 /// /// 业务Id /// public DataResult SeaExportFeeUnLook(string id) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var info = tenantDb.Queryable().Where(x => x.Id == long.Parse(id)).First(); if (info.IsNullOrEmpty()) { return DataResult.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist); } if (!(bool)info.IsFeeLocking) { return DataResult.Failed("海运出口信息费用锁定已解锁!", MultiLanguageConst.SeaExportFeeUnLock); } info.IsFeeLocking = false; tenantDb.Updateable(info).ExecuteCommand(); return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess); } #endregion /// /// 获取场站数据 /// /// 业务Id /// /// public async Task> GetYardData(string id, bool isWeb = false) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var info = tenantDb.Queryable().Where(x => x.Id == long.Parse(id)).First(); if (info.IsNull()) { return await Task.FromResult(DataResult.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist)); } if (string.IsNullOrEmpty(info.YardId.ToString())) { return await Task.FromResult(DataResult.Failed("请先选择场站!", MultiLanguageConst.SeaExportNotExist)); } var data = GetYardDataAndMappingSystem(info, isWeb); return await Task.FromResult(DataResult.Success("")); } /// /// 从爬虫获取场站数据,并映射为系统中的箱型 /// /// private async Task>> GetYardDataAndMappingSystem(SeaExport order, bool isWeb = false) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var req = new YardDataReq { YardId = order.YardId, MBLNO = order.MBLNO, IsWeb = isWeb }; var rtn = await GetYardData(req); //if (!rtn.Key) //{ // throw Oops.Bah(rtn.Value); //} //场站引入的数据,转换为订舱箱型,且带上箱型代码 var ctnList = tenantDb.Queryable().Where(x => x.Status == StatusEnum.Enable).ToList(); var mapCtn = tenantDb.Queryable().Where(x => x.Status == StatusEnum.Enable).ToList(); var listRtn = JsonConvert.DeserializeObject>(rtn.Data); foreach (var item in listRtn) { var ctnall = item.CTNALL; var findMap = mapCtn.FirstOrDefault(x => x.Module == "YardData" && x.MapCode == ctnall); var findCtn = ctnList.FirstOrDefault(x => x.CtnName == ctnall); if (findMap != null) { item.CtnCode = findMap.Code; findCtn = ctnList.First(c => c.EdiCode == findMap.Code); item.CTNALL = findCtn.CtnName; //名称显示维护的箱型 } else if (findCtn != null) { item.CtnCode = findCtn.EdiCode; item.CTNALL = findCtn.CtnName; //名称显示维护的箱型 } else { return await Task.FromResult(DataResult>.Failed($"未找到箱型{ctnall}的场站引入配置")); } } return await Task.FromResult(DataResult>.Success(listRtn)); } /// /// 异步调取出口运踪场站详情(按箱明细显示) /// /// /// public async Task> GetYardData(YardDataReq req) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var account = tenantDb.Queryable().Where(x => x.CustomerId == req.YardId && x.AccountType == "BillTrace").First(); var userKey = db.Queryable().Where(x => x.Code == "spiderUserKeyBilltrace").First().Value; var userSecret = db.Queryable().Where(x => x.Code == "spiderUserSecretBilltrace").First().Value; var spiderServerUrl = db.Queryable().Where(x => x.Code == "spiderServerUrlBillTraceNew").First().Value; var tenantName = db.Queryable().Filter(null, true).Where(x => x.Id == long.Parse(user.TenantId)).First().Name; if (account.IsNull()) { return await Task.FromResult(DataResult.Failed("未配置出口运踪场站第三方账号信息!")); } var yardMap = tenantDb.Queryable().Where(x => x.LinkId == req.YardId && x.Module == "BillTrace").First(); if (yardMap.IsNull()) { return await Task.FromResult(DataResult.Failed($"场站代号配置未找到:{req.YardId}")); } var objSend = new { user_key = userKey, user_secret = userSecret, customer_id = user.TenantId, customer_name = tenantName, web_code = yardMap.MapCode, bno = req.MBLNO, req_type = req.IsWeb ? "1" : "0", web_user = account.AppKey, web_psw = account.AppSecret, }; var urlYard = spiderServerUrl; if (!urlYard.EndsWith("/")) { urlYard += "/"; } urlYard += "real/query"; var res = RequestHelper.Post(JsonConvert.SerializeObject(objSend), urlYard); var rtnObj = JObject.Parse(res); if (rtnObj.GetIntValue("code") != 200) { return await Task.FromResult(DataResult.Failed("$\"获取场站数据失败:{rtnObj.GetStringValue(\"msg\")}\"!")); } else { var rtnData = rtnObj.GetStringValue("data"); if (req.IsWeb) { var viewstatehtml = GetDataHtmlList(rtnData, "__VIEWSTATE", "/>"); if (viewstatehtml != "") { rtnData = rtnData.Replace(viewstatehtml, ""); } } return await Task.FromResult(DataResult.Success(rtnData)); } } public static string GetDataHtmlList(string html, string startstr, string endstr) { var subhtml = html; var htmllength = subhtml.Length; var startindex = subhtml.IndexOf(startstr); //if (startindex == -1 || startindex == 0) return ""; if (startindex == -1) return ""; subhtml = subhtml.Substring(startindex + startstr.Length, htmllength - startindex - startstr.Length); var endindex = subhtml.IndexOf(endstr); if (endindex != -1 && endindex != 0) subhtml = subhtml.Substring(0, endindex); return subhtml; } #region 运踪相关 /// /// 发起运踪订阅或者更新提单号 /// /// /// public async Task> SendOrUpdateTrace(List req) { if (req.Count == 0) { return await Task.FromResult(DataResult.Failed("未传入正确参数!")); } var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var userKey = db.Queryable().Where(x => x.Code == "seae_billtraceurl_userKey").First().Value; var userPwd = db.Queryable().Where(x => x.Code == "seae_billtraceurl_userPwd").First().Value; var userId = db.Queryable().Where(x => x.Code == "seae_billtraceurl_userId").First().Value; var reqUrl = db.Queryable().Where(x => x.Code == "request_seae_billtraceurl").First().Value; var resUrl = db.Queryable().Where(x => x.Code == "response_seae_billtraceurl").First().Value; BillTraceMain billdto = new BillTraceMain(); List billTraceList = new List(); foreach (var item in req) { if (!string.IsNullOrWhiteSpace(item.CARRIERID)) { var et = await tenantDb.Queryable().Where(x => x.StatusCode == "status_mudigang" && x.BusinessId == Convert.ToInt64(item.BusinessId)).FirstAsync(); if (et != null) { return await Task.FromResult(DataResult.Failed("\"提单号\" + item.MBLNO + \"已订阅!")); } } if (!string.IsNullOrWhiteSpace(item.YardCode)) { var et = await tenantDb.Queryable().Where(x => x.StatusCode == "status_qiyungang" && x.BusinessId == Convert.ToInt64(item.BusinessId)).FirstAsync(); if (et != null) { return await Task.FromResult(DataResult.Failed("\"提单号\" + item.MBLNO + \"已订阅!")); } } if (item.isBook && (string.IsNullOrWhiteSpace(item.CARRIERID) || string.IsNullOrWhiteSpace(item.CARRIER) || string.IsNullOrWhiteSpace(item.MBLNO))) { return await Task.FromResult(DataResult.Failed("订阅目的港船公司或提单号不能为空!")); } if (!item.isBook && (string.IsNullOrWhiteSpace(item.YARD) || string.IsNullOrWhiteSpace(item.YardCode) || string.IsNullOrWhiteSpace(item.MBLNO))) { return await Task.FromResult(DataResult.Failed("订阅港前数据提单号或场站不能为空!")); } var yardMap = tenantDb.Queryable().Where(x => x.Code == item.YardCode && x.Module == "BillTrace").First(); if (yardMap.IsNull()) { return await Task.FromResult(DataResult.Failed($"场站代号配置未找到:{item.YardCode}")); } billTraceList.Add(new BillTraceReq { BusinessId = item.BusinessId, MBLNO = item.MBLNO, YARD = item.YARD == "" ? null : item.YARD, YardCode = yardMap.MapCode == "" ? null : yardMap.MapCode, CARRIER = item.CARRIER == "" ? null : item.CARRIER, CARRIERID = item.CARRIERID == "" ? null : item.CARRIERID, isBook = item.isBook }); var status = string.Empty; var IsBookingYZ = String.Empty; if (!string.IsNullOrWhiteSpace(item.YardCode) && !string.IsNullOrWhiteSpace(item.CARRIERID)) { status = "订阅起运港,目的港"; IsBookingYZ = "3"; } else if (string.IsNullOrWhiteSpace(item.YardCode) && !string.IsNullOrWhiteSpace(item.CARRIERID)) { status = "订阅目的港"; IsBookingYZ = "2"; } else if (!string.IsNullOrWhiteSpace(item.YardCode) && string.IsNullOrWhiteSpace(item.CARRIERID)) { status = "订阅起运港"; IsBookingYZ = "1"; } else { IsBookingYZ = "0"; } //TODO 添加booking日志 //更新运踪标识 var info = tenantDb.Queryable().First(x => x.Id == Convert.ToInt64(item.BusinessId)); info.IsBookingYZ = IsBookingYZ; await tenantDb.Updateable(info).ExecuteCommandAsync(); } billdto.Children = billTraceList; billdto.Key = userKey; billdto.PWD = userPwd; billdto.url = resUrl; billdto.Gid = userId; var json = billdto.ToJsonString(); if (!reqUrl.EndsWith("/")) { reqUrl += "/"; } reqUrl += "BillTrace/UpdateMblno"; var result = RequestHelper.Post(json, reqUrl); var res = JsonConvert.DeserializeObject(result); if (!res.Success) { return await Task.FromResult(DataResult.Failed($"发起运踪订阅或者更新提单号失败:{res.Message}")); } else { return await Task.FromResult(DataResult.Success(res.Data)); } } /// /// 运踪退订 /// /// /// public async Task> UnsubscribeBillTrace(List req) { if (req.Count == 0) { return await Task.FromResult(DataResult.Failed("未传入正确参数!")); } var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var userKey = db.Queryable().Where(x => x.Code == "seae_billtraceurl_userKey").First().Value; var userPwd = db.Queryable().Where(x => x.Code == "seae_billtraceurl_userPwd").First().Value; var userId = db.Queryable().Where(x => x.Code == "seae_billtraceurl_userId").First().Value; var reqUrl = db.Queryable().Where(x => x.Code == "request_seae_billtraceurl").First().Value; var resUrl = db.Queryable().Where(x => x.Code == "response_seae_billtraceurl").First().Value; BillTraceUnsubscribeDto reqDto = new BillTraceUnsubscribeDto() { Children = new List(), Key = userKey, PWD = userPwd, Gid = userId }; foreach (var item in req) { if (string.IsNullOrEmpty(item.BusinessId)) { return await Task.FromResult(DataResult.Failed("订舱记录主键不能为空!!")); } reqDto.Children.Add(new BillTraceUnsubscribeList(item.BusinessId, item.MBLNO)); //TODO 添加booking日志 //更新运踪标识 var info = tenantDb.Queryable().First(x => x.Id == Convert.ToInt64(item.BusinessId)); info.IsBookingYZ = "0"; await tenantDb.Updateable(info).ExecuteCommandAsync(); } var json = reqDto.ToJsonString(); if (!reqUrl.EndsWith("/")) { reqUrl += "/"; } reqUrl += "BillTrace/UnsubscribeBillTrace"; var result = RequestHelper.Post(json, reqUrl); var res = JsonConvert.DeserializeObject(result); if (!res.Success) { return await Task.FromResult(DataResult.Failed($"运踪退订失败:{res.Message}")); } else { return await Task.FromResult(DataResult.Success(res.Data)); } } #endregion }