using SlnMesnac.RfidUpload.Business;
using SlnMesnac.RfidUpload.Common;
using SlnMesnac.RfidUpload.Model;
using SlnMesnac.RfidUpload.Model.apiParam;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
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, Institution institution = null);
public static event RefreshSubmitVerifyDelegate RefreshSubmitVerifyEvent;
#endregion
private CsbHandleBusiness csbHandleBusiness = CsbHandleBusiness.Instance;
TransferOrderInfo _transferOrderInfo;
///
/// 区分属于哪个界面
/// 由于库存容器分发配发与卸车容器分发配发使用同一个界面与viewmodel
/// BelongPage = 3,表示库存容器分发配发,BelongPage = 4,表示卸车容器分发配发
public int BelongPage = 3;
public SelectRouterWindow(TransferOrderInfo transferOrderInfo,int _BelongPage)
{
BelongPage = _BelongPage;
_transferOrderInfo = transferOrderInfo;
InitializeComponent();
}
///
/// 二、获取卸交站
///
///
///
private void QueryButton_Click(object sender, RoutedEventArgs e)
{
try
{
if (string.IsNullOrEmpty(this.RouteCode.Text))
{
this.PageMessage.Content = "请先输入邮路代码";
// MessageBox.Show("请先输入邮路代码");
return;
}
CsbHandleBusiness.iNIFile.IniWriteValue("TdjContainerAllotQuery", "routeCode", this.RouteCode.Text);
#region 正式启用
// 自动生成opBatch
string opBatch = Guid.NewGuid().ToString("N").Substring(0, 20);
OpBatchManager.BathNo = opBatch;
CsbResult res = csbHandleBusiness.findStationSequenceByCsb(_transferOrderInfo.ffjhNo, opBatch);
this.PageMessage.Content = res.GetMsg();
if (res.IsSuccess)
{
List institutionList = res.ToObjectList();
int count = 1;
Console.WriteLine("机构信息:");
foreach (var institution in institutionList)
{
institution.No = count++.ToString();
institution.opBatch = opBatch;
}
InstitutionList.ItemsSource = institutionList;
}
else
{
MessageBox.Show(res.message);
}
#endregion
}
catch (Exception ex)
{
this.PageMessage.Content = $"获取卸交站异常:{ex.Message}";
// MessageBox.Show($"获取卸交站异常:{ex.Message}");
}
}
///
///
/// 三、验证封发计划- 不指定机构
///
///
///
private void HandOutButton_Click(object sender, RoutedEventArgs e)
{
//string opBatch = Guid.NewGuid().ToString("N").Substring(0, 20);
//CsbResult res = csbHandleBusiness.tranPlanCheckByCsb(_transferOrderInfo.ffjhNo,opBatch,"","");
//this.PageMessage.Content = "校验发运计划结果:"+res.GetMsg();
//if (res.code == "200")
//{
// RefreshSubmitVerifyEvent?.Invoke(3, res.GetMsg(), _transferOrderInfo);
// this.Close();
//}
FfjhCheck();
}
// 三、验证封发计划 -指定机构
private void ExecuteCommand_Click(object sender, RoutedEventArgs e)
{
var button = sender as Button;
var institution = button.DataContext as Institution;
if (institution != null)
{
FfjhCheck(institution);
// string opBatch = OpBatchManager.BathNo;
// CsbResult res = csbHandleBusiness.tranPlanCheckByCsb(_transferOrderInfo.ffjhNo, opBatch, institution.stationOrgCode,institution.stationOrgName);
// MessageBox.Show($"执行配发 6.12.容器直连配发-校验发运计划 容器封发完毕后直接向指定机构进行容器配发 :{res.message}");
// if (res.code == "200")
// {
// RefreshSubmitVerifyEvent?.Invoke(3, res.GetMsg(), _transferOrderInfo);
// this.Close();
// }
}
}
///
/// 封发计划校验
/// 可传递机构机构实体,机构代码、机构名称供后续效验封发计划使用
///
private void FfjhCheck(Institution institution = null)
{
#region 正式启用
//6.8 验证封发计划接口
CsbResult res = csbHandleBusiness.transferOrderFfjhCheckByCsb(_transferOrderInfo.ffjhNo, _transferOrderInfo.ffjhscrq);
this.PageMessage.Content = $"验证封发计划接口:{res.GetMsg()}";
if (res.IsSuccess)
{
//封发计划正常可封发
RefreshSubmitVerifyEvent?.Invoke(BelongPage, res.GetMsg(), _transferOrderInfo,institution);
this.Close();
}
#endregion
}
///
/// 机构实体
///
public class Institution
{
public string No { get; set; }
public string stationOrgCode { get; set; }
public string stationOrgName { get; set; }
public string opBatch { get; set; }
}
}
}