|
|
@ -10,6 +10,7 @@ using System.Threading.Tasks.Dataflow; |
|
|
|
using AutoMapper; |
|
|
|
using AutoMapper.Configuration; |
|
|
|
using FluentValidation; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Volo.Abp.Application.Dtos; |
|
|
|
using Volo.Abp.Application.Services; |
|
|
@ -24,6 +25,7 @@ using IConfiguration = Microsoft.Extensions.Configuration.IConfiguration; |
|
|
|
using Volo.Abp.TenantManagement; |
|
|
|
using Win_in.Sfs.Scp.WebApi.Asns; |
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
using System.Security.Cryptography; |
|
|
|
|
|
|
|
namespace Win_in.Sfs.Scp.WebApi |
|
|
|
{ |
|
|
@ -37,18 +39,12 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
public class X12AsnAppService : ReadOnlyAppService<X12Asn, X12AsnDTO, Guid, RequestDTO>, IX12AsnAppService |
|
|
|
{ |
|
|
|
private readonly IX12AsnRepository _x12AsnRepository; |
|
|
|
private readonly ITenantStore _tenantStore; |
|
|
|
private readonly ITenantRepository _tenantRepository; |
|
|
|
|
|
|
|
public X12AsnAppService( |
|
|
|
IX12AsnRepository repository |
|
|
|
, ITenantStore tenantStore |
|
|
|
, ITenantRepository tenantRepository |
|
|
|
) : base(repository) |
|
|
|
{ |
|
|
|
_x12AsnRepository = repository; |
|
|
|
_tenantStore = tenantStore; |
|
|
|
_tenantRepository = tenantRepository; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -71,34 +67,121 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
/// <param name="requestDTO">请求条件DTO(Request condition DTO)</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet] |
|
|
|
[Route("")] |
|
|
|
[Route("paged-list")] |
|
|
|
public override async Task<PagedResultDto<X12AsnDTO>> GetListAsync(RequestDTO requestDTO) |
|
|
|
{ |
|
|
|
return await base.GetListAsync(requestDTO); |
|
|
|
} |
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
[Route("unread")] |
|
|
|
public async Task<ListResultDto<X12AsnDTO>> GetUnreadListAsync(string site, int count) |
|
|
|
[Route("unread-list")] |
|
|
|
public async Task<List<X12AsnDTO>> GetUnreadListAsync(string site, int count, bool autoUpdateStatus) |
|
|
|
{ |
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetUnreadListAsync(site, count, autoUpdateStatus); |
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetUnreadListAsync(site,count); |
|
|
|
var dtos = BuildDtos(entities); |
|
|
|
|
|
|
|
return dtos; |
|
|
|
|
|
|
|
var dtos = entities.Select(entity => new X12AsnDTO() |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
[Route("between-id")] |
|
|
|
public async Task<List<X12AsnDTO>> GetListAsync(long beginUid, long endUid) |
|
|
|
{ |
|
|
|
if (endUid < beginUid) |
|
|
|
{ |
|
|
|
throw new BadHttpRequestException("beginUid is bigger than endUid"); |
|
|
|
} |
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetListAsync(p => p.UID >= beginUid && p.UID <= endUid); |
|
|
|
|
|
|
|
var dtos = BuildDtos(entities); |
|
|
|
|
|
|
|
return dtos; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
[Route("between-date")] |
|
|
|
public async Task<List<X12AsnDTO>> GetListAsync(DateTime beginDate, DateTime endDate) |
|
|
|
{ |
|
|
|
if (endDate < beginDate) |
|
|
|
{ |
|
|
|
Id = entity.Id, |
|
|
|
UID = entity.UID, |
|
|
|
BillNum = entity.BillNum, |
|
|
|
Remark = entity.Remark, |
|
|
|
AsnX12 = JsonSerializer.Deserialize<ASN_X12_856_3060>(entity.DataContent) |
|
|
|
}) |
|
|
|
.ToList(); |
|
|
|
throw new BadHttpRequestException("beginDate is after endDate"); |
|
|
|
} |
|
|
|
|
|
|
|
return new ListResultDto<X12AsnDTO>(dtos); |
|
|
|
var entities = await _x12AsnRepository.GetListAsync(p => p.EffectiveDate >= beginDate && p.EffectiveDate <= endDate); |
|
|
|
|
|
|
|
var dtos = BuildDtos(entities); |
|
|
|
|
|
|
|
return dtos; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
[Route("by-id")] |
|
|
|
public async Task<X12AsnDTO> GetAsync(long uid) |
|
|
|
{ |
|
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.UID == uid); |
|
|
|
|
|
|
|
if (entity == null) |
|
|
|
{ |
|
|
|
throw new BadHttpRequestException($"ASN of {uid} is not found"); |
|
|
|
} |
|
|
|
|
|
|
|
var dto = BuildDto(entity); |
|
|
|
|
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
[Route("by-number")] |
|
|
|
public async Task<X12AsnDTO> GetAsync(string number) |
|
|
|
{ |
|
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.BillNum == number); |
|
|
|
|
|
|
|
if (entity == null) |
|
|
|
{ |
|
|
|
throw new BadHttpRequestException($"ASN of {number} is not found"); |
|
|
|
} |
|
|
|
|
|
|
|
var dto = BuildDto(entity); |
|
|
|
|
|
|
|
return dto; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
[Route("update-status")] |
|
|
|
public async Task<X12AsnDTO> UpdateStatusAsync(string number, EnumExchangeDataStatus status) |
|
|
|
{ |
|
|
|
|
|
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.BillNum == number); |
|
|
|
|
|
|
|
if (entity == null) |
|
|
|
{ |
|
|
|
throw new BadHttpRequestException($"ASN of {number} is not found"); |
|
|
|
} |
|
|
|
|
|
|
|
var result = await _x12AsnRepository.UpdateStatusAsync(entity.Id, status); |
|
|
|
|
|
|
|
var dto = BuildDto(result); |
|
|
|
|
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
private List<X12AsnDTO> BuildDtos(List<X12Asn> entities) |
|
|
|
{ |
|
|
|
var dtos = ObjectMapper.Map<List<X12Asn>, List<X12AsnDTO>>(entities); |
|
|
|
return dtos; |
|
|
|
} |
|
|
|
|
|
|
|
private X12AsnDTO BuildDto(X12Asn entity) |
|
|
|
{ |
|
|
|
var dto = ObjectMapper.Map<X12Asn, X12AsnDTO>(entity); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|