Merge pull request '完成 轨迹内容映射列表 接口' (#5) from S01-轨迹中台 into dev
Reviewed-on: http://192.168.80.50:3000/Dotnet/SJZY.Track.Api/pulls/5
This commit is contained in:
commit
9ae6a0c359
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
@ -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; }
|
||||
}
|
||||
@ -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; }
|
||||
}
|
||||
@ -8,10 +8,8 @@ namespace SJZY.Track.Repository.Repositories;
|
||||
|
||||
public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrackContentRepository, IScopedDependency
|
||||
{
|
||||
|
||||
public TrackContentRepository()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -24,20 +22,20 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
|
||||
var detail = await Context.Queryable<TrackContentEntity>()
|
||||
.LeftJoin<TrackStatusEntity>((a, b) => a.TrackStatusId == b.Id && b.IsDeleted == false)
|
||||
.LeftJoin<TrackFlagEntity>((a, b, c) => a.TrackFlagId == c.Id && c.IsDeleted == false)
|
||||
.LeftJoin<VSystemEntity>((a, b, c, d) => a.SubSystemId == d.Id&&d.IsDeleted==false)
|
||||
.LeftJoin<VSystemEntity>((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<TrackContentEntity>, ITrac
|
||||
{
|
||||
UnifyPageResultDto<GetTrackContentListVO> pagedList = new UnifyPageResultDto<GetTrackContentListVO>();
|
||||
pagedList = await Context.Queryable<TrackContentEntity>()
|
||||
.LeftJoin<TrackStatusEntity>((a, b) => a.TrackStatusId==b.Id&&b.IsDeleted==false)
|
||||
.LeftJoin<TrackFlagEntity>((a, b, c) => a.TrackFlagId==c.Id&&c.IsDeleted==false)
|
||||
.LeftJoin<TrackStatusEntity>((a, b) => a.TrackStatusId == b.Id && b.IsDeleted == false)
|
||||
.LeftJoin<TrackFlagEntity>((a, b, c) => a.TrackFlagId == c.Id && c.IsDeleted == false)
|
||||
.LeftJoin<VSystemEntity>((a, b, c, d) => a.SubSystemId == d.Id && d.IsDeleted == false)
|
||||
.LeftJoin<VUserEntity>((a, b, c, d, e) => a.CreateUserId == e.Id && e.IsDeleted == false)
|
||||
.LeftJoin<VUserEntity>((a, b, c, d, e, f) => a.UpdateUserId == f.Id && f.IsDeleted == false)
|
||||
@ -71,11 +69,11 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, 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<TrackContentEntity>, ITrac
|
||||
})
|
||||
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||
|
||||
var ff = await Context.Queryable<TrackContentEntity>().Where(a => 1==1).ToListAsync();
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user