From 91a8b511ec1fadca253994d792bf3d26f8e3fa0a Mon Sep 17 00:00:00 2001 From: "nodyang@aliyun.com" Date: Thu, 12 Dec 2024 12:23:23 +0800 Subject: [PATCH] 34 --- SlnMesnac.RfidUpload.Common/SqLiteHelper.cs | 164 +++++++++--------- .../apiParam/CsbResult.cs | 4 +- .../SelectRouterWindow.xaml.cs | 11 +- .../ContainerTransferOrderViewModel.cs | 47 ++--- .../viewModel/MainWindowViewModel.cs | 2 - .../viewModel/TransferOrderViewModel.cs | 83 +++++---- 6 files changed, 143 insertions(+), 168 deletions(-) diff --git a/SlnMesnac.RfidUpload.Common/SqLiteHelper.cs b/SlnMesnac.RfidUpload.Common/SqLiteHelper.cs index e4c6b45..2942ef7 100644 --- a/SlnMesnac.RfidUpload.Common/SqLiteHelper.cs +++ b/SlnMesnac.RfidUpload.Common/SqLiteHelper.cs @@ -1,91 +1,91 @@ -using SQLite; +//using SQLite; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq.Expressions; -using System.Text; +//using System; +//using System.Collections.Generic; +//using System.IO; +//using System.Linq.Expressions; +//using System.Text; -namespace SlnMesnac.RfidUpload.Common -{ - /// - /// SQLite同步方法帮助类 - /// 作者:追逐时光者 - /// 创建时间:2023年11月30日 - /// - /// - public class SqLiteHelper where T : new() - { - private readonly string _databasePath = Path.Combine(Environment.CurrentDirectory, "db.db"); - private readonly SQLiteConnection _connection; // SQLite连接对象 +//namespace SlnMesnac.RfidUpload.Common +//{ +// /// +// /// SQLite同步方法帮助类 +// /// 作者:追逐时光者 +// /// 创建时间:2023年11月30日 +// /// +// /// +// public class SqLiteHelper where T : new() +// { +// private readonly string _databasePath = Path.Combine(Environment.CurrentDirectory, "db.db"); +// private readonly SQLiteConnection _connection; // SQLite连接对象 - /// - /// 构造函数 - /// - public SqLiteHelper() - { - // 创建SQLite连接对象并打开连接 - _connection = new SQLiteConnection(_databasePath); - _connection.CreateTable(); // 如果表不存在,则创建该表[不会创建重复的表] - } +// /// +// /// 构造函数 +// /// +// public SqLiteHelper() +// { +// // 创建SQLite连接对象并打开连接 +// _connection = new SQLiteConnection(_databasePath); +// _connection.CreateTable(); // 如果表不存在,则创建该表[不会创建重复的表] +// } - /// - /// 数据插入 - /// - /// 要插入的数据项 - /// - public int Insert(T item) - { - return _connection.Insert(item); - } +// /// +// /// 数据插入 +// /// +// /// 要插入的数据项 +// /// +// public int Insert(T item) +// { +// return _connection.Insert(item); +// } - /// - /// 数据删除 - /// - /// 要删除的数据的主键ID - /// - public int Delete(int id) - { - return _connection.Delete(id); - } +// /// +// /// 数据删除 +// /// +// /// 要删除的数据的主键ID +// /// +// public int Delete(int id) +// { +// return _connection.Delete(id); +// } - /// - /// 数据更新 - /// - /// 要更新的数据项 - /// - public int Update(T item) - { - return _connection.Update(item); - } +// /// +// /// 数据更新 +// /// +// /// 要更新的数据项 +// /// +// public int Update(T item) +// { +// return _connection.Update(item); +// } - /// - /// 根据条件查询记录 - /// - /// 查询条件 - /// - public List Query(Expression> predExpr) - { - return _connection.Table().Where(predExpr).ToList(); - } +// /// +// /// 根据条件查询记录 +// /// +// /// 查询条件 +// /// +// public List Query(Expression> predExpr) +// { +// return _connection.Table().Where(predExpr).ToList(); +// } - /// - /// 查询所有数据 - /// - /// - public List QueryAll() - { - return _connection.Table().ToList(); - } +// /// +// /// 查询所有数据 +// /// +// /// +// public List QueryAll() +// { +// return _connection.Table().ToList(); +// } - /// - /// 根据条件查询单条记录 - /// - /// 查询条件 - /// - public T QuerySingle(Expression> predExpr) - { - return _connection.Table().Where(predExpr).FirstOrDefault(); - } - } -} +// /// +// /// 根据条件查询单条记录 +// /// +// /// 查询条件 +// /// +// public T QuerySingle(Expression> predExpr) +// { +// return _connection.Table().Where(predExpr).FirstOrDefault(); +// } +// } +//} diff --git a/SlnMesnac.RfidUpload.Model/apiParam/CsbResult.cs b/SlnMesnac.RfidUpload.Model/apiParam/CsbResult.cs index 7a3a964..4cf6939 100644 --- a/SlnMesnac.RfidUpload.Model/apiParam/CsbResult.cs +++ b/SlnMesnac.RfidUpload.Model/apiParam/CsbResult.cs @@ -34,7 +34,9 @@ namespace SlnMesnac.RfidUpload.Model.apiParam public List @object { get; set; } - public string code { get; set; } + public string body { get; set; } + + public string code { get; set; } public string csbCode { get; set; } public string message { get; set; } } diff --git a/SlnMesnac.RfidUpload.UI/SelectRouterWindow.xaml.cs b/SlnMesnac.RfidUpload.UI/SelectRouterWindow.xaml.cs index 47032df..bf2c8ce 100644 --- a/SlnMesnac.RfidUpload.UI/SelectRouterWindow.xaml.cs +++ b/SlnMesnac.RfidUpload.UI/SelectRouterWindow.xaml.cs @@ -90,16 +90,7 @@ namespace SlnMesnac.RfidUpload.UI } #endregion - #region 测试数据 - // 初始化数据源 - var institutions = new List - { - new Institution { No = "1", stationOrgCode = "001", stationOrgName = "机构A" }, - new Institution { No = "2", stationOrgCode = "002", stationOrgName = "机构B" }, - }; - - InstitutionList.ItemsSource = institutions; - #endregion + } catch (Exception ex) { diff --git a/SlnMesnac.RfidUpload.UI/viewModel/ContainerTransferOrderViewModel.cs b/SlnMesnac.RfidUpload.UI/viewModel/ContainerTransferOrderViewModel.cs index 6ddb47f..2695eb6 100644 --- a/SlnMesnac.RfidUpload.UI/viewModel/ContainerTransferOrderViewModel.cs +++ b/SlnMesnac.RfidUpload.UI/viewModel/ContainerTransferOrderViewModel.cs @@ -135,49 +135,22 @@ namespace SlnMesnac.RfidUpload.UI.viewModel return; } #region 正式启用 - //CsbResult res = csbHandleBusiness.transferOrderFfjhByCsb("", _startDate.Value.ToString(), _endDate.Value.ToString()); - //MessageBox.Show(res.message); - //if (res.code == "200") - //{ - // if (res.@object != null && res.@object.Count > 0) - // { - // List institutionList = res.@object.ConvertAll(item => JsonConvert.DeserializeObject(item.ToString())); - // TransferOrderInfoItems = new ObservableCollection(institutionList); - // } - //} - #endregion - - - - #region 测试启用 - result res = new result() + CsbResult res = csbHandleBusiness.transferOrderFfjhByCsb("", _startDate.Value.ToString(), _endDate.Value.ToString()); + MessageBox.Show(res.message); + if (res.code == "200") { - status = "1", - msg = "测试", - @object = new List() + if (res.@object != null && res.@object.Count > 0) { - new TransferOrderInfo() - { - dbdh = "123", - jsdw = "123", - ffjhNo = "jh123", - ffjhscrq = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") - }, - new TransferOrderInfo() - { - dbdh = "324", - jsdw = "456", - ffjhNo = "jh456", - ffjhscrq = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") - } + List institutionList = res.@object.ConvertAll(item => JsonConvert.DeserializeObject(item.ToString())); + TransferOrderInfoItems = new ObservableCollection(institutionList); } - }; - if (res.@object != null) - { - TransferOrderInfoItems = new ObservableCollection(res.@object); } #endregion + + + + } diff --git a/SlnMesnac.RfidUpload.UI/viewModel/MainWindowViewModel.cs b/SlnMesnac.RfidUpload.UI/viewModel/MainWindowViewModel.cs index f0c6c38..e2e32eb 100644 --- a/SlnMesnac.RfidUpload.UI/viewModel/MainWindowViewModel.cs +++ b/SlnMesnac.RfidUpload.UI/viewModel/MainWindowViewModel.cs @@ -16,8 +16,6 @@ using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; using ApiServer = SlnMesnac.RfidUpload.TouchSocket.ApiServer; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json; using System.Windows; using System.Threading; diff --git a/SlnMesnac.RfidUpload.UI/viewModel/TransferOrderViewModel.cs b/SlnMesnac.RfidUpload.UI/viewModel/TransferOrderViewModel.cs index 48c4a7b..cc72195 100644 --- a/SlnMesnac.RfidUpload.UI/viewModel/TransferOrderViewModel.cs +++ b/SlnMesnac.RfidUpload.UI/viewModel/TransferOrderViewModel.cs @@ -15,7 +15,11 @@ using System.ServiceModel.Channels; using System.Text; using System.Threading.Tasks; using System.Windows; +using NewLife; +using Newtonsoft.Json; using static SlnMesnac.RfidUpload.UI.SelectRouterWindow; +using NewLife.Log; +using Newtonsoft.Json.Linq; #region << 版 本 注 释 >> /*-------------------------------------------------------------------- @@ -133,49 +137,56 @@ namespace SlnMesnac.RfidUpload.UI.viewModel return; } #region 正式启用 - //CsbResult res = csbHandleBusiness.transferOrderFfjhByCsb(_drj, _startDate.Value.ToString(), _endDate.Value.ToString()); - //MessageBox.Show(res.message); - //if (res.code == "200") - //{ - // if (res.@object != null && res.@object.Count > 0) - // { - // List institutionList = res.@object.ConvertAll(item => JsonConvert.DeserializeObject(item.ToString())); - // TransferOrderInfoItems = new ObservableCollection(institutionList); - // } - //} - #endregion - + CsbResult res = csbHandleBusiness.transferOrderFfjhByCsb(_drj, _startDate.Value.ToString(), _endDate.Value.ToString()); + MessageBox.Show(res.message); + if (res.code == "200") + { - #region 测试 - result res = new result() - { - status = "1", - msg = "测试", - @object = new List() + JObject job = JObject.Parse(res.body); + string str = job["retBody"]?["object"]?.ToString(); + if (!str.IsNullOrEmpty()) { - new TransferOrderInfo() - { - dbdh = "123", - jsdw = "123", - ffjhNo = "jh123", - ffjhscrq = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") - }, - new TransferOrderInfo() - { - dbdh = "324", - jsdw = "456", - ffjhNo = "jh456", - ffjhscrq = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") - } + + + List institutionList = JsonConvert.DeserializeObject>(str); + TransferOrderInfoItems = new ObservableCollection(institutionList); + } - }; - if (res.@object != null) - { - TransferOrderInfoItems = new ObservableCollection(res.@object); } #endregion + + + //#region 测试 + //result res = new result() + //{ + // status = "1", + // msg = "测试", + // @object = new List() + // { + // new TransferOrderInfo() + // { + // dbdh = "123", + // jsdw = "123", + // ffjhNo = "jh123", + // ffjhscrq = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + // }, + // new TransferOrderInfo() + // { + // dbdh = "324", + // jsdw = "456", + // ffjhNo = "jh456", + // ffjhscrq = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + // } + // } + //}; + //if (res.@object != null) + //{ + // TransferOrderInfoItems = new ObservableCollection(res.@object); + //} + //#endregion + } ///