using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SlnMesnac.RfidUpload.Business; using SlnMesnac.RfidUpload.Common; using SlnMesnac.RfidUpload.Model; using SlnMesnac.RfidUpload.Model.apiParam; using SlnMesnac.RfidUpload.UI.viewModel; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using TouchSocket.Core; using static SlnMesnac.RfidUpload.UI.SelectRouterWindow; namespace SlnMesnac.RfidUpload.UI { /// /// containerStorageQueryByCsb.xaml 的交互逻辑 /// public partial class SelectRouterWindow : Window { #region 委托事件 /// /// model-新容器入库-调拨单号验证状态成功1,失败-1 /// model-容器封发-验证封发计划接口,状态成功2,失败-1 /// dbdh-调拨单号 /// status- 1-正常 /// /// /// public delegate void RefreshSubmitVerifyDelegate(int model, string msg, TransferOrderInfo transferOrderInfo = null); public static event RefreshSubmitVerifyDelegate RefreshSubmitVerifyEvent; #endregion private CsbHandleBusiness csbHandleBusiness = CsbHandleBusiness.Instance; TransferOrderInfo _transferOrderInfo; public SelectRouterWindow(TransferOrderInfo transferOrderInfo) { _transferOrderInfo = transferOrderInfo; InitializeComponent(); } /// /// 获取卸交站 /// /// /// private void QueryButton_Click(object sender, RoutedEventArgs e) { try { if (string.IsNullOrEmpty(this.RouteCode.Text)) { MessageBox.Show("请先输入邮路代码"); return; } CsbHandleBusiness.iNIFile.IniWriteValue("TdjContainerAllotQuery", "routeCode", this.RouteCode.Text); #region 正式启用 // 自动生成opBatch string opBatch = Guid.NewGuid().ToString("N").Substring(0, 20); CsbResult res = csbHandleBusiness.findStationSequenceByCsb(_transferOrderInfo.ffjhNo, opBatch); if (res.code == "200") { if (res.@object != null && res.@object.Count > 0) { List institutionList = res.@object.ConvertAll(item => JsonConvert.DeserializeObject(item.ToString())); int count = 1; Console.WriteLine("机构信息:"); foreach (var institution in institutionList) { institution.No = count++.ToString(); } InstitutionList.ItemsSource = institutionList; } } else { MessageBox.Show(res.message); } #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) { MessageBox.Show($"获取卸交站异常:{ex.Message}"); } } /// /// 封发配发 6.12.容器直连配发-校验发运计划 /// 可不指定机构直接完成容器封发配发 /// /// /// private void HandOutButton_Click(object sender, RoutedEventArgs e) { string opBatch = Guid.NewGuid().ToString("N").Substring(0, 20); CsbResult res = csbHandleBusiness.tranPlanCheckByCsb(_transferOrderInfo.ffjhNo,opBatch,"",""); MessageBox.Show(res.message); if (res.code == "200") { RefreshSubmitVerifyEvent?.Invoke(3, res.message, _transferOrderInfo); this.Close(); } } // 执行配发 6.12.容器直连配发-校验发运计划 // 容器封发完毕后直接向指定机构进行容器配发 private void ExecuteCommand_Click(object sender, RoutedEventArgs e) { var button = sender as Button; var institution = button.DataContext as Institution; if (institution != null) { string opBatch = Guid.NewGuid().ToString("N").Substring(0, 20); CsbResult res = csbHandleBusiness.tranPlanCheckByCsb(_transferOrderInfo.ffjhNo, opBatch, institution.stationOrgCode,institution.stationOrgName); if(res.code == "200") { RefreshSubmitVerifyEvent?.Invoke(3, res.message, _transferOrderInfo); this.Close(); } } } /// /// 机构实体 /// public class Institution { public string No { get; set; } public string stationOrgCode { get; set; } public string stationOrgName { get; set; } } } }