diff --git a/SlnMesnac.Business/TagScanBusiness.cs b/SlnMesnac.Business/TagScanBusiness.cs
index d118f37..cee5b2f 100644
--- a/SlnMesnac.Business/TagScanBusiness.cs
+++ b/SlnMesnac.Business/TagScanBusiness.cs
@@ -1,8 +1,11 @@
-using SlnMesnac.Model.domain;
+using SlnMesnac.Common;
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service.ScanLog;
using SlnMesnac.TouchSocket;
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Linq.Expressions;
using System.Text;
#region << 版 本 注 释 >>
@@ -32,6 +35,7 @@ namespace SlnMesnac.Business
public class TagScanBusiness
{
private ApiServer apiServer;
+ private IScanLogService scanLogService;
public delegate void RefreshTagScanInfo(ScanLogModel scanLogModel);
public event RefreshTagScanInfo? RefreshTagScanInfoEvent;
@@ -43,13 +47,17 @@ namespace SlnMesnac.Business
public event RefreshDeviceStatus? RefreshDeviceStatusEvent;
- public TagScanBusiness(ApiServer apiServer)
+ public TagScanBusiness(ApiServer apiServer, IScanLogService scanLogService)
{
this.apiServer = apiServer;
+ this.scanLogService = scanLogService;
this.RefreshScanInfo();
}
+ ///
+ /// 扫描信息刷新
+ ///
private void RefreshScanInfo()
{
//扫描记录刷新
@@ -99,6 +107,33 @@ namespace SlnMesnac.Business
};
}
+ ///
+ /// 查询扫描记录
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void QuerySacnInfo(string rfidStr,DateTime beginTime,DateTime endTime,out List result)
+ {
+ //var info = scanLogService.Query(x => x.CreateTime >= beginTime && x.CreateTime <= endTime);
+ Expression> exp = s1 => true;
+ if(beginTime != null)
+ {
+ exp = exp.And(x => x.CreateTime >= beginTime);
+ }
+
+ if (endTime != null)
+ {
+ exp = exp.And(x => x.CreateTime <= endTime);
+ }
+
+ if (!string.IsNullOrEmpty(rfidStr))
+ {
+ exp = exp.And(x => x.Rfid == rfidStr);
+ }
+ result = scanLogService.Query(exp);
+ }
}
}
diff --git a/SlnMesnac.Model/SlnMesnac.Model.csproj b/SlnMesnac.Model/SlnMesnac.Model.csproj
index 4f9d9b5..75ced3c 100644
--- a/SlnMesnac.Model/SlnMesnac.Model.csproj
+++ b/SlnMesnac.Model/SlnMesnac.Model.csproj
@@ -6,6 +6,7 @@
+
diff --git a/SlnMesnac.Model/domain/ScanLog.cs b/SlnMesnac.Model/domain/ScanLog.cs
index 8d20e2f..f727fa3 100644
--- a/SlnMesnac.Model/domain/ScanLog.cs
+++ b/SlnMesnac.Model/domain/ScanLog.cs
@@ -1,5 +1,6 @@
using System;
using System.Runtime.Serialization;
+using MiniExcelLibs.Attributes;
using SqlSugar;
namespace SlnMesnac.Model.domain
@@ -11,18 +12,31 @@ namespace SlnMesnac.Model.domain
///
///
///
+ [ExcelColumnName("ʶ"), ExcelColumnWidth(15)]
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
+
+ [ExcelColumnName("ɨʱ"), ExcelColumnWidth(30)]
[SugarColumn(ColumnName = "create_time")]
public DateTime CreateTime { get; set; }
+
+ [ExcelColumnName(""), ExcelColumnWidth(15)]
[SugarColumn(ColumnName = "data_type")]
public int DataType { get; set; }
+
+ [ExcelColumnName("RFID"), ExcelColumnWidth(30)]
[SugarColumn(ColumnName = "rfid")]
public string Rfid { get; set; }
+
+ [ExcelColumnName("ATRʶ"), ExcelColumnWidth(30)]
[SugarColumn(ColumnName = "code")]
public string Code { get; set; }
+
+ [ExcelColumnName("OCRʶ"), ExcelColumnWidth(30)]
[SugarColumn(ColumnName = "ocr")]
public string Ocr { get; set; }
+
+ [ExcelColumnName("ȫͼ·"), ExcelColumnWidth(50)]
[SugarColumn(ColumnName = "url")]
public string Url { get; set; }
}
diff --git a/SlnMesnac.WPF/Page/History/HistoryControl.xaml b/SlnMesnac.WPF/Page/History/HistoryControl.xaml
index 947c4f8..72faeb0 100644
--- a/SlnMesnac.WPF/Page/History/HistoryControl.xaml
+++ b/SlnMesnac.WPF/Page/History/HistoryControl.xaml
@@ -14,7 +14,7 @@
-
+
@@ -25,9 +25,9 @@
-
+
-
+
@@ -47,7 +47,7 @@
-
+
diff --git a/SlnMesnac.WPF/Page/History/HistoryControl.xaml.cs b/SlnMesnac.WPF/Page/History/HistoryControl.xaml.cs
index 1f55155..a74c7bf 100644
--- a/SlnMesnac.WPF/Page/History/HistoryControl.xaml.cs
+++ b/SlnMesnac.WPF/Page/History/HistoryControl.xaml.cs
@@ -1,4 +1,5 @@
-using System;
+using SlnMesnac.WPF.ViewModel;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -23,6 +24,7 @@ namespace SlnMesnac.WPF.Page.History
public HistoryControl()
{
InitializeComponent();
+ this.DataContext = new HistoryViewModel();
}
}
}
diff --git a/SlnMesnac.WPF/ViewModel/HistoryViewModel.cs b/SlnMesnac.WPF/ViewModel/HistoryViewModel.cs
new file mode 100644
index 0000000..08177c7
--- /dev/null
+++ b/SlnMesnac.WPF/ViewModel/HistoryViewModel.cs
@@ -0,0 +1,112 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Win32;
+using MiniExcelLibs;
+using SlnMesnac.Business;
+using SlnMesnac.Model.domain;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:T14-GEN3-7895
+* 命名空间:SlnMesnac.WPF.ViewModel
+* 唯一标识:363901e3-4a2d-433c-862a-6ea822f784fb
+*
+* 创建者:WenJY
+* 电子邮箱:
+* 创建时间:2024-09-20 10:23:24
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace SlnMesnac.WPF.ViewModel
+{
+ public partial class HistoryViewModel : ObservableObject
+ {
+ private TagScanBusiness tagScanBusiness;
+ public HistoryViewModel()
+ {
+ tagScanBusiness = App.ServiceProvider.GetService();
+
+ }
+
+ public string _rfidCode;
+ public string RfidCode
+ {
+ get => _rfidCode;
+ set => SetProperty(ref _rfidCode, value);
+ }
+
+ public DateTime _beginTime = DateTime.Now;
+ public DateTime BeginTime
+ {
+ get => _beginTime;
+ set => SetProperty(ref _beginTime, value);
+ }
+
+ public DateTime _endTime = DateTime.Now;
+ public DateTime EndTime
+ {
+ get => _endTime;
+ set => SetProperty(ref _endTime, value);
+ }
+
+ private ObservableCollection _scanItems = new ObservableCollection();
+ public ObservableCollection ScanItems
+ {
+ get => _scanItems;
+ set => SetProperty(ref _scanItems, value);
+ }
+
+ [RelayCommand]
+ private void Query()
+ {
+ tagScanBusiness.QuerySacnInfo(_rfidCode, _beginTime, _endTime,out List info);
+
+ ScanItems = new ObservableCollection(info);
+ }
+
+ [RelayCommand]
+ private void Export()
+ {
+ try
+ {
+ var info = _scanItems;
+
+ // 创建 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);
+ MessageBox.Show($"扫描记录导出成功:{filePath}");
+
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"扫描记录导出异常:{ex.Message}");
+ }
+ }
+ }
+}