diff --git a/Myshipping.Application/Enum/BookingErrorCode.cs b/Myshipping.Application/Enum/BookingErrorCode.cs new file mode 100644 index 00000000..2058dde8 --- /dev/null +++ b/Myshipping.Application/Enum/BookingErrorCode.cs @@ -0,0 +1,120 @@ +using Furion.FriendlyException; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application.Enum +{ + [ErrorCodeType] + public enum BookingErrorCode + { + + #region 订舱 + /// + /// 订舱数据不存在 + /// + [ErrorCodeItemMetadata("订舱数据不存在")] + BOOK001, + + + + /// + /// 已存在同类型且名称相同的收发通模板 + /// + [ErrorCodeItemMetadata("已存在同类型且名称相同的收发通模板")] + BOOK101, + + /// + /// 收发通模板不存在 + /// + [ErrorCodeItemMetadata("收发通模板不存在")] + BOOK111, + + /// + /// 打印模板不存在 + /// + [ErrorCodeItemMetadata("打印模板不存在")] + BOOK112, + + /// + /// 未上传模板文件 + /// + [ErrorCodeItemMetadata("未上传模板文件")] + BOOK113, + + /// + /// 不允许的文件类型 + /// + [ErrorCodeItemMetadata("不允许的文件类型")] + BOOK114, + /// + /// 模板文件不存在 + /// + [ErrorCodeItemMetadata("模板文件不存在")] + BOOK115, + + /// + /// 放舱信息不存在 + /// + [ErrorCodeItemMetadata("放舱信息不存在")] + BOOK116, + + /// + /// 不支持的船公司 + /// + [ErrorCodeItemMetadata("不支持的船公司")] + BOOK117, + + /// + /// 船公司未正确填写 + /// + [ErrorCodeItemMetadata("船公司未正确填写")] + BOOK118, + + /// + /// 亿通账号未正确配置 + /// + [ErrorCodeItemMetadata("亿通账号未正确配置")] + BOOK119, + + /// + /// 场站EDI配置未找到 + /// + [ErrorCodeItemMetadata("场站EDI配置未找到:{0}")] + BOOK120, + + /// + /// 所有箱型箱量必须录入完整 + /// + [ErrorCodeItemMetadata("所有箱型箱量必须录入完整")] + BOOK121, + + /// + /// 箱型EDI配置未找到 + /// + [ErrorCodeItemMetadata("箱型EDI配置未找到")] + BOOK122, + + /// + /// 箱型EDI配置未找到 + /// + [ErrorCodeItemMetadata("箱型EDI配置未找到:{0}")] + BOOK123, + + /// + /// 提箱小票链接生成失败 + /// + [ErrorCodeItemMetadata("提箱小票链接生成失败:{0}")] + BOOK124, + + + /// + /// 附件不存在 + /// + [ErrorCodeItemMetadata("附件不存在")] + BOOK200, + #endregion + } +} diff --git a/Myshipping.Application/Myshipping.Application.xml b/Myshipping.Application/Myshipping.Application.xml index 22a50149..9afc7053 100644 --- a/Myshipping.Application/Myshipping.Application.xml +++ b/Myshipping.Application/Myshipping.Application.xml @@ -2511,6 +2511,91 @@ 运踪id + + + 订舱数据不存在 + + + + + 已存在同类型且名称相同的收发通模板 + + + + + 收发通模板不存在 + + + + + 打印模板不存在 + + + + + 未上传模板文件 + + + + + 不允许的文件类型 + + + + + 模板文件不存在 + + + + + 放舱信息不存在 + + + + + 不支持的船公司 + + + + + 船公司未正确填写 + + + + + 亿通账号未正确配置 + + + + + 场站EDI配置未找到 + + + + + 所有箱型箱量必须录入完整 + + + + + 箱型EDI配置未找到 + + + + + 箱型EDI配置未找到 + + + + + 提箱小票链接生成失败 + + + + + 附件不存在 + + 多品名输出参数 @@ -3363,6 +3448,13 @@ 类型,1:pdf、2:xlsx + + + 获取提箱小票链接 + + + + 获取用户报表的json diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index f2d55ce7..c5baecc0 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -35,6 +35,7 @@ using System.Text; using System.Web; using Newtonsoft.Json.Linq; using Myshipping.Core.Helper; +using Myshipping.Application.Enum; namespace Myshipping.Application { @@ -61,13 +62,15 @@ namespace Myshipping.Application private readonly SqlSugarRepository _repPrintTemplate; private readonly SqlSugarRepository _repLetterYard; private readonly SqlSugarRepository _repUser; + private readonly SqlSugarRepository _repOrderUrl; public BookingOrderService(SqlSugarRepository rep, SqlSugarRepository repCtn, SqlSugarRepository ctndetailrep, SqlSugarRepository bookinglog, SqlSugarRepository bookinglogdetail, SqlSugarRepository bookingremark, SqlSugarRepository bookingfile, SqlSugarRepository webconfig, SqlSugarRepository repPrint, SqlSugarRepository dicdata, SqlSugarRepository statuslog, SqlSugarRepository statuslogdetail, ILogger logger, ISysCacheService cache, - SqlSugarRepository repPrintTemplate, SqlSugarRepository repLetterYard, SqlSugarRepository repUser) + SqlSugarRepository repPrintTemplate, SqlSugarRepository repLetterYard, SqlSugarRepository repUser, + SqlSugarRepository repOrderUrl) { this._logger = logger; this._rep = rep; @@ -86,6 +89,7 @@ namespace Myshipping.Application this._repPrintTemplate = repPrintTemplate; this._repLetterYard = repLetterYard; this._repUser = repUser; + this._repOrderUrl = repOrderUrl; } #region 主表和箱信息 @@ -471,7 +475,7 @@ namespace Myshipping.Application //未上传打印模板文件 if (file == null || file.Length == 0) { - throw Oops.Oh(ErrorCode.BOOK113); + throw Oops.Oh(BookingErrorCode.BOOK200); } var opt = App.GetOptions(); @@ -479,7 +483,7 @@ namespace Myshipping.Application var fileSuffix = Path.GetExtension(file.FileName).ToLower(); // 文件后缀 if (!opt.fileType.Contains(fileSuffix)) { - throw Oops.Oh(ErrorCode.BOOK114); + throw Oops.Oh(BookingErrorCode.BOOK114); } var dirAbs = string.Empty; @@ -509,7 +513,7 @@ namespace Myshipping.Application TypeCode = dto.TypeCode, TypeName = dto.TypeName, TenantId = Convert.ToInt16(UserManager.TENANT_ID), - TenantName = UserManager.CLAINM_TENANT_NAME, + TenantName = UserManager.TENANT_NAME, }; await _bookingfile.InsertAsync(newFile); using (var stream = File.Create(fileAbsPath)) @@ -722,19 +726,19 @@ namespace Myshipping.Application var order = _rep.FirstOrDefault(x => x.Id == bookingId); if (order == null) { - throw Oops.Oh(ErrorCode.BOOK001); + throw Oops.Oh(BookingErrorCode.BOOK001); } var letterYard = await _repLetterYard.FirstOrDefaultAsync(x => x.BookingId == bookingId); if (letterYard == null) { - throw Oops.Oh(ErrorCode.BOOK116); + throw Oops.Oh(BookingErrorCode.BOOK116); } var printTemplate = _repPrintTemplate.FirstOrDefault(x => x.TenantId == letterYard.TenantId && x.TypeCode == "fangcang"); if (printTemplate == null) { - throw Oops.Oh(ErrorCode.BOOK115); + throw Oops.Oh(BookingErrorCode.BOOK115); } var opt = App.GetOptions(); @@ -747,7 +751,7 @@ namespace Myshipping.Application var fileAbsPath = Path.Combine(dirAbs, printTemplate.FilePath); if (!File.Exists(fileAbsPath)) { - throw Oops.Oh(ErrorCode.BOOK115); + throw Oops.Oh(BookingErrorCode.BOOK115); } _logger.LogInformation($"准备调用报表生成放舱:id:{bookingId},文件:{printTemplate.FileName}"); @@ -784,6 +788,146 @@ namespace Myshipping.Application #endregion + #region 小票链接 + + /// + /// 获取提箱小票链接 + /// + /// + /// + [HttpGet("/BookingOrder/txxplink")] + public async Task TxxpLink(long bookingId) + { + var order = _rep.FirstOrDefault(x => x.Id == bookingId); + if (order == null) + { + throw Oops.Oh(BookingErrorCode.BOOK001); + } + + var ordUrl = _repOrderUrl.FirstOrDefault(x => x.BookingId == bookingId); + if (ordUrl == null) + { + ordUrl = new BookingOrderUrl(); + ordUrl.BookingId = bookingId; + await _repOrderUrl.InsertAsync(ordUrl); + } + + if (!string.IsNullOrEmpty(ordUrl.UrlTxxp)) + { + return ordUrl.UrlTxxp; + } + + //校验船公司 + if (string.IsNullOrEmpty(order.CARRIERID)) + { + throw Oops.Oh(BookingErrorCode.BOOK118); + } + + //判断船公司是否支持 + var allowCarrier = _cache.GetAllDictData().Result.Where(x => x.TypeCode == "txxp_carrier_list").Select(x => x.Code).ToList(); + if (!allowCarrier.Contains(order.CARRIERID)) + { + throw Oops.Oh(BookingErrorCode.BOOK117); + } + + //亿通账号 + var ytAcc = _webconfig.FirstOrDefault(x => x.CreatedUserId == UserManager.UserId && x.TypeCode == "YitongWeb"); + if (ytAcc == null) + { + throw Oops.Oh(BookingErrorCode.BOOK119); + } + + //场站转换 + var yardset = _cache.GetAllMappingYard().Result.FirstOrDefault(y => y.Code == order.YARDID && y.Module == "BookingTxxp"); + if (yardset == null) + { + throw Oops.Oh(BookingErrorCode.BOOK120, order.YARDID); + } + + var ctns = await _repCtn.Where(x => x.BILLID == bookingId).ToListAsync(); + //校验箱子数据录入 + if (ctns.Where(c => string.IsNullOrEmpty(c.CTNALL) || !c.CTNNUM.HasValue).Count() > 0) + { + throw Oops.Oh(BookingErrorCode.BOOK121); + } + + //箱型映射 + var ctnMapping = await _cache.GetAllMappingCtn(); + ctnMapping = ctnMapping.Where(x => x.Module == "BookingTxxp").ToList(); + if (ctnMapping.Count == 0) + { + throw Oops.Oh(BookingErrorCode.BOOK122); + } + + var expCode = ctns.Select(x => x.CTNCODE).Distinct().Except(ctnMapping.Select(y => y.Code)).ToList(); + if (expCode.Count > 0) + { + throw Oops.Oh(BookingErrorCode.BOOK123, string.Join(',', expCode)); + } + + var user = await _repUser.FirstOrDefaultAsync(x => x.Id == UserManager.UserId); + + //调用小票服务 + var dicUrlTxxp = _cache.GetAllDictData().Result.First(x => x.TypeCode == "url_set" && x.Code == "txxp_service"); + var postObj = new + { + SystemCode = "djy_hechuan", + CarrierCode = order.CARRIERID, + billOrderId = order.Id.ToString(), + sendOrderCode = order.MBLNO, + userId = UserManager.DjyUserId, + customerId = order.CUSTOMERID.ToString(), + // userName = currUser.CODENAME, + //userPassword = currUser.PASSWORD, + operatorName = UserManager.Name, + depotCode = yardset.MapCode, + depotName = yardset.MapName, + AgentName = UserManager.TENANT_NAME, + linkName = UserManager.Name, + linkMobile = user.Tel, + CustomerName = $"{UserManager.TENANT_NAME}+{UserManager.Name}", //公司名称+用户姓名 + memo = string.Empty, + boxInfo = ctns.Select(c => + { + return new + { + boxType = ctnMapping.First(x => x.Code == c.CTNCODE).MapCode, + boxCount = c.CTNNUM.Value + }; + }), + sysLoginName = ytAcc.Account, + sysPsssword = ytAcc.Password + }; + + + string strPostObj = postObj.ToJsonString(); + _logger.LogInformation($"调用提箱小票接口传递数据:{strPostObj}"); + var strResp = await dicUrlTxxp.Value.SetBody(postObj).PostAsStringAsync(); + _logger.LogInformation($"调用提箱小票接口返回:{strResp}"); + + var jobjResp = JObject.Parse(strResp); + int respCode = jobjResp.GetIntValue("code"); + if (respCode != 200) + { + throw Oops.Oh(BookingErrorCode.BOOK124, jobjResp.GetStringValue("message")); + } + + //保存url + var txxpUrl = jobjResp.GetStringValue("data"); + ordUrl.UrlTxxp = txxpUrl; + await _repOrderUrl.UpdateAsync(ordUrl); + return txxpUrl; + } + #endregion + + #region VGM及VMG链接 + + #endregion + + #region 订舱、截单EDI + + #endregion + #region 其他 /// /// 获取用户报表的json @@ -826,14 +970,14 @@ namespace Myshipping.Application var order = _rep.FirstOrDefault(x => x.Id == id); if (order == null) { - throw Oops.Oh(ErrorCode.BOOK001); + throw Oops.Oh(BookingErrorCode.BOOK001); } //打印模板 var printTemplate = _repPrint.FirstOrDefault(x => x.TenantId == order.TenantId && x.TypeCode == type); if (printTemplate == null) { - throw Oops.Oh(ErrorCode.BOOK112); + throw Oops.Oh(BookingErrorCode.BOOK112); } //读取配置路劲 @@ -848,7 +992,7 @@ namespace Myshipping.Application var fileAbsPath = Path.Combine(dirAbs, printTemplate.FilePath).ToLower(); if (!File.Exists(fileAbsPath)) { - throw Oops.Oh(ErrorCode.BOOK112); + throw Oops.Oh(BookingErrorCode.BOOK112); } _logger.LogInformation($"准备调用报表生成:id:{id},文件:{printTemplate.FileName}"); diff --git a/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs b/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs index 645e30fb..4c67d28f 100644 --- a/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs +++ b/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs @@ -17,6 +17,7 @@ using Furion.FriendlyException; using Furion.RemoteRequest.Extensions; using System.Text; using System.Web; +using Myshipping.Application.Enum; namespace Myshipping.Application { @@ -63,7 +64,7 @@ namespace Myshipping.Application //未上传打印模板文件 if (file == null || file.Length == 0) { - throw Oops.Oh(ErrorCode.BOOK113); + throw Oops.Oh(BookingErrorCode.BOOK113); } var opt = App.GetOptions(); @@ -71,7 +72,7 @@ namespace Myshipping.Application var fileSuffix = Path.GetExtension(file.FileName).ToLower(); // 文件后缀 if (!opt.fileType.Contains(fileSuffix)) { - throw Oops.Oh(ErrorCode.BOOK114); + throw Oops.Oh(BookingErrorCode.BOOK114); } var dirAbs = string.Empty; @@ -123,7 +124,7 @@ namespace Myshipping.Application //未上传打印模板文件 if (file == null || file.Length == 0) { - throw Oops.Oh(ErrorCode.BOOK113); + throw Oops.Oh(BookingErrorCode.BOOK113); } var opt = App.GetOptions(); @@ -131,14 +132,14 @@ namespace Myshipping.Application var fileSuffix = Path.GetExtension(file.FileName).ToLower(); // 文件后缀 if (!opt.fileType.Contains(fileSuffix)) { - throw Oops.Oh(ErrorCode.BOOK114); + throw Oops.Oh(BookingErrorCode.BOOK114); } _rep.Context.QueryFilter.Clear(); var entity = _rep.FirstOrDefault(x => x.Id == input.Id); if (entity == null) { - throw Oops.Oh(ErrorCode.BOOK112); + throw Oops.Oh(BookingErrorCode.BOOK112); } entity = input.Adapt(entity); @@ -218,7 +219,7 @@ namespace Myshipping.Application var printFile = await _rep.FirstOrDefaultAsync(u => u.Id == id); if (printFile == null) { - throw Oops.Oh(ErrorCode.BOOK115); + throw Oops.Oh(BookingErrorCode.BOOK115); } @@ -232,7 +233,7 @@ namespace Myshipping.Application var fileFullPath = Path.Combine(dirAbs, printFile.FilePath); if (!File.Exists(fileFullPath)) { - throw Oops.Oh(ErrorCode.BOOK115); + throw Oops.Oh(BookingErrorCode.BOOK115); } var fileName = HttpUtility.UrlEncode(printFile.FileName, Encoding.GetEncoding("UTF-8")); diff --git a/Myshipping.Application/Service/BookingTemplate/BookingTemplateService.cs b/Myshipping.Application/Service/BookingTemplate/BookingTemplateService.cs index 0060dbc9..a93a62f8 100644 --- a/Myshipping.Application/Service/BookingTemplate/BookingTemplateService.cs +++ b/Myshipping.Application/Service/BookingTemplate/BookingTemplateService.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Myshipping.Application.Entity; using Microsoft.Extensions.Logging; using Furion.FriendlyException; +using Myshipping.Application.Enum; namespace Myshipping.Application { @@ -53,7 +54,7 @@ namespace Myshipping.Application var c = _rep.Count(x => x.Type == input.Type && x.Title == input.Title); if (c > 0) { - throw Oops.Oh(ErrorCode.BOOK101); + throw Oops.Oh(BookingErrorCode.BOOK101); } var entity = input.Adapt(); @@ -71,7 +72,7 @@ namespace Myshipping.Application var bt = _rep.FirstOrDefault(x => x.Id == input.Id); if (bt == null) { - throw Oops.Oh(ErrorCode.BOOK111); + throw Oops.Oh(BookingErrorCode.BOOK111); } bt.Content = input.Content; diff --git a/Myshipping.Core/Const/CommonConst.cs b/Myshipping.Core/Const/CommonConst.cs index be29f683..18d61c9b 100644 --- a/Myshipping.Core/Const/CommonConst.cs +++ b/Myshipping.Core/Const/CommonConst.cs @@ -115,13 +115,18 @@ public class CommonConst /// public const string CACHE_KEY_COMMON_DB_MAPPING_VESSEL = "CommonDbMappingVessel"; + /// + /// 场站映射 + /// + public const string CACHE_KEY_COMMON_DB_MAPPING_YARD = "CommonDbMappingYard"; + /// /// 字典映射 /// public const string CACHE_KEY_COMMON_DB_DICT_DATA = "DictDataList"; /// - /// 船名映射 + /// EDI映射 /// public const string CACHE_KEY_DJY_EDI_SETTING = "DjyEdiSetting"; diff --git a/Myshipping.Core/Entity/CommonDB/CodeYard.cs b/Myshipping.Core/Entity/CommonDB/CodeYard.cs index 9ffe39ed..059fe7fb 100644 --- a/Myshipping.Core/Entity/CommonDB/CodeYard.cs +++ b/Myshipping.Core/Entity/CommonDB/CodeYard.cs @@ -32,26 +32,39 @@ namespace Myshipping.Core.Entity /// public string Remark { get; set; } + } + + + + + [SugarTable("MappingYard")] + [Description("场站映射")] + public class MappingYard : CommonDbEntity + { /// - /// 创建时间 + /// 代码 /// - public DateTime CreateTime { get; set; } + public string Code { get; set; } /// - /// 修改时间 + /// 模块 /// - public DateTime? ModifyTime { get; set; } + public string Module { get; set; } /// - /// 创建人 + /// 映射代码 /// - public string CreateUser { get; set; } + public string MapCode { get; set; } /// - /// 修改人 + /// 映射名称 /// - public string ModifyUser { get; set; } + public string MapName { get; set; } + /// + /// 备注 + /// + public string Remark { get; set; } } } diff --git a/Myshipping.Core/Enum/ErrorCode.cs b/Myshipping.Core/Enum/ErrorCode.cs index 515242e3..c22e553c 100644 --- a/Myshipping.Core/Enum/ErrorCode.cs +++ b/Myshipping.Core/Enum/ErrorCode.cs @@ -405,56 +405,6 @@ public enum ErrorCode F1000, - #region 订舱 - /// - /// 订舱数据不存在 - /// - [ErrorCodeItemMetadata("订舱数据不存在")] - BOOK001, - - - - /// - /// 已存在同类型且名称相同的收发通模板 - /// - [ErrorCodeItemMetadata("已存在同类型且名称相同的收发通模板")] - BOOK101, - - /// - /// 收发通模板不存在 - /// - [ErrorCodeItemMetadata("收发通模板不存在")] - BOOK111, - - /// - /// 打印模板不存在 - /// - [ErrorCodeItemMetadata("打印模板不存在")] - BOOK112, - - /// - /// 未上传模板文件 - /// - [ErrorCodeItemMetadata("未上传模板文件")] - BOOK113, - - /// - /// 不允许的文件类型 - /// - [ErrorCodeItemMetadata("不允许的文件类型")] - BOOK114, - /// - /// 模板文件不存在 - /// - [ErrorCodeItemMetadata("模板文件不存在")] - BOOK115, - - /// - /// 放舱信息不存在 - /// - [ErrorCodeItemMetadata("放舱信息不存在")] - BOOK116, - #endregion #region 邮箱账号 diff --git a/Myshipping.Core/Manager/UserManager.cs b/Myshipping.Core/Manager/UserManager.cs index 0e6804df..522cfccc 100644 --- a/Myshipping.Core/Manager/UserManager.cs +++ b/Myshipping.Core/Manager/UserManager.cs @@ -40,7 +40,7 @@ public static class UserManager /// /// 租户名称 /// - public static string CLAINM_TENANT_NAME => App.User.FindFirst(ClaimConst.CLAINM_TENANT_NAME)?.Value; + public static string TENANT_NAME => App.User.FindFirst(ClaimConst.CLAINM_TENANT_NAME)?.Value; /// /// 大简云userid diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 2ab001d5..d121ee34 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -652,6 +652,11 @@ 船名映射 + + + 场站映射 + + 字典映射 @@ -659,7 +664,7 @@ - 船名映射 + EDI映射 @@ -1237,24 +1242,29 @@ 备注 - + - 创建时间 + 代码 - + - 修改时间 + 模块 - + - 创建人 + 映射代码 - + - 修改人 + 映射名称 + + + + + 备注 @@ -3880,46 +3890,6 @@ 表单不存在 - - - 订舱数据不存在 - - - - - 已存在同类型且名称相同的收发通模板 - - - - - 收发通模板不存在 - - - - - 打印模板不存在 - - - - - 未上传模板文件 - - - - - 不允许的文件类型 - - - - - 模板文件不存在 - - - - - 放舱信息不存在 - - 邮箱账号已存在 @@ -4968,7 +4938,7 @@ 租户ID - + 租户名称 @@ -5518,6 +5488,12 @@ + + + 获取公共库 场站映射 + + + 设置公共库 船公司 @@ -5602,6 +5578,12 @@ + + + 设置公共库 场站映射 + + + 获取租户参数 @@ -5899,6 +5881,12 @@ + + + 获取公共库 船名映射 + + + 设置公共库 船公司 @@ -5983,6 +5971,12 @@ + + + 设置公共库 场站映射 + + + 获取租户参数 @@ -6588,6 +6582,16 @@ 新增场站信息 + + + 获取场站映射 + + + + + 新增编辑场站映射信息 + + 获取起始港信息 @@ -6719,6 +6723,12 @@ + + + 获取场站映射 + + + 获取起始港 diff --git a/Myshipping.Core/Service/Auth/AuthService.cs b/Myshipping.Core/Service/Auth/AuthService.cs index 5f06e30e..5c501b27 100644 --- a/Myshipping.Core/Service/Auth/AuthService.cs +++ b/Myshipping.Core/Service/Auth/AuthService.cs @@ -94,6 +94,7 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient {ClaimConst.CLAINM_SUPERADMIN, user.AdminType}, { ClaimConst.CLAINM_TENANT_TYPE, tenant.TenantType }, { ClaimConst.CLAINM_TENANT_NAME, tenant.Name }, + { ClaimConst.DjyUserId, user.DjyUserId }, }); // 设置Swagger自动登录 @@ -148,6 +149,7 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient { ClaimConst.CLAINM_SUPERADMIN, user.AdminType }, { ClaimConst.CLAINM_TENANT_TYPE, tenant.TenantType }, { ClaimConst.CLAINM_TENANT_NAME, tenant.Name }, + { ClaimConst.DjyUserId, user.DjyUserId }, }); // 设置Swagger自动登录 diff --git a/Myshipping.Core/Service/Cache/ISysCacheService.cs b/Myshipping.Core/Service/Cache/ISysCacheService.cs index 8156676d..9362cd72 100644 --- a/Myshipping.Core/Service/Cache/ISysCacheService.cs +++ b/Myshipping.Core/Service/Cache/ISysCacheService.cs @@ -121,7 +121,11 @@ public interface ISysCacheService Task> GetAllMappingVessel(); - + /// + /// 获取公共库 场站映射 + /// + /// + Task> GetAllMappingYard(); /// /// 设置公共库 船公司 /// @@ -204,6 +208,12 @@ public interface ISysCacheService /// /// Task SetAllMappingVessel(List list); + + /// + /// 设置公共库 场站映射 + /// + /// + Task SetAllMappingYard(List list); #endregion #region DJY diff --git a/Myshipping.Core/Service/Cache/SysCacheService.cs b/Myshipping.Core/Service/Cache/SysCacheService.cs index 73c55db2..91dd987c 100644 --- a/Myshipping.Core/Service/Cache/SysCacheService.cs +++ b/Myshipping.Core/Service/Cache/SysCacheService.cs @@ -418,7 +418,14 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet return _cache.GetAsync>(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_VESSEL); } - + /// + /// 获取公共库 船名映射 + /// + /// + public Task> GetAllMappingYard() + { + return _cache.GetAsync>(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_YARD); + } /// @@ -427,7 +434,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllCodeCarrier(List list) { - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_CARRIER, list, TimeSpan.FromMinutes(5)); + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_CARRIER, list); } /// @@ -436,7 +443,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllCodeVessel(List list) { - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_VESSEL, list, TimeSpan.FromMinutes(5)); + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_VESSEL, list); } /// @@ -445,7 +452,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllCodeForwarder(List list) { - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_FORWARDER, list, TimeSpan.FromMinutes(5)); + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_FORWARDER, list); } /// @@ -454,7 +461,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllCodeYard(List list) { - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_YARD, list, TimeSpan.FromMinutes(5)); + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_YARD, list); } /// @@ -463,7 +470,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllCodePortLoad(List list) { - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_PORTLOAD, list, TimeSpan.FromMinutes(5)); + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_PORTLOAD, list); } /// @@ -472,7 +479,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllCodePort(List list) { - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_PORT, list, TimeSpan.FromMinutes(5)); + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_PORT, list); } /// @@ -481,7 +488,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllCodePackage(List list) { - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_PACKAGE, list, TimeSpan.FromMinutes(5)); + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_PACKAGE, list); } /// @@ -490,7 +497,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllCodeService(List list) { - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_SERVICE, list, TimeSpan.FromMinutes(5)); + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_SERVICE, list); } /// @@ -499,7 +506,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllCodeCtn(List list) { - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_CTN, list, TimeSpan.FromMinutes(5)); + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_CTN, list); } /// @@ -508,7 +515,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllCodeFrt(List list) { - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_FRT, list, TimeSpan.FromMinutes(5)); + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_FRT, list); } /// @@ -517,7 +524,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllMappingCtn(List list) { - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_CTN, list, TimeSpan.FromMinutes(5)); + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_CTN, list); } /// @@ -526,7 +533,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllMappingCarrier(List list) { - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_CARRIER, list, TimeSpan.FromMinutes(5)); + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_CARRIER, list); } /// @@ -535,7 +542,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllMappingFrt(List list) { - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_FRT, list, TimeSpan.FromMinutes(5)); + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_FRT, list); } /// @@ -544,9 +551,17 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllMappingVessel(List list) { - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_VESSEL, list, TimeSpan.FromMinutes(5)); + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_VESSEL, list); } + /// + /// 设置公共库 场站映射 + /// + /// + public Task SetAllMappingYard(List list) + { + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_YARD, list); + } #endregion diff --git a/Myshipping.Core/Service/CommonDB/CommonDBService.cs b/Myshipping.Core/Service/CommonDB/CommonDBService.cs index 864109aa..f96a5ec2 100644 --- a/Myshipping.Core/Service/CommonDB/CommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/CommonDBService.cs @@ -20,23 +20,19 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie private readonly SqlSugarRepository _codeCarrierRep; private readonly SqlSugarRepository _mappingCarrierRep; - private readonly SqlSugarRepository _codeVesselRep; private readonly SqlSugarRepository _mappingVesselRep; - - private readonly SqlSugarRepository _codeForwarderRep; private readonly SqlSugarRepository _codeYardRep; + private readonly SqlSugarRepository _mappingYardRep; private readonly SqlSugarRepository _codePortLoadrRep; private readonly SqlSugarRepository _codePortRep; private readonly SqlSugarRepository _codePackageRep; private readonly SqlSugarRepository _codeServiceRep; private readonly SqlSugarRepository _codeCtnRep; private readonly SqlSugarRepository _mappingCtnRep; - private readonly SqlSugarRepository _codeFrtRep; private readonly SqlSugarRepository _mappingFrtRep; - private readonly ISysCacheService _sysCacheService; public CommonDBService(SqlSugarRepository codeCarrierRep, @@ -53,6 +49,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie SqlSugarRepository mappingVesselRep, SqlSugarRepository mappingCtnRep, SqlSugarRepository mappingFrtRep, + SqlSugarRepository mappingYardRep, ISysCacheService sysCacheService) { _codeCarrierRep = codeCarrierRep; @@ -69,6 +66,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie _mappingVesselRep = mappingVesselRep; _mappingCtnRep = mappingCtnRep; _mappingFrtRep = mappingFrtRep; + _mappingYardRep = mappingYardRep; _sysCacheService = sysCacheService; @@ -96,6 +94,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie public async Task AddCarrier([FromBody] CodeCarrier dto) { var entity = dto.Adapt(); + entity.GID = Guid.NewGuid().ToString(); await _codeCarrierRep.InsertAsync(entity); await GetAllCarrier(); } @@ -112,7 +111,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie .WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code, System.StringComparison.CurrentCultureIgnoreCase)) .WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase)) .WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module) - .WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.Code.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase)); + .WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.MapName.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase)); return queryList.ToList(); } @@ -125,6 +124,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie var entity = dto.Adapt(); if (string.IsNullOrWhiteSpace(dto.GID)) { + entity.GID = Guid.NewGuid().ToString(); await _mappingCarrierRep.InsertAsync(entity); } else @@ -159,7 +159,6 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie return queryList.ToList(); } - /// /// 新增船名信息 /// @@ -167,6 +166,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie public async Task AddVessel([FromBody] CodeVessel dto) { var entity = dto.Adapt(); + entity.GID = Guid.NewGuid().ToString(); await _codeVesselRep.InsertAsync(entity); await GetAllVessel(); } @@ -186,7 +186,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie List list = await _sysCacheService.GetAllMappingVessel(); var queryList = list.WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module) - .WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.Name.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase)); + .WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.MapName.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase)); return queryList.ToList(); } @@ -200,6 +200,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie var entity = dto.Adapt(); if (string.IsNullOrWhiteSpace(dto.GID)) { + entity.GID = Guid.NewGuid().ToString(); await _mappingVesselRep.InsertAsync(entity); } else @@ -213,7 +214,6 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie #endregion - #region 船代 /// /// 获取船代列表信息 @@ -235,12 +235,12 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie public async Task AddForwarder([FromBody] CodeForwarder dto) { var entity = dto.Adapt(); + entity.GID = Guid.NewGuid().ToString(); await _codeForwarderRep.InsertAsync(entity); await GetAllForwarder(); } #endregion - #region 场站 /// @@ -262,11 +262,54 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie public async Task AddYard([FromBody] CodeYard dto) { var entity = dto.Adapt(); + entity.GID = Guid.NewGuid().ToString(); await _codeYardRep.InsertAsync(entity); await GetAllYard(); } - #endregion + /// + /// 获取场站映射 + /// + [HttpGet("/commondb/mappingyardlist")] + public async Task MappingYardList([FromQuery] MappingQueryDto input) + { + //数量太多,不允许查询全部 + if (string.IsNullOrEmpty(input.Module) || input.Module.Length < 1) + { + return new List(); + } + + List list = await _sysCacheService.GetAllMappingYard(); + + var queryList = list.WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module) + .WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.MapName.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase)); + + return queryList.ToList(); + } + + /// + /// 新增编辑场站映射信息 + /// + [HttpPost("/commondb/addorupdatemappingyard")] + public async Task AddOrUpdateMappingYard([FromBody] MappingYard dto) + { + var entity = dto.Adapt(); + if (string.IsNullOrWhiteSpace(dto.GID)) + { + entity.GID = Guid.NewGuid().ToString(); + await _mappingYardRep.InsertAsync(entity); + } + else + { + await _mappingYardRep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + } + await GetAllMappingYard(); + } + + + + + #endregion #region 起始港 /// @@ -288,6 +331,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie public async Task AddPortload([FromBody] CodePortLoad dto) { var entity = dto.Adapt(); + entity.GID = Guid.NewGuid().ToString(); await _codePortLoadrRep.InsertAsync(entity); await GetAllPortload(); } @@ -321,6 +365,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie public async Task AddPort([FromBody] CodePort dto) { var entity = dto.Adapt(); + entity.GID = Guid.NewGuid().ToString(); await _codePortRep.InsertAsync(entity); await GetAllPort(); } @@ -348,6 +393,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie public async Task AddPackage([FromBody] CodePackage dto) { var entity = dto.Adapt(); + entity.GID = Guid.NewGuid().ToString(); await _codePackageRep.InsertAsync(entity); await GetAllPackage(); } @@ -375,6 +421,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie public async Task AddService([FromBody] CodeService dto) { var entity = dto.Adapt(); + entity.GID = Guid.NewGuid().ToString(); await _codeServiceRep.InsertAsync(entity); await GetAllService(); } @@ -404,6 +451,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie public async Task AddCtn([FromBody] CodeCtn dto) { var entity = dto.Adapt(); + entity.GID = Guid.NewGuid().ToString(); await _codeCtnRep.InsertAsync(entity); await GetAllCtn(); } @@ -421,7 +469,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie .WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code, System.StringComparison.CurrentCultureIgnoreCase)) .WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase)) .WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module) - .WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.Code.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase)); + .WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.MapName.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase)); return queryList.ToList(); } @@ -435,6 +483,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie var entity = dto.Adapt(); if (string.IsNullOrWhiteSpace(dto.GID)) { + entity.GID = Guid.NewGuid().ToString(); await _mappingCtnRep.InsertAsync(entity); } else @@ -470,6 +519,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie public async Task AddFrt([FromBody] CodeFrt dto) { var entity = dto.Adapt(); + entity.GID = Guid.NewGuid().ToString(); await _codeFrtRep.InsertAsync(entity); await GetAllFrt(); } @@ -487,7 +537,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie .WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code, System.StringComparison.CurrentCultureIgnoreCase)) .WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase)) .WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module) - .WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.Code.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase)); + .WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.MapName.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase)); return queryList.ToList(); } @@ -500,6 +550,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie var entity = dto.Adapt(); if (string.IsNullOrWhiteSpace(dto.GID)) { + entity.GID = Guid.NewGuid().ToString(); await _mappingFrtRep.InsertAsync(entity); } else @@ -510,9 +561,6 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie } #endregion - - - #region 实现接口,获取公共数据并缓存 [NonAction] public async Task> GetAllCarrier() @@ -550,7 +598,15 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie return list; } + [NonAction] + public async Task> GetAllMappingYard() + { + var list = await _mappingYardRep.ToListAsync(); + await _sysCacheService.SetAllMappingYard(list); + return list; + + } [NonAction] public async Task> GetAllForwarder() { @@ -647,7 +703,4 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie } #endregion - - - } diff --git a/Myshipping.Core/Service/CommonDB/ICommonDBService.cs b/Myshipping.Core/Service/CommonDB/ICommonDBService.cs index b015ba4a..5cf68df8 100644 --- a/Myshipping.Core/Service/CommonDB/ICommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/ICommonDBService.cs @@ -42,6 +42,12 @@ public interface ICommonDBService /// Task> GetAllYard(); + /// + /// 获取场站映射 + /// + /// + Task> GetAllMappingYard(); + /// /// 获取起始港 /// diff --git a/Myshipping.Web.Core/Startup.cs b/Myshipping.Web.Core/Startup.cs index 2f77f3bc..0777e248 100644 --- a/Myshipping.Web.Core/Startup.cs +++ b/Myshipping.Web.Core/Startup.cs @@ -135,6 +135,9 @@ public class Startup : AppStartup //船名映射 App.GetService().GetAllMappingVessel(); + //场站映射 + App.GetService().GetAllMappingYard(); + //船代 App.GetService().GetAllForwarder();