From 3af6d96533c6f5631703f264005d11361dac510e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=BE=E8=8D=A3=E5=9B=BD?= Date: Fri, 20 May 2022 14:17:20 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=E9=80=9A=E8=BF=87=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=8E=B7=E5=8F=96AsnX12=E8=B0=83=E8=AF=95=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Asns/IX12AsnAppService.cs | 11 +- .../Asns/X12AsnDTO.cs | 31 ++++- .../Asns/X12AsnAppService.cs | 127 +++++++++++++++--- .../WebApiApplicationAutoMapperProfile.cs | 29 ++-- .../ASN_X12/Commons/DTM.cs | 5 + .../ASN_X12/Commons/HL.cs | 5 + .../ASN_X12/Commons/REF.cs | 5 + .../ASN_X12/FunctionGroups/GE.cs | 5 + .../ASN_X12/FunctionGroups/GS.cs | 5 + .../ASN_X12/IEA.cs | 5 + .../ASN_X12/ISA.cs | 5 + .../ASN_X12/Items/CLD.cs | 4 + .../ASN_X12/Items/LIN.cs | 6 + .../ASN_X12/Items/PRF.cs | 5 + .../ASN_X12/Items/SN1.cs | 5 + .../ASN_X12/ShipNotices/BSN.cs | 5 + .../ASN_X12/ShipNotices/CTT.cs | 5 + .../ASN_X12/ShipNotices/SE.cs | 5 + .../ASN_X12/ShipNotices/ST.cs | 5 + .../ASN_X12/Shipments/MEA.cs | 5 + .../ASN_X12/Shipments/N1.cs | 5 + .../ASN_X12/Shipments/TD1.cs | 5 + .../ASN_X12/Shipments/TD3.cs | 5 + .../ASN_X12/Shipments/TD5.cs | 5 + .../EnumExchangeDataStatus.cs | 14 +- .../Asns/IX12AsnRepository.cs | 2 +- .../Asns/X12Asn.cs | 4 +- .../Repositories/X12AsnRepository.cs | 16 ++- .../AsnBackgroundWorker.cs | 6 +- .../Asns/IScpAsnManager.cs | 4 +- .../Asns/ITbAsnRepository.cs | 2 +- .../Asns/ITsBarcodeRepository.cs | 2 +- .../Asns/ScpAsnManager.cs | 12 +- .../Repositories/TbAsnRepository.cs | 4 +- .../Repositories/TsBarcodeRepository.cs | 4 +- 35 files changed, 302 insertions(+), 66 deletions(-) diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Asns/IX12AsnAppService.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Asns/IX12AsnAppService.cs index 09aab89..93be5c7 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Asns/IX12AsnAppService.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Asns/IX12AsnAppService.cs @@ -14,8 +14,17 @@ namespace Win_in.Sfs.Scp.WebApi /// public interface IX12AsnAppService : IReadOnlyAppService { - Task> GetUnreadListAsync(string site, int count); + Task> GetUnreadListAsync(string site, int count,bool autoUpdateStatus); + Task> GetListAsync(long beginUid,long endUid); + + Task> GetListAsync(DateTime beginDate, DateTime endDate); + + Task GetAsync(long uid); + + Task GetAsync(string number); + + Task UpdateStatusAsync(string number, EnumExchangeDataStatus status); } diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Asns/X12AsnDTO.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Asns/X12AsnDTO.cs index a4042f8..89c0fd2 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Asns/X12AsnDTO.cs +++ b/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 +public class X12AsnDTO: IEntityDto { + + /// + /// ID + /// + public Guid Id { get; set; } + + /// + /// 地点 + /// + public string Site { get; set; } + + /// + /// 唯一ID + /// public long UID { get; set; } /// @@ -13,6 +29,17 @@ public class X12AsnDTO: EntityDtoBase /// public string BillNum { get; set; } + /// + /// 生效日期 + /// + public DateTime EffectiveDate { get; set; } + + /// + /// 状态 + /// + public EnumExchangeDataStatus Status { get; set; } + + /// /// 备注 /// @@ -21,6 +48,6 @@ public class X12AsnDTO: EntityDtoBase /// /// 数据内容 /// - public ASN_X12_856_3060 AsnX12 { get; set; } + public List Scpedi { get; set; } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Asns/X12AsnAppService.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Asns/X12AsnAppService.cs index c5512fa..4649326 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Asns/X12AsnAppService.cs +++ b/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, 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; } /// @@ -71,34 +67,121 @@ namespace Win_in.Sfs.Scp.WebApi /// 请求条件DTO(Request condition DTO) /// [HttpGet] - [Route("")] + [Route("paged-list")] public override async Task> GetListAsync(RequestDTO requestDTO) { return await base.GetListAsync(requestDTO); } [HttpGet] - [Route("unread")] - public async Task> GetUnreadListAsync(string site, int count) + [Route("unread-list")] + public async Task> 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() - { - Id = entity.Id, - UID = entity.UID, - BillNum = entity.BillNum, - Remark = entity.Remark, - AsnX12 = JsonSerializer.Deserialize(entity.DataContent) - }) - .ToList(); + return dtos; - return new ListResultDto(dtos); + } + + + [HttpGet] + [Route("between-id")] + public async Task> 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> 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 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 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 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 BuildDtos(List entities) + { + var dtos = ObjectMapper.Map, List>(entities); + return dtos; + } + + private X12AsnDTO BuildDto(X12Asn entity) + { + var dto = ObjectMapper.Map(entity); + return dto; } } } diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/WebApiApplicationAutoMapperProfile.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/WebApiApplicationAutoMapperProfile.cs index 7c6b294..3efc5f5 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/WebApiApplicationAutoMapperProfile.cs +++ b/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(); CreateMap() - .Ignore(p=>p.Id) - .Ignore(p=>p.CreatorId) - .Ignore(p=>p.CreationTime); + .Ignore(p => p.Id) + .Ignore(p => p.CreatorId) + .Ignore(p => p.CreationTime); } /// @@ -42,7 +46,7 @@ namespace Win_in.Sfs.Scp.WebApi { CreateMap(); - CreateMap() + CreateMap() .Ignore(p => p.Id) .Ignore(p => p.CreatorId) .Ignore(p => p.CreationTime); @@ -83,7 +87,7 @@ namespace Win_in.Sfs.Scp.WebApi { CreateMap(); - CreateMap() + CreateMap() .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() - .Ignore(p=>p.AsnX12); + CreateMap() + .Ignore(p => p.Scpedi) + .AfterMap(ConvertToScpEdi) + ; + } + + private void ConvertToScpEdi(X12Asn src, X12AsnDTO dest) + { + var asnX12 = JsonSerializer.Deserialize(src.DataContent)?.ToString(); + var list = asnX12?.Split("\r\n").ToList(); + dest.Scpedi = list; } } } diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/DTM.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/DTM.cs index 38a587c..01ebe1f 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/DTM.cs +++ b/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; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/HL.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/HL.cs index 8b26466..e9d3850 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/HL.cs +++ b/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; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/REF.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/REF.cs index a8d8056..0690412 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/REF.cs +++ b/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(); diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GE.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GE.cs index 7f2056f..876a7b5 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GE.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GE.cs @@ -18,6 +18,11 @@ public class GE /// public string GE02 { get; set; } + public GE() + { + + } + public GE(string code, int count = 1) { GE01 = count.ToString(); diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GS.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GS.cs index 6efb309..09b866a 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GS.cs +++ b/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; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/IEA.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/IEA.cs index 7794ede..79d0170 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/IEA.cs +++ b/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(); diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ISA.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ISA.cs index 6facb4c..6bc7e35 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ISA.cs +++ b/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 = "") { diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/CLD.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/CLD.cs index e43c0c3..17c56f5 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/CLD.cs +++ b/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) { diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/LIN.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/LIN.cs index cf7d6cd..223994e 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/LIN.cs +++ b/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; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/PRF.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/PRF.cs index 5b9e22d..86083e7 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/PRF.cs +++ b/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; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/SN1.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/SN1.cs index f66d9c6..a7cba20 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/SN1.cs +++ b/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; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/BSN.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/BSN.cs index eaa5187..765f77a 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/BSN.cs +++ b/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; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/CTT.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/CTT.cs index 333c017..26a2d84 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/CTT.cs +++ b/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; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/SE.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/SE.cs index 0b3d100..68c20e8 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/SE.cs +++ b/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(); diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/ST.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/ST.cs index ff4d9f7..21a5390 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/ST.cs +++ b/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; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/MEA.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/MEA.cs index 9a226a1..6cb2ed6 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/MEA.cs +++ b/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(); diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/N1.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/N1.cs index ed3e5f9..8f21fe9 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/N1.cs +++ b/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(); diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD1.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD1.cs index c436a66..9b2ec06 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD1.cs +++ b/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; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD3.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD3.cs index a365f3b..21ff7b5 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD3.cs +++ b/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; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD5.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD5.cs index 5060da8..4a82b1f 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD5.cs +++ b/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; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EnumExchangeDataStatus.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EnumExchangeDataStatus.cs index cd55885..b328ffb 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EnumExchangeDataStatus.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EnumExchangeDataStatus.cs @@ -3,23 +3,23 @@ public enum EnumExchangeDataStatus { /// - /// 新增 + /// 新增(new) /// - Ready = 0, + New = 0, /// - /// 处理中 + /// 处理中(Processing) /// Processing = 1, /// - /// 完成 + /// 完成(Finish) /// - Success = 2, + Finish = 2, /// - /// 搁置 + /// 搁置(Hold) /// Hold = 9, /// - /// 错误 + /// 错误(Error) /// Error = -1, } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/IX12AsnRepository.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/IX12AsnRepository.cs index b41096d..db1e9af 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/IX12AsnRepository.cs +++ b/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 { - Task> GetUnreadListAsync(string site, int count); + Task> GetUnreadListAsync(string site, int count, bool autoUpdateStatus); Task UpdateStatusAsync(Guid id, EnumExchangeDataStatus status); } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/X12Asn.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/X12Asn.cs index 3237f93..a11857a 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/X12Asn.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/X12Asn.cs @@ -120,7 +120,7 @@ public class X12Asn: EntityBase 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 public void SetSuccess(string remark = null) { - Status = EnumExchangeDataStatus.Success; + Status = EnumExchangeDataStatus.Finish; ErrorCode = (int)EnumExchangeDataErrorCode.None; ErrorMessage = ""; Remark = remark; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Repositories/X12AsnRepository.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Repositories/X12AsnRepository.cs index 8f3ff84..ca9f374 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Repositories/X12AsnRepository.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Repositories/X12AsnRepository.cs @@ -15,18 +15,22 @@ public class X12AsnRepository : EfCoreRepository, { } - public async Task> GetUnreadListAsync(string site, int count) + public async Task> 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(); - foreach (var entity in list) + if (autoUpdateStatus) { - await UpdateStatusAsync(entity.Id, EnumExchangeDataStatus.Success); + foreach (var entity in list) + { + entity.SetSuccess(); + await UpdateAsync(entity); + } } return list; @@ -38,13 +42,13 @@ public class X12AsnRepository : EfCoreRepository, 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: diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBackgroundWorker.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBackgroundWorker.cs index 435ca2e..4448f60 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBackgroundWorker.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBackgroundWorker.cs @@ -69,9 +69,9 @@ public class AsnBackgroundWorker : AsyncPeriodicBackgroundWorkerBase { using (dataFilter.Disable()) { - 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); diff --git a/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/IScpAsnManager.cs b/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/IScpAsnManager.cs index 0860da3..76edef1 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/IScpAsnManager.cs +++ b/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> GetUnreadAsnsAsync(long uid, int batchSize); - Task> GetBarcodesAsync(string billNum); + Task> GetUnreadAsnsAsync(string site, long uid, int batchSize); + Task> GetBarcodesAsync(string site, string billNum); } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ITbAsnRepository.cs b/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ITbAsnRepository.cs index bd74ddf..a5d17d0 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ITbAsnRepository.cs +++ b/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,ITransientDependency { - Task> GetUnreadListAsync(long uid,int batchSize); + Task> GetUnreadListAsync(string site, long uid, int batchSize); } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ITsBarcodeRepository.cs b/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ITsBarcodeRepository.cs index 7f1fed4..35556e4 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ITsBarcodeRepository.cs +++ b/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, ITransientDependency { - Task> GetListByBillNumAsync(string billNum); + Task> GetListByBillNumAsync(string site, string billNum); } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ScpAsnManager.cs b/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ScpAsnManager.cs index 5fb687d..200174e 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ScpAsnManager.cs +++ b/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> GetUnreadAsnsAsync(long uid, int batchSize) + public async Task> GetUnreadAsnsAsync(string site, long uid, int batchSize) { - return await _tbAsnRepository.GetUnreadListAsync(uid, batchSize); + return await _tbAsnRepository.GetUnreadListAsync(site, uid, batchSize); } - public async Task> GetBarcodesAsync(string billNum) + public async Task> GetBarcodesAsync(string site, string billNum) { - return await _tsBarcodeRepository.GetListByBillNumAsync(billNum); + return await _tsBarcodeRepository.GetListByBillNumAsync(site, billNum); } } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TbAsnRepository.cs b/WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TbAsnRepository.cs index cc841c3..12da6e9 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TbAsnRepository.cs +++ b/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> GetUnreadListAsync(long uid, int batchSize) + public async Task> 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(); diff --git a/WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TsBarcodeRepository.cs b/WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TsBarcodeRepository.cs index 233ca24..afe9a03 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TsBarcodeRepository.cs +++ b/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> GetListByBillNumAsync(string billNum) + public async Task> 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; }