|
|
|
@ -2,10 +2,12 @@
|
|
|
|
|
using GalaSoft.MvvmLight.Command;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SlnMesnac.Business;
|
|
|
|
|
using SlnMesnac.Model.domain;
|
|
|
|
|
using SlnMesnac.Model.dto;
|
|
|
|
|
using SlnMesnac.Model.enums;
|
|
|
|
|
using SlnMesnac.Plc;
|
|
|
|
|
using SlnMesnac.Repository.service;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
@ -41,30 +43,46 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
{
|
|
|
|
|
public class ManualDeliveryViewModel : ViewModelBase
|
|
|
|
|
{
|
|
|
|
|
private readonly ProdMgmtBusiness? _prodMgmtBusiness;
|
|
|
|
|
|
|
|
|
|
private readonly IWmsRawPreferredOutService? wmsRawPreferredOutService;
|
|
|
|
|
private readonly ISqlSugarClient? sqlSugarClient;
|
|
|
|
|
|
|
|
|
|
public ManualDeliveryViewModel()
|
|
|
|
|
{
|
|
|
|
|
_prodMgmtBusiness = App.ServiceProvider.GetService<ProdMgmtBusiness>();
|
|
|
|
|
|
|
|
|
|
wmsRawPreferredOutService = App.ServiceProvider.GetService<IWmsRawPreferredOutService>();
|
|
|
|
|
sqlSugarClient = App.ServiceProvider.GetService<ISqlSugarClient>();
|
|
|
|
|
QueryStringCommand = new RelayCommand<string>(Query);
|
|
|
|
|
|
|
|
|
|
this.Query(string.Empty);
|
|
|
|
|
Init();
|
|
|
|
|
|
|
|
|
|
// ConfirmCommand = new RelayCommand<object>(Confirm);
|
|
|
|
|
DeleteCommand = new RelayCommand<object>(Delete);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConfirmCommand = new RelayCommand<object>(Confirm);
|
|
|
|
|
CancelCommand = new RelayCommand<object>(Cancel);
|
|
|
|
|
private void Init()
|
|
|
|
|
{
|
|
|
|
|
WmsRawPreferredOutDataGrid.Clear();
|
|
|
|
|
List<WmsRawPreferredOut> list = wmsRawPreferredOutService.Query();
|
|
|
|
|
if(list!= null && list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
WmsRawPreferredOutDataGrid.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 参数定义
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 计划列表DataGrid
|
|
|
|
|
/// </summary>
|
|
|
|
|
private ObservableCollection<MesProductPlanDto> planInfoDataGrid;
|
|
|
|
|
private ObservableCollection<WmsRawPreferredOut> wmsRawPreferredOutDataGrid = new ObservableCollection<WmsRawPreferredOut>();
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<MesProductPlanDto> PlanInfoDataGrid
|
|
|
|
|
public ObservableCollection<WmsRawPreferredOut> WmsRawPreferredOutDataGrid
|
|
|
|
|
{
|
|
|
|
|
get { return planInfoDataGrid; }
|
|
|
|
|
set { planInfoDataGrid = value; RaisePropertyChanged(() => PlanInfoDataGrid); }
|
|
|
|
|
get { return wmsRawPreferredOutDataGrid; }
|
|
|
|
|
set { wmsRawPreferredOutDataGrid = value; RaisePropertyChanged(() => WmsRawPreferredOutDataGrid); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -86,85 +104,107 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
#region 事件定义
|
|
|
|
|
public RelayCommand<string> QueryStringCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 确认事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public RelayCommand<object> ConfirmCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 关闭事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public RelayCommand<object> CancelCommand { get; set; }
|
|
|
|
|
public RelayCommand<object> DeleteCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询事件
|
|
|
|
|
/// 查询库位能否优先投料,可以的话保存
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="queryStr"></param>
|
|
|
|
|
private void Query(string queryStr)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PlanInfoDataGrid = new ObservableCollection<MesProductPlanDto>();
|
|
|
|
|
var list = _prodMgmtBusiness._mesProductPlanService.GetPlanDtos();
|
|
|
|
|
if (list != null)
|
|
|
|
|
WmsBaseLocation? targetLocation = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<WmsBaseLocation>().Where(it => it.LocationCode == queryStr && it.WarehouseId ==311).First();
|
|
|
|
|
WmsRawStock? wmsRawStock = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<WmsRawStock>().Where(it => it.LocationCode == queryStr).First();
|
|
|
|
|
if(targetLocation != null)
|
|
|
|
|
{
|
|
|
|
|
list.OrderByDescending(x => x.PlanStatus);
|
|
|
|
|
list.ForEach(
|
|
|
|
|
arg =>
|
|
|
|
|
if (string.IsNullOrEmpty(targetLocation.ContainerCode) || wmsRawStock==null)
|
|
|
|
|
{
|
|
|
|
|
PlanInfoDataGrid.Add(arg);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//_logger.LogError($"生产计划刷新异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 确认
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="parameter"></param>
|
|
|
|
|
private void Confirm(object parameter)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (selectedCells != null)
|
|
|
|
|
{
|
|
|
|
|
if (_prodMgmtBusiness.ApplyDeliveryHandle(selectedCells.MaterialId.ToString()))
|
|
|
|
|
{
|
|
|
|
|
_prodMgmtBusiness.RefreshMessage("手动叫料成功");
|
|
|
|
|
MessageBox.Show("该库位没有库存,请重新输入");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (targetLocation.LocationStatus != "1")
|
|
|
|
|
{
|
|
|
|
|
_prodMgmtBusiness.RefreshMessage("手动叫料失败");
|
|
|
|
|
MessageBox.Show("该库位状态异常,禁止出");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
WmsRawPreferredOut wmsRawPreferredOut = new WmsRawPreferredOut();
|
|
|
|
|
wmsRawPreferredOut.WarehouseId = wmsRawStock.WarehouseId;
|
|
|
|
|
wmsRawPreferredOut.WarehouseFloor = targetLocation.WarehouseFloor;
|
|
|
|
|
wmsRawPreferredOut.LocationCode = targetLocation.LocationCode;
|
|
|
|
|
wmsRawPreferredOut.StockType = "1";
|
|
|
|
|
wmsRawPreferredOut.MaterialId = wmsRawStock.MaterialId;
|
|
|
|
|
wmsRawPreferredOut.CreateBy = "PRD";
|
|
|
|
|
wmsRawPreferredOut.CreateDate = DateTime.Now;
|
|
|
|
|
wmsRawPreferredOut.UpdateBy = "PRD";
|
|
|
|
|
wmsRawPreferredOut.UpdateDate = DateTime.Now;
|
|
|
|
|
wmsRawPreferredOut.UseFlag = "1";
|
|
|
|
|
wmsRawPreferredOutService.Insert(wmsRawPreferredOut);
|
|
|
|
|
Init();
|
|
|
|
|
MessageBox.Show("保存成功");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("输入的库位有误,请重新输入");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_prodMgmtBusiness.RefreshMessage($"手动叫料处理异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var window = parameter as Window;
|
|
|
|
|
if (window != null)
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
window.Close();
|
|
|
|
|
Console.WriteLine($"保存异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 确认
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="parameter"></param>
|
|
|
|
|
//private void Confirm(object parameter)
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
// try
|
|
|
|
|
// {
|
|
|
|
|
// if (selectedCells != null)
|
|
|
|
|
// {
|
|
|
|
|
// if (_prodMgmtBusiness.ApplyDeliveryHandle(selectedCells.MaterialId.ToString()))
|
|
|
|
|
// {
|
|
|
|
|
// _prodMgmtBusiness.RefreshMessage("手动叫料成功");
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// _prodMgmtBusiness.RefreshMessage("手动叫料失败");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }catch (Exception ex)
|
|
|
|
|
// {
|
|
|
|
|
// _prodMgmtBusiness.RefreshMessage($"手动叫料处理异常:{ex.Message}");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// var window = parameter as Window;
|
|
|
|
|
// if (window != null)
|
|
|
|
|
// {
|
|
|
|
|
// window.Close();
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 取消
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Cancel(object parameter)
|
|
|
|
|
private void Delete(object parameter)
|
|
|
|
|
{
|
|
|
|
|
var window = parameter as Window;
|
|
|
|
|
if (window != null)
|
|
|
|
|
string locationCode = parameter as string;
|
|
|
|
|
if (!string.IsNullOrEmpty(locationCode))
|
|
|
|
|
{
|
|
|
|
|
window.Close();
|
|
|
|
|
var item = wmsRawPreferredOutService.Query(x => x.LocationCode == locationCode).FirstOrDefault();
|
|
|
|
|
bool isSuccess = wmsRawPreferredOutService.DeleteById(item.RawPreferredOutId);
|
|
|
|
|
Init();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|