|
|
@ -29,6 +29,7 @@ using System.Security.Cryptography; |
|
|
|
using IdentityModel; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Volo.Abp; |
|
|
|
using System.Drawing; |
|
|
|
|
|
|
|
namespace Win_in.Sfs.Scp.WebApi |
|
|
|
{ |
|
|
@ -122,15 +123,15 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取未读无POASN列表(Get unread Asn listwithout PO)
|
|
|
|
/// 获取未读无PO ASN列表(Get unread Asn list without PO)
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="site">地点(Site)</param>
|
|
|
|
/// <param name="count">数量(Count)</param>
|
|
|
|
/// <param name="autoUpdateStatus">是否自动更新状态(Auto update data status to finish)</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet] |
|
|
|
[Route("nopo-unread-list")] |
|
|
|
public async Task<ListResultDto<X12AsnDTO>> GetNoPoUnreadListAsync(string site, int count, bool autoUpdateStatus) |
|
|
|
[Route("nopo/unread-list")] |
|
|
|
public async Task<ListResultDto<AsnMstrDTO>> GetNoPoUnreadListAsync(string site, int count, bool autoUpdateStatus) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
@ -151,10 +152,85 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetNoPoUnreadListAsync(site, count, autoUpdateStatus); |
|
|
|
|
|
|
|
var dtos = BuildDtos(entities); |
|
|
|
// var dtos = BuildDtos(entities);
|
|
|
|
|
|
|
|
return new ListResultDto<X12AsnDTO>(dtos); |
|
|
|
var dtos = BuildAsnMstrDtos(entities); |
|
|
|
|
|
|
|
return new ListResultDto<AsnMstrDTO>(dtos); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取首个未读无PO ASN,并更新状态为已读(Get first unread Asn without PO and update status to read)
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="site">地点</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="AbpValidationException"></exception>
|
|
|
|
[HttpGet] |
|
|
|
[Route("nopo/unread-first")] |
|
|
|
public async Task<ActionResult<AsnMstrDTO>> GetNoPoUnreadFirstAsync(string site) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
Validator.CheckSite(_tenantRepository, site); |
|
|
|
|
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
throw new AbpValidationException(new List<ValidationResult> |
|
|
|
{ |
|
|
|
new(ex.Message) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetNoPoUnreadListAsync(site, 1, true); |
|
|
|
|
|
|
|
if (entities == null || entities.Count == 0) |
|
|
|
{ |
|
|
|
return new OkResult(); |
|
|
|
} |
|
|
|
// var dtos = BuildDtos(entities);
|
|
|
|
|
|
|
|
var dto = BuildAsnMstrDto(entities[0]); |
|
|
|
|
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 根据UID获取无PO ASN(Get Asn without PO by UID)
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="site">地点(Site)</param>
|
|
|
|
/// <param name="uid">UID(UID)</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
|
[HttpGet] |
|
|
|
[Route("nopo/by-uid")] |
|
|
|
public async Task<ActionResult<AsnMstrDTO>> GetNoPoAsync(string site,long uid) |
|
|
|
{ |
|
|
|
X12Asn entity; |
|
|
|
try |
|
|
|
{ |
|
|
|
Validator.CheckSite(_tenantRepository, site); |
|
|
|
|
|
|
|
entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.DataType==ScpWebApiConsts.NO_PO_ASN && p.UID == uid); |
|
|
|
|
|
|
|
if (entity == null) |
|
|
|
{ |
|
|
|
|
|
|
|
throw new UserFriendlyException($"No Po ASN of {uid} in {site} is not found"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
throw new AbpValidationException(new List<ValidationResult> |
|
|
|
{ |
|
|
|
new(ex.Message) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var dto = BuildAsnMstrDto(entity); |
|
|
|
|
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -352,6 +428,24 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
return dtos; |
|
|
|
} |
|
|
|
|
|
|
|
private List<AsnMstrDTO> BuildAsnMstrDtos(List<X12Asn> entities) |
|
|
|
{ |
|
|
|
var dtos = new List<AsnMstrDTO>(); |
|
|
|
foreach (var entity in entities) |
|
|
|
{ |
|
|
|
var dto = BuildAsnMstrDto(entity); |
|
|
|
dtos.Add(dto); |
|
|
|
} |
|
|
|
return dtos; |
|
|
|
} |
|
|
|
|
|
|
|
private AsnMstrDTO BuildAsnMstrDto(X12Asn entity) |
|
|
|
{ |
|
|
|
var dto = JsonSerializer.Deserialize<AsnMstrDTO>(entity.JsonString); |
|
|
|
dto.TraceId = $"{dto.Site}-{dto.UID}-{DateTime.Now.Ticks}"; |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
private X12AsnDTO BuildDto(X12Asn entity) |
|
|
|
{ |
|
|
|
var dto = ObjectMapper.Map<X12Asn, X12AsnDTO>(entity); |
|
|
|