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.

839 lines
33 KiB
C#

using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Microsoft.Win32;
using MiniExcelLibs;
using SlnMesnac.RfidUpload.NLog;
using SlnMesnac.RfidUpload.Business;
using SlnMesnac.RfidUpload.Common;
using SlnMesnac.RfidUpload.Model;
using SlnMesnac.RfidUpload.Model.apiParam;
using SlnMesnac.RfidUpload.Model.config;
using SlnMesnac.RfidUpload.TouchSocket;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using ApiServer = SlnMesnac.RfidUpload.TouchSocket.ApiServer;
using System.Windows;
using System.Threading;
using static SlnMesnac.RfidUpload.UI.SelectRouterWindow;
using static SlnMesnac.RfidUpload.UI.viewModel.containerStorageQueryByCsbViewModel;
using SlnMesnac.RfidUpload.UI.TempData;
namespace SlnMesnac.RfidUpload.UI.viewModel
{
public class MainWindowViewModel : ViewModelBase
{
TransferOrderViewModel transferOrderViewModel = new TransferOrderViewModel();
ContainerTransferOrderViewModel containerTransferOrderViewModel = new ContainerTransferOrderViewModel();
private readonly LogHelper logger = LogHelper.Instance;
private readonly HandleBusiness _business = HandleBusiness.Instance;
private readonly SerialPortBusiness _serialPortBusiness = SerialPortBusiness.Instance;
private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>();
private ObservableCollection<DataGridEnt> labelItems = new ObservableCollection<DataGridEnt>();
private CsbHandleBusiness csbHandleBusiness = CsbHandleBusiness.Instance;
private WebApiServerApp webApiServerApp = WebApiServerApp.Instance;
private ApiServer apiServer = ApiServer.GetInstance();
private AppConfig appConfig = AppConfig.Instance;
private JsonChange jsonChange = JsonChange.Instance;
private int No = 1;
private SysData sysData = SysData.Instance;
//暂存库存容器分发配发机构数据
private Institution Institution;
#region 参数定义
/// <summary>
/// 串口
/// </summary>
private ObservableCollection<string> _serialPortItems = new ObservableCollection<string>();
public ObservableCollection<string> SerialPortItems
{
get { return _serialPortItems; }
set { _serialPortItems = value; RaisePropertyChanged(() => SerialPortItems); }
}
private string _selectedSerialPortItems = string.Empty;
public string SelectedSerialPortItems
{
get { return _selectedSerialPortItems; }
set { _selectedSerialPortItems = value; RaisePropertyChanged(() => SelectedSerialPortItems); }
}
/// <summary>
/// 波特率
/// </summary>
private ObservableCollection<int> _baudRateItems = new ObservableCollection<int>() { 9600, 115200 };
public ObservableCollection<int> BaudRateItems
{
get { return _baudRateItems; }
set { _baudRateItems = value; RaisePropertyChanged(() => BaudRateItems); }
}
private int _selectedBaudRateItems = 115200;
public int SelectedBaudRateItems
{
get { return _selectedBaudRateItems; }
set { _selectedBaudRateItems = value; RaisePropertyChanged(() => SelectedBaudRateItems); }
}
/// <summary>
/// 数据位
/// </summary>
private ObservableCollection<int> _dataBitsItems = new ObservableCollection<int>() { 2, 4, 6, 8 };
public ObservableCollection<int> DataBitsItems
{
get { return _dataBitsItems; }
set { _dataBitsItems = value; RaisePropertyChanged(() => DataBitsItems); }
}
private int _selectedDataBitsItems = 8;
public int SelectedDataBitsItems
{
get { return _selectedDataBitsItems; }
set { _selectedDataBitsItems = value; RaisePropertyChanged(() => SelectedDataBitsItems); }
}
/// <summary>
///停止位
/// </summary>
private ObservableCollection<int> _stopBitsItems = new ObservableCollection<int>() { 0, 1, 2, 3, 4 };
public ObservableCollection<int> StopBitsItems
{
get { return _stopBitsItems; }
set { _stopBitsItems = value; RaisePropertyChanged(() => StopBitsItems); }
}
private int _selectedStopBitsItems = 1;
public int SelectedStopBitsItems
{
get { return _selectedStopBitsItems; }
set { _selectedStopBitsItems = value; RaisePropertyChanged(() => SelectedStopBitsItems); }
}
/// <summary>
///校验位
/// </summary>
private ObservableCollection<string> _parityItems = new ObservableCollection<string>() { "None", "Odd", "Even", "Mark", "Space" };
public ObservableCollection<string> ParityItems
{
get { return _parityItems; }
set { _parityItems = value; RaisePropertyChanged(() => ParityItems); }
}
private string _selectedParityItems = "None";
public string SelectedParityItems
{
get { return _selectedParityItems; }
set { _selectedParityItems = value; RaisePropertyChanged(() => SelectedParityItems); }
}
/// <summary>
/// 标签数量
/// </summary>
private int labelCountParam = 0;
public int LabelCountParam
{
get { return labelCountParam; }
set { labelCountParam = value;RaisePropertyChanged(() => LabelCountParam); }
}
/// <summary>
/// 主界面当前调拨单号
/// </summary>
private string _mainPageDbdh = "";
public string MainPageDbdh
{
get { return _mainPageDbdh; }
set { _mainPageDbdh = value; RaisePropertyChanged(() => MainPageDbdh); }
}
/// <summary>
/// 主界面当前送货单号
/// </summary>
private string _trackNo = "";
public string TrackNo
{
get { return _trackNo; }
set { _trackNo = value; RaisePropertyChanged(() => TrackNo); }
}
/// <summary>
/// 主界面当前封发计划
/// </summary>
private string _mainPageFfjhNo = "";
public string MainPageFfjhNo
{
get { return _mainPageFfjhNo; }
set { _mainPageFfjhNo = value; RaisePropertyChanged(() => MainPageFfjhNo); }
}
/// <summary>
/// 主界面提示信息
/// </summary>
private string _mainPageTipMessage = "";
public string MainPageTipMessage
{
get { return _mainPageTipMessage; }
set { _mainPageTipMessage = value; RaisePropertyChanged(() => MainPageTipMessage); }
}
/// <summary>
/// 工作模式
/// </summary>
private int workModelParam = 0;
public int WorkModelParam
{
get { return workModelParam; }
set { workModelParam = value; RaisePropertyChanged(() => WorkModelParam); }
}
/// <summary>
/// 分发验证后的对象
/// </summary>
private TransferOrderInfo _transferOrderInfo = new TransferOrderInfo();
public TransferOrderInfo TransferOrderInfoItem
{
get { return _transferOrderInfo; }
set { _transferOrderInfo = value; RaisePropertyChanged(() => TransferOrderInfoItem); }
}
private int rfidDeviceStatus = 0;
public int RfidDeviceStatus
{
get { return rfidDeviceStatus; }
set { rfidDeviceStatus = value; RaisePropertyChanged(nameof(RfidDeviceStatus)); }
}
/// <summary>
/// 日志打印ListBox
/// </summary>
private IEnumerable logInfoListBox;
public IEnumerable LogInfoListBox
{
get { return logInfoListBox; }
set { logInfoListBox = value; RaisePropertyChanged(() => LogInfoListBox); }
}
/// <summary>
/// 标签信息DataGrid
/// </summary>
private IEnumerable labelInfoDataGrid;
public IEnumerable LabelInfoDataGrid
{
get { return labelInfoDataGrid; }
set { labelInfoDataGrid = value; RaisePropertyChanged(() => LabelInfoDataGrid); }
}
#endregion
#region 事件定义
/// <summary>
/// 打开串口
/// </summary>
public RelayCommand OpenSerialPortCommand { get; set; }
/// <summary>
/// 关闭串口
/// </summary>
public RelayCommand CloseSerialPortCommand { get; set; }
/// <summary>
/// 导出文件
/// </summary>
public RelayCommand ExportFilesCommand { get; set; }
#endregion
/// <summary>
/// 清空列表
/// </summary>
public RelayCommand EmptyFilesCommand { get; set; }
public RelayCommand FinishCommand { get; set; }
public RelayCommand systemSetCommand { get; set; }
/// <summary>
/// 设置工作模式
/// </summary>
public RelayCommand<object> SetWorkModelCommand { get; set; }
public MainWindowViewModel()
{
containerStorageQueryByCsbViewModel.RefreshSubmitVerifyEvent += RefreshSubmitVerify;
containerStorageQueryByCsbViewModel.RefreshTrackNoEvent += RefreshTrackNo;
TransferOrderViewModel.RefreshSubmitVerifyEvent += RefreshSubmitVerify;
SelectRouterWindow.RefreshSubmitVerifyEvent += RefreshSubmitVerify;
logger.Info("程序启动");
EmptyFilesCommand = new RelayCommand(EmptyFiles);
ExportFilesCommand = new RelayCommand(ExportFiles);
OpenSerialPortCommand = new RelayCommand(OpenSerialPort);
CloseSerialPortCommand = new RelayCommand(CloseSerialPort);
SetWorkModelCommand = new RelayCommand<object>(SetWorkModel);
systemSetCommand = new RelayCommand(SystemSet);
FinishCommand = new RelayCommand(Finish);
this.Init();
//测试数据
//sysData.trackNoList.Add(new newContainerInCheckData() { dbdh = "1234567890", trackNo = "123", rqtmStart = "123", rqtmEnd = "123", time = DateTime.Now });
//sysData.trackNoList.Add(new newContainerInCheckData() { dbdh = "1234", trackNo = "123", rqtmStart = "123", rqtmEnd = "123", time = DateTime.Now });
//sysData.trackNoList.Add(new newContainerInCheckData() { dbdh = "4434", trackNo = "123", rqtmStart = "123", rqtmEnd = "123", time = DateTime.Now });
//sysData.trackNoList.Add(new newContainerInCheckData() { dbdh = "554434", trackNo = "123", rqtmStart = "123", rqtmEnd = "123", time = DateTime.Now.AddDays(1) });
//sysData.trackNoList.Add(new newContainerInCheckData() { dbdh = "4434", trackNo = "123", rqtmStart = "123", rqtmEnd = "123", time = DateTime.Now });
//sysData.trackNoList.Add(new newContainerInCheckData() { dbdh = "4434", trackNo = "123", rqtmStart = "123", rqtmEnd = "123", time = DateTime.Now });
//sysData.trackNoList.Add(new newContainerInCheckData() { dbdh = "4434", trackNo = "123", rqtmStart = "123", rqtmEnd = "123", time = DateTime.Now });
//sysData.trackNoList.Add(new newContainerInCheckData() { dbdh = "4434", trackNo = "123", rqtmStart = "123", rqtmEnd = "123", time = DateTime.Now });
//sysData.trackNoList.Add(new newContainerInCheckData() { dbdh = "4434", trackNo = "123", rqtmStart = "123", rqtmEnd = "123", time = DateTime.Now });
//sysData.trackNoList.Add(new newContainerInCheckData() { dbdh = "4434", trackNo = "123", rqtmStart = "123", rqtmEnd = "123", time = DateTime.Now });
//sysData.trackNoList.Add(new newContainerInCheckData() { dbdh = "4434", trackNo = "123", rqtmStart = "123", rqtmEnd = "123", time = DateTime.Now });
//sysData.trackNoList.Add(new newContainerInCheckData() { dbdh = "4434", trackNo = "123", rqtmStart = "123", rqtmEnd = "123", time = DateTime.Now });
}
private void Init()
{
//程序启动默认打开串口7
_selectedSerialPortItems = "COM7";
OpenSerialPort();
WorkModelParam = Convert.ToInt32(appConfig.workModel);
//webApiServerApp.Init();
//apiServer.RefreshScanInfoInCenterStartEvent += () =>
//{
// OpenSerialPort();
//};
//apiServer.RefreshScanInfoInCenterStopEvent += () =>
//{
// CloseSerialPort();
//};
//apiServer.RefreshScanInfoOutCenterStartEvent += () =>
//{
// OpenSerialPort();
//};
//apiServer.RefreshScanInfoOutCenterStopEvent += () =>
//{
// CloseSerialPort();
//};
//加载标签信息
_business.InstructionInfoDataGridEvent += RefreshLabelInfoDataGrid;
//加载解析日志
_business.RefreshLogMessageEvent += message =>
{
// logger.Info(message);
PrintMessageToListBox(message);
};
//接收串口数据
_serialPortBusiness.ReceivedDataEvent += buffer =>
{
//粘包数据处理
List<byte[]> dataPackages = _business.SplitPackets(buffer);
foreach (byte[] package in dataPackages)
{
_business.LabelHandle(package);
//LabelCountParam += 1;
}
};
//加载串口通讯日志
_serialPortBusiness.RefreshLogMessageEvent += message =>
{
logger.Info(message);
PrintMessageToListBox(message);
};
_serialPortBusiness.GetSerialPorts(out List<string> serialPorts);
SerialPortItems = new ObservableCollection<string>(serialPorts);
}
/// <summary>
/// 打开串口通讯
/// </summary>
private void OpenSerialPort()
{
try
{
// LabelTest();
//_serialPortBusiness.OpenSerialPort();
this.GetParity(out int parity);
_serialPortBusiness.OpenSerialPort(_selectedSerialPortItems, _selectedBaudRateItems, parity, _selectedDataBitsItems, _selectedStopBitsItems);
if (rfidDeviceStatus != 1)
{
RfidDeviceStatus = 1;
}
}
catch (Exception e)
{
PrintMessageToListBox($"串口通讯打开异常:{e.Message}");
}
}
/// <summary>
/// 关闭串口通讯
/// </summary>
private void CloseSerialPort()
{
try
{
_serialPortBusiness.Close();
if (rfidDeviceStatus != 2)
{
RfidDeviceStatus = 2;
}
}
catch (Exception e)
{
PrintMessageToListBox($"串口通讯关闭异常:{e.Message}");
}
}
/// <summary>
/// 导出文件
/// </summary>
private void ExportFiles()
{
try
{
var info = labelItems.ToList();
// 创建 SaveFileDialog 对象
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Excel文件 (*.xlsx)|*.xlsx|所有文件 (*.*)|*.*";
saveFileDialog.Title = "保存文件";
saveFileDialog.FileName = $"标签信息{DateTime.Now.Date:yyyy-MM-dd}.xlsx";
if (saveFileDialog.ShowDialog() == true)
{
string filePath = saveFileDialog.FileName;
MiniExcel.SaveAs(filePath, info);
PrintMessageToListBox($"标签数据导出成功:{filePath}");
}
}
catch(Exception ex)
{
PrintMessageToListBox($"标签数据导出异常:{ex.Message}");
logger.Error($"标签数据导出异常", ex);
}
}
private static INIFile iNIFile = new INIFile(System.Environment.CurrentDirectory + "/App.InI");
private void Finish()
{
try
{
if (workModelParam == 1) //新容器入库
{
var info = labelItems.ToList();
var strList = info.Select(x => x.result).ToList();
int batchNo = 0;
string opBatch = System.Guid.NewGuid().ToString("N").Substring(0, 20);
ListPage<string> ls = new ListPage<string>(strList, 500);
CsbResult res = new CsbResult();
foreach (var enumerable in ls.GetPage())
{
batchNo++;
res = csbHandleBusiness.containerStorageBatchQueryByCsb(TrackNo,batchNo.ToString(), enumerable.ToList());
PrintMessageToListBox($"新容器入库结果 [{res.GetMsg()}]");
}
MainPageTipMessage = $"新容器入库 [{res.GetMsg()}]";
if (res.IsSuccess)
{
Task.Run(() =>
{
Thread.Sleep(3000);
CsbResult res = csbHandleBusiness.receContainerStorageByCsb(TrackNo, "1");
PrintMessageToListBox($"新容器入库反馈接口 [{res.GetMsg()}]");
Application.Current.Dispatcher.Invoke(() =>
{
MainPageTipMessage = $"新容器入库反馈接口,[{res.GetMsg()}]";
});
});
}
}
else if (workModelParam == 2) //封发-按调拨单
{
var info = labelItems.ToList();
var strList = info.Select(x => x.result).ToList();
int batchNo = 0;
string opBatch = System.Guid.NewGuid().ToString("N").Substring(0, 20);
ListPage<string> ls = new ListPage<string>(strList, 500);
CsbResult res = new CsbResult();
foreach (var enumerable in ls.GetPage())
{
batchNo++;
res = csbHandleBusiness.containerScanSealByCsb(TransferOrderInfoItem.ffjhNo,
opBatch,
TransferOrderInfoItem.ffjhscrq, batchNo.ToString(), enumerable.ToList());
PrintMessageToListBox($"封发-按调拨单结果 [{res.GetMsg()}]");
}
// MessageBox.Show($"封发-按调拨单 [{res.GetMsg()}]");
MainPageTipMessage = $"封发-按调拨单 [{res.GetMsg()}]";
if (res.IsSuccess)
{
Task.Run(() =>
{ //若干秒以后调反馈接口,确认是否和实际相符
Thread.Sleep(3000);
CsbResult res = csbHandleBusiness.containerScanSealResultByCsb(TransferOrderInfoItem.ffjhNo, opBatch);
Application.Current.Dispatcher.Invoke(() =>
{
MainPageTipMessage = $"封发-按调拨单反馈接口,[{res.GetMsg()}]";
PrintMessageToListBox($"封发-按调拨单反馈接口结果 [{res.GetMsg()}]");
// 如果需要弹出消息框,也需要在 UI 线程调用 MessageBox
// MessageBox.Show($"封发-按调拨单反馈接口,[{res.GetMsg()}]");
});
});
}
}
else if (WorkModelParam == 3 || WorkModelParam == 4) //库存容器封发配发 -- 6.13.容器直连配发-开始配发
{
//四、6.9接收容器条码接口
var info = labelItems.ToList();
var strList = info.Select(x => x.result).ToList();
int batchNo = 0;
string opBatch = OpBatchManager.BathNo;
ListPage<string> ls = new ListPage<string>(strList, 500);
CsbResult res = new CsbResult();
foreach (var enumerable in ls.GetPage())
{
batchNo++;
res = csbHandleBusiness.containerScanSealByCsb(TransferOrderInfoItem.ffjhNo,
opBatch,
TransferOrderInfoItem.ffjhscrq, batchNo.ToString(), enumerable.ToList());
PrintMessageToListBox($"封发-按调拨单接口结果 [{res.GetMsg()}]");
}
MainPageTipMessage = $"封发-按调拨单 [{res.GetMsg()}]";
if (res.IsSuccess)
{
Task.Run(() =>
{
// 五、6.10反馈接收结果(利用上一步的opBatch)
Task.Delay(3000);
CsbResult res1 = csbHandleBusiness.containerScanSealResultByCsb(TransferOrderInfoItem.ffjhNo, opBatch);
MainPageTipMessage = $"封发-按调拨单反馈接口,[{res1.GetMsg()}]";
PrintMessageToListBox($"封发-按调拨单反馈接口,[{res1.GetMsg()}]");
if (!res1.IsSuccess) return;
//六、6.12 效验发运计划(利用上一步的opBatch)
string stationOrgCode = Institution != null ? Institution.stationOrgCode : "";
string stationOrgName = Institution != null ? Institution.stationOrgName : "";
CsbResult res2 = csbHandleBusiness.tranPlanCheckByCsb(_transferOrderInfo.ffjhNo, opBatch, stationOrgCode, stationOrgName);
MainPageTipMessage = "校验发运计划结果:" + res2.GetMsg();
PrintMessageToListBox("校验发运计划结果:" + res2.GetMsg());
if (res2.IsSuccess)
{
// 七、6.13.容器直连配发-开始配发
CsbResult res3 = csbHandleBusiness.containerAllotByCsb(TransferOrderInfoItem.ffjhNo, opBatch);
MainPageTipMessage = $"库存容器封发配发 -- 6.13.容器直连配发-开始配发 [{res3.GetMsg()}]";
PrintMessageToListBox($"库存容器封发配发 -- 6.13.容器直连配发-开始配发 [{res3.GetMsg()}]");
if (res3.IsSuccess)
{
Task.Delay(3000);
// Thread.Sleep(3000);
//八、反馈接收接口,确认是否和实际相符
for (int i = 0; i < 3; i++)
{
try
{
CsbResult res4 = csbHandleBusiness.containerAllotResultByCsb(TransferOrderInfoItem.ffjhNo, opBatch);
MainPageTipMessage = $"八、反馈接收接口,确认是否和实际相符[{res4.GetMsg()}]";
PrintMessageToListBox($"库存容器封发配发反馈接收接口 [{res4.GetMsg()}]");
if (res4.IsSuccess)
{
break;
};
}
catch (Exception ex)
{
logger.Info(ex.Message);
Task.Delay(3000);
}
}
}
}
});
}
//string opBatch = OpBatchManager.BathNo;
//CsbResult res = csbHandleBusiness.containerAllotByCsb(TransferOrderInfoItem.ffjhNo,opBatch);
//MessageBox.Show($"库存容器封发配发 -- 6.13.容器直连配发-开始配发 [{res.GetMsg()}]");
//Task.Run(() =>
//{
// Thread.Sleep(3000);
// //若干秒以后调反馈接口,确认是否和实际相符
// CsbResult res = csbHandleBusiness.containerAllotResultByCsb(TransferOrderInfoItem.ffjhNo, opBatch);
// MessageBox.Show($"库存容器封发配发--若干秒以后调反馈接口,确认是否和实际相符[{res.GetMsg()}]");
//});
}
else if (workModelParam == -1)
{
MessageBox.Show("工作模式错误"); return;
}
}catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
/// <summary>
/// 清空标签信息列表
/// </summary>
private void EmptyFiles()
{
No = 0;
labelItems.Clear();
LabelCountParam = 0;
}
private void SystemSet()
{
systemSetWindow systemSetWindow = new systemSetWindow();
systemSetWindow.ShowDialog();
}
private void SetWorkModel(object modelFlag)
{
// WorkModelParam = Convert.ToInt32(modelFlag);
int WorkModel = Convert.ToInt32(modelFlag);
// appConfig.workModel = this.workModelParam.ToString();
//TransferOrderWindow transferOrderWindow = new TransferOrderWindow(transferOrderViewModel);
//transferOrderWindow.ShowDialog();
if(WorkModel == 1) //新容器入库
{
containerStorageQueryByCsb storageQueryByCsb = new containerStorageQueryByCsb();
storageQueryByCsb.ShowDialog();
}
else if(WorkModel == 2) //容器封发-按调拨单
{
TransferOrderWindow transferOrderWindow = new TransferOrderWindow(transferOrderViewModel);
transferOrderWindow.ShowDialog();
}
else if (WorkModel == 3) //库存容器封发配发
{
containerTransferOrderViewModel.BelongPage = 3;
ContainerTransferOrderWindow containerTransferOrderWindow = new ContainerTransferOrderWindow(containerTransferOrderViewModel);
containerTransferOrderWindow.ShowDialog();
}
else if (WorkModel == 4) //卸车容器封发配发
{
containerTransferOrderViewModel.BelongPage = 4;
ContainerTransferOrderWindow containerTransferOrderWindow = new ContainerTransferOrderWindow(containerTransferOrderViewModel);
containerTransferOrderWindow.ShowDialog();
}else if (WorkModel == 5) //退出
{
System.Environment.Exit(0);
}
}
/// <summary>
/// 加载标签信息DataGrid
/// </summary>
/// <param name="labelInfos"></param>
private void RefreshLabelInfoDataGrid(InstructionInfo instructionInfo)
{
if (instructionInfo == null) return;
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
int no =labelItems.Count;
DataGridEnt dataGridEnt = new DataGridEnt();
dataGridEnt.no = ++no;
dataGridEnt.dbdh = _transferOrderInfo.dbdh;
dataGridEnt.result = instructionInfo.data;
dataGridEnt.recordtime = DateTime.Now;
labelItems.Add(dataGridEnt);
LabelInfoDataGrid = labelItems;
LabelCountParam += 1;
}));
Task.Run(() =>
{
if (workModelParam == 101)
{
var info = BatchOpenQuery.Instance;
info.rqtm = instructionInfo.data;
_business.upload(101, jsonChange.ModeToJson(info), "新容器入库");
}
});
}
/// <summary>
/// listBox绑定日志
/// </summary>
/// <param name="message"></param>
private void PrintMessageToListBox(string message)
{
lock (string.Empty)
{
try
{
listItems.Add($"{DateTime.Now.ToString("HH:mm:ss")}==>{message}");
LogInfoListBox = listItems.OrderByDescending(x => x);
}
catch (Exception ex)
{
logger.Error("日志数据绑定异常", ex);
}
}
}
/// <summary>
/// 标签解析测试
/// </summary>
private void LabelTest()
{
// 模拟接收到的粘包数据
byte[] receivedData = {
0xAA, 0x55, 0x00, 0x1F, 0x31, 0x03, 0x45, 0x32, 0x30, 0x30, 0x33, 0x30, 0x33, 0x32, 0x37, 0x38, 0x31, 0x30, 0x30, 0x31, 0x35, 0x30, 0x30, 0x35, 0x39, 0x30, 0x44, 0x35, 0x35, 0x36, 0x2C,
0xAA, 0x55, 0x00, 0x1F, 0x31, 0x03, 0x45, 0x32, 0x30, 0x30, 0x33, 0x30, 0x33, 0x32, 0x37, 0x38, 0x31, 0x30, 0x30, 0x31, 0x35, 0x30, 0x30, 0x35, 0x39, 0x30, 0x44, 0x35, 0x35, 0x36, 0x2C,
0xAA, 0x55, 0x00, 0x1F, 0x31, 0x03, 0x45, 0x32, 0x30, 0x30, 0x33, 0x30, 0x33, 0x32, 0x37, 0x38, 0x31, 0x30, 0x30, 0x31, 0x35, 0x30, 0x30, 0x35, 0x39, 0x30, 0x44, 0x35, 0x35, 0x36, 0x2C,
0xAA, 0x55, 0x00, 0x1F, 0x31, 0x03, 0x45, 0x32, 0x30, 0x30, 0x33, 0x30, 0x33, 0x32, 0x37, 0x38, 0x31, 0x30, 0x30, 0x31, 0x35, 0x30, 0x30, 0x35, 0x39, 0x30, 0x44, 0x35, 0x35, 0x36, 0x2C,
0xAA, 0x55, 0x00, 0x27, 0x31, 0x03, 0x46, 0x43, 0x31, 0x30, 0x30, 0x38, 0x32, 0x30, 0x32, 0x30, 0x30
};
//粘包数据的处理
List<byte[]> dataPackages = _business.SplitPackets(receivedData);
// 打印处理后的数据包
foreach (byte[] package in dataPackages)
{
_business.LabelHandle(package);
//LabelCountParam += 1;
}
}
/// <summary>
/// 转换校验位
/// </summary>
/// <param name="parity"></param>
private void GetParity(out int parity)
{
switch (_selectedParityItems)
{
case "None":
parity = 0;
break;
case "Odd":
parity = 1;
break;
case "Even":
parity = 2;
break;
case "Mark":
parity = 3;
break;
case "Space":
parity = 4;
break;
default:
parity = 0;
break;
}
}
/// <summary>
///
/// model -当前工作模式
/// msg -接口返回信息
/// dbdh -调拨单号
/// </summary>
/// <param name="model"></param>
/// <param name="msg"></param>
/// <param name="dbdh"></param>
private void RefreshSubmitVerify(int model,string msg,TransferOrderInfo transferOrderInfo=null, Institution institution = null)
{
MainPageTipMessage = msg;
appConfig.workModel = model.ToString();
WorkModelParam = model ;
if (transferOrderInfo != null)
{
MainPageDbdh = transferOrderInfo.dbdh;
MainPageFfjhNo = transferOrderInfo.ffjhNo;
TransferOrderInfoItem = transferOrderInfo;
}
if(institution != null)
{
Institution = institution;
}
}
private void RefreshTrackNo(string trackNo)
{
MainPageTipMessage = "trackNo:" + trackNo;
TrackNo = trackNo;
}
}
}
class DataGridEnt
{
public int no { get; set; }
public string dbdh { get; set; }
public string result { get; set; }
public DateTime recordtime { get; set; }
}