You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

246 lines
9.3 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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;
#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 IAirportTaskService _taskservice;
private IAGVStateService _agvstateService;
private BaseTaskInfoBusiness _taskInfoBusiness;
private DispatcherTimer _timer;
public IndexContentViewModel()
{
LogMessages = new ObservableCollection<string>();
_taskBusinessLogger = App.ServiceProvider.GetService<ILogger<BaseTaskInfoBusiness>>();
_taskservice = App.ServiceProvider.GetService<IAirportTaskService>();
_agvstateService = App.ServiceProvider.GetService<IAGVStateService>();
_taskInfoBusiness = BaseTaskInfoBusiness.GetInstance(_taskBusinessLogger, _taskservice, _agvstateService);
_taskInfoBusiness._Taskaction += task =>
{
TaskItems = new ObservableCollection<AirportTask>
{
task
};
};
this.Init();
}
private void Init()
{
#region 测试数据
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
}
#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>
private void RefreshLogMessage(string msg)
{
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
LogMessages.Add($"{DateTime.Now}: {msg}");
}));
}
/// <summary>
/// 添加任务
/// </summary>
[RelayCommand]
private void AddTask()
{
MessageBox.Show("添加任务");
}
/// <summary>
/// 处理任务
/// </summary>
/// <param name="taskCode"></param>
[RelayCommand]
private void HandleTask(string taskCode)
{
var info = taskCode;
}
/// <summary>
/// 删除任务
/// </summary>
/// <param name="taskCode"></param>
[RelayCommand]
private void DeleteTask(string taskCode)
{
var info = taskCode;
}
/// <summary>
/// 手动呼叫
/// </summary>
[RelayCommand]
private void ManualCall()
{
MessageBox.Show("手动呼叫");
}
/// <summary>
/// 手动终止
/// </summary>
[RelayCommand]
private void ManualTerminate()
{
MessageBox.Show("手动终止");
}
/// <summary>
/// 复位
/// </summary>
[RelayCommand]
private void Reset()
{
MessageBox.Show("复位");
}
}
}