From 3d91f9c632c80e9a5c503122732be25b625ade80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com> Date: Fri, 1 Mar 2024 20:30:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=20=E8=BD=A8=E8=BF=B9?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=98=A0=E5=B0=84=E5=88=97=E8=A1=A8=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrackContents/TrackContentService.cs | 26 +++++++-- .../ITrackContentRepository.cs | 4 +- .../GetTrackContentMapPageInputVO.cs | 11 ++++ .../GetTrackContentMapPageOutputVO.cs | 56 +++++++++++++++++++ .../Repositories/TrackContentRepository.cs | 56 ++++++++++++++----- 5 files changed, 134 insertions(+), 19 deletions(-) create mode 100644 src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentMapPageInputVO.cs create mode 100644 src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentMapPageOutputVO.cs diff --git a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs index 281fed37..52c01e40 100644 --- a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs +++ b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Localization; +using SJZY.Expand.ABP.Core.Common.Dto; using SJZY.Track.Application.Contract.Dtos.TrackContents; using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackContentAggregate; @@ -93,7 +94,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 +105,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,7 +113,9 @@ 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); @@ -123,13 +127,27 @@ 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); + } } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/ITrackContentRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/ITrackContentRepository.cs index fbd0e412..fe1ab55c 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/ITrackContentRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/ITrackContentRepository.cs @@ -1,10 +1,12 @@ 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); } \ 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.Repository/Repositories/TrackContentRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs index e4f2e387..50f6a2d2 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs @@ -8,10 +8,8 @@ namespace SJZY.Track.Repository.Repositories; public class TrackContentRepository : BasicRepository, ITrackContentRepository, IScopedDependency { - public TrackContentRepository() { - } /// @@ -24,20 +22,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 +50,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 +69,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 +81,40 @@ 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); + } } \ No newline at end of file