diff --git a/SJZY.Track.Api.sln b/SJZY.Track.Api.sln index 8a9c51e8..c1408517 100644 --- a/SJZY.Track.Api.sln +++ b/SJZY.Track.Api.sln @@ -10,7 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DAC93270-5A2 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0E2537C3-6EF3-4085-9BD2-CF923E53F82A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SJZY.Track.Repository", "src\SJZY.Track.Repository\SJZY.Track.Repository.csproj", "{D9CF5706-1972-414F-821E-AA32C13B8570}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SJZY.Track.Infrastructure", "src\SJZY.Track.Infrastructure\SJZY.Track.Infrastructure.csproj", "{D9CF5706-1972-414F-821E-AA32C13B8570}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SJZY.Track.HttpApi", "src\SJZY.Track.HttpApi\SJZY.Track.HttpApi.csproj", "{390A44FB-0DB5-4B66-86AB-7712DC3030F5}" EndProject diff --git a/SJZY.Track.Api.sln.DotSettings b/SJZY.Track.Api.sln.DotSettings new file mode 100644 index 00000000..2363a683 --- /dev/null +++ b/SJZY.Track.Api.sln.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/src/SJZY.Track.Api/SJZY.Track.Api.csproj b/src/SJZY.Track.Api/SJZY.Track.Api.csproj index 44113706..0dd07648 100644 --- a/src/SJZY.Track.Api/SJZY.Track.Api.csproj +++ b/src/SJZY.Track.Api/SJZY.Track.Api.csproj @@ -26,7 +26,7 @@ - + diff --git a/src/SJZY.Track.Api/SJZYTrackApiModule.cs b/src/SJZY.Track.Api/SJZYTrackApiModule.cs index 93e04188..07bb3fee 100644 --- a/src/SJZY.Track.Api/SJZYTrackApiModule.cs +++ b/src/SJZY.Track.Api/SJZYTrackApiModule.cs @@ -9,7 +9,7 @@ using SJZY.Expand.ABP.Core.Prometheus; using SJZY.Expand.ABP.Core.Redis; using SJZY.Expand.ABP.Core.Swagger; using SJZY.Track.Application; -using SJZY.Track.Repository; +using SJZY.Track.Infrastructure; using Volo.Abp; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Serilog; @@ -28,7 +28,7 @@ namespace SJZY.Track.Api typeof(AbpAspNetCoreMvcModule), typeof(AbpAspNetCoreSerilogModule), typeof(ApplicationModule), - typeof(SJZYTrackRepositoryModule) + typeof(SJZYTrackInfrastructureModule) )] public class SJZYTrackApiModule : AbpModule { diff --git a/src/SJZY.Track.Application/ApplicationModule.cs b/src/SJZY.Track.Application/ApplicationModule.cs index ba3bc813..94127ff2 100644 --- a/src/SJZY.Track.Application/ApplicationModule.cs +++ b/src/SJZY.Track.Application/ApplicationModule.cs @@ -2,6 +2,7 @@ using SJZY.Track.Application.Localization; using SJZY.UserCenter.Contracts; using SJZY.UserCenter.SharedModel; +using SJZY.UserCenter.SharedModel.Pub; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AutoMapper; using Volo.Abp.FluentValidation; @@ -18,7 +19,8 @@ namespace SJZY.Track.Application typeof(AbpLocalizationModule), typeof(AbpVirtualFileSystemModule), typeof(AbpHttpClientModule), - typeof(SJZYTrackDomainModule) + typeof(SJZYTrackDomainModule), + typeof(SjzyUserCenterHttpApiModule) )] public class ApplicationModule : AbpModule { @@ -46,6 +48,11 @@ namespace SJZY.Track.Application .AddBaseTypes(typeof(SjzyBasicLocalization)) .AddVirtualJson("/Localization/Resources"); }); + //授权拦截提示 + context.Services.Configure(options => + { + options.Filters.Add(new ApiAsyncAuthorizationFilter()); + }); //用户中心 context.Services.AddHttpClientProxies(typeof(SjzyUserCenterHttpApiModule).Assembly, "UserCenter", false); diff --git a/src/SJZY.Track.Application/AutoMapper/OrderAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/OrderAutoMapperProfile.cs index 2dac9751..a8d93386 100644 --- a/src/SJZY.Track.Application/AutoMapper/OrderAutoMapperProfile.cs +++ b/src/SJZY.Track.Application/AutoMapper/OrderAutoMapperProfile.cs @@ -1,6 +1,9 @@ using AutoMapper; +using AutoMapper.Internal.Mappers; using SJZY.Track.Application.Dtos.ProvideServices; using SJZY.Track.Domain.Aggregates.OrderAggregate; +using SJZY.Track.Domain.Dtos.Order; +using System.Diagnostics; namespace SJZY.Track.Application.AutoMapper; @@ -8,12 +11,16 @@ public class OrderAutoMapperProfile : Profile { public OrderAutoMapperProfile() { - CreateMap(MemberList.None); + CreateMap(MemberList.None); CreateMap(MemberList.None); CreateMap(MemberList.None) .ForMember(dest => dest.ServiceProviderId, opt => opt.MapFrom(m => m.ServiceProviderId ?? 0)) .ForMember(dest => dest.TrackTemplateId, opt => opt.MapFrom(m => m.TemplateId)); CreateMap(MemberList.None); + + CreateMap(MemberList.None); + CreateMap(MemberList.None); + CreateMap, UnifyPageResultDto>(MemberList.None); } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs new file mode 100644 index 00000000..da6207a5 --- /dev/null +++ b/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs @@ -0,0 +1,17 @@ +using AutoMapper; +using SJZY.Track.Application.Dtos.TrackPull; +using SJZY.Track.Domain.Aggregates.TrackPullAggregate; +using Volo.Abp.AutoMapper; + +namespace SJZY.Track.Application.AutoMapper; + +public class TrackPullAutoMapperProfile : Profile +{ + public TrackPullAutoMapperProfile() + { + CreateMap(MemberList.None); + CreateMap(MemberList.None).Ignore(dest => dest.Id) + .ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => false)); + CreateMap(MemberList.None); + } +} \ No newline at end of file diff --git a/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs new file mode 100644 index 00000000..420b0e23 --- /dev/null +++ b/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs @@ -0,0 +1,10 @@ +using AutoMapper; + +namespace SJZY.Track.Application.AutoMapper; + +public class TrackPushAutoMapperProfile : Profile +{ + public TrackPushAutoMapperProfile() + { + } +} \ No newline at end of file diff --git a/src/SJZY.Track.Application/Dtos/ProvideServices/DeleteOrderInput.cs b/src/SJZY.Track.Application/Dtos/ProvideServices/DeleteOrderInput.cs index b48f8af7..c4fba2a8 100644 --- a/src/SJZY.Track.Application/Dtos/ProvideServices/DeleteOrderInput.cs +++ b/src/SJZY.Track.Application/Dtos/ProvideServices/DeleteOrderInput.cs @@ -1,23 +1,5 @@ -using System.ComponentModel.DataAnnotations; - -namespace SJZY.Track.Application.Dtos.ProvideServices; +namespace SJZY.Track.Application.Dtos.ProvideServices; public class DeleteOrderInput : OrderNoInfo { -} - -public class OrderNoInfo -{ - /// - /// 订单类型,必填 - /// - [Required] - public int OrderType { get; set; } - - /// - /// 订单号,必填 - /// - [Required] - [MaxLength(100)] - public string OrderNo { get; set; } = null!; } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Dtos/ProvideServices/GetPageTrackOrderInput.cs b/src/SJZY.Track.Application/Dtos/ProvideServices/GetPageTrackOrderInput.cs index 62a1bdb2..06335e34 100644 --- a/src/SJZY.Track.Application/Dtos/ProvideServices/GetPageTrackOrderInput.cs +++ b/src/SJZY.Track.Application/Dtos/ProvideServices/GetPageTrackOrderInput.cs @@ -8,7 +8,25 @@ namespace SJZY.Track.Application.Dtos.ProvideServices { public class GetPageTrackOrderInput : PageInfoInput { + /// + /// 子系统id + /// + public int SubSystemId { get; set; } + /// + /// 单号 + /// + public List? OrderNos { get; set; } + + /// + /// 创建时间开始 + /// + public DateTime? CreateTimeStart { get; set; } + + /// + /// 创建时间截止 + /// + public DateTime? CreateTimeEnd { get; set; } } /// @@ -16,6 +34,69 @@ namespace SJZY.Track.Application.Dtos.ProvideServices /// public class TrackOrderDto { + /// + /// 轨迹订单id + /// + public int Id { get; set; } + /// + /// 订单类型id + /// + public int OrderType { get; set; } + + /// + /// 订单号 + /// + public string? OrderNumber { get; set; } + + /// + /// 轨迹模版 + /// + public string? TrackTemplateNames { get; set; } + + /// + /// 客户简称 + /// + public string? CustomerShortName { get; set; } + + /// + /// 客户代码 + /// + public string? CustomerCode { get; set; } + + /// + /// 订单明细(json) + /// + public string? OrderDetails { get; set; } + + /// + /// 最新轨迹内容 + /// + public string? NewestTrackContent { get; set; } + + /// + /// 最新轨迹内容英文 + /// + public string? NewestTrackEnContent { get; set; } + + /// + /// 最新轨迹发生地 + /// + public string? NewestTrackPlace { get; set; } + + /// + /// 是否完结 + /// + public bool IsFinish { get; set; } + + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + + /// + /// 子系统 + /// + public string SubSystem { get; set; } } } diff --git a/src/SJZY.Track.Application/Dtos/ProvideServices/OrderNoInfo.cs b/src/SJZY.Track.Application/Dtos/ProvideServices/OrderNoInfo.cs new file mode 100644 index 00000000..6f98fafc --- /dev/null +++ b/src/SJZY.Track.Application/Dtos/ProvideServices/OrderNoInfo.cs @@ -0,0 +1,19 @@ +using System.ComponentModel.DataAnnotations; + +namespace SJZY.Track.Application.Dtos.ProvideServices; + +public class OrderNoInfo +{ + /// + /// 订单类型,必填 + /// + [Required] + public int OrderType { get; set; } + + /// + /// 订单号,必填 + /// + [Required] + [MaxLength(100)] + public string OrderNo { get; set; } = null!; +} \ No newline at end of file diff --git a/src/SJZY.Track.Application/Dtos/ProvideServices/CreateOrderInput.cs b/src/SJZY.Track.Application/Dtos/ProvideServices/UpsertOrderInput.cs similarity index 93% rename from src/SJZY.Track.Application/Dtos/ProvideServices/CreateOrderInput.cs rename to src/SJZY.Track.Application/Dtos/ProvideServices/UpsertOrderInput.cs index 47888316..c03d2478 100644 --- a/src/SJZY.Track.Application/Dtos/ProvideServices/CreateOrderInput.cs +++ b/src/SJZY.Track.Application/Dtos/ProvideServices/UpsertOrderInput.cs @@ -2,7 +2,7 @@ namespace SJZY.Track.Application.Dtos.ProvideServices; -public class CreateOrderInput : UpdateOrderInput +public class UpsertOrderInput : UpdateOrderInput { /// /// 客户id diff --git a/src/SJZY.Track.Application/Dtos/ProvideServices/UpsertTrackInput.cs b/src/SJZY.Track.Application/Dtos/ProvideServices/UpsertTrackInput.cs new file mode 100644 index 00000000..fa2112ee --- /dev/null +++ b/src/SJZY.Track.Application/Dtos/ProvideServices/UpsertTrackInput.cs @@ -0,0 +1,24 @@ +namespace SJZY.Track.Application.Dtos.ProvideServices; + +public class UpsertTrackInput : OrderNoInfo +{ + /// + /// 轨迹内容代码 + /// + public string TrackCode { get; set; } + + /// + /// 轨迹发生地 + /// + public string TrackPlace { get; set; } + + /// + /// 轨迹发生时间 + /// + public DateTime TrackTime { get; set; } + + /// + /// 轨迹发生时区 + /// + public float TraceTimeZone { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Application/Dtos/TrackContents/EditTrackContentInput.cs b/src/SJZY.Track.Application/Dtos/TrackContents/EditTrackContentInput.cs index 23294dfe..9879ffb8 100644 --- a/src/SJZY.Track.Application/Dtos/TrackContents/EditTrackContentInput.cs +++ b/src/SJZY.Track.Application/Dtos/TrackContents/EditTrackContentInput.cs @@ -31,17 +31,17 @@ namespace SJZY.Track.Application.Dtos.TrackContents /// /// 轨迹内容代码 /// - public string Code { get; set; } + public string? Code { get; set; } /// /// 轨迹内容 /// - public string Content { get; set; } + public string? Content { get; set; } /// /// 轨迹内容英文 /// - public string EnContent { get; set; } + public string? EnContent { get; set; } /// /// 轨迹标记id diff --git a/src/SJZY.Track.Application/Dtos/TrackContents/GetPageTrackContentInput.cs b/src/SJZY.Track.Application/Dtos/TrackContents/GetPageTrackContentInput.cs index a494d030..7a009ccb 100644 --- a/src/SJZY.Track.Application/Dtos/TrackContents/GetPageTrackContentInput.cs +++ b/src/SJZY.Track.Application/Dtos/TrackContents/GetPageTrackContentInput.cs @@ -15,8 +15,8 @@ namespace SJZY.Track.Application.Dtos.TrackContents /// /// 关键字 - /// - public string Keywords { get; set; } + /// + public string Keywords { get; set; } = ""; } public class GetTrackContentListDto diff --git a/src/SJZY.Track.Application/Dtos/TrackFlags/EditTrackFlagInput.cs b/src/SJZY.Track.Application/Dtos/TrackFlags/EditTrackFlagInput.cs index 05c9b56c..901f5e5a 100644 --- a/src/SJZY.Track.Application/Dtos/TrackFlags/EditTrackFlagInput.cs +++ b/src/SJZY.Track.Application/Dtos/TrackFlags/EditTrackFlagInput.cs @@ -26,12 +26,12 @@ namespace SJZY.Track.Application.Dtos.TrackFlags /// /// 标记 /// - public string Flag { get; set; } + public string? Flag { get; set; } /// /// 代码 /// - public string Code { get; set; } + public string? Code { get; set; } /// /// 是否完结 diff --git a/src/SJZY.Track.Application/Dtos/TrackPull/EditTrackPullConfigInput.cs b/src/SJZY.Track.Application/Dtos/TrackPull/EditTrackPullConfigInput.cs new file mode 100644 index 00000000..71fe55cf --- /dev/null +++ b/src/SJZY.Track.Application/Dtos/TrackPull/EditTrackPullConfigInput.cs @@ -0,0 +1,71 @@ +namespace SJZY.Track.Application.Dtos.TrackPull; + +public class EditTrackPullConfigInput +{ + public int? Id { get; set; } + + /// + /// 操作类型 + /// + public OptionTypeNoNull Options { get; set; } + + /// + /// 拉取轨迹订单号 + /// + public string OrderNoName { get; set; } + + /// + /// 返参解析对象 + /// + public int ParseMethod { get; set; } + + /// + /// 定时任务(分钟) + /// + public int PullInterval { get; set; } + + /// + /// 服务商id + /// + public int ServiceProviderId { get; set; } + + /// + /// 子系统id + /// + public int SubSystemId { get; set; } + + /// + /// 拉取轨迹时区 + /// + public string TackTimeZoneName { get; set; } + + /// + /// 拉取轨迹内容代码 + /// + public string TrackContentCodeName { get; set; } + + /// + /// 拉取轨迹内容 + /// + public string TrackContentName { get; set; } + + /// + /// 拉取轨迹发生地 + /// + public string TrackPlaceName { get; set; } + + /// + /// 拉取轨迹状态 + /// + public string TrackStatusName { get; set; } + + /// + /// 轨迹模板id + /// + public int TrackTemplateId { get; set; } + + /// + /// 拉取轨迹发生时间 + /// + public string TrackTimeName { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Application/Dtos/TrackPull/UpdateTrackPullContentInput.cs b/src/SJZY.Track.Application/Dtos/TrackPull/UpdateTrackPullContentInput.cs new file mode 100644 index 00000000..74a54567 --- /dev/null +++ b/src/SJZY.Track.Application/Dtos/TrackPull/UpdateTrackPullContentInput.cs @@ -0,0 +1,51 @@ +namespace SJZY.Track.Application.Dtos.TrackPull; + +public class UpdateTrackPullContentInput +{ + public int Id { get; set; } + + /// + /// 服务商轨迹代码参数值 + /// + public string TrackContentCodeValue { get; set; } + + /// + /// 轨迹内容id + /// + public int TrackContentId { get; set; } + + /// + /// 服务商轨迹内容参数值 + /// + public string TrackContentValue { get; set; } + + /// + /// 轨迹关键词(正向) + /// + public string TrackKeyword { get; set; } + + /// + /// 轨迹关键词(反向) + /// + public string TrackKeywordReverse { get; set; } + + /// + /// 轨迹发生地参数值 + /// + public int? TrackPlaceValue { get; set; } + + /// + /// 轨迹拉取配置id + /// + public int TrackPullConfigId { get; set; } + + /// + /// 服务商轨迹状态参数值 + /// + public string TrackStatusValue { get; set; } + + /// + /// 轨迹时区GMT + /// + public string TrackTimeZone { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Application/Dtos/TrackStatus/EditTrackStatusInput.cs b/src/SJZY.Track.Application/Dtos/TrackStatus/EditTrackStatusInput.cs index a77a4f1c..ce9a0ebf 100644 --- a/src/SJZY.Track.Application/Dtos/TrackStatus/EditTrackStatusInput.cs +++ b/src/SJZY.Track.Application/Dtos/TrackStatus/EditTrackStatusInput.cs @@ -31,16 +31,16 @@ namespace SJZY.Track.Application.Dtos.TrackStatus /// /// 轨迹状态代码 /// - public string Code { get; set; } + public string? Code { get; set; } /// /// 轨迹状态 /// - public string TrackStatus { get; set; } + public string? TrackStatus { get; set; } /// /// 轨迹状态英文 /// - public string EntrackStatus { get; set; } + public string? EntrackStatus { get; set; } } } diff --git a/src/SJZY.Track.Application/Dtos/TrackStatus/GetTrackStatusListDto.cs b/src/SJZY.Track.Application/Dtos/TrackStatus/GetTrackStatusListDto.cs index ec218c97..ecdb123d 100644 --- a/src/SJZY.Track.Application/Dtos/TrackStatus/GetTrackStatusListDto.cs +++ b/src/SJZY.Track.Application/Dtos/TrackStatus/GetTrackStatusListDto.cs @@ -65,11 +65,11 @@ namespace SJZY.Track.Application.Dtos.TrackStatus /// /// 子系统id /// - public int SubSystemId { get; set; } + public int SubSystemId { get; set; } /// /// 关键字 /// - public string Keywords { get; set; } + public string Keywords { get; set; } = ""; } } diff --git a/src/SJZY.Track.Application/Dtos/TrackTemplates/GetPageTrackTemplateInput.cs b/src/SJZY.Track.Application/Dtos/TrackTemplates/GetPageTrackTemplateInput.cs index 357784df..3be009ac 100644 --- a/src/SJZY.Track.Application/Dtos/TrackTemplates/GetPageTrackTemplateInput.cs +++ b/src/SJZY.Track.Application/Dtos/TrackTemplates/GetPageTrackTemplateInput.cs @@ -13,8 +13,8 @@ /// /// 关键字 /// - public string Keywords { get; set; } - + public string Keywords { get; set; } = ""; + /// /// 轨迹模版id,轨迹映射的查询使用 /// diff --git a/src/SJZY.Track.Application/Dtos/TrackTemplates/GetTrackDetailDto.cs b/src/SJZY.Track.Application/Dtos/TrackTemplates/GetTrackDetailDto.cs index 6269ba0b..f4ac73d8 100644 --- a/src/SJZY.Track.Application/Dtos/TrackTemplates/GetTrackDetailDto.cs +++ b/src/SJZY.Track.Application/Dtos/TrackTemplates/GetTrackDetailDto.cs @@ -85,11 +85,11 @@ /// /// 模板名称 /// - public string Name { set; get; } + public string? Name { set; get; } /// /// 模板代码 /// - public string Code { set; get; } + public string? Code { set; get; } } } diff --git a/src/SJZY.Track.Application/SJZY.Track.Application.csproj b/src/SJZY.Track.Application/SJZY.Track.Application.csproj index e8f1425c..ccc853da 100644 --- a/src/SJZY.Track.Application/SJZY.Track.Application.csproj +++ b/src/SJZY.Track.Application/SJZY.Track.Application.csproj @@ -17,12 +17,12 @@ - - - - - - + + + + + + diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderLinkService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderLinkService.cs index d4ec1f87..e21ca538 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/OrderLinkService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderLinkService.cs @@ -1,5 +1,6 @@ using SJZY.Track.Application.Dtos.ProvideServices; using SJZY.Track.Domain.Aggregates.OrderAggregate; +using SJZY.Track.Domain.Queries; namespace SJZY.Track.Application.Services.ProvideServices; diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs index 7381144c..8b6b8e19 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs @@ -1,5 +1,7 @@ -using SJZY.Track.Application.Dtos.ProvideServices; +using SJZY.Expand.ABP.Core.Common.Dto; +using SJZY.Track.Application.Dtos.ProvideServices; using SJZY.Track.Domain.Aggregates.OrderAggregate; +using SJZY.Track.Domain.Dtos.Order; namespace SJZY.Track.Application.Services.ProvideServices; @@ -22,8 +24,8 @@ public class OrderService : ApplicationService /// /// /// - [HttpPost("Order/CreateOrUpdate")] - public async Task CreateOrUpdateOrderAsync(CreateOrderInput input) + [HttpPost("Order/Upsert")] + public async Task UpsertAsync(UpsertOrderInput input) { var order = await _orderRepository.GetFirstAsync(x => x.OrderType == input.OrderType && x.OrderNo == input.OrderNo); @@ -34,7 +36,7 @@ public class OrderService : ApplicationService return "更新成功"; } - order = ObjectMapper.Map(input); + order = ObjectMapper.Map(input); order.SubSystemId = 1; order.OrderTemplates = ObjectMapper.Map, List>(input.Templates); order.OrderFlights = ObjectMapper.Map, List>(input.FlightInfos); @@ -59,12 +61,13 @@ public class OrderService : ApplicationService throw new BusinessException(message: $"订单:{input.OrderNo}不存在"); } - await _orderRepository.SoftDeleteAsync(x => x.Id == orderId); + await _orderRepository.DeleteOrderAsync(orderId); return true; } #region 轨迹订单明细 + /// /// 根据轨迹订单id获取轨迹订单明细列表 /// @@ -75,19 +78,25 @@ public class OrderService : ApplicationService { return null; } + #endregion #region 轨迹订单列表 + /// - /// + /// 获取分页的轨迹订单 /// /// /// [HttpPost("/Order/GetTrackOrderList")] public async Task> GetPageTrackOrder(GetPageTrackOrderInput input) { - return null; + var vo = ObjectMapper.Map(input); + var pageList = await _orderRepository.GetPageTrackOrder(vo); + var pageResultDto = ObjectMapper.Map, UnifyPageResultDto>(pageList); + return pageResultDto; } + #endregion private async Task UpdateOrderAsync(UpdateOrderInput input, OrderEntity order) diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs index 7792631f..587c316b 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs @@ -1,7 +1,6 @@ using SJZY.Track.Application.Dtos.ProvideServices; -using SJZY.Track.Domain.Aggregates.OrderAggregate; using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate; -using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; +using SJZY.Track.Domain.Queries; namespace SJZY.Track.Application.Services.ProvideServices; @@ -12,15 +11,13 @@ namespace SJZY.Track.Application.Services.ProvideServices; public class TrackQueryService : ApplicationService { private readonly ITrackDetailsRepository _trackDetailsRepository; - private readonly IOrderRepository _orderRepository; - private readonly ITrackTemplateRepository _trackTemplateRepository; + private readonly ITrackQueries _trackQueries; - public TrackQueryService(ITrackDetailsRepository trackDetailsRepository, IOrderRepository orderRepository, - ITrackTemplateRepository trackTemplateRepository) + public TrackQueryService(ITrackDetailsRepository trackDetailsRepository, + ITrackQueries trackQueries) { _trackDetailsRepository = trackDetailsRepository; - _orderRepository = orderRepository; - _trackTemplateRepository = trackTemplateRepository; + _trackQueries = trackQueries; } /// @@ -29,8 +26,8 @@ public class TrackQueryService : ApplicationService /// /// /// - [HttpPost("TrackQuery/GetByOrderNos")] - public async Task> GetByOrderNosAsync(GetTrackInput input) + [HttpPost("Track/Query")] + public async Task> QueryAsync(GetTrackInput input) { if (input.OrderNos.Count > 500) { @@ -38,8 +35,8 @@ public class TrackQueryService : ApplicationService } var res = new List(); - input.OrderNos = input.OrderNos.Distinct().ToList(); - var details = await _trackDetailsRepository.GetListAsync(input.OrderNos); + input.OrderNos = input.OrderNos.Distinct().ToList(); // 单号去重 + var details = await _trackDetailsRepository.GetListAsync(input.OrderType, input.OrderNos); var isTurn = input.TimeZone != 0; foreach (var group in details.GroupBy(x => x.OrderId)) @@ -78,18 +75,21 @@ public class TrackQueryService : ApplicationService list.ForEach(item => item.TrackDetails.Sort((a, b) => b.Time.CompareTo(a.Time))); break; case SortMethod.ByTemplate: - var orderTemplates = await _orderRepository.GetOrderTemplatesAsync(input.OrderType, input.OrderNos); + var orderTemplates = await _trackQueries + .GetOrderTemplateLinksAsync(input.OrderType, input.OrderNos); var distinctTemplateIds = orderTemplates.Select(x => x.TemplateId).Distinct().ToList(); - var templateContent = - await _trackTemplateRepository.GetTemplateContentOrderlyAsync(distinctTemplateIds); + var templateContent = await _trackQueries.GetOrderedTrackCodesAsync(distinctTemplateIds); list.ForEach(item => { - var template = orderTemplates.FirstOrDefault(x => x.OrderNo == item.OrderNo); - if (template == default) return; - var codes = templateContent - .Where(x => x.TemplateId == template.TemplateId) - .Select(x => x.Code) - .ToList(); + var codes = new List(); + // 多模板拼接显示 + foreach (var orderTemplate in orderTemplates.Where(x => x.OrderNo == item.OrderNo)) + { + codes.AddRange(templateContent + .Where(t => t.TemplateId == orderTemplate.TemplateId) + .Select(t => t.Code)); + } + item.TrackDetails = item.TrackDetails .Where(x => codes.Contains(x.Code)) // 剔除不在模板内容中的元素 .OrderBy(x => codes.IndexOf(x.Code)) // 按照在模板内容的位置排序 diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs index c5cddf06..7077cfb3 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs @@ -1,5 +1,88 @@ -namespace SJZY.Track.Application.Services.ProvideServices; +using DotNetCore.CAP; +using SJZY.Track.Application.Dtos.ProvideServices; +using SJZY.Track.Domain.Aggregates.OrderAggregate; +using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate; +using SJZY.Track.Domain.Queries; +using SJZY.UserCenter.HttpApi.Services; -public class TrackService +namespace SJZY.Track.Application.Services.ProvideServices; + +/// +/// 轨迹服务 +/// +[ApiExplorerSettings(GroupName = "提供接口")] +public class TrackService : ApplicationService { + private readonly IOrderRepository _orderRepository; + private readonly ITrackDetailsRepository _trackDetailsRepository; + private readonly ITrackQueries _trackQueries; + private readonly ICapPublisher _capPublisher; + + public TrackService(ITrackQueries trackQueries, IOrderRepository orderRepository, + ITrackDetailsRepository trackDetailsRepository, ICapPublisher capPublisher) + { + _trackQueries = trackQueries; + _orderRepository = orderRepository; + _trackDetailsRepository = trackDetailsRepository; + _capPublisher = capPublisher; + } + + /// + /// 新增/更新订单轨迹接口 + /// + /// + /// + /// + [HttpPost("Track/Upsert")] + public async Task UpsertTrackAsync(UpsertTrackInput input) + { + var orderId = await _orderRepository.GetFirstAsync(x => + x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => x.Id); + if (orderId == default) + { + throw new BusinessException(message: $"订单:{input.OrderNo}不存在"); + } + + // 不存在则新增轨迹,存在则更新 + var track = await _trackDetailsRepository.GetFirstOrDefaultAsync(orderId, input.TrackCode); + if (track == default) + { + var trackContent = await _trackQueries.MatchTrackContentAsync(orderId, input.TrackCode); + if (trackContent == default) + { + throw new BusinessException(message: $"订单:{input.OrderNo} 所绑定的模板,没有一条内容可以匹配轨迹代码:{input.TrackCode}"); + } + + track = new TrackDetailsIndex + { + OrderId = orderId, + OrderNo = input.OrderNo, + OrderType = input.OrderType, + TrackStatus = trackContent.Status, + TrackCode = input.TrackCode, + TrackContent = trackContent.Content, + TrackEnContent = trackContent.EnContent, + TrackPlace = input.TrackPlace, + TrackTime = input.TrackTime, + TraceTimeZone = input.TraceTimeZone, + CreateUserId = CurrentUserRequest.CurrentUser.UserId, + CreateTime = DateTime.Now + }; + await _trackDetailsRepository.CreateAsync(track); + } + else + { + track.UpdateUserId = CurrentUserRequest.CurrentUser.UserId; + track.UpdateTime = DateTime.Now; + track.TrackPlace = input.TrackPlace; + track.TrackTime = input.TrackTime; + track.TraceTimeZone = input.TraceTimeZone; + await _trackDetailsRepository.UpdateAsync(track); + } + + // 根据订单关联关系向下刷,不同子系统还需要做内容映射 + + // 推送 + return true; + } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs index 004198e0..fcd56e92 100644 --- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs +++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs @@ -1,8 +1,13 @@ using Microsoft.Extensions.Localization; +using SJZY.Expand.ABP.Core.Localization; +using SJZY.Expand.ABP.Core.PublicMethords; +using SJZY.Track.Application.Dtos.TrackPull; using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackPullAggregate; +using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Dtos.Common; using SJZY.Track.Domain.Dtos.TrackPull; +using System.Linq.Expressions; using Volo.Abp.DependencyInjection; namespace SJZY.Track.Application.Services.TrackPull; @@ -16,13 +21,16 @@ public class TrackPullService : ApplicationService, ITransientDependency { private readonly IStringLocalizer _stringLocalizer; private readonly ITrackPullConfigRepository _trackPullConfigRepository; + private readonly ITrackTemplateRepository _trackTemplateRepository; public TrackPullService( IStringLocalizer stringLocalizer, - ITrackPullConfigRepository trackPullConfigRepository) + ITrackPullConfigRepository trackPullConfigRepository, + ITrackTemplateRepository trackTemplateRepository) { _stringLocalizer = stringLocalizer; _trackPullConfigRepository = trackPullConfigRepository; + _trackTemplateRepository = trackTemplateRepository; } /// @@ -68,4 +76,132 @@ public class TrackPullService : ApplicationService, ITransientDependency { return await _trackPullConfigRepository.GetContentDetailAsync(id); } + + /// + /// 轨迹拉取配置编辑 + /// + /// + /// + [HttpPost("Edit")] + public async Task EditAsync([FromBody] EditTrackPullConfigInput input) + { + if (input.Options != OptionTypeNoNull.删除) + { + Expression> isAnyExp = x => + x.SubSystemId == input.SubSystemId && x.TrackTemplateId == input.TrackTemplateId && x.ServiceProviderId == input.ServiceProviderId; + if (input.Options == OptionTypeNoNull.修改) isAnyExp.And(x => x.Id != input.Id); + + if (await _trackPullConfigRepository.IsAnyAsync(isAnyExp)) + throw new BusinessException(message: _stringLocalizer["IsTrackPullConfigAny"]); + } + + switch (input.Options) + { + case OptionTypeNoNull.新增: + { + var trackPullEntity = ObjectMapper.Map(input); + var trackPullParamsEntity = ObjectMapper.Map(input); + + var trackTemplateContentEntities = await _trackTemplateRepository.GetContentListAsync(x => x.TrackTemplateId == input.TrackTemplateId); + + var trackPullContentEntities = new List(); + + using (var ts = TransactionScopeHelper.Create()) + { + int id = await _trackPullConfigRepository.InsertReturnIdentityAsync(trackPullEntity); + + trackPullParamsEntity.PullOrPushConfigId = id; + await _trackPullConfigRepository.InsertParamsAsync(trackPullParamsEntity); + + foreach (var item in trackTemplateContentEntities) + { + trackPullContentEntities.Add(new() + { + TrackPullConfigId = id, + TrackContentId = item.TrackContentId + }); + } + await _trackPullConfigRepository.InsertContentRangeAsync(trackPullContentEntities); + + ts.Complete(); + } + } + break; + + case OptionTypeNoNull.修改: + { + var oldTrackPullEntity = await _trackPullConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]); + + var oldTrackPullParamsEntity = await _trackPullConfigRepository.GetParamsSingleAsync(x => x.PullOrPushConfigId == input.Id && !x.IsPush); + + var trackPullContentEntities = new List(); + + if (oldTrackPullEntity.TrackTemplateId != input.TrackTemplateId) + { + var trackTemplateContentEntities = await _trackTemplateRepository.GetContentListAsync(x => x.TrackTemplateId == input.TrackTemplateId); + + foreach (var item in trackTemplateContentEntities) + { + trackPullContentEntities.Add(new() + { + TrackPullConfigId = oldTrackPullEntity.Id, + TrackContentId = item.TrackContentId + }); + } + } + + ObjectMapper.Map(input, oldTrackPullEntity); + ObjectMapper.Map(input, oldTrackPullParamsEntity); + + using (var ts = TransactionScopeHelper.Create()) + { + await _trackPullConfigRepository.UpdateAsync(oldTrackPullEntity); + await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPullParamsEntity); + + if (oldTrackPullEntity.TrackTemplateId != input.TrackTemplateId) + { + await _trackPullConfigRepository.SoftDeleteContentAsync(x => x.TrackPullConfigId == input.Id); + await _trackPullConfigRepository.InsertContentRangeAsync(trackPullContentEntities); + } + + ts.Complete(); + } + } + break; + + case OptionTypeNoNull.删除: + using (var ts = TransactionScopeHelper.Create()) + { + await _trackPullConfigRepository.SoftDeleteAsync(x => x.Id == input.Id); + await _trackPullConfigRepository.SoftDeleteParamsAsync(x => x.PullOrPushConfigId == input.Id && !x.IsPush); + await _trackPullConfigRepository.SoftDeleteContentAsync(x => x.TrackPullConfigId == input.Id); + + ts.Complete(); + } + break; + + default: + throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum, + nameof(EditTrackPullConfigInput.Options)]); + } + + return true; + } + + /// + /// 轨迹拉取配置内容修改 + /// + /// + /// + [HttpPost("UpdateContent")] + public async Task UpdateContentAsync([FromBody] UpdateTrackPullContentInput input) + { + var oldTrackPullContentEntity = await _trackPullConfigRepository.GetContentByIdAsync(input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]); + + ObjectMapper.Map(input, oldTrackPullContentEntity); + + await _trackPullConfigRepository.UpdateContentAsync(oldTrackPullContentEntity); + + return true; + } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs new file mode 100644 index 00000000..f303cc4c --- /dev/null +++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs @@ -0,0 +1,60 @@ +using Microsoft.Extensions.Localization; +using SJZY.Track.Application.Localization; +using SJZY.Track.Domain.Aggregates.TrackPushAggregate; +using SJZY.Track.Domain.Dtos.Common; +using SJZY.Track.Domain.Dtos.TrackPush; +using Volo.Abp.DependencyInjection; + +namespace SJZY.Track.Application.Services.TrackPush; + +/// +/// 轨迹推送 +/// +[ApiExplorerSettings(GroupName = "轨迹推送")] +[Route("/Track/PushConfig")] +public class TrackPushService : ApplicationService, ITransientDependency +{ + private readonly IStringLocalizer _stringLocalizer; + private readonly ITrackPushConfigRepository _trackPushConfigRepository; + + public TrackPushService( + IStringLocalizer stringLocalizer, + ITrackPushConfigRepository trackPushConfigRepository) + { + _stringLocalizer = stringLocalizer; + _trackPushConfigRepository = trackPushConfigRepository; + } + + /// + /// 轨迹推送配置列表 + /// + /// + /// + [HttpPost("GetPage")] + public async Task> GetPageAsync([FromBody] KeywordsInputVO input) + { + return await _trackPushConfigRepository.GetPageAsync(input); + } + + /// + /// 轨迹推送配置内容列表 + /// + /// + /// + [HttpPost("GetContentPage")] + public async Task> GetContentPageAsync([FromBody] GetTrackPushContentPageInputVO input) + { + return await _trackPushConfigRepository.GetContentPageAsync(input); + } + + /// + /// 轨迹推送配置详情 + /// + /// + /// + [HttpGet("GetDetail")] + public async Task GetDetailAsync(int id) + { + return await _trackPushConfigRepository.GetDetailAsync(id); + } +} \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs b/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs index 7b076868..bd58470f 100644 --- a/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs +++ b/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.Localization; +using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.Localization; using SJZY.Track.Application.Dtos.TrackStatus; using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; diff --git a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs index 422aafde..e77a574d 100644 --- a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs +++ b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs @@ -1,4 +1,5 @@ using System.Linq.Expressions; +using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.Localization; using SJZY.Expand.ABP.Core.Localization; using SJZY.Track.Application.Dtos.TrackTemplates; diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs index e076b731..93d162e2 100644 --- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs @@ -11,13 +11,14 @@ public interface IOrderRepository : IBasicRepository /// Task CreateOrderAsync(OrderEntity order); + Task> GetOrderDetails(GetOrderDetailsInputVO input); + /// - /// 根据订单号,获取订单模板 + /// 获取分页的轨迹订单 /// - /// 订单类型 - /// + /// /// - Task> GetOrderTemplatesAsync(int orderType, List distinctOrderNumbers); + Task> GetPageTrackOrder(GetPageTrackOrderInputVO input); /// /// 关联订单 @@ -39,4 +40,11 @@ public interface IOrderRepository : IBasicRepository /// /// Task UpdateOrderAsync(OrderEntity order); + + /// + /// 删除订单 + /// + /// + /// + Task DeleteOrderAsync(int orderId); } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderFlightEntity.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderFlightEntity.cs index c76d4d54..4e5f2017 100644 --- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderFlightEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderFlightEntity.cs @@ -4,7 +4,7 @@ /// 订单航班表(1:N) /// [SugarTable("t_order_flight")] -public class OrderFlightEntity : ICreateBaicEntity, IEntity +public class OrderFlightEntity : ICreateBaicEntity, ISoftDeleteBasicEntity, IEntity { /// /// 自增主键 @@ -33,10 +33,18 @@ public class OrderFlightEntity : ICreateBaicEntity, IEntity /// /// 创建人 /// + [SugarColumn(ColumnName = "CreateUserId")] public int CreateUserId { get; set; } /// /// 创建时间 /// + [SugarColumn(ColumnName = "CreateTime")] public DateTime? CreateTime { get; set; } + + /// + /// 是否删除 + /// + [SugarColumn(ColumnName = "IsDeleted")] + public bool IsDeleted { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderLinkEntity.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderLinkEntity.cs index 68b20740..112fc472 100644 --- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderLinkEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderLinkEntity.cs @@ -4,7 +4,7 @@ /// 轨迹订单关联表(1:N) /// [SugarTable("t_order_link")] -public class OrderLinkEntity : ICreateBaicEntity, IEntity +public class OrderLinkEntity : ICreateBaicEntity, ISoftDeleteBasicEntity, IEntity { /// /// 自增主键 @@ -39,10 +39,18 @@ public class OrderLinkEntity : ICreateBaicEntity, IEntity /// /// 创建人 /// + [SugarColumn(ColumnName = "CreateUserId")] public int CreateUserId { get; set; } /// /// 创建时间 /// + [SugarColumn(ColumnName = "CreateTime")] public DateTime? CreateTime { get; set; } + + /// + /// 是否删除 + /// + [SugarColumn(ColumnName = "IsDeleted")] + public bool IsDeleted { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderTemplateEntity.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderTemplateEntity.cs index 91219904..88559ae6 100644 --- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderTemplateEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/OrderTemplateEntity.cs @@ -4,7 +4,7 @@ /// 轨迹订单模板表(1:N) /// [SugarTable("t_order_template")] -public class OrderTemplateEntity : ICreateBaicEntity, IEntity +public class OrderTemplateEntity : ICreateBaicEntity, ISoftDeleteBasicEntity, IEntity { /// /// 自增主键 @@ -30,6 +30,21 @@ public class OrderTemplateEntity : ICreateBaicEntity, IEntity [SugarColumn(ColumnName = "TrackTemplateId")] public int TrackTemplateId { get; set; } + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "CreateUserId")] public int CreateUserId { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "CreateTime")] public DateTime? CreateTime { get; set; } + + /// + /// 是否删除 + /// + [SugarColumn(ColumnName = "IsDeleted")] + public bool IsDeleted { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/TrackContentEntity.cs b/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/TrackContentEntity.cs index adf4b23b..02fac985 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/TrackContentEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/TrackContentEntity.cs @@ -16,19 +16,19 @@ public class TrackContentEntity : IFullAuditedBasicEntitys, IAggregateRoot /// 轨迹内容代码 /// [SugarColumn(ColumnName = "Code")] - public string Code { get; set; } + public string Code { get; set; } = null!; /// /// 轨迹内容 /// [SugarColumn(ColumnName = "Content")] - public string Content { get; set; } + public string Content { get; set; } = null!; /// /// 轨迹内容英文 /// [SugarColumn(ColumnName = "EnContent")] - public string EnContent { get; set; } + public string EnContent { get; set; } = null!; /// /// 子系统id diff --git a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs index 5e83c476..444dd072 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsRepository.cs @@ -4,9 +4,13 @@ namespace SJZY.Track.Domain.Aggregates.TrackDetailsAggregate; public interface ITrackDetailsRepository { - Task WriteTrack(TrackDetailsIndex index); + Task GetFirstOrDefaultAsync(int orderId, string inputTrackCode); - Task> GetListAsync(List orderNos); + Task UpdateAsync(TrackDetailsIndex index); + + Task CreateAsync(TrackDetailsIndex index); + + Task> GetListAsync(int orderType, List orderNos); Task<(List list, long total)> GetListAsync(TrackDetailsQueryInput input); } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs index 9040ecc2..a8160da6 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/TrackDetailsIndex.cs @@ -21,7 +21,7 @@ public class TrackDetailsIndex : IdBaseIndex /// /// 订单类型(主数据枚举TrackOrderType) /// - public string OrderType { get; set; } + public int OrderType { get; set; } /// /// 轨迹状态 diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs index 6de7445c..c7a36732 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs @@ -32,4 +32,20 @@ public interface ITrackPullConfigRepository : IBasicRepository /// Task GetContentDetailAsync(int id); + + Task InsertParamsAsync(TrackPushPullParamsConfigEntity insertObj); + + Task InsertContentRangeAsync(List insertObjs); + + Task GetParamsSingleAsync(Expression> whereExpression); + + Task UpdateParamsAsync(TrackPushPullParamsConfigEntity updateObj); + + Task SoftDeleteContentAsync(Expression> whereExpression); + + Task SoftDeleteParamsAsync(Expression> whereExpression); + + Task GetContentByIdAsync(int id); + + Task UpdateContentAsync(TrackPullContentConfigEntity updateObj); } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs index abceffa6..9050f090 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs @@ -1,5 +1,13 @@ -namespace SJZY.Track.Domain.Aggregates.TrackPushAggregate; +using SJZY.Track.Domain.Dtos.Common; +using SJZY.Track.Domain.Dtos.TrackPush; + +namespace SJZY.Track.Domain.Aggregates.TrackPushAggregate; public interface ITrackPushConfigRepository : IBasicRepository { + Task> GetPageAsync(KeywordsInputVO input); + + Task> GetContentPageAsync(GetTrackPushContentPageInputVO input); + + Task GetDetailAsync(int id); } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/TrackStatusAggregate/TrackStatusEntity.cs b/src/SJZY.Track.Domain/Aggregates/TrackStatusAggregate/TrackStatusEntity.cs index 7d1b1a0d..dd98a21d 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackStatusAggregate/TrackStatusEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackStatusAggregate/TrackStatusEntity.cs @@ -16,13 +16,13 @@ public class TrackStatusEntity : IFullAuditedBasicEntitys, IAggregateRoot /// 轨迹状态代码 /// [SugarColumn(ColumnName = "Code")] - public string Code { get; set; } + public string Code { get; set; } = null!; /// /// 轨迹状态英文 /// [SugarColumn(ColumnName = "EnStatus")] - public string EnStatus { get; set; } + public string EnStatus { get; set; } = null!; /// /// 所属节点(主数据枚举ServiceNode) @@ -34,7 +34,7 @@ public class TrackStatusEntity : IFullAuditedBasicEntitys, IAggregateRoot /// 轨迹状态 /// [SugarColumn(ColumnName = "Status")] - public string Status { get; set; } + public string Status { get; set; } = null!; /// /// 子系统id diff --git a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs index 22b3a468..13d2ff0a 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs @@ -4,8 +4,6 @@ namespace SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; public interface ITrackTemplateRepository : IBasicRepository { - Task> GetTemplateContentOrderlyAsync(List distinctTemplateIds); - Task GetDetailAsync(int id); Task> GetPageTrackTemplate(GetPageTrackTemplateVO input); @@ -34,4 +32,7 @@ public interface ITrackTemplateRepository : IBasicRepository UpdateContentAsync(TrackTemplateContentEntity updateObj); Task SoftDeleteContentAsync(int id); + + Task> GetContentListAsync( + Expression> whereExpression); } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/Order/GetOrderDetailsInputVO.cs b/src/SJZY.Track.Domain/Dtos/Order/GetOrderDetailsInputVO.cs new file mode 100644 index 00000000..082b245a --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/Order/GetOrderDetailsInputVO.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SJZY.Track.Domain.Dtos.Order +{ + public class GetOrderDetailsInputVO + { + + } + + public class TrackOrderDetailVO + { + + } +} diff --git a/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs b/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs new file mode 100644 index 00000000..c95fae3e --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/Order/GetPageTrackOrderInputVO.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SJZY.Track.Domain.Dtos.Order +{ + public class GetPageTrackOrderInputVO : PageInfoInput + { + /// + /// 子系统id + /// + public int SubSystemId { get; set; } + + /// + /// 单号 + /// + public List OrderNos { get; set; } + + /// + /// 创建时间开始 + /// + public DateTime? CreateTimeStart { get; set; } + + /// + /// 创建时间截止 + /// + public DateTime? createTimeEnd { get; set; } + } + + /// + /// 轨迹订单VO + /// + public class TrackOrderVO + { + /// + /// 轨迹订单id + /// + public int Id { get; set; } + + /// + /// 订单类型id + /// + public int OrderType { get; set; } + + /// + /// 订单号 + /// + public string? OrderNumber { get; set; } + + /// + /// 轨迹模版 + /// + public string? TrackTemplateNames { get; set; } + + /// + /// 客户简称 + /// + public string? CustomerShortName { get; set; } + + /// + /// 客户代码 + /// + public string? CustomerCode { get; set; } + + /// + /// 订单明细(json) + /// + public string? OrderDetails { get; set; } + + /// + /// 最新轨迹内容 + /// + public string? NewestTrackContent { get; set; } + + /// + /// 最新轨迹内容英文 + /// + public string? NewestTrackEnContent { get; set; } + + /// + /// 最新轨迹发生地 + /// + public string? NewestTrackPlace { get; set; } + + /// + /// 是否完结 + /// + public bool IsFinish { get; set; } + + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + + /// + /// 子系统 + /// + public string SubSystem { get; set; } + } +} diff --git a/src/SJZY.Track.Domain/Dtos/Order/OrderIdentifier.cs b/src/SJZY.Track.Domain/Dtos/Order/OrderIdentifier.cs new file mode 100644 index 00000000..248ec7e9 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/Order/OrderIdentifier.cs @@ -0,0 +1,23 @@ +namespace SJZY.Track.Domain.Dtos.Order; + +/// +/// 订单标识符 +/// +public readonly struct OrderIdentifier +{ + public OrderIdentifier(int orderType, string orderNo) + { + OrderType = orderType; + OrderNo = orderNo; + } + + /// + /// 订单类型 + /// + public int OrderType { get; } + + /// + /// 订单号 + /// + public string OrderNo { get; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateDto.cs b/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateLinkDto.cs similarity index 70% rename from src/SJZY.Track.Domain/Dtos/Order/OrderTemplateDto.cs rename to src/SJZY.Track.Domain/Dtos/Order/OrderTemplateLinkDto.cs index c2655b43..6ca82ed3 100644 --- a/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateDto.cs +++ b/src/SJZY.Track.Domain/Dtos/Order/OrderTemplateLinkDto.cs @@ -1,11 +1,11 @@ namespace SJZY.Track.Domain.Dtos.Order; -public class OrderTemplateDto +public class OrderTemplateLinkDto { /// /// 订单号 /// - public string OrderNo { get; set; } + public string OrderNo { get; set; } = null!; /// /// 模板id diff --git a/src/SJZY.Track.Domain/Dtos/TrackDetails/MatchTrackContentDto.cs b/src/SJZY.Track.Domain/Dtos/TrackDetails/MatchTrackContentDto.cs new file mode 100644 index 00000000..c6e07352 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackDetails/MatchTrackContentDto.cs @@ -0,0 +1,19 @@ +namespace SJZY.Track.Domain.Dtos.TrackDetails; + +public class MatchTrackContentDto +{ + /// + /// 轨迹内容 + /// + public string Content { get; set; } + + /// + /// 轨迹内容英文 + /// + public string EnContent { get; set; } + + /// + /// 轨迹状态 + /// + public string Status { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs index e45b7de8..15d25401 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs @@ -7,7 +7,7 @@ public class GetTrackPullConfigPageOutputVO /// public DateTime? CreateTime { get; set; } - public int? Id { get; set; } + public int Id { get; set; } /// /// 服务商名称 diff --git a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs new file mode 100644 index 00000000..6e9cd961 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs @@ -0,0 +1,98 @@ +using SJZY.Expand.ABP.Core.PublicMethords; + +namespace SJZY.Track.Domain.Dtos.TrackPush; + +public class GetTrackPushConfigDetailOutputVO +{ + /// + /// 客户id + /// + public int CustomId { get; set; } + + /// + /// 客户 + /// + public string CustomName { get; set; } + + /// + /// 推送扩展字段 + /// + public string ExpandFieldsName { get; set; } + + public int Id { get; set; } + + /// + /// 是否自动推送 + /// + public bool IsAutoPush { get; set; } + + /// + /// 推送轨迹订单号 + /// + public string OrderNoName { get; set; } + + /// + /// 服务商 + /// + public string ServiceProvider { get; set; } + + /// + /// 服务商id + /// + public int ServiceProviderId { get; set; } + + /// + /// 子系统 + /// + public string SubSystem { get; set; } + + /// + /// 子系统id + /// + public int SubSystemId { get; set; } + + /// + /// 推送轨迹时区 + /// + public string TackTimeZoneName { get; set; } + + /// + /// 推送轨迹内容代码 + /// + public string TrackContentCodeName { get; set; } + + /// + /// 推送轨迹内容 + /// + public string TrackContentName { get; set; } + + /// + /// 推送轨迹内容英文 + /// + public string TrackEnContentName { get; set; } + + /// + /// 推送轨迹发生地 + /// + public string TrackPlaceName { get; set; } + + /// + /// 推送轨迹状态 + /// + public string TrackStatusName { get; set; } + + /// + /// 轨迹模板 + /// + public List TrackTemplate { get; set; } + + /// + /// 轨迹模板id + /// + public int TrackTemplateId { get; set; } + + /// + /// 推送轨迹发生时间 + /// + public string TrackTimeName { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs new file mode 100644 index 00000000..9b2e3a83 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs @@ -0,0 +1,26 @@ +namespace SJZY.Track.Domain.Dtos.TrackPush; + +public class GetTrackPushConfigPageOutputVO +{ + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + + /// + /// 客户名称 + /// + public string CustomName { get; set; } + + public int Id { get; set; } + + /// + /// 子系统名称 + /// + public string SubSystem { get; set; } + + /// + /// 模板名称 + /// + public string TrackTemplate { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushContentPageInputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushContentPageInputVO.cs new file mode 100644 index 00000000..f0558e95 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushContentPageInputVO.cs @@ -0,0 +1,9 @@ +namespace SJZY.Track.Domain.Dtos.TrackPush; + +public class GetTrackPushContentPageInputVO : PageInfoInput +{ + /// + /// 轨迹推送配置id + /// + public int TrackPushConfigId { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushContentPageOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushContentPageOutputVO.cs new file mode 100644 index 00000000..b3ae2d3f --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushContentPageOutputVO.cs @@ -0,0 +1,56 @@ +namespace SJZY.Track.Domain.Dtos.TrackPush; + +public class GetTrackPushContentPageOutputVO +{ + /// + /// 轨迹内容代码 + /// + public string Code { get; set; } + + /// + /// 轨迹内容 + /// + public string Content { get; set; } + + /// + /// 轨迹内容英文 + /// + public string EnContent { get; set; } + + /// + /// 推送扩展字段 + /// + public string ExpandFieldsValue { get; set; } + + public int Id { get; set; } + + /// + /// 推送单号类型 + /// + public string OrderNoType { get; set; } + + /// + /// 推送排序 + /// + public int Sort { get; set; } + + /// + /// 推送轨迹内容代码 + /// + public string TrackContentCodeValue { get; set; } + + /// + /// 推送轨迹内容 + /// + public string TrackContentValue { get; set; } + + /// + /// 推送轨迹内容英文 + /// + public string TrackEnContentValue { get; set; } + + /// + /// 推送轨迹状态 + /// + public string TrackStatusValue { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackTemplate/TemplateContentOrderlyDto.cs b/src/SJZY.Track.Domain/Dtos/TrackTemplate/OrderedTrackCodeDto.cs similarity index 86% rename from src/SJZY.Track.Domain/Dtos/TrackTemplate/TemplateContentOrderlyDto.cs rename to src/SJZY.Track.Domain/Dtos/TrackTemplate/OrderedTrackCodeDto.cs index d7ef08ef..60362986 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackTemplate/TemplateContentOrderlyDto.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackTemplate/OrderedTrackCodeDto.cs @@ -1,6 +1,6 @@ namespace SJZY.Track.Domain.Dtos.TrackTemplate; -public class TemplateContentOrderlyDto +public class OrderedTrackCodeDto { /// /// 模板id diff --git a/src/SJZY.Track.Repository/Enum/Enums.cs b/src/SJZY.Track.Domain/Enums/EnumPropertyEnums.cs similarity index 66% rename from src/SJZY.Track.Repository/Enum/Enums.cs rename to src/SJZY.Track.Domain/Enums/EnumPropertyEnums.cs index f32f511c..e1c08aaf 100644 --- a/src/SJZY.Track.Repository/Enum/Enums.cs +++ b/src/SJZY.Track.Domain/Enums/EnumPropertyEnums.cs @@ -1,6 +1,6 @@ using System.ComponentModel; -namespace SJZY.Track.Repository.Enum; +namespace SJZY.Track.Domain.Enums; /// /// 枚举属性 @@ -10,6 +10,5 @@ public enum EnumPropertyEnums /// /// 节点 /// - [Description("ServiceNode")] - 节点, + [Description("ServiceNode")] 节点, } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/IBasicRepository.cs b/src/SJZY.Track.Domain/IBasicRepository.cs index b085429b..8e9baed2 100644 --- a/src/SJZY.Track.Domain/IBasicRepository.cs +++ b/src/SJZY.Track.Domain/IBasicRepository.cs @@ -1,4 +1,6 @@ -namespace SJZY.Track.Domain; +using SJZY.Track.Domain.Queries; + +namespace SJZY.Track.Domain; public interface IBasicRepository : IBasicQuery where T : IAggregateRoot { @@ -33,7 +35,7 @@ public interface IBasicRepository : IBasicQuery where T : IAggregateRoot /// /// 要更新的列 /// - Task UpdateRangeAsync(List entities, Expression> updateColumns = null); + Task UpdateRangeAsync(List entities, Expression>? updateColumns = null); /// /// 软删 diff --git a/src/SJZY.Track.Domain/IBasicQuery.cs b/src/SJZY.Track.Domain/Queries/IBasicQuery.cs similarity index 96% rename from src/SJZY.Track.Domain/IBasicQuery.cs rename to src/SJZY.Track.Domain/Queries/IBasicQuery.cs index f050d54d..894e72a9 100644 --- a/src/SJZY.Track.Domain/IBasicQuery.cs +++ b/src/SJZY.Track.Domain/Queries/IBasicQuery.cs @@ -1,4 +1,4 @@ -namespace SJZY.Track.Domain; +namespace SJZY.Track.Domain.Queries; public interface IBasicQuery where T : IEntity { diff --git a/src/SJZY.Track.Domain/Queries/ITrackQueries.cs b/src/SJZY.Track.Domain/Queries/ITrackQueries.cs new file mode 100644 index 00000000..df41882c --- /dev/null +++ b/src/SJZY.Track.Domain/Queries/ITrackQueries.cs @@ -0,0 +1,34 @@ +using SJZY.Track.Domain.Dtos.Order; +using SJZY.Track.Domain.Dtos.TrackDetails; +using SJZY.Track.Domain.Dtos.TrackTemplate; + +namespace SJZY.Track.Domain.Queries; + +/// +/// 提供接口专用查询 +/// +public interface ITrackQueries +{ + /// + /// 根据订单号,获取订单模板 + /// + /// 订单类型 + /// 订单号 + /// + Task> GetOrderTemplateLinksAsync(int orderType, List orderNumbers); + + /// + /// 根据订单模板,获取有序的轨迹code + /// + /// 模板id + /// + Task> GetOrderedTrackCodesAsync(List templateIds); + + /// + /// 根据订单id找到订单模板,匹配模板命中的轨迹内容 + /// + /// 订单id + /// 轨迹代码 + /// + Task MatchTrackContentAsync(int orderId, string code); +} \ No newline at end of file diff --git a/src/SJZY.Track.Infrastructure/DataBaseContext.cs b/src/SJZY.Track.Infrastructure/DataBaseContext.cs new file mode 100644 index 00000000..9fbb7d44 --- /dev/null +++ b/src/SJZY.Track.Infrastructure/DataBaseContext.cs @@ -0,0 +1,77 @@ +using SJZY.UserCenter.HttpApi.Services; + +#pragma warning disable 1591 + +namespace SJZY.Track.Infrastructure; + +/// +/// Sqlsugar 上下文对象 +/// +public class DataBaseContext +{ + #region 审计属性自动赋值 + + public static void OnExcutingAction(object oldValue, DataFilterModel entityInfo) + { + //过滤掉 "v_" 开头的表 + if (entityInfo.EntityColumnInfo.DbTableName.StartsWith("v_", StringComparison.OrdinalIgnoreCase)) + throw new Exception("非法的操作,不允许编辑映射表"); + + //新增 + if (entityInfo.OperationType == DataFilterType.InsertByObject) + { + if (entityInfo.PropertyName == nameof(ICreateBaicEntity.CreateTime)) + entityInfo.SetValue(DateTime.Now); + if (entityInfo.PropertyName == nameof(ICreateBaicEntity.CreateUserId)) + { + if (oldValue == null || (int)oldValue == 0) + { + try + { + entityInfo.SetValue(CurrentUserRequest.CurrentUser?.UserId); + } + catch + { + } + } + //entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId); + } + } + //修改 + else if (entityInfo.OperationType == DataFilterType.UpdateByObject) + { + if (entityInfo.PropertyName == nameof(IUpdateBasicEntity.UpdateTime)) + entityInfo.SetValue(DateTime.Now); + else if (entityInfo.PropertyName == nameof(IUpdateBasicEntity.UpdateUserId)) + { + if (oldValue == null || (int)oldValue == 1) + { + try + { + entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId); + } + catch + { + } + } + //entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId); + } + //删除 + else if (entityInfo.PropertyName == nameof(IDeleteBasicEntity.IsDeleted)) + { + var currentType = entityInfo.EntityValue.GetType(); + bool.TryParse( + currentType.GetProperty(entityInfo.PropertyName)?.GetValue(entityInfo.EntityValue)?.ToString(), + out bool isdelete); + if (isdelete) + { + //currentType.GetProperty(nameof(IDeleteBasicEntity.DeleteUserId))?.SetValue(entityInfo.EntityValue, 5); + currentType.GetProperty(nameof(IDeleteBasicEntity.DeleteTime)) + ?.SetValue(entityInfo.EntityValue, DateTime.Now); + } + } + } + } + + #endregion 审计属性自动赋值 +} \ No newline at end of file diff --git a/src/SJZY.Track.Repository/GlobalUsing.cs b/src/SJZY.Track.Infrastructure/GlobalUsing.cs similarity index 85% rename from src/SJZY.Track.Repository/GlobalUsing.cs rename to src/SJZY.Track.Infrastructure/GlobalUsing.cs index dc581267..bb8c080a 100644 --- a/src/SJZY.Track.Repository/GlobalUsing.cs +++ b/src/SJZY.Track.Infrastructure/GlobalUsing.cs @@ -4,4 +4,4 @@ global using SJZY.Expand.ABP.Core.SqlSugar; global using SJZY.Expand.ABP.Core.SqlSugar.Entitys; global using SJZY.Expand.ABP.Core.SqlSugar.Tools; global using SqlSugar; -global using Volo.Abp.DependencyInjection; +global using Volo.Abp.DependencyInjection; \ No newline at end of file diff --git a/src/SJZY.Track.Repository/BasicQuery.cs b/src/SJZY.Track.Infrastructure/Queries/BasicQuery.cs similarity index 91% rename from src/SJZY.Track.Repository/BasicQuery.cs rename to src/SJZY.Track.Infrastructure/Queries/BasicQuery.cs index 275b3b4d..fbb511c7 100644 --- a/src/SJZY.Track.Repository/BasicQuery.cs +++ b/src/SJZY.Track.Infrastructure/Queries/BasicQuery.cs @@ -1,8 +1,8 @@ using System.Linq.Expressions; -using SJZY.Track.Domain; +using SJZY.Track.Domain.Queries; using SJZY.Track.Domain.SeedWork; -namespace SJZY.Track.Repository; +namespace SJZY.Track.Infrastructure.Queries; #pragma warning disable CS8613 public class BasicQuery : SimpleClient, IBasicQuery where T : class, IEntity, new() diff --git a/src/SJZY.Track.Infrastructure/Queries/TrackQueries.cs b/src/SJZY.Track.Infrastructure/Queries/TrackQueries.cs new file mode 100644 index 00000000..413c38fe --- /dev/null +++ b/src/SJZY.Track.Infrastructure/Queries/TrackQueries.cs @@ -0,0 +1,78 @@ +using SJZY.Track.Domain.Aggregates.OrderAggregate; +using SJZY.Track.Domain.Aggregates.TrackContentAggregate; +using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; +using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; +using SJZY.Track.Domain.Dtos.Order; +using SJZY.Track.Domain.Dtos.TrackDetails; +using SJZY.Track.Domain.Dtos.TrackTemplate; +using SJZY.Track.Domain.Queries; + +namespace SJZY.Track.Infrastructure.Queries; + +public class TrackQueries : ISugarRepository, ITrackQueries, + ITransientDependency +{ + public ISqlSugarClient Context { get; set; } + + public TrackQueries() + { + Context = SqlsugarScopeBasic.GetContextSafely("default"); + } + + public async Task> GetOrderTemplateLinksAsync(int orderType, + params string[] orderNumbers) + { + return await Context.Queryable() + .LeftJoin((a, b) => a.Id == b.OrderId) + .Where(a => a.OrderType == orderType && orderNumbers.Contains(a.OrderNo)) + .Select((a, b) => new OrderTemplateLinkDto + { + OrderNo = a.OrderNo, + TemplateId = b.TrackTemplateId + }) + .ToListAsync(); + } + + public async Task> GetOrderTemplateLinksAsync(int orderType, List orderNumbers) + { + return await Context.Queryable() + .LeftJoin((a, b) => a.Id == b.OrderId) + .Where(a => a.OrderType == orderType && orderNumbers.Contains(a.OrderNo)) + .Select((a, b) => new OrderTemplateLinkDto + { + OrderNo = a.OrderNo, + TemplateId = b.TrackTemplateId + }) + .ToListAsync(); + } + + public async Task> GetOrderedTrackCodesAsync(List templateIds) + { + return await Context.Queryable() + .LeftJoin((a, b) => a.TrackContentId == b.Id) + .Where(a => templateIds.Contains(a.TrackTemplateId)) + .OrderBy(a => a.Sort) + .Select((a, b) => new OrderedTrackCodeDto + { + TemplateId = a.Id, + Code = b.Code + }) + .ToListAsync(); + } + + public async Task MatchTrackContentAsync(int orderId, string code) + { + return await Context.Queryable() + .LeftJoin((x, a) => x.TrackTemplateId == a.TrackTemplateId) + .LeftJoin((x, a, b) => a.TrackContentId == b.Id) + .LeftJoin((x, a, b, c) => b.TrackStatusId == c.Id) + .Where((x, a, b) => x.OrderId == orderId && b.Code == code) + .Select((x, a, b, c) => new MatchTrackContentDto + { + Content = b.Content, + EnContent = b.EnContent, + Status = c.Status + }) + .FirstAsync(); + } +} \ No newline at end of file diff --git a/src/SJZY.Track.Repository/BasicRepository.cs b/src/SJZY.Track.Infrastructure/Repositories/BasicRepository.cs similarity index 93% rename from src/SJZY.Track.Repository/BasicRepository.cs rename to src/SJZY.Track.Infrastructure/Repositories/BasicRepository.cs index a4616860..a776fd88 100644 --- a/src/SJZY.Track.Repository/BasicRepository.cs +++ b/src/SJZY.Track.Infrastructure/Repositories/BasicRepository.cs @@ -1,9 +1,10 @@ using System.Linq.Expressions; using SJZY.Track.Domain; using SJZY.Track.Domain.SeedWork; +using SJZY.Track.Infrastructure.Queries; using Volo.Abp; -namespace SJZY.Track.Repository; +namespace SJZY.Track.Infrastructure.Repositories; /// /// 仓储基类实现 @@ -32,7 +33,7 @@ public class BasicRepository : BasicQuery, IBasicRepository where T : c .ExecuteCommandHasChangeAsync(); } - public async Task UpdateRangeAsync(List entities, Expression> columns = null) + public async Task UpdateRangeAsync(List entities, Expression>? columns = null) { return await Context.Updateable(entities) .UpdateColumnsIF(columns != null, columns) diff --git a/src/SJZY.Track.Repository/DemoRepository.cs b/src/SJZY.Track.Infrastructure/Repositories/DemoRepository.cs similarity index 99% rename from src/SJZY.Track.Repository/DemoRepository.cs rename to src/SJZY.Track.Infrastructure/Repositories/DemoRepository.cs index 18a8d5da..9acceca7 100644 --- a/src/SJZY.Track.Repository/DemoRepository.cs +++ b/src/SJZY.Track.Infrastructure/Repositories/DemoRepository.cs @@ -2,7 +2,7 @@ using SJZY.Track.Domain.Aggregates.DemoAggregate; using SJZY.Track.Domain.Dtos.Demo; -namespace SJZY.Track.Repository; +namespace SJZY.Track.Infrastructure.Repositories; public class DemoRepository : BasicRepository, IDemoRepository, IScopedDependency { diff --git a/src/SJZY.Track.Infrastructure/Repositories/OrderRepository.cs b/src/SJZY.Track.Infrastructure/Repositories/OrderRepository.cs new file mode 100644 index 00000000..9b556ecb --- /dev/null +++ b/src/SJZY.Track.Infrastructure/Repositories/OrderRepository.cs @@ -0,0 +1,132 @@ +using Nest; +using SJZY.Track.Domain; +using SJZY.Track.Domain.Aggregates.OrderAggregate; +using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; +using SJZY.Track.Domain.Dtos.Order; +using SJZY.Track.Domain.VEntities; +using SJZY.Track.Repository.VData.Entitys; + +namespace SJZY.Track.Infrastructure.Repositories; + +public class OrderRepository : BasicRepository, IOrderRepository, ITransientDependency +{ + public async Task CreateOrderAsync(OrderEntity order) + { + return await Context.InsertNav(order) + .Include(x => x.OrderFlights) + .Include(x => x.OrderTemplates) + .ExecuteCommandAsync(); + } + + public async Task LinkOrderAsync(List orderLinkEntities) + { + await Context.Insertable(orderLinkEntities).ExecuteCommandAsync(); + } + + public async Task UnLinkByIdsAsync(List linkIds) + { + await Context.Deleteable(linkIds).ExecuteCommandAsync(); + } + + public async Task UpdateOrderAsync(OrderEntity order) + { + using var tran = TransactionHelper.GetReadCommitted(); + + // 更新订单主表 + await UpdateAsync(order, x => new { x.CustomId, x.SubSystemId }); + + // 更新订单模板 + await Context.Deleteable().Where(x => x.OrderId == order.Id).ExecuteCommandAsync(); + order.OrderTemplates.ForEach(x => x.OrderId = order.Id); + await Context.Insertable(order.OrderTemplates).ExecuteCommandAsync(); + + // 更新订单航班 + await Context.Deleteable().Where(x => x.OrderId == order.Id).ExecuteCommandAsync(); + order.OrderFlights.ForEach(x => x.OrderId = order.Id); + await Context.Insertable(order.OrderFlights).ExecuteCommandAsync(); + + tran.Complete(); + } + + public async Task DeleteOrderAsync(int orderId) + { + using var tran = TransactionHelper.GetReadCommitted(); + + // 软删订单主表 + await SoftDeleteAsync(x => x.Id == orderId); + + // 软删订单模板 + // 软删订单航班 + // 软删订单关联关系 + + tran.Complete(); + } + + #region 轨迹订单明细 + + /// + /// 根据轨迹订单id获取轨迹明细列表 + /// + /// + /// + public async Task> GetOrderDetails(GetOrderDetailsInputVO input) + { + return null; + } + + #endregion + + #region 轨迹订单分页 + + /// + /// 获取分页的轨迹订单 + /// + /// + /// + public async Task> GetPageTrackOrder(GetPageTrackOrderInputVO input) + { + var pageList = await Context.Queryable() + .LeftJoin((a, b) => a.CustomId==b.Id) + .LeftJoin((a, b, c) => a.SubSystemId==c.Id) + .Select((a, b, c) => new TrackOrderVO + { + Id = a.Id, + OrderNumber= a.OrderNo, + OrderType = a.OrderType, + CustomerShortName= b.Abbreviation, + CustomerCode= b.Code, + TrackTemplateNames = "", + OrderDetails="", + NewestTrackContent= a.LatestTrackContent, + NewestTrackEnContent= a.LatestTrackEnContent, + NewestTrackPlace= a.LatestTrackPlace, + IsFinish=a.IsCompleted, + CreateTime=a.CreateTime, + SubSystem= c.CnName + }) + .ToPagedListAsync(input.PageIndex, input.PageSize); + + if (pageList.List.Any()) + { + var orderIds = pageList.List.Select(a => a.Id); + //查询轨迹模版 + + + var trackTemplateList = await Context.Queryable() + .LeftJoin((a, b) => a.TrackTemplateId==b.Id) + .Where((a, b) => orderIds.Contains(a.OrderId)) + .Select((a, b) => new { OrderId = a.OrderId, Name = b.Name }) + .ToListAsync(); + + pageList.List.ForEach(a => + { + var templateListOfOrderId = trackTemplateList.Where(b => b.OrderId== a.Id); + a.TrackTemplateNames = templateListOfOrderId.Select(c => c.Name).JoinAsString(","); + }); + } + + return pageList; + } + + #endregion +} \ No newline at end of file diff --git a/src/SJZY.Track.Repository/TrackContentRepository.cs b/src/SJZY.Track.Infrastructure/Repositories/TrackContentRepository.cs similarity index 97% rename from src/SJZY.Track.Repository/TrackContentRepository.cs rename to src/SJZY.Track.Infrastructure/Repositories/TrackContentRepository.cs index 32ebd92d..eac2265f 100644 --- a/src/SJZY.Track.Repository/TrackContentRepository.cs +++ b/src/SJZY.Track.Infrastructure/Repositories/TrackContentRepository.cs @@ -2,10 +2,9 @@ using SJZY.Track.Domain.Aggregates.TrackFlagAggregate; using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; using SJZY.Track.Domain.Dtos.TrackContents; -using SJZY.Track.Domain.Dtos.TrackStatus; using SJZY.Track.Domain.VEntities; -namespace SJZY.Track.Repository; +namespace SJZY.Track.Infrastructure.Repositories; public class TrackContentRepository : BasicRepository, ITrackContentRepository, IScopedDependency { @@ -25,7 +24,7 @@ public class TrackContentRepository : BasicRepository, ITrac var detail = await Context.Queryable() .LeftJoin((a, b) => a.TrackStatusId==b.Id) .LeftJoin((a, b, c) => a.TrackFlagId==c.Id) - .LeftJoin((a, b, c, d) => a.SubSystemId == b.Id) + .LeftJoin((a, b, c, d) => a.SubSystemId == d.Id) .Where((a, b, c, d) => a.Id == id) .Select((a, b, c, d) => new GetTrackContentDetailVO { diff --git a/src/SJZY.Track.Repository/TrackDetailsRepository.cs b/src/SJZY.Track.Infrastructure/Repositories/TrackDetailsRepository.cs similarity index 52% rename from src/SJZY.Track.Repository/TrackDetailsRepository.cs rename to src/SJZY.Track.Infrastructure/Repositories/TrackDetailsRepository.cs index 3a0677b9..2737c39d 100644 --- a/src/SJZY.Track.Repository/TrackDetailsRepository.cs +++ b/src/SJZY.Track.Infrastructure/Repositories/TrackDetailsRepository.cs @@ -1,35 +1,56 @@ using Nest; -using SJZY.Expand.ABP.Core.Logger; -using SJZY.Expand.ABP.Core.PublicMethords; using SJZY.Expand.ElasticSearch.Services; using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate; using SJZY.Track.Domain.Dtos.TrackDetails; -namespace SJZY.Track.Repository; +namespace SJZY.Track.Infrastructure.Repositories; internal class TrackDetailsRepository : ElasticSearchContextAbstract, ITrackDetailsRepository, ITransientDependency { + public string IndexName => $"{TrackDetailsIndex.IndexName}-{DateTime.Now:yyyy.MM.dd}"; + public TrackDetailsRepository(ConnectionFactory connectionFactory) : base(connectionFactory) { } - public async Task WriteTrack(TrackDetailsIndex index) + public async Task GetFirstOrDefaultAsync(int orderId, string trackCode) { - try + var r = await Context.SearchAsync(s => s + .Index($"{TrackDetailsIndex.IndexName}-{DateTime.Now:yyyy.MM.dd}") + .Query(q => + q.Term(t => t.Field(f => f.OrderId).Value(orderId)) + && q.Term(t => t.Field(f => f.TrackCode).Value(trackCode)) + ) + ); + + if (r.IsValid) { - //await Context.IndexDocumentAsync(idx); - var response = await Context.IndexAsync(index, - request => request.Index($"{TrackDetailsIndex.IndexName}-{DateTime.Now:yyyy.MM.dd}")); - if (!response.IsValid) LogHelper.Error("数据添加失败,原因:" + response.DebugInformation); - } - catch (Exception ex) - { - LogHelper.Error($"日志插入ES失败:{ex.Message}。{index.ToJson()}"); + return r.Documents.FirstOrDefault(); } + + return default; } - public async Task> GetListAsync(List orderNos) + public async Task UpdateAsync(TrackDetailsIndex index) + { + var response = await Context.UpdateAsync(index.Id, u => u + .Index(IndexName) + .Doc(index) + //.Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见 + ); + if (!response.IsValid) + throw new Exception($"数据修改失败,原因:{response.DebugInformation}"); + } + + public async Task CreateAsync(TrackDetailsIndex index) + { + var response = await Context.IndexAsync(index, request => request.Index(IndexName)); + if (!response.IsValid) + throw new Exception($"数据添加失败,原因:{response.DebugInformation}"); + } + + public async Task> GetListAsync(int orderType, List orderNos) { if (orderNos.Count < 1) return new List(); @@ -42,9 +63,11 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract f.TrackTime) .Field(f => f.TraceTimeZone) )) - .Query(q => q.Terms(t => t - .Field(f => f.OrderNo) - .Terms(orderNos))) + .Query(q => + q.Terms(t => t + .Field(f => f.OrderNo) + .Terms(orderNos)) + && q.Term(f => f.OrderType, orderType)) ); return data.Documents.ToList(); diff --git a/src/SJZY.Track.Repository/TrackFlagRepository.cs b/src/SJZY.Track.Infrastructure/Repositories/TrackFlagRepository.cs similarity index 94% rename from src/SJZY.Track.Repository/TrackFlagRepository.cs rename to src/SJZY.Track.Infrastructure/Repositories/TrackFlagRepository.cs index 508d80ef..12c29447 100644 --- a/src/SJZY.Track.Repository/TrackFlagRepository.cs +++ b/src/SJZY.Track.Infrastructure/Repositories/TrackFlagRepository.cs @@ -1,10 +1,8 @@ using SJZY.Track.Domain.Aggregates.TrackFlagAggregate; -using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; using SJZY.Track.Domain.Dtos.TrackFlags; -using SJZY.Track.Domain.Dtos.TrackStatus; using SJZY.Track.Domain.VEntities; -namespace SJZY.Track.Repository; +namespace SJZY.Track.Infrastructure.Repositories; public class TrackFlagRepository : BasicRepository, ITrackFlagRepository, IScopedDependency { diff --git a/src/SJZY.Track.Repository/TrackPullConfigRepository.cs b/src/SJZY.Track.Infrastructure/Repositories/TrackPullConfigRepository.cs similarity index 70% rename from src/SJZY.Track.Repository/TrackPullConfigRepository.cs rename to src/SJZY.Track.Infrastructure/Repositories/TrackPullConfigRepository.cs index e2e8882c..796e6778 100644 --- a/src/SJZY.Track.Repository/TrackPullConfigRepository.cs +++ b/src/SJZY.Track.Infrastructure/Repositories/TrackPullConfigRepository.cs @@ -1,11 +1,12 @@ -using SJZY.Track.Domain.Aggregates.TrackContentAggregate; +using System.Linq.Expressions; +using SJZY.Track.Domain.Aggregates.TrackContentAggregate; using SJZY.Track.Domain.Aggregates.TrackPullAggregate; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Dtos.Common; using SJZY.Track.Domain.Dtos.TrackPull; using SJZY.Track.Domain.VEntities; -namespace SJZY.Track.Repository; +namespace SJZY.Track.Infrastructure.Repositories; public class TrackPullConfigRepository : BasicRepository, ITrackPullConfigRepository, IScopedDependency @@ -83,4 +84,50 @@ public class TrackPullConfigRepository : BasicRepository, }, true) .SingleAsync(); } + + public async Task InsertParamsAsync(TrackPushPullParamsConfigEntity insertObj) + { + return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0; + } + + public async Task InsertContentRangeAsync(List insertObjs) + { + return await Context.Insertable(insertObjs).ExecuteCommandAsync() > 0; + } + + public async Task GetParamsSingleAsync(Expression> whereExpression) + { + return await Context.Queryable().SingleAsync(whereExpression); + } + + public async Task UpdateParamsAsync(TrackPushPullParamsConfigEntity updateObj) + { + return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync(); + } + + public async Task SoftDeleteContentAsync(Expression> whereExpression) + { + return await Context.Updateable() + .Where(whereExpression) + .SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true) + .ExecuteCommandHasChangeAsync(); + } + + public async Task SoftDeleteParamsAsync(Expression> whereExpression) + { + return await Context.Updateable() + .Where(whereExpression) + .SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true) + .ExecuteCommandHasChangeAsync(); + } + + public async Task GetContentByIdAsync(int id) + { + return await Context.Queryable().InSingleAsync(id); + } + + public async Task UpdateContentAsync(TrackPullContentConfigEntity updateObj) + { + return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync(); + } } \ No newline at end of file diff --git a/src/SJZY.Track.Infrastructure/Repositories/TrackPushConfigRepository.cs b/src/SJZY.Track.Infrastructure/Repositories/TrackPushConfigRepository.cs new file mode 100644 index 00000000..d5180da1 --- /dev/null +++ b/src/SJZY.Track.Infrastructure/Repositories/TrackPushConfigRepository.cs @@ -0,0 +1,72 @@ +using SJZY.Track.Domain.Aggregates.TrackContentAggregate; +using SJZY.Track.Domain.Aggregates.TrackPullAggregate; +using SJZY.Track.Domain.Aggregates.TrackPushAggregate; +using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; +using SJZY.Track.Domain.Dtos.Common; +using SJZY.Track.Domain.Dtos.TrackPush; +using SJZY.Track.Domain.VEntities; +using SJZY.Track.Repository.VData.Entitys; + +namespace SJZY.Track.Infrastructure.Repositories; + +public class TrackPushConfigRepository : BasicRepository, ITrackPushConfigRepository, + IScopedDependency +{ + public async Task> GetPageAsync(KeywordsInputVO input) + { + return await AsQueryable() + .LeftJoin((trackPush, system) => trackPush.SubSystemId == system.Id && !system.IsDeleted) + .LeftJoin((trackPush, system, externalSubject) => trackPush.CustomId == externalSubject.Id && !externalSubject.IsDeleted) + .LeftJoin((trackPush, system, externalSubject, template) => SqlFunc.SplitIn(trackPush.TrackTemplateId, template.Id.ToString()) && !template.IsDeleted) + .Filter(null, true) + .Where(trackPush => !trackPush.IsDeleted) + .WhereIF(input.SubSystemId.HasValue, trackPush => trackPush.SubSystemId == input.SubSystemId) + .WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (trackPush, system, externalSubject, template) => externalSubject.Abbreviation.Contains(input.Keywords) || externalSubject.Name.Contains(input.Keywords) || template.Name.Contains(input.Keywords)) + .OrderByDescending(trackPush => trackPush.CreateTime) + .Select((trackPush, system, externalSubject, template) => new GetTrackPushConfigPageOutputVO + { + Id = trackPush.Id, + SubSystem = system.CnName, + CustomName = externalSubject.Abbreviation, + TrackTemplate = SqlFunc.Subqueryable() + .Where(template => SqlFunc.SplitIn(trackPush.TrackTemplateId, template.Id.ToString()) && !template.IsDeleted) + .SelectStringJoin(template => template.Name, ","), + CreateTime = trackPush.CreateTime + }) + .Distinct() + .ToPagedListAsync(input.PageIndex, input.PageSize); + } + + public async Task> GetContentPageAsync(GetTrackPushContentPageInputVO input) + { + return await Context.Queryable() + .InnerJoin((pushContent, trackContent) => pushContent.TrackContentId == trackContent.Id) + .Where(pushContent => pushContent.TrackPushConfigId == input.TrackPushConfigId) + .OrderBy((pushContent, trackContent) => pushContent.Sort) + .Select((pushContent, trackContent) => new GetTrackPushContentPageOutputVO + { + Id = pushContent.Id, + Sort = pushContent.Sort + }, true) + .ToPagedListAsync(input.PageIndex, input.PageSize); + } + + public async Task GetDetailAsync(int id) + { + return await AsQueryable() + .LeftJoin((trackPush, system) => trackPush.SubSystemId == system.Id && !system.IsDeleted) + .LeftJoin((trackPush, system, externalSubject) => trackPush.CustomId == externalSubject.Id && !externalSubject.IsDeleted) + .LeftJoin((trackPush, system, externalSubject, service) => trackPush.ServiceProviderId == service.Id && !service.IsDeleted) + .InnerJoin((trackPush, system, externalSubject, service, paramsConfig) => trackPush.Id == paramsConfig.PullOrPushConfigId && paramsConfig.IsPush && !paramsConfig.IsDeleted) + .Filter(null, true) + .Where(trackPush => trackPush.Id == id && !trackPush.IsDeleted) + .Select((trackPush, system, externalSubject, service, paramsConfig) => new GetTrackPushConfigDetailOutputVO + { + Id = trackPush.Id, + SubSystem = system.CnName, + CustomName = externalSubject.Abbreviation, + ServiceProvider = service.Name, + }, true) + .SingleAsync(); + } +} \ No newline at end of file diff --git a/src/SJZY.Track.Repository/TrackStatusRepository.cs b/src/SJZY.Track.Infrastructure/Repositories/TrackStatusRepository.cs similarity index 98% rename from src/SJZY.Track.Repository/TrackStatusRepository.cs rename to src/SJZY.Track.Infrastructure/Repositories/TrackStatusRepository.cs index 9e88da35..a9218613 100644 --- a/src/SJZY.Track.Repository/TrackStatusRepository.cs +++ b/src/SJZY.Track.Infrastructure/Repositories/TrackStatusRepository.cs @@ -2,7 +2,7 @@ using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; using SJZY.Track.Domain.Dtos.TrackStatus; using SJZY.Track.Domain.VEntities; -namespace SJZY.Track.Repository; +namespace SJZY.Track.Infrastructure.Repositories; public class TrackStatusRepository : BasicRepository, ITrackStatusRepository, IScopedDependency { diff --git a/src/SJZY.Track.Repository/TrackTemplateRepository.cs b/src/SJZY.Track.Infrastructure/Repositories/TrackTemplateRepository.cs similarity index 83% rename from src/SJZY.Track.Repository/TrackTemplateRepository.cs rename to src/SJZY.Track.Infrastructure/Repositories/TrackTemplateRepository.cs index 249ed8d4..d4ae27a6 100644 --- a/src/SJZY.Track.Repository/TrackTemplateRepository.cs +++ b/src/SJZY.Track.Infrastructure/Repositories/TrackTemplateRepository.cs @@ -5,29 +5,13 @@ using SJZY.Track.Domain.Aggregates.TrackFlagAggregate; using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Dtos.TrackTemplate; +using SJZY.Track.Domain.Enums; using SJZY.Track.Domain.VEntities; -using SJZY.Track.Repository.Enum; -namespace SJZY.Track.Repository; +namespace SJZY.Track.Infrastructure.Repositories; -/// public class TrackTemplateRepository : BasicRepository, ITrackTemplateRepository, IScopedDependency { - public async Task> GetTemplateContentOrderlyAsync(List distinctTemplateIds) - { - return await Context.Queryable() - .LeftJoin((a, b) => a.Id == b.TrackTemplateId) - .LeftJoin((a, b, c) => b.TrackContentId == c.Id) - .Where(a => distinctTemplateIds.Contains(a.Id)) - .OrderBy((a, b) => b.Sort) - .Select((a, b, c) => new TemplateContentOrderlyDto - { - TemplateId = a.Id, - Code = c.Code - }) - .ToListAsync(); - } - /// /// 获取轨迹模版明细 /// @@ -40,13 +24,13 @@ public class TrackTemplateRepository : BasicRepository, ITr .Where((a, b) => a.Id == id) .Select((a, b) => new GetTrackTemplateDetailVO - { - Id = a.Id, - Code = a.Code, - Name = a.Name, - SubSystemId = a.SubSystemId, - SubSystem = b.CnName - }).FirstAsync(); + { + Id = a.Id, + Code = a.Code, + Name = a.Name, + SubSystemId = a.SubSystemId, + SubSystem = b.CnName + }).FirstAsync(); return detail; } @@ -58,13 +42,14 @@ public class TrackTemplateRepository : BasicRepository, ITr /// public async Task> GetPageTrackTemplate(GetPageTrackTemplateVO input) { - UnifyPageResultDto pagedList = new UnifyPageResultDto(); - pagedList = await Context.Queryable() + UnifyPageResultDto pagedList = await Context.Queryable() .LeftJoin((a, b) => a.SubSystemId == b.Id) .WhereIF(input.SubSystemId > 0, (a, b) => a.SubSystemId == input.SubSystemId) .WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (a, b) => a.Name.Contains(input.Keywords) || a.Code.Contains(input.Keywords)) - .OrderByIF(input.TrackTemplateId > 0, (a, b) => SqlFunc.IIF(a.Id == input.TrackTemplateId, SqlFunc.DateAdd(SqlFunc.GetDate(), 1), a.CreateTime), OrderByType.Desc) + .OrderByIF(input.TrackTemplateId > 0, + (a, b) => SqlFunc.IIF(a.Id == input.TrackTemplateId, SqlFunc.DateAdd(SqlFunc.GetDate(), 1), + a.CreateTime), OrderByType.Desc) .Select((a, b) => new GetTrackTemplateListVO { Id = a.Id, @@ -167,4 +152,10 @@ public class TrackTemplateRepository : BasicRepository, ITr .SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true) .ExecuteCommandHasChangeAsync(); } + + public async Task> GetContentListAsync( + Expression> whereExpression) + { + return await Context.Queryable().Where(whereExpression).ToListAsync(); + } } \ No newline at end of file diff --git a/src/SJZY.Track.Repository/SJZY.Track.Repository.csproj b/src/SJZY.Track.Infrastructure/SJZY.Track.Infrastructure.csproj similarity index 81% rename from src/SJZY.Track.Repository/SJZY.Track.Repository.csproj rename to src/SJZY.Track.Infrastructure/SJZY.Track.Infrastructure.csproj index 42332f80..f1e677f8 100644 --- a/src/SJZY.Track.Repository/SJZY.Track.Repository.csproj +++ b/src/SJZY.Track.Infrastructure/SJZY.Track.Infrastructure.csproj @@ -17,8 +17,10 @@ - - + + + + diff --git a/src/SJZY.Track.Repository/SJZYTrackRepositoryModule.cs b/src/SJZY.Track.Infrastructure/SJZYTrackInfrastructureModule.cs similarity index 89% rename from src/SJZY.Track.Repository/SJZYTrackRepositoryModule.cs rename to src/SJZY.Track.Infrastructure/SJZYTrackInfrastructureModule.cs index b58d19b1..c412b69c 100644 --- a/src/SJZY.Track.Repository/SJZYTrackRepositoryModule.cs +++ b/src/SJZY.Track.Infrastructure/SJZYTrackInfrastructureModule.cs @@ -3,17 +3,20 @@ using Microsoft.Extensions.DependencyInjection; using SJZY.Expand.ABP.Core.SqlSugar.Options; using SJZY.Expand.ElasticSearch; using SJZY.Track.Domain; +using SJZY.Track.Domain.Queries; +using SJZY.Track.Infrastructure.Queries; +using SJZY.Track.Infrastructure.Repositories; using Volo.Abp.Autofac; using Volo.Abp.Modularity; -namespace SJZY.Track.Repository; +namespace SJZY.Track.Infrastructure; /// /// 仓储模块 /// [DependsOn(typeof(AbpAutofacModule))] [DependsOn(typeof(SJZYTrackDomainModule))] -public class SJZYTrackRepositoryModule : AbpModule +public class SJZYTrackInfrastructureModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) { @@ -43,6 +46,7 @@ public class SJZYTrackRepositoryModule : AbpModule }); } + public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddTransient(typeof(IBasicQuery<>), typeof(BasicQuery<>)); diff --git a/src/SJZY.Track.Repository/TrackPushRecord/Entitys/TrackPushRecordEntity.cs b/src/SJZY.Track.Infrastructure/TrackPushRecord/Entitys/TrackPushRecordEntity.cs similarity index 96% rename from src/SJZY.Track.Repository/TrackPushRecord/Entitys/TrackPushRecordEntity.cs rename to src/SJZY.Track.Infrastructure/TrackPushRecord/Entitys/TrackPushRecordEntity.cs index 9b45f7c2..32615bba 100644 --- a/src/SJZY.Track.Repository/TrackPushRecord/Entitys/TrackPushRecordEntity.cs +++ b/src/SJZY.Track.Infrastructure/TrackPushRecord/Entitys/TrackPushRecordEntity.cs @@ -1,6 +1,6 @@ using SJZY.Track.Domain.SeedWork; -namespace SJZY.Track.Repository.TrackPushRecord.Entitys +namespace SJZY.Track.Infrastructure.TrackPushRecord.Entitys { /// /// 轨迹推送记录 diff --git a/src/SJZY.Track.Infrastructure/TrackPushRecord/Services/ITrackPushRecordRepository.cs b/src/SJZY.Track.Infrastructure/TrackPushRecord/Services/ITrackPushRecordRepository.cs new file mode 100644 index 00000000..7b2e515e --- /dev/null +++ b/src/SJZY.Track.Infrastructure/TrackPushRecord/Services/ITrackPushRecordRepository.cs @@ -0,0 +1,8 @@ +using SJZY.Track.Infrastructure.TrackPushRecord.Entitys; + +namespace SJZY.Track.Infrastructure.TrackPushRecord.Services +{ + public interface ITrackPushRecordRepository : ISimpleClient + { + } +} \ No newline at end of file diff --git a/src/SJZY.Track.Infrastructure/TrackPushRecord/Services/TrackPushRecordRepository.cs b/src/SJZY.Track.Infrastructure/TrackPushRecord/Services/TrackPushRecordRepository.cs new file mode 100644 index 00000000..22529060 --- /dev/null +++ b/src/SJZY.Track.Infrastructure/TrackPushRecord/Services/TrackPushRecordRepository.cs @@ -0,0 +1,10 @@ +using SJZY.Track.Infrastructure.Repositories; +using SJZY.Track.Infrastructure.TrackPushRecord.Entitys; + +namespace SJZY.Track.Infrastructure.TrackPushRecord.Services +{ + public class TrackPushRecordRepository : BasicRepository, ITrackPushRecordRepository, IScopedDependency + { + + } +} diff --git a/src/SJZY.Track.Repository/TrackPushRecordDetails/Entitys/TrackPushRecordDetailsEntity.cs b/src/SJZY.Track.Infrastructure/TrackPushRecordDetails/Entitys/TrackPushRecordDetailsEntity.cs similarity index 94% rename from src/SJZY.Track.Repository/TrackPushRecordDetails/Entitys/TrackPushRecordDetailsEntity.cs rename to src/SJZY.Track.Infrastructure/TrackPushRecordDetails/Entitys/TrackPushRecordDetailsEntity.cs index 64208102..796e3e47 100644 --- a/src/SJZY.Track.Repository/TrackPushRecordDetails/Entitys/TrackPushRecordDetailsEntity.cs +++ b/src/SJZY.Track.Infrastructure/TrackPushRecordDetails/Entitys/TrackPushRecordDetailsEntity.cs @@ -1,6 +1,6 @@ using SJZY.Track.Domain.SeedWork; -namespace SJZY.Track.Repository.TrackPushRecordDetails.Entitys +namespace SJZY.Track.Infrastructure.TrackPushRecordDetails.Entitys { /// /// 轨迹推送明细表 diff --git a/src/SJZY.Track.Infrastructure/TrackPushRecordDetails/Services/ITrackPushRecordDetailsRepository.cs b/src/SJZY.Track.Infrastructure/TrackPushRecordDetails/Services/ITrackPushRecordDetailsRepository.cs new file mode 100644 index 00000000..6f29bbc3 --- /dev/null +++ b/src/SJZY.Track.Infrastructure/TrackPushRecordDetails/Services/ITrackPushRecordDetailsRepository.cs @@ -0,0 +1,8 @@ +using SJZY.Track.Infrastructure.TrackPushRecordDetails.Entitys; + +namespace SJZY.Track.Infrastructure.TrackPushRecordDetails.Services +{ + public interface ITrackPushRecordDetailsRepository : ISimpleClient + { + } +} \ No newline at end of file diff --git a/src/SJZY.Track.Infrastructure/TrackPushRecordDetails/Services/TrackPushRecordDetailsRepository.cs b/src/SJZY.Track.Infrastructure/TrackPushRecordDetails/Services/TrackPushRecordDetailsRepository.cs new file mode 100644 index 00000000..157dc8bd --- /dev/null +++ b/src/SJZY.Track.Infrastructure/TrackPushRecordDetails/Services/TrackPushRecordDetailsRepository.cs @@ -0,0 +1,10 @@ +using SJZY.Track.Infrastructure.Repositories; +using SJZY.Track.Infrastructure.TrackPushRecordDetails.Entitys; + +namespace SJZY.Track.Infrastructure.TrackPushRecordDetails.Services +{ + public class TrackPushRecordDetailsRepository : BasicRepository, ITrackPushRecordDetailsRepository, IScopedDependency + { + + } +} diff --git a/src/SJZY.Track.Repository/DataBaseContext.cs b/src/SJZY.Track.Repository/DataBaseContext.cs deleted file mode 100644 index b9712ab1..00000000 --- a/src/SJZY.Track.Repository/DataBaseContext.cs +++ /dev/null @@ -1,53 +0,0 @@ -#pragma warning disable 1591 -namespace SJZY.Track.Repository -{ - /// - /// Sqlsugar 上下文对象 - /// - public class DataBaseContext - { - - #region 审计属性自动赋值 - - public static void OnExcutingAction(object oldValue, DataFilterModel entityInfo) - { - //过滤掉 "v_" 开头的表 - if (entityInfo.EntityColumnInfo.DbTableName.StartsWith("v_", StringComparison.OrdinalIgnoreCase)) - throw new Exception("非法的操作,不允许编辑映射表"); - - //新增 - if (entityInfo.OperationType == DataFilterType.InsertByObject) - { - if (entityInfo.PropertyName == nameof(ICreateBaicEntity.CreateTime)) - entityInfo.SetValue(DateTime.Now); - if (entityInfo.PropertyName == nameof(ICreateBaicEntity.CreateUserId)) - { - //entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId); - } - } - //修改 - else if (entityInfo.OperationType == DataFilterType.UpdateByObject) - { - if (entityInfo.PropertyName == nameof(IUpdateBasicEntity.UpdateTime)) - entityInfo.SetValue(DateTime.Now); - else if (entityInfo.PropertyName == nameof(IUpdateBasicEntity.UpdateUserId)) - { - //entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId); - } - //删除 - else if (entityInfo.PropertyName == nameof(IDeleteBasicEntity.IsDeleted)) - { - var currentType = entityInfo.EntityValue.GetType(); - bool.TryParse(currentType.GetProperty(entityInfo.PropertyName)?.GetValue(entityInfo.EntityValue)?.ToString(), out bool isdelete); - if (isdelete) - { - //currentType.GetProperty(nameof(IDeleteBasicEntity.DeleteUserId))?.SetValue(entityInfo.EntityValue, 5); - currentType.GetProperty(nameof(IDeleteBasicEntity.DeleteTime))?.SetValue(entityInfo.EntityValue, DateTime.Now); - } - } - } - } - - #endregion 审计属性自动赋值 - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Repository/OrderRepository.cs b/src/SJZY.Track.Repository/OrderRepository.cs deleted file mode 100644 index 645fb94b..00000000 --- a/src/SJZY.Track.Repository/OrderRepository.cs +++ /dev/null @@ -1,60 +0,0 @@ -using SJZY.Track.Domain; -using SJZY.Track.Domain.Aggregates.OrderAggregate; -using SJZY.Track.Domain.Dtos.Order; - -namespace SJZY.Track.Repository; - -public class OrderRepository : BasicRepository, IOrderRepository, ITransientDependency -{ - public async Task CreateOrderAsync(OrderEntity order) - { - return await Context.InsertNav(order) - .Include(x => x.OrderFlights) - .Include(x => x.OrderTemplates) - .ExecuteCommandAsync(); - } - - public async Task> GetOrderTemplatesAsync(int orderType, - List distinctOrderNumbers) - { - return await AsQueryable() - .LeftJoin((a, b) => a.Id == b.OrderId) - .Where(a => a.OrderType == orderType && distinctOrderNumbers.Contains(a.OrderNo)) - .Select((a, b) => new OrderTemplateDto - { - OrderNo = a.OrderNo, - TemplateId = b.TrackTemplateId - }) - .ToListAsync(); - } - - public async Task LinkOrderAsync(List orderLinkEntities) - { - await Context.Insertable(orderLinkEntities).ExecuteCommandAsync(); - } - - public async Task UnLinkByIdsAsync(List linkIds) - { - await Context.Deleteable(linkIds).ExecuteCommandAsync(); - } - - public async Task UpdateOrderAsync(OrderEntity order) - { - using var tran = TransactionHelper.GetReadCommitted(); - - // 更新订单主表 - await UpdateAsync(order, x => new { x.CustomId, x.SubSystemId }); - - // 更新订单模板 - await Context.Deleteable().Where(x => x.OrderId == order.Id).ExecuteCommandAsync(); - order.OrderTemplates.ForEach(x => x.OrderId = order.Id); - await Context.Insertable(order.OrderTemplates).ExecuteCommandAsync(); - - // 更新订单航班 - await Context.Deleteable().Where(x => x.OrderId == order.Id).ExecuteCommandAsync(); - order.OrderFlights.ForEach(x => x.OrderId = order.Id); - await Context.Insertable(order.OrderFlights).ExecuteCommandAsync(); - - tran.Complete(); - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Repository/TrackPushConfigRepository.cs b/src/SJZY.Track.Repository/TrackPushConfigRepository.cs deleted file mode 100644 index 32c71905..00000000 --- a/src/SJZY.Track.Repository/TrackPushConfigRepository.cs +++ /dev/null @@ -1,8 +0,0 @@ -using SJZY.Track.Domain.Aggregates.TrackPushAggregate; - -namespace SJZY.Track.Repository; - -public class TrackPushConfigRepository : BasicRepository, ITrackPushConfigRepository, - IScopedDependency -{ -} \ No newline at end of file diff --git a/src/SJZY.Track.Repository/TrackPushRecord/Services/ITrackPushRecordRepository.cs b/src/SJZY.Track.Repository/TrackPushRecord/Services/ITrackPushRecordRepository.cs deleted file mode 100644 index cac702c2..00000000 --- a/src/SJZY.Track.Repository/TrackPushRecord/Services/ITrackPushRecordRepository.cs +++ /dev/null @@ -1,9 +0,0 @@ -using SJZY.Track.Repository.TrackPushRecord.Entitys; - -namespace SJZY.Track.Repository.TrackPushRecord.Services -{ - public interface ITrackPushRecordRepository : ISimpleClient - { - - } -} diff --git a/src/SJZY.Track.Repository/TrackPushRecord/Services/TrackPushRecordRepository.cs b/src/SJZY.Track.Repository/TrackPushRecord/Services/TrackPushRecordRepository.cs deleted file mode 100644 index 06a72739..00000000 --- a/src/SJZY.Track.Repository/TrackPushRecord/Services/TrackPushRecordRepository.cs +++ /dev/null @@ -1,9 +0,0 @@ -using SJZY.Track.Repository.TrackPushRecord.Entitys; - -namespace SJZY.Track.Repository.TrackPushRecord.Services -{ - public class TrackPushRecordRepository : BasicRepository, ITrackPushRecordRepository, IScopedDependency - { - - } -} diff --git a/src/SJZY.Track.Repository/TrackPushRecordDetails/Services/ITrackPushRecordDetailsRepository.cs b/src/SJZY.Track.Repository/TrackPushRecordDetails/Services/ITrackPushRecordDetailsRepository.cs deleted file mode 100644 index 85047d16..00000000 --- a/src/SJZY.Track.Repository/TrackPushRecordDetails/Services/ITrackPushRecordDetailsRepository.cs +++ /dev/null @@ -1,9 +0,0 @@ -using SJZY.Track.Repository.TrackPushRecordDetails.Entitys; - -namespace SJZY.Track.Repository.TrackPushRecordDetails.Services -{ - public interface ITrackPushRecordDetailsRepository : ISimpleClient - { - - } -} diff --git a/src/SJZY.Track.Repository/TrackPushRecordDetails/Services/TrackPushRecordDetailsRepository.cs b/src/SJZY.Track.Repository/TrackPushRecordDetails/Services/TrackPushRecordDetailsRepository.cs deleted file mode 100644 index 20cd54e3..00000000 --- a/src/SJZY.Track.Repository/TrackPushRecordDetails/Services/TrackPushRecordDetailsRepository.cs +++ /dev/null @@ -1,9 +0,0 @@ -using SJZY.Track.Repository.TrackPushRecordDetails.Entitys; - -namespace SJZY.Track.Repository.TrackPushRecordDetails.Services -{ - public class TrackPushRecordDetailsRepository : BasicRepository, ITrackPushRecordDetailsRepository, IScopedDependency - { - - } -} diff --git a/test/SJZY.Track.Test/TestModule.cs b/test/SJZY.Track.Test/TestModule.cs index 8cff2d50..43bc8f71 100644 --- a/test/SJZY.Track.Test/TestModule.cs +++ b/test/SJZY.Track.Test/TestModule.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using SJZY.Track.Api; using SJZY.Track.Application; -using SJZY.Track.Repository; +using SJZY.Track.Infrastructure; using Volo.Abp; using Volo.Abp.AspNetCore.TestBase; using Volo.Abp.Authorization; @@ -19,7 +19,7 @@ namespace SJZY.Track.Test; typeof(AbpAspNetCoreTestBaseModule), typeof(AbpAutofacModule), typeof(AbpAuthorizationModule), - typeof(SJZYTrackRepositoryModule), + typeof(SJZYTrackInfrastructureModule), typeof(ApplicationModule), typeof(SJZYTrackApiModule), typeof(AbpHttpClientModule) //添加abp的http代理模块