- 工作台成员扫码登入:workstation_login_records 记录谁在什么时候登入/下线了哪台工作台, 超时(团购 1h / 散单 30min)由 schedule/workstation_idle_offline 自动下线; 运单查询的 packers 取当时的登入成员 - 面单摄像头识别:workstation_cameras.is_label_camera + service/label_scan 下发本机该跑的识别配置, 设备端(桌面端 LabelScan 工作线程)按配置做面单识别并上报 - 虚拟通道 CAM-<工作台id>:工作台没接扫码枪时,面单摄像头那一路顶替扫码枪上报,records 规则按 ws_type 区分 - 桌面端:新增 LabelScanMonitor/LabelScanWorker/ScanDeviceKind 与面单预览页,扫描通道支持改名,静默窗口 5s Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
107 lines
4.5 KiB
C#
107 lines
4.5 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Windows;
|
||
using System.Windows.Media;
|
||
using YuncangTrace.LocalService.Services.Scan;
|
||
|
||
namespace YuncangTrace.LocalService;
|
||
|
||
/// <summary>
|
||
/// 「添加通道」弹窗:设置**通道号**与**设备名**(与 AndroidScanCenter 的添加流程一致)。
|
||
///
|
||
/// - 通道号是本地概念(现场认工位用),被占用的号照样列出来、只标注谁占着
|
||
/// —— 直接藏掉的话现场看到「怎么就没有 3 号」还得来问一遍;
|
||
/// - 设备名会写进设备本身(SYS.HostName),默认填设备自报的名字。
|
||
/// </summary>
|
||
public partial class AddChannelWindow : Window
|
||
{
|
||
/// <summary>下拉框选项(带占用标注)</summary>
|
||
public sealed class NumberOption
|
||
{
|
||
public int Number { get; init; }
|
||
public string Label { get; init; } = string.Empty;
|
||
public bool Taken { get; init; }
|
||
}
|
||
|
||
private readonly IReadOnlyList<ScanChannel> _channels;
|
||
|
||
public AddChannelWindow(DiscoveredDevice device, IReadOnlyList<ScanChannel> channels)
|
||
{
|
||
InitializeComponent();
|
||
|
||
_channels = channels;
|
||
|
||
var reported = (device.HostName ?? string.Empty).Trim();
|
||
DeviceText.Text = reported.Length == 0
|
||
? $"{device.Mac} · {device.Ip} · {device.Model}"
|
||
: $"{reported}({device.Mac} · {device.Ip} · {device.Model})";
|
||
|
||
if (device.IsAndroidStation)
|
||
{
|
||
KindBadge.Background = new SolidColorBrush(Color.FromRgb(0xEF, 0xF6, 0xFF));
|
||
KindBadge.BorderBrush = new SolidColorBrush(Color.FromRgb(0xBF, 0xDB, 0xFE));
|
||
KindText.Foreground = new SolidColorBrush(Color.FromRgb(0x1D, 0x4E, 0xD8));
|
||
KindText.Text = "安卓扫描通道 · 摄像头识别到条码时会收到通知并播报「扫码成功」";
|
||
}
|
||
else
|
||
{
|
||
KindBadge.Background = new SolidColorBrush(Color.FromRgb(0xF8, 0xFA, 0xFC));
|
||
KindBadge.BorderBrush = new SolidColorBrush(Color.FromRgb(0xE2, 0xE8, 0xF0));
|
||
KindText.Foreground = new SolidColorBrush(Color.FromRgb(0x64, 0x74, 0x8B));
|
||
KindText.Text = "普通扫码枪通道 · 设备无语音能力,不发通知(扫码记录照常上报)";
|
||
}
|
||
|
||
// 默认名:设备自报的 HostName(通常就是工位名),没有就用 MAC
|
||
var defaultName = reported.Length == 0 ? device.Mac : reported;
|
||
NameBox.Text = defaultName;
|
||
|
||
var suggested = ChannelStore.NextNumber(channels);
|
||
var options = new List<NumberOption>();
|
||
for (var number = 1; number <= ChannelStore.MaxNumber; number++)
|
||
{
|
||
var owner = ChannelStore.FindByNumber(channels, number);
|
||
options.Add(new NumberOption
|
||
{
|
||
Number = number,
|
||
Taken = owner is not null,
|
||
Label = owner is null ? number.ToString() : $"{number}(已被「{owner.DisplayName}」占用)",
|
||
});
|
||
}
|
||
NumberBox.ItemsSource = options;
|
||
NumberBox.SelectedItem = options.FirstOrDefault(item => item.Number == suggested) ?? options[0];
|
||
|
||
HintText.Text = $"添加时会先检查并确保设备上有给中控用的 TCP 服务(条目 {ScanProtocol.SockName}、端口 {ScanProtocol.TcpPort},"
|
||
+ "与 Android 中控的 8086 分开),设备名有变化会写入设备并落盘";
|
||
}
|
||
|
||
/// <summary>用户选的通道号(确定后有值)</summary>
|
||
public int ChannelNumber { get; private set; }
|
||
|
||
/// <summary>用户填的设备名(确定后有值,可能为空 = 用设备自报名)</summary>
|
||
public string ChannelName { get; private set; } = string.Empty;
|
||
|
||
private void Ok_Click(object sender, RoutedEventArgs e)
|
||
{
|
||
if (NumberBox.SelectedItem is not NumberOption option)
|
||
{
|
||
MessageBox.Show(this, "请先选择通道号", "添加通道", MessageBoxButton.OK, MessageBoxImage.Information);
|
||
return;
|
||
}
|
||
|
||
// 已被占用:只提示、不关框,用户可以接着选(与 AndroidScanCenter 一致)
|
||
if (option.Taken)
|
||
{
|
||
MessageBox.Show(this, $"通道号 {option.Number} 已经被占用了,请换一个号", "添加通道",
|
||
MessageBoxButton.OK, MessageBoxImage.Warning);
|
||
return;
|
||
}
|
||
|
||
ChannelNumber = option.Number;
|
||
ChannelName = (NameBox.Text ?? string.Empty).Trim();
|
||
DialogResult = true;
|
||
}
|
||
|
||
private void Cancel_Click(object sender, RoutedEventArgs e) => DialogResult = false;
|
||
}
|