修改根命名空间,修改分库配置。

This commit is contained in:
陈梓阳 2024-02-02 17:14:41 +08:00
parent e0de5d1c58
commit 5cda84797b
52 changed files with 163 additions and 237 deletions

View File

@ -1,4 +1,4 @@
namespace ConsoleApp2.Cache; namespace MesETL.App.Cache;
#nullable disable #nullable disable
public static class CacheKeys public static class CacheKeys

View File

@ -1,4 +1,4 @@
namespace ConsoleApp2.Cache; namespace MesETL.App.Cache;
public interface ICacher public interface ICacher
{ {

View File

@ -1,8 +1,8 @@
using ConsoleApp2.Options; using MesETL.App.Options;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using StackExchange.Redis; using StackExchange.Redis;
namespace ConsoleApp2.Cache; namespace MesETL.App.Cache;
public class RedisCache : ICacher public class RedisCache : ICacher
{ {

View File

@ -1,4 +1,4 @@
namespace ConsoleApp2.Const; namespace MesETL.App.Const;
public static class ProcessStep public static class ProcessStep
{ {

View File

@ -1,4 +1,4 @@
namespace ConsoleApp2.Const; namespace MesETL.App.Const;
public static class TableNames public static class TableNames
{ {

View File

@ -1,4 +1,4 @@
namespace ConsoleApp2; namespace MesETL.App;
public class DataRecord : ICloneable public class DataRecord : ICloneable
{ {

View File

@ -1,7 +1,7 @@
using System.Data; using System.Data;
using MySqlConnector; using MySqlConnector;
namespace ConsoleApp2.Helpers; namespace MesETL.App.Helpers;
public static class DatabaseHelper public static class DatabaseHelper
{ {

View File

@ -1,7 +1,7 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using ZstdSharp; using ZstdSharp;
namespace ConsoleApp2.Helpers; namespace MesETL.App.Helpers;
public static partial class DumpDataHelper public static partial class DumpDataHelper
{ {

View File

@ -1,4 +1,4 @@
namespace ConsoleApp2.Helpers; namespace MesETL.App.Helpers;
public static class DictionaryExtensions public static class DictionaryExtensions
{ {

View File

@ -1,11 +1,15 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Reflection; using System.Reflection;
namespace ConsoleApp2.Helpers; namespace MesETL.App.Helpers;
#nullable disable #nullable disable
public static class EnumerableExtensions public static class EnumerableExtensions
{ {
public static string ToMarkdownTable<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)]T>(this IEnumerable<T> source) public static string ToMarkdownTable<
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties |
DynamicallyAccessedMemberTypes.NonPublicProperties |
DynamicallyAccessedMemberTypes.PublicFields |
DynamicallyAccessedMemberTypes.NonPublicFields)] T>(this IEnumerable<T> source)
{ {
var properties = typeof(T).GetRuntimeProperties(); var properties = typeof(T).GetRuntimeProperties();
var fields = typeof(T) var fields = typeof(T)

View File

@ -1,7 +1,7 @@
using System.Globalization; using System.Globalization;
using System.Text; using System.Text;
namespace ConsoleApp2.Helpers; namespace MesETL.App.Helpers;
public static class StringExtensions public static class StringExtensions
{ {

View File

@ -1,4 +1,4 @@
namespace ConsoleApp2.Helpers; namespace MesETL.App.Helpers;
public static class TaskExtensions public static class TaskExtensions
{ {

View File

@ -1,10 +1,4 @@
using System; namespace MesETL.App.HostedServices.Abstractions
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2.HostedServices.Abstractions
{ {
public interface IDataReader : IDisposable public interface IDataReader : IDisposable
{ {

View File

@ -1,7 +1,4 @@
using ConsoleApp2.Options; namespace MesETL.App.HostedServices.Abstractions;
using ConsoleApp2.Services;
namespace ConsoleApp2.HostedServices.Abstractions;
public interface IInputService public interface IInputService
{ {

View File

@ -1,7 +1,4 @@
using ConsoleApp2.Options; namespace MesETL.App.HostedServices.Abstractions;
using ConsoleApp2.Services;
namespace ConsoleApp2.HostedServices.Abstractions;
public interface IOutputService public interface IOutputService
{ {

View File

@ -1,7 +1,4 @@
using ConsoleApp2.Options; namespace MesETL.App.HostedServices.Abstractions;
using ConsoleApp2.Services;
namespace ConsoleApp2.HostedServices.Abstractions;
public interface ITransformService public interface ITransformService
{ {

View File

@ -1,13 +1,13 @@
using ConsoleApp2.Const; using MesETL.App.Const;
using ConsoleApp2.HostedServices.Abstractions; using MesETL.App.HostedServices.Abstractions;
using ConsoleApp2.Options; using MesETL.App.Options;
using ConsoleApp2.Services; using MesETL.App.Services;
using ConsoleApp2.Services.ETL; using MesETL.App.Services.ETL;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
namespace ConsoleApp2.HostedServices; namespace MesETL.App.HostedServices;
public record FileInputInfo public record FileInputInfo
{ {

View File

@ -1,17 +1,17 @@
using System.Diagnostics; using System.Diagnostics;
using System.Text; using System.Text;
using ConsoleApp2.Helpers; using MesETL.App.Helpers;
using ConsoleApp2.HostedServices.Abstractions; using MesETL.App.HostedServices.Abstractions;
using ConsoleApp2.Options; using MesETL.App.Options;
using ConsoleApp2.Services; using MesETL.App.Services;
using ConsoleApp2.Services.ErrorRecorder; using MesETL.App.Services.ErrorRecorder;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using MySqlConnector; using MySqlConnector;
namespace ConsoleApp2.HostedServices; namespace MesETL.App.HostedServices;
public class MainHostedService : BackgroundService public class MainHostedService : BackgroundService
{ {
@ -107,7 +107,7 @@ public class MainHostedService : BackgroundService
private async Task SetVariableAsync(bool enable = true) private async Task SetVariableAsync(bool enable = true)
{ {
var connStr = _databaseOptions.Value.ConnectionString var connStr = _databaseOptions.Value.ConnectionString
?? throw new ApplicationException("无法还原索引,因为分库配置中没有配置数据库"); ?? throw new ApplicationException("分库配置中没有配置数据库");
if (enable) if (enable)
{ {
await DatabaseHelper.NonQueryAsync(connStr, await DatabaseHelper.NonQueryAsync(connStr,
@ -128,13 +128,13 @@ public class MainHostedService : BackgroundService
private async Task ExecuteEachDatabase(string command, CancellationToken cancellationToken = default) private async Task ExecuteEachDatabase(string command, CancellationToken cancellationToken = default)
{ {
var databases = _tenantDbOptions.Value.DbList?.Keys var databases = _tenantDbOptions.Value.DbGroup?.Keys
?? throw new ApplicationException("无法还原索引,因为分库配置中没有配置数据库"); ?? throw new ApplicationException("分库配置中没有配置数据库");
var list = new List<Task>(); var list = new List<Task>();
foreach (var db in databases) foreach (var db in databases)
{ {
var connStr = new MySqlConnectionStringBuilder(_databaseOptions.Value.ConnectionString var connStr = new MySqlConnectionStringBuilder(_databaseOptions.Value.ConnectionString
?? throw new ApplicationException("无法还原索引,因为没有配置数据库连接字符串")) ?? throw new ApplicationException("没有配置数据库连接字符串"))
{ {
ConnectionTimeout = 60, ConnectionTimeout = 60,
DefaultCommandTimeout = 0, DefaultCommandTimeout = 0,

View File

@ -1,15 +1,15 @@
using ConsoleApp2.Helpers; using MesETL.App.Helpers;
using ConsoleApp2.HostedServices.Abstractions; using MesETL.App.HostedServices.Abstractions;
using ConsoleApp2.Options; using MesETL.App.Options;
using ConsoleApp2.Services; using MesETL.App.Services;
using ConsoleApp2.Services.ErrorRecorder; using MesETL.App.Services.ErrorRecorder;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using MySqlConnector; using MySqlConnector;
using MySqlDestination = ConsoleApp2.Services.ETL.MySqlDestination; using MySqlDestination = MesETL.App.Services.ETL.MySqlDestination;
using TaskExtensions = ConsoleApp2.Helpers.TaskExtensions; using TaskExtensions = MesETL.App.Helpers.TaskExtensions;
namespace ConsoleApp2.HostedServices; namespace MesETL.App.HostedServices;
/// <summary> /// <summary>
/// 数据导出服务将数据导出至MySql服务 /// 数据导出服务将数据导出至MySql服务

View File

@ -1,10 +1,10 @@
using System.Diagnostics; using System.Diagnostics;
using ConsoleApp2.Const; using MesETL.App.Const;
using ConsoleApp2.Services; using MesETL.App.Services;
using ConsoleApp2.Services.Loggers; using MesETL.App.Services.Loggers;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace ConsoleApp2.HostedServices; namespace MesETL.App.HostedServices;
/// <summary> /// <summary>
/// 任务监控 /// 任务监控

View File

@ -1,14 +1,14 @@
using ConsoleApp2.Cache; using MesETL.App.Cache;
using ConsoleApp2.Const; using MesETL.App.Const;
using ConsoleApp2.HostedServices.Abstractions; using MesETL.App.HostedServices.Abstractions;
using ConsoleApp2.Options; using MesETL.App.Options;
using ConsoleApp2.Services; using MesETL.App.Services;
using ConsoleApp2.Services.ErrorRecorder; using MesETL.App.Services.ErrorRecorder;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
namespace ConsoleApp2.HostedServices; namespace MesETL.App.HostedServices;
public record DataTransformContext(DataRecord Record, ICacher Cacher, ILogger Logger); public record DataTransformContext(DataRecord Record, ICacher Cacher, ILogger Logger);

View File

@ -1,8 +1,8 @@
using ConsoleApp2.HostedServices.Abstractions; using MesETL.App.HostedServices.Abstractions;
using ConsoleApp2.Services; using MesETL.App.Services;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace ConsoleApp2.HostedServices; namespace MesETL.App.HostedServices;
// 空输出服务,测试用 // 空输出服务,测试用
public class VoidOutputService : IOutputService public class VoidOutputService : IOutputService

View File

@ -1,19 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<AssemblyName>MesETL</AssemblyName>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<RootNamespace>ConsoleApp2</RootNamespace> <RootNamespace>MesETL.App</RootNamespace>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="appsettings.json" /> <None Remove="appsettings.json" />
<None Update="RestoreIndex.sql">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,6 +1,6 @@
using ConsoleApp2.HostedServices; using MesETL.App.HostedServices;
namespace ConsoleApp2.Options namespace MesETL.App.Options
{ {
public class DataInputOptions public class DataInputOptions
{ {

View File

@ -1,8 +1,6 @@
using ConsoleApp2.Cache; using MesETL.App.HostedServices;
using ConsoleApp2.HostedServices;
using Microsoft.Extensions.Logging;
namespace ConsoleApp2.Options; namespace MesETL.App.Options;
public enum ColumnType public enum ColumnType
{ {

View File

@ -1,4 +1,4 @@
namespace ConsoleApp2.Options; namespace MesETL.App.Options;
public class DatabaseOutputOptions public class DatabaseOutputOptions
{ {

View File

@ -1,4 +1,4 @@
namespace ConsoleApp2.Options; namespace MesETL.App.Options;
public class RedisCacheOptions public class RedisCacheOptions
{ {

View File

@ -1,4 +1,4 @@
namespace ConsoleApp2.Options; namespace MesETL.App.Options;
public struct TableMockConfig public struct TableMockConfig
{ {

View File

@ -1,21 +1,22 @@
namespace ConsoleApp2.Options; namespace MesETL.App.Options;
public class TenantDbOptions public class TenantDbOptions
{ {
public string? TenantKey { get; set; } public string? TenantKey { get; set; }
public string? UseDbGroup { get; set; }
/// <summary> /// <summary>
/// Key-Value: {DbName}-{TenantKeyLessThan} /// Key-Value: {DbName}-{TenantKeyLessThan}
/// </summary> /// </summary>
public Dictionary<string, int>? DbList { get; set; } public Dictionary<string, int>? DbGroup { get; set; }
public string GetDbNameByTenantKeyValue(int tenantKeyValue) public string GetDbNameByTenantKeyValue(int tenantKeyValue)
{ {
// var dictionary = new SortedDictionary<int, string>(); // var dictionary = new SortedDictionary<int, string>();
// DbList.ForEach(pair => dictionary.Add(pair.Value, pair.Key)); // DbList.ForEach(pair => dictionary.Add(pair.Value, pair.Key));
// 注意配置顺序 // 注意配置顺序
if(DbList is null) throw new ApplicationException("分库配置中没有发现任何数据库"); if(DbGroup is null) throw new ApplicationException("分库配置中没有发现任何数据库");
var dbName = DbList.Cast<KeyValuePair<string, int>?>() var dbName = DbGroup.Cast<KeyValuePair<string, int>?>()
.FirstOrDefault(pair => pair?.Value != null && pair.Value.Value > tenantKeyValue)!.Value.Key; .FirstOrDefault(pair => pair?.Value != null && pair.Value.Value > tenantKeyValue)!.Value.Key;
return dbName ?? return dbName ??
throw new ArgumentOutOfRangeException(nameof(tenantKeyValue), throw new ArgumentOutOfRangeException(nameof(tenantKeyValue),

View File

@ -1,23 +1,22 @@
#define USE_TEST_DB // 测试库的结构与生产库不一样如果使用测试库运行则加上USE_TEST_DB预处理器指令 // #define USE_TEST_DB // 测试库的结构与生产库不一样如果使用测试库运行则加上USE_TEST_DB预处理器指令
using ConsoleApp2; using MesETL.App;
using ConsoleApp2.Cache; using MesETL.App.Services;
using ConsoleApp2.Const; using MesETL.App.Services.ETL;
using ConsoleApp2.Helpers; using MesETL.App.Cache;
using ConsoleApp2.HostedServices; using MesETL.App.Const;
using ConsoleApp2.HostedServices.Abstractions; using MesETL.App.HostedServices;
using ConsoleApp2.Options; using MesETL.App.HostedServices.Abstractions;
using ConsoleApp2.Services; using MesETL.App.Options;
using ConsoleApp2.Services.ErrorRecorder; using MesETL.App.Services.ErrorRecorder;
using ConsoleApp2.Services.ETL; using MesETL.App.Services.Loggers;
using ConsoleApp2.Services.Loggers;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using MySqlConnector;
using Serilog; using Serilog;
using Serilog.Events; using Serilog.Events;
using DumpDataHelper = MesETL.App.Helpers.DumpDataHelper;
await RunProgram(); await RunProgram();
return; return;
@ -29,14 +28,16 @@ async Task RunProgram()
host.Configuration.AddJsonFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "appsettings.json"), false, false); host.Configuration.AddJsonFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "appsettings.json"), false, false);
host.Configuration.AddCommandLine(args, new Dictionary<string, string> host.Configuration.AddCommandLine(args, new Dictionary<string, string>
{ {
{"-d", "Input:InputDir"}, { "-d", "Input:InputDir" },
{"--InputDir", "Input:InputDir"}, { "--InputDir", "Input:InputDir" },
{"-s", "Output:ConnectionString"}, { "-s", "Output:ConnectionString" },
{"--ConnectionString", "Output:ConnectionString"}, { "--ConnectionString", "Output:ConnectionString" },
{"-r", "RedisCache:Configuration"}, { "-r", "RedisCache:Configuration" },
{"--Redis", "RedisCache:Configuration"}, { "--Redis", "RedisCache:Configuration" },
{"-c", "Command"}, { "-g", "TenantDb:UseDbGroup" },
{"--Command", "Command"} { "--UseDbGroup", "TenantDb:UseDbGroup" },
{ "-c", "Command" },
{ "--Command", "Command" }
}); });
var inputOptions = host.Configuration.GetRequiredSection("Input").Get<DataInputOptions>() var inputOptions = host.Configuration.GetRequiredSection("Input").Get<DataInputOptions>()
@ -50,13 +51,22 @@ async Task RunProgram()
var redisSection = host.Configuration.GetRequiredSection("RedisCache"); var redisSection = host.Configuration.GetRequiredSection("RedisCache");
var redisOptions = redisSection.Get<RedisCacheOptions>() ?? throw new ApplicationException("缺少RedisCache配置"); var redisOptions = redisSection.Get<RedisCacheOptions>() ?? throw new ApplicationException("缺少RedisCache配置");
var tenantDbSection = host.Configuration.GetRequiredSection("TenantDb"); var tenantDbSection = host.Configuration.GetRequiredSection("TenantDb");
var tenantDbOptions = tenantDbSection.Get<TenantDbOptions>() ?? throw new ApplicationException("缺少TenantDb配置"); var tenantDbOptions = new TenantDbOptions()
if(tenantDbOptions.TenantKey is null) throw new ApplicationException("分库配置中缺少分库键"); {
if(tenantDbOptions.DbList is null) throw new ApplicationException("分库配置中没有发现任何数据库"); TenantKey = tenantDbSection.GetValue<string>(nameof(TenantDbOptions.TenantKey)) ?? throw new ApplicationException("分库配置缺少分库键TenantKey"),
UseDbGroup = tenantDbSection.GetValue<string>(nameof(TenantDbOptions.UseDbGroup)) ?? throw new ApplicationException("分库配置缺少使用分库组UseDbGroup")
};
tenantDbOptions.DbGroup = tenantDbSection.GetRequiredSection($"DbGroups:{tenantDbOptions.UseDbGroup}").Get<Dictionary<string,int>>()
?? throw new ApplicationException($"分库配置无法解析分库组{tenantDbOptions.UseDbGroup},请检查配置");
host.Services.Configure<TenantDbOptions>(tenantDbSection); host.Services.Configure<TenantDbOptions>(options =>
{
options.TenantKey = tenantDbOptions.TenantKey;
options.UseDbGroup = tenantDbOptions.UseDbGroup;
options.DbGroup = tenantDbOptions.DbGroup;
});
host.Services.Configure<RedisCacheOptions>(redisSection); host.Services.Configure<RedisCacheOptions>(redisSection);
var oldestTime = DateTime.ParseExact(transformOptions.CleanDate, "yyyyMM", System.Globalization.DateTimeFormatInfo.InvariantInfo); var oldestTime = DateTime.ParseExact(transformOptions.CleanDate, "yyyyMM", System.Globalization.DateTimeFormatInfo.InvariantInfo);
@ -313,7 +323,7 @@ async Task RunProgram()
//OrderBlockPlan将OrderNo长度<2的置空 //OrderBlockPlan将OrderNo长度<2的置空
case TableNames.OrderBlockPlan: case TableNames.OrderBlockPlan:
if (record["OrderNos"].Length < 2) if (record["OrderNos"].Length < 2)
record["OrderNos"] = ""; record["OrderNos"] = "NULL";
break; break;
// OrderBlockPlanResult表添加CompanyID列 // OrderBlockPlanResult表添加CompanyID列
case TableNames.OrderBlockPlanResult: case TableNames.OrderBlockPlanResult:
@ -532,7 +542,8 @@ async Task RunProgram()
builder.ClearProviders(); builder.ClearProviders();
builder.AddSerilog(new LoggerConfiguration() builder.AddSerilog(new LoggerConfiguration()
.WriteTo.Console() .WriteTo.Console()
.WriteTo.File($"./Log/Error/{ErrorRecorder.UID}.log", restrictedToMinimumLevel:LogEventLevel.Error) .WriteTo.File(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"./Log/Error/{ErrorRecorder.UID}.log"),
restrictedToMinimumLevel:LogEventLevel.Error)
// .WriteTo.File("./Log/Info/{ErrorRecorder.UID}.log", restrictedToMinimumLevel:LogEventLevel.Information) //性能考虑暂不使用 // .WriteTo.File("./Log/Info/{ErrorRecorder.UID}.log", restrictedToMinimumLevel:LogEventLevel.Information) //性能考虑暂不使用
.CreateLogger() .CreateLogger()
); );
@ -542,7 +553,7 @@ async Task RunProgram()
host.Services.AddErrorRecorderFactory(); host.Services.AddErrorRecorderFactory();
host.Services.AddSingleton<ProcessContext>(); host.Services.AddSingleton<ProcessContext>();
host.Services.AddKeyedSingleton<DataRecordQueue>(ProcessStep.Produce); host.Services.AddKeyedSingleton<DataRecordQueue>(ProcessStep.Produce);
host.Services.AddRecordQueuePool(tenantDbOptions.DbList.Keys.Select(key => (key:key, queue:new DataRecordQueue(500_000))).ToArray()); host.Services.AddRecordQueuePool(tenantDbOptions.DbGroup.Keys.Select(key => (key:key, queue:new DataRecordQueue(500_000))).ToArray());
host.Services.AddSingleton<ITaskMonitorLogger, CacheTaskMonitorLogger>(); host.Services.AddSingleton<ITaskMonitorLogger, CacheTaskMonitorLogger>();
host.Services.AddSingleton<ITaskMonitorLogger, LoggerTaskMonitorLogger>(); host.Services.AddSingleton<ITaskMonitorLogger, LoggerTaskMonitorLogger>();

View File

@ -1,73 +0,0 @@
CREATE INDEX `idx_CompanyID` ON `machine` (`CompanyID`);
CREATE INDEX `idx_companyid` ON `order` (`CompanyID`);
CREATE INDEX `idx_CompanyID` ON `order_block_plan` (`CompanyID`);
CREATE INDEX `idx_PlanID` ON `order_block_plan_item` (`PlanID`);
CREATE INDEX `idx_orderno` ON `order_box_block` (`OrderNo`);
CREATE INDEX `index_OrderNo` ON `order_data_block` (`OrderNo`);
CREATE INDEX `index_OrderNo` ON `order_data_goods` (`OrderNo`);
CREATE INDEX `index_OrderNo` ON `order_data_parts` (`OrderNo`);
CREATE INDEX `index_ItemNo` ON `order_item` (`ItemNo`);
CREATE INDEX `index_OrderNo` ON `order_item` (`OrderNo`);
CREATE INDEX `index_PackageID` ON `order_item` (`PackageID`);
CREATE INDEX `index_PlanID` ON `order_item` (`PlanID`);
CREATE INDEX `idx_OrderNo` ON `order_module` (`OrderNo`);
CREATE INDEX `index_OrderNo` ON `order_module_extra` (`OrderNo`);
CREATE INDEX `index_OrderNo` ON `order_module_item` (`OrderNo`);
CREATE INDEX `idx_OrderNo` ON `order_package` (`OrderNo`);
CREATE INDEX `idx_PakageNo` ON `order_package` (`PakageNo`);
CREATE INDEX `idx_PackageID` ON `order_package_item` (`PackageID`);
CREATE INDEX `idx_companyid` ON `order_patch_detail` (`CompanyID`);
CREATE INDEX `idx_OrderNo` ON `order_process` (`OrderNo`);
CREATE INDEX `index_CompanyID` ON `order_process_schdule` (`CompanyID`);
CREATE INDEX `IX_order_process_step_OrderProcessID` ON `order_process_step` (`OrderProcessID`);
CREATE INDEX `idx_OrderProcessID` ON `order_process_step_item` (`OrderProcessID`);
CREATE INDEX `idx_OrderProcessStepID` ON `order_process_step_item` (`OrderProcessStepID`);
CREATE INDEX `idx_CompanyID` ON `order_scrap_board` (`CompanyID`);
CREATE INDEX `idx_CompanyID` ON `process_group` (`CompanyID`);
CREATE INDEX `idx_CompanyID` ON `process_info` (`CompanyID`);
CREATE INDEX `index_CompanyID` ON `process_item_exp` (`CompanyID`);
CREATE INDEX `idx_CompanyID` ON `process_schdule_capacity` (`CompanyID`);
CREATE INDEX `idx_CompanyID` ON `process_step_efficiency` (`CompanyID`);
CREATE INDEX `idx_CompanyID` ON `report_template` (`CompanyID`);
CREATE INDEX `indx_OrderNo` ON `simple_package` (`OrderNo`);
CREATE INDEX `idx_CompanyID` ON `simple_plan_order` (`CompanyID`);
CREATE INDEX `idx_CompanyID` ON `sys_config` (`CompanyID`);
CREATE INDEX `idx` ON `work_calendar` (`CompanyID`);
CREATE INDEX `idx_CompanyID` ON `work_shift` (`CompanyID`);
CREATE INDEX `IX_work_time_ShiftID` ON `work_time` (`ShiftID`);

View File

@ -1,7 +1,7 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
namespace ConsoleApp2.Services; namespace MesETL.App.Services;
/// <summary> /// <summary>
/// 数据队列 /// 数据队列

View File

@ -1,8 +1,8 @@
using System.Text; using System.Text;
using ConsoleApp2.HostedServices.Abstractions; using MesETL.App.HostedServices.Abstractions;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace ConsoleApp2.Services.ETL; namespace MesETL.App.Services.ETL;
/// <summary> /// <summary>
/// CSV文件读取 /// CSV文件读取

View File

@ -1,10 +1,10 @@
using ConsoleApp2.HostedServices.Abstractions; using MesETL.App.HostedServices.Abstractions;
using ConsoleApp2.Options; using MesETL.App.Options;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
namespace ConsoleApp2.Services.ETL; namespace MesETL.App.Services.ETL;
public class DataReaderFactory public class DataReaderFactory
{ {

View File

@ -1,12 +1,12 @@
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using ConsoleApp2.Helpers; using MesETL.App.Helpers;
using ConsoleApp2.Options; using MesETL.App.Options;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using MySqlConnector; using MySqlConnector;
namespace ConsoleApp2.Services.ETL; namespace MesETL.App.Services.ETL;
/// <summary> /// <summary>
/// Mysql导出 /// Mysql导出

View File

@ -1,7 +1,7 @@
using ConsoleApp2.Options; using MesETL.App.Options;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace ConsoleApp2.Services.ETL; namespace MesETL.App.Services.ETL;
/// <summary> /// <summary>
/// 截取提供ZST文件中的第一行然后复制成指定数量的数据 /// 截取提供ZST文件中的第一行然后复制成指定数量的数据

View File

@ -1,7 +1,7 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using ZstdSharp; using ZstdSharp;
namespace ConsoleApp2.Services.ETL; namespace MesETL.App.Services.ETL;
/// <summary> /// <summary>
/// 解压ZST文件从中读取CSV数据 /// 解压ZST文件从中读取CSV数据

View File

@ -1,7 +1,7 @@
using ConsoleApp2.Helpers; using MesETL.App.Helpers;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace ConsoleApp2.Services.ErrorRecorder; namespace MesETL.App.Services.ErrorRecorder;
public class ErrorRecorder public class ErrorRecorder
{ {

View File

@ -1,7 +1,7 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace ConsoleApp2.Services.ErrorRecorder; namespace MesETL.App.Services.ErrorRecorder;
public class ErrorRecorderFactory public class ErrorRecorderFactory
{ {

View File

@ -1,6 +1,6 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace ConsoleApp2.Services.ErrorRecorder; namespace MesETL.App.Services.ErrorRecorder;
public sealed class InputErrorRecorder : ErrorRecorder public sealed class InputErrorRecorder : ErrorRecorder
{ {

View File

@ -1,12 +1,12 @@
using System.Text; using System.Text;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace ConsoleApp2.Services.ErrorRecorder; namespace MesETL.App.Services.ErrorRecorder;
public sealed class OutputErrorRecorder : ErrorRecorder public sealed class OutputErrorRecorder : ErrorRecorder
{ {
private readonly string _outputDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"/ErrorRecords/{UID}/Output"); private readonly string _outputDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"ErrorRecords/{UID}/Output");
private readonly string _database; private readonly string _database;
private readonly Dictionary<string, int> _logIndex = new(); private readonly Dictionary<string, int> _logIndex = new();

View File

@ -1,6 +1,6 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace ConsoleApp2.Services.ErrorRecorder; namespace MesETL.App.Services.ErrorRecorder;
public sealed class TransformErrorRecorder : ErrorRecorder public sealed class TransformErrorRecorder : ErrorRecorder
{ {

View File

@ -1,6 +1,6 @@
using ConsoleApp2.Cache; using MesETL.App.Cache;
namespace ConsoleApp2.Services.Loggers; namespace MesETL.App.Services.Loggers;
public class CacheTaskMonitorLogger : ITaskMonitorLogger public class CacheTaskMonitorLogger : ITaskMonitorLogger
{ {

View File

@ -1,4 +1,4 @@
namespace ConsoleApp2.Services.Loggers; namespace MesETL.App.Services.Loggers;
public interface ITaskMonitorLogger public interface ITaskMonitorLogger
{ {

View File

@ -1,7 +1,7 @@
using System.Text; using System.Text;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace ConsoleApp2.Services.Loggers; namespace MesETL.App.Services.Loggers;
public class LoggerTaskMonitorLogger : ITaskMonitorLogger public class LoggerTaskMonitorLogger : ITaskMonitorLogger
{ {

View File

@ -1,6 +1,6 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
namespace ConsoleApp2.Services; namespace MesETL.App.Services;
/// <summary> /// <summary>
/// 处理上下文类,标识处理进度 /// 处理上下文类,标识处理进度

View File

@ -1,7 +1,7 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace ConsoleApp2.Services; namespace MesETL.App.Services;
public class RecordQueuePool public class RecordQueuePool
{ {

View File

@ -1,7 +1,7 @@
using ApplicationException = System.ApplicationException; using ApplicationException = System.ApplicationException;
using TaskExtensions = ConsoleApp2.Helpers.TaskExtensions; using TaskExtensions = MesETL.App.Helpers.TaskExtensions;
namespace ConsoleApp2.Services; namespace MesETL.App.Services;
/// <summary> /// <summary>
/// 快速批量创建和等待任务 /// 快速批量创建和等待任务

View File

@ -6,14 +6,14 @@
}, },
"Input":{ "Input":{
"InputDir": "D:\\Dump\\MockData", // Csv "InputDir": "D:\\Dump\\MockData", // Csv
"UseMock": true, // 使 "UseMock": false, // 使
"MockCountMultiplier": 0.5 // "MockCountMultiplier": 0.5 //
}, },
"Transform":{ "Transform":{
"StrictMode": true, // true "StrictMode": false, // true
"EnableFilter": false, // "EnableFilter": true, //
"EnableReplacer": false, // ma "EnableReplacer": true, //
"EnableReBuilder": false, // "EnableReBuilder": true, //
"CleanDate": "202301" // "CleanDate": "202301" //
}, },
"Output":{ "Output":{
@ -22,7 +22,6 @@
"FlushCount": 10000, // "FlushCount": 10000, //
"MaxDatabaseOutputTask" : 4, // "MaxDatabaseOutputTask" : 4, //
"TreatJsonAsHex": false, // json16(0x) "TreatJsonAsHex": false, // json16(0x)
"RestoreIndex": true // (RestoreIndex.sql)
}, },
"RedisCache": { "RedisCache": {
"Configuration": "192.168.1.246:6380", "Configuration": "192.168.1.246:6380",
@ -31,17 +30,20 @@
"TenantDb": // "TenantDb": //
{ {
"TenantKey" : "CompanyID", "TenantKey" : "CompanyID",
"DbList": { "UseDbGroup": "test",
/* "DbGroups": {
* "test": {
* (CompanyId < 1000) -> cferp_test_1 "cferp_test_1": 1000,
* (CompanyId < 2000) -> cferp_test_2 "cferp_test_2": 2000,
* (CompanyId < 2147483647) -> cferp_test_3 "cferp_test_3": 2147483647
*/ },
"cferp_test_1": 1000, "prod":{
"cferp_test_2": 2000, "mesdb_1": 5000,
"cferp_test_3": 2147483647 "mesdb_2": 10000,
// "cferp_void_1": 2147483647 "mesdb_3": 15000,
"mesdb_4": 20000,
"mesdb_5": 2147483647
}
} }
} }
} }

View File

@ -1,5 +1,5 @@
using System.Data; using System.Data;
using ConsoleApp2.Helpers; using MesETL.App.Helpers;
using MySqlConnector; using MySqlConnector;
using Xunit.Abstractions; using Xunit.Abstractions;

View File

@ -1,6 +1,6 @@
using System.Data; using System.Data;
using System.Text; using System.Text;
using ConsoleApp2.Helpers; using MesETL.App.Helpers;
using MySqlConnector; using MySqlConnector;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;

View File

@ -1,4 +1,4 @@
using ConsoleApp2.Helpers; using MesETL.App.Helpers;
namespace TestProject1; namespace TestProject1;