You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
830 lines
34 KiB
830 lines
34 KiB
using AutoMapper.Internal;
|
|
using BBWY.Client.APIServices;
|
|
using BBWY.Client.Models;
|
|
using BBWY.Client.Models.APIModel;
|
|
using BBWY.Client.Models.QiKu;
|
|
using BBWY.Client.Models.SealBox;
|
|
using BBWY.Client.Views.BatchPurchase;
|
|
using BBWY.Client.Views.SealBox;
|
|
using BBWY.Controls;
|
|
using GalaSoft.MvvmLight.Command;
|
|
using NPOI.SS.Formula.Functions;
|
|
using NPOI.Util;
|
|
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.Documents;
|
|
using System.Windows.Input;
|
|
using WebSocketSharp;
|
|
|
|
namespace BBWY.Client.ViewModels.SealBox
|
|
{
|
|
public class SealBoxConfigureViewModel : BaseVM
|
|
{
|
|
private IList<StoreResponse> storeList;//仓库列表
|
|
public LogisticsService logisticsService;
|
|
private SealBoxService sealBoxService;
|
|
private GlobalContext globalContext;
|
|
|
|
private WareType selectWareType = WareType.京仓;
|
|
public WareType SelectWareType { get => selectWareType; set { Set(ref selectWareType, value); } }
|
|
|
|
private string searchSkuId;
|
|
public string SearchSkuId { get => searchSkuId; set { Set(ref searchSkuId, value); } }
|
|
|
|
private List<SealBoxConfigureModel> sealBoxConfigureModelList;
|
|
/// <summary>
|
|
/// 分箱配置列表
|
|
/// </summary>
|
|
public List<SealBoxConfigureModel> SealBoxConfigureModelList { get => sealBoxConfigureModelList; set { Set(ref sealBoxConfigureModelList, value); } }
|
|
|
|
private ObservableCollection<SealBoxConfigureModel> jdConfigureModelList;
|
|
|
|
/// <summary>
|
|
/// 京仓配置列表
|
|
/// </summary>
|
|
public ObservableCollection<SealBoxConfigureModel> JdConfigureModelList { get => jdConfigureModelList; set { Set(ref jdConfigureModelList, value); } }
|
|
|
|
private ObservableCollection<SealBoxConfigureModel> cloudConfigureModelList;
|
|
/// <summary>
|
|
/// 云仓配置列表
|
|
/// </summary>
|
|
public ObservableCollection<SealBoxConfigureModel> CloudConfigureModelList { get => cloudConfigureModelList; set { Set(ref cloudConfigureModelList, value); } }
|
|
|
|
private ObservableCollection<SealBoxConfigureModel> jstConfigureModelList;
|
|
/// <summary>
|
|
/// 聚水潭配置列表
|
|
/// </summary>
|
|
public ObservableCollection<SealBoxConfigureModel> JstConfigureModelList { get => jstConfigureModelList; set { Set(ref jstConfigureModelList, value); } }
|
|
|
|
private ObservableCollection<SealBoxConfigureModel> storeConfigureModelList;
|
|
/// <summary>
|
|
/// 商家仓配置列表
|
|
/// </summary>
|
|
public ObservableCollection<SealBoxConfigureModel> StoreConfigureModelList { get => storeConfigureModelList; set { Set(ref storeConfigureModelList, value); } }
|
|
|
|
|
|
private ObservableCollection<SealBoxConfigureWareHourseModel> jdWareHourseHeaderList;
|
|
/// <summary>
|
|
/// 京仓仓库配置头列表
|
|
/// </summary>
|
|
public ObservableCollection<SealBoxConfigureWareHourseModel> JdWareHourseHeaderList { get => jdWareHourseHeaderList; set { Set(ref jdWareHourseHeaderList, value); } }
|
|
|
|
private ObservableCollection<SealBoxConfigureWareHourseModel> cloudWareHourseHeaderList;
|
|
/// <summary>
|
|
/// 云仓仓库配置头列表
|
|
/// </summary>
|
|
public ObservableCollection<SealBoxConfigureWareHourseModel> CloudWareHourseHeaderList { get => cloudWareHourseHeaderList; set { Set(ref cloudWareHourseHeaderList, value); } }
|
|
|
|
private ObservableCollection<SealBoxConfigureWareHourseModel> jstWareHourseHeaderList;
|
|
/// <summary>
|
|
/// 聚水潭仓库配置头列表
|
|
/// </summary>
|
|
public ObservableCollection<SealBoxConfigureWareHourseModel> JstWareHourseHeaderList { get => jstWareHourseHeaderList; set { Set(ref jstWareHourseHeaderList, value); } }
|
|
|
|
private ObservableCollection<SealBoxConfigureWareHourseModel> storeWareHourseHeaderList;
|
|
/// <summary>
|
|
/// 商家仓仓库配置头列表
|
|
/// </summary>
|
|
public ObservableCollection<SealBoxConfigureWareHourseModel> StoreWareHourseHeaderList { get => storeWareHourseHeaderList; set { Set(ref storeWareHourseHeaderList, value); } }
|
|
|
|
|
|
|
|
|
|
private string jDWareTaskCount;
|
|
/// <summary>
|
|
/// 京仓任务数
|
|
/// </summary>
|
|
public string JDWareTaskCount { get => jDWareTaskCount; set { Set(ref jDWareTaskCount, value); } }
|
|
|
|
|
|
private string cloudWareTaskCount;
|
|
/// <summary>
|
|
/// 京仓任务数
|
|
/// </summary>
|
|
public string CloudWareTaskCount { get => cloudWareTaskCount; set { Set(ref cloudWareTaskCount, value); } }
|
|
|
|
|
|
private string jSTWareTaskCount;
|
|
/// <summary>
|
|
/// 京仓任务数
|
|
/// </summary>
|
|
public string JSTWareTaskCount { get => jSTWareTaskCount; set { Set(ref jSTWareTaskCount, value); } }
|
|
|
|
|
|
private string storeWareTaskCount;
|
|
/// <summary>
|
|
/// 京仓任务数
|
|
/// </summary>
|
|
public string StoreWareTaskCount { get => storeWareTaskCount; set { Set(ref storeWareTaskCount, value); } }
|
|
|
|
|
|
|
|
|
|
|
|
public SealBoxConfigureViewModel(LogisticsService logisticsService, SealBoxService sealBoxService, GlobalContext globalContext)
|
|
{
|
|
this.logisticsService = logisticsService;
|
|
this.sealBoxService = sealBoxService;
|
|
SetPackCountAndStoreCommand = new RelayCommand<object>(SetPackCountAndStore);
|
|
SaveCommand = new RelayCommand<object>(Save);
|
|
//SealBoxConfigureModelList = new ObservableCollection<SealBoxConfigureModel>();
|
|
this.globalContext = globalContext;
|
|
|
|
SelectWareTypeCommand = new RelayCommand(SearchSku);
|
|
|
|
SearchSkuCommand = new RelayCommand(SearchSku);
|
|
AddWareCommand = new RelayCommand(AddWare);
|
|
|
|
SpliteOtherWareCommand = new RelayCommand<SealBoxConfigureModel>(SpliteOtherWare);
|
|
|
|
BatchSetWareMaxCountCommand = new RelayCommand<string>(BatchSetWareMaxCount);
|
|
|
|
|
|
SetWareMaxCountCommand = new RelayCommand<SealBoxConfigureWareHourseModel>(SetWareMaxCount);
|
|
}
|
|
|
|
public void LoadCount()
|
|
{
|
|
App.Current.Dispatcher.Invoke(new Action(() => {
|
|
|
|
JDWareTaskCount= SealBoxConfigureModelList.Where(s=>s.SkuCount>0 &&s.WareType== WareType.京仓).Count().ToString();
|
|
|
|
CloudWareTaskCount = SealBoxConfigureModelList.Where(s => s.SkuCount > 0 && s.WareType == WareType.云仓).Count().ToString();
|
|
JSTWareTaskCount = SealBoxConfigureModelList.Where(s => s.SkuCount > 0 && s.WareType == WareType.聚水潭).Count().ToString();
|
|
StoreWareTaskCount = SealBoxConfigureModelList.Where(s => s.SkuCount > 0 && s.WareType == WareType.商家仓).Count().ToString();
|
|
}));
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetWareMaxCount(SealBoxConfigureWareHourseModel model)
|
|
{
|
|
SealBoxConfigureModelList.Where(s => s.WareType == SelectWareType && s.TaskId == model.TaskId)
|
|
.ForAll(s =>
|
|
{
|
|
|
|
s.WareHourseDatas?.ForAll(d =>
|
|
{
|
|
if (d.WareId == model.WareId)
|
|
{
|
|
d.Count += s.WaitConfigureCount;
|
|
s.WaitConfigureCount = 0;
|
|
}
|
|
});
|
|
|
|
});
|
|
}
|
|
|
|
private void BatchSetWareMaxCount(string wareId)
|
|
{
|
|
SealBoxConfigureModelList.Where(s => s.WareType == SelectWareType)
|
|
.ForAll(s =>
|
|
{
|
|
|
|
s.WareHourseDatas?.ForAll(d =>
|
|
{
|
|
if (d.WareId == wareId)
|
|
{
|
|
d.Count += s.WaitConfigureCount;
|
|
}
|
|
});
|
|
|
|
});
|
|
}
|
|
|
|
private long sealBoxId;
|
|
public long SealBoxId { get => sealBoxId; set { Set(ref sealBoxId, value); } }
|
|
|
|
public ICommand SetPackCountAndStoreCommand { get; set; }
|
|
|
|
public ICommand SaveCommand { get; set; }
|
|
|
|
public ICommand SearchSkuCommand { get; set; }
|
|
|
|
public ICommand AddWareCommand { get; set; }
|
|
|
|
public ICommand SpliteOtherWareCommand { get; set; }
|
|
|
|
public ICommand SelectWareTypeCommand { get; set; }
|
|
|
|
public ICommand BatchSetWareMaxCountCommand { get; set; }
|
|
|
|
|
|
public ICommand SetWareMaxCountCommand { get; set; }
|
|
|
|
|
|
private void SearchSku()
|
|
{
|
|
if (SearchSkuId.IsNullOrEmpty())
|
|
{
|
|
switch (SelectWareType)
|
|
{
|
|
case WareType.京仓:
|
|
JdConfigureModelList = new ObservableCollection<SealBoxConfigureModel>();
|
|
SealBoxConfigureModelList.Where(s => s.WareType == WareType.京仓 && s.SkuCount > 0).ForAll(s =>
|
|
{
|
|
App.Current.Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
JdConfigureModelList.Add(s);
|
|
}));
|
|
});
|
|
|
|
break;
|
|
case WareType.云仓:
|
|
CloudConfigureModelList = new ObservableCollection<SealBoxConfigureModel>();
|
|
SealBoxConfigureModelList.Where(s => s.WareType == WareType.云仓 && s.SkuCount > 0).ForAll(s =>
|
|
{
|
|
App.Current.Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
CloudConfigureModelList.Add(s);
|
|
}));
|
|
|
|
});
|
|
break;
|
|
case WareType.商家仓:
|
|
StoreConfigureModelList = new ObservableCollection<SealBoxConfigureModel>();
|
|
SealBoxConfigureModelList.Where(s => s.WareType == WareType.商家仓 && s.SkuCount > 0).ForAll(s =>
|
|
{
|
|
App.Current.Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
StoreConfigureModelList.Add(s);
|
|
}));
|
|
|
|
});
|
|
break;
|
|
case WareType.聚水潭:
|
|
JstConfigureModelList = new ObservableCollection<SealBoxConfigureModel>();
|
|
SealBoxConfigureModelList.Where(s => s.WareType == WareType.聚水潭 && s.SkuCount > 0).ForAll(s =>
|
|
{
|
|
App.Current.Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
JstConfigureModelList.Add(s);
|
|
}));
|
|
|
|
});
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
switch (SelectWareType)
|
|
{
|
|
case WareType.京仓:
|
|
JdConfigureModelList = new ObservableCollection<SealBoxConfigureModel>();
|
|
SealBoxConfigureModelList.Where(s => s.SkuId == SearchSkuId && s.WareType == WareType.京仓 && s.SkuCount > 0).ForAll(s =>
|
|
{
|
|
App.Current.Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
JdConfigureModelList.Add(s);
|
|
}));
|
|
|
|
});
|
|
break;
|
|
case WareType.云仓:
|
|
CloudConfigureModelList = new ObservableCollection<SealBoxConfigureModel>();
|
|
SealBoxConfigureModelList.Where(s => s.SkuId == SearchSkuId && s.WareType == WareType.云仓 && s.SkuCount > 0).ForAll(s =>
|
|
{
|
|
App.Current.Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
CloudConfigureModelList.Add(s);
|
|
}));
|
|
|
|
});
|
|
break;
|
|
case WareType.商家仓:
|
|
StoreConfigureModelList = new ObservableCollection<SealBoxConfigureModel>();
|
|
SealBoxConfigureModelList.Where(s => s.SkuId == SearchSkuId && s.WareType == WareType.商家仓 && s.SkuCount > 0).ForAll(s =>
|
|
{
|
|
App.Current.Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
StoreConfigureModelList.Add(s);
|
|
}));
|
|
|
|
});
|
|
break;
|
|
case WareType.聚水潭:
|
|
JstConfigureModelList = new ObservableCollection<SealBoxConfigureModel>();
|
|
SealBoxConfigureModelList.Where(s => s.SkuId == SearchSkuId && s.WareType == WareType.聚水潭 && s.SkuCount > 0).ForAll(s =>
|
|
{
|
|
App.Current.Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
JstConfigureModelList.Add(s);
|
|
}));
|
|
|
|
});
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (SelectWareType)//加载动态仓库头
|
|
{
|
|
case WareType.京仓:
|
|
if (JdConfigureModelList.Count > 0 && JdConfigureModelList[0].WareHourseDatas?.Count > 0)
|
|
{
|
|
JdWareHourseHeaderList = JdConfigureModelList[0].WareHourseDatas;
|
|
}
|
|
else
|
|
{
|
|
JdWareHourseHeaderList = new ObservableCollection<SealBoxConfigureWareHourseModel>();
|
|
}
|
|
break;
|
|
case WareType.云仓:
|
|
if (CloudConfigureModelList.Count > 0 && CloudConfigureModelList[0].WareHourseDatas?.Count > 0)
|
|
{
|
|
CloudWareHourseHeaderList = CloudConfigureModelList[0].WareHourseDatas;
|
|
}
|
|
else
|
|
{
|
|
CloudWareHourseHeaderList = new ObservableCollection<SealBoxConfigureWareHourseModel>();
|
|
}
|
|
break;
|
|
case WareType.商家仓:
|
|
if (StoreConfigureModelList.Count > 0 && StoreConfigureModelList[0].WareHourseDatas?.Count > 0)
|
|
{
|
|
StoreWareHourseHeaderList = StoreConfigureModelList[0].WareHourseDatas;
|
|
}
|
|
else
|
|
{
|
|
StoreWareHourseHeaderList = new ObservableCollection<SealBoxConfigureWareHourseModel>();
|
|
}
|
|
break;
|
|
case WareType.聚水潭:
|
|
if (JstConfigureModelList.Count > 0 && JstConfigureModelList[0].WareHourseDatas?.Count > 0)
|
|
{
|
|
JstWareHourseHeaderList = JstConfigureModelList[0].WareHourseDatas;
|
|
}
|
|
else
|
|
{
|
|
JstWareHourseHeaderList = new ObservableCollection<SealBoxConfigureWareHourseModel>();
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LoadCount();
|
|
}
|
|
private void AddWare()
|
|
{
|
|
AddWareListWindow addWareListWindow = new AddWareListWindow(SelectWareType, logisticsService, SealBoxConfigureModelList);
|
|
addWareListWindow.AddWareList = AddWareList;
|
|
addWareListWindow.ShowDialog();
|
|
}
|
|
|
|
void AddWareList(WareType wareType, List<StoreWare> storeWares)
|
|
{
|
|
|
|
var oldList = sealBoxConfigureModelList.Where(s => s.WareType == wareType).SelectMany(s => s.WareHourseDatas).Select(w => w.WareId).Distinct().ToList();//原ids
|
|
var newList = storeWares.Select(s => s.WareId).Distinct().ToList();
|
|
var addList = newList.Except(oldList).ToList();
|
|
var deletedList = oldList.Except(newList).ToList();
|
|
|
|
sealBoxConfigureModelList.Where(s => s.WareType == wareType).ForAll(s =>
|
|
{
|
|
|
|
if (s.WareHourseDatas == null)
|
|
s.WareHourseDatas = new ObservableCollection<SealBoxConfigureWareHourseModel> { };
|
|
|
|
foreach (var item in addList)
|
|
{
|
|
s.WareHourseDatas.Add(new SealBoxConfigureWareHourseModel
|
|
{
|
|
Count = 0,
|
|
SealBoxId = null,
|
|
WareId = item,
|
|
WareName = storeWares.FirstOrDefault(f => f.WareId == item)?.WareName,
|
|
TotalWareCount = TotalCount,
|
|
TaskId = s.TaskId
|
|
});
|
|
}
|
|
|
|
foreach (var item in deletedList)
|
|
{
|
|
var deletedCount = s.WareHourseDatas.Where(w => w.WareId == item).Select(w => w.Count).Sum();
|
|
s.WaitConfigureCount += deletedCount;
|
|
|
|
ObservableCollection<SealBoxConfigureWareHourseModel> d = new ObservableCollection<SealBoxConfigureWareHourseModel>();
|
|
|
|
foreach (var WareHourseData in s.WareHourseDatas)
|
|
{
|
|
if (item == WareHourseData.WareId)
|
|
continue;
|
|
d.Add(WareHourseData);
|
|
}
|
|
s.WareHourseDatas = d;
|
|
}
|
|
|
|
|
|
});
|
|
SearchSku();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="count"></param>
|
|
/// <param name="skuid"></param>
|
|
public void TotalCount(int count, long taskId)
|
|
{
|
|
|
|
var totalSkuItemCount = sealBoxConfigureModelList.Where(s => s.TaskId == taskId && s.WareType == SelectWareType).SelectMany(s => s.WareHourseDatas).Sum(s => s.Count);
|
|
|
|
|
|
|
|
sealBoxConfigureModelList.Where(s => s.TaskId == taskId && s.WareType == SelectWareType).ForAll(
|
|
|
|
s =>
|
|
{
|
|
if (totalSkuItemCount > s.SkuCount)
|
|
{
|
|
MessageBox.Show($"总量超过可分配量,请重新分配,任务id:{s.TaskId}");
|
|
}
|
|
s.WaitConfigureCount = s.SkuCount - totalSkuItemCount;
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SpliteOtherWare(SealBoxConfigureModel model)//
|
|
{
|
|
if (model.WaitConfigureCount <= 0)
|
|
{
|
|
MessageBox.Show($"可分配量不足!当前可分配量:{model.WaitConfigureCount}", "提示");
|
|
return;
|
|
}
|
|
|
|
SplitOtherWareWindow splitOtherWareWindow = new SplitOtherWareWindow(model.WaitConfigureCount, SelectWareType, (count, waretype) =>
|
|
{
|
|
model.WaitConfigureCount -= count;
|
|
model.SkuCount -= count;
|
|
|
|
var type = SealBoxConfigureModelList.SingleOrDefault(s => s.TaskId == model.TaskId && s.WareType == waretype);
|
|
if (type != null)
|
|
{
|
|
type.SkuCount += count;
|
|
type.WaitConfigureCount += count;
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
var data = new SealBoxConfigureModel
|
|
{
|
|
Logo = model.Logo,
|
|
WareType = waretype,
|
|
SkuCount = count,
|
|
SkuId = model.SkuId,
|
|
SkuName = model.SkuName,
|
|
TaskId = model.TaskId,
|
|
TaskState = model.TaskState,
|
|
WaitConfigureCount = count,
|
|
TaskIdRemark= model.TaskIdRemark,
|
|
};
|
|
data.WareHourseDatas = new ObservableCollection<SealBoxConfigureWareHourseModel>();
|
|
switch (waretype)
|
|
{
|
|
case WareType.京仓:
|
|
|
|
if (JdWareHourseHeaderList != null)
|
|
foreach (var item in JdWareHourseHeaderList)
|
|
{
|
|
data.WareHourseDatas.Add(new SealBoxConfigureWareHourseModel
|
|
{
|
|
TaskId = model.TaskId,
|
|
SealBoxId = item.SealBoxId,
|
|
TotalWareCount = TotalCount,
|
|
WareId = item.WareId,
|
|
WareName = item.WareName,
|
|
//WareType = s.WareType,
|
|
WareState = item.WareState,
|
|
TaskIdRemark = item.TaskIdRemark,
|
|
});
|
|
}
|
|
break;
|
|
case WareType.云仓:
|
|
if (CloudWareHourseHeaderList != null)
|
|
foreach (var item in CloudWareHourseHeaderList)
|
|
{
|
|
data.WareHourseDatas.Add(new SealBoxConfigureWareHourseModel
|
|
{
|
|
TaskId = model.TaskId,
|
|
SealBoxId = item.SealBoxId,
|
|
TotalWareCount = TotalCount,
|
|
WareId = item.WareId,
|
|
WareName = item.WareName,
|
|
//WareType = s.WareType,
|
|
WareState = item.WareState,
|
|
TaskIdRemark = item.TaskIdRemark,
|
|
|
|
});
|
|
}
|
|
|
|
break;
|
|
case WareType.商家仓:
|
|
if (StoreWareHourseHeaderList != null)
|
|
foreach (var item in StoreWareHourseHeaderList)
|
|
{
|
|
data.WareHourseDatas.Add(new SealBoxConfigureWareHourseModel
|
|
{
|
|
TaskId = model.TaskId,
|
|
SealBoxId = item.SealBoxId,
|
|
TotalWareCount = TotalCount,
|
|
WareId = item.WareId,
|
|
WareName = item.WareName,
|
|
//WareType = s.WareType,
|
|
WareState = item.WareState,
|
|
TaskIdRemark = item.TaskIdRemark,
|
|
});
|
|
}
|
|
|
|
break;
|
|
case WareType.聚水潭:
|
|
if (JstWareHourseHeaderList != null)
|
|
foreach (var item in JstWareHourseHeaderList)
|
|
{
|
|
data.WareHourseDatas.Add(new SealBoxConfigureWareHourseModel
|
|
{
|
|
TaskId = model.TaskId,
|
|
SealBoxId = item.SealBoxId,
|
|
TotalWareCount = TotalCount,
|
|
WareId = item.WareId,
|
|
WareName = item.WareName,
|
|
//WareType = s.WareType,
|
|
WareState = item.WareState,
|
|
TaskIdRemark = item.TaskIdRemark,
|
|
});
|
|
}
|
|
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
SealBoxConfigureModelList.Add(data);
|
|
}
|
|
SearchSku();
|
|
|
|
|
|
});
|
|
splitOtherWareWindow.ShowDialog();
|
|
}
|
|
private StoreResponse store;
|
|
private void SetPackCountAndStore(object obj)
|
|
{
|
|
|
|
var sealBoxConfigureWareHourseModel = obj as SealBoxConfigureWareHourseModel;
|
|
if (storeList == null)
|
|
{
|
|
var response = logisticsService.GetStoreList();
|
|
if (!response.Success)
|
|
{
|
|
MessageBox.Show(response.Msg, "获取仓库");
|
|
return;
|
|
}
|
|
storeList = response.Data.Where(s => s.Status == StockStatus.使用).ToArray();
|
|
}
|
|
if (store == null)
|
|
{
|
|
if (sealBoxConfigureWareHourseModel != null)
|
|
store = new StoreResponse
|
|
{
|
|
Id = sealBoxConfigureWareHourseModel.WareId,
|
|
Name = sealBoxConfigureWareHourseModel.WareName,
|
|
//Type = ToStockType(sealBoxConfigureWareHourseModel.WareType),
|
|
Status = StockStatus.使用
|
|
};
|
|
}
|
|
|
|
|
|
|
|
//var w = new PackSkuSplitCountAndStoreWindow(sealBoxConfigureWareHourseModel.Count, store, storeList, sealBoxConfigureWareHourseModel.WareType == WareType.聚水潭);
|
|
//if (w.ShowDialog() == true)
|
|
//{
|
|
// store = w.Store;
|
|
// sealBoxConfigureWareHourseModel.Count = w.Quantity;
|
|
// IsJST = w.IsJST;
|
|
// // sealBoxConfigureWareHourseModel.WareType = w.IsJST ? WareType.聚水潭 : ToWareType(w.Store.Type);
|
|
// sealBoxConfigureWareHourseModel.WareId = w.IsJST ? "qiyuejushuitan" : w.Store.Id;
|
|
// sealBoxConfigureWareHourseModel.WareName = w.IsJST ? "齐越聚水潭" : w.Store.Name;
|
|
|
|
|
|
|
|
|
|
//}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否聚水潭
|
|
/// </summary>
|
|
public bool IsJST { get; set; }
|
|
|
|
//private PositionType ToPositionType(WareType wareType)
|
|
//{
|
|
// switch (wareType)
|
|
// {
|
|
// case WareType.京仓:
|
|
// return PositionType.京仓;
|
|
// break;
|
|
// case WareType.云仓:
|
|
// return PositionType.云仓;
|
|
// break;
|
|
// case WareType.商家仓:
|
|
// return PositionType.商家仓;
|
|
// break;
|
|
// case WareType.聚水潭:
|
|
// return PositionType.聚水潭;
|
|
// break;
|
|
// default:
|
|
// break;
|
|
// }
|
|
// return PositionType.聚水潭;
|
|
//}
|
|
|
|
//private WareType ToWareType(StockType stockType)
|
|
//{
|
|
// switch (stockType)
|
|
// {
|
|
// case StockType.商家仓:
|
|
// return WareType.商家仓;
|
|
// break;
|
|
// case StockType.京仓:
|
|
// return WareType.京仓;
|
|
// break;
|
|
// case StockType.云仓:
|
|
// return WareType.云仓;
|
|
// break;
|
|
// default:
|
|
// break;
|
|
// }
|
|
// return WareType.聚水潭;
|
|
//}
|
|
|
|
//private StockType ToStockType(WareType? wareType)
|
|
//{
|
|
// switch (wareType)
|
|
// {
|
|
// case WareType.京仓:
|
|
// return StockType.京仓;
|
|
// break;
|
|
// case WareType.云仓:
|
|
// return StockType.云仓;
|
|
// break;
|
|
// case WareType.商家仓:
|
|
// return StockType.商家仓;
|
|
// break;
|
|
// case WareType.聚水潭:
|
|
// break;
|
|
// default:
|
|
// break;
|
|
// }
|
|
|
|
// return StockType.京仓;
|
|
//}
|
|
|
|
private void Save(object obj)
|
|
{
|
|
|
|
if (SealBoxId <= 0)//设置分箱
|
|
{
|
|
SetSealBoxConfiguredRequest setSealBoxConfiguredRequest = new SetSealBoxConfiguredRequest();
|
|
setSealBoxConfiguredRequest.ShopId = globalContext.User.Shop.ShopId.ToString();
|
|
IList<SetSealBoxConfiguredData> SetSealBoxConfiguredDatas = new List<SetSealBoxConfiguredData>();
|
|
|
|
foreach (var sealBoxConfigureModel in SealBoxConfigureModelList)
|
|
{
|
|
|
|
if (sealBoxConfigureModel.WareHourseDatas == null || !sealBoxConfigureModel.WareHourseDatas.Any(w => w.Count > 0))//未配置
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (sealBoxConfigureModel.WaitConfigureCount != 0)
|
|
{
|
|
MessageBox.Show($"任务id:{sealBoxConfigureModel.TaskId}中,采购数量:{sealBoxConfigureModel.SkuCount} 不等于 分箱总数量:{sealBoxConfigureModel.WareHourseDatas.Select(s => s.Count).Sum()}");
|
|
return;
|
|
}
|
|
|
|
if (SealBoxConfigureModelList.Where(s => s.TaskId == sealBoxConfigureModel.TaskId).Any(s => s.WaitConfigureCount != 0))
|
|
{
|
|
MessageBox.Show($"任务id:{sealBoxConfigureModel.TaskId}中,存在部分落仓 未设置数据");
|
|
return;
|
|
}
|
|
SetSealBoxConfiguredDatas.Add(new SetSealBoxConfiguredData
|
|
{
|
|
SkuId = sealBoxConfigureModel.SkuId,
|
|
TaskId = sealBoxConfigureModel.TaskId,
|
|
TotalCount = sealBoxConfigureModel.SkuCount,
|
|
WareHourseDatas = sealBoxConfigureModel.WareHourseDatas.Where(w => w.Count > 0).Select(x => new WareHourseData//上传过滤0数据
|
|
{
|
|
Count = x.Count,
|
|
WareId = x.WareId,
|
|
WareName = x.WareName,
|
|
WareType = sealBoxConfigureModel.WareType.Value,
|
|
}).ToList(),
|
|
});
|
|
}
|
|
setSealBoxConfiguredRequest.SetSealBoxConfiguredDatas = SetSealBoxConfiguredDatas;
|
|
var setSealBoxRes = sealBoxService.SetSealBoxConfigured(setSealBoxConfiguredRequest);
|
|
if (setSealBoxRes == null)
|
|
{
|
|
MessageBox.Show("网络异常");
|
|
return;
|
|
}
|
|
if (!setSealBoxRes.Success || setSealBoxRes.Data == null || !setSealBoxRes.Data)
|
|
{
|
|
MessageBox.Show(setSealBoxRes.Msg);
|
|
return;
|
|
}
|
|
if (ReflashWindow != null) ReflashWindow();
|
|
|
|
var window = obj as BWindow;
|
|
window.Close();
|
|
}
|
|
|
|
|
|
if (SealBoxId > 0)//修改分箱
|
|
{
|
|
BatchUpdateSealBoxConfiguredRequest res = new BatchUpdateSealBoxConfiguredRequest()
|
|
{
|
|
|
|
SealBoxId = SealBoxId,
|
|
ShopId = globalContext.User.Shop.ShopId.ToString()
|
|
};
|
|
|
|
IList<UpdateSealBoxConfiguredDataRequest> UpdateSealBoxConfiguredDatas = new List<UpdateSealBoxConfiguredDataRequest>();
|
|
foreach (var sealBoxConfigureModel in SealBoxConfigureModelList)
|
|
{
|
|
if (sealBoxConfigureModel.WaitConfigureCount != 0)
|
|
{
|
|
MessageBox.Show($"任务id:{sealBoxConfigureModel.TaskId}中,采购数量:{sealBoxConfigureModel.SkuCount} 不等于 分箱总数量:{sealBoxConfigureModel.WareHourseDatas.Select(s => s.Count).Sum()}");
|
|
return;
|
|
}
|
|
if (SealBoxConfigureModelList.Where(s => s.TaskId == sealBoxConfigureModel.TaskId).Any(s => s.WaitConfigureCount != 0))
|
|
{
|
|
MessageBox.Show($"任务id:{sealBoxConfigureModel.TaskId}中,存在部分落仓 未设置数据");
|
|
return;
|
|
}
|
|
|
|
UpdateSealBoxConfiguredDatas.Add(new UpdateSealBoxConfiguredDataRequest
|
|
{
|
|
|
|
TaskId = sealBoxConfigureModel.TaskId,
|
|
SkuCount = sealBoxConfigureModel.SkuCount,
|
|
SealBoxConfiguredWareHourseRequests = sealBoxConfigureModel.WareHourseDatas.Where(w => w.Count > 0).Select(x => new SealBoxConfiguredWareHourseRequest
|
|
{
|
|
Count = x.Count,
|
|
WareId = x.WareId,
|
|
WareName = x.WareName,
|
|
WareType = sealBoxConfigureModel.WareType.Value,
|
|
WareState = x.WareState,
|
|
SealBoxId = x.SealBoxId
|
|
|
|
}).ToList(),
|
|
});
|
|
}
|
|
res.UpdateSealBoxConfiguredDatas = UpdateSealBoxConfiguredDatas;
|
|
|
|
|
|
var setSealBoxRes = sealBoxService.BatchUpdateSealBoxConfigured(res);
|
|
if (setSealBoxRes == null)
|
|
{
|
|
MessageBox.Show("网络异常");
|
|
return;
|
|
}
|
|
if (!setSealBoxRes.Success || !setSealBoxRes.Data)
|
|
{
|
|
MessageBox.Show(setSealBoxRes.Msg);
|
|
return;
|
|
}
|
|
if (ReflashWindow != null) ReflashWindow();
|
|
var window = obj as BWindow;
|
|
window.Close();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public Action ReflashWindow { get; set; }
|
|
|
|
}
|
|
}
|
|
|