Browse Source

[fix]通过接口获取AsnX12调试通过

master
贾荣国 3 years ago
parent
commit
3af6d96533
  1. 11
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Asns/IX12AsnAppService.cs
  2. 31
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Asns/X12AsnDTO.cs
  3. 121
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Asns/X12AsnAppService.cs
  4. 29
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/WebApiApplicationAutoMapperProfile.cs
  5. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/DTM.cs
  6. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/HL.cs
  7. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/REF.cs
  8. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GE.cs
  9. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GS.cs
  10. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/IEA.cs
  11. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ISA.cs
  12. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/CLD.cs
  13. 6
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/LIN.cs
  14. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/PRF.cs
  15. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/SN1.cs
  16. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/BSN.cs
  17. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/CTT.cs
  18. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/SE.cs
  19. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/ST.cs
  20. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/MEA.cs
  21. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/N1.cs
  22. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD1.cs
  23. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD3.cs
  24. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD5.cs
  25. 14
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EnumExchangeDataStatus.cs
  26. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/IX12AsnRepository.cs
  27. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/X12Asn.cs
  28. 14
      WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Repositories/X12AsnRepository.cs
  29. 6
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBackgroundWorker.cs
  30. 4
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/IScpAsnManager.cs
  31. 2
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ITbAsnRepository.cs
  32. 2
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ITsBarcodeRepository.cs
  33. 12
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ScpAsnManager.cs
  34. 4
      WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TbAsnRepository.cs
  35. 4
      WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TsBarcodeRepository.cs

11
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Asns/IX12AsnAppService.cs

@ -14,8 +14,17 @@ namespace Win_in.Sfs.Scp.WebApi
/// </summary>
public interface IX12AsnAppService : IReadOnlyAppService<X12AsnDTO,Guid,RequestDTO>
{
Task<ListResultDto<X12AsnDTO>> GetUnreadListAsync(string site, int count);
Task<List<X12AsnDTO>> GetUnreadListAsync(string site, int count,bool autoUpdateStatus);
Task<List<X12AsnDTO>> GetListAsync(long beginUid,long endUid);
Task<List<X12AsnDTO>> GetListAsync(DateTime beginDate, DateTime endDate);
Task<X12AsnDTO> GetAsync(long uid);
Task<X12AsnDTO> GetAsync(string number);
Task<X12AsnDTO> UpdateStatusAsync(string number, EnumExchangeDataStatus status);
}

31
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Asns/X12AsnDTO.cs

@ -1,11 +1,27 @@
using System;
using System.Collections.Generic;
using Volo.Abp.Application.Dtos;
using Win_in.Sfs.Scp.WebApi.Asns;
using Win_in.Sfs.Scp.WebApi.Domain.Shared;
namespace Win_in.Sfs.Scp.WebApi;
public class X12AsnDTO: EntityDtoBase<Guid>
public class X12AsnDTO: IEntityDto<Guid>
{
/// <summary>
/// ID
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// 地点
/// </summary>
public string Site { get; set; }
/// <summary>
/// 唯一ID
/// </summary>
public long UID { get; set; }
/// <summary>
@ -13,6 +29,17 @@ public class X12AsnDTO: EntityDtoBase<Guid>
/// </summary>
public string BillNum { get; set; }
/// <summary>
/// 生效日期
/// </summary>
public DateTime EffectiveDate { get; set; }
/// <summary>
/// 状态
/// </summary>
public EnumExchangeDataStatus Status { get; set; }
/// <summary>
/// 备注
/// </summary>
@ -21,6 +48,6 @@ public class X12AsnDTO: EntityDtoBase<Guid>
/// <summary>
/// 数据内容
/// </summary>
public ASN_X12_856_3060 AsnX12 { get; set; }
public List<string> Scpedi { get; set; }
}

121
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Asns/X12AsnAppService.cs

@ -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;
}
}
}

29
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/WebApiApplicationAutoMapperProfile.cs

@ -1,5 +1,9 @@
using AutoMapper;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using AutoMapper;
using Volo.Abp.AutoMapper;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Timing;
using Win_in.Sfs.Scp.WebApi.Asns;
@ -30,9 +34,9 @@ namespace Win_in.Sfs.Scp.WebApi
{
CreateMap<Part, PartDTO>();
CreateMap<PartCreateDto, Part>()
.Ignore(p=>p.Id)
.Ignore(p=>p.CreatorId)
.Ignore(p=>p.CreationTime);
.Ignore(p => p.Id)
.Ignore(p => p.CreatorId)
.Ignore(p => p.CreationTime);
}
/// <summary>
@ -42,7 +46,7 @@ namespace Win_in.Sfs.Scp.WebApi
{
CreateMap<Supplier, SupplierDTO>();
CreateMap<SupplierCreateDTO,Supplier>()
CreateMap<SupplierCreateDTO, Supplier>()
.Ignore(p => p.Id)
.Ignore(p => p.CreatorId)
.Ignore(p => p.CreationTime);
@ -83,7 +87,7 @@ namespace Win_in.Sfs.Scp.WebApi
{
CreateMap<PurchaseOrderDetail, PurchaseOrderDetailDTO>();
CreateMap<PurchaseOrderDetailCreateDTO,PurchaseOrderDetail>()
CreateMap<PurchaseOrderDetailCreateDTO, PurchaseOrderDetail>()
.Ignore(p => p.Id)
.Ignore(p => p.CreatorId)
.Ignore(p => p.CreationTime);
@ -100,8 +104,17 @@ namespace Win_in.Sfs.Scp.WebApi
private void CreateMapX12Asn()
{
CreateMap<X12Asn,X12AsnDTO>()
.Ignore(p=>p.AsnX12);
CreateMap<X12Asn, X12AsnDTO>()
.Ignore(p => p.Scpedi)
.AfterMap(ConvertToScpEdi)
;
}
private void ConvertToScpEdi(X12Asn src, X12AsnDTO dest)
{
var asnX12 = JsonSerializer.Deserialize<ASN_X12_856_3060>(src.DataContent)?.ToString();
var list = asnX12?.Split("\r\n").ToList();
dest.Scpedi = list;
}
}
}

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/DTM.cs

@ -41,6 +41,11 @@ public class DTM
public string DTM06 { get; }
public string DTM07 { get; }
public DTM()
{
}
public DTM(DateTime datetime, string datetimeType = "011")
{
DTM01 = datetimeType;

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/HL.cs

@ -35,6 +35,11 @@ public class HL
public string HL03 { get;}
public string HL04 { get;}
public HL()
{
}
public HL(LevelType hl03,string code="",string parentCode="")
{
HL01 = code;

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/REF.cs

@ -27,6 +27,11 @@ public class REF
public string REF03 { get;}
public string REF04 { get;}
public REF()
{
}
public REF(RefType type)
{
REF01 = type.ToString();

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GE.cs

@ -18,6 +18,11 @@ public class GE
/// </summary>
public string GE02 { get; set; }
public GE()
{
}
public GE(string code, int count = 1)
{
GE01 = count.ToString();

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GS.cs

@ -73,6 +73,11 @@ public class GS
[StringLength(1, MinimumLength = 12)]
public string GS08 { get; } = "003060";
public GS()
{
}
public GS(string senderId, string receiverId, DateTime datetime, string functionalGroupCode)
{
GS02 = senderId;

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/IEA.cs

@ -23,6 +23,11 @@ public class IEA
[StringLength(9, MinimumLength = 9)]
public string IEA02 { get; set; }
public IEA()
{
}
public IEA(string asnCode, int count = 1)
{
IEA01 = count.ToString();

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ISA.cs

@ -137,6 +137,11 @@ public class ISA
[StringLength(1, MinimumLength = 1)]
public string ISA16 { get; set; } = "|";
public ISA()
{
}
public ISA(string asnCode,string senderId, string receiverId, DateTime datetime, EnvType envType = EnvType.P,
string authorization = "", string security = "")
{

4
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/CLD.cs

@ -33,6 +33,10 @@ public class CLD
public string CLD04 { get;}
public string CLD05 { get;}
public CLD()
{
}
public CLD(int loadQty,decimal unitQty)
{

6
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/LIN.cs

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Threading;
namespace Win_in.Sfs.Scp.WebApi.Asns;
@ -24,6 +25,11 @@ public class LIN
[StringLength(30, MinimumLength = 1)]
public string LIN03 { get; set; }
public LIN()
{
}
public LIN(string itemCode)
{
LIN03 = itemCode;

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/PRF.cs

@ -23,6 +23,11 @@ public class PRF
public string PRF06 { get;}
public string PRF07 { get;}
public PRF()
{
}
public PRF(string poNumber)
{
PRF01 = poNumber;

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/SN1.cs

@ -45,6 +45,11 @@ public class SN1
public decimal Qty { get; set; }
public SN1()
{
}
public SN1(decimal qty, string uom, int accumQty)
{
Qty = qty;

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/BSN.cs

@ -45,6 +45,11 @@ public class BSN
public string BSN06 { get; }
public string BSN07 { get; }
public BSN()
{
}
public BSN(string noticeNumber, DateTime datetime, string purpose = "00")
{
BSN01 = purpose;

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/CTT.cs

@ -31,6 +31,11 @@ public class CTT
private int _hlCount = 0;
private decimal _hashTotal = 0;
public CTT()
{
}
public CTT(int hlCount,decimal hashTotal)
{
_hlCount = hlCount;

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/SE.cs

@ -22,6 +22,11 @@ public class SE
[StringLength(9,MinimumLength = 4)]
public string SE02 { get; set; }
public SE()
{
}
public SE(string transactionCode ,int segmentCount = 1)
{
SE01 = segmentCount.ToString();

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/ST.cs

@ -22,6 +22,11 @@ public class ST
[StringLength(9, MinimumLength = 4)]
public string ST02 { get; set; }
public ST()
{
}
public ST(string transactionCode)
{
ST02 = transactionCode;

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/MEA.cs

@ -49,6 +49,11 @@ public class MEA
public string MEA09 { get;}
public string MEA10 { get;}
public MEA()
{
}
public MEA(MeaType meaType,decimal meaValue =0,string uom="KG")
{
MEA02 = meaType.ToString();

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/N1.cs

@ -40,6 +40,11 @@ public class N1
public string N105 { get;}
public string N106 { get;}
public N1()
{
}
public N1(NameType type,string code)
{
N101 = type.ToString();

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD1.cs

@ -32,6 +32,11 @@ public class TD1
public string TD109 { get;}
public string TD110 { get;}
public TD1()
{
}
public TD1(string packagingCode,int loadingQty)
{
TD101 = packagingCode;

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD3.cs

@ -31,6 +31,11 @@ public class TD3
public string TD308 { get;}
public string TD309 { get;}
public TD3()
{
}
public TD3(string equipmentCode,string equipmentNumber)
{
TD301 = equipmentCode;

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD5.cs

@ -48,6 +48,11 @@ public class TD5
public string TD513 { get;}
public string TD514 { get;}
public TD5()
{
}
public TD5(string routeSequenceCode,string identificationCode,string mode)
{
TD501 = routeSequenceCode;

14
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EnumExchangeDataStatus.cs

@ -3,23 +3,23 @@
public enum EnumExchangeDataStatus
{
/// <summary>
/// 新增
/// 新增(new)
/// </summary>
Ready = 0,
New = 0,
/// <summary>
/// 处理中
/// 处理中(Processing)
/// </summary>
Processing = 1,
/// <summary>
/// 完成
/// 完成(Finish)
/// </summary>
Success = 2,
Finish = 2,
/// <summary>
/// 搁置
/// 搁置(Hold)
/// </summary>
Hold = 9,
/// <summary>
/// 错误
/// 错误(Error)
/// </summary>
Error = -1,
}

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/IX12AsnRepository.cs

@ -7,7 +7,7 @@ namespace Win_in.Sfs.Scp.WebApi.Asns;
public interface IX12AsnRepository : IRepository<X12Asn, Guid>
{
Task<List<X12Asn>> GetUnreadListAsync(string site, int count);
Task<List<X12Asn>> GetUnreadListAsync(string site, int count, bool autoUpdateStatus);
Task<X12Asn> UpdateStatusAsync(Guid id, EnumExchangeDataStatus status);
}

4
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/X12Asn.cs

@ -120,7 +120,7 @@ public class X12Asn: EntityBase<Guid>
public virtual void Reset(string remark = null)
{
Status = EnumExchangeDataStatus.Ready;
Status = EnumExchangeDataStatus.New;
ErrorCode = (int)EnumExchangeDataErrorCode.None;
ErrorMessage = "";
Remark = remark;
@ -136,7 +136,7 @@ public class X12Asn: EntityBase<Guid>
public void SetSuccess(string remark = null)
{
Status = EnumExchangeDataStatus.Success;
Status = EnumExchangeDataStatus.Finish;
ErrorCode = (int)EnumExchangeDataErrorCode.None;
ErrorMessage = "";
Remark = remark;

14
WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Repositories/X12AsnRepository.cs

@ -15,18 +15,22 @@ public class X12AsnRepository : EfCoreRepository<WebApiDbContext, X12Asn, Guid>,
{
}
public async Task<List<X12Asn>> GetUnreadListAsync(string site, int count)
public async Task<List<X12Asn>> GetUnreadListAsync(string site, int count, bool autoUpdateStatus)
{
var dbSet = await GetDbSetAsync();
var list =await dbSet
.Where(p =>p.Site ==site && p.Status == EnumExchangeDataStatus.Ready)
.Where(p =>p.Site ==site && p.Status == EnumExchangeDataStatus.New)
.OrderBy(p => p.UID)
.Take(count)
.ToListAsync();
if (autoUpdateStatus)
{
foreach (var entity in list)
{
await UpdateStatusAsync(entity.Id, EnumExchangeDataStatus.Success);
entity.SetSuccess();
await UpdateAsync(entity);
}
}
return list;
@ -38,13 +42,13 @@ public class X12AsnRepository : EfCoreRepository<WebApiDbContext, X12Asn, Guid>,
var entity =await base.GetAsync(id);
switch (status)
{
case EnumExchangeDataStatus.Ready:
case EnumExchangeDataStatus.New:
entity.Reset();
break;
case EnumExchangeDataStatus.Processing:
entity.SetProcessing();
break;
case EnumExchangeDataStatus.Success:
case EnumExchangeDataStatus.Finish:
entity.SetSuccess();
break;
case EnumExchangeDataStatus.Hold:

6
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBackgroundWorker.cs

@ -69,9 +69,9 @@ public class AsnBackgroundWorker : AsyncPeriodicBackgroundWorkerBase
{
using (dataFilter.Disable<IMultiTenant>())
{
var scpAsns = await scpAsnManager.GetUnreadAsnsAsync(maxUid, _options.Value.BatchSize);
var scpAsns = await scpAsnManager.GetUnreadAsnsAsync(site,maxUid, _options.Value.BatchSize);
Logger.LogInformation($"{scpAsns.Count} Scp ASN records were Found");
Logger.LogInformation($"{site}: {scpAsns.Count} Scp ASN records were Found");
if (scpAsns.Count <= 0)
{
@ -80,7 +80,7 @@ public class AsnBackgroundWorker : AsyncPeriodicBackgroundWorkerBase
foreach (var asn in scpAsns)
{
var barcodes = await scpAsnManager.GetBarcodesAsync(asn.AsnBillNum);
var barcodes = await scpAsnManager.GetBarcodesAsync(site,asn.AsnBillNum);
var asnFactory = new AsnFactory();
var asnX128563060 = asnFactory.CreateAsnX128563060(asn, barcodes);

4
WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/IScpAsnManager.cs

@ -7,7 +7,7 @@ namespace Win_in.Sfs.Scp.v1.Domain
{
public interface IScpAsnManager:IDomainService
{
Task<List<TB_ASN>> GetUnreadAsnsAsync(long uid, int batchSize);
Task<List<TS_BARCODE>> GetBarcodesAsync(string billNum);
Task<List<TB_ASN>> GetUnreadAsnsAsync(string site, long uid, int batchSize);
Task<List<TS_BARCODE>> GetBarcodesAsync(string site, string billNum);
}
}

2
WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ITbAsnRepository.cs

@ -8,6 +8,6 @@ namespace Win_in.Sfs.Scp.v1.Domain
{
public interface ITbAsnRepository : IRepository<TB_ASN>,ITransientDependency
{
Task<List<TB_ASN>> GetUnreadListAsync(long uid,int batchSize);
Task<List<TB_ASN>> GetUnreadListAsync(string site, long uid, int batchSize);
}
}

2
WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ITsBarcodeRepository.cs

@ -8,6 +8,6 @@ namespace Win_in.Sfs.Scp.v1.Domain
{
public interface ITsBarcodeRepository : IRepository<TS_BARCODE>, ITransientDependency
{
Task<List<TS_BARCODE>> GetListByBillNumAsync(string billNum);
Task<List<TS_BARCODE>> GetListByBillNumAsync(string site, string billNum);
}
}

12
WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ScpAsnManager.cs

@ -5,25 +5,25 @@ using Win_in.Sfs.Scp.v1.Domain.Asns;
namespace Win_in.Sfs.Scp.v1.Domain
{
public class ScpAsnManager : DomainService,IScpAsnManager
public class ScpAsnManager : DomainService, IScpAsnManager
{
private readonly ITbAsnRepository _tbAsnRepository;
private readonly ITsBarcodeRepository _tsBarcodeRepository;
public ScpAsnManager(ITbAsnRepository tbAsnRepository
,ITsBarcodeRepository tsBarcodeRepository)
, ITsBarcodeRepository tsBarcodeRepository)
{
_tbAsnRepository = tbAsnRepository;
_tsBarcodeRepository = tsBarcodeRepository;
}
public async Task<List<TB_ASN>> GetUnreadAsnsAsync(long uid, int batchSize)
public async Task<List<TB_ASN>> GetUnreadAsnsAsync(string site, long uid, int batchSize)
{
return await _tbAsnRepository.GetUnreadListAsync(uid, batchSize);
return await _tbAsnRepository.GetUnreadListAsync(site, uid, batchSize);
}
public async Task<List<TS_BARCODE>> GetBarcodesAsync(string billNum)
public async Task<List<TS_BARCODE>> GetBarcodesAsync(string site, string billNum)
{
return await _tsBarcodeRepository.GetListByBillNumAsync(billNum);
return await _tsBarcodeRepository.GetListByBillNumAsync(site, billNum);
}
}
}

4
WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TbAsnRepository.cs

@ -15,11 +15,11 @@ namespace Win_in.Sfs.Scp.v1.EntityFrameworkCore
{
}
public async Task<List<TB_ASN>> GetUnreadListAsync(long uid, int batchSize)
public async Task<List<TB_ASN>> GetUnreadListAsync(string site, long uid, int batchSize)
{
var dbSet = await GetDbSetAsync();
var list = await dbSet
.Where(p => p.Id > uid)
.Where(p =>p.Site==site && p.Id > uid)
.OrderBy(p => p.Id)
.Take(batchSize)
.ToListAsync();

4
WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TsBarcodeRepository.cs

@ -15,11 +15,11 @@ namespace Win_in.Sfs.Scp.v1.EntityFrameworkCore
{
}
public async Task<List<TS_BARCODE>> GetListByBillNumAsync(string billNum)
public async Task<List<TS_BARCODE>> GetListByBillNumAsync(string site, string billNum)
{
var dbSet = await GetDbSetAsync();
var list = await dbSet
.Where(p => p.BillNum == billNum)
.Where(p =>p.Site==site && p.BillNum == billNum)
.ToListAsync();
return list;
}

Loading…
Cancel
Save