增加盘点模式
This commit is contained in:
329
货架标准上位机/ViewModels/InOutRecordViewModel.cs
Normal file
329
货架标准上位机/ViewModels/InOutRecordViewModel.cs
Normal file
@ -0,0 +1,329 @@
|
||||
using HandyControl.Controls;
|
||||
using MiniExcelLibs;
|
||||
using Ping9719.WpfEx.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using SqlSugar;
|
||||
using HandyControl.Data;
|
||||
using System.Windows;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using 货架标准上位机.Views.Controls;
|
||||
using WCS.Model.ApiModel.User;
|
||||
using 货架标准上位机.Api;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using System.Windows.Controls;
|
||||
using WCS.Model.ApiModel.InterfaceRecord;
|
||||
using HandyControl.Collections;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.Model.ApiModel.MatInventoryDetail;
|
||||
using HandyControl.Tools.Extension;
|
||||
using WCS.Model.ApiModel.Stocktaking;
|
||||
using WCS.Model.ApiModel.InOutRecord;
|
||||
|
||||
namespace 货架标准上位机.ViewModel
|
||||
{
|
||||
public class InOutRecordViewModel : BindableBase
|
||||
{
|
||||
public InOutRecordViewModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void InitMatCode()
|
||||
{
|
||||
//调用接口更新!
|
||||
Task.Run(() =>
|
||||
{
|
||||
var body = new GetMatCodeListRequest()
|
||||
{
|
||||
IsFromBaseData = false,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
};
|
||||
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<string>>>(LocalFile.Config.ApiIpHost + "matBaseInfo/getMatCodeList", body, "POST");
|
||||
if (Result != null && Result.Data != null && Result.Data.Count() > 0)
|
||||
{
|
||||
matCodes = Result.Data.Select(t => new DataModel()
|
||||
{
|
||||
MatCode = t
|
||||
}).ToList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#region Property
|
||||
private List<InOutRecordModel> dataGridItemSource;
|
||||
public List<InOutRecordModel> DataGridItemSource
|
||||
{
|
||||
get { return dataGridItemSource; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref dataGridItemSource, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
private string matCode;
|
||||
public string MatCode
|
||||
{
|
||||
get { return matCode; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref matCode, value);
|
||||
FilterItems(value);
|
||||
}
|
||||
}
|
||||
public ManualObservableCollection<DataModel> Items { get; set; } = new();
|
||||
private List<DataModel> matCodes = new List<DataModel>();
|
||||
private void FilterItems(string key)
|
||||
{
|
||||
//至少输入三个字符 避免删除或输入时界面变卡
|
||||
if (string.IsNullOrEmpty(key) || key.Length < 3)
|
||||
{
|
||||
Items.Clear();
|
||||
return;
|
||||
}
|
||||
key = key.ToUpper();
|
||||
Items.CanNotify = false;
|
||||
Items.Clear();
|
||||
foreach (var matCode in matCodes)
|
||||
{
|
||||
if (matCode.MatCode.ToUpper().Contains(key))
|
||||
{
|
||||
Items.Add(matCode);
|
||||
}
|
||||
}
|
||||
Items.CanNotify = true;
|
||||
}
|
||||
public class DataModel()
|
||||
{
|
||||
public string MatCode { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
private string matName;
|
||||
public string MatName
|
||||
{
|
||||
get { return matName; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref matName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物料批次
|
||||
/// </summary>
|
||||
private string matBatch;
|
||||
public string MatBatch
|
||||
{
|
||||
get { return matBatch; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref matBatch, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 库位
|
||||
/// </summary>
|
||||
private string storeCode;
|
||||
public string StoreCode
|
||||
{
|
||||
get { return storeCode; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref storeCode, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物料条码 物料SN
|
||||
/// </summary>
|
||||
private string matSN;
|
||||
public string MatSN
|
||||
{
|
||||
get { return matSN; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref matSN, value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Command
|
||||
public ICommand BtnResetCommand { get => new DelegateCommand(BtnReset); }
|
||||
public void BtnReset()
|
||||
{
|
||||
MatCode = string.Empty;
|
||||
MatName = string.Empty;
|
||||
MatSN = string.Empty;
|
||||
StoreCode = string.Empty;
|
||||
}
|
||||
|
||||
public ICommand BtnSearchCommand { get => new DelegateCommand(BtnSearchReset); }
|
||||
public void BtnSearchReset()
|
||||
{
|
||||
BtnSearch(true);
|
||||
}
|
||||
public void BtnSearch(bool IsPageReset = true)
|
||||
{
|
||||
if (CurrentPage == 0 || IsPageReset)
|
||||
{
|
||||
CurrentPage = 1;
|
||||
return;
|
||||
}
|
||||
#region 调用接口获取数据
|
||||
var dia = Dialog.Show(new TextDialog());
|
||||
try
|
||||
{
|
||||
var body = new GetInOutRecordRequest()
|
||||
{
|
||||
MatName = MatName,
|
||||
MatSN = MatSN,
|
||||
MatBatch = MatBatch,
|
||||
MatCode = MatCode,
|
||||
StoreCode = StoreCode,
|
||||
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
PageNumber = CurrentPage,
|
||||
PageSize = 10,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<PageQueryResponse<InOutRecordModel>>(LocalFile.Config.ApiIpHost + "inOutRecord/getInOutRecord", body, "POST");
|
||||
if (Result != null && Result.Data != null && Result.Data.Lists != null)
|
||||
{
|
||||
DataGridItemSource = Result.Data.Lists;
|
||||
MaxPage = Result.Data.MaxPage;
|
||||
TotalCount = Result.Data.TotalCount;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error("加载数据失败:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
dia.Close();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public ICommand BtnExportCommand { get => new DelegateCommand(BtnExport); }
|
||||
public async void BtnExport()
|
||||
{
|
||||
try
|
||||
{
|
||||
#region 选择文件保存路径
|
||||
Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
|
||||
sfd.Filter = ".xlsx文件(*.xlsx)|*.xlsx";
|
||||
sfd.FileName = "出入库记录" + DateTime.Now.ToString("yyyyMMddhhmmss");
|
||||
sfd.OverwritePrompt = true;
|
||||
if (sfd.ShowDialog() != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string path = sfd.FileName;
|
||||
#endregion
|
||||
|
||||
#region 调用接口导出数据
|
||||
var body = new GetInOutRecordRequest()
|
||||
{
|
||||
MatName = MatName,
|
||||
MatSN = MatSN,
|
||||
MatBatch = MatBatch,
|
||||
MatCode = MatCode,
|
||||
StoreCode = StoreCode,
|
||||
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
PageNumber = CurrentPage,
|
||||
PageSize = 10,
|
||||
};
|
||||
await ApiHelp.PostDownloadFileAsync(path, System.Net.Http.HttpMethod.Post, LocalFile.Config.ApiIpHost + "inOutRecord/exportInOutRecord", body);
|
||||
Growl.Success("导出成功!");
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error("导出失败:" + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PageOperation 分页操作
|
||||
private int currentPage;
|
||||
public int CurrentPage
|
||||
{
|
||||
get { return currentPage; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref currentPage, value);
|
||||
BtnSearch(false);
|
||||
}
|
||||
}
|
||||
|
||||
private int maxPage;
|
||||
public int MaxPage
|
||||
{
|
||||
get { return maxPage; }
|
||||
set { SetProperty(ref maxPage, value); }
|
||||
}
|
||||
|
||||
//总数量
|
||||
private int totalCount;
|
||||
public int TotalCount
|
||||
{
|
||||
get { return totalCount; }
|
||||
set { SetProperty(ref totalCount, value); }
|
||||
}
|
||||
|
||||
public ICommand BtnFirstPageCommand { get => new DelegateCommand(BtnFirstPage); }
|
||||
public void BtnFirstPage()
|
||||
{
|
||||
CurrentPage = 1;
|
||||
}
|
||||
|
||||
public ICommand BtnPrePageCommand { get => new DelegateCommand(BtnPrePage); }
|
||||
public void BtnPrePage()
|
||||
{
|
||||
if (CurrentPage > 1)
|
||||
{
|
||||
CurrentPage--;
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand BtnNextPageCommand { get => new DelegateCommand(BtnNextPage); }
|
||||
public void BtnNextPage()
|
||||
{
|
||||
if (CurrentPage < MaxPage)
|
||||
{
|
||||
CurrentPage++;
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand BtnLastPageCommand { get => new DelegateCommand(BtnLastPage); }
|
||||
public void BtnLastPage()
|
||||
{
|
||||
if (CurrentPage != MaxPage)
|
||||
{
|
||||
CurrentPage = MaxPage;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -106,43 +106,43 @@ namespace 货架标准上位机.ViewModels
|
||||
// SelectedItemSource = itemSource;
|
||||
// return;
|
||||
//}
|
||||
#region 调用接口生成出库单据
|
||||
try
|
||||
{
|
||||
var body = new SysOutOrderByMatCodeRequest()
|
||||
{
|
||||
OrderType = "出库",
|
||||
OrderSource = "WCS前端",
|
||||
ItemList = DataGridItemSource.Select(t => new MatCodeItemList()
|
||||
{
|
||||
MatCode = t.MatCode,
|
||||
MatName = t.MatName,
|
||||
MatBatch = t.MatBatch,
|
||||
ReqQty = t.NeedQty,
|
||||
}).ToList(),
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
UserName = LocalStatic.CurrentUser
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outstore/sysOutOrderByMatCode", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
Growl.Success(Result.Message);
|
||||
OnRequestClose();
|
||||
}
|
||||
else if (Result != null)
|
||||
{
|
||||
Growl.Warning(Result.Message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error("加载数据失败:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#region 调用接口生成出库单据
|
||||
try
|
||||
{
|
||||
var body = new SysOutOrderByMatCodeRequest()
|
||||
{
|
||||
OrderType = "出库",
|
||||
OrderSource = "WCS前端",
|
||||
ItemList = DataGridItemSource.Select(t => new MatCodeItemList()
|
||||
{
|
||||
MatCode = t.MatCode,
|
||||
MatName = t.MatName,
|
||||
MatBatch = t.MatBatch,
|
||||
ReqQty = t.NeedQty,
|
||||
}).ToList(),
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
UserName = LocalStatic.CurrentUser
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outstore/sysOutOrderByMatCode", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
Growl.Success(Result.Message);
|
||||
OnRequestClose();
|
||||
}
|
||||
else if (Result != null)
|
||||
{
|
||||
Growl.Warning(Result.Message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error("加载数据失败:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -142,6 +142,7 @@ namespace 货架标准上位机.ViewModels
|
||||
if (DataGridItemSource == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
|
||||
//判断是否勾选数据
|
||||
@ -150,6 +151,7 @@ namespace 货架标准上位机.ViewModels
|
||||
if (selectedOutOrder == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
|
||||
#region 调用接口获取数据
|
||||
@ -205,6 +207,7 @@ namespace 货架标准上位机.ViewModels
|
||||
if (DataGridItemSource == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
|
||||
//判断是否勾选数据
|
||||
@ -213,6 +216,7 @@ namespace 货架标准上位机.ViewModels
|
||||
if (selectedOutOrder == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
#region 调用接口获取数据
|
||||
var body = new GetOutOrderDetailRequest()
|
||||
@ -282,6 +286,7 @@ namespace 货架标准上位机.ViewModels
|
||||
{
|
||||
OrderId = selectedOutOrder.Id,
|
||||
OrderNumber = selectedOutOrder.OrderNumber,
|
||||
IsStart = true,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
};
|
||||
@ -317,7 +322,56 @@ namespace 货架标准上位机.ViewModels
|
||||
public ICommand BtnPauseCommand { get => new DelegateCommand(BtnPause); }
|
||||
public void BtnPause()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DataGridItemSource == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
//判断是否勾选数据
|
||||
var selectedOutOrder = DataGridItemSource.Where(t => t.IsSelected)
|
||||
.FirstOrDefault();
|
||||
if (selectedOutOrder == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
|
||||
#region 调用接口结束出库
|
||||
var body = new GetOutOrderDetailRequest()
|
||||
{
|
||||
OrderId = selectedOutOrder.Id,
|
||||
OrderNumber = selectedOutOrder.OrderNumber,
|
||||
IsPause = true,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outStore/goOutOutstore", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
//刷新出库单列表
|
||||
OutVentoryView.viewModel.RefreshOutOrderList(selectedOutOrder.OrderNumber);
|
||||
Growl.Success("已暂停出库!");
|
||||
}
|
||||
else if (Result != null)
|
||||
{
|
||||
OutVentoryView.viewModel.RefreshOutOrderList(OutVentoryView.viewModel.SelectedOutOrder?.OrderNumber);
|
||||
Growl.Warning(Result.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("调用接口失败!");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error("出现异常:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -144,6 +144,7 @@ namespace 货架标准上位机.ViewModel
|
||||
if (SelectedOutOrder == null)
|
||||
{
|
||||
Growl.Warning("未选择单据!");
|
||||
return;
|
||||
}
|
||||
|
||||
#region 调用接口开始出库
|
||||
@ -157,7 +158,8 @@ namespace 货架标准上位机.ViewModel
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outStore/goInOutstore", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
Growl.Warning("已成功开始入库!");
|
||||
Growl.Warning("已成功开始出库!");
|
||||
RefreshDataGridItemSource();
|
||||
}
|
||||
else if (Result != null)
|
||||
{
|
||||
@ -187,8 +189,8 @@ namespace 货架标准上位机.ViewModel
|
||||
if (SelectedOutOrder == null)
|
||||
{
|
||||
Growl.Warning("未选择单据!");
|
||||
return;
|
||||
}
|
||||
|
||||
#region 调用接口结束出库
|
||||
var body = new GetOutOrderDetailRequest()
|
||||
{
|
||||
@ -200,7 +202,8 @@ namespace 货架标准上位机.ViewModel
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outStore/goOutOutstore", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
Growl.Warning("已成功结束入库!");
|
||||
Growl.Warning("已成功结束出库!");
|
||||
RefreshDataGridItemSource();
|
||||
}
|
||||
else if (Result != null)
|
||||
{
|
||||
|
@ -129,11 +129,7 @@ namespace 货架标准上位机.ViewModels
|
||||
OrderSource = string.Empty;
|
||||
}
|
||||
|
||||
//public ICommand BtnDeleteCommand { get => new DelegateCommand(BtnDelete); }
|
||||
//public void BtnDelete()
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
public ICommand BtnOrderDetailCommand { get => new DelegateCommand(BtnOrderDetail); }
|
||||
public void BtnOrderDetail()
|
||||
@ -143,39 +139,41 @@ namespace 货架标准上位机.ViewModels
|
||||
if (DataGridItemSource == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
|
||||
//判断是否勾选数据
|
||||
var selectedOutOrder = DataGridItemSource.Where(t => t.IsSelected)
|
||||
var selectetOrder = DataGridItemSource.Where(t => t.IsSelected)
|
||||
.FirstOrDefault();
|
||||
if (selectedOutOrder == null)
|
||||
if (selectetOrder == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
|
||||
#region 调用接口获取数据
|
||||
|
||||
var body = new GetOutOrderDetailRequest()
|
||||
var body = new GetStockTakingOrderMatDetailRequest()
|
||||
{
|
||||
OrderId = selectedOutOrder.Id,
|
||||
OrderNumber = selectedOutOrder.StocktakingOrderNumber,
|
||||
StockTakingOrderId = selectetOrder.Id,
|
||||
StockTakingOrderNumber = selectetOrder.StocktakingOrderNumber,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<OutOrderDetailModel>>>(LocalFile.Config.ApiIpHost + "outStore/getOutOrderDetail", body, "POST");
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<StockTakingOrderMatDetailModel>>>(LocalFile.Config.ApiIpHost + "stockTaking/getStockTakingOrderMatDetail", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
if (Result.Data.Count > 0)
|
||||
{
|
||||
//打开窗体
|
||||
var window = new OutInventoryDocumentDetailView(Result.Data);
|
||||
var window = new StocktakingDocumentDetailView(Result.Data);
|
||||
window.Owner = Application.Current.MainWindow;
|
||||
window.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("该单据没有单据明细!");
|
||||
Growl.Warning("该盘点单据不存在单据明细!");
|
||||
}
|
||||
}
|
||||
else if (Result != null)
|
||||
@ -206,6 +204,7 @@ namespace 货架标准上位机.ViewModels
|
||||
if (DataGridItemSource == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
|
||||
//判断是否勾选数据
|
||||
@ -214,6 +213,7 @@ namespace 货架标准上位机.ViewModels
|
||||
if (selectedOutOrder == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
#region 调用接口获取数据
|
||||
var body = new GetOutOrderDetailRequest()
|
||||
@ -262,61 +262,107 @@ namespace 货架标准上位机.ViewModels
|
||||
public ICommand BtnStartCommand { get => new DelegateCommand(BtnStart); }
|
||||
public void BtnStart()
|
||||
{
|
||||
WarningManager.AddWarning(new WCS.Model.WebSocketModel.WebSocketMessageModel());
|
||||
//try
|
||||
//{
|
||||
// if (DataGridItemSource == null)
|
||||
// {
|
||||
// Growl.Warning("未勾选数据!");
|
||||
// return;
|
||||
// }
|
||||
// //判断是否勾选数据
|
||||
// var selectedOutOrder = DataGridItemSource.Where(t => t.IsSelected)
|
||||
// .FirstOrDefault();
|
||||
// if (selectedOutOrder == null)
|
||||
// {
|
||||
// Growl.Warning("未勾选数据!");
|
||||
// return;
|
||||
// }
|
||||
try
|
||||
{
|
||||
//是否已搜索
|
||||
if (DataGridItemSource == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
//判断是否已勾选数据
|
||||
var selectetOrder = DataGridItemSource.Where(t => t.IsSelected)
|
||||
.FirstOrDefault();
|
||||
if (selectetOrder == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
|
||||
// #region 调用接口开始盘点
|
||||
// var body = new GetOutOrderDetailRequest()
|
||||
// {
|
||||
// OrderId = selectedOutOrder.Id,
|
||||
// OrderNumber = selectedOutOrder.StocktakingOrderNumber,
|
||||
// UserName = LocalStatic.CurrentUser,
|
||||
// DeviceType = LocalFile.Config.DeviceType,
|
||||
// };
|
||||
// var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outStore/goInOutstore", body, "POST");
|
||||
// if (Result != null && Result.Code == 200)
|
||||
// {
|
||||
// //成功后直接跳转
|
||||
// MainWindow1.viewModel.GoToOutVentoryView = true;
|
||||
// Growl.Success("已跳转到物料出库页面!");
|
||||
// }
|
||||
// else if (Result != null)
|
||||
// {
|
||||
// Growl.Warning(Result.Message);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Growl.Warning("调用接口失败!");
|
||||
// }
|
||||
// #endregion
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// Growl.Error("出现异常:" + ex.Message);
|
||||
//}
|
||||
//finally
|
||||
//{
|
||||
//}
|
||||
#region 调用接口开始盘点
|
||||
var body = new GetStockTakingOrderMatDetailRequest()
|
||||
{
|
||||
StockTakingOrderId = selectetOrder.Id,
|
||||
StockTakingOrderNumber = selectetOrder.StocktakingOrderNumber,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "stockTaking/startStockTakingOrder", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
//成功后直接跳转
|
||||
MainWindow1.viewModel.GoToStockTakingView = true;
|
||||
Growl.Success("已跳转到物料盘点页面!");
|
||||
}
|
||||
else if (Result != null)
|
||||
{
|
||||
Growl.Warning(Result.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("调用接口失败!");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error("出现异常:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand BtnPauseCommand { get => new DelegateCommand(BtnPause); }
|
||||
public void BtnPause()
|
||||
{
|
||||
WarningManager.RemoveWarning(Guid.NewGuid());
|
||||
try
|
||||
{
|
||||
//是否已搜索
|
||||
if (DataGridItemSource == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
//判断是否已勾选数据
|
||||
var selectetOrder = DataGridItemSource.Where(t => t.IsSelected)
|
||||
.FirstOrDefault();
|
||||
if (selectetOrder == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
|
||||
#region 调用接口结束盘点
|
||||
var body = new GetStockTakingOrderMatDetailRequest()
|
||||
{
|
||||
StockTakingOrderId = selectetOrder.Id,
|
||||
StockTakingOrderNumber = selectetOrder.StocktakingOrderNumber,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "stockTaking/endStockTakingOrder", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
Growl.Success("暂停盘点成功!");
|
||||
}
|
||||
else if (Result != null)
|
||||
{
|
||||
Growl.Warning(Result.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("暂停失败:调用接口失败!");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error("出现异常:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
296
货架标准上位机/ViewModels/StocktakingViewModel.cs
Normal file
296
货架标准上位机/ViewModels/StocktakingViewModel.cs
Normal file
@ -0,0 +1,296 @@
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Data;
|
||||
using MiniExcelLibs;
|
||||
using Ping9719.WpfEx.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using TouchSocket.Core;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.OutStore;
|
||||
using WCS.Model.ApiModel.Stocktaking;
|
||||
using 货架标准上位机.Api;
|
||||
using 货架标准上位机.ViewModel;
|
||||
|
||||
namespace 货架标准上位机.ViewModel
|
||||
{
|
||||
public class StocktakingViewModel : BindableBase
|
||||
{
|
||||
public StocktakingViewModel()
|
||||
{
|
||||
RefreshStockTakingOrderList();
|
||||
}
|
||||
|
||||
#region Property
|
||||
private StockTakingOrderModel selectedOutOrder;
|
||||
public StockTakingOrderModel SelectedOutOrder
|
||||
{
|
||||
get { return selectedOutOrder; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref selectedOutOrder, value);
|
||||
if (selectedOutOrder != null)
|
||||
{
|
||||
SelectedOutOrderNumber = selectedOutOrder.StocktakingOrderNumber;
|
||||
RefreshDataGridItemSource();
|
||||
}
|
||||
else
|
||||
{
|
||||
DataGridItemSource?.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string selectedOutOrderNumber;
|
||||
public string SelectedOutOrderNumber
|
||||
{
|
||||
get => selectedOutOrderNumber;
|
||||
set
|
||||
{
|
||||
SetProperty(ref selectedOutOrderNumber, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ObservableCollection<StockTakingOrderModel> outOrderList;
|
||||
public ObservableCollection<StockTakingOrderModel> OutOrderList
|
||||
{
|
||||
get => outOrderList;
|
||||
set
|
||||
{
|
||||
SetProperty(ref outOrderList, value);
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<StockTakingOrderMatDetailModel> dataGridItemSource;
|
||||
public ObservableCollection<StockTakingOrderMatDetailModel> DataGridItemSource
|
||||
{
|
||||
get { return dataGridItemSource; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref dataGridItemSource, value);
|
||||
RefreshCount();
|
||||
}
|
||||
}
|
||||
|
||||
//单据总盘数
|
||||
private int totalPan;
|
||||
public int TotalPan
|
||||
{
|
||||
get => totalPan; set
|
||||
{
|
||||
SetProperty(ref totalPan, value);
|
||||
}
|
||||
}
|
||||
|
||||
private int sendedPan;
|
||||
public int SendedPan
|
||||
{
|
||||
get => sendedPan; set
|
||||
{
|
||||
SetProperty(ref sendedPan, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string orderStatus;
|
||||
public string OrderStatus
|
||||
{
|
||||
get { return orderStatus; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref orderStatus, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshCount()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
SendedPan = dataGridItemSource.Where(t => t.IsStocktaking).Count();
|
||||
TotalPan = dataGridItemSource.Count();
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Command
|
||||
public ICommand BtnStartCommand { get => new DelegateCommand(BtnStart); }
|
||||
public void BtnStart()
|
||||
{
|
||||
try
|
||||
{
|
||||
//判断是否选择单据
|
||||
if (SelectedOutOrder == null)
|
||||
{
|
||||
Growl.Warning("未选择单据!");
|
||||
return;
|
||||
}
|
||||
|
||||
#region 调用接口开始盘点
|
||||
var body = new GetStockTakingOrderMatDetailRequest()
|
||||
{
|
||||
StockTakingOrderId = selectedOutOrder.Id,
|
||||
StockTakingOrderNumber = selectedOutOrder.StocktakingOrderNumber,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "stockTaking/startStockTakingOrder", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
Growl.Warning("已成功开始盘点!");
|
||||
RefreshDataGridItemSource();
|
||||
}
|
||||
else if (Result != null)
|
||||
{
|
||||
Growl.Warning(Result.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("调用接口失败!");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error("出现异常:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand BtnPauseCommand { get => new DelegateCommand(BtnPause); }
|
||||
public void BtnPause()
|
||||
{
|
||||
try
|
||||
{
|
||||
//判断是否选择单据
|
||||
if (SelectedOutOrder == null)
|
||||
{
|
||||
Growl.Warning("未选择单据!");
|
||||
return;
|
||||
}
|
||||
#region 调用接口结束盘点
|
||||
var body = new GetStockTakingOrderMatDetailRequest()
|
||||
{
|
||||
StockTakingOrderId = selectedOutOrder.Id,
|
||||
StockTakingOrderNumber = selectedOutOrder.StocktakingOrderNumber,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "stockTaking/endStockTakingOrder", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
Growl.Warning("已成功结束盘点!");
|
||||
RefreshDataGridItemSource();
|
||||
}
|
||||
else if (Result != null)
|
||||
{
|
||||
Growl.Warning(Result.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("调用接口失败!");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error("出现异常:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshStockTakingOrderList(string OrderNumber = "")
|
||||
{
|
||||
#region 调用接口获取发料单
|
||||
try
|
||||
{
|
||||
var body = new GetStockTakingOrdersRequest()
|
||||
{
|
||||
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<PageQueryResponse<StockTakingOrderModel>>(LocalFile.Config.ApiIpHost + "stockTaking/getStockTakingOrdersByStatus", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
OutOrderList = new ObservableCollection<StockTakingOrderModel>(Result.Data.Lists);
|
||||
if (!string.IsNullOrEmpty(OrderNumber))
|
||||
{
|
||||
SelectedOutOrder = OutOrderList.Where(t => t.StocktakingOrderNumber == OrderNumber).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else if (Result != null && !string.IsNullOrEmpty(Result.Message))
|
||||
{
|
||||
Growl.Warning(Result.Message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Warning(ex.Message);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public void RefreshDataGridItemSource()
|
||||
{
|
||||
if (SelectedOutOrder == null)
|
||||
{
|
||||
//选择的单据为空无法进行查询
|
||||
return;
|
||||
}
|
||||
#region 调用接口获取盘点单物料明细
|
||||
Task.Run(() =>
|
||||
{
|
||||
var body = new GetStockTakingOrderMatDetailRequest()
|
||||
{
|
||||
StockTakingOrderId = selectedOutOrder.Id,
|
||||
StockTakingOrderNumber = selectedOutOrder.StocktakingOrderNumber,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<StockTakingOrderMatDetailModel>>>(LocalFile.Config.ApiIpHost + "stockTaking/getStockTakingOrderMatDetail", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
if (Result.Data.Count > 0)
|
||||
{
|
||||
DataGridItemSource = new ObservableCollection<StockTakingOrderMatDetailModel>(Result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
DataGridItemSource?.Clear();
|
||||
});
|
||||
|
||||
Growl.Warning("该单据未查询到盘点明细!");
|
||||
}
|
||||
}
|
||||
else if (Result != null)
|
||||
{
|
||||
Growl.Warning(Result.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("调用接口失败!");
|
||||
}
|
||||
});
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user