From a69ee1594f35429df8e728129c85e51b176e81c7 Mon Sep 17 00:00:00 2001 From: liuwf Date: Mon, 16 Dec 2024 15:09:46 +0800 Subject: [PATCH] =?UTF-8?q?.change-=E6=96=B0=E5=AE=B9=E5=99=A8=E5=85=A5?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CsbHandleBusiness.cs | 21 ++++--- .../viewModel/MainWindowViewModel.cs | 56 +++++++++++++++---- .../containerStorageQueryByCsbViewModel.cs | 37 +++++++++++- 3 files changed, 95 insertions(+), 19 deletions(-) diff --git a/SlnMesnac.RfidUpload.Business/CsbHandleBusiness.cs b/SlnMesnac.RfidUpload.Business/CsbHandleBusiness.cs index dcc0258..e296d15 100644 --- a/SlnMesnac.RfidUpload.Business/CsbHandleBusiness.cs +++ b/SlnMesnac.RfidUpload.Business/CsbHandleBusiness.cs @@ -181,36 +181,40 @@ namespace SlnMesnac.RfidUpload.Business /// /// 新容器入库-按送货单接收容器接口 /// - public void containerStorageBatchQueryByCsb(string trackNo, string batchNo, string rqtmList, string rqtmEnd) + public CsbResult containerStorageBatchQueryByCsb(string trackNo, string batchNo, List rqtmList) { + CsbResult res = new CsbResult(); try { var jsonObject = new JObject { ["opOrgCode"] = appConfig.opOrgCode, ["trackNo"] = trackNo, - ["devicedId"] = appConfig.devicedId, ["batchNo"] = batchNo, - ["rqtmList"] = rqtmList, - ["rqtmEnd"] = rqtmEnd, + ["devicedId"] = appConfig.devicedId, + ["rqtmList"] = JArray.FromObject(rqtmList), + // ["rqtmEnd"] = rqtmEnd, }; string jsonString = jsonObject.ToString(); var str = webApiClientApp.UploadAsync("containerStorageBatchQueryByCsb", "newContainerStorageBatchQuery", jsonString, "新容器入库-按送货单接收容器接口"); - CsbResult res = JsonConvert.DeserializeObject(str); + res = JsonConvert.DeserializeObject(str); + return res; } catch (Exception ex) { logHelper.Error($"新容器入库-按送货单接收容器接口处理异常:{ex.Message}", ex); + return res; } } /// /// 6.6.新容器入库-按送货单反馈接收结果接口 /// - public void receContainerStorageByCsb(string trackNo, string msgType) + public CsbResult receContainerStorageByCsb(string trackNo, string msgType) { + CsbResult res = new CsbResult(); try { var jsonObject = new JObject @@ -222,12 +226,13 @@ namespace SlnMesnac.RfidUpload.Business string jsonString = jsonObject.ToString(); var str = webApiClientApp.UploadAsync("receContainerStorageByCsb", "newContainerStorageQuery", jsonString, "新容器入库-按送货单反馈接收结果接口"); - CsbResult res = JsonConvert.DeserializeObject(str); - + res = JsonConvert.DeserializeObject(str); + return res; } catch (Exception ex) { logHelper.Error($"新容器入库-按送货单反馈接收结果接口处理异常:{ex.Message}", ex); + return res; } } /// diff --git a/SlnMesnac.RfidUpload.UI/viewModel/MainWindowViewModel.cs b/SlnMesnac.RfidUpload.UI/viewModel/MainWindowViewModel.cs index b83ade0..3d394e3 100644 --- a/SlnMesnac.RfidUpload.UI/viewModel/MainWindowViewModel.cs +++ b/SlnMesnac.RfidUpload.UI/viewModel/MainWindowViewModel.cs @@ -19,6 +19,7 @@ using ApiServer = SlnMesnac.RfidUpload.TouchSocket.ApiServer; using System.Windows; using System.Threading; using static SlnMesnac.RfidUpload.UI.SelectRouterWindow; +using static SlnMesnac.RfidUpload.UI.viewModel.containerStorageQueryByCsbViewModel; namespace SlnMesnac.RfidUpload.UI.viewModel { @@ -38,6 +39,7 @@ namespace SlnMesnac.RfidUpload.UI.viewModel private AppConfig appConfig = AppConfig.Instance; private JsonChange jsonChange = JsonChange.Instance; private int No = 1; + private string TrackNo = ""; //暂存库存容器分发配发机构数据 private Institution Institution; #region 参数定义 @@ -249,6 +251,7 @@ namespace SlnMesnac.RfidUpload.UI.viewModel public MainWindowViewModel() { containerStorageQueryByCsbViewModel.RefreshSubmitVerifyEvent += RefreshSubmitVerify; + containerStorageQueryByCsbViewModel.RefreshTrackNoEvent += RefreshTrackNo; TransferOrderViewModel.RefreshSubmitVerifyEvent += RefreshSubmitVerify; SelectRouterWindow.RefreshSubmitVerifyEvent += RefreshSubmitVerify; logger.Info("程序启动"); @@ -410,18 +413,44 @@ namespace SlnMesnac.RfidUpload.UI.viewModel { if (workModelParam == 1) //新容器入库 { - //取出托盘号并调用接口 - var palletInfo = labelItems.FirstOrDefault(); - if (palletInfo == null) - { - MessageBox.Show("请先放包裹读条码!"); - return; - } - else + var info = labelItems.ToList(); + var strList = info.Select(x => x.result).ToList(); + int batchNo = 0; + string opBatch = System.Guid.NewGuid().ToString("N").Substring(0, 20); + ListPage ls = new ListPage(strList, 500); + CsbResult res = new CsbResult(); + foreach (var enumerable in ls.GetPage()) { - CsbResult res = csbHandleBusiness.scanAnyContainerCodeByCsb(palletInfo.result); - MessageBox.Show("新容器入库" + res.message); + batchNo++; + res = csbHandleBusiness.containerStorageBatchQueryByCsb(TrackNo,batchNo.ToString(), enumerable.ToList()); } + MainPageTipMessage = $"新容器入库 [{res.GetMsg()}]"; + Task.Run(() => + { + Thread.Sleep(3000); + CsbResult res = csbHandleBusiness.receContainerStorageByCsb(TrackNo, "1"); + + Application.Current.Dispatcher.Invoke(() => + { + MainPageTipMessage = $"新容器入库反馈接口,[{res.GetMsg()}]"; + + }); + + }); + + + ////取出托盘号并调用接口 + //var palletInfo = labelItems.FirstOrDefault(); + //if (palletInfo == null) + //{ + // MessageBox.Show("请先放包裹读条码!"); + // return; + //} + //else + //{ + // CsbResult res = csbHandleBusiness.scanAnyContainerCodeByCsb(palletInfo.result); + // MessageBox.Show("新容器入库" + res.message); + //} } else if (workModelParam == 2) //封发-按调拨单 { @@ -752,6 +781,13 @@ namespace SlnMesnac.RfidUpload.UI.viewModel } } + + private void RefreshTrackNo(string trackNo) + { + MainPageTipMessage = "trackNo:" + trackNo; + TrackNo = trackNo; + } + } } diff --git a/SlnMesnac.RfidUpload.UI/viewModel/containerStorageQueryByCsbViewModel.cs b/SlnMesnac.RfidUpload.UI/viewModel/containerStorageQueryByCsbViewModel.cs index 4e58e59..93e5309 100644 --- a/SlnMesnac.RfidUpload.UI/viewModel/containerStorageQueryByCsbViewModel.cs +++ b/SlnMesnac.RfidUpload.UI/viewModel/containerStorageQueryByCsbViewModel.cs @@ -1,5 +1,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using SlnMesnac.RfidUpload.Business; using SlnMesnac.RfidUpload.Model; using SlnMesnac.RfidUpload.Model.apiParam; @@ -51,6 +53,9 @@ namespace SlnMesnac.RfidUpload.UI.viewModel /// public delegate void RefreshSubmitVerifyDelegate(int model,string msg, TransferOrderInfo transferOrderInfo = null, Institution institution = null); public static event RefreshSubmitVerifyDelegate RefreshSubmitVerifyEvent; + + public delegate void RefreshTrackNo(string trackNo); + public static event RefreshTrackNo RefreshTrackNoEvent; #endregion @@ -96,6 +101,15 @@ namespace SlnMesnac.RfidUpload.UI.viewModel if (res.code == "200") { + JObject job = JObject.Parse(res.body); + string str = job["retBody"]?["object"]?.ToString(); + if (!string.IsNullOrEmpty(str)) + { + TrackResult trackResult = JsonConvert.DeserializeObject(str); + MessageBox.Show($"传递trackNo"+ trackResult.trackNo); + RefreshTrackNoEvent?.Invoke(trackResult.trackNo); + } + MessageBox.Show($"新容器入库-调拨单号验证通过"); TransferOrderInfo transferOrderInfo = new TransferOrderInfo() { dbdh = _dbbh, @@ -109,7 +123,28 @@ namespace SlnMesnac.RfidUpload.UI.viewModel { MessageBox.Show($"新容器入库-调拨单号验证失败,status:{res.code};msg:{res.GetMsg()};"); } - + + } + + public class TrackResult + { + public String trackNo { get; set; } + public List rqtmSerialList { get; set; } + + } + + public class rqtmSerialDto + { + public String rqzlmc { get; set; } + public String rqxhmc { get; set; } + public String rqtmStart { get; set; } + public String rqtmEnd { get; set; } + } + + + + + } }