You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

210 lines
6.7 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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 委托事件
/// <summary>
/// model-新容器入库-调拨单号验证状态成功1失败-1
/// model-容器封发-验证封发计划接口状态成功2失败-1
/// dbdh-调拨单号
/// status- 1-正常
/// </summary>
/// <param name="status"></param>
/// <param name="dbdh"></param>
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<newContainerInCheckData> _trackNoItems = new ObservableCollection<newContainerInCheckData>();
public ObservableCollection<newContainerInCheckData> 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);
}
/// <summary>
/// 新容器入库-调拨单号验证
/// </summary>
/// <param name="dbbh"></param>
/// <param name="rqtmStart"></param>
/// <param name="rqtmEnd"></param>
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<TrackResult>(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);
}
}
/// <summary>
/// 执行分发 容器封发-验证封发计划
/// </summary>
/// <param name="transferOrderInfo"></param>
[RelayCommand]
private void Execute(newContainerInCheckData newContainerInCheck)
{
Check(newContainerInCheck.dbdh, newContainerInCheck.rqtmStart, newContainerInCheck.rqtmEnd);
}
public class TrackResult
{
public String trackNo { get; set; }
public List<rqtmSerialDto> 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; }
}
}
}