完成 轨迹内容映射列表 接口

This commit is contained in:
柳文翔 2024-03-01 20:30:17 +08:00
parent 81a8e077fc
commit 3d91f9c632
5 changed files with 134 additions and 19 deletions

View File

@ -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<EditTrackContentInput, TrackContentEntity>(input);
var isTrue = await _trackContentRepository.InsertAsync(entity);
@ -104,6 +105,7 @@ namespace SJZY.Track.Application.Services.TrackContents
private async Task<UnifyResultDto> 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<UnifyResultDto> DeleteAsync(EditTrackContentInput input)
{
#region 业务校验
//需要加个判断,存在内容映射,则出提示
#endregion
#endregion 业务校验
var isTrue = await _trackContentRepository.SoftDeleteAsync(x => x.Id == input.Id);
return new UnifyResultDto("200", "删除成功", isTrue);
}
#endregion
#endregion 私有方法
/// <summary>
/// 轨迹内容映射列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("GetMapPage")]
public async Task<UnifyPageResultDto<GetTrackContentMapPageOutputVO>> GetMapPageAsync([FromBody] GetTrackContentMapPageInputVO input)
{
return await _trackContentRepository.GetMapPageAsync(input);
}
}
}

View File

@ -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<TrackContentEntity>
{
Task<GetTrackContentDetailVO?> GetDetailAsync(int id);
Task<UnifyPageResultDto<GetTrackContentListVO>> GetPageTrackContent(GetPageTrackContentVO input);
Task<UnifyPageResultDto<GetTrackContentMapPageOutputVO>> GetMapPageAsync(GetTrackContentMapPageInputVO input);
}

View File

@ -0,0 +1,11 @@
using SJZY.Track.Domain.Dtos.Common;
namespace SJZY.Track.Domain.Dtos.TrackContents;
public class GetTrackContentMapPageInputVO : KeywordsInputVO
{
/// <summary>
/// 映射子系统id
/// </summary>
public int? MapSubSystemId { get; set; }
}

View File

@ -0,0 +1,56 @@
namespace SJZY.Track.Domain.Dtos.TrackContents;
public class GetTrackContentMapPageOutputVO
{
/// <summary>
/// 轨迹内容代码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 轨迹内容
/// </summary>
public string Content { get; set; }
/// <summary>
/// 轨迹内容英文
/// </summary>
public string EnContent { get; set; }
public int Id { get; set; }
/// <summary>
/// 映射轨迹内容代码
/// </summary>
public string MapCode { get; set; }
/// <summary>
/// 映射内容
/// </summary>
public string MapContent { get; set; }
/// <summary>
/// 映射内容英文
/// </summary>
public string MapEnContent { get; set; }
/// <summary>
/// 映射子系统
/// </summary>
public string MapSubSystem { get; set; }
/// <summary>
/// 映射轨迹状态
/// </summary>
public string MapTrackStatus { get; set; }
/// <summary>
/// 子系统
/// </summary>
public string SubSystem { get; set; }
/// <summary>
/// 轨迹状态
/// </summary>
public string TrackStatus { get; set; }
}

View File

@ -8,10 +8,8 @@ namespace SJZY.Track.Repository.Repositories;
public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrackContentRepository, IScopedDependency
{
public TrackContentRepository()
{
}
/// <summary>
@ -85,8 +83,38 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
var ff = await Context.Queryable<TrackContentEntity>().Where(a => 1 == 1).ToListAsync();
return pagedList;
}
public async Task<UnifyPageResultDto<GetTrackContentMapPageOutputVO>> GetMapPageAsync(GetTrackContentMapPageInputVO input)
{
return await Context.Queryable<TrackContentMapEntity>()
.InnerJoin<TrackContentEntity>((contentMap, sourceContent) => contentMap.TrackContentId == sourceContent.Id && !sourceContent.IsDeleted)
.InnerJoin<TrackContentEntity>((contentMap, sourceContent, targetContent) => contentMap.MapTrackContentId == targetContent.Id && !targetContent.IsDeleted)
.LeftJoin<VSystemEntity>((contentMap, sourceContent, targetContent, sourceSystem) => contentMap.SubSystemId == sourceSystem.Id && !sourceSystem.IsDeleted)
.LeftJoin<VSystemEntity>((contentMap, sourceContent, targetContent, sourceSystem, targetSystem) => contentMap.MapSubSystemId == targetSystem.Id && !targetSystem.IsDeleted)
.LeftJoin<TrackStatusEntity>((contentMap, sourceContent, targetContent, sourceSystem, targetSystem, sourceStatus) => sourceContent.TrackStatusId == sourceStatus.Id && !sourceStatus.IsDeleted)
.LeftJoin<TrackStatusEntity>((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);
}
}