diff --git a/src/SJZY.Track.Application/AutoMapper/TrackContentAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackContentAutoMapperProfile.cs new file mode 100644 index 00000000..e9346eff --- /dev/null +++ b/src/SJZY.Track.Application/AutoMapper/TrackContentAutoMapperProfile.cs @@ -0,0 +1,28 @@ +using AutoMapper; +using AutoMapper.Internal.Mappers; +using SJZY.Track.Application.Dtos.TrackContents; +using SJZY.Track.Application.Dtos.TrackTemplates; +using SJZY.Track.Domain.Aggregates.TrackContentAggregate; +using SJZY.Track.Domain.Dtos.TrackContents; +using SJZY.Track.Domain.Dtos.TrackTemplate; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.ObjectMapping; + +namespace SJZY.Track.Application.AutoMapper +{ + public class TrackContentAutoMapperProfile : Profile + { + public TrackContentAutoMapperProfile() + { + CreateMap(MemberList.None); + CreateMap(MemberList.None); + CreateMap(MemberList.None); + CreateMap(MemberList.None); + CreateMap, UnifyPageResultDto>(MemberList.None); + } + } +} diff --git a/src/SJZY.Track.Application/AutoMapper/TrackStatusAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackStatusAutoMapperProfile.cs new file mode 100644 index 00000000..c66d09e7 --- /dev/null +++ b/src/SJZY.Track.Application/AutoMapper/TrackStatusAutoMapperProfile.cs @@ -0,0 +1,31 @@ +using AutoMapper; +using AutoMapper.Internal.Mappers; +using SJZY.Track.Application.Dtos.Demo; +using SJZY.Track.Application.Dtos.TrackStatus; +using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; +using SJZY.Track.Domain.Dtos.TrackStatus; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.ObjectMapping; + +namespace SJZY.Track.Application.AutoMapper +{ + public class TrackStatusAutoMapperProfile : Profile + { + public TrackStatusAutoMapperProfile() + { + CreateMap(MemberList.None) + //层级不一致的场景 + .ForMember(dest => dest.Status, opt => opt.MapFrom(source => source.TrackStatus)) + .ForMember(dest => dest.EnStatus, opt => opt.MapFrom(source => source.EntrackStatus)) + .ForMember(dest => dest.Node, opt => opt.MapFrom(source => source.NodeId)); + CreateMap(MemberList.None); + CreateMap(MemberList.None); + CreateMap(MemberList.None); + CreateMap, UnifyPageResultDto>(MemberList.None); + } + } +} diff --git a/src/SJZY.Track.Application/AutoMapper/TrackTemplateAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackTemplateAutoMapperProfile.cs index 94219051..cec240ac 100644 --- a/src/SJZY.Track.Application/AutoMapper/TrackTemplateAutoMapperProfile.cs +++ b/src/SJZY.Track.Application/AutoMapper/TrackTemplateAutoMapperProfile.cs @@ -3,6 +3,7 @@ using AutoMapper.Internal.Mappers; using SJZY.Track.Application.Dtos.TrackTemplates; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Dtos.TrackTemplate; +using Volo.Abp.ObjectMapping; namespace SJZY.Track.Application.AutoMapper; @@ -14,11 +15,10 @@ public class TrackTemplateAutoMapperProfile : Profile public TrackTemplateAutoMapperProfile() { CreateMap(MemberList.None); - - //CreateMap, UnifyResultDto>(MemberList.None); - CreateMap(MemberList.None); - 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/Localization/Resources/en.json b/src/SJZY.Track.Application/Localization/Resources/en.json index 23d14ff9..7833f864 100644 --- a/src/SJZY.Track.Application/Localization/Resources/en.json +++ b/src/SJZY.Track.Application/Localization/Resources/en.json @@ -4,7 +4,8 @@ "NotNull1": "{0} is not null", "NotFindData": "No data found under the specified number", "ParameterDemo1": "{0} in {1} to do {2}", - "TemplateExist": "The template code already exists under the currently selected subsystem" - + "TemplateExist": "The template code already exists under the currently selected subsystem", + "TrackContentExist": "The trace code or trace content or trace content in the current subsystem is repeated in English", + "TrackStatusExist": "The trajectory status code or trajectory status or trajectory status in English is repeated under the current subsystem" } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Localization/Resources/zh.json b/src/SJZY.Track.Application/Localization/Resources/zh.json index 1bb47943..7ef977fe 100644 --- a/src/SJZY.Track.Application/Localization/Resources/zh.json +++ b/src/SJZY.Track.Application/Localization/Resources/zh.json @@ -4,6 +4,8 @@ "NotFindData": "未找到指定编号下的任何数据!", "ParameterDemo": "{0}在{1}地方做了{2}动作", "ParameterDemo1": "{0}在{1}地方做了{2}动作", - "TemplateExist": "模板代码已存在于当前选择的子系统下" + "TemplateExist": "模板代码已存在于当前选择的子系统下", + "TrackContentExist": "当前子系统下轨迹代码或轨迹内容或轨迹内容英文重复", + "TrackStatusExist": "当前子系统下轨迹状态代码或轨迹状态或轨迹状态英文重复" } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/SJZY.Track.Application.csproj b/src/SJZY.Track.Application/SJZY.Track.Application.csproj index 58d32d12..e8f1425c 100644 --- a/src/SJZY.Track.Application/SJZY.Track.Application.csproj +++ b/src/SJZY.Track.Application/SJZY.Track.Application.csproj @@ -8,8 +8,11 @@ + + + @@ -26,8 +29,4 @@ - - - - diff --git a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs index 95504518..3245d2ce 100644 --- a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs +++ b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs @@ -1,6 +1,8 @@ using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.Localization; using SJZY.Track.Application.Dtos.TrackContents; using SJZY.Track.Application.Dtos.TrackStatus; +using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackContentAggregate; using SJZY.Track.Domain.Dtos.TrackContents; using SJZY.Track.Domain.Dtos.TrackStatus; @@ -20,12 +22,15 @@ namespace SJZY.Track.Application.Services.TrackContents [Route("/Track/Content")] public class TrackContentService : ApplicationService, ITransientDependency { + private readonly IStringLocalizer _stringLocalizer; private readonly ITrackContentRepository _trackContentRepository; public TrackContentService( + IStringLocalizer stringLocalizer, ITrackContentRepository trackContentRepository ) { + this._stringLocalizer=stringLocalizer; this._trackContentRepository=trackContentRepository; } @@ -34,7 +39,6 @@ namespace SJZY.Track.Application.Services.TrackContents /// /// [HttpPost("Edit")] - [AllowAnonymous] public async Task EditAsync(EditTrackContentInput input) { return input.Options switch @@ -84,6 +88,15 @@ namespace SJZY.Track.Application.Services.TrackContents #region 私有方法 private async Task AddAsync(EditTrackContentInput input) { + #region 业务逻辑校验 + var trackContentEntity = await _trackContentRepository.GetFirstAsync(a => a.SubSystemId==input.SubSystemId&&(a.Code==input.Code || + a.Content==input.Content || a.EnContent==input.EnContent)); + if (trackContentEntity != null) + { + throw new BusinessException(message: _stringLocalizer["TrackContentExist"]); + } + #endregion + var entity = ObjectMapper.Map(input); var isTrue = await _trackContentRepository.InsertAsync(entity); @@ -92,6 +105,15 @@ namespace SJZY.Track.Application.Services.TrackContents private async Task UpdateAsync(EditTrackContentInput input) { + #region 业务逻辑校验 + var trackContentEntity = await _trackContentRepository.GetFirstAsync(a => a.Id!=input.Id && a.SubSystemId==input.SubSystemId && (a.Code==input.Code || + a.Content==input.Content || a.EnContent==input.EnContent)); + if (trackContentEntity != null) + { + throw new BusinessException(message: _stringLocalizer["TrackContentExist"]); + } + #endregion + var templateEntity = await _trackContentRepository.GetFirstAsync(a => a.Id == input.Id); ObjectMapper.Map(input, templateEntity); var isTrue = await _trackContentRepository.UpdateAsync(templateEntity); diff --git a/src/SJZY.Track.Application/Services/TrackFlags/ITrackFlagService.cs b/src/SJZY.Track.Application/Services/TrackFlags/ITrackFlagService.cs new file mode 100644 index 00000000..1e745341 --- /dev/null +++ b/src/SJZY.Track.Application/Services/TrackFlags/ITrackFlagService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SJZY.Track.Application.Services.TrackFlags +{ + public interface ITrackFlagService + { + } +} diff --git a/src/SJZY.Track.Application/Services/TrackFlags/TrackFlagService.cs b/src/SJZY.Track.Application/Services/TrackFlags/TrackFlagService.cs new file mode 100644 index 00000000..a01d56b5 --- /dev/null +++ b/src/SJZY.Track.Application/Services/TrackFlags/TrackFlagService.cs @@ -0,0 +1,26 @@ +using SJZY.Track.Application.Dtos.TrackStatus; +using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; +using SJZY.Track.Domain.Dtos.TrackStatus; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace SJZY.Track.Application.Services.TrackFlags +{ + /// + /// 轨迹标记服务 + /// + [ApiExplorerSettings(GroupName = "轨迹标记")] + [Route("/Track/Flag")] + public class TrackFlagService : ApplicationService, ITransientDependency + { + public TrackFlagService() + { + } + + + } +} diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs new file mode 100644 index 00000000..004198e0 --- /dev/null +++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs @@ -0,0 +1,71 @@ +using Microsoft.Extensions.Localization; +using SJZY.Track.Application.Localization; +using SJZY.Track.Domain.Aggregates.TrackPullAggregate; +using SJZY.Track.Domain.Dtos.Common; +using SJZY.Track.Domain.Dtos.TrackPull; +using Volo.Abp.DependencyInjection; + +namespace SJZY.Track.Application.Services.TrackPull; + +/// +/// 轨迹拉取 +/// +[ApiExplorerSettings(GroupName = "轨迹拉取")] +[Route("/Track/PullConfig")] +public class TrackPullService : ApplicationService, ITransientDependency +{ + private readonly IStringLocalizer _stringLocalizer; + private readonly ITrackPullConfigRepository _trackPullConfigRepository; + + public TrackPullService( + IStringLocalizer stringLocalizer, + ITrackPullConfigRepository trackPullConfigRepository) + { + _stringLocalizer = stringLocalizer; + _trackPullConfigRepository = trackPullConfigRepository; + } + + /// + /// 轨迹拉取配置列表 + /// + /// + /// + [HttpPost("GetPage")] + public async Task> GetPageAsync([FromBody] KeywordsInputVO input) + { + return await _trackPullConfigRepository.GetPageAsync(input); + } + + /// + /// 轨迹拉取配置内容列表 + /// + /// + /// + [HttpPost("GetContentPage")] + public async Task> GetContentPageAsync([FromBody] GetTrackPullContentPageInputVO input) + { + return await _trackPullConfigRepository.GetContentPageAsync(input); + } + + /// + /// 轨迹拉取配置详情 + /// + /// + /// + [HttpGet("GetDetail")] + public async Task GetDetailAsync(int id) + { + return await _trackPullConfigRepository.GetDetailAsync(id); + } + + /// + /// 轨迹拉取配置内容详情 + /// + /// + /// + [HttpGet("GetContentDetail")] + public async Task GetContentDetailAsync(int id) + { + return await _trackPullConfigRepository.GetContentDetailAsync(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 9db46c6f..7b076868 100644 --- a/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs +++ b/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs @@ -1,4 +1,6 @@ -using SJZY.Track.Application.Dtos.TrackStatus; +using Microsoft.Extensions.Localization; +using SJZY.Track.Application.Dtos.TrackStatus; +using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; using SJZY.Track.Domain.Dtos.TrackStatus; using Volo.Abp.DependencyInjection; @@ -12,12 +14,15 @@ namespace SJZY.Track.Application.Services.TrackStatus; [Route("/Track/Status")] public class TrackStatusService : ApplicationService, ITransientDependency { + private readonly IStringLocalizer _stringLocalizer; private readonly ITrackStatusRepository _trackStatusRepository; public TrackStatusService( + IStringLocalizer stringLocalizer, ITrackStatusRepository trackStatusRepository ) { + this._stringLocalizer=stringLocalizer; this._trackStatusRepository = trackStatusRepository; } @@ -73,9 +78,17 @@ public class TrackStatusService : ApplicationService, ITransientDependency } #region 私有方法 - private async Task AddAsync(EditTrackStatusInput input) { + #region 业务校验 + var trackStatusEntity = await _trackStatusRepository.GetFirstAsync(a => a.SubSystemId==input.SubSystemId&& (a.Code==input.Code || + a.Status==input.TrackStatus || a.EnStatus==input.EntrackStatus)); + if (trackStatusEntity!=null) + { + throw new BusinessException(message: _stringLocalizer["TrackStatusExist"]); + } + #endregion + var entity = ObjectMapper.Map(input); var isTrue = await _trackStatusRepository.InsertAsync(entity); @@ -84,6 +97,15 @@ public class TrackStatusService : ApplicationService, ITransientDependency private async Task UpdateAsync(EditTrackStatusInput input) { + #region 业务校验 + var trackStatusEntity = await _trackStatusRepository.GetFirstAsync(a => a.Id !=input.Id && a.SubSystemId==input.SubSystemId&& (a.Code==input.Code || + a.Status==input.TrackStatus || a.EnStatus==input.EntrackStatus)); + if (trackStatusEntity!=null) + { + throw new BusinessException(message: _stringLocalizer["TrackStatusExist"]); + } + #endregion + var templateEntity = await _trackStatusRepository.GetFirstAsync(a => a.Id == input.Id); ObjectMapper.Map(input, templateEntity); var isTrue = await _trackStatusRepository.UpdateAsync(templateEntity); @@ -97,6 +119,5 @@ public class TrackStatusService : ApplicationService, ITransientDependency return new UnifyResultDto("200", "删除成功", isTrue); } - #endregion } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs index 4716c2ba..422aafde 100644 --- a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs +++ b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs @@ -164,7 +164,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency x.TrackTemplateId == input.TrackTemplateId && x.TrackContentId == input.TrackContentId; if (input.Options == OptionTypeNoNull.修改) isAnyExp.And(x => x.Id != input.Id); - if (await _trackTemplateRepository.IsAnyAsync(isAnyExp)) + if (await _trackTemplateRepository.IsContentAnyAsync(isAnyExp)) throw new BusinessException(message: _stringLocalizer["IsTrackTemplateContentAny"]); } @@ -174,18 +174,18 @@ public class TrackTemplateService : ApplicationService, ITransientDependency var entity = ObjectMapper.Map(input); - await _trackTemplateRepository.InsertAsync(entity); + await _trackTemplateRepository.InsertContentAsync(entity); break; case OptionTypeNoNull.修改: - var oldEntity = await _trackTemplateRepository.GetByIdAsync(input.Id!.Value) ?? + var oldEntity = await _trackTemplateRepository.GetContentByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]); ObjectMapper.Map(input, oldEntity); - await _trackTemplateRepository.UpdateAsync(oldEntity); + await _trackTemplateRepository.UpdateContentAsync(oldEntity); break; diff --git a/src/SJZY.Track.Application/Validations/TrackContents/EditTrackContentInputValidation.cs b/src/SJZY.Track.Application/Validations/TrackContents/EditTrackContentInputValidation.cs new file mode 100644 index 00000000..0faf7a0c --- /dev/null +++ b/src/SJZY.Track.Application/Validations/TrackContents/EditTrackContentInputValidation.cs @@ -0,0 +1,38 @@ +using FluentValidation; +using SJZY.Track.Application.Dtos.TrackContents; +using SJZY.Track.Application.Dtos.TrackTemplates; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SJZY.Track.Application.Validations.TrackContents +{ + public class EditTrackContentInputValidation : AbstractValidator, IValidationEnabled + { + public EditTrackContentInputValidation() + { + //条件分支 + When(x => x.Options == OptionType.修改 || x.Options == OptionType.删除, () => + { + RuleFor(x => x.Id).GreaterThan(0).WithMessage("修改或删除时Id必须大于0!"); + }); + + When(x => x.Options == OptionType.新增, () => + { + RuleFor(x => x.Id).Equal(0).WithMessage("新增时Id必须等于0!"); + }); + + When(x => x.Options == OptionType.修改 || x.Options == OptionType.新增, () => + { + RuleFor(x => x.SubSystemId).GreaterThan(0).WithMessage("子系统的id必须大于0!"); + RuleFor(x => x.TrackStatusId).GreaterThan(0).WithMessage("所属状态的id必须大于0!"); + RuleFor(x => x.Code).NotNull().WithMessage("轨迹内容代码必填!").NotEmpty().WithMessage("轨迹内容代码不能为空!"); + RuleFor(x => x.Content).NotNull().WithMessage("轨迹内容必填!").NotEmpty().WithMessage("轨迹内容不能为空!"); + RuleFor(x => x.EnContent).NotNull().WithMessage("轨迹内容英文必填!").NotEmpty().WithMessage("轨迹内容英文不能为空!"); + }); + } + + } +} diff --git a/src/SJZY.Track.Application/Validations/TrackStatus/EditTrackStatusInputValidation.cs b/src/SJZY.Track.Application/Validations/TrackStatus/EditTrackStatusInputValidation.cs new file mode 100644 index 00000000..beb1df54 --- /dev/null +++ b/src/SJZY.Track.Application/Validations/TrackStatus/EditTrackStatusInputValidation.cs @@ -0,0 +1,37 @@ +using FluentValidation; +using SJZY.Track.Application.Dtos.TrackContents; +using SJZY.Track.Application.Dtos.TrackStatus; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SJZY.Track.Application.Validations.TrackStatus +{ + public class EditTrackStatusInputValidation : AbstractValidator, IValidationEnabled + { + public EditTrackStatusInputValidation() + { + //条件分支 + When(x => x.Options == OptionType.修改 || x.Options == OptionType.删除, () => + { + RuleFor(x => x.Id).GreaterThan(0).WithMessage("修改或删除时Id必须大于0!"); + }); + + When(x => x.Options == OptionType.新增, () => + { + RuleFor(x => x.Id).Equal(0).WithMessage("新增时Id必须等于0!"); + }); + + When(x => x.Options == OptionType.修改 || x.Options == OptionType.新增, () => + { + RuleFor(x => x.SubSystemId).GreaterThan(0).WithMessage("子系统的id必须大于0!"); + RuleFor(x => x.NodeId).GreaterThan(0).WithMessage("所属节点的id必须大于0!"); + RuleFor(x => x.Code).NotNull().WithMessage("轨迹状态代码必填!").NotEmpty().WithMessage("轨迹状态代码不能为空!"); + RuleFor(x => x.TrackStatus).NotNull().WithMessage("轨迹状态必填!").NotEmpty().WithMessage("轨迹状态不能为空!"); + RuleFor(x => x.EntrackStatus).NotNull().WithMessage("轨迹状态英文必填!").NotEmpty().WithMessage("轨迹状态英文不能为空!"); + }); + } + } +} diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs index 3b0b8441..6de7445c 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs @@ -1,5 +1,35 @@ -namespace SJZY.Track.Domain.Aggregates.TrackPullAggregate; +using SJZY.Track.Domain.Dtos.Common; +using SJZY.Track.Domain.Dtos.TrackPull; + +namespace SJZY.Track.Domain.Aggregates.TrackPullAggregate; public interface ITrackPullConfigRepository : IBasicRepository { + /// + /// 轨迹拉取配置列表 + /// + /// + /// + Task> GetPageAsync(KeywordsInputVO input); + + /// + /// 轨迹拉取配置内容列表 + /// + /// + /// + Task> GetContentPageAsync(GetTrackPullContentPageInputVO input); + + /// + /// 轨迹拉取配置详情 + /// + /// + /// + Task GetDetailAsync(int id); + + /// + /// 轨迹拉取配置内容详情 + /// + /// + /// + Task GetContentDetailAsync(int id); } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs index 72c28edf..22b3a468 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs @@ -25,13 +25,13 @@ public interface ITrackTemplateRepository : IBasicRepository Task GetContentDetailAsync(int id); - Task IsAnyAsync(Expression> whereExpression); + Task IsContentAnyAsync(Expression> whereExpression); - Task InsertAsync(TrackTemplateContentEntity insertObj); + Task InsertContentAsync(TrackTemplateContentEntity insertObj); - Task GetByIdAsync(int id); + Task GetContentByIdAsync(int id); - Task UpdateAsync(TrackTemplateContentEntity updateObj); + Task UpdateContentAsync(TrackTemplateContentEntity updateObj); Task SoftDeleteContentAsync(int id); } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/Common/KeywordsInputVO.cs b/src/SJZY.Track.Domain/Dtos/Common/KeywordsInputVO.cs new file mode 100644 index 00000000..9cf11c60 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/Common/KeywordsInputVO.cs @@ -0,0 +1,19 @@ +namespace SJZY.Track.Domain.Dtos.Common; + +public class KeywordsInputVO : PageInfoInput +{ + /// + /// 子系统id + /// + public int? SubSystemId { get; set; } + + /// + /// 关键字 + /// + public string Keywords { get; set; } + + /// + /// 选中项 + /// + public int? SelectedId { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs new file mode 100644 index 00000000..c424e5a6 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigDetailOutputVO.cs @@ -0,0 +1,81 @@ +namespace SJZY.Track.Domain.Dtos.TrackPull; + +public class GetTrackPullConfigDetailOutputVO +{ + public int Id { get; set; } + + /// + /// 拉取轨迹订单号 + /// + public string OrderNoName { get; set; } + + /// + /// 返参解析对象 + /// + public int ParseMethod { get; set; } + + /// + /// 定时任务(分钟) + /// + public int PullInterval { 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 TrackPlaceName { get; set; } + + /// + /// 拉取轨迹状态 + /// + public string TrackStatusName { get; set; } + + /// + /// 轨迹模板 + /// + public string 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/TrackPull/GetTrackPullConfigPageOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs new file mode 100644 index 00000000..e45b7de8 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullConfigPageOutputVO.cs @@ -0,0 +1,26 @@ +namespace SJZY.Track.Domain.Dtos.TrackPull; + +public class GetTrackPullConfigPageOutputVO +{ + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + + public int? Id { get; set; } + + /// + /// 服务商名称 + /// + public string ServiceProvider { 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/TrackPull/GetTrackPullContentDetailOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentDetailOutputVO.cs new file mode 100644 index 00000000..af51f0cf --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentDetailOutputVO.cs @@ -0,0 +1,56 @@ +namespace SJZY.Track.Domain.Dtos.TrackPull; + +public class GetTrackPullContentDetailOutputVO +{ + /// + /// 轨迹内容代码 + /// + public string Code { get; set; } + + 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; } + + /// + /// 拉取轨迹时区 + /// + public string TrackTimeZone { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentPageInputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentPageInputVO.cs new file mode 100644 index 00000000..ca31153a --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentPageInputVO.cs @@ -0,0 +1,9 @@ +namespace SJZY.Track.Domain.Dtos.TrackPull; + +public class GetTrackPullContentPageInputVO : PageInfoInput +{ + /// + /// 轨迹拉取配置id + /// + public int TrackPullConfigId { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentPageOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentPageOutputVO.cs new file mode 100644 index 00000000..c05a0375 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentPageOutputVO.cs @@ -0,0 +1,61 @@ +namespace SJZY.Track.Domain.Dtos.TrackPull; + +public class GetTrackPullContentPageOutputVO +{ + /// + /// 轨迹内容代码 + /// + public string Code { get; set; } + + /// + /// 轨迹内容 + /// + public string Content { get; set; } + + /// + /// 轨迹内容英文 + /// + public string EnContent { get; set; } + + public int? Id { get; set; } + + /// + /// 拉取轨迹内容代码 + /// + public string TrackContentCodeValue { get; set; } + + /// + /// 拉取轨迹内容 + /// + public bool? TrackContentValue { get; set; } + + /// + /// 拉取轨迹关键字(正向) + /// + public string TrackKeyword { get; set; } + + /// + /// 拉取轨迹关键字(正向) + /// + public List TrackKeywords { get; set; } + + /// + /// 拉取轨迹关键字(反向) + /// + public string TrackKeywordReverse { get; set; } + + /// + /// 拉取轨迹关键字(反向) + /// + public List TrackKeywordsReverse { get; set; } + + /// + /// 轨迹发生地 + /// + public string TrackPlaceValue { get; set; } + + /// + /// 拉取轨迹状态 + /// + public string TrackStatusValue { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/SJZY.Track.Domain.csproj b/src/SJZY.Track.Domain/SJZY.Track.Domain.csproj index aac0e12d..0354af7d 100644 --- a/src/SJZY.Track.Domain/SJZY.Track.Domain.csproj +++ b/src/SJZY.Track.Domain/SJZY.Track.Domain.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/SJZY.Track.Repository/TrackContentRepository.cs b/src/SJZY.Track.Repository/TrackContentRepository.cs index 1671ac80..32ebd92d 100644 --- a/src/SJZY.Track.Repository/TrackContentRepository.cs +++ b/src/SJZY.Track.Repository/TrackContentRepository.cs @@ -1,4 +1,5 @@ using SJZY.Track.Domain.Aggregates.TrackContentAggregate; +using SJZY.Track.Domain.Aggregates.TrackFlagAggregate; using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; using SJZY.Track.Domain.Dtos.TrackContents; using SJZY.Track.Domain.Dtos.TrackStatus; @@ -22,20 +23,22 @@ public class TrackContentRepository : BasicRepository, ITrac public async Task GetDetailAsync(int id) { var detail = await Context.Queryable() - .LeftJoin((a, b) => a.SubSystemId == b.Id) - .Where((a, b) => a.Id == id) - .Select((a, b) => new GetTrackContentDetailVO + .LeftJoin((a, b) => a.TrackStatusId==b.Id) + .LeftJoin((a, b, c) => a.TrackFlagId==c.Id) + .LeftJoin((a, b, c, d) => a.SubSystemId == b.Id) + .Where((a, b, c, d) => a.Id == id) + .Select((a, b, c, d) => new GetTrackContentDetailVO { Id = a.Id, SubSystemId = a.SubSystemId, - SubSystem = b.CnName, + SubSystem = d.CnName, TrackStatusId=a.TrackStatusId, - TrackStatus= "", + TrackStatus= b.Status, Code = a.Code, Content = a.Content, EnContent = a.EnContent, TrackFlagId=a.TrackFlagId, - TrackFlag="" + TrackFlag=c.Name }) .FirstAsync(); return detail; @@ -50,28 +53,32 @@ public class TrackContentRepository : BasicRepository, ITrac { UnifyPageResultDto pagedList = new UnifyPageResultDto(); pagedList = await Context.Queryable() - .LeftJoin((a, b) => a.SubSystemId == b.Id) - .LeftJoin((a, b, c) => a.CreateUserId == c.Id) - .LeftJoin((a, b, c, d) => a.UpdateUserId == d.Id) - .WhereIF(input.SubSystemId > 0, (a, b, c, d) => a.SubSystemId == input.SubSystemId) + .LeftJoin((a, b) => a.TrackStatusId==b.Id) + .LeftJoin((a, b, c) => a.TrackFlagId==c.Id) + .LeftJoin((a, b, c, d) => a.SubSystemId == d.Id) + .LeftJoin((a, b, c, d, e) => a.CreateUserId == e.Id) + .LeftJoin((a, b, c, d, e, f) => a.UpdateUserId == f.Id) + .WhereIF(input.SubSystemId > 0, (a, b, c, d, e, f) => a.SubSystemId == input.SubSystemId) .WhereIF(!input.Keywords.IsNullOrWhiteSpace(), - (a, b, c, d) => a.Code.Contains(input.Keywords) + (a, b, c, d, e, f) => a.Code.Contains(input.Keywords) || a.Content.Contains(input.Keywords) + || a.EnContent.Contains(input.Keywords) ) - .Select((a, b, c, d) => new GetTrackContentListVO + .Select((a, b, c, d, e, f) => new GetTrackContentListVO { Id = a.Id, - SubSystem = b.CnName, + SubSystem = d.CnName, Code = a.Code, Content = a.Content, EnContent = a.EnContent, - TrackStatus= "", - Node = "", - TrackFlag= "", + TrackStatus= b.Status, + Node = SqlFunc.IF(b.Node == 1).Return("揽收").ElseIF(b.Node == 2).Return("干线").ElseIF(b.Node == 3).Return("清关") + .ElseIF(b.Node == 4).Return("中转").ElseIF(b.Node == 5).Return("派送") + .End(""), + TrackFlag= c.Name, CreateTime = a.CreateTime, - CreateUser = c.Name, + CreateUser = e.Name, UpdateTime = a.UpdateTime, - UpdateUser = d.Name, - + UpdateUser = f.Name }) .ToPagedListAsync(input.PageIndex, input.PageSize); diff --git a/src/SJZY.Track.Repository/TrackPullConfigRepository.cs b/src/SJZY.Track.Repository/TrackPullConfigRepository.cs index d63120b7..8965f22a 100644 --- a/src/SJZY.Track.Repository/TrackPullConfigRepository.cs +++ b/src/SJZY.Track.Repository/TrackPullConfigRepository.cs @@ -1,8 +1,86 @@ -using SJZY.Track.Domain.Aggregates.TrackPullAggregate; +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; public class TrackPullConfigRepository : BasicRepository, ITrackPullConfigRepository, IScopedDependency { + public async Task> GetPageAsync(KeywordsInputVO input) + { + return await AsQueryable() + .LeftJoin((trackPull, system) => trackPull.SubSystemId == system.Id && !system.IsDeleted) + .LeftJoin((trackPull, system, service) => trackPull.ServiceProviderId == service.Id && !service.IsDeleted) + .LeftJoin((trackPull, system, service, template) => trackPull.TrackTemplateId == template.Id && !template.IsDeleted) + .Filter(null, true) + .Where(trackPull => !trackPull.IsDeleted) + .WhereIF(input.SubSystemId.HasValue, trackPull => trackPull.SubSystemId == input.SubSystemId) + .WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (trackPull, system, service, template) => service.Name.Contains(input.Keywords) || template.Name.Contains(input.Keywords)) + .OrderByDescending(trackPull => trackPull.CreateTime) + .Select((trackPull, system, service, template) => new GetTrackPullConfigPageOutputVO + { + Id = trackPull.Id, + SubSystem = system.CnName, + ServiceProvider = service.Name, + TrackTemplate = template.Name, + CreateTime = trackPull.CreateTime + }) + .ToPagedListAsync(input.PageIndex, input.PageSize); + } + + public async Task> GetContentPageAsync(GetTrackPullContentPageInputVO input) + { + return await Context.Queryable() + .InnerJoin((pullContent, trackContent) => pullContent.TrackContentId == trackContent.Id) + .InnerJoin((pullContent, trackContent, trackPull) => pullContent.TrackPullConfigId == trackPull.Id) + .InnerJoin((pullContent, trackContent, trackPull, templateContent) => trackPull.TrackTemplateId == templateContent.TrackTemplateId && pullContent.TrackContentId == templateContent.TrackContentId) + .Where(pullContent => pullContent.TrackPullConfigId == input.TrackPullConfigId) + .OrderBy((pullContent, trackContent, trackPull, templateContent) => templateContent.Sort) + .Select((pullContent, trackContent, trackPull, templateContent) => new GetTrackPullContentPageOutputVO + { + Id = pullContent.Id + }, true) + .Mapper(x => + { + x.TrackKeywords = [.. x.TrackKeyword.Split(',')]; + x.TrackKeywordsReverse = [.. x.TrackKeywordReverse.Split(',')]; + }) + .ToPagedListAsync(input.PageIndex, input.PageSize); + } + + public async Task GetDetailAsync(int id) + { + return await AsQueryable() + .LeftJoin((trackPull, system) => trackPull.SubSystemId == system.Id && !system.IsDeleted) + .LeftJoin((trackPull, system, service) => trackPull.ServiceProviderId == service.Id && !service.IsDeleted) + .LeftJoin((trackPull, system, service, template) => trackPull.TrackTemplateId == template.Id && !template.IsDeleted) + .InnerJoin((trackPull, system, service, template, paramsConfig) => trackPull.Id == paramsConfig.PullOrPushConfigId && !paramsConfig.IsPush && !paramsConfig.IsDeleted) + .Filter(null, true) + .Where(trackPull => trackPull.Id == id && !trackPull.IsDeleted) + .Select((trackPull, system, service, template, paramsConfig) => new GetTrackPullConfigDetailOutputVO + { + Id = trackPull.Id, + SubSystem = system.CnName, + ServiceProvider = service.Name, + TrackTemplate = template.Name + }, true) + .SingleAsync(); + } + + public async Task GetContentDetailAsync(int id) + { + return await Context.Queryable() + .InnerJoin((pullContent, trackContent) => pullContent.TrackContentId == trackContent.Id) + .Where(pullContent => pullContent.Id == id) + .Select((pullContent, trackContent) => new GetTrackPullContentDetailOutputVO + { + Id = pullContent.Id, + Code = trackContent.Code + "-" + trackContent.Content, + }, true) + .SingleAsync(); + } } \ No newline at end of file diff --git a/src/SJZY.Track.Repository/TrackStatusRepository.cs b/src/SJZY.Track.Repository/TrackStatusRepository.cs index 7f5d88b7..9e88da35 100644 --- a/src/SJZY.Track.Repository/TrackStatusRepository.cs +++ b/src/SJZY.Track.Repository/TrackStatusRepository.cs @@ -11,7 +11,7 @@ public class TrackStatusRepository : BasicRepository, ITrackS } /// - /// 获取轨迹模版明细 + /// 获取轨迹状态明细 /// /// /// @@ -56,7 +56,10 @@ public class TrackStatusRepository : BasicRepository, ITrackS Code = a.Code, EntrackStatus = a.EnStatus, TrackStatus = a.Status, - Node = "", + NodeId = a.Node, + Node = SqlFunc.IF(a.Node == 1).Return("揽收").ElseIF(a.Node == 2).Return("干线").ElseIF(a.Node == 3).Return("清关") + .ElseIF(a.Node == 4).Return("中转").ElseIF(a.Node == 5).Return("派送") + .End(""), CreateTime = a.CreateTime, CreateUser = c.Name, UpdateTime = a.UpdateTime, diff --git a/src/SJZY.Track.Repository/TrackTemplateRepository.cs b/src/SJZY.Track.Repository/TrackTemplateRepository.cs index b36ea8bf..249ed8d4 100644 --- a/src/SJZY.Track.Repository/TrackTemplateRepository.cs +++ b/src/SJZY.Track.Repository/TrackTemplateRepository.cs @@ -40,13 +40,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; } @@ -64,6 +64,7 @@ public class TrackTemplateRepository : BasicRepository, ITr .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) .Select((a, b) => new GetTrackTemplateListVO { Id = a.Id, @@ -73,41 +74,6 @@ public class TrackTemplateRepository : BasicRepository, ITr SubSystem = b.CnName }) .ToPagedListAsync(input.PageIndex, input.PageSize); - //如果轨迹模版id传值了,就置顶在第一条 - if (input.TrackTemplateId > 0 && (!pagedList.List.IsNullOrEmpty())) - { - if (input.PageIndex == 1) - { - bool existCurrent = pagedList.List.Any(x => x.Id == input.TrackTemplateId); - if (existCurrent) - { - var item = pagedList.List.FirstOrDefault(x => x.Id == input.TrackTemplateId); - pagedList.List.Remove(item); - pagedList.List.Insert(0, item); - } - else - { - var item = await Context.Queryable() - .LeftJoin((a, b) => a.SubSystemId == b.Id) - .Where((a, b) => a.Id == input.TrackTemplateId) - .Select((a, b) => new GetTrackTemplateListVO - { - Id = a.Id, - Code = a.Code, - CreateTime = a.CreateTime, - Name = a.Name, - SubSystem = b.CnName - }) - .FirstAsync(); - if (item != null) - { - var removeItem = pagedList.List.LastOrDefault(); - pagedList.List.Remove(removeItem); - pagedList.List.Insert(0, item); - } - } - } - } return pagedList; } @@ -134,6 +100,7 @@ public class TrackTemplateRepository : BasicRepository, ITr .Filter(null, true) .Where(templateContent => templateContent.TrackTemplateId == input.TrackTemplateId && !templateContent.IsDeleted) + .OrderByDescending(templateContent => templateContent.CreateTime) .Select((templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) => new GetTrackTemplateContentPageOutputVO { @@ -169,25 +136,25 @@ public class TrackTemplateRepository : BasicRepository, ITr } /// - public async Task IsAnyAsync(Expression> whereExpression) + public async Task IsContentAnyAsync(Expression> whereExpression) { return await Context.Queryable().Where(whereExpression).AnyAsync(); } /// - public async Task InsertAsync(TrackTemplateContentEntity insertObj) + public async Task InsertContentAsync(TrackTemplateContentEntity insertObj) { return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0; } /// - public async Task GetByIdAsync(int id) + public async Task GetContentByIdAsync(int id) { return await Context.Queryable().InSingleAsync(id); } /// - public async Task UpdateAsync(TrackTemplateContentEntity updateObj) + public async Task UpdateContentAsync(TrackTemplateContentEntity updateObj) { return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync(); }