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; using SlnMesnac.RfidUpload.UI.TempData; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Threading; using static SlnMesnac.RfidUpload.UI.SelectRouterWindow; using static SlnMesnac.RfidUpload.UI.viewModel.containerStorageQueryByCsbViewModel; #region << 版 本 注 释 >> /*-------------------------------------------------------------------- * 版权所有 (c) 2024 WenJY 保留所有权利。 * CLR版本:4.0.30319.42000 * 机器名称:T14-GEN3-7895 * 命名空间:SlnMesnac.RfidUpload.UI.viewModel * 唯一标识:a65ccfd9-c493-46c4-9905-7a7d55ef1508 * * 创建者:WenJY * 电子邮箱: * 创建时间:2024-12-06 16:31:16 * 版本:V1.0.0 * 描述: * *-------------------------------------------------------------------- * 修改人: * 时间: * 修改说明: * * 版本:V1.0.0 *--------------------------------------------------------------------*/ #endregion << 版 本 注 释 >> namespace SlnMesnac.RfidUpload.UI.viewModel { public partial class containerStorageQueryByCsbViewModel : ObservableObject { private SysData sysData = SysData.Instance; private readonly Window _window; #region 委托事件 /// /// model-新容器入库-调拨单号验证状态成功1,失败-1 /// model-容器封发-验证封发计划接口,状态成功2,失败-1 /// dbdh-调拨单号 /// status- 1-正常 /// /// /// 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 public containerStorageQueryByCsbViewModel(Window window) { _window = window; RefreshItems(); } private void RefreshItems() { TrackNoItems.Clear(); sysData.trackNoList = sysData.trackNoList.OrderByDescending(x => x.time).ToList(); Dispatcher.CurrentDispatcher.BeginInvoke(() => { sysData.trackNoList.ForEach(x => TrackNoItems.Add(x)); }); } private ObservableCollection _trackNoItems = new ObservableCollection(); public ObservableCollection TrackNoItems { get => _trackNoItems; set => SetProperty(ref _trackNoItems, value); } private CsbHandleBusiness csbHandleBusiness = CsbHandleBusiness.Instance; public string _dbbh = string.Empty; public string dbbh { get => _dbbh; set => SetProperty(ref _dbbh, value); } public string _rqtmStart = string.Empty; public string rqtmStart { get => _rqtmStart; set => SetProperty(ref _rqtmStart, value); } private string _rqtmEnd = string.Empty; public string rqtmEnd { get => _rqtmEnd; set { _rqtmEnd = value; OnPropertyChanged(nameof(_rqtmEnd)); } } [RelayCommand] private void Submit() { Check(_dbbh, _rqtmStart, _rqtmEnd); } /// /// 新容器入库-调拨单号验证 /// /// /// /// private void Check(string dbbh,string rqtmStart, string rqtmEnd) { try { CsbResult res = csbHandleBusiness.containerStorageQueryByCsb(dbbh,rqtmStart,rqtmEnd); 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); if (sysData.trackNoList.FirstOrDefault(x => x.trackNo == trackResult.trackNo) == null) { sysData.trackNoList.Add(new newContainerInCheckData() { dbdh = _dbbh, trackNo = trackResult.trackNo, rqtmStart = _rqtmStart, rqtmEnd = _rqtmEnd, time = DateTime.Now }); } RefreshItems(); } MessageBox.Show($"新容器入库-调拨单号验证通过"); TransferOrderInfo transferOrderInfo = new TransferOrderInfo() { dbdh = _dbbh, }; RefreshSubmitVerifyEvent?.Invoke(1, res.GetMsg(), transferOrderInfo); _window.Close(); } else { MessageBox.Show($"新容器入库-调拨单号验证失败,status:{res.code};msg:{res.GetMsg()};"); } }catch (Exception ex) { MessageBox.Show("新容器入库-调拨单号验证异常:" + ex.Message); } } /// /// 执行分发 容器封发-验证封发计划 /// /// [RelayCommand] private void Execute(newContainerInCheckData newContainerInCheck) { Check(newContainerInCheck.dbdh, newContainerInCheck.rqtmStart, newContainerInCheck.rqtmEnd); } 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; } } } }