|
|
@ -4,6 +4,7 @@ using Admin.Core.Model;
|
|
|
|
using Admin.Core.Model.Model_New;
|
|
|
|
using Admin.Core.Model.Model_New;
|
|
|
|
using log4net;
|
|
|
|
using log4net;
|
|
|
|
using Serilog;
|
|
|
|
using Serilog;
|
|
|
|
|
|
|
|
using SqlSugar;
|
|
|
|
using StackExchange.Profiling.Internal;
|
|
|
|
using StackExchange.Profiling.Internal;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Timers;
|
|
|
|
using System.Timers;
|
|
|
@ -24,15 +25,15 @@ namespace Aucma.Core.TemperatureTask
|
|
|
|
private readonly IMaterialCompletionServices _materialCompletionServices;
|
|
|
|
private readonly IMaterialCompletionServices _materialCompletionServices;
|
|
|
|
private readonly IPrintBarCodeServices _printBarCodeServices;
|
|
|
|
private readonly IPrintBarCodeServices _printBarCodeServices;
|
|
|
|
private readonly IReportQualityInspectionServices _reportQualityInspectionServices;
|
|
|
|
private readonly IReportQualityInspectionServices _reportQualityInspectionServices;
|
|
|
|
|
|
|
|
private ISqlSugarClient sqlSugarClient;
|
|
|
|
|
|
|
|
|
|
|
|
System.Timers.Timer timer1 = new System.Timers.Timer(5000);
|
|
|
|
System.Timers.Timer timer1 = new System.Timers.Timer(5000);
|
|
|
|
bool flag = true;
|
|
|
|
bool flag = true;
|
|
|
|
public AucamTemperatureMeasurementService(ITemperatureHistoryServices temperatureHistoryServices,
|
|
|
|
public AucamTemperatureMeasurementService(ITemperatureHistoryServices temperatureHistoryServices,
|
|
|
|
ITestedCodeMESServices codeMESServices, IMaterialCompletionServices materialCompletionServices,
|
|
|
|
ITestedCodeMESServices codeMESServices, IMaterialCompletionServices materialCompletionServices,
|
|
|
|
IPrintBarCodeServices printBarCodeServices, IReportQualityInspectionServices reportQualityInspectionServices)
|
|
|
|
IPrintBarCodeServices printBarCodeServices, IReportQualityInspectionServices reportQualityInspectionServices, ISqlSugarClient _sqlSugarClient)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_codeMESServices = codeMESServices;
|
|
|
|
sqlSugarClient = _sqlSugarClient;
|
|
|
|
|
|
|
|
_codeMESServices = codeMESServices;
|
|
|
|
_temperatureHistoryServices = temperatureHistoryServices;
|
|
|
|
_temperatureHistoryServices = temperatureHistoryServices;
|
|
|
|
_materialCompletionServices = materialCompletionServices;
|
|
|
|
_materialCompletionServices = materialCompletionServices;
|
|
|
|
_printBarCodeServices = printBarCodeServices;
|
|
|
|
_printBarCodeServices = printBarCodeServices;
|
|
|
@ -52,16 +53,18 @@ namespace Aucma.Core.TemperatureTask
|
|
|
|
/// 采集任务处理
|
|
|
|
/// 采集任务处理
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async void Run(object? sender, ElapsedEventArgs e)
|
|
|
|
private void Run(object? sender, ElapsedEventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (flag)
|
|
|
|
if (flag)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
flag = false;
|
|
|
|
flag = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sqlSugarClient.AsTenant().BeginTran();
|
|
|
|
var historyList = _codeMESServices.QueryAsync(d => d.IsSync == 0).Result;
|
|
|
|
var historyList = _codeMESServices.QueryAsync(d => d.IsSync == 0).Result;
|
|
|
|
if (historyList == null || historyList.Count == 0) return;
|
|
|
|
if (historyList == null || historyList.Count == 0) return;
|
|
|
|
Console.WriteLine($"【{DateTime.Now}】开始读取测温数据");
|
|
|
|
Console.WriteLine($"【{DateTime.Now}】开始读取测温数据");
|
|
|
@ -114,13 +117,19 @@ namespace Aucma.Core.TemperatureTask
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Console.WriteLine($"【{DateTime.Now}】测温数据同步成功!数量:{query.Count}");
|
|
|
|
Console.WriteLine($"【{DateTime.Now}】测温数据同步成功!数量:{query.Count}");
|
|
|
|
|
|
|
|
sqlSugarClient.AsTenant().CommitTran();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
sqlSugarClient.AsTenant().RollbackTran();
|
|
|
|
Console.WriteLine($"【{DateTime.Now}】 {ex.Message}");
|
|
|
|
Console.WriteLine($"【{DateTime.Now}】 {ex.Message}");
|
|
|
|
logHelper.Error(ex.Message);
|
|
|
|
logHelper.Error(ex.Message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally { flag = true; }
|
|
|
|
|
|
|
|
|
|
|
|
finally {
|
|
|
|
|
|
|
|
flag = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|