From f9a1dab76ad1109c0bad3836dd88f6b696e15f37 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Sat, 11 Jan 2025 19:05:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=93=E4=BD=8D=E5=8C=BA=E5=9F=9F=E5=BB=BA?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WCS.BLL/DbModels/STZL/LocationAreaInfo.cs | 22 ++ WCS.BLL/DbModels/STZL/LocationInfo.cs | 9 +- WCS.BLL/Manager/DbInit.cs | 5 +- .../ApiModel/Location/LocationAreaModel.cs | 13 + .../ViewModels/InOutRecordViewModel.cs | 2 +- .../ViewModels/LocaionInfoViewModel.cs | 359 ++++++++++++++++++ .../ViewModels/MatInventoryDetailViewModel.cs | 12 +- .../ViewModels/OutInventoryAddDucumentViewModel.cs | 6 +- 货架标准上位机/Views/LocationInfoView.xaml | 312 +++++++++++++++ 货架标准上位机/Views/LocationInfoView.xaml.cs | 88 +++++ 10 files changed, 814 insertions(+), 14 deletions(-) create mode 100644 WCS.BLL/DbModels/STZL/LocationAreaInfo.cs create mode 100644 WCS.Model/ApiModel/Location/LocationAreaModel.cs create mode 100644 货架标准上位机/ViewModels/LocaionInfoViewModel.cs create mode 100644 货架标准上位机/Views/LocationInfoView.xaml create mode 100644 货架标准上位机/Views/LocationInfoView.xaml.cs diff --git a/WCS.BLL/DbModels/STZL/LocationAreaInfo.cs b/WCS.BLL/DbModels/STZL/LocationAreaInfo.cs new file mode 100644 index 0000000..447ec18 --- /dev/null +++ b/WCS.BLL/DbModels/STZL/LocationAreaInfo.cs @@ -0,0 +1,22 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WCS.BLL.DbModels +{ + /// + /// 库位区域 + /// + [SugarTable("wcs_location_area")] + public class LocationAreaInfo + { + [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)] + public int Id { get; set; } + + [SugarColumn(ColumnName = "location_area", Length = 64, IsNullable = false, ColumnDescription = "库位区域")] + public string LocationArea { get; set; } + } +} diff --git a/WCS.BLL/DbModels/STZL/LocationInfo.cs b/WCS.BLL/DbModels/STZL/LocationInfo.cs index 24e9479..a1cef89 100644 --- a/WCS.BLL/DbModels/STZL/LocationInfo.cs +++ b/WCS.BLL/DbModels/STZL/LocationInfo.cs @@ -24,9 +24,14 @@ namespace WCS.DAL.DbModels public string LocationCode { get; set; } /// - /// 位置区域 + /// 库位区域 + /// + [SugarColumn(ColumnName = "location_area_id", IsNullable = true, ColumnDescription = "库位区域Id")] + public int LocationAreaId { get; set; } + /// + /// 库位区域 /// - [SugarColumn(ColumnName = "location_area", Length = 64, IsNullable = false, ColumnDescription = "位置区域")] + [SugarColumn(ColumnName = "location_area", Length = 64, IsNullable = false, ColumnDescription = "库位区域名称")] public string LocationArea { get; set; } /// diff --git a/WCS.BLL/Manager/DbInit.cs b/WCS.BLL/Manager/DbInit.cs index 47b1cdc..1f70a39 100644 --- a/WCS.BLL/Manager/DbInit.cs +++ b/WCS.BLL/Manager/DbInit.cs @@ -70,9 +70,10 @@ namespace WCS.BLL.Manager DbHelp.dbLog.DbMaintenance.CreateDatabase(); Logs.Write("【初始化数据库】创建数据库", LogsType.StartBoot); - DbHelp.db.CodeFirst.InitTables(typeof(ShelfInfo), typeof(StoreInfo), typeof(ShelfTypeInfo) + DbHelp.db.CodeFirst.InitTables(typeof(ShelfInfo), typeof(MatBaseInfo), typeof(ShelfTypeInfo) + ,typeof(LocationInfo), typeof(LocationAreaInfo) , typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail) - , typeof(MatBaseInfo), typeof(MatInfo) + , typeof(MatInfo), typeof(StoreInfo) , typeof(StockTakingOrder), typeof(StockTakingOrderMatDetail), typeof(InOutRecord) , typeof(DocumentSerialNumber), typeof(MatInfoLog) , typeof(AppVersion) diff --git a/WCS.Model/ApiModel/Location/LocationAreaModel.cs b/WCS.Model/ApiModel/Location/LocationAreaModel.cs new file mode 100644 index 0000000..ebbb034 --- /dev/null +++ b/WCS.Model/ApiModel/Location/LocationAreaModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel +{ + public class LocationAreaModel + { + public int? Id { get; set; } + public string LocationAreaName { get; set; } + + } +} diff --git a/货架标准上位机/ViewModels/InOutRecordViewModel.cs b/货架标准上位机/ViewModels/InOutRecordViewModel.cs index 4f6f0c2..b17d2b6 100644 --- a/货架标准上位机/ViewModels/InOutRecordViewModel.cs +++ b/货架标准上位机/ViewModels/InOutRecordViewModel.cs @@ -281,7 +281,7 @@ namespace 智慧物流软件系统.ViewModel // StoreCode = StoreCode, // Direction = SelectedDirection, - // ShelfTypeId = SelectedShelfTypeItem == null ? 0 : SelectedShelfTypeItem.Id, + // ShelfTypeId = SelectedLocationAreaItems == null ? 0 : SelectedLocationAreaItems.Id, // UserName = LocalStatic.CurrentUser, // DeviceType = LocalFile.Config.DeviceType, diff --git a/货架标准上位机/ViewModels/LocaionInfoViewModel.cs b/货架标准上位机/ViewModels/LocaionInfoViewModel.cs new file mode 100644 index 0000000..7454622 --- /dev/null +++ b/货架标准上位机/ViewModels/LocaionInfoViewModel.cs @@ -0,0 +1,359 @@ +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 智慧物流软件系统.Views.Controls; +using 智慧物流软件系统.Api; +using WCS.Model; +using WCS.Model.ApiModel.Home; +using WCS.Model.ApiModel.StoreInfo; +using WCS.BLL.DbModels; +using WCS.Model.ApiModel.MatBaseInfo; +using WCS.Model.ApiModel.User; +using WCS.Model.ApiModel; +using Newtonsoft.Json.Bson; + +namespace 智慧物流软件系统.ViewModel +{ + public class LocaionInfoViewModel : BindableBase + { + public LocaionInfoViewModel() + { + + } + + #region Property + private List dataGridItemSource; + public List DataGridItemSource + { + get { return dataGridItemSource; } + set + { + SetProperty(ref dataGridItemSource, value); + } + } + + private ShelfInfoModel selectedataGridItem; + public ShelfInfoModel SelectedataGridItem + { + get { return selectedataGridItem; } + set + { + SetProperty(ref selectedataGridItem, value); + } + } + + + /// + /// 货架编号 + /// + private string locationCode; + public string LocationCode + { + get { return locationCode; } + set + { + SetProperty(ref locationCode, value); + } + } + + private List locationAreaItems; + public List LocationAreaItems + { + get { return locationAreaItems; } + set + { + SetProperty(ref locationAreaItems, value); + } + } + + private ShelfTypeModel? selectedLocationAreaItems; + public ShelfTypeModel? SelectedLocationAreaItems + { + get { return selectedLocationAreaItems; } + set + { + SetProperty(ref selectedLocationAreaItems, value); + } + } + + public void InitLocationAreaItems() + { + //调用接口更新! + Task.Run(() => + { + LocationAreaItems = new List(); + LocationAreaItems.Add(new ShelfTypeModel { Id = null, ShelfTypeName = "全部" }); + + var body = new RequestBase() + { + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + }; + + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "home/getShelfTypes", body, "POST"); + if (Result != null && Result.Data != null && Result.Data.Lists.Count() > 0) + { + LocationAreaItems.AddRange(Result.Data.Lists); + } + + SelectedLocationAreaItems = LocationAreaItems.FirstOrDefault(); + }); + } + + /// + /// 启用状态 + /// + private bool? isEnable; + public bool? IsEnable + { + get { return isEnable; } + set + { + SetProperty(ref isEnable, value); + } + } + #endregion + + #region Command + public ICommand BtnResetCommand { get => new DelegateCommand(BtnReset); } + public void BtnReset() + { + if (LocationAreaItems != null) + { + SelectedLocationAreaItems = LocationAreaItems.FirstOrDefault(); + } + LocationCode = string.Empty; + IsEnable = null; + } + + 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 GetShelvesRequest() + { + ShelfTypeId = SelectedLocationAreaItems == null ? null : SelectedLocationAreaItems.Id, + ShelfCode = LocationCode, + IsEnable = IsEnable, + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + PageNumber = CurrentPage, + PageSize = PageSize, + }; + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "storeInfo/getShelves", 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 BtnAddCommand { get => new DelegateCommand(BtnAdd); } + public async void BtnAdd() + { + var addView = new ShelfInfoAddOrUpdateView("新增货架"); + addView.ShowDialog(); + if (addView.DialogResult == true) + { + //添加或修改成功后重新查询 + CurrentPage = 1; + } + } + + public ICommand BtnEditCommand { get => new DelegateCommand(BtnEdit); } + public async void BtnEdit() + { + //查询勾选的第一个数据 + var shelfInfo = DataGridItemSource?.Where(t => t.IsSelected == true).FirstOrDefault(); + if (shelfInfo == null) + { + Growl.Warning("请选择需要修改的数据!"); + } + else + { + var addView = new ShelfInfoAddOrUpdateView("修改货架", shelfInfo); + addView.ShowDialog(); + if (addView.DialogResult == true) + { + CurrentPage = 1; + } + } + } + + public ICommand BtnDeleteCommand { get => new DelegateCommand(BtnDelete); } + public void BtnDelete() + { + Growl.Ask($"是否删除所有勾选的数据?", isConfirmed => + { + if (isConfirmed) + { + //查询勾选的第一个数据 + var matBaseInfoIds = DataGridItemSource?.Where(t => t.IsSelected == true) + .Select(t => t.Id) + .ToList(); + + if (matBaseInfoIds == null) + { + Growl.Warning("请选择需要修改的数据!"); + } + else + { + var body = new DeleteInfosRequest() + { + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + MatBaseInfoIds = matBaseInfoIds, + }; + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "storeInfo/deleteShelfInfo", body, "POST"); + if (Result != null && Result.Code == 200) + { + BtnSearch(); + Growl.Success("删除成功!" + Result?.Message); + } + else + { + Growl.Error($"{Result?.Message?.ToString()}"); + } + } + } + return true; + }); + + ////查询勾选的第一个数据 + //var shelfInfo = DataGridItemSource?.Where(t => t.IsSelected == true).FirstOrDefault(); + //if (shelfInfo == null) + //{ + // Growl.Warning("请选择需要删除的数据!"); + //} + //else + //{ + // var body = new AddShelfInfoRequest() + // { + // UserName = LocalStatic.CurrentUser, + // DeviceType = LocalFile.Config.DeviceType, + // ShelfInfo = shelfInfo, + // AddOrUpdate = AddOrUpdate.Delete + // }; + // var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "storeInfo/addOrUpdateShelfInfo", body, "POST"); + // if (Result != null && Result.Code == 200) + // { + // Growl.Success("删除成功!"); + // CurrentPage = 1; + // } + // else + // { + // Growl.Error($"{Result?.Message?.ToString()}"); + // } + //} + } + #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); } + } + + private int pageSize = 10; + public int PageSize + { + get => pageSize; + set + { + SetProperty(ref pageSize, value); + BtnSearch(true); + } + } + + + 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 + } +} diff --git a/货架标准上位机/ViewModels/MatInventoryDetailViewModel.cs b/货架标准上位机/ViewModels/MatInventoryDetailViewModel.cs index 43c5490..a50d2dd 100644 --- a/货架标准上位机/ViewModels/MatInventoryDetailViewModel.cs +++ b/货架标准上位机/ViewModels/MatInventoryDetailViewModel.cs @@ -253,8 +253,8 @@ namespace 智慧物流软件系统.ViewModel // MatCode = MatCode, // StoreCode = StoreCode, - // ShelfTypeId = SelectedShelfTypeItem == null ? 0 : SelectedShelfTypeItem.Id, - // ShelfCode = ShelfCode, + // ShelfTypeId = SelectedLocationAreaItems == null ? 0 : SelectedLocationAreaItems.Id, + // LocationCode = LocationCode, // UserName = LocalStatic.CurrentUser, // DeviceType = LocalFile.Config.DeviceType, @@ -342,8 +342,8 @@ namespace 智慧物流软件系统.ViewModel // MatCode = MatCode, // StoreCode = StoreCode, - // ShelfTypeId = SelectedShelfTypeItem == null ? 0 : SelectedShelfTypeItem.Id, - // ShelfCode = ShelfCode, + // ShelfTypeId = SelectedLocationAreaItems == null ? 0 : SelectedLocationAreaItems.Id, + // LocationCode = LocationCode, // UserName = LocalStatic.CurrentUser, // DeviceType = LocalFile.Config.DeviceType, @@ -443,8 +443,8 @@ namespace 智慧物流软件系统.ViewModel // MatCode = MatCode, // StoreCode = StoreCode, - // ShelfTypeId = SelectedShelfTypeItem == null ? 0 : SelectedShelfTypeItem.Id, - // ShelfCode = ShelfCode, + // ShelfTypeId = SelectedLocationAreaItems == null ? 0 : SelectedLocationAreaItems.Id, + // LocationCode = LocationCode, // UserName = LocalStatic.CurrentUser, // DeviceType = LocalFile.Config.DeviceType, diff --git a/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs b/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs index 80ef7e3..dcf71cc 100644 --- a/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs +++ b/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs @@ -115,7 +115,7 @@ namespace 智慧物流软件系统.ViewModels { HandyControl.Controls.MessageBox.Show("请选择货架类型!"); } - //var window = new OutInventoryAddMatView(SelectedShelfTypeItem.Id); + //var window = new OutInventoryAddMatView(SelectedLocationAreaItems.Id); //window.Owner = Application.Current.MainWindow; //window.Topmost = true; @@ -192,8 +192,8 @@ namespace 智慧物流软件系统.ViewModels // { // OrderType = "出库", // OrderSource = "WCS前端", - // ShelfTypeId = SelectedShelfTypeItem.Id, - // ShelfTypeName = SelectedShelfTypeItem.ShelfTypeName, + // ShelfTypeId = SelectedLocationAreaItems.Id, + // ShelfTypeName = SelectedLocationAreaItems.ShelfTypeName, // ItemList = DataGridItemSource.Select(t => new MatCodeItemList() // { // MatCode = t.MatCode, diff --git a/货架标准上位机/Views/LocationInfoView.xaml b/货架标准上位机/Views/LocationInfoView.xaml new file mode 100644 index 0000000..0fdd66e --- /dev/null +++ b/货架标准上位机/Views/LocationInfoView.xaml @@ -0,0 +1,312 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 全部 + 启用 + 禁用 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10条/页 + 20条/页 + 50条/页 + 100条/页 + 500条/页 + + + + + + + + + + + + + + + + +