|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Threading;
|
|
|
using SlnMesnac.Business.@base;
|
|
|
using static Microsoft.WindowsAPICodePack.Shell.PropertySystem.SystemProperties.System;
|
|
|
using SlnMesnac.Repository.service;
|
|
|
using SlnMesnac.Repository;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
using Task = System.Threading.Tasks.Task;
|
|
|
using SlnMesnac.WPF.Page.IndexPage;
|
|
|
using System.Windows.Documents;
|
|
|
using SlnMesnac.TouchSocket;
|
|
|
using HslCommunication.Enthernet;
|
|
|
using SlnMesnac.Config;
|
|
|
using System.Threading;
|
|
|
using SlnMesnac.Common;
|
|
|
|
|
|
#region << 版 本 注 释 >>
|
|
|
/*--------------------------------------------------------------------
|
|
|
* 版权所有 (c) 2024 WenJY 保留所有权利。
|
|
|
* CLR版本:4.0.30319.42000
|
|
|
* 机器名称:T14-GEN3-7895
|
|
|
* 命名空间:SlnMesnac.WPF.ViewModel.IndexPage
|
|
|
* 唯一标识:ffdc8ddd-928f-4910-b6ac-d6d6426c39d0
|
|
|
*
|
|
|
* 创建者:WenJY
|
|
|
* 电子邮箱:
|
|
|
* 创建时间:2024-09-05 15:05:57
|
|
|
* 版本:V1.0.0
|
|
|
* 描述:
|
|
|
*
|
|
|
*--------------------------------------------------------------------
|
|
|
* 修改人:
|
|
|
* 时间:
|
|
|
* 修改说明:
|
|
|
*
|
|
|
* 版本:V1.0.0
|
|
|
*--------------------------------------------------------------------*/
|
|
|
#endregion << 版 本 注 释 >>
|
|
|
namespace SlnMesnac.WPF.ViewModel.IndexPage
|
|
|
{
|
|
|
public partial class IndexContentViewModel: ObservableObject
|
|
|
{
|
|
|
private ILogger<IndexContentViewModel> _logger;
|
|
|
private ILogger<BaseTaskInfoBusiness> _taskBusinessLogger;
|
|
|
//private ILogger<BaseStateRefreshBusiness> _stateBusinessLogger;
|
|
|
private IAirportTaskService _taskservice;
|
|
|
private IAGVStateService _agvstateService;
|
|
|
private BaseTaskInfoBusiness _taskInfoBusiness;
|
|
|
private DispatcherTimer _timer;
|
|
|
private TcpServer _tcpServer;
|
|
|
private AppConfig _appConfig;
|
|
|
private AirPorthttpClient _airPorthttpClient;
|
|
|
|
|
|
private Idata1_TableService _data1TableService;
|
|
|
private Idata2_TableService _data2TableService;
|
|
|
private Idata3_TableService _data3TableService;
|
|
|
private Idata4_TableService _data4TableService;
|
|
|
private IT_RP_StationPara_110_1Service _tr_stationPara_110_1Service;
|
|
|
private IT_RP_StationPara_110_2Service _tr_stationPara_110_2Service;
|
|
|
private IT_RP_StationPara_130Service _tr_stationPara_130Service;
|
|
|
private IT_RP_StationPara_160_1Service _tr_stationPara_160_1Service;
|
|
|
|
|
|
public IndexContentViewModel()
|
|
|
{
|
|
|
LogMessages = new ObservableCollection<string>();
|
|
|
_taskBusinessLogger = App.ServiceProvider.GetService<ILogger<BaseTaskInfoBusiness>>();
|
|
|
_taskservice = App.ServiceProvider.GetService<IAirportTaskService>();
|
|
|
_agvstateService = App.ServiceProvider.GetService<IAGVStateService>();
|
|
|
_tcpServer = App.ServiceProvider.GetService<TcpServer>();
|
|
|
_appConfig = App.ServiceProvider.GetService<AppConfig>();
|
|
|
_airPorthttpClient = App.ServiceProvider.GetService<AirPorthttpClient>();
|
|
|
|
|
|
_data1TableService = App.ServiceProvider.GetService<Idata1_TableService>();
|
|
|
_data2TableService = App.ServiceProvider.GetService<Idata2_TableService>();
|
|
|
_data3TableService = App.ServiceProvider.GetService<Idata3_TableService>();
|
|
|
_data4TableService = App.ServiceProvider.GetService<Idata4_TableService>();
|
|
|
|
|
|
_tr_stationPara_110_1Service = App.ServiceProvider.GetService<IT_RP_StationPara_110_1Service>();
|
|
|
_tr_stationPara_110_2Service = App.ServiceProvider.GetService<IT_RP_StationPara_110_2Service>();
|
|
|
_tr_stationPara_130Service = App.ServiceProvider.GetService<IT_RP_StationPara_130Service>();
|
|
|
_tr_stationPara_160_1Service = App.ServiceProvider.GetService<IT_RP_StationPara_160_1Service>();
|
|
|
_logger = App.ServiceProvider.GetService<ILogger<IndexContentViewModel>>();
|
|
|
|
|
|
//_taskInfoBusiness = BaseTaskInfoBusiness.GetInstance(_taskBusinessLogger, _taskservice, _agvstateService, _tcpServer, _airPorthttpClient);
|
|
|
//_taskInfoBusiness._RefreshLogMessageAction += RefreshLogMessage;
|
|
|
//_taskInfoBusiness._Taskaction += task =>
|
|
|
//{
|
|
|
// if (task != null)
|
|
|
// {
|
|
|
// var x = TaskItems.ToList().Find(x => x.conveyorno == task.conveyorno);
|
|
|
// if (x != null)
|
|
|
// {
|
|
|
// x.id = task.id;
|
|
|
// x.taskno = task.taskno;
|
|
|
// x.flightno = task.flightno;
|
|
|
// x.manipulatorno = task.manipulatorno;
|
|
|
// x.agvno = task.agvno;
|
|
|
// x.taskstate = task.taskstate;
|
|
|
// TaskItems = new ObservableCollection<AirportTask>(TaskItems);
|
|
|
|
|
|
// }
|
|
|
// }
|
|
|
//};
|
|
|
this.Init();
|
|
|
}
|
|
|
|
|
|
private async void LoadTaskInfo()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DateTime start = Convert.ToDateTime(DateTime.Now.ToString("D").ToString());
|
|
|
DateTime end = Convert.ToDateTime(DateTime.Now.AddDays(1).ToString("D").ToString()).AddSeconds(-1);
|
|
|
List<data1_Table> _data1Tables = _data1TableService.Getdata1TableListAsync().Result;
|
|
|
if (_data1Tables != null && _data1Tables.Count > 0)
|
|
|
{
|
|
|
foreach (var data1Table in _data1Tables)
|
|
|
{
|
|
|
T_RP_StationPara_110_1 T_RP_StationPara_110_1 = new T_RP_StationPara_110_1()
|
|
|
{
|
|
|
semibarcode = data1Table.dpqrcode,
|
|
|
scanbarcode = data1Table.jpqrcode,
|
|
|
state = data1Table.etotaljudge == "OK" ? "1" : "2",
|
|
|
para1 = data1Table.evalue,
|
|
|
para2 = data1Table.erangevalue,
|
|
|
para3 = data1Table.erank,
|
|
|
para4 = data1Table.bprank,
|
|
|
para5 = data1Table.e1value,
|
|
|
para6 = data1Table.e2value,
|
|
|
para7 = data1Table.e3value,
|
|
|
para8 = data1Table.e4value,
|
|
|
inserttime = DateTime.Parse(data1Table.time)
|
|
|
};
|
|
|
bool insertflag = false;
|
|
|
var GetFlag = await _tr_stationPara_110_1Service.GetResultAsync(data1Table.jpqrcode, data1Table.dpqrcode);
|
|
|
if (GetFlag != null)
|
|
|
{
|
|
|
T_RP_StationPara_110_1.id = GetFlag.id;
|
|
|
insertflag = _tr_stationPara_110_1Service.Update(T_RP_StationPara_110_1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
insertflag = _tr_stationPara_110_1Service.Insert(T_RP_StationPara_110_1);
|
|
|
}
|
|
|
if (insertflag)
|
|
|
{
|
|
|
data1Table.flag = "F";
|
|
|
var iflag = _data1TableService.UpdateAsync(data1Table).Result;
|
|
|
if (iflag)
|
|
|
{
|
|
|
Console.WriteLine(StringChange.ModeToJson(data1Table));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
_logger.LogError($"异常:{ex.Message}");
|
|
|
}
|
|
|
}
|
|
|
private async void LoadEDataInfo()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DateTime start = Convert.ToDateTime(DateTime.Now.ToString("D").ToString());
|
|
|
DateTime end = Convert.ToDateTime(DateTime.Now.AddDays(1).ToString("D").ToString()).AddSeconds(-1);
|
|
|
List<data2_Table> _data1Tables = _data2TableService.Getdata2TableListAsync(start, end).Result;
|
|
|
Console.WriteLine(_data1Tables.Count);
|
|
|
if (_data1Tables != null && _data1Tables.Count > 0)
|
|
|
{
|
|
|
for (global::System.Int32 i = 0; i < _data1Tables.Count; i++)
|
|
|
{
|
|
|
T_RP_StationPara_110_2 t_RP_StationPara_110_2 = new T_RP_StationPara_110_2()
|
|
|
{
|
|
|
scanbarcode = _data1Tables[i].qrcode,
|
|
|
state = _data1Tables[i].totaljudge == "OK" ? "1" : "2",
|
|
|
para1 = _data1Tables[i].f1value,
|
|
|
para1State = _data1Tables[i].f1judge == "OK" ? "1" : "2",
|
|
|
para2 = _data1Tables[i].f2value,
|
|
|
para2State = _data1Tables[i].f2judge == "OK" ? "1" : "2",
|
|
|
para3 = _data1Tables[i].f3value,
|
|
|
para3State = _data1Tables[i].f3judge == "OK" ? "1" : "2",
|
|
|
para4 = _data1Tables[i].f4value,
|
|
|
para4State = _data1Tables[i].f4judge == "OK" ? "1" : "2",
|
|
|
para5 = _data1Tables[i].frangevalue,
|
|
|
para5State = _data1Tables[i].frange == "OK" ? "1" : "2",
|
|
|
inserttime = _data1Tables[i].time
|
|
|
|
|
|
};
|
|
|
var GetFlag = await _tr_stationPara_110_2Service.GetResultAsync(_data1Tables[i].qrcode);
|
|
|
bool insertflag = false;
|
|
|
//存在相同测量数据则更新
|
|
|
if (GetFlag != null)
|
|
|
{
|
|
|
t_RP_StationPara_110_2.id = GetFlag.id;
|
|
|
insertflag = await _tr_stationPara_110_2Service.UpdateResultAsync(t_RP_StationPara_110_2);
|
|
|
}
|
|
|
//反之则插入
|
|
|
else
|
|
|
{
|
|
|
insertflag = await _tr_stationPara_110_2Service.AddTaskAsync(t_RP_StationPara_110_2);
|
|
|
}
|
|
|
if (insertflag)
|
|
|
{
|
|
|
_data1Tables[i].flag = "F";
|
|
|
var iflag = _data2TableService.UpdateAsync(_data1Tables[i]).Result;
|
|
|
if (iflag)
|
|
|
{
|
|
|
Console.WriteLine(StringChange.ModeToJson(_data1Tables[i]));
|
|
|
_logger.LogDebug(StringChange.ModeToJson(_data1Tables[i]));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
_logger.LogError($"异常:{ex.Message}");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private async void LoadFDataInfo()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DateTime start = Convert.ToDateTime(DateTime.Now.ToString("D").ToString());
|
|
|
DateTime end = Convert.ToDateTime(DateTime.Now.AddDays(1).ToString("D").ToString()).AddSeconds(-1);
|
|
|
List<data2_Table> _data1Tables = _data2TableService.Getdata2TableListAsync(start, end).Result;
|
|
|
Console.WriteLine(_data1Tables.Count);
|
|
|
if (_data1Tables != null && _data1Tables.Count > 0)
|
|
|
{
|
|
|
for (global::System.Int32 i = 0; i < _data1Tables.Count; i++)
|
|
|
{
|
|
|
T_RP_StationPara_110_2 t_RP_StationPara_110_2 = new T_RP_StationPara_110_2()
|
|
|
{
|
|
|
scanbarcode = _data1Tables[i].qrcode,
|
|
|
state = _data1Tables[i].totaljudge == "OK" ? "1" : "2",
|
|
|
para1 = _data1Tables[i].f1value,
|
|
|
para1State = _data1Tables[i].f1judge == "OK" ? "1" : "2",
|
|
|
para2 = _data1Tables[i].f2value,
|
|
|
para2State = _data1Tables[i].f2judge == "OK" ? "1" : "2",
|
|
|
para3 = _data1Tables[i].f3value,
|
|
|
para3State = _data1Tables[i].f3judge == "OK" ? "1" : "2",
|
|
|
para4 = _data1Tables[i].f4value,
|
|
|
para4State = _data1Tables[i].f4judge == "OK" ? "1" : "2",
|
|
|
para5 = _data1Tables[i].frangevalue,
|
|
|
para5State = _data1Tables[i].frange == "OK" ? "1" : "2",
|
|
|
inserttime = _data1Tables[i].time,
|
|
|
uploadflag = "0",
|
|
|
finalflag = "1",
|
|
|
|
|
|
};
|
|
|
//查询是否同条码多次测量
|
|
|
|
|
|
bool insertflag = await _tr_stationPara_110_2Service.AddTaskAsync(t_RP_StationPara_110_2);
|
|
|
|
|
|
if (insertflag)
|
|
|
{
|
|
|
_data1Tables[i].flag = "F";
|
|
|
var iflag = _data2TableService.UpdateAsync(_data1Tables[i]).Result;
|
|
|
if (iflag)
|
|
|
{
|
|
|
_logger.LogInformation(StringChange.ModeToJson(_data1Tables[i]));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
_logger.LogError($"异常:{ex.Message}");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private async void LoadHDataInfo()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DateTime start = Convert.ToDateTime(DateTime.Now.ToString("D").ToString());
|
|
|
DateTime end = Convert.ToDateTime(DateTime.Now.AddDays(1).ToString("D").ToString()).AddSeconds(-1);
|
|
|
List<data3_Table> _data1Tables = _data3TableService.GetTableListAsync(start, end).Result;
|
|
|
Console.WriteLine(_data1Tables.Count);
|
|
|
if (_data1Tables != null && _data1Tables.Count > 0)
|
|
|
{
|
|
|
foreach (var data1Table in _data1Tables)
|
|
|
{
|
|
|
T_RP_StationPara_130 T_RP_StationPara_110_1 = new T_RP_StationPara_130()
|
|
|
{
|
|
|
scanbarcode = data1Table.qrcode,
|
|
|
state = data1Table.totaljudge == "OK" ? "1" : "2",
|
|
|
para1 = data1Table.h1value,
|
|
|
para1State = data1Table.h1judge == "OK" ? "1" : "2",
|
|
|
para2 = data1Table.h2value,
|
|
|
para2State = data1Table.h2judge == "OK" ? "1" : "2",
|
|
|
para3 = data1Table.h3value,
|
|
|
para3State = data1Table.h3judge == "OK" ? "1" : "2",
|
|
|
para4 = data1Table.h4value,
|
|
|
para4State = data1Table.h4judge == "OK" ? "1" : "2",
|
|
|
para5 = data1Table.hrangevalue,
|
|
|
para5State = data1Table.hrangejudge == "OK" ? "1" : "2",
|
|
|
inserttime = data1Table.time,
|
|
|
uploadflag = "0",
|
|
|
finalflag = "1",
|
|
|
};
|
|
|
bool insertflag = false;
|
|
|
var GetFlag = await _tr_stationPara_130Service.GetResultAsync(data1Table.qrcode);
|
|
|
if (GetFlag != null)
|
|
|
{
|
|
|
T_RP_StationPara_110_1.id = GetFlag.id;
|
|
|
insertflag = _tr_stationPara_130Service.Update(T_RP_StationPara_110_1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
insertflag = _tr_stationPara_130Service.Insert(T_RP_StationPara_110_1);
|
|
|
}
|
|
|
if (insertflag)
|
|
|
{
|
|
|
data1Table.flag = "F";
|
|
|
var iflag = _data3TableService.UpdateAsync(data1Table).Result;
|
|
|
if (iflag)
|
|
|
{
|
|
|
_logger.LogInformation(StringChange.ModeToJson(data1Table));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
_logger.LogError($"异常:{ex.Message}");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
private async void LoadLSHDataInfo()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DateTime start = Convert.ToDateTime(DateTime.Now.ToString("D").ToString());
|
|
|
DateTime end = Convert.ToDateTime(DateTime.Now.AddDays(1).ToString("D").ToString()).AddSeconds(-1);
|
|
|
List<data4_Table> _data1Tables = _data4TableService.GetTableListAsync(start, end).Result;
|
|
|
if (_data1Tables != null && _data1Tables.Count > 0)
|
|
|
{
|
|
|
foreach (var data1Table in _data1Tables)
|
|
|
{
|
|
|
T_RP_StationPara_160_1 T_RP_StationPara_110_1 = new T_RP_StationPara_160_1()
|
|
|
{
|
|
|
scanbarcode = data1Table.qrcode,
|
|
|
state = data1Table.totaljudge == "OK" ? "1" : "2",
|
|
|
para1 = data1Table.lsh1value,
|
|
|
para1State = data1Table.lsh1judge == "OK" ? "1" : "2",
|
|
|
para2 = data1Table.lsh2value,
|
|
|
para2State = data1Table.lsh2judge == "OK" ? "1" : "2",
|
|
|
para3 = data1Table.lsh3value,
|
|
|
para3State = data1Table.lsh3judge == "OK" ? "1" : "2",
|
|
|
para4 = data1Table.lsh4value,
|
|
|
para4State = data1Table.lsh4judge == "OK" ? "1" : "2",
|
|
|
para5 = data1Table.lsh5value,
|
|
|
para5State = data1Table.lsh5judge == "OK" ? "1" : "2",
|
|
|
para6 = data1Table.hrangevalue,
|
|
|
para6State = data1Table.hrangejudge == "OK" ? "1" : "2",
|
|
|
inserttime = data1Table.time,
|
|
|
uploadflag = "0",
|
|
|
finalflag = "1",
|
|
|
};
|
|
|
bool insertflag = false;
|
|
|
var GetFlag = await _tr_stationPara_160_1Service.GetResultAsync(data1Table.qrcode);
|
|
|
if (GetFlag != null)
|
|
|
{
|
|
|
T_RP_StationPara_110_1.id = GetFlag.id;
|
|
|
insertflag = _tr_stationPara_160_1Service.Update(T_RP_StationPara_110_1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
insertflag = _tr_stationPara_160_1Service.Insert(T_RP_StationPara_110_1);
|
|
|
}
|
|
|
if (insertflag)
|
|
|
{
|
|
|
data1Table.flag = "F";
|
|
|
var iflag = _data4TableService.UpdateAsync(data1Table).Result;
|
|
|
if (iflag)
|
|
|
{
|
|
|
_logger.LogInformation(StringChange.ModeToJson(data1Table));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
_logger.LogError($"异常:{ex.Message}");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
private void Init()
|
|
|
{
|
|
|
#region 测试数据
|
|
|
//LoadHDataInfo();
|
|
|
//LoadEDataInfo();
|
|
|
//LoadTaskInfo();
|
|
|
//Thread.Sleep(5000);
|
|
|
|
|
|
//_tcpServer.SendReplyGetManualException(
|
|
|
// _appConfig.visionConfig.Where(x => x.VisionPort == 7001).First().VisionPort.ToString()
|
|
|
// );
|
|
|
|
|
|
//_StateRefreshBusiness.UpdateManipulatorStateByResposne(
|
|
|
// new Model.AirportApiEntity.ManipulatorStateRequestEntity()
|
|
|
// { ManipulatorNo = "1", SignalSendTime = DateTime.Now.ToString()});
|
|
|
//List<AirportTask> AirportTaskItem = _taskservice.GetTaskInfos();
|
|
|
//TaskItems = new ObservableCollection<AirportTask>(AirportTaskItem);
|
|
|
// TaskItems = new ObservableCollection<AirportTask>
|
|
|
// {
|
|
|
// new AirportTask { TaskCode = "1", StationName = "1#站台", TaskDetails = "入库:P04->C01", Status = "任务状态:执行中" },
|
|
|
// new TaskItem { TaskCode = "2", StationName = "2#站台", TaskDetails = "入库:P04->C01", Status = "任务状态:执行中" },
|
|
|
// new TaskItem { TaskCode = "3", StationName = "3#站台", TaskDetails = "入库:P04->C01", Status = "任务状态:执行中" },
|
|
|
// new TaskItem { TaskCode = "4", StationName = "4#站台", TaskDetails = "入库:P04->C01", Status = "任务状态:执行中" },
|
|
|
// new TaskItem { TaskCode = "5", StationName = "5#站台", TaskDetails = "入库:P04->C01", Status = "任务状态:执行中" },
|
|
|
// new TaskItem { TaskCode = "6", StationName = "6#站台", TaskDetails = "入库:P04->C01", Status = "任务状态:执行中" },
|
|
|
// };
|
|
|
|
|
|
//RefreshLogMessage($"1#站台任务下发站台任务下发站台任务下发站台任务下发站台任务下发站台任务下发");
|
|
|
//RefreshLogMessage($"2#站台任务下发");
|
|
|
//RefreshLogMessage($"3#站台任务下发");
|
|
|
//RefreshLogMessage($"4#站台任务下发");
|
|
|
//RefreshLogMessage($"5#站台任务下发");
|
|
|
//RefreshLogMessage($"6#站台任务下发");
|
|
|
//RefreshLogMessage($"7#站台任务下发");
|
|
|
//RefreshLogMessage($"2#站台任务下发");
|
|
|
//RefreshLogMessage($"3#站台任务下发");
|
|
|
//RefreshLogMessage($"4#站台任务下发");
|
|
|
//RefreshLogMessage($"5#站台任务下发");
|
|
|
//RefreshLogMessage($"6#站台任务下发");
|
|
|
//RefreshLogMessage($"7#站台任务下发");
|
|
|
|
|
|
//FlightItems = new ObservableCollection<FlightItem>
|
|
|
//{
|
|
|
// new FlightItem { flightNumber = "航班号:CZ3021", scheduledTime = "计划/变更:11:28", destination = "经停/目的:深圳",flightStatus="状态:到达",baggageClaim="转盘:1" },
|
|
|
// new FlightItem { flightNumber = "航班号:CZ3022", scheduledTime = "计划/变更:11:28", destination = "经停/目的:深圳",flightStatus="状态:到达",baggageClaim="转盘:1" },
|
|
|
// new FlightItem { flightNumber = "航班号:CZ3023", scheduledTime = "计划/变更:11:28", destination = "经停/目的:深圳",flightStatus="状态:到达",baggageClaim="转盘:1" },
|
|
|
// new FlightItem { flightNumber = "航班号:CZ3024", scheduledTime = "计划/变更:11:28", destination = "经停/目的:深圳",flightStatus="状态:到达",baggageClaim="转盘:1" },
|
|
|
// new FlightItem { flightNumber = "航班号:CZ3025", scheduledTime = "计划/变更:11:28", destination = "经停/目的:深圳",flightStatus="状态:到达",baggageClaim="转盘:1" },
|
|
|
// new FlightItem { flightNumber = "航班号:CZ3026", scheduledTime = "计划/变更:11:28", destination = "经停/目的:深圳",flightStatus="状态:到达",baggageClaim="转盘:1" },
|
|
|
// new FlightItem { flightNumber = "航班号:CZ3027", scheduledTime = "计划/变更:11:28", destination = "经停/目的:深圳",flightStatus="状态:到达",baggageClaim="转盘:1" },
|
|
|
//};
|
|
|
#endregion
|
|
|
|
|
|
#region 更新时间显示
|
|
|
_currentDateTime = DateTime.Now;
|
|
|
_timer = new DispatcherTimer
|
|
|
{
|
|
|
Interval = TimeSpan.FromSeconds(1) // 每秒更新一次
|
|
|
};
|
|
|
_timer.Tick += (s, e) =>
|
|
|
{
|
|
|
CurrentDateTime = DateTime.Now;
|
|
|
};
|
|
|
_timer.Start();
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public async void RefreshTaskItems(AirportTask airportTask)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
await Task.Run(async () =>
|
|
|
{
|
|
|
foreach (var VARIABLE in TaskItems)
|
|
|
{
|
|
|
if (VARIABLE.agvno == airportTask.conveyorno)
|
|
|
{
|
|
|
VARIABLE.taskstate = airportTask.taskstate;
|
|
|
VARIABLE.agvno = airportTask.agvno;
|
|
|
VARIABLE.totalcount = airportTask.totalcount;
|
|
|
VARIABLE.loadcount = airportTask.loadcount;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
}
|
|
|
#region 参数定义
|
|
|
/// <summary>
|
|
|
/// 任务列表
|
|
|
/// </summary>
|
|
|
private ObservableCollection<AirportTask> _taskItems = new ObservableCollection<AirportTask>();
|
|
|
public ObservableCollection<AirportTask> TaskItems
|
|
|
{
|
|
|
get => _taskItems;
|
|
|
set => SetProperty(ref _taskItems, value);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 日志信息
|
|
|
/// </summary>
|
|
|
private ObservableCollection<string> _logMessages = new ObservableCollection<string>();
|
|
|
|
|
|
public ObservableCollection<string> LogMessages
|
|
|
{
|
|
|
get => _logMessages;
|
|
|
set => SetProperty(ref _logMessages, value);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 日期时间
|
|
|
/// </summary>
|
|
|
private DateTime _currentDateTime;
|
|
|
public DateTime CurrentDateTime
|
|
|
{
|
|
|
get => _currentDateTime;
|
|
|
set
|
|
|
{
|
|
|
if (_currentDateTime != value)
|
|
|
{
|
|
|
SetProperty(ref _currentDateTime, value);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 航班信息
|
|
|
/// </summary>
|
|
|
private ObservableCollection<FlightItem> _flightItems = new ObservableCollection<FlightItem>();
|
|
|
public ObservableCollection<FlightItem> FlightItems
|
|
|
{
|
|
|
get => _flightItems;
|
|
|
set => SetProperty(ref _flightItems, value);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 刷新日志
|
|
|
/// </summary>
|
|
|
/// <param name="msg"></param>
|
|
|
public void RefreshLogMessage(string msg)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
App.Current.Dispatcher.BeginInvoke((Action)(() =>
|
|
|
{
|
|
|
LogMessages.Add($"{DateTime.Now}: {msg}");
|
|
|
while (LogMessages.Count > 120)
|
|
|
{
|
|
|
LogMessages.RemoveAt(0);
|
|
|
}
|
|
|
var orderedList = LogMessages.OrderByDescending(x => x); // 排序后转为 List
|
|
|
LogMessages = new ObservableCollection<string>(orderedList);
|
|
|
}));
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 系统运行日志输出
|
|
|
/// </summary>
|
|
|
/// <param name="message"></param>
|
|
|
private async void PrintMessageToListBox(string message)
|
|
|
{
|
|
|
await Task.Run(() =>
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string formattedMessage = $"{DateTime.Now.ToString("HH:mm:ss.ss")} ==> {message}";
|
|
|
|
|
|
lock (LogMessages)
|
|
|
{
|
|
|
LogMessages.Add(formattedMessage);
|
|
|
|
|
|
while (LogMessages.Count > 120)
|
|
|
{
|
|
|
LogMessages.RemoveAt(0);
|
|
|
}
|
|
|
|
|
|
var orderedList = LogMessages.OrderByDescending(x => x).ToList(); // 排序后转为 List
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
_logger.LogError($"日志数据绑定异常:{ex.Message}");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 添加任务
|
|
|
/// </summary>
|
|
|
[RelayCommand]
|
|
|
private void AddTask()
|
|
|
{
|
|
|
//生成任务号
|
|
|
//输入航班号
|
|
|
//任务状态默认等待
|
|
|
AddTaskContent AddTaskContent = new AddTaskContent();
|
|
|
AddTaskContent._Taskaction = task =>
|
|
|
{
|
|
|
if (task != null)
|
|
|
{
|
|
|
var x = TaskItems.ToList().Find(x => x.conveyorno == task.conveyorno);
|
|
|
if (x != null)
|
|
|
{
|
|
|
x.id = task.id;
|
|
|
x.taskno = task.taskno;
|
|
|
x.flightno = task.flightno;
|
|
|
x.manipulatorno = task.manipulatorno;
|
|
|
x.agvno = task.agvno;
|
|
|
x.taskstate = task.taskstate;
|
|
|
TaskItems = new ObservableCollection<AirportTask>(TaskItems);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
TaskItems.Add(task);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
AddTaskContent.ShowDialog();
|
|
|
if ((bool)AddTaskContent.DialogResult)
|
|
|
{
|
|
|
RefreshLogMessage("任务添加成功!");
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 处理任务
|
|
|
/// </summary>
|
|
|
/// <param name="taskCode"></param>
|
|
|
[RelayCommand]
|
|
|
private void HandleTask(AirportTask taskCode)
|
|
|
{
|
|
|
var info = taskCode;
|
|
|
if (info != null)
|
|
|
{
|
|
|
|
|
|
DetailTaskContent DetailTaskContent = new DetailTaskContent();
|
|
|
DetailTaskContent.AirportTask = taskCode;
|
|
|
DetailTaskContent.ShowDialog();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除任务
|
|
|
/// </summary>
|
|
|
/// <param name="taskCode"></param>
|
|
|
[RelayCommand]
|
|
|
private void DeleteTask(AirportTask task)
|
|
|
{
|
|
|
if (task.taskstate != "等待")
|
|
|
{
|
|
|
MessageBox.Show("任务已下发,不允许删除!");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (MessageBox.Show("请确认是否删除该任务?", "Confirm Message", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
|
|
{
|
|
|
//根据任务号删除任务
|
|
|
TaskItems.Remove(task);
|
|
|
//清表
|
|
|
_taskservice.DeleteTaskAsync(task);
|
|
|
//TaskItems = new ObservableCollection<AirportTask>(TaskItems);
|
|
|
//LoadTaskInfo();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 手动呼叫
|
|
|
/// </summary>
|
|
|
[RelayCommand]
|
|
|
private void ManualCall()
|
|
|
{
|
|
|
MessageBox.Show("手动呼叫");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 手动终止
|
|
|
/// </summary>
|
|
|
[RelayCommand]
|
|
|
private void ManualTerminate()
|
|
|
{
|
|
|
MessageBox.Show("手动终止");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 复位
|
|
|
/// </summary>
|
|
|
[RelayCommand]
|
|
|
private void Reset()
|
|
|
{
|
|
|
MessageBox.Show("复位");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|