From 9f0be5494deeb827e48ad2bbe92383b8979ab41f Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Thu, 28 Mar 2024 14:50:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=94=B5=E6=94=BE=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 96 +++++++++++++++++-- 1 file changed, 90 insertions(+), 6 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 5415cab6..ccd41fab 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -12038,7 +12038,6 @@ namespace Myshipping.Application { throw Oops.Bah("大简云电放服务接口Secret未配置,请联系管理员"); } - url += "/v1/submit"; var webAccount = _webAccountConfig.GetAccountConfig("MSKWeb", UserManager.UserId).Result; if (webAccount == null) @@ -12050,6 +12049,8 @@ namespace Myshipping.Application var mappingIssueType = _cache.GetAllMappingIssueType().Result; List result = new(); + List<(long Id, string MBLNO, string CarrierId)> pushList = new(); + foreach (var order in orderList) { try @@ -12081,21 +12082,104 @@ namespace Myshipping.Application // 判断签单方式是否符合条件 string issueType = mappingIssueType.FirstOrDefault(x => x.Module == "TelexCheck" && x.Code == order.ISSUETYPE)?.MapCode; - issueType = issueType?? order.ISSUETYPE; + issueType = issueType ?? order.ISSUETYPE; if (!issueType.Equals("telex", StringComparison.OrdinalIgnoreCase)) { result.Add(new SubmitTelexResultDto(order.MBLNO, false, $"签单方式非电放")); continue; } + pushList.Add((order.Id, order.MBLNO, carrierId)); + } + catch (Exception ex) + { + _logger.LogError("请求电放条件判断的过程中发生未知异常,mblno={mblno}, ex={ex}", order.MBLNO, ex); + result.Add(new SubmitTelexResultDto(order.MBLNO, false, $"提交错误:{ex.Message}")); + continue; + } + } + + if (pushList.Count == 0) + { + return result; + } + + if (ids.Length > 1) + { + url += "/v1/tasks"; + var mblnos = string.Concat(',', pushList.Select(x => x.MBLNO)); + try + { + // 提交电放 + var data = pushList.Select(x => new + { + web_code = x.CarrierId, + web_user = webAccount.Account, + web_psw = webAccount.Password, + bno = x.MBLNO, + email = UserManager.Email + }); + var body = new + { + user_key = key, + user_secret = secret, + data = data + }; + + _logger.LogInformation("请求电放提交接口开始,mblnos={mblnos}, url={url}, body={body}", mblnos, url, body); + var rtn = await url.SetBody(body).PostAsStringAsync(); + _logger.LogInformation("请求电放提交接口结束,rtn={rtn}", rtn); + + var jsonRtn = JObject.Parse(rtn); + if (jsonRtn.GetIntValue("code") == 200) + { + _logger.LogInformation("请求电放提交接口成功,mblnos={mblnos}", mblnos); + + foreach (var item in pushList) + { + // 推送 电放已安排 状态 + var pushModel = new ModifyServiceProjectStatusDto + { + BookingId = item.Id, + SourceType = TrackingSourceTypeEnum.MANUAL, + StatusCodes = new List { + new ModifyServiceProjectStatusDetailDto { StatusCode = "DFYAP" } } + }; + var saveStatusRlt = await bookingValueAddedService.SaveServiceStatus(pushModel); + _logger.LogInformation("请求电放提交接口成功后推送 电放已安排 状态,mblno={mblno},JSON={json} ,结果={rlt}", + item.MBLNO, JSON.Serialize(pushModel), JSON.Serialize(saveStatusRlt)); + + result.Add(new SubmitTelexResultDto(item.MBLNO, true, null)); + } + } + else + { + var msg = jsonRtn.GetStringValue("msg")?.Replace("爬虫", ""); + _logger.LogInformation("请求电放提交接口失败,mblnos={mblnos}, 电放服务返回:{msg}", mblnos, msg); + result.AddRange(pushList.Select(x => new SubmitTelexResultDto(x.MBLNO, false, $"电放服务返回:{msg}"))); + } + } + catch (Exception ex) + { + _logger.LogError("请求电放服务的过程中发生未知异常,mblnos={mblnos}, ex={ex}", mblnos, ex); + result.AddRange(pushList.Select(x => new SubmitTelexResultDto(x.MBLNO, false, $"错误:{ex.Message}"))); + } + } + else + { + url += "/v1/submit"; + + var order = pushList[0]; + try + { // 提交电放 var body = new { user_key = key, user_secret = secret, - web_code = carrierId, web_user = webAccount.Account, web_psw = webAccount.Password, + web_code = order.CarrierId, bno = order.MBLNO }; @@ -12114,7 +12198,7 @@ namespace Myshipping.Application BookingId = order.Id, SourceType = TrackingSourceTypeEnum.MANUAL, StatusCodes = new List { - new ModifyServiceProjectStatusDetailDto { StatusCode = "DFYAP" } } + new ModifyServiceProjectStatusDetailDto { StatusCode = "DFYAP" } } }; var saveStatusRlt = await bookingValueAddedService.SaveServiceStatus(pushModel); _logger.LogInformation("请求电放提交接口成功后推送 电放已安排 状态,JSON={json} ,结果={rlt}", JSON.Serialize(pushModel), JSON.Serialize(saveStatusRlt)); @@ -12130,11 +12214,11 @@ namespace Myshipping.Application } catch (Exception ex) { - _logger.LogError("请求电放提交接口过程中发生未知异常,mblno={mblno}, ex={ex}", order.MBLNO, ex); + _logger.LogError("请求电放服务的过程中发生未知异常,mblno={mblno}, ex={ex}", order.MBLNO, ex); result.Add(new SubmitTelexResultDto(order.MBLNO, false, $"错误:{ex.Message}")); - continue; } } + return result; } #endregion From 7f3e9b42b8ba40fb1f0efd33cec2450fbb478181 Mon Sep 17 00:00:00 2001 From: wanghaomei <86whm@163.com> Date: Thu, 28 Mar 2024 16:20:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=A7=9F=E6=88=B7=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Core/Myshipping.Core.xml | 84 +++++++++++++-- .../DjyTenantParam/DjyTenantParamService.cs | 101 +++++++++++++++--- .../DjyTenantParam/Dto/DjyTenantParamInput.cs | 28 ++--- .../Dto/DjyTenantParamOutput.cs | 7 +- .../Dto/DjyTenantParamValueOutput.cs | 41 +++++++ 5 files changed, 223 insertions(+), 38 deletions(-) diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index e7eb3e4d..a4775205 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -12561,6 +12561,13 @@ 获取租户参数类别 + 准备废弃,使用/DJYTenantParam/page替代 + + + + + + 分页获取租户参数类别 @@ -12590,7 +12597,14 @@ - 获取参数 + 获取参数 + 准备废弃,使用/DJYTenantParam/PageParamValue替代 + + + + + + 分页获取参数值 @@ -12713,11 +12727,6 @@ 租户参数类别表查询输入参数 - - - 主键Id - - 类别代码 @@ -12733,14 +12742,19 @@ 业务大类 - + - 备注 + 租户参数值查询输入参数 - + - 排序 + 类别代码 + + + + + 租户id @@ -12768,6 +12782,11 @@ 业务大类 + + + 业务大类名称 + + 备注 @@ -12778,6 +12797,51 @@ 排序 + + + 列表输出 + + + + + 参数类别 + + + + + 类别名称 + + + + + 租户id + + + + + 租户名称 + + + + + 参数值 + + + + + 参数值名称 + + + + + 备注 + + + + + 排序 + + 用户自定义配置服务 diff --git a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs index 5ab9642a..52e3e68e 100644 --- a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs +++ b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs @@ -25,13 +25,19 @@ namespace Myshipping.Core.Service private readonly SqlSugarRepository _valuerep; private readonly ILogger _logger; private readonly ISysCacheService _cache; - public DjyTenantParamService(SqlSugarRepository rep, SqlSugarRepository itemrep, SqlSugarRepository valuerep, ISysCacheService cache, ILogger logger) + private readonly SqlSugarRepository _repTenant; + public DjyTenantParamService(SqlSugarRepository rep, + SqlSugarRepository itemrep, + SqlSugarRepository valuerep, + ISysCacheService cache, ILogger logger, + SqlSugarRepository repTenant) { _rep = rep; _logger = logger; _itemrep = itemrep; _valuerep = valuerep; _cache = cache; + _repTenant = repTenant; } #region 类别 @@ -119,6 +125,7 @@ namespace Myshipping.Core.Service /// /// 获取租户参数类别 + /// 准备废弃,使用/DJYTenantParam/page替代 /// /// [HttpGet("/DJYTenantParam/list")] @@ -126,6 +133,31 @@ namespace Myshipping.Core.Service { return await _rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(Type), x => x.Type == Type).WhereIF(!string.IsNullOrEmpty(ParaName), x => x.ParaName.Contains(ParaName)).OrderBy(x => x.Sort).ToListAsync(); } + + /// + /// 分页获取租户参数类别 + /// + /// + [HttpGet("/DJYTenantParam/page")] + public async Task> Page(QueryDJYTenantParamInput input) + { + var list = await _rep.AsQueryable() + .WhereIF(!string.IsNullOrEmpty(input.Type), x => x.Type == input.Type) + .WhereIF(!string.IsNullOrEmpty(input.ParaCode), x => x.ParaCode == input.ParaCode) + .WhereIF(!string.IsNullOrEmpty(input.ParaName), x => x.ParaName.Contains(input.ParaName)) + .OrderBy(x => x.Sort) + .ToPagedListAsync(input.PageNo, input.PageSize); + + var rtn = list.Adapt>(); + var dict = await _cache.GetAllDictData(); + foreach (var item in rtn.Items) + { + var d = dict.FirstOrDefault(x => x.TypeCode == "tenant_param_group" && x.Code == item.Type); + item.TypeName = d.Value; + } + + return rtn; + } #endregion #region 参数 @@ -231,7 +263,8 @@ namespace Myshipping.Core.Service #region 值 /// - /// 获取参数 + /// 获取参数 + /// 准备废弃,使用/DJYTenantParam/PageParamValue替代 /// /// [HttpGet("/DJYTenantParam/getParamValue")] @@ -239,6 +272,44 @@ namespace Myshipping.Core.Service { return await _valuerep.AsQueryable().Filter(null, true).WhereIF(paraCode != null, x => x.ParaCode == paraCode).OrderBy(x => x.Sort).ToListAsync(); } + + /// + /// 分页获取参数值 + /// + /// + [HttpGet("/DJYTenantParam/PageParamValue")] + public async Task> PageParamValue(QueryTenantParamValueInput input) + { + var list = await _valuerep.AsQueryable().Filter(null, true) + .WhereIF(!string.IsNullOrEmpty(input.ParaCode), x => x.ParaCode == input.ParaCode) + .WhereIF(input.TenantId.HasValue, x => x.TenantId == input.TenantId) + .OrderBy(x => x.Sort) + .ToPagedListAsync(input.PageNo, input.PageSize); + + + var rtn = list.Adapt>(); + var listParam = await _rep.AsQueryable().ToListAsync(); + var listParamItem = await _itemrep.AsQueryable().ToListAsync(); + var listTenant = await _repTenant.AsQueryable().Select(x => new { x.Id, x.Name }).ToListAsync(); + foreach (var item in rtn.Items) + { + var p = listParam.FirstOrDefault(x => x.ParaCode == item.ParaCode); + item.ParaName = p.ParaName; + + var t = listTenant.FirstOrDefault(x => x.Id == item.TenantId); + item.TenantName = t.Name; + + var it= listParamItem.FirstOrDefault(x=>x.ParaCode == item.ParaCode&&x.ItemCode==item.ItemCode); + if (it != null) + { + item.ItemCodeName = it.ItemName; + } + } + + return rtn; + + } + /// /// 增加参数 /// @@ -323,19 +394,19 @@ namespace Myshipping.Core.Service [NonAction] public async Task> GetParaCodeWithValue(string[] paraCodes) { - List result = await _rep.AsQueryable() - .Filter(null, true) - .LeftJoin((t1, t2) => t1.ParaCode == t2.ParaCode) - .Where((t1, t2) => t2.TenantId == UserManager.TENANT_ID) - .WhereIF(paraCodes?.Any() == true, (t1, t2) => paraCodes.Contains(t1.ParaCode)) - .Select((t1, t2) => new DjyTenantParamValueOutput() - { - ParaCode = t1.ParaCode, - ParaName = t1.ParaName, - ParaType = t1.Type, - ParaValue = t2.ItemCode - }) - .ToListAsync(); + List result = await _rep.AsQueryable() + .Filter(null, true) + .LeftJoin((t1, t2) => t1.ParaCode == t2.ParaCode) + .Where((t1, t2) => t2.TenantId == UserManager.TENANT_ID) + .WhereIF(paraCodes?.Any() == true, (t1, t2) => paraCodes.Contains(t1.ParaCode)) + .Select((t1, t2) => new DjyTenantParamValueOutput() + { + ParaCode = t1.ParaCode, + ParaName = t1.ParaName, + ParaType = t1.Type, + ParaValue = t2.ItemCode + }) + .ToListAsync(); return result; } #endregion diff --git a/Myshipping.Core/Service/DjyTenantParam/Dto/DjyTenantParamInput.cs b/Myshipping.Core/Service/DjyTenantParam/Dto/DjyTenantParamInput.cs index 6cd5b9e5..c6baccef 100644 --- a/Myshipping.Core/Service/DjyTenantParam/Dto/DjyTenantParamInput.cs +++ b/Myshipping.Core/Service/DjyTenantParam/Dto/DjyTenantParamInput.cs @@ -73,12 +73,7 @@ namespace Myshipping.Core.Service /// 租户参数类别表查询输入参数 /// public class QueryDJYTenantParamInput : PageInputBase - { - /// - /// 主键Id - /// - public virtual long Id { get; set; } - + { /// /// 类别代码 /// @@ -94,15 +89,24 @@ namespace Myshipping.Core.Service /// public virtual string Type { get; set; } + } + + + /// + /// 租户参数值查询输入参数 + /// + public class QueryTenantParamValueInput : PageInputBase + { /// - /// 备注 + /// 类别代码 /// - public virtual string Remark { get; set; } - + public virtual string ParaCode { get; set; } + /// - /// 排序 + /// 租户id /// - public virtual int Sort { get; set; } - + public long? TenantId { get; set; } + + } } diff --git a/Myshipping.Core/Service/DjyTenantParam/Dto/DjyTenantParamOutput.cs b/Myshipping.Core/Service/DjyTenantParam/Dto/DjyTenantParamOutput.cs index a5931a4b..dfac0ca6 100644 --- a/Myshipping.Core/Service/DjyTenantParam/Dto/DjyTenantParamOutput.cs +++ b/Myshipping.Core/Service/DjyTenantParam/Dto/DjyTenantParamOutput.cs @@ -26,7 +26,12 @@ namespace Myshipping.Core.Service /// 业务大类 /// public string Type { get; set; } - + + /// + /// 业务大类名称 + /// + public string TypeName { get; set; } + /// /// 备注 /// diff --git a/Myshipping.Core/Service/DjyTenantParam/Dto/DjyTenantParamValueOutput.cs b/Myshipping.Core/Service/DjyTenantParam/Dto/DjyTenantParamValueOutput.cs index 24240d94..1a33b8cb 100644 --- a/Myshipping.Core/Service/DjyTenantParam/Dto/DjyTenantParamValueOutput.cs +++ b/Myshipping.Core/Service/DjyTenantParam/Dto/DjyTenantParamValueOutput.cs @@ -7,4 +7,45 @@ public string ParaType { get; set; } public string ParaValue { get; set; } } + + /// + /// 列表输出 + /// + public class DjyTenantParamValueListOutput + { + /// + /// 参数类别 + /// + public string ParaCode { get; set; } + + /// + /// 类别名称 + /// + public string ParaName { get; set; } + /// + /// 租户id + /// + public long? TenantId { get; set; } + /// + /// 租户名称 + /// + public string TenantName { get; set; } + /// + /// 参数值 + /// + public string ItemCode { get; set; } + /// + /// 参数值名称 + /// + public string ItemCodeName { get; set; } + /// + /// 备注 + /// + public string Remark { get; set; } + /// + /// 排序 + /// + public int? Sort { get; set; } + + } }