diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackContents/EditTrackContentMapInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackContents/EditTrackContentMapInput.cs new file mode 100644 index 00000000..e952cc62 --- /dev/null +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackContents/EditTrackContentMapInput.cs @@ -0,0 +1,41 @@ +namespace SJZY.Track.Application.Contract.Dtos.TrackContents; + +public class EditTrackContentMapInput +{ + public int? Id { get; set; } + + /// + /// 映射子系统id + /// + public int MapSubSystemId { get; set; } + + /// + /// 映射轨迹内容代码 + /// + public string MapTrackContentCode { get; set; } + + /// + /// 映射轨迹内容id + /// + public int MapTrackContentId { get; set; } + + /// + /// 操作类型 + /// + public OptionTypeNoNull Options { get; set; } + + /// + /// 源子系统id + /// + public int SubSystemId { get; set; } + + /// + /// 源轨迹内容代码 + /// + public string TrackContentCode { get; set; } + + /// + /// 源轨迹内容id + /// + public int TrackContentId { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs index 61e15c3e..0b69d4a5 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/EditTrackPullConfigInput.cs @@ -37,27 +37,27 @@ public class EditTrackPullConfigInput /// /// 拉取轨迹时区 /// - public string TackTimeZoneName { get; set; } + public string? TackTimeZoneName { get; set; } /// /// 拉取轨迹内容代码 /// - public string TrackContentCodeName { get; set; } + public string? TrackContentCodeName { get; set; } /// /// 拉取轨迹内容 /// - public string TrackContentName { get; set; } + public string? TrackContentName { get; set; } /// /// 拉取轨迹发生地 /// - public string TrackPlaceName { get; set; } + public string? TrackPlaceName { get; set; } /// /// 拉取轨迹状态 /// - public string TrackStatusName { get; set; } + public string? TrackStatusName { get; set; } /// /// 轨迹模板id @@ -67,5 +67,5 @@ public class EditTrackPullConfigInput /// /// 拉取轨迹发生时间 /// - public string TrackTimeName { get; set; } + public string? TrackTimeName { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPush/SortTrackPushContentInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/SortTrackPushContentInput.cs new file mode 100644 index 00000000..f4ecab4c --- /dev/null +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/SortTrackPushContentInput.cs @@ -0,0 +1,5 @@ +namespace SJZY.Track.Application.Contract.Dtos.TrackPush; + +public class SortTrackPushContentInput +{ +} \ No newline at end of file diff --git a/src/SJZY.Track.Application/AutoMapper/TrackContentAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackContentAutoMapperProfile.cs index 25f17ab6..bf20809b 100644 --- a/src/SJZY.Track.Application/AutoMapper/TrackContentAutoMapperProfile.cs +++ b/src/SJZY.Track.Application/AutoMapper/TrackContentAutoMapperProfile.cs @@ -15,6 +15,7 @@ namespace SJZY.Track.Application.AutoMapper CreateMap(MemberList.None); CreateMap, UnifyPageResultDto>( MemberList.None); + CreateMap(MemberList.None); } } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs index 281fed37..b746323f 100644 --- a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs +++ b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs @@ -1,8 +1,14 @@ using Microsoft.Extensions.Localization; +using SJZY.Expand.ABP.Core.Common.Dto; +using SJZY.Expand.ABP.Core.Localization; +using SJZY.Expand.ABP.Core.PublicMethords; using SJZY.Track.Application.Contract.Dtos.TrackContents; +using SJZY.Track.Application.Contract.Dtos.TrackPull; using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackContentAggregate; +using SJZY.Track.Domain.Aggregates.TrackPullAggregate; using SJZY.Track.Domain.Dtos.TrackContents; +using System.Linq.Expressions; using Volo.Abp.DependencyInjection; namespace SJZY.Track.Application.Services.TrackContents @@ -93,7 +99,7 @@ namespace SJZY.Track.Application.Services.TrackContents throw new BusinessException(message: _stringLocalizer["TrackContentExist"]); } - #endregion + #endregion 业务逻辑校验 var entity = ObjectMapper.Map(input); var isTrue = await _trackContentRepository.InsertAsync(entity); @@ -104,6 +110,7 @@ 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)); @@ -111,11 +118,38 @@ namespace SJZY.Track.Application.Services.TrackContents { throw new BusinessException(message: _stringLocalizer["TrackContentExist"]); } - #endregion + + #endregion 业务逻辑校验 + //更新的时候需要覆盖内容映射轨迹代码 var templateEntity = await _trackContentRepository.GetFirstAsync(a => a.Id == input.Id); - ObjectMapper.Map(input, templateEntity); - var isTrue = await _trackContentRepository.UpdateAsync(templateEntity); + + bool isTrue = false; + + using (var ts = TransactionScopeHelper.Create()) + { + // 如果轨迹内容的子系统和code发生变化,同步到轨迹映射表 + if (templateEntity.SubSystemId != input.SubSystemId || templateEntity.Code != input.Code) + { + await _trackContentRepository.UpdateMapAsync(x => new TrackContentMapEntity + { + SubSystemId = input.SubSystemId, + TrackContentCode = input.Code + }, x => x.TrackContentId == input.Id); + + await _trackContentRepository.UpdateMapAsync(x => new TrackContentMapEntity + { + MapSubSystemId = input.SubSystemId, + MapTrackContentCode = input.Code + }, x => x.MapTrackContentId == input.Id); + } + + ObjectMapper.Map(input, templateEntity); + + isTrue = await _trackContentRepository.UpdateAsync(templateEntity); + + ts.Complete(); + } return new UnifyResultDto("200", "修改成功", isTrue); } @@ -123,13 +157,88 @@ namespace SJZY.Track.Application.Services.TrackContents private async Task DeleteAsync(EditTrackContentInput input) { #region 业务校验 + //需要加个判断,存在内容映射,则出提示 - #endregion + + #endregion 业务校验 + var isTrue = await _trackContentRepository.SoftDeleteAsync(x => x.Id == input.Id); return new UnifyResultDto("200", "删除成功", isTrue); } - #endregion + #endregion 私有方法 + + /// + /// 轨迹内容映射列表 + /// + /// + /// + [HttpPost("GetMapPage")] + public async Task> GetMapPageAsync([FromBody] GetTrackContentMapPageInputVO input) + { + return await _trackContentRepository.GetMapPageAsync(input); + } + + /// + /// 轨迹内容映射详情 + /// + /// + /// + [HttpGet("GetMapDetail")] + public async Task GetMapDetailAsync(int id) + { + return await _trackContentRepository.GetMapDetailAsync(id); + } + + /// + /// 轨迹内容映射编辑 + /// + /// + /// + [HttpPost("EditMap")] + public async Task EditMapAsync([FromBody] EditTrackContentMapInput input) + { + if (input.Options != OptionTypeNoNull.删除) + { + Expression> isMapAnyExp = x => + x.TrackContentId == input.TrackContentId && x.MapTrackContentId == input.MapTrackContentId; + if (input.Options == OptionTypeNoNull.修改) isMapAnyExp.And(x => x.Id != input.Id); + + if (await _trackContentRepository.IsMapAnyAsync(isMapAnyExp)) + throw new BusinessException(message: _stringLocalizer["IsTrackContentMapAny"]); + } + + switch (input.Options) + { + case OptionTypeNoNull.新增: + { + var trackContentMapEntity = ObjectMapper.Map(input); + + await _trackContentRepository.InsertMapAsync(trackContentMapEntity); + } + break; + + case OptionTypeNoNull.修改: + { + var oldTrackContentMapEntity = await _trackContentRepository.GetMapByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]); + + ObjectMapper.Map(input, oldTrackContentMapEntity); + + await _trackContentRepository.UpdateMapAsync(oldTrackContentMapEntity); + } + break; + + case OptionTypeNoNull.删除: + await _trackContentRepository.SoftDeleteMapAsync(x => x.Id == input.Id); + break; + + default: + throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum, + nameof(EditTrackContentMapInput.Options)]); + } + + 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 index 7c8489ed..cbb9a835 100644 --- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs +++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs @@ -1,8 +1,10 @@ using Microsoft.Extensions.Localization; +using SJZY.Expand.ABP.Core; using SJZY.Expand.ABP.Core.Localization; using SJZY.Expand.ABP.Core.PublicMethords; using SJZY.Track.Application.Contract.Dtos.TrackPush; using SJZY.Track.Application.Localization; +using SJZY.Track.Domain.Aggregates.DemoAggregate; using SJZY.Track.Domain.Aggregates.TrackPullAggregate; using SJZY.Track.Domain.Aggregates.TrackPushAggregate; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; @@ -66,7 +68,7 @@ public class TrackPushService : ApplicationService, ITransientDependency /// /// [HttpGet("GetDetail")] - public async Task GetDetailAsync(int id) + public async Task GetDetailAsync(int id) { var res = await _trackPushConfigRepository.GetDetailAsync(id); if (res is null) return null; @@ -126,6 +128,8 @@ public class TrackPushService : ApplicationService, ITransientDependency trackPushParamsEntity.PullOrPushConfigId = id; await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity); + if (input.IsAutoPush) await RedisHelper.Client.SAddAsync(GlobalConst.AutoPushRosterRedisKey, input.CustomId); + ts.Complete(); } } @@ -135,6 +139,8 @@ public class TrackPushService : ApplicationService, ITransientDependency { var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]); + int oldCustomId = oldTrackPushEntity.CustomId; + var oldTrackPushParamsEntity = await _trackPullConfigRepository.GetParamsSingleAsync(x => x.PullOrPushConfigId == input.Id && x.IsPush); @@ -147,22 +153,30 @@ public class TrackPushService : ApplicationService, ITransientDependency await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity); await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity); + await RedisHelper.Client.SRemAsync(GlobalConst.AutoPushRosterRedisKey, oldCustomId); + if (input.IsAutoPush) await RedisHelper.Client.SAddAsync(GlobalConst.AutoPushRosterRedisKey, input.CustomId); + ts.Complete(); } } break; case OptionTypeNoNull.删除: - using (var ts = TransactionScopeHelper.Create()) { - await _trackPushConfigRepository.SoftDeleteAsync(x => x.Id == input.Id); - await _trackPullConfigRepository.SoftDeleteParamsAsync(x => - x.PullOrPushConfigId == input.Id && x.IsPush); - await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id); + var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]); - ts.Complete(); + using (var ts = TransactionScopeHelper.Create()) + { + await _trackPushConfigRepository.SoftDeleteAsync(x => x.Id == input.Id); + await _trackPullConfigRepository.SoftDeleteParamsAsync(x => + x.PullOrPushConfigId == input.Id && x.IsPush); + await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id); + + await RedisHelper.Client.SRemAsync(GlobalConst.AutoPushRosterRedisKey, oldTrackPushEntity.CustomId); + + ts.Complete(); + } } - break; default: @@ -223,4 +237,15 @@ public class TrackPushService : ApplicationService, ITransientDependency return true; } + + /// + /// 轨迹推送配置内容排序 + /// + /// + /// + [HttpPost("SortContent")] + public async Task SortContentAsync([FromBody] SortTrackPushContentInput input) + { + return true; + } } \ 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 2365b632..6fdf4498 100644 --- a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs +++ b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs @@ -30,7 +30,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency { _stringLocalizer = stringLocalizer; _trackTemplateRepository = trackTemplateRepository; - _trackPullConfigRepository=trackPullConfigRepository; + _trackPullConfigRepository = trackPullConfigRepository; } /// @@ -100,7 +100,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency throw new BusinessException("轨迹代码重复"); } - #endregion + #endregion 业务校验 var entity = ObjectMapper.Map(input); var isTrue = await _trackTemplateRepository.InsertAsync(entity); @@ -111,13 +111,15 @@ public class TrackTemplateService : ApplicationService, ITransientDependency private async Task UpdateAsync(EditTrackTemplateInput input) { #region 业务校验 + var isExist = await _trackTemplateRepository.GetFirstAsync(a => a.Id != input.Id && a.SubSystemId == input.SubSystemId && a.Code == input.Code); if (isExist != null) { throw new BusinessException(message: _stringLocalizer["TemplateExist"]); } - #endregion + + #endregion 业务校验 var templateEntity = await _trackTemplateRepository.GetFirstAsync(a => a.Id == input.Id); ObjectMapper.Map(input, templateEntity); @@ -129,13 +131,15 @@ public class TrackTemplateService : ApplicationService, ITransientDependency private async Task DeleteAsync(EditTrackTemplateInput input) { #region 业务校验 + //查询看看在轨迹拉取里面有没有被占用 - var isExisistTrackPullConfig = await _trackPullConfigRepository.GetFirstAsync(a => a.TrackTemplateId==input.Id); - if (isExisistTrackPullConfig!=null) + var isExisistTrackPullConfig = await _trackPullConfigRepository.GetFirstAsync(a => a.TrackTemplateId == input.Id); + if (isExisistTrackPullConfig != null) { throw new BusinessException(message: _stringLocalizer["IsExistTrackPullConfig"]); } - #endregion + + #endregion 业务校验 var isTrue = await _trackTemplateRepository.SoftDeleteAsync(x => x.Id == input.Id); diff --git a/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/ITrackContentRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/ITrackContentRepository.cs index fbd0e412..cc7a54e9 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/ITrackContentRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/ITrackContentRepository.cs @@ -1,10 +1,26 @@ using SJZY.Track.Domain.Dtos.TrackContents; -using SJZY.Track.Domain.Dtos.TrackStatus; namespace SJZY.Track.Domain.Aggregates.TrackContentAggregate; public interface ITrackContentRepository : IBasicRepository { Task GetDetailAsync(int id); + Task> GetPageTrackContent(GetPageTrackContentVO input); + + Task> GetMapPageAsync(GetTrackContentMapPageInputVO input); + + Task GetMapDetailAsync(int id); + + Task IsMapAnyAsync(Expression> whereExpression); + + Task InsertMapAsync(TrackContentMapEntity insertObj); + + Task GetMapByIdAsync(int id); + + Task UpdateMapAsync(TrackContentMapEntity updateObj); + + Task SoftDeleteMapAsync(Expression> whereExpression); + + Task UpdateMapAsync(Expression> columns, Expression> whereExpression); } \ 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 index 2e58c378..f46e3c41 100644 --- a/src/SJZY.Track.Domain/Dtos/Common/KeywordsInputVO.cs +++ b/src/SJZY.Track.Domain/Dtos/Common/KeywordsInputVO.cs @@ -15,5 +15,5 @@ public class KeywordsInputVO : PageInfoInput /// /// 选中项 /// - public int? SelectedId { get; set; } + public List? SelectedId { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentMapDetailOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentMapDetailOutputVO.cs new file mode 100644 index 00000000..dce4eff9 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentMapDetailOutputVO.cs @@ -0,0 +1,56 @@ +namespace SJZY.Track.Domain.Dtos.TrackContents; + +public class GetTrackContentMapDetailOutputVO +{ + public int Id { get; set; } + + /// + /// 映射子系统 + /// + public string MapSubSystem { get; set; } + + /// + /// 映射子系统id + /// + public int MapSubSystemId { get; set; } + + /// + /// 映射轨迹内容 + /// + public string MapTrackContent { get; set; } + + /// + /// 映射轨迹内容id + /// + public int MapTrackContentId { get; set; } + + /// + /// 子系统 + /// + public string SubSystem { get; set; } + + /// + /// 子系统id + /// + public int SubSystemId { get; set; } + + /// + /// 源轨迹内容 + /// + public string TrackContent { get; set; } + + /// + /// 源轨迹内容id + /// + public int TrackContentId { get; set; } + + /// + /// 源轨迹内容代码 + /// + public string TrackContentCode { get; set; } + + /// + /// 映射轨迹内容代码 + /// + public string MapTrackContentCode { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentMapPageInputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentMapPageInputVO.cs new file mode 100644 index 00000000..e6cd19e6 --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentMapPageInputVO.cs @@ -0,0 +1,11 @@ +using SJZY.Track.Domain.Dtos.Common; + +namespace SJZY.Track.Domain.Dtos.TrackContents; + +public class GetTrackContentMapPageInputVO : KeywordsInputVO +{ + /// + /// 映射子系统id + /// + public int? MapSubSystemId { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentMapPageOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentMapPageOutputVO.cs new file mode 100644 index 00000000..e291b71f --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentMapPageOutputVO.cs @@ -0,0 +1,56 @@ +namespace SJZY.Track.Domain.Dtos.TrackContents; + +public class GetTrackContentMapPageOutputVO +{ + /// + /// 轨迹内容代码 + /// + public string Code { get; set; } + + /// + /// 轨迹内容 + /// + public string Content { get; set; } + + /// + /// 轨迹内容英文 + /// + public string EnContent { get; set; } + + public int Id { get; set; } + + /// + /// 映射轨迹内容代码 + /// + public string MapCode { get; set; } + + /// + /// 映射内容 + /// + public string MapContent { get; set; } + + /// + /// 映射内容英文 + /// + public string MapEnContent { get; set; } + + /// + /// 映射子系统 + /// + public string MapSubSystem { get; set; } + + /// + /// 映射轨迹状态 + /// + public string MapTrackStatus { get; set; } + + /// + /// 子系统 + /// + public string SubSystem { get; set; } + + /// + /// 轨迹状态 + /// + public string TrackStatus { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs index 900c74bc..ced23f75 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigDetailOutputVO.cs @@ -91,6 +91,11 @@ public class GetTrackPushConfigDetailOutputVO /// public string TrackTemplateId { get; set; } + /// + /// 轨迹模板ids + /// + public List TrackTemplateIds { get; set; } + /// /// 推送轨迹发生时间 /// diff --git a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs index 9b2e3a83..e0095b23 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackPush/GetTrackPushConfigPageOutputVO.cs @@ -23,4 +23,14 @@ public class GetTrackPushConfigPageOutputVO /// 模板名称 /// public string TrackTemplate { get; set; } + + /// + /// 轨迹模板id + /// + public string TrackTemplateId { get; set; } + + /// + /// 轨迹模板ids + /// + public List TrackTemplateIds { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentPageInputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentPageInputVO.cs index d08ad492..09e8f51f 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentPageInputVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentPageInputVO.cs @@ -5,5 +5,5 @@ public class GetTrackTemplateContentPageInputVO : PageInfoInput /// /// 轨迹模板id /// - public int TrackTemplateId { get; set; } + public List TrackTemplateIds { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentPageOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentPageOutputVO.cs index dd3a27d4..18d6ddcc 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentPageOutputVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentPageOutputVO.cs @@ -68,4 +68,9 @@ public class GetTrackTemplateContentPageOutputVO /// 修改人 /// public string UpdateUser { get; set; } + + /// + /// 轨迹内容id + /// + public int TrackContentId { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/GlobalConst.cs b/src/SJZY.Track.Domain/GlobalConst.cs index 77881f20..8db2300c 100644 --- a/src/SJZY.Track.Domain/GlobalConst.cs +++ b/src/SJZY.Track.Domain/GlobalConst.cs @@ -6,9 +6,14 @@ public class GlobalConst /// 轨迹明细es索引名称 /// public const string TrackIndex = "sjzy_track_details"; - + /// /// 轨迹新增/更新cap订阅名称 /// public const string TrackUpsertSubscribe = "SJZY.Track.Upsert"; + + /// + /// 自动推送名单RedisKey + /// + public const string AutoPushRosterRedisKey = "AutoPushRoster"; } \ No newline at end of file diff --git a/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs index e4f2e387..6946391e 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs @@ -3,15 +3,15 @@ using SJZY.Track.Domain.Aggregates.TrackFlagAggregate; using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; using SJZY.Track.Domain.Dtos.TrackContents; using SJZY.Track.Domain.VEntities; +using System.Linq; +using System.Linq.Expressions; namespace SJZY.Track.Repository.Repositories; public class TrackContentRepository : BasicRepository, ITrackContentRepository, IScopedDependency { - public TrackContentRepository() { - } /// @@ -24,20 +24,20 @@ public class TrackContentRepository : BasicRepository, ITrac var detail = await Context.Queryable() .LeftJoin((a, b) => a.TrackStatusId == b.Id && b.IsDeleted == false) .LeftJoin((a, b, c) => a.TrackFlagId == c.Id && c.IsDeleted == false) - .LeftJoin((a, b, c, d) => a.SubSystemId == d.Id&&d.IsDeleted==false) + .LeftJoin((a, b, c, d) => a.SubSystemId == d.Id && d.IsDeleted == false) .Where((a, b, c, d) => a.Id == id) .Select((a, b, c, d) => new GetTrackContentDetailVO { Id = a.Id, SubSystemId = a.SubSystemId, SubSystem = d.CnName, - TrackStatusId=a.TrackStatusId, - TrackStatus= b.Status, + TrackStatusId = a.TrackStatusId, + TrackStatus = b.Status, Code = a.Code, Content = a.Content, EnContent = a.EnContent, - TrackFlagId=a.TrackFlagId, - TrackFlag=c.Name + TrackFlagId = a.TrackFlagId, + TrackFlag = c.Name }) .FirstAsync(); return detail; @@ -52,8 +52,8 @@ public class TrackContentRepository : BasicRepository, ITrac { UnifyPageResultDto pagedList = new UnifyPageResultDto(); pagedList = await Context.Queryable() - .LeftJoin((a, b) => a.TrackStatusId==b.Id&&b.IsDeleted==false) - .LeftJoin((a, b, c) => a.TrackFlagId==c.Id&&c.IsDeleted==false) + .LeftJoin((a, b) => a.TrackStatusId == b.Id && b.IsDeleted == false) + .LeftJoin((a, b, c) => a.TrackFlagId == c.Id && c.IsDeleted == false) .LeftJoin((a, b, c, d) => a.SubSystemId == d.Id && d.IsDeleted == false) .LeftJoin((a, b, c, d, e) => a.CreateUserId == e.Id && e.IsDeleted == false) .LeftJoin((a, b, c, d, e, f) => a.UpdateUserId == f.Id && f.IsDeleted == false) @@ -71,11 +71,11 @@ public class TrackContentRepository : BasicRepository, ITrac Code = a.Code, Content = a.Content, EnContent = a.EnContent, - TrackStatus= b.Status, + 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, + TrackFlag = c.Name, CreateTime = a.CreateTime, CreateUser = e.Name, UpdateTime = a.UpdateTime, @@ -83,10 +83,95 @@ public class TrackContentRepository : BasicRepository, ITrac }) .ToPagedListAsync(input.PageIndex, input.PageSize); - var ff = await Context.Queryable().Where(a => 1==1).ToListAsync(); - - + var ff = await Context.Queryable().Where(a => 1 == 1).ToListAsync(); return pagedList; } + + public async Task> GetMapPageAsync(GetTrackContentMapPageInputVO input) + { + return await Context.Queryable() + .InnerJoin((contentMap, sourceContent) => contentMap.TrackContentId == sourceContent.Id && !sourceContent.IsDeleted) + .InnerJoin((contentMap, sourceContent, targetContent) => contentMap.MapTrackContentId == targetContent.Id && !targetContent.IsDeleted) + .LeftJoin((contentMap, sourceContent, targetContent, sourceSystem) => contentMap.SubSystemId == sourceSystem.Id && !sourceSystem.IsDeleted) + .LeftJoin((contentMap, sourceContent, targetContent, sourceSystem, targetSystem) => contentMap.MapSubSystemId == targetSystem.Id && !targetSystem.IsDeleted) + .LeftJoin((contentMap, sourceContent, targetContent, sourceSystem, targetSystem, sourceStatus) => sourceContent.TrackStatusId == sourceStatus.Id && !sourceStatus.IsDeleted) + .LeftJoin((contentMap, sourceContent, targetContent, sourceSystem, targetSystem, sourceStatus, targetStatus) => targetContent.TrackStatusId == targetStatus.Id && !targetStatus.IsDeleted) + .Filter(null, true) + .Where(contentMap => !contentMap.IsDeleted) + .WhereIF(input.SubSystemId.HasValue, contentMap => contentMap.SubSystemId == input.SubSystemId) + .WhereIF(input.MapSubSystemId.HasValue, contentMap => contentMap.MapSubSystemId == input.MapSubSystemId) + .WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (contentMap, sourceContent) => sourceContent.Code.Contains(input.Keywords) || sourceContent.Content.Contains(input.Keywords) || sourceContent.EnContent.Contains(input.Keywords)) + .OrderByDescending(contentMap => contentMap.CreateTime) + .Select((contentMap, sourceContent, targetContent, sourceSystem, targetSystem, sourceStatus, targetStatus) => new GetTrackContentMapPageOutputVO + { + Id = contentMap.Id, + SubSystem = sourceSystem.CnName, + Code = contentMap.TrackContentCode, + TrackStatus = sourceStatus.Status, + Content = sourceContent.Content, + EnContent = sourceContent.EnContent, + MapSubSystem = targetSystem.CnName, + MapCode = contentMap.MapTrackContentCode, + MapTrackStatus = targetStatus.Status, + MapContent = targetContent.Content, + MapEnContent = targetContent.EnContent + }) + .ToPagedListAsync(input.PageIndex, input.PageSize); + } + + public async Task GetMapDetailAsync(int id) + { + return await Context.Queryable() + .InnerJoin((contentMap, sourceContent) => contentMap.TrackContentId == sourceContent.Id && !sourceContent.IsDeleted) + .InnerJoin((contentMap, sourceContent, targetContent) => contentMap.MapTrackContentId == targetContent.Id && !targetContent.IsDeleted) + .LeftJoin((contentMap, sourceContent, targetContent, sourceSystem) => contentMap.SubSystemId == sourceSystem.Id && !sourceSystem.IsDeleted) + .LeftJoin((contentMap, sourceContent, targetContent, sourceSystem, targetSystem) => contentMap.MapSubSystemId == targetSystem.Id && !targetSystem.IsDeleted) + .Filter(null, true) + .Where(contentMap => !contentMap.IsDeleted) + .Select((contentMap, sourceContent, targetContent, sourceSystem, targetSystem) => new GetTrackContentMapDetailOutputVO + { + Id = contentMap.Id, + SubSystemId = contentMap.SubSystemId, + SubSystem = sourceSystem.CnName, + TrackContent = contentMap.TrackContentCode + "-" + sourceContent.Content, + MapSubSystem = targetSystem.CnName, + MapTrackContent = contentMap.MapTrackContentCode + "-" + targetContent.Content + }, true) + .SingleAsync(); + } + + public async Task IsMapAnyAsync(Expression> whereExpression) + { + return await Context.Queryable().Where(whereExpression).AnyAsync(); + } + + public async Task InsertMapAsync(TrackContentMapEntity insertObj) + { + return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0; + } + + public async Task GetMapByIdAsync(int id) + { + return await Context.Queryable().InSingleAsync(id); + } + + public async Task UpdateMapAsync(TrackContentMapEntity updateObj) + { + return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync(); + } + + public async Task SoftDeleteMapAsync(Expression> whereExpression) + { + return await Context.Updateable() + .Where(whereExpression) + .SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true) + .ExecuteCommandHasChangeAsync(); + } + + public async Task UpdateMapAsync(Expression> columns, Expression> whereExpression) + { + return await Context.Updateable().SetColumns(columns).Where(whereExpression) + .ExecuteCommandAsync() > 0; + } } \ No newline at end of file diff --git a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs index 9c2cb3d2..472a8908 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs @@ -32,9 +32,11 @@ public class TrackPushConfigRepository : BasicRepository, TrackTemplate = SqlFunc.Subqueryable() .Where(template => SqlFunc.SplitIn(trackPush.TrackTemplateId, template.Id.ToString()) && !template.IsDeleted) .SelectStringJoin(template => template.Name, ","), + TrackTemplateId = trackPush.TrackTemplateId, CreateTime = trackPush.CreateTime }) .Distinct() + .Mapper(x => { x.TrackTemplateIds = x.TrackTemplateId.Split(',').Select(int.Parse).ToList(); }) .ToPagedListAsync(input.PageIndex, input.PageSize); } @@ -68,6 +70,7 @@ public class TrackPushConfigRepository : BasicRepository, CustomName = externalSubject.Abbreviation, ServiceProvider = service.Name, }, true) + .Mapper(x => { x.TrackTemplateIds = x.TrackTemplateId.Split(',').Select(int.Parse).ToList(); }) .SingleAsync(); } diff --git a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs index 6fe279f7..af67ce40 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs @@ -20,7 +20,7 @@ public class TrackTemplateRepository : BasicRepository, ITr public async Task GetDetailAsync(int id) { var detail = await Context.Queryable() - .LeftJoin((a, b) => a.SubSystemId == b.Id&&b.IsDeleted==false) + .LeftJoin((a, b) => a.SubSystemId == b.Id && b.IsDeleted == false) .Where((a, b) => a.Id == id) .Select((a, b) => new GetTrackTemplateDetailVO @@ -84,8 +84,7 @@ public class TrackTemplateRepository : BasicRepository, ITr (templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) => templateContent.UpdateUserId == updateUser.Id && !updateUser.IsDeleted) .Filter(null, true) - .Where(templateContent => - templateContent.TrackTemplateId == input.TrackTemplateId && !templateContent.IsDeleted) + .Where(templateContent => input.TrackTemplateIds.Contains(templateContent.TrackTemplateId) && !templateContent.IsDeleted) .OrderByDescending(templateContent => templateContent.CreateTime) .Select((templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) => new GetTrackTemplateContentPageOutputVO