|
|
|
|
using System.Reflection;
|
|
|
|
|
using Com.Ctrip.Framework.Apollo;
|
|
|
|
|
using Flurl.Http;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using NeoSmart.Caching.Sqlite;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Sln.Wcs.HikRoBotAdapter.Domain.Dto.GbTaskSubmit;
|
|
|
|
|
using Sln.Wcs.HikRoBotAdapter.Domain.Dto.GenAgvSchedulingTask;
|
|
|
|
|
using Sln.Wcs.HikRoBotAdapter.Service;
|
|
|
|
|
using Sln.Wcs.HikRoBotAdapter.Service.Impl;
|
|
|
|
|
using Sln.Wcs.HoistSdk;
|
|
|
|
|
using Sln.Wcs.HoistSdk.Dto.GetHoistStatus;
|
|
|
|
|
using Sln.Wcs.Model.Domain;
|
|
|
|
|
using Sln.Wcs.Repository;
|
|
|
|
|
using Sln.Wcs.Serilog;
|
|
|
|
|
using Sln.Wcs.Plc;
|
|
|
|
|
using Sln.Wcs.Repository.service;
|
|
|
|
|
using Sln.Wcs.Strategy;
|
|
|
|
|
using ZiggyCreatures.Caching.Fusion;
|
|
|
|
|
using ZiggyCreatures.Caching.Fusion.Serialization.NewtonsoftJson;
|
|
|
|
|
using TargetRoute = Sln.Wcs.HikRoBotAdapter.Domain.Dto.GbTaskSubmit.TargetRoute;
|
|
|
|
|
|
|
|
|
|
namespace Sln.Wcs
|
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
static async Task Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
|
|
|
|
|
|
ConfigureServices(services);
|
|
|
|
|
|
|
|
|
|
var serviceProvider = services.BuildServiceProvider();
|
|
|
|
|
|
|
|
|
|
serviceProvider.UseSerilogExtensions();
|
|
|
|
|
var config = serviceProvider.GetService<IConfiguration>();
|
|
|
|
|
var log = serviceProvider.GetService<SerilogHelper>();
|
|
|
|
|
|
|
|
|
|
log.Info($"系统启动成功,日志存放位置:{config["logPath"]}");
|
|
|
|
|
|
|
|
|
|
//禁用 SSL
|
|
|
|
|
FlurlHttp.ConfigureClientForUrl("https://172.16.12.11")
|
|
|
|
|
.ConfigureInnerHandler(handler =>
|
|
|
|
|
{
|
|
|
|
|
handler.ServerCertificateCustomValidationCallback = (_, _, _, _) => true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// var service = serviceProvider.GetService<HikRoBotService>();
|
|
|
|
|
// var res = service.GbTaskSubmit(new GbTaskSubmitDto()
|
|
|
|
|
// {
|
|
|
|
|
// TaskType = "PF-FMR-COMMON",
|
|
|
|
|
// TargetRoute = new List<TargetRoute>()
|
|
|
|
|
// {
|
|
|
|
|
// new TargetRoute(){Type = "STORAGE",Code = "R5001A02011"},
|
|
|
|
|
// new TargetRoute(){Type = "STORAGE",Code = "R5001A01011"}
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
var service = serviceProvider.GetService<IHoistSdk>();
|
|
|
|
|
service.GetHoistStatus(new GetHoistStatusDto());
|
|
|
|
|
|
|
|
|
|
Task.Delay(-1).Wait();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
var basePath = AppContext.BaseDirectory;
|
|
|
|
|
|
|
|
|
|
ApolloConfigureServices(services,ref basePath,out IConfiguration apolloConfiguration);
|
|
|
|
|
|
|
|
|
|
Assembly[] assemblies = {
|
|
|
|
|
Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.Common.dll")),
|
|
|
|
|
Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.Cache.dll")),
|
|
|
|
|
Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.Repository.dll")),
|
|
|
|
|
Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.HikRoBotAdapter.dll")),
|
|
|
|
|
Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.HikRoBotSdk.dll")),
|
|
|
|
|
Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.HoistAdapter.dll")),
|
|
|
|
|
Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.HoistSdk.dll")),
|
|
|
|
|
Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.Plc.dll")),
|
|
|
|
|
Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.Business.dll")),
|
|
|
|
|
Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.Strategy.dll")),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
services.Scan(scan => scan.FromAssemblies(assemblies)
|
|
|
|
|
.AddClasses()
|
|
|
|
|
.AsImplementedInterfaces()
|
|
|
|
|
.AsSelf()
|
|
|
|
|
.WithTransientLifetime());
|
|
|
|
|
|
|
|
|
|
services.AddSingleton(typeof(SerilogHelper));
|
|
|
|
|
|
|
|
|
|
services.AddSingleton(typeof(MaterialInStoreTest));
|
|
|
|
|
|
|
|
|
|
services.AddSqlSugarSetup();
|
|
|
|
|
|
|
|
|
|
services.AddPlcSetup();
|
|
|
|
|
|
|
|
|
|
services.AddFusionCache()
|
|
|
|
|
.WithSerializer(
|
|
|
|
|
new FusionCacheNewtonsoftJsonSerializer()
|
|
|
|
|
)
|
|
|
|
|
.WithDistributedCache(new SqliteCache(new SqliteCacheOptions
|
|
|
|
|
{
|
|
|
|
|
CachePath = apolloConfiguration["cachePath"]
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Apollo 配置中心
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="services"></param>
|
|
|
|
|
/// <param name="basePath"></param>
|
|
|
|
|
/// <param name="apolloConfiguration"></param>
|
|
|
|
|
private static void ApolloConfigureServices(IServiceCollection services, ref string basePath, out IConfiguration apolloConfiguration)
|
|
|
|
|
{
|
|
|
|
|
var localConfiguration = new ConfigurationBuilder()
|
|
|
|
|
.SetBasePath(basePath)
|
|
|
|
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var apolloConfigSection = localConfiguration.GetSection("apollo");
|
|
|
|
|
|
|
|
|
|
services.AddSingleton<IConfiguration>(localConfiguration);
|
|
|
|
|
|
|
|
|
|
var configurationBuilder = new ConfigurationBuilder()
|
|
|
|
|
.SetBasePath(basePath)
|
|
|
|
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
|
|
|
|
.AddApollo(apolloConfigSection)
|
|
|
|
|
.AddDefault();
|
|
|
|
|
|
|
|
|
|
apolloConfiguration = configurationBuilder.Build();
|
|
|
|
|
|
|
|
|
|
services.Remove(new ServiceDescriptor(typeof(IConfiguration), localConfiguration));
|
|
|
|
|
|
|
|
|
|
services.AddSingleton<IConfiguration>(apolloConfiguration);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|