|
@ -10,6 +10,7 @@ using System.Threading.Tasks.Dataflow; |
|
|
using AutoMapper; |
|
|
using AutoMapper; |
|
|
using AutoMapper.Configuration; |
|
|
using AutoMapper.Configuration; |
|
|
using FluentValidation; |
|
|
using FluentValidation; |
|
|
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
using Volo.Abp.Application.Services; |
|
|
using Volo.Abp.Application.Services; |
|
@ -24,6 +25,7 @@ using IConfiguration = Microsoft.Extensions.Configuration.IConfiguration; |
|
|
using Volo.Abp.TenantManagement; |
|
|
using Volo.Abp.TenantManagement; |
|
|
using Win_in.Sfs.Scp.WebApi.Asns; |
|
|
using Win_in.Sfs.Scp.WebApi.Asns; |
|
|
using Volo.Abp.Domain.Entities; |
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
|
|
using System.Security.Cryptography; |
|
|
|
|
|
|
|
|
namespace Win_in.Sfs.Scp.WebApi |
|
|
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 |
|
|
public class X12AsnAppService : ReadOnlyAppService<X12Asn, X12AsnDTO, Guid, RequestDTO>, IX12AsnAppService |
|
|
{ |
|
|
{ |
|
|
private readonly IX12AsnRepository _x12AsnRepository; |
|
|
private readonly IX12AsnRepository _x12AsnRepository; |
|
|
private readonly ITenantStore _tenantStore; |
|
|
|
|
|
private readonly ITenantRepository _tenantRepository; |
|
|
|
|
|
|
|
|
|
|
|
public X12AsnAppService( |
|
|
public X12AsnAppService( |
|
|
IX12AsnRepository repository |
|
|
IX12AsnRepository repository |
|
|
, ITenantStore tenantStore |
|
|
|
|
|
, ITenantRepository tenantRepository |
|
|
|
|
|
) : base(repository) |
|
|
) : base(repository) |
|
|
{ |
|
|
{ |
|
|
_x12AsnRepository = repository; |
|
|
_x12AsnRepository = repository; |
|
|
_tenantStore = tenantStore; |
|
|
|
|
|
_tenantRepository = tenantRepository; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
@ -71,34 +67,121 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
/// <param name="requestDTO">请求条件DTO(Request condition DTO)</param>
|
|
|
/// <param name="requestDTO">请求条件DTO(Request condition DTO)</param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("")] |
|
|
[Route("paged-list")] |
|
|
public override async Task<PagedResultDto<X12AsnDTO>> GetListAsync(RequestDTO requestDTO) |
|
|
public override async Task<PagedResultDto<X12AsnDTO>> GetListAsync(RequestDTO requestDTO) |
|
|
{ |
|
|
{ |
|
|
return await base.GetListAsync(requestDTO); |
|
|
return await base.GetListAsync(requestDTO); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("unread")] |
|
|
[Route("unread-list")] |
|
|
public async Task<ListResultDto<X12AsnDTO>> GetUnreadListAsync(string site, int count) |
|
|
public async Task<List<X12AsnDTO>> GetUnreadListAsync(string site, int count, bool autoUpdateStatus) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetUnreadListAsync(site,count); |
|
|
var entities = await _x12AsnRepository.GetUnreadListAsync(site, count, autoUpdateStatus); |
|
|
|
|
|
|
|
|
|
|
|
var dtos = BuildDtos(entities); |
|
|
|
|
|
|
|
|
var dtos = entities.Select(entity => new X12AsnDTO() |
|
|
return dtos; |
|
|
{ |
|
|
|
|
|
Id = entity.Id, |
|
|
|
|
|
UID = entity.UID, |
|
|
|
|
|
BillNum = entity.BillNum, |
|
|
|
|
|
Remark = entity.Remark, |
|
|
|
|
|
AsnX12 = JsonSerializer.Deserialize<ASN_X12_856_3060>(entity.DataContent) |
|
|
|
|
|
}) |
|
|
|
|
|
.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
return new ListResultDto<X12AsnDTO>(dtos); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[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) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new BadHttpRequestException("beginDate is after endDate"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|