Browse Source

[add]添加ASN接口

master
贾荣国 3 years ago
parent
commit
9deec24ad4
  1. 6
      WebApiService/Win_in.Sfs.Scp.WebApi.sln
  2. 41
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/AgentHostedService.cs
  3. 60
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/AgentModule.cs
  4. 16
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/AgentOptions.cs
  5. 14
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/AgentService.cs
  6. 10
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/EnumExchangeDataErrorCode.cs
  7. 67
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/IncomingDataWorker.cs
  8. 57
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/Program.cs
  9. 35
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/Win_in.Sfs.Scp.WebApi.Agent.csproj
  10. 14
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/appsettings.json
  11. 22
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Asns/IX12AsnAppService.cs
  12. 26
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Asns/X12AsnDTO.cs
  13. 1
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/RouteConsts.cs
  14. 97
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Asns/X12AsnAppService.cs
  15. 8
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/WebApiApplicationAutoMapperProfile.cs
  16. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ASN_X12_856_3060.cs
  17. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ASN_X12_856_3060Extensions.cs
  18. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/DTM.cs
  19. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/HL.cs
  20. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/REF.cs
  21. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/FunctionalGroup.cs
  22. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/FunctionalGroupExtensions.cs
  23. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GE.cs
  24. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GS.cs
  25. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/IEA.cs
  26. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ISA.cs
  27. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/CLD.cs
  28. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/Item.cs
  29. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/ItemExtentions.cs
  30. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/LIN.cs
  31. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/PRF.cs
  32. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/SN1.cs
  33. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/BSN.cs
  34. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/CTT.cs
  35. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/FOB.cs
  36. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/SE.cs
  37. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/ST.cs
  38. 1
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/ShipNotice.cs
  39. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/ShipNoticeExtensions.cs
  40. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/MEA.cs
  41. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/N1.cs
  42. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/Shipment.cs
  43. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/ShipmentExtensions.cs
  44. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD1.cs
  45. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD3.cs
  46. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD5.cs
  47. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Tares/Tare.cs
  48. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Tares/TareExtensions.cs
  49. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/X12Const.cs
  50. 9
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EnumExchangeDataErrorCode.cs
  51. 25
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EnumExchangeDataStatus.cs
  52. 13
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/IX12AsnRepository.cs
  53. 138
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/X12Asn.cs
  54. 3
      WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/DbContext/IWebApiDbContext.cs
  55. 3
      WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/DbContext/WebApiDbContext.cs
  56. 49
      WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/DbContext/WebApiDbContextModelCreatingExtensions.cs
  57. 2998
      WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Migrations/20220519044235_X12Asn.Designer.cs
  58. 70
      WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Migrations/20220519044235_X12Asn.cs
  59. 90
      WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Migrations/WebApiDbContextModelSnapshot.cs
  60. 60
      WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Repositories/X12AsnRepository.cs
  61. 74
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBackgroundWorker.cs
  62. 9
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBgWorker.cs
  63. 194
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnFactory.cs
  64. 9
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/EnumExchangeDataErrorCode.cs
  65. 11
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/WebApiHttpApiHostModule.cs
  66. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/Win_in.Sfs.Scp.WebApi.HttpApi.Host.csproj
  67. 6
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/appsettings.json
  68. 13
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/IScpAsnManager.cs
  69. 13
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ITbAsnRepository.cs
  70. 13
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ITsBarcodeRepository.cs
  71. 29
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/ScpAsnManager.cs
  72. 8
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TB_ASN.cs
  73. 5
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TS_BARCODE.cs
  74. 29
      WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TbAsnRepository.cs
  75. 27
      WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TsBarcodeRepository.cs

6
WebApiService/Win_in.Sfs.Scp.WebApi.sln

@ -49,7 +49,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scp", "scp", "{925EA68F-25D
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "webApi", "webApi", "{A79A01B2-9532-4C6B-880F-193251F3B9F3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Win_in.Sfs.Scp.WebApi.Console", "src\Win_in.Sfs.Scp.WebApi.Console\Win_in.Sfs.Scp.WebApi.Console.csproj", "{FAC4C418-08A2-48C5-A966-A832FB091C78}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.Console", "src\Win_in.Sfs.Scp.WebApi.Console\Win_in.Sfs.Scp.WebApi.Console.csproj", "{FAC4C418-08A2-48C5-A966-A832FB091C78}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "apps", "apps", "{F4E990AA-C8C9-4574-9027-CC2640A6C1BB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -158,7 +160,7 @@ Global
{98CDED94-F046-4010-88F4-700B7481169E} = {44A92E7C-E2FC-4F37-AF3D-6B7213EF54FE}
{925EA68F-25D1-444F-A79B-EB9BF754EC3C} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{A79A01B2-9532-4C6B-880F-193251F3B9F3} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{FAC4C418-08A2-48C5-A966-A832FB091C78} = {A79A01B2-9532-4C6B-880F-193251F3B9F3}
{FAC4C418-08A2-48C5-A966-A832FB091C78} = {F4E990AA-C8C9-4574-9027-CC2640A6C1BB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F}

41
WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/AgentHostedService.cs

@ -0,0 +1,41 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Volo.Abp;
namespace Win_in.Sfs.Scp.WebApi.Agent
{
public class AgentHostedService : IHostedService
{
private readonly IAbpApplicationWithExternalServiceProvider _application;
private readonly IServiceProvider _serviceProvider;
private readonly AgentService _agentService;
public AgentHostedService(
IAbpApplicationWithExternalServiceProvider application,
IServiceProvider serviceProvider,
AgentService agentService)
{
_application = application;
_serviceProvider = serviceProvider;
_agentService = agentService;
}
public Task StartAsync(CancellationToken cancellationToken)
{
_application.Initialize(_serviceProvider);
_agentService.Start();
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)
{
_application.Shutdown();
return Task.CompletedTask;
}
}
}

60
WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/AgentModule.cs

@ -0,0 +1,60 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Volo.Abp;
using Volo.Abp.Autofac;
using Volo.Abp.AutoMapper;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.BackgroundWorkers;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Modularity;
using Win_in.Sfs.Scp.v1.Domain;
using Win_in.Sfs.Scp.v1.EntityFrameworkCore;
namespace Win_in.Sfs.Scp.WebApi.Agent
{
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpAutoMapperModule),
typeof(AbpBackgroundJobsModule),
typeof(AbpBackgroundWorkersModule)
)]
[DependsOn(
typeof(V1ScpDomainModule),
typeof(V1ScpEntityFrameworkCoreModule)
)]
public class AgentModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var env = context.Services.GetSingletonInstance<IHostEnvironment>();
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer();
});
Configure<AgentOptions>(configuration.GetSection("AgentOptions"));
context.Services.AddHostedService<AgentHostedService>();
context.Services.AddAutoMapperObjectMapper<AgentModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<AgentModule>(validate: false);
});
}
public override void OnApplicationInitialization(
ApplicationInitializationContext context)
{
context.AddBackgroundWorker<IncomingDataWorker>();
}
}
}

16
WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/AgentOptions.cs

@ -0,0 +1,16 @@
namespace Win_in.Sfs.Scp.WebApi.Agent
{
public class AgentOptions
{
public IncomingOptions IncomingOptions { get; set; }
}
public class IncomingOptions
{
public bool Active { get; set; } = false;
public int PeriodSeconds { get; set; } = 5 * 60;
public int RetryTimes { get; set; } = 3;
public int BatchSize { get; set; } = 100;
}
}

14
WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/AgentService.cs

@ -0,0 +1,14 @@
using System;
using Volo.Abp.DependencyInjection;
namespace Win_in.Sfs.Scp.WebApi.Agent
{
public class AgentService : ITransientDependency
{
public void Start()
{
Console.WriteLine("Wms dataExchange service has started...");
}
}
}

10
WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/EnumExchangeDataErrorCode.cs

@ -0,0 +1,10 @@
namespace Win_in.Sfs.Scp.WebApi.Agent
{
public enum EnumExchangeDataErrorCode
{
None = 0,
UnknownDataType = 1,
WrongDataFormat = 2,
Exception = 9,
}
}

67
WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/IncomingDataWorker.cs

@ -0,0 +1,67 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Volo.Abp.BackgroundWorkers;
using Volo.Abp.Threading;
using Volo.Abp.Uow;
namespace Win_in.Sfs.Scp.WebApi.Agent
{
public class IncomingDataWorker : AsyncPeriodicBackgroundWorkerBase
{
private readonly IOptions<AgentOptions> _options;
public IncomingDataWorker(
AbpAsyncTimer timer,
IOptions<AgentOptions> options,
IServiceScopeFactory serviceScopeFactory
) : base(timer, serviceScopeFactory)
{
_options = options;
Timer.Period = options.Value.IncomingOptions.PeriodSeconds * 1000; //default 5 minutes
}
[UnitOfWork]
protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext)
{
Logger.LogInformation("Starting: Handling Incoming Exchange data...");
if (!_options.Value.IncomingOptions.Active)
{
Logger.LogInformation("Incoming Exchange is not active!");
return;
}
//Resolve dependencies
var incomingDataManager = workerContext
.ServiceProvider
.GetRequiredService<IIncomingDataManager>();
//Do the work
var incomingDataList = await incomingDataManager.GetReadyListAsync();
foreach (var incomingData in incomingDataList)
{
try
{
await UpdateWmsAsync(incomingData);
}
catch (Exception e)
{
e = e.GetBaseException();
incomingData.SetError(EnumExchangeDataErrorCode.Exception, e.Message);
}
//归档并删除
await incomingDataManager.FileAndDeleteAsync(incomingData);
}
Logger.LogInformation("Completed: Handling Incoming Exchange data...");
}
private async Task UpdateWmsAsync(object incomingData)
{
throw new NotImplementedException();
}
}
}

57
WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/Program.cs

@ -0,0 +1,57 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
namespace Win_in.Sfs.Scp.WebApi.Agent
{
public class Program
{
public static async Task<int> Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Debug()
#else
.MinimumLevel.Information()
#endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
.WriteTo.Async(c => c.Console())
.CreateLogger();
try
{
Log.Information("Starting console host.");
await CreateHostBuilder(args).RunConsoleAsync();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseAutofac()
.UseSerilog()
.ConfigureAppConfiguration((context, config) =>
{
//setup your additional configuration sources
})
.ConfigureServices((hostContext, services) =>
{
services.AddApplication<AgentModule>();
});
}
}

35
WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/Win_in.Sfs.Scp.WebApi.Agent.csproj

@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.*" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.*" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="4.4.2" />
<PackageReference Include="Volo.Abp.BackgroundJobs" Version="4.4.2" />
<PackageReference Include="Volo.Abp.BackgroundWorkers" Version="4.4.2" />
<PackageReference Include="Volo.Abp.AutoMapper" Version="4.4.2" />
<PackageReference Include="Volo.Abp.Autofac" Version="4.4.2" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Win_in.Sfs.Scp.v1.Domain\Win_in.Sfs.Scp.v1.Domain.csproj" />
<ProjectReference Include="..\Win_in.Sfs.Scp.v1.EntityFrameworkCore\Win_in.Sfs.Scp.v1.EntityFrameworkCore.csproj" />
</ItemGroup>
</Project>

14
WebApiService/src/Win_in.Sfs.Scp.WebApi.Agent/appsettings.json

@ -0,0 +1,14 @@
{
"ConnectionStrings": {
"DataExchange": "Server=127.0.0.1;Database=DataExchange_Test;uid=sa;pwd=Microsoft2008;"
},
"AgentOptions": {
"IncomingOptions": {
"Active": false,
"PeriodSeconds": 300,
"RetryTimes": 3,
"BatchSize": 100
}
}
}

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

@ -0,0 +1,22 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Validation;
using Win_in.Sfs.Scp.WebApi.Asns;
namespace Win_in.Sfs.Scp.WebApi
{
/// <summary>
/// Asn接口
/// </summary>
public interface IX12AsnAppService : IReadOnlyAppService<X12AsnDTO,Guid,RequestDTO>
{
Task<ListResultDto<X12AsnDTO>> GetUnreadListAsync(int count);
}
}

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

@ -0,0 +1,26 @@
using System;
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 long UID { get; set; }
/// <summary>
/// 单据号
/// </summary>
public string BillNum { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 数据内容
/// </summary>
public ASN_X12_856_3060 AsnX12 { get; set; }
}

1
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/RouteConsts.cs

@ -10,5 +10,6 @@ namespace Win_in.Sfs.Scp.WebApi
public const string Receipt = "api/scp/receipt";
public const string Supplier = "api/scp/supplier";
public const string UnplannedReceipt = "api/scp/unplanned-receipt";
public const string X12Asn = "api/scp/asn";
}
}

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

@ -0,0 +1,97 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using AutoMapper;
using AutoMapper.Configuration;
using FluentValidation;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow;
using Win_in.Sfs.Scp.v1.Domain;
using Microsoft.Extensions.Configuration;
using Volo.Abp.Clients;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Validation;
using IConfiguration = Microsoft.Extensions.Configuration.IConfiguration;
using Volo.Abp.TenantManagement;
using Win_in.Sfs.Scp.WebApi.Asns;
namespace Win_in.Sfs.Scp.WebApi
{
/// <summary>
/// 零件服务
/// </summary>
[Authorize]
[Route(RouteConsts.X12Asn)]
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.ScpWebApi)]
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>
/// 按ID获取零件 (Get X12Asn by ID)
/// </summary>
/// <param name="id">唯一ID(unique ID)</param>
/// <returns></returns>
[HttpGet]
[Route("{id}")]
public override async Task<X12AsnDTO> GetAsync(Guid id)
{
return await base.GetAsync(id);
}
/// <summary>
/// 按条件获取零件列表 (Get X12Asn list by request condition)
/// </summary>
/// <param name="requestDTO">请求条件DTO(Request condition DTO)</param>
/// <returns></returns>
[HttpGet]
[Route("")]
public override async Task<PagedResultDto<X12AsnDTO>> GetListAsync(RequestDTO requestDTO)
{
return await base.GetListAsync(requestDTO);
}
public async Task<ListResultDto<X12AsnDTO>> GetUnreadListAsync(int count)
{
var entities = await _x12AsnRepository.GetUnreadListAsync(count);
var dtos = entities.Select(entity => new X12AsnDTO()
{
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);
}
}
}

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

@ -1,6 +1,7 @@
using AutoMapper;
using Volo.Abp.AutoMapper;
using Volo.Abp.Timing;
using Win_in.Sfs.Scp.WebApi.Asns;
namespace Win_in.Sfs.Scp.WebApi
{
@ -18,6 +19,7 @@ namespace Win_in.Sfs.Scp.WebApi
CreateMapPurchaseOrder();
CreateMapPurchaseOrderDetail();
CreateMapUnplannedReceipt();
CreateMapX12Asn();
}
/// <summary>
@ -95,5 +97,11 @@ namespace Win_in.Sfs.Scp.WebApi
.Ignore(p => p.CreatorId)
.Ignore(p => p.CreationTime);
}
private void CreateMapX12Asn()
{
CreateMap<X12Asn,X12AsnDTO>()
.Ignore(p=>p.AsnX12);
}
}
}

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ASN_X12_856_3060.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ASN_X12_856_3060.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ASN_X12_856_3060Extensions.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ASN_X12_856_3060Extensions.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Commons/DTM.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/DTM.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Commons/HL.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/HL.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Commons/REF.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Commons/REF.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionGroups/FunctionalGroup.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/FunctionalGroup.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionGroups/FunctionalGroupExtensions.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/FunctionalGroupExtensions.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionGroups/GE.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GE.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionGroups/GS.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/FunctionGroups/GS.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/IEA.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/IEA.cs

4
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ISA.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ISA.cs

@ -1,9 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Net;
using System.Reflection;
using static System.Net.Mime.MediaTypeNames;
using static AutoMapper.Internal.ExpressionFactory;
namespace Win_in.Sfs.Scp.WebApi.Asns;

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/CLD.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/CLD.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/Item.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/Item.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/ItemExtentions.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/ItemExtentions.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/LIN.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/LIN.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/PRF.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/PRF.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/SN1.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Items/SN1.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/BSN.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/BSN.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/CTT.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/CTT.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/FOB.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/FOB.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/SE.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/SE.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ST.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/ST.cs

1
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ShipNotice.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/ShipNotice.cs

@ -1,5 +1,4 @@
using System.Text;
using Microsoft.AspNetCore.SignalR;
namespace Win_in.Sfs.Scp.WebApi.Asns;

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ShipNoticeExtensions.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/ShipNotices/ShipNoticeExtensions.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/MEA.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/MEA.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/N1.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/N1.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/Shipment.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/Shipment.cs

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/ShipmentExtensions.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/ShipmentExtensions.cs

@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Microsoft.AspNetCore.SignalR;

namespace Win_in.Sfs.Scp.WebApi.Asns;
public static class ShipmentExtensions

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/TD1.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD1.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/TD3.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD3.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/TD5.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Shipments/TD5.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Tares/Tare.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Tares/Tare.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Tares/TareExtensions.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/Tares/TareExtensions.cs

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/X12Const.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/ASN_X12/X12Const.cs

9
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EnumExchangeDataErrorCode.cs

@ -0,0 +1,9 @@
namespace Win_in.Sfs.Scp.WebApi.Asns;
public enum EnumExchangeDataErrorCode
{
None = 0,
UnknownDataType = 1,
WrongDataFormat = 2,
Exception = 9,
}

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

@ -0,0 +1,25 @@
namespace Win_in.Sfs.Scp.WebApi.Asns;
public enum EnumExchangeDataStatus
{
/// <summary>
/// 新增
/// </summary>
Ready = 0,
/// <summary>
/// 处理中
/// </summary>
Processing = 1,
/// <summary>
/// 完成
/// </summary>
Success = 2,
/// <summary>
/// 搁置
/// </summary>
Hold = 9,
/// <summary>
/// 错误
/// </summary>
Error = -1,
}

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

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
namespace Win_in.Sfs.Scp.WebApi.Asns;
public interface IX12AsnRepository : IRepository<X12Asn, Guid>
{
Task<List<X12Asn>> GetUnreadListAsync(int count);
Task<X12Asn> UpdateStatusAsync(Guid id, EnumExchangeDataStatus status);
}

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

@ -0,0 +1,138 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
using Win_in.Sfs.Scp.WebApi.Domain.Shared;
namespace Win_in.Sfs.Scp.WebApi.Asns;
public class X12Asn: EntityBase<Guid>
{
public long UID { get; set; }
/// <summary>
/// 单据号
/// </summary>
public string BillNum { get; set; }
/// <summary>
/// 数据类型
/// </summary>
public string DataType { get; set; }
/// <summary>
/// 生效日期
/// </summary>
public DateTime EffectiveDate { get; protected internal set; } = DateTime.Today;
/// <summary>
/// 数据状态
/// </summary>
public EnumExchangeDataStatus Status { get; protected internal set; } = 0;
/// <summary>
/// 数据内容
/// </summary>
public string DataContent { get; set; }
/// <summary>
/// 目标系统
/// </summary>
public string DestinationSystem { get; set; }
/// <summary>
/// 读取时间
/// </summary>
public DateTime? ReadTime { get; set; }
/// <summary>
/// 读取者
/// </summary>
public string Reader { get; set; }
/// <summary>
/// 来源系统
/// </summary>
public string SourceSystem { get; set; }
/// <summary>
/// 写入时间
/// </summary>
public DateTime WriteTime { get; set; } = DateTime.Now;
/// <summary>
/// 写入者
/// </summary>
public string Writer { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
public int RetryTimes { get; protected internal set; } = 0;
public X12Asn(long uid,string billNum,string dataContent,DateTime effectiveDate)
{
UID = uid;
BillNum = billNum;
DataType = "ASN";
DataContent = dataContent;
EffectiveDate = effectiveDate;
DestinationSystem = "QAD";
SourceSystem = "SCP";
Writer = "SCP";
}
public void SetEffectiveDate(DateTime newDate)
{
EffectiveDate = newDate;
}
public void SetError(EnumExchangeDataErrorCode errorCode, string errorMessage, string remark = null)
{
Status = EnumExchangeDataStatus.Error;
ErrorCode = (int)errorCode;
ErrorMessage = errorMessage;
Remark = remark;
RetryTimes++;
}
public void SetHold(string remark = null)
{
Status = EnumExchangeDataStatus.Hold;
Remark = remark;
}
public virtual void Reset(string remark = null)
{
Status = EnumExchangeDataStatus.Ready;
ErrorCode = (int)EnumExchangeDataErrorCode.None;
ErrorMessage = "";
Remark = remark;
RetryTimes = 0;
}
public void Take(string remark = null)
{
Status = EnumExchangeDataStatus.Processing;
Remark = remark;
}
public void SetSuccess(string remark = null)
{
Status = EnumExchangeDataStatus.Success;
ErrorCode = (int)EnumExchangeDataErrorCode.None;
ErrorMessage = "";
Remark = remark;
}
public void SetProcessing(string remark =null)
{
Status = EnumExchangeDataStatus.Processing;
Remark = remark;
}
}

3
WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/DbContext/IWebApiDbContext.cs

@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Win_in.Sfs.Scp.WebApi.Asns;
namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore
{
@ -16,5 +17,7 @@ namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore
DbSet<PurchaseOrder> PurchaseOrders { get; set; }
DbSet<Receipt> Receipts { get; set; }
DbSet<UnplannedReceipt> UnplannedReceipts { get; set; }
DbSet<X12Asn> X12Asns { get; set; }
}
}

3
WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/DbContext/WebApiDbContext.cs

@ -12,6 +12,7 @@ using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement;
using Volo.Abp.TenantManagement.EntityFrameworkCore;
using Win_in.Sfs.Scp.WebApi.Asns;
namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore
{
@ -33,6 +34,8 @@ namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore
public virtual DbSet<Receipt> Receipts { get; set; }
public virtual DbSet<UnplannedReceipt> UnplannedReceipts { get; set; }
public virtual DbSet<X12Asn> X12Asns { get; set; }
#region Entities from the modules

49
WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/DbContext/WebApiDbContextModelCreatingExtensions.cs

@ -2,6 +2,7 @@ using System;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling;
using Win_in.Sfs.Scp.WebApi.Asns;
namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore
{
@ -42,11 +43,12 @@ namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore
*/
builder.ConfigurePart(options);
builder.ConfigSuppliers(options);
builder.ConfigReceipt(options);
builder.ConfigPurchaseOrder(options);
builder.ConfigPurchaseOrderDetail(options);
builder.ConfigUnplannedReceipt(options);
builder.ConfigureSuppliers(options);
builder.ConfigureReceipt(options);
builder.ConfigurePurchaseOrder(options);
builder.ConfigurePurchaseOrderDetail(options);
builder.ConfigureUnplannedReceipt(options);
builder.ConfigureX12Asn(options);
}
/// <summary>
@ -95,7 +97,7 @@ namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore
/// <summary>
/// 供应商
/// </summary>
private static void ConfigSuppliers(this ModelBuilder builder, WebApiModelBuilderConfigurationOptions options)
private static void ConfigureSuppliers(this ModelBuilder builder, WebApiModelBuilderConfigurationOptions options)
{
builder.Entity<Supplier>(b =>
{
@ -154,7 +156,7 @@ namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore
/// <summary>
/// 收货单与退货单明细
/// </summary>
private static void ConfigReceipt(this ModelBuilder builder, WebApiModelBuilderConfigurationOptions options)
private static void ConfigureReceipt(this ModelBuilder builder, WebApiModelBuilderConfigurationOptions options)
{
builder.Entity<Receipt>(b =>
{
@ -189,7 +191,7 @@ namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore
/// <summary>
/// 采购订单主表
/// </summary>
private static void ConfigPurchaseOrder(this ModelBuilder builder, WebApiModelBuilderConfigurationOptions options)
private static void ConfigurePurchaseOrder(this ModelBuilder builder, WebApiModelBuilderConfigurationOptions options)
{
builder.Entity<PurchaseOrder>(b =>
{
@ -223,7 +225,7 @@ namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore
/// <summary>
/// 采购订单明细表
/// </summary>
private static void ConfigPurchaseOrderDetail(this ModelBuilder builder, WebApiModelBuilderConfigurationOptions options)
private static void ConfigurePurchaseOrderDetail(this ModelBuilder builder, WebApiModelBuilderConfigurationOptions options)
{
builder.Entity<PurchaseOrderDetail>(b =>
{
@ -246,7 +248,7 @@ namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore
}
private static void ConfigUnplannedReceipt(this ModelBuilder builder,
private static void ConfigureUnplannedReceipt(this ModelBuilder builder,
WebApiModelBuilderConfigurationOptions options)
{
builder.Entity<UnplannedReceipt>(b =>
@ -275,6 +277,33 @@ namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore
});
}
private static void ConfigureX12Asn(this ModelBuilder builder,
WebApiModelBuilderConfigurationOptions options)
{
builder.Entity<X12Asn>(b =>
{
//Configure table & schema name
b.ToTable(options.TablePrefix + "_X12Asn", options.Schema);
b.ConfigureByConvention();
b.Property(q => q.BillNum).HasMaxLength(16).IsRequired();
b.Property(q => q.EffectiveDate).HasColumnType("datetime2(7)").IsRequired();
b.Property(q => q.Status).IsRequired();
b.Property(q => q.ErrorCode).IsRequired();
b.Property(q => q.ErrorMessage);
b.Property(q => q.DataContent);
b.Property(q => q.DataType).IsRequired().HasMaxLength(16);
b.Property(q => q.SourceSystem).IsRequired().HasMaxLength(16);
b.Property(q => q.WriteTime).IsRequired();
b.Property(q => q.Writer).HasMaxLength(16);
b.Property(q => q.DestinationSystem).IsRequired().HasMaxLength(16);
b.Property(q => q.ReadTime).IsRequired();
b.Property(q => q.Reader).HasMaxLength(16);
b.Property(q => q.Remark);
});
}
/*
/// <summary>
/// 发货单主表

2998
WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Migrations/20220519044235_X12Asn.Designer.cs

File diff suppressed because it is too large

70
WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Migrations/20220519044235_X12Asn.cs

@ -0,0 +1,70 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win_in.Sfs.Scp.WebApi.Migrations
{
public partial class X12Asn : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "AsnNumber",
table: "WebApi_Receipt",
type: "nvarchar(64)",
maxLength: 64,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(64)",
oldMaxLength: 64);
migrationBuilder.CreateTable(
name: "WebApi_X12Asn",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
BillNum = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: false),
DataType = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: false),
EffectiveDate = table.Column<DateTime>(type: "datetime2(7)", nullable: false),
Status = table.Column<int>(type: "int", nullable: false),
DataContent = table.Column<string>(type: "nvarchar(max)", nullable: true),
DestinationSystem = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: false),
ReadTime = table.Column<DateTime>(type: "datetime2", nullable: false),
Reader = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: true),
SourceSystem = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: false),
WriteTime = table.Column<DateTime>(type: "datetime2", nullable: false),
Writer = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: true),
Remark = table.Column<string>(type: "nvarchar(max)", nullable: true),
RetryTimes = table.Column<int>(type: "int", nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
TraceId = table.Column<string>(type: "nvarchar(max)", nullable: true),
ErrorCode = table.Column<int>(type: "int", nullable: false),
ErrorMessage = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_WebApi_X12Asn", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "WebApi_X12Asn");
migrationBuilder.AlterColumn<string>(
name: "AsnNumber",
table: "WebApi_Receipt",
type: "nvarchar(64)",
maxLength: 64,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(64)",
oldMaxLength: 64,
oldNullable: true);
}
}
}

90
WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Migrations/WebApiDbContextModelSnapshot.cs

@ -18,7 +18,7 @@ namespace Win_in.Sfs.Scp.WebApi.Migrations
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.15")
.HasAnnotation("ProductVersion", "5.0.17")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b =>
@ -1928,6 +1928,93 @@ namespace Win_in.Sfs.Scp.WebApi.Migrations
b.ToTable("AbpTenantConnectionStrings");
});
modelBuilder.Entity("Win_in.Sfs.Scp.WebApi.Asns.X12Asn", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("BillNum")
.IsRequired()
.HasMaxLength(16)
.HasColumnType("nvarchar(16)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId");
b.Property<string>("DataContent")
.HasColumnType("nvarchar(max)");
b.Property<string>("DataType")
.IsRequired()
.HasMaxLength(16)
.HasColumnType("nvarchar(16)");
b.Property<string>("DestinationSystem")
.IsRequired()
.HasMaxLength(16)
.HasColumnType("nvarchar(16)");
b.Property<DateTime>("EffectiveDate")
.HasColumnType("datetime2(7)");
b.Property<int>("ErrorCode")
.HasColumnType("int");
b.Property<string>("ErrorMessage")
.HasColumnType("nvarchar(max)");
b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<DateTime?>("ReadTime")
.IsRequired()
.HasColumnType("datetime2");
b.Property<string>("Reader")
.HasMaxLength(16)
.HasColumnType("nvarchar(16)");
b.Property<string>("Remark")
.HasColumnType("nvarchar(max)");
b.Property<int>("RetryTimes")
.HasColumnType("int");
b.Property<string>("SourceSystem")
.IsRequired()
.HasMaxLength(16)
.HasColumnType("nvarchar(16)");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<string>("TraceId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("WriteTime")
.HasColumnType("datetime2");
b.Property<string>("Writer")
.HasMaxLength(16)
.HasColumnType("nvarchar(16)");
b.HasKey("Id");
b.ToTable("WebApi_X12Asn");
});
modelBuilder.Entity("Win_in.Sfs.Scp.WebApi.Part", b =>
{
b.Property<Guid>("Id")
@ -2206,7 +2293,6 @@ namespace Win_in.Sfs.Scp.WebApi.Migrations
.HasColumnType("uniqueidentifier");
b.Property<string>("AsnNumber")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");

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

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Win_in.Sfs.Scp.WebApi.Asns;
namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore;
public class X12AsnRepository : EfCoreRepository<WebApiDbContext, X12Asn, Guid>, IX12AsnRepository
{
public X12AsnRepository(IDbContextProvider<WebApiDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public async Task<List<X12Asn>> GetUnreadListAsync(int count)
{
var dbSet = await GetDbSetAsync();
var list =await dbSet.Where(p => p.Status == EnumExchangeDataStatus.Ready)
.OrderBy(p => p.UID)
.Take(count)
.ToListAsync();
foreach (var entity in list)
{
await UpdateStatusAsync(entity.Id, EnumExchangeDataStatus.Success);
}
return list;
}
public async Task<X12Asn> UpdateStatusAsync(Guid id,EnumExchangeDataStatus status)
{
var entity =await base.GetAsync(id);
switch (status)
{
case EnumExchangeDataStatus.Ready:
entity.Reset();
break;
case EnumExchangeDataStatus.Processing:
entity.SetProcessing();
break;
case EnumExchangeDataStatus.Success:
entity.SetSuccess();
break;
case EnumExchangeDataStatus.Hold:
entity.SetHold();
break;
case EnumExchangeDataStatus.Error:
entity.SetError(EnumExchangeDataErrorCode.Exception,"");
break;
default:
throw new ArgumentOutOfRangeException(nameof(status), status, null);
}
return await UpdateAsync(entity);
}
}

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

@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Volo.Abp.BackgroundWorkers;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Threading;
using Volo.Abp.Uow;
using Win_in.Sfs.Scp.v1.Domain;
using Win_in.Sfs.Scp.WebApi.Asns;
namespace Win_in.Sfs.Scp.WebApi;
public class AsnBackgroundWorker : AsyncPeriodicBackgroundWorkerBase
{
private readonly IOptions<AsnBgWorker> _options;
public AsnBackgroundWorker(
AbpAsyncTimer timer,
IOptions<AsnBgWorker> options,
IServiceScopeFactory serviceScopeFactory
) : base(timer, serviceScopeFactory)
{
_options = options;
Timer.Period = options.Value.PeriodSeconds * 1000; //default 5 minutes
}
[UnitOfWork]
protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext)
{
Logger.LogInformation("Starting: Handling Scp Asn data...");
if (!_options.Value.Active)
{
Logger.LogInformation("Scp Asn is not active!");
return;
}
//Resolve dependencies
var scpAsnManager = workerContext
.ServiceProvider
.GetRequiredService<IScpAsnManager>();
var x12AsnRepository = workerContext
.ServiceProvider
.GetRequiredService<IX12AsnRepository>();
//Do the work
var maxUid = await x12AsnRepository.MaxAsync(p => p.UID);
var scpAsns = await scpAsnManager.GetUnreadAsnsAsync(maxUid, _options.Value.BatchSize);
Logger.LogInformation($"{scpAsns.Count} Scp ASN records were Found");
if (scpAsns.Count > 0)
{
var asnX12List = new List<X12Asn>();
foreach (var asn in scpAsns)
{
var barcodes = await scpAsnManager.GetBarcodesAsync(asn.AsnBillNum);
var asnFactory = new AsnFactory();
var asnX128563060 = asnFactory.CreateAsnX128563060(asn, barcodes);
var dataContent = JsonSerializer.Serialize(asnX128563060);
var asnX12 = new X12Asn(asn.UID, asn.AsnBillNum, dataContent,asn.ShipTime??DateTime.Today);
asnX12List.Add(asnX12);
}
await x12AsnRepository.InsertManyAsync(asnX12List);
}
Logger.LogInformation("Completed: Handling Scp Asn data...");
}
}

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

@ -0,0 +1,9 @@
namespace Win_in.Sfs.Scp.WebApi;
public class AsnBgWorker
{
public bool Active { get; set; } = false;
public int PeriodSeconds { get; set; } = 60;
public int RetryTimes { get; set; } = 3;
public int BatchSize { get; set; } = 10;
}

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

@ -0,0 +1,194 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Win_in.Sfs.Scp.v1.Domain.Asns;
using Win_in.Sfs.Scp.WebApi.Asns;
namespace Win_in.Sfs.Scp.WebApi
{
public class AsnFactory
{
public ASN_X12_856_3060 CreateAsnX128563060(TB_ASN scpAsn,List<TS_BARCODE> barcodes)
{
var asnCode = scpAsn.AsnBillNum;
var senderId = scpAsn.VendId;
var receiverId = "IACNA_ID";
var shipTime = scpAsn.ShipTime ?? DateTime.Now;
var envType = ISA.EnvType.P;
var authorization = "";
var security = "";
//初始化ASN单
var asn = CreateAsn(asnCode,senderId,receiverId,shipTime,envType,authorization,security);
var functionalGroupCode = "123456789";
//初始化功能组
var functionalGroup = CreateFunctionalGroup(senderId,receiverId,shipTime,functionalGroupCode);
var shipNoticeCode = "0001";
var datetimeType = "011";
//初始化发货单
var shipNotice = CreateShipNotice(shipNoticeCode,functionalGroupCode,shipTime,datetimeType);
var gValue = 0;
var gUom = "KG";
var nValue = 0;
var nUom = "KG";
var routeSequenceCode = "B";
var identificationCode = "PSTV";
var mode = "LT";
var equipmentCode = "TL";
var equipmentNumber = "123456";//TODO 车牌号
//初始化发货明细
var shipment = CreateShipment(shipNotice,gValue,gUom,nValue,nUom,routeSequenceCode,identificationCode,mode,
equipmentCode,equipmentNumber,functionalGroupCode,functionalGroupCode,senderId,receiverId);
//计算与添加托盘和尾箱
var palletCodes = barcodes.Select(p => p.Extend2).Distinct().ToList();
foreach (var palletCode in palletCodes)
{
var palletBarcodes = barcodes.Where(p => p.Extend2==palletCode).ToList();
var items = new List<Item>();
var group = palletBarcodes
.GroupBy(p => new { p.PartCode, p.Qty, p.Batch, p.PoUnit, p.PoBillNum,p.PackQty})
.Select(p => new
{
p.Key.PartCode,
p.Key.Qty,
p.Key.Batch,
p.Key.PoUnit,
p.Key.PoBillNum,
p.Key.PackQty,
Labels = p.Select(p=>p.BarCode).ToList()
})
.ToList();
foreach (var b in group)
{
var accumQty = 0;//TODO 如何计算
var loadQty = b.Labels.Count;
var unitQty = b.PackQty;
var item = CreateItem(b.PartCode, loadQty * unitQty, b.PoUnit, accumQty, b.PoBillNum, loadQty, unitQty,b.Labels);
items.Add(item);
}
//如果托标签为空,当作尾箱处理
if (string.IsNullOrEmpty(palletCode))
{
foreach (var item in items)
{
shipment.AddOrphanItem(shipNotice,item);
}
}
//添加托盘
else
{
var tare = CreateTare(palletCode);
shipment.AddTare(shipNotice,tare);
foreach (var item in items)
{
tare.AddItem(shipNotice, item);
}
}
}
//TODO 如何获取包装代码,或者规则是什么?
var packagingCode = "PLT90";
//装载量需要在添加托盘和尾箱后再计算
var loadingQty = shipment.Tares.Count+shipment.OrphanItems.Count;
shipment.SetTD1(packagingCode, loadingQty);
shipNotice
.AddShipment(shipment) //添加发货明细
.SetCTT() //设置发货单汇总
.SetSE(shipNoticeCode); //设置发货明细结尾
//添加发货单
functionalGroup
.AddShipNotice(shipNotice)
.SetGE(functionalGroupCode);
//添加功能组
asn
.AddFunctionGroup(functionalGroup)
.SetIEA(asnCode);
return asn;
}
private ASN_X12_856_3060 CreateAsn(string asnCode, string senderId, string receiverId, DateTime datetime,
ISA.EnvType envType = ISA.EnvType.P, string authorization = "", string security = "")
{
var asn = new ASN_X12_856_3060();
asn.SetISA(asnCode, senderId, receiverId, datetime, envType, authorization, security);
return asn;
}
private FunctionalGroup CreateFunctionalGroup(string senderId, string receiverId, DateTime datetime,
string functionalGroupCode)
{
var functionGroup = new FunctionalGroup();
functionGroup.SetGS(senderId, receiverId, datetime, functionalGroupCode);
return functionGroup;
}
private ShipNotice CreateShipNotice(string shipNoticeCode, string noticeNumber, DateTime datetime,
string datetimeType="011", string purpose = "00")
{
var shipNotice = new ShipNotice();
shipNotice
.SetST(shipNoticeCode)
.SetBSN(noticeNumber, datetime, purpose)
.SetDTM(datetime, datetimeType);
shipNotice.AddSegment(4);
return shipNotice;
}
private Shipment CreateShipment(ShipNotice shipNotice, decimal gValue, string gUom, decimal nValue, string nUom,
string routeSequenceCode, string identificationCode, string mode, string equipmentCode,
string equipmentNumber, string bmRefValue, string pkRefValue, string senderId, string receiverId)
{
var shipment = new Shipment();
shipment
.SetHL()
.SetMEA_G(gValue, gUom)
.SetMEA_N(nValue, nUom)
.SetTD5(routeSequenceCode, identificationCode, mode)
.SetTD3(equipmentCode, equipmentNumber)
.SetREF_BM(bmRefValue)
.SetREF_PK(pkRefValue)
.SetN1_SF(senderId)
.SetN1_ST(receiverId)
;
shipNotice.AddSegment(10);
return shipment;
}
private Tare CreateTare(string tareLabelCode)
{
var tare = new Tare();
tare.SetHL()
.SetREF_LS(tareLabelCode);
return tare;
}
private Item CreateItem(string itemCode, decimal qty, string uom, int accumQty,
string poNumber, int loadQty, decimal unitQty, List<string> itemLabelCodes)
{
var item = new Item();
item.SetHL()
.SetLIN(itemCode)
.SetSN1(qty, uom, accumQty)
.SetPRF(poNumber)
.SetCLD(loadQty, unitQty)
.SetREF_LSs(itemLabelCodes);
return item;
}
}
}

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

@ -0,0 +1,9 @@
namespace Win_in.Sfs.Scp.WebApi;
public enum EnumExchangeDataErrorCode
{
None = 0,
UnknownDataType = 1,
WrongDataFormat = 2,
Exception = 9,
}

11
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/WebApiHttpApiHostModule.cs

@ -30,6 +30,7 @@ using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.Autofac;
using Volo.Abp.BackgroundWorkers;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.Swashbuckle;
@ -53,7 +54,8 @@ namespace Win_in.Sfs.Scp.WebApi
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule),
typeof(AbpMultiTenancyModule)
typeof(AbpMultiTenancyModule),
typeof(AbpBackgroundWorkersModule)
)]
[DependsOn(
typeof(V1ScpEntityFrameworkCoreModule))]
@ -76,6 +78,8 @@ namespace Win_in.Sfs.Scp.WebApi
ConfigureMultiTenancy(configuration);
ConfigureAuthorization(context,configuration);
context.Services.AddScoped<IConnectionStringResolver, MultiTenantConnectionStringResolver>();
Configure<AsnBgWorker>(configuration.GetSection("AsnBgWorker"));
}
private void ConfigureMultiTenancy(IConfiguration configuration)
@ -285,6 +289,8 @@ namespace Win_in.Sfs.Scp.WebApi
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
context.AddBackgroundWorker<AsnBackgroundWorker>();
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
@ -343,7 +349,6 @@ namespace Win_in.Sfs.Scp.WebApi
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
}
}
}
}

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/Win_in.Sfs.Scp.WebApi.HttpApi.Host.csproj

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\common.props" />

6
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/appsettings.json

@ -34,6 +34,12 @@
}
}
},
"AsnBgWorker": {
"Active": true,
"PeriodSeconds": 10,
"RetryTimes": 3,
"BatchSize": 10
},
"AlwaysAllowAuthorization": true,
"ValidSites": "T8,T9"
}

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

@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
using Win_in.Sfs.Scp.v1.Domain.Asns;
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);
}
}

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

@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Win_in.Sfs.Scp.v1.Domain.Asns;
namespace Win_in.Sfs.Scp.v1.Domain
{
public interface ITbAsnRepository : IRepository<TB_ASN>,ITransientDependency
{
Task<List<TB_ASN>> GetUnreadListAsync(long uid,int batchSize);
}
}

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

@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Win_in.Sfs.Scp.v1.Domain.Asns;
namespace Win_in.Sfs.Scp.v1.Domain
{
public interface ITsBarcodeRepository : IRepository<TS_BARCODE>, ITransientDependency
{
Task<List<TS_BARCODE>> GetListByBillNumAsync(string billNum);
}
}

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

@ -0,0 +1,29 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
using Win_in.Sfs.Scp.v1.Domain.Asns;
namespace Win_in.Sfs.Scp.v1.Domain
{
public class ScpAsnManager : DomainService,IScpAsnManager
{
private readonly ITbAsnRepository _tbAsnRepository;
private readonly ITsBarcodeRepository _tsBarcodeRepository;
public ScpAsnManager(ITbAsnRepository tbAsnRepository
,ITsBarcodeRepository tsBarcodeRepository)
{
_tbAsnRepository = tbAsnRepository;
_tsBarcodeRepository = tsBarcodeRepository;
}
public async Task<List<TB_ASN>> GetUnreadAsnsAsync(long uid, int batchSize)
{
return await _tbAsnRepository.GetUnreadListAsync(uid, batchSize);
}
public async Task<List<TS_BARCODE>> GetBarcodesAsync(string billNum)
{
return await _tsBarcodeRepository.GetListByBillNumAsync(billNum);
}
}
}

8
WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TB_ASN.cs

@ -1,11 +1,14 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System;
using System.Collections.Generic;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;
namespace Win_in.Sfs.Scp.v1.Domain.Asns
{
public class TB_ASN
public class TB_ASN : Entity<long>, IMultiTenant
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long UID { get; set; }
@ -44,7 +47,6 @@ namespace Win_in.Sfs.Scp.v1.Domain.Asns
public string SubSite { get; set; }
public Guid? TenantId { get; }
}
}

5
WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TS_BARCODE.cs

@ -3,10 +3,12 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;
namespace Win_in.Sfs.Scp.v1.Domain.Asns
{
public partial class TS_BARCODE
public partial class TS_BARCODE : Entity<long>, IMultiTenant
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
@ -88,5 +90,6 @@ namespace Win_in.Sfs.Scp.v1.Domain.Asns
[DisplayName("是否扫描")]
public bool IsScanned { get; set; }
public Guid? TenantId { get; }
}
}

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

@ -0,0 +1,29 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Win_in.Sfs.Scp.v1.Domain;
using Win_in.Sfs.Scp.v1.Domain.Asns;
namespace Win_in.Sfs.Scp.v1.EntityFrameworkCore
{
public class TbAsnRepository : EfCoreRepository<V1ScpDbContext, TB_ASN>, ITbAsnRepository
{
public TbAsnRepository(IDbContextProvider<V1ScpDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public async Task<List<TB_ASN>> GetUnreadListAsync(long uid, int batchSize)
{
var dbSet = await GetDbSetAsync();
var list = await dbSet
.Where(p => p.UID > uid)
.OrderBy(p => p.UID)
.Take(batchSize)
.ToListAsync();
return list;
}
}
}

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

@ -0,0 +1,27 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Win_in.Sfs.Scp.v1.Domain;
using Win_in.Sfs.Scp.v1.Domain.Asns;
namespace Win_in.Sfs.Scp.v1.EntityFrameworkCore
{
public class TsBarcodeRepository : EfCoreRepository<V1ScpDbContext, TS_BARCODE>, ITsBarcodeRepository
{
public TsBarcodeRepository(IDbContextProvider<V1ScpDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public async Task<List<TS_BARCODE>> GetListByBillNumAsync(string billNum)
{
var dbSet = await GetDbSetAsync();
var list = await dbSet
.Where(p => p.BillNum == billNum)
.ToListAsync();
return list;
}
}
}
Loading…
Cancel
Save