|
|
@ -28,6 +28,7 @@ using Volo.Abp.Domain.Entities; |
|
|
|
using System.Security.Cryptography; |
|
|
|
using IdentityModel; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Volo.Abp; |
|
|
|
|
|
|
|
namespace Win_in.Sfs.Scp.WebApi |
|
|
|
{ |
|
|
@ -94,12 +95,22 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
[HttpGet] |
|
|
|
[Route("unread-list")] |
|
|
|
public async Task<ListResultDto<X12AsnDTO>> GetUnreadListAsync(string site, int count, bool autoUpdateStatus) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
Validator.CheckSite(_tenantRepository, site); |
|
|
|
|
|
|
|
if (count < 1 || count > _options.Value.MaxCount) |
|
|
|
{ |
|
|
|
throw new AbpValidationException($"Count must bigger than 1 and smaller than {_options.Value.MaxCount}"); |
|
|
|
throw new UserFriendlyException($"Count must between 1 and {_options.Value.MaxCount}"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
throw new AbpValidationException(new List<ValidationResult> |
|
|
|
{ |
|
|
|
new(ex.Message) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetUnreadListAsync(site, count, autoUpdateStatus); |
|
|
@ -121,12 +132,22 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
[HttpGet] |
|
|
|
[Route("between-uid")] |
|
|
|
public async Task<ListResultDto<X12AsnDTO>> GetListAsync(string site, long beginUid, long endUid) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
Validator.CheckSite(_tenantRepository, site); |
|
|
|
|
|
|
|
if (endUid < beginUid) |
|
|
|
{ |
|
|
|
throw new AbpValidationException("beginUid can not bigger than endUid"); |
|
|
|
throw new UserFriendlyException("beginUid can not bigger than endUid"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
throw new AbpValidationException(new List<ValidationResult> |
|
|
|
{ |
|
|
|
new(ex.Message) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetListAsync(p => p.Site == site && p.UID >= beginUid && p.UID <= endUid); |
|
|
@ -147,14 +168,23 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
[HttpGet] |
|
|
|
[Route("between-date")] |
|
|
|
public async Task<ListResultDto<X12AsnDTO>> GetListAsync(string site, DateTime beginDate, DateTime endDate) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
Validator.CheckSite(_tenantRepository, site); |
|
|
|
|
|
|
|
if (endDate < beginDate) |
|
|
|
{ |
|
|
|
throw new AbpValidationException("beginDate can not after endDate"); |
|
|
|
throw new UserFriendlyException("beginDate can not after endDate"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
throw new AbpValidationException(new List<ValidationResult> |
|
|
|
{ |
|
|
|
new(ex.Message) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetListAsync(p => p.Site == site && p.EffectiveDate >= beginDate && p.EffectiveDate <= endDate); |
|
|
|
|
|
|
|
var dtos = BuildDtos(entities); |
|
|
@ -172,17 +202,27 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
[HttpGet] |
|
|
|
[Route("by-uid")] |
|
|
|
public async Task<ActionResult<X12AsnDTO>> GetAsync(string site, long uid) |
|
|
|
{ |
|
|
|
X12Asn entity; |
|
|
|
try |
|
|
|
{ |
|
|
|
Validator.CheckSite(_tenantRepository, site); |
|
|
|
|
|
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.UID == uid); |
|
|
|
entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.UID == uid); |
|
|
|
|
|
|
|
if (entity == null) |
|
|
|
{ |
|
|
|
|
|
|
|
throw new AbpValidationException($"ASN of {uid} in {site} is not found"); |
|
|
|
throw new UserFriendlyException($"ASN of {uid} in {site} is not found"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
throw new AbpValidationException(new List<ValidationResult> |
|
|
|
{ |
|
|
|
new(ex.Message) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var dto = BuildDto(entity); |
|
|
|
|
|
|
|
return dto; |
|
|
@ -198,16 +238,27 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
[HttpGet] |
|
|
|
[Route("by-number")] |
|
|
|
public async Task<ActionResult<X12AsnDTO>> GetAsync(string site, string number) |
|
|
|
{ |
|
|
|
X12Asn entity; |
|
|
|
try |
|
|
|
{ |
|
|
|
Validator.CheckSite(_tenantRepository, site); |
|
|
|
|
|
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.BillNum == number); |
|
|
|
|
|
|
|
entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.BillNum == number); |
|
|
|
|
|
|
|
if (entity == null) |
|
|
|
{ |
|
|
|
throw new AbpValidationException($"ASN of {number} in {site} is not found"); |
|
|
|
throw new UserFriendlyException($"ASN of {number} in {site} is not found"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
throw new AbpValidationException(new List<ValidationResult> |
|
|
|
{ |
|
|
|
new(ex.Message) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var dto = BuildDto(entity); |
|
|
|
|
|
|
|
return dto; |
|
|
@ -231,16 +282,27 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
[HttpPost] |
|
|
|
[Route("update-status")] |
|
|
|
public async Task<ActionResult<X12AsnDTO>> UpdateStatusAsync(string site, string number, EnumExchangeDataStatus status) |
|
|
|
{ |
|
|
|
X12Asn entity; |
|
|
|
try |
|
|
|
{ |
|
|
|
Validator.CheckSite(_tenantRepository, site); |
|
|
|
|
|
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.BillNum == number); |
|
|
|
|
|
|
|
entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.BillNum == number); |
|
|
|
|
|
|
|
if (entity == null) |
|
|
|
{ |
|
|
|
throw new AbpValidationException($"ASN of {number} in {site} is not found"); |
|
|
|
throw new UserFriendlyException($"ASN of {number} in {site} is not found"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
throw new AbpValidationException(new List<ValidationResult> |
|
|
|
{ |
|
|
|
new(ex.Message) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var result = await _x12AsnRepository.UpdateStatusAsync(entity.Id, status); |
|
|
|
|
|
|
|
var dto = BuildDto(result); |
|
|
|