|
|
|
|
using Admin.Core.Common;
|
|
|
|
|
using Admin.Core.IService.IService_New;
|
|
|
|
|
using Aucma.Core.DataCollector.Factory;
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Org.BouncyCastle.Crypto.Tls;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Core.DataCollector
|
|
|
|
|
{
|
|
|
|
|
public static class DataCollectorSetup
|
|
|
|
|
{
|
|
|
|
|
public static IApplicationBuilder UseDataCollectorExtensions(this IApplicationBuilder app)
|
|
|
|
|
{
|
|
|
|
|
if (app == null) throw new ArgumentNullException(nameof(app));
|
|
|
|
|
|
|
|
|
|
var stationCode = Appsettings.app("StationInfo", "StationCode");
|
|
|
|
|
|
|
|
|
|
var _deviceParamServices = app.ApplicationServices.GetService<IBaseDeviceParamServices>();
|
|
|
|
|
var _deviceAlarmInfoServices = app.ApplicationServices.GetService<IRecordDeviceAlarmInfoServices>();
|
|
|
|
|
var _deviceElectricityServices = app.ApplicationServices.GetService< IRecordDeviceElectricityServices>();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(stationCode))
|
|
|
|
|
{
|
|
|
|
|
if(stationCode == "1002") //箱壳、内胆,包含预装线、集存库
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
DataCollectorFactory collector = new ShellStoreFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
|
|
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
DataCollectorFactory collector = new LinerStoreFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
|
|
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
|
|
|
});
|
|
|
|
|
}else if(stationCode == "1005")//泡前库、发泡线、发泡机、泡后库
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
DataCollectorFactory collector = new BoxFoamFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
|
|
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
|
|
|
});
|
|
|
|
|
}else if(stationCode == "1010")//成品分垛
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
DataCollectorFactory collector = new PalletizFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
|
|
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return app;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|