DataServices 现场调试OK

This commit is contained in:
2025-11-26 16:46:48 +08:00
parent 979afae645
commit 010272aa0b
31 changed files with 1866 additions and 267 deletions

View File

@@ -365,56 +365,56 @@ namespace FATrace.WPLApp.ViewModels
/// </summary>
private void ExportToCsv()
{
if (IsBusy) return;
if (Items.Count == 0)
{
System.Windows.MessageBox.Show("无可导出的数据", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
//if (IsBusy) return;
//if (Items.Count == 0)
//{
// System.Windows.MessageBox.Show("无可导出的数据", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
// return;
//}
try
{
IsBusy = true;
//try
//{
// IsBusy = true;
var dr = "D:\\迅雷下载";
// 转换为 RawProUserCsvDto
var all = Items.Select(it => new RawProUserCsvDto
{
RawCode = it.RawCode,
RawName = it.RawName,
InBagCode = it.InBagCode,
BoxCode = it.BoxCode,
Batch = it.Batch,
ShelfLife = it.ShelfLife,
Weight = it.Weight,
DeliveryDate = it.WeightTime.ToString("yyyyMMdd"),
RemainWeight = it.RemainWeight,
StockWeight = it.StockWeight,
WeightTime = it.WeightTime,
OpUser = it.OpUser,
CheckUser = it.CheckUser,
OutTime = it.OutTime
}).ToList();
// var dr = "D:\\迅雷下载";
// // 转换为 RawProUserCsvDto
// var all = Items.Select(it => new RawProUserCsvDto
// {
// RawCode = it.RawCode,
// RawName = it.RawName,
// InBagCode = it.InBagCode,
// BoxCode = it.BoxCode,
// Batch = it.Batch,
// ShelfLife = it.ShelfLife,
// Weight = it.Weight,
// DeliveryDate = it.WeightTime.ToString("yyyyMMdd"),
// RemainWeight = it.RemainWeight,
// StockWeight = it.StockWeight,
// WeightTime = it.WeightTime,
// OpUser = it.OpUser,
// CheckUser = it.CheckUser,
// OutTime = it.OutTime
// }).ToList();
// 过滤 InBagCode 为空的记录,避免导出失败
var valid = all.Where(x => !string.IsNullOrWhiteSpace(x.InBagCode)).ToList();
int skipped = all.Count - valid.Count;
// // 过滤 InBagCode 为空的记录,避免导出失败
// var valid = all.Where(x => !string.IsNullOrWhiteSpace(x.InBagCode)).ToList();
// int skipped = all.Count - valid.Count;
var svc = csvServices;
var paths = svc.ExportMany(valid, dr, overwrite: true);
// var svc = csvServices;
// var paths = svc.ExportMany(valid, dr, overwrite: true);
_log.Info($"RawProUse CSV 导出完成: 目录={dr}, 成功={valid.Count}, 跳过={skipped}");
System.Windows.MessageBox.Show($"导出完成:成功 {valid.Count} 条,跳过 {skipped} 条。\n目录{dr}", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
_log.Error($"RawProUse CSV 导出失败: {ex}");
System.Windows.MessageBox.Show($"导出失败: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
finally
{
IsBusy = false;
}
// _log.Info($"RawProUse CSV 导出完成: 目录={dr}, 成功={valid.Count}, 跳过={skipped}");
// System.Windows.MessageBox.Show($"导出完成:成功 {valid.Count} 条,跳过 {skipped} 条。\n目录{dr}", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
//}
//catch (Exception ex)
//{
// _log.Error($"RawProUse CSV 导出失败: {ex}");
// System.Windows.MessageBox.Show($"导出失败: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
//}
//finally
//{
// IsBusy = false;
//}
}
/// <summary>