整理代码
This commit is contained in:
@@ -62,47 +62,6 @@ async Task RunProgram()
|
||||
Console.WriteLine($"InputDir:{commandOptions?.InputDir}");
|
||||
|
||||
var oldestTime = DateTime.ParseExact(commandOptions.OldestTime, "yyyyMM", System.Globalization.DateTimeFormatInfo.InvariantInfo);
|
||||
//host.Services.Configure<InputTableOptions>(option =>
|
||||
//{
|
||||
// option.TableInfoConfig = new Dictionary<string, TableInfo>
|
||||
// {
|
||||
|
||||
// //order_block_plan_item从order_item表查询,然后程序插入
|
||||
// //order_package_item从order_item表查询,然后程序插入
|
||||
// //order_patch_detail生产没有这个表,不处理
|
||||
|
||||
|
||||
// {"machine",new TableInfo{SimulaRowCount=14655 }},
|
||||
// {"order",new TableInfo{SimulaRowCount=5019216 }},
|
||||
// {"order_block_plan",new TableInfo{SimulaRowCount=2725553 }},//CreateTime < 202301的删除
|
||||
// {"order_block_plan_result",new TableInfo{SimulaRowCount=1174096 }},
|
||||
// {"order_box_block",new TableInfo{SimulaRowCount=29755672 }},
|
||||
// {"order_data_block",new TableInfo{SimulaRowCount=731800334 }},
|
||||
// {"order_data_goods",new TableInfo{SimulaRowCount=25803671 }},
|
||||
// {"order_data_parts",new TableInfo{SimulaRowCount=468517543 }},
|
||||
// {"order_item",new TableInfo{SimulaRowCount=1345520079 }},
|
||||
// {"order_module",new TableInfo{SimulaRowCount=103325385 }},
|
||||
// {"order_module_extra",new TableInfo{SimulaRowCount=54361321 }},
|
||||
// {"order_module_item",new TableInfo{SimulaRowCount=69173339 }},
|
||||
// {"order_package",new TableInfo{SimulaRowCount=16196195 }},
|
||||
// {"order_process",new TableInfo{SimulaRowCount=3892685 }},//orderNo < 202301的
|
||||
// {"order_process_step",new TableInfo{SimulaRowCount=8050349 }},//orderNo < 202301的删除
|
||||
// {"order_process_step_item",new TableInfo{SimulaRowCount=14538058 }},//orderNo < 202301的删除
|
||||
// {"order_scrap_board",new TableInfo{SimulaRowCount=123998 }},
|
||||
// {"process_group",new TableInfo{SimulaRowCount=1253 }},
|
||||
// {"process_info",new TableInfo{SimulaRowCount=7839 }},
|
||||
// {"process_item_exp",new TableInfo{SimulaRowCount=28 }},
|
||||
// {"process_schdule_capacity",new TableInfo{SimulaRowCount=39736 }},
|
||||
// {"process_step_efficiency",new TableInfo{SimulaRowCount=8 }},
|
||||
// {"report_template",new TableInfo{SimulaRowCount=7337 }},
|
||||
// {"simple_package",new TableInfo{SimulaRowCount=130436 }},//orderNo < 202301的删除
|
||||
// {"simple_plan_order",new TableInfo{SimulaRowCount=351470 }},//CreateTime < 202301的删除
|
||||
// {"sys_config",new TableInfo{SimulaRowCount=2296 }},
|
||||
// {"work_calendar",new TableInfo{SimulaRowCount=11 }},
|
||||
// {"work_shift",new TableInfo{SimulaRowCount=59 }},
|
||||
// {"work_time",new TableInfo{SimulaRowCount=62 }},
|
||||
// };
|
||||
//});
|
||||
host.Services.Configure<CsvOptions>(option =>
|
||||
{
|
||||
option.Delimiter = ",";
|
||||
@@ -121,13 +80,17 @@ async Task RunProgram()
|
||||
|
||||
host.Services.Configure<DataTransformOptions>(options =>
|
||||
{
|
||||
if (commandOptions.IsMock) return;
|
||||
options.DatabaseFilter = record => "cferp_test";
|
||||
|
||||
options.TransformBinary = field => commandOptions != null && commandOptions.Isutf8mb4 ? $"_utf8mb4 0x{field}" : $"0x{field}";
|
||||
var noFilterTables = commandOptions.NoFilterTables.Split(",");
|
||||
//数据过滤
|
||||
options.RecordFilter = async (record, cache) =>
|
||||
{
|
||||
//var index = Array.IndexOf(record.Headers, "ShardKey");
|
||||
|
||||
if (noFilterTables.Contains(record.TableName)) return true;
|
||||
|
||||
if (record.TryGetField("ShardKey", out var skStr))
|
||||
{
|
||||
short.TryParse(skStr, out var sk);
|
||||
@@ -149,7 +112,7 @@ async Task RunProgram()
|
||||
if (dt < oldestTime) return false;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
return false;//订单号转换失败,跳过
|
||||
|
||||
@@ -175,9 +138,7 @@ async Task RunProgram()
|
||||
if (record.TableName == "order_process_step" || record.TableName == "order_process_step_item")
|
||||
{
|
||||
//如果缓存中不存在OrderProcessID,则丢弃
|
||||
//if(record.TryGetField("OrderProcessID",out var orderProcessID))
|
||||
|
||||
|
||||
if(record.TryGetField("OrderProcessID",out string orderProcessID))
|
||||
{
|
||||
var value = await cache.GetStringAsync($"order_process_{orderProcessID}");
|
||||
@@ -195,8 +156,6 @@ async Task RunProgram()
|
||||
var value = await cache.GetStringAsync($"order_block_plan_{id}");
|
||||
if (string.IsNullOrEmpty(value)) return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -486,7 +445,7 @@ async Task RunProgram()
|
||||
|
||||
host.Services.AddHostedService<MainHostedService>();
|
||||
host.Services.AddHostedService<TaskMonitorService>();
|
||||
host.Services.AddSingleton<IInputService,InputService>();
|
||||
host.Services.AddSingleton<IInputService,SimulationInputService>();
|
||||
host.Services.AddSingleton<ITransformService, TransformService>();
|
||||
host.Services.AddSingleton<IOutputService, OutputService>();
|
||||
var redisOptions = host.Configuration.GetSection("RedisCacheOptions").Get<RedisCacheOptions>() ?? new RedisCacheOptions();
|
||||
|
Reference in New Issue
Block a user