更新
This commit is contained in:
@@ -29,14 +29,13 @@ namespace FATrace.OEMApp
|
||||
// 历史表列头中文映射
|
||||
private readonly Dictionary<string, string> _historyHeaderMap = new Dictionary<string, string>
|
||||
{
|
||||
{ nameof(VideoAction.Id), "编号" },
|
||||
{ nameof(VideoAction.Code), "条码" },
|
||||
{ nameof(VideoAction.User), "用户" },
|
||||
{ nameof(VideoAction.VideoFilePath), "视频路径" },
|
||||
{ nameof(VideoAction.VideoName), "视频名称" },
|
||||
{ nameof(VideoAction.StartTime), "开始时间" },
|
||||
{ nameof(VideoAction.EndTime), "结束时间" },
|
||||
{ nameof(VideoAction.CreateTime), "创建时间" }
|
||||
{ nameof(OEMRawUse.InBagCode), "内袋二维码" },
|
||||
{ nameof(OEMRawUse.RawName), "原料名称" },
|
||||
{ nameof(OEMRawUse.RawCode), "原料条码" },
|
||||
{ nameof(OEMRawUse.VideoFilePath), "视频路径" },
|
||||
{ nameof(OEMRawUse.VideoName), "视频名称" },
|
||||
{ nameof(OEMRawUse.User), "用户" },
|
||||
{ nameof(OEMRawUse.CreateTime), "创建时间" }
|
||||
};
|
||||
|
||||
private int _lvLogMaxItems = 1000;
|
||||
@@ -101,6 +100,7 @@ namespace FATrace.OEMApp
|
||||
private PLCDataService PLCDataService { get; set; }
|
||||
private TimeClearDataService TimeClearService { get; set; }
|
||||
private System.Windows.Forms.Timer _statusTimer;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 主窗体加载:
|
||||
@@ -175,8 +175,7 @@ namespace FATrace.OEMApp
|
||||
_ = UpdateNasStatusAsync();
|
||||
_ = UpdateNvrStatusAsync();
|
||||
StartStatusTimer();
|
||||
|
||||
//materialListView1.DataBindings
|
||||
|
||||
try
|
||||
{
|
||||
var systemName = Program.SystemName;
|
||||
@@ -211,11 +210,18 @@ namespace FATrace.OEMApp
|
||||
//解析Code条码数据,内包条码数据
|
||||
CurParsedCodeInfo = NVRCom.ParseCodeFull(Code);
|
||||
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
txtRUInBagCode.Text = CurParsedCodeInfo.Code;
|
||||
txtRURawName.Text= CurParsedCodeInfo.RawName;
|
||||
txtRURawCode.Text = CurParsedCodeInfo.RawCode;
|
||||
}));
|
||||
|
||||
var taskId = DownloadTaskWorker.Instance.Enqueue(
|
||||
CurParsedCodeInfo,
|
||||
user: CurUserName,
|
||||
start: DateTime.Now,
|
||||
end: DateTime.Now.AddSeconds(DownloadTaskWorker.VideoTime+2)
|
||||
start: DateTime.Now.AddDays(-2),
|
||||
end: DateTime.Now.AddDays(-2).AddSeconds(DownloadTaskWorker.VideoTime + 2)
|
||||
);
|
||||
//MessageBox.Show($"[Test] 已入队下载任务,Id={taskId}");
|
||||
|
||||
@@ -412,20 +418,8 @@ namespace FATrace.OEMApp
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 测试手动播放
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnPlayHistoryVideo_Click(object sender, EventArgs e)
|
||||
{
|
||||
string path = "D:\\Downtest_Channel2025-09-12 102454.mp4";
|
||||
_mediaPlayer.Play(new Media(_libVLC, path));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止播放当前的视频文件
|
||||
/// </summary>
|
||||
@@ -455,7 +449,7 @@ namespace FATrace.OEMApp
|
||||
/// 采用 BindingList + BindingSource,使数据变化自动触发 UI 刷新
|
||||
/// </summary>
|
||||
private BindingSource historyBindingSource { get; set; }
|
||||
private BindingList<VideoAction> historyVideoBindingList { get; set; }
|
||||
private BindingList<OEMRawUse> historyVideoBindingList { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -464,7 +458,7 @@ namespace FATrace.OEMApp
|
||||
private void InitHistoryGridBinding()
|
||||
{
|
||||
historyBindingSource = new BindingSource();
|
||||
historyVideoBindingList = new BindingList<VideoAction>();
|
||||
historyVideoBindingList = new BindingList<OEMRawUse>();
|
||||
historyBindingSource.DataSource = historyVideoBindingList;
|
||||
// 绑定到 WinForms 原生 DataGridView
|
||||
dataGridView1.AutoGenerateColumns = true;
|
||||
@@ -482,12 +476,20 @@ namespace FATrace.OEMApp
|
||||
|
||||
private void btnHistoryVideoSearch_Click(object sender, EventArgs e)
|
||||
{
|
||||
var query = FSqlContext.FDb.Select<VideoAction>();
|
||||
var query = FSqlContext.FDb.Select<OEMRawUse>();
|
||||
if (!string.IsNullOrEmpty(txtSearchCode.Text.Trim()))
|
||||
{
|
||||
query = query.Where(a => a.Code!.Contains(txtSearchCode.Text.Trim()));
|
||||
var kw = txtSearchCode.Text.Trim();
|
||||
query = query.Where(a => (a.InBagCode != null && a.InBagCode.Contains(kw))
|
||||
|| (a.RawCode != null && a.RawCode.Contains(kw))
|
||||
|| (a.RawName != null && a.RawName.Contains(kw)));
|
||||
}
|
||||
query.Where(a => a.CreateTime >= PdtHistorySearchStart.Value && a.CreateTime <= PdtHistorySearchEnd.Value);
|
||||
// 日期范围:起始日00:00:00(含)到结束日次日00:00:00(不含),覆盖整天
|
||||
var startDate = PdtHistorySearchStart.Value.Date;
|
||||
var endDate = PdtHistorySearchEnd.Value.Date;
|
||||
if (endDate < startDate) endDate = startDate;
|
||||
var endExclusive = endDate.AddDays(1);
|
||||
query = query.Where(a => a.CreateTime >= startDate && a.CreateTime < endExclusive);
|
||||
|
||||
// 拉取结果并刷新绑定列表
|
||||
var resultList = query.ToList();
|
||||
@@ -526,9 +528,9 @@ namespace FATrace.OEMApp
|
||||
try
|
||||
{
|
||||
var row = dataGridView1.Rows[e.RowIndex];
|
||||
if (row?.DataBoundItem is VideoAction va)
|
||||
if (row?.DataBoundItem is OEMRawUse item)
|
||||
{
|
||||
var path = va.VideoFilePath;
|
||||
var path = item.VideoFilePath;
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
MessageBox.Show("该记录没有可播放的视频路径。", "播放提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
@@ -557,18 +559,62 @@ namespace FATrace.OEMApp
|
||||
{
|
||||
if (dataGridView1 == null || dataGridView1.Columns.Count == 0) return;
|
||||
|
||||
var allowedProps = new HashSet<string>
|
||||
{
|
||||
nameof(OEMRawUse.InBagCode),
|
||||
nameof(OEMRawUse.RawName),
|
||||
nameof(OEMRawUse.RawCode),
|
||||
nameof(OEMRawUse.VideoFilePath),
|
||||
nameof(OEMRawUse.VideoName),
|
||||
nameof(OEMRawUse.User),
|
||||
nameof(OEMRawUse.CreateTime)
|
||||
};
|
||||
|
||||
foreach (DataGridViewColumn col in dataGridView1.Columns)
|
||||
{
|
||||
var propName = col.DataPropertyName;
|
||||
|
||||
|
||||
// 设置列头中文
|
||||
if (!string.IsNullOrWhiteSpace(propName) && _historyHeaderMap.TryGetValue(propName, out var headerText))
|
||||
{
|
||||
col.HeaderText = headerText;
|
||||
}
|
||||
switch (col.Name)
|
||||
{
|
||||
case "InBagCode":
|
||||
col.Width = 400;
|
||||
break;
|
||||
case "RawName":
|
||||
col.Width = 200;
|
||||
break;
|
||||
case "RawCode":
|
||||
col.Width = 200;
|
||||
break;
|
||||
case "VideoFilePath":
|
||||
col.Width = 490;
|
||||
break;
|
||||
case "VideoName":
|
||||
col.Width = 450;
|
||||
break;
|
||||
case "User":
|
||||
col.Width = 100;
|
||||
break;
|
||||
case "CreateTime":
|
||||
col.Width = 200;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// 隐藏 Id 列
|
||||
if (propName == nameof(VideoAction.Id))
|
||||
if (propName == nameof(OEMRawUse.Id))
|
||||
{
|
||||
col.Visible = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 仅显示指定字段,其他隐藏
|
||||
if (!allowedProps.Contains(propName))
|
||||
{
|
||||
col.Visible = false;
|
||||
continue;
|
||||
@@ -585,7 +631,7 @@ namespace FATrace.OEMApp
|
||||
//}
|
||||
|
||||
// 时间列格式化
|
||||
if (propName is nameof(VideoAction.StartTime) or nameof(VideoAction.EndTime) or nameof(VideoAction.CreateTime))
|
||||
if (propName is nameof(OEMRawUse.CreateTime))
|
||||
{
|
||||
col.DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:ss";
|
||||
col.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||
@@ -610,11 +656,13 @@ namespace FATrace.OEMApp
|
||||
/// <param name="e"></param>
|
||||
private void btnTestAction_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CurParsedCodeInfo==null) return ;
|
||||
|
||||
var taskId = DownloadTaskWorker.Instance.Enqueue(
|
||||
CurParsedCodeInfo,
|
||||
user: CurUserName,
|
||||
start: DateTime.Now,
|
||||
end: DateTime.Now.AddSeconds(DownloadTaskWorker.VideoTime)
|
||||
start: DateTime.Now.AddDays(-2),
|
||||
end: DateTime.Now.AddDays(-2).AddSeconds(DownloadTaskWorker.VideoTime)
|
||||
);
|
||||
//MessageBox.Show($"[Test] 已入队下载任务,Id={taskId}");
|
||||
}
|
||||
@@ -947,7 +995,7 @@ namespace FATrace.OEMApp
|
||||
}
|
||||
else
|
||||
{
|
||||
DownloadProgressBarMain.Value = 0;
|
||||
BeginInvoke(new Action(() => DownloadProgressBarMain.Value = 0));
|
||||
}
|
||||
_lastProgressLogged = -1;
|
||||
}
|
||||
@@ -1044,7 +1092,7 @@ namespace FATrace.OEMApp
|
||||
else
|
||||
{
|
||||
try { BeginInvoke(new Action(() => DownloadFileName.Text = name ?? string.Empty)); } catch { }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
Reference in New Issue
Block a user