From 6bd77a559b4daaee2a17d31986d9017690656222 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Mon, 13 Jan 2025 14:10:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E5=89=8D=E5=90=8E=E7=AB=AF=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WCS.BLL/DbModels/STZL/LocationAreaInfo.cs | 2 +- WCS.BLL/DbModels/STZL/LocationInfo.cs | 4 +- .../Services/IService/ILocationInfoService.cs | 32 +++ .../Services/Service/LocationInfoService.cs | 217 ++++++++++++++++++ .../Services/Service/MatBaseInfoService.cs | 2 +- WCS.BLL/Services/Service/StoreInfoService.cs | 4 +- .../LocationInfo/AddLocaionInfoRequest.cs | 13 ++ .../LocationInfo/GetLocationInfosRequest.cs | 13 ++ .../LocationAreaInfoModel.cs} | 4 +- .../LocationInfo/LocationInfoModel.cs | 84 +++++++ .../MatBaseInfo/DeleteInfosRequest.cs | 2 +- .../StoreInfo/CalibrationSetOffsetRequest.cs | 13 -- .../StoreInfo/DisableOrEnableModuleRequest.cs | 15 -- .../Controllers/LocationInfoController.cs | 85 +++++++ WCS.WebApi/Program.cs | 1 + 货架标准上位机/App.xaml | 1 + 货架标准上位机/Converters/ListToString.cs | 44 ++++ 货架标准上位机/Tool/GetBaseData.cs | 20 ++ .../ViewModels/LocaionInfoViewModel.cs | 55 ++--- .../ViewModels/LocationInfoAddOrUpdateViewModel.cs | 171 ++++++++++++++ .../ViewModels/MatBaseInfoViewModel.cs | 6 +- 货架标准上位机/ViewModels/MatInfoViewModel.cs | 6 +- .../ViewModels/ShelfInfoViewModel.cs | 6 +- .../Views/LocationInfoAddOrUpdateView.xaml | 91 ++++++++ .../Views/LocationInfoAddOrUpdateView.xaml.cs | 87 +++++++ 货架标准上位机/Views/LocationInfoView.xaml | 14 +- 货架标准上位机/Views/LocationInfoView.xaml.cs | 6 +- .../Views/MainWindows/MainWindow1.xaml | 2 +- .../Views/Windows/CalibrationWindow.xaml.cs | 107 --------- 29 files changed, 917 insertions(+), 190 deletions(-) create mode 100644 WCS.BLL/Services/IService/ILocationInfoService.cs create mode 100644 WCS.BLL/Services/Service/LocationInfoService.cs create mode 100644 WCS.Model/ApiModel/LocationInfo/AddLocaionInfoRequest.cs create mode 100644 WCS.Model/ApiModel/LocationInfo/GetLocationInfosRequest.cs rename WCS.Model/ApiModel/{Location/LocationAreaModel.cs => LocationInfo/LocationAreaInfoModel.cs} (68%) create mode 100644 WCS.Model/ApiModel/LocationInfo/LocationInfoModel.cs delete mode 100644 WCS.Model/ApiModel/StoreInfo/CalibrationSetOffsetRequest.cs delete mode 100644 WCS.Model/ApiModel/StoreInfo/DisableOrEnableModuleRequest.cs create mode 100644 WCS.WebApi/Controllers/LocationInfoController.cs create mode 100644 货架标准上位机/Converters/ListToString.cs create mode 100644 货架标准上位机/ViewModels/LocationInfoAddOrUpdateViewModel.cs create mode 100644 货架标准上位机/Views/LocationInfoAddOrUpdateView.xaml create mode 100644 货架标准上位机/Views/LocationInfoAddOrUpdateView.xaml.cs diff --git a/WCS.BLL/DbModels/STZL/LocationAreaInfo.cs b/WCS.BLL/DbModels/STZL/LocationAreaInfo.cs index 447ec18..6c10e7d 100644 --- a/WCS.BLL/DbModels/STZL/LocationAreaInfo.cs +++ b/WCS.BLL/DbModels/STZL/LocationAreaInfo.cs @@ -17,6 +17,6 @@ namespace WCS.BLL.DbModels public int Id { get; set; } [SugarColumn(ColumnName = "location_area", Length = 64, IsNullable = false, ColumnDescription = "库位区域")] - public string LocationArea { get; set; } + public string LocationAreaName { get; set; } } } diff --git a/WCS.BLL/DbModels/STZL/LocationInfo.cs b/WCS.BLL/DbModels/STZL/LocationInfo.cs index a1cef89..00596da 100644 --- a/WCS.BLL/DbModels/STZL/LocationInfo.cs +++ b/WCS.BLL/DbModels/STZL/LocationInfo.cs @@ -43,8 +43,8 @@ namespace WCS.DAL.DbModels /// /// 可放置货架类型 /// - [SugarColumn(ColumnName = "allow_shelf_types", Length = 512, IsNullable = true, ColumnDescription = "可放置货架类型")] - public string AllowShelfTypes { get; set; } + [SugarColumn(ColumnName = "allow_shelf_types", Length = 256, IsNullable = true, ColumnDescription = "可放置货架类型", IsJson = true)] + public List AllowShelfTypes { get; set; } /// /// 更新人 diff --git a/WCS.BLL/Services/IService/ILocationInfoService.cs b/WCS.BLL/Services/IService/ILocationInfoService.cs new file mode 100644 index 0000000..ae61173 --- /dev/null +++ b/WCS.BLL/Services/IService/ILocationInfoService.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WCS.Model.ApiModel.User; +using WCS.Model; +using WCS.DAL.DbModels; +using WCS.Model.ApiModel.StoreInfo; +using WCS.BLL.DbModels; +using WCS.Model.ApiModel.MatBaseInfo; + +namespace WCS.BLL.Services.IService +{ + public interface ILocationInfoService + { + /// + /// 查询货架列表 + /// + /// + /// + public Task> GetLocationInfos(GetLocationInfosRequest request); + /// + /// 添加、更新、删除货架 + /// + /// + /// + public Task> addOrUpdateLocationInfo(AddLocaionInfoRequest request); + + public Task> deleteLocationInfo(DeleteInfosRequest request); + } +} diff --git a/WCS.BLL/Services/Service/LocationInfoService.cs b/WCS.BLL/Services/Service/LocationInfoService.cs new file mode 100644 index 0000000..895b242 --- /dev/null +++ b/WCS.BLL/Services/Service/LocationInfoService.cs @@ -0,0 +1,217 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using TouchSocket.Core; +using WCS.BLL.Config; +using WCS.BLL.DbModels; +using WCS.BLL.HardWare; +using WCS.BLL.Manager; +using WCS.BLL.Services.IService; +using WCS.DAL; +using WCS.DAL.Db; +using WCS.DAL.DbModels; +using WCS.Model; +using WCS.Model.ApiModel; +using WCS.Model.ApiModel.InOutRecord; +using WCS.Model.ApiModel.MatBaseInfo; +using WCS.Model.ApiModel.StoreInfo; +using WCS.Model.ApiModel.User; + +namespace WCS.BLL.Services.Service +{ + public class LocationInfoService : ILocationInfoService + { + + public async Task> GetLocationInfos(GetLocationInfosRequest request) + { + try + { + var recordsQueryable = DbHelp.db.Queryable() + .WhereIF(request.LocationAreaId != null, t => t.LocationAreaId == request.LocationAreaId) + .WhereIF(request.IsEnable != null, t => t.IsEnable == request.IsEnable) + .WhereIF(!string.IsNullOrEmpty(request.LocationCode), t => t.LocationCode.Contains(request.LocationCode)); + + //分页 + var totalCount = await recordsQueryable.CountAsync(); + var records = await recordsQueryable + .Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize) + .ToListAsync(); + //生成序号 + for (int i = 0; i < records.Count; i++) + { + records[i].RowNumber = (request.PageNumber - 1) * request.PageSize + i + 1; + } + return new PageQueryResponse() + { + Code = 200, + Message = $"success", + Data = new PageQueryResponseData() + { + TotalCount = totalCount, + MaxPage = request.PageSize == 0 ? 0 : (int)Math.Ceiling((decimal)totalCount / request.PageSize), + Count = records.Count, + Lists = records.ToList() + } + }; + } + catch (Exception ex) + { + return new PageQueryResponse() + { + Code = 300, + Message = $"操作失败:{ex.Message}", + }; + } + } + + public async Task> addOrUpdateLocationInfo(AddLocaionInfoRequest request) + { + try + { + var locationInfo = await DbHelp.db.Queryable() + .Where(t => t.LocationCode == request.LocationInfo.LocationCode) + .FirstAsync(); + //修改位置信息 + if (request.AddOrUpdate == AddOrUpdate.Update) + { + var existId = locationInfo == null ? 0 : locationInfo.Id; + + locationInfo = await DbHelp.db.Queryable() + .Where(t => t.Id == request.LocationInfo.Id) + .FirstAsync(); + if (locationInfo == null) + { + return new ResponseCommon + { + Code = 201, + Message = $"更新位置信息失败:该位置不存在!", + Data = null + }; + } + else if (existId != locationInfo.Id) + { + return new ResponseCommon + { + Code = 201, + Message = $"更新位置信息失败:位置[{locationInfo.LocationCode}]已存在!!", + Data = null + }; + } + else + { + request.LocationInfo.ModifyUser = request.UserName; + request.LocationInfo.ModifyTime = DateTime.Now; + + var rowNum = await DbHelp.db.Updateable(request.LocationInfo).ExecuteCommandAsync(); + if (rowNum == 0) + { + return new ResponseCommon + { + Code = 201, + Message = $"更新位置信息失败:请重试!", + Data = null + }; + } + else + { + return new ResponseCommon + { + Code = 200, + Message = $"更新位置信息成功!", + Data = null + }; + } + } + } + else if (request.AddOrUpdate == AddOrUpdate.Add) + { + if (locationInfo != null) + { + return new ResponseCommon + { + Code = 201, + Message = $"新增位置信息失败:位置[{locationInfo.LocationCode}]已存在!", + Data = null + }; + } + else + { + request.LocationInfo.ModifyUser = request.UserName; + var rowNum = await DbHelp.db.Insertable(request.LocationInfo).ExecuteCommandAsync(); + if (rowNum == 0) + { + return new ResponseCommon + { + Code = 201, + Message = $"添加位置信息失败:请重试!", + Data = null + }; + } + else + { + return new ResponseCommon + { + Code = 200, + Message = $"添加位置信息成功!", + Data = null + }; + } + } + } + else + { + var response = new ResponseCommon + { + Code = 300, + Message = "不支持的操作!", + Data = null + }; + return response; + } + } + catch (Exception ex) + { + var response = new ResponseCommon + { + Code = 300, + Message = $"操作失败:{ex.Message}", + Data = null + }; + return response; + } + } + + public async Task> deleteLocationInfo(DeleteInfosRequest request) + { + //先查询出具体的Id + var locationInfos = await DbHelp.db.Queryable() + .Where(t => request.needDeleteIds.Contains(t.Id)) + .ToListAsync(); + //执行删除 + try + { + var deleteRows = await DbHelp.db.Deleteable(locationInfos).ExecuteCommandAsync(); + return new ResponseCommon + { + Code = 200, + Message = $"已删除{deleteRows}条数据!", + Data = null + }; + } + catch (Exception ex) + { + var response = new ResponseCommon + { + Code = 300, + Message = $"操作失败:{ex.Message}", + Data = null + }; + return response; + } + } + } +} diff --git a/WCS.BLL/Services/Service/MatBaseInfoService.cs b/WCS.BLL/Services/Service/MatBaseInfoService.cs index d0786cc..ab5b066 100644 --- a/WCS.BLL/Services/Service/MatBaseInfoService.cs +++ b/WCS.BLL/Services/Service/MatBaseInfoService.cs @@ -353,7 +353,7 @@ namespace WCS.BLL.Services.Service { //先查询出具体的Id var matBaseInfos = await DbHelp.db.Queryable() - .Where(t => request.MatBaseInfoIds.Contains(t.Id)) + .Where(t => request.needDeleteIds.Contains(t.Id)) .ToListAsync(); //执行删除 try diff --git a/WCS.BLL/Services/Service/StoreInfoService.cs b/WCS.BLL/Services/Service/StoreInfoService.cs index e7d1b6a..b4c168f 100644 --- a/WCS.BLL/Services/Service/StoreInfoService.cs +++ b/WCS.BLL/Services/Service/StoreInfoService.cs @@ -103,6 +103,8 @@ namespace WCS.BLL.Services.Service else { request.ShelfInfo.ModifyUser = request.UserName; + request.ShelfInfo.ModifyTime = DateTime.Now; + var rowNum = await DbHelp.db.Updateable(request.ShelfInfo).ExecuteCommandAsync(); if (rowNum == 0) { @@ -223,7 +225,7 @@ namespace WCS.BLL.Services.Service { //先查询出具体的Id var shelfInfos = await DbHelp.db.Queryable() - .Where(t => request.MatBaseInfoIds.Contains(t.Id)) + .Where(t => request.needDeleteIds.Contains(t.Id)) .ToListAsync(); //执行删除 try diff --git a/WCS.Model/ApiModel/LocationInfo/AddLocaionInfoRequest.cs b/WCS.Model/ApiModel/LocationInfo/AddLocaionInfoRequest.cs new file mode 100644 index 0000000..23d4dc3 --- /dev/null +++ b/WCS.Model/ApiModel/LocationInfo/AddLocaionInfoRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; +using WCS.Model.ApiModel.User; + +namespace WCS.Model.ApiModel.StoreInfo +{ + public class AddLocaionInfoRequest : RequestBase + { + public T LocationInfo { get; set; } + public AddOrUpdate AddOrUpdate { get; set; } + } +} diff --git a/WCS.Model/ApiModel/LocationInfo/GetLocationInfosRequest.cs b/WCS.Model/ApiModel/LocationInfo/GetLocationInfosRequest.cs new file mode 100644 index 0000000..b3a1958 --- /dev/null +++ b/WCS.Model/ApiModel/LocationInfo/GetLocationInfosRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.StoreInfo +{ + public class GetLocationInfosRequest : PageQueryRequestBase + { + public int? LocationAreaId { get; set; } + public string LocationCode { get; set; } + public bool? IsEnable { get; set; } + } +} diff --git a/WCS.Model/ApiModel/Location/LocationAreaModel.cs b/WCS.Model/ApiModel/LocationInfo/LocationAreaInfoModel.cs similarity index 68% rename from WCS.Model/ApiModel/Location/LocationAreaModel.cs rename to WCS.Model/ApiModel/LocationInfo/LocationAreaInfoModel.cs index ebbb034..b559142 100644 --- a/WCS.Model/ApiModel/Location/LocationAreaModel.cs +++ b/WCS.Model/ApiModel/LocationInfo/LocationAreaInfoModel.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.Text; -namespace WCS.Model.ApiModel +namespace WCS.Model.ApiModel.LocationInfo { - public class LocationAreaModel + public class LocationAreaInfoModel { public int? Id { get; set; } public string LocationAreaName { get; set; } diff --git a/WCS.Model/ApiModel/LocationInfo/LocationInfoModel.cs b/WCS.Model/ApiModel/LocationInfo/LocationInfoModel.cs new file mode 100644 index 0000000..e707c23 --- /dev/null +++ b/WCS.Model/ApiModel/LocationInfo/LocationInfoModel.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace WCS.Model.ApiModel.StoreInfo +{ + public class LocationInfoModel : INotifyPropertyChanged + { + + /// + /// 主键 自增Id + /// + public int Id { get; set; } + + /// + /// 位置编码 + /// + public string LocationCode { get; set; } + + /// + /// 库位区域 + /// + public int? LocationAreaId { get; set; } + /// + /// 库位区域 + /// + public string LocationArea { get; set; } + /// + /// RCS库位编码 + /// + public string RcsStoreCode { get; set; } = string.Empty; + /// + /// 允许放置的货架类型 + /// + public List AllowShelfTypes { get; set; } = new List(); + /// + /// 更新人 + /// + public string ModifyUser { get; set; } = string.Empty; + /// + /// 更新时间 + /// + public DateTime ModifyTime { get; set; } = DateTime.Now; + /// + /// 是否启用 + /// + public bool IsEnable { get; set; } = true; + /// + /// 启用状态显示用字符串 + /// + public string IsEnableStr + { + get + { + if (IsEnable) + return "启用"; + else + return "禁用"; + } + } + /// + /// 序号 + /// + public int RowNumber { get; set; } + public bool IsSelected + { + get { return isSelected; } + set + { + isSelected = value; + OnPropertyChanged(nameof(IsSelected)); + } + } + public bool isSelected; + + public event PropertyChangedEventHandler PropertyChanged; + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } + +} diff --git a/WCS.Model/ApiModel/MatBaseInfo/DeleteInfosRequest.cs b/WCS.Model/ApiModel/MatBaseInfo/DeleteInfosRequest.cs index 1407c96..25682fa 100644 --- a/WCS.Model/ApiModel/MatBaseInfo/DeleteInfosRequest.cs +++ b/WCS.Model/ApiModel/MatBaseInfo/DeleteInfosRequest.cs @@ -7,7 +7,7 @@ namespace WCS.Model.ApiModel.MatBaseInfo { public class DeleteInfosRequest : RequestBase { - public List MatBaseInfoIds { get; set; } + public List needDeleteIds { get; set; } } } diff --git a/WCS.Model/ApiModel/StoreInfo/CalibrationSetOffsetRequest.cs b/WCS.Model/ApiModel/StoreInfo/CalibrationSetOffsetRequest.cs deleted file mode 100644 index d5e6ba9..0000000 --- a/WCS.Model/ApiModel/StoreInfo/CalibrationSetOffsetRequest.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace WCS.Model.ApiModel.StoreInfo -{ - public class CalibrationSetOffsetRequest : RequestBase - { - public List MouduleIds { get; set; } - - public int OffSet { get; set; } - } -} diff --git a/WCS.Model/ApiModel/StoreInfo/DisableOrEnableModuleRequest.cs b/WCS.Model/ApiModel/StoreInfo/DisableOrEnableModuleRequest.cs deleted file mode 100644 index 60b978d..0000000 --- a/WCS.Model/ApiModel/StoreInfo/DisableOrEnableModuleRequest.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace WCS.Model.ApiModel.StoreInfo -{ - public class DisableOrEnableModuleRequest : RequestBase - { - public int ModuleId { get; set; } - - public string ModuleCode { get; set; } - - public DisableOrEnableEnum DisableOrEnable { get; set; } - } -} diff --git a/WCS.WebApi/Controllers/LocationInfoController.cs b/WCS.WebApi/Controllers/LocationInfoController.cs new file mode 100644 index 0000000..f33e386 --- /dev/null +++ b/WCS.WebApi/Controllers/LocationInfoController.cs @@ -0,0 +1,85 @@ +using Microsoft.AspNetCore.Mvc; +using WCS.BLL.Services.IService; +using WCS.BLL.Services.Service; +using WCS.Model.ApiModel.MatInventoryDetail; +using WCS.Model; +using WCS.Model.ApiModel.StoreInfo; +using WCS.BLL.DbModels; +using WCS.Model.ApiModel.MatBaseInfo; +using WCS.DAL.DbModels; +using WCS.DAL.Db; +using WCS.Model.ApiModel.Home; +using WCS.Model.ApiModel.LocationInfo; + +namespace WCS.WebApi.Controllers +{ + /// + /// 货架管理、模组管理、库位管理的接口 + /// + [ApiController] + [Route("[controller]")] + public class LocationInfoController : ControllerBase + { + public ILocationInfoService _locationInfoService { get; set; } + public LocationInfoController(ILocationInfoService locationInfoService) + { + _locationInfoService = locationInfoService; + } + + #region 位置管理 + [Route("getLocationAreas")] + [HttpPost(Name = "getLocationAreas")] + public async Task getLocationAreas(RequestBase request) + { + try + { + //直接获取当前所有货架类型并返回 + var locationAreaInfos = DbHelp.db.Queryable() + .Select(t => new LocationAreaInfoModel() + { + Id = t.Id, + LocationAreaName = t.LocationAreaName + }) + .ToList(); + return new PageQueryResponse() + { + Code = 200, + Message = "success", + Data = new PageQueryResponseData + { + Lists = locationAreaInfos, + Count = locationAreaInfos.Count + } + }; + } + catch (Exception ex) + { + return new PageQueryResponse() + { + Code = 300, + Message = $"查询失败:{ex.Message}", + }; + } + } + + [Route("getLocationInfos")] + [HttpPost(Name = "getLocationInfos")] + public async Task GetLocationInfos(GetLocationInfosRequest request) + { + return await _locationInfoService.GetLocationInfos(request); + } + + [HttpPost("addOrUpdateLocationInfo")] + public async Task> addOrUpdateLocationInfo(AddLocaionInfoRequest request) + { + return await _locationInfoService.addOrUpdateLocationInfo(request); + } + + [HttpPost("deleteLocationInfo")] + public async Task> deleteLocationInfo(DeleteInfosRequest request) + { + return await _locationInfoService.deleteLocationInfo(request); + } + #endregion + } +} diff --git a/WCS.WebApi/Program.cs b/WCS.WebApi/Program.cs index f1d44cc..b88d43b 100644 --- a/WCS.WebApi/Program.cs +++ b/WCS.WebApi/Program.cs @@ -81,6 +81,7 @@ namespace WebApi builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddScoped(); //롢ɵõģʽ builder.Services.AddSingleton(); diff --git a/货架标准上位机/App.xaml b/货架标准上位机/App.xaml index 7112940..ddbf35b 100644 --- a/货架标准上位机/App.xaml +++ b/货架标准上位机/App.xaml @@ -18,6 +18,7 @@ + pack://application,,,/智慧物流软件系统;component/Fonts/#iconfont diff --git a/货架标准上位机/Converters/ListToString.cs b/货架标准上位机/Converters/ListToString.cs new file mode 100644 index 0000000..654b51a --- /dev/null +++ b/货架标准上位机/Converters/ListToString.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace 智慧物流软件系统 +{ + public class ListToString : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + return ""; + + if (value is string) + { + return value.ToString(); + } + else if (value is List) + { + List strList = new List(); + string sep = parameter == null ? "," : parameter.ToString(); + + foreach (var item in value as List) + { + strList.Add(item.ToString()); + } + + return string.Join(sep, strList); + } + + return ""; + } + + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotSupportedException(); + } + } +} diff --git a/货架标准上位机/Tool/GetBaseData.cs b/货架标准上位机/Tool/GetBaseData.cs index 65b5f0f..13d94e5 100644 --- a/货架标准上位机/Tool/GetBaseData.cs +++ b/货架标准上位机/Tool/GetBaseData.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using System.Windows.Documents; using WCS.Model; using WCS.Model.ApiModel.Home; +using WCS.Model.ApiModel.LocationInfo; using 智慧物流软件系统.Api; namespace 智慧物流软件系统.Tool @@ -27,5 +28,24 @@ namespace 智慧物流软件系统.Tool } else { return new List(); } } + + public static List GetLocationAreaInfos() + { + var body = new RequestBase() + { + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + }; + + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "locationInfo/getLocationAreas", body, "POST"); + if (Result != null && Result.Data != null && Result.Data.Lists.Count() > 0) + { + return Result.Data.Lists; + } + else + { + return new List(); + } + } } } diff --git a/货架标准上位机/ViewModels/LocaionInfoViewModel.cs b/货架标准上位机/ViewModels/LocaionInfoViewModel.cs index 7454622..7550745 100644 --- a/货架标准上位机/ViewModels/LocaionInfoViewModel.cs +++ b/货架标准上位机/ViewModels/LocaionInfoViewModel.cs @@ -19,6 +19,7 @@ using WCS.Model.ApiModel.MatBaseInfo; using WCS.Model.ApiModel.User; using WCS.Model.ApiModel; using Newtonsoft.Json.Bson; +using WCS.Model.ApiModel.LocationInfo; namespace 智慧物流软件系统.ViewModel { @@ -30,8 +31,8 @@ namespace 智慧物流软件系统.ViewModel } #region Property - private List dataGridItemSource; - public List DataGridItemSource + private List dataGridItemSource; + public List DataGridItemSource { get { return dataGridItemSource; } set @@ -40,8 +41,8 @@ namespace 智慧物流软件系统.ViewModel } } - private ShelfInfoModel selectedataGridItem; - public ShelfInfoModel SelectedataGridItem + private LocationInfoModel selectedataGridItem; + public LocationInfoModel SelectedataGridItem { get { return selectedataGridItem; } set @@ -52,7 +53,7 @@ namespace 智慧物流软件系统.ViewModel /// - /// 货架编号 + /// 位置编号 /// private string locationCode; public string LocationCode @@ -64,8 +65,8 @@ namespace 智慧物流软件系统.ViewModel } } - private List locationAreaItems; - public List LocationAreaItems + private List locationAreaItems; + public List LocationAreaItems { get { return locationAreaItems; } set @@ -74,8 +75,8 @@ namespace 智慧物流软件系统.ViewModel } } - private ShelfTypeModel? selectedLocationAreaItems; - public ShelfTypeModel? SelectedLocationAreaItems + private LocationAreaInfoModel? selectedLocationAreaItems; + public LocationAreaInfoModel? SelectedLocationAreaItems { get { return selectedLocationAreaItems; } set @@ -89,8 +90,8 @@ namespace 智慧物流软件系统.ViewModel //调用接口更新! Task.Run(() => { - LocationAreaItems = new List(); - LocationAreaItems.Add(new ShelfTypeModel { Id = null, ShelfTypeName = "全部" }); + LocationAreaItems = new List(); + LocationAreaItems.Add(new LocationAreaInfoModel { Id = null, LocationAreaName = "全部" }); var body = new RequestBase() { @@ -98,7 +99,7 @@ namespace 智慧物流软件系统.ViewModel DeviceType = LocalFile.Config.DeviceType, }; - var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "home/getShelfTypes", body, "POST"); + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "locationInfo/getLocationAreas", body, "POST"); if (Result != null && Result.Data != null && Result.Data.Lists.Count() > 0) { LocationAreaItems.AddRange(Result.Data.Lists); @@ -151,17 +152,17 @@ namespace 智慧物流软件系统.ViewModel var dia = Dialog.Show(new TextDialog()); try { - var body = new GetShelvesRequest() + var body = new GetLocationInfosRequest() { - ShelfTypeId = SelectedLocationAreaItems == null ? null : SelectedLocationAreaItems.Id, - ShelfCode = LocationCode, + LocationAreaId = SelectedLocationAreaItems == null ? null : SelectedLocationAreaItems.Id, + LocationCode = 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"); + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "locationInfo/getLocationInfos", body, "POST"); if (Result != null && Result.Data != null && Result.Data.Lists != null) { DataGridItemSource = Result.Data.Lists; @@ -186,7 +187,7 @@ namespace 智慧物流软件系统.ViewModel public ICommand BtnAddCommand { get => new DelegateCommand(BtnAdd); } public async void BtnAdd() { - var addView = new ShelfInfoAddOrUpdateView("新增货架"); + var addView = new LocationInfoAddOrUpdateView("新增位置"); addView.ShowDialog(); if (addView.DialogResult == true) { @@ -199,14 +200,14 @@ namespace 智慧物流软件系统.ViewModel public async void BtnEdit() { //查询勾选的第一个数据 - var shelfInfo = DataGridItemSource?.Where(t => t.IsSelected == true).FirstOrDefault(); - if (shelfInfo == null) + var info = DataGridItemSource?.Where(t => t.IsSelected == true).FirstOrDefault(); + if (info == null) { Growl.Warning("请选择需要修改的数据!"); } else { - var addView = new ShelfInfoAddOrUpdateView("修改货架", shelfInfo); + var addView = new LocationInfoAddOrUpdateView("修改位置", info); addView.ShowDialog(); if (addView.DialogResult == true) { @@ -223,11 +224,11 @@ namespace 智慧物流软件系统.ViewModel if (isConfirmed) { //查询勾选的第一个数据 - var matBaseInfoIds = DataGridItemSource?.Where(t => t.IsSelected == true) + var needDeleteIds = DataGridItemSource?.Where(t => t.IsSelected == true) .Select(t => t.Id) .ToList(); - if (matBaseInfoIds == null) + if (needDeleteIds == null) { Growl.Warning("请选择需要修改的数据!"); } @@ -237,9 +238,9 @@ namespace 智慧物流软件系统.ViewModel { UserName = LocalStatic.CurrentUser, DeviceType = LocalFile.Config.DeviceType, - MatBaseInfoIds = matBaseInfoIds, + needDeleteIds = needDeleteIds, }; - var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "storeInfo/deleteShelfInfo", body, "POST"); + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "locationInfo/deleteLocationInfo", body, "POST"); if (Result != null && Result.Code == 200) { BtnSearch(); @@ -255,8 +256,8 @@ namespace 智慧物流软件系统.ViewModel }); ////查询勾选的第一个数据 - //var shelfInfo = DataGridItemSource?.Where(t => t.IsSelected == true).FirstOrDefault(); - //if (shelfInfo == null) + //var info = DataGridItemSource?.Where(t => t.IsSelected == true).FirstOrDefault(); + //if (info == null) //{ // Growl.Warning("请选择需要删除的数据!"); //} @@ -266,7 +267,7 @@ namespace 智慧物流软件系统.ViewModel // { // UserName = LocalStatic.CurrentUser, // DeviceType = LocalFile.Config.DeviceType, - // ShelfInfo = shelfInfo, + // ShelfInfo = info, // AddOrUpdate = AddOrUpdate.Delete // }; // var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "storeInfo/addOrUpdateShelfInfo", body, "POST"); diff --git a/货架标准上位机/ViewModels/LocationInfoAddOrUpdateViewModel.cs b/货架标准上位机/ViewModels/LocationInfoAddOrUpdateViewModel.cs new file mode 100644 index 0000000..cee2cd3 --- /dev/null +++ b/货架标准上位机/ViewModels/LocationInfoAddOrUpdateViewModel.cs @@ -0,0 +1,171 @@ +using HandyControl.Controls; +using Ping9719.WpfEx.Mvvm; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.AccessControl; +using System.Security.Cryptography.X509Certificates; +using System.Threading.Tasks; +using System.Web.UI.WebControls; +using System.Windows.Controls; +using TouchSocket.Core; +using WCS.Model; +using WCS.Model.ApiModel.Home; +using WCS.Model.ApiModel.LocationInfo; +using WCS.Model.ApiModel.StoreInfo; +using 智慧物流软件系统.Tool; + +namespace 智慧物流软件系统.ViewModel +{ + public class LocationInfoAddOrUpdateViewModel : BindableBase + { + public HandyControl.Controls.CheckComboBox checkComboBox { get; set; } + #region Property 属性 + public LocationInfoAddOrUpdateViewModel() + { + + } + + public void InitTypes() + { + try + { + var task1 = Task.Run(() => + { + LocationAreaItems = GetBaseData.GetLocationAreaInfos(); + if (LocationAreaItems != null && LocationAreaItems.Count > 0) + SelectedLocationAreaItem = LocationAreaItems.First(); + + }); + + var task2 = Task.Run(() => + { + AllowShelfTypes = new List(); + AllowShelfTypes = GetBaseData.GetShelfType() + .Select(t => t.ShelfTypeName) + .ToList(); + }); + + Task.WaitAll([task1, task2]); + } + catch (Exception ex) + { + Growl.Warning("打开窗体失败,请关闭后重试!"); + } + } + + public void SetValues(LocationInfoModel locationInfoModel) + { + if (locationInfoModel == null) + { + locationInfoModel = new LocationInfoModel(); + } + LocationId = locationInfoModel.Id; + + var item = LocationAreaItems.FirstOrDefault(t => t.Id == locationInfoModel.LocationAreaId); + if (item != null) + { + SelectedLocationAreaItem = item; + } + LocationCode = locationInfoModel.LocationCode; + RcsStoreCode = locationInfoModel.RcsStoreCode; + //comboBox.selec + App.Current.Dispatcher.Invoke(() => + { + locationInfoModel.AllowShelfTypes?.ForEach(t => checkComboBox.SelectedItems.Add(t)); + }); + IsEnable = locationInfoModel.IsEnable; + } + + public LocationInfoModel GetValues() + { + var selectShelfTypes = checkComboBox.SelectedItems?.Cast().ToList(); + + return new LocationInfoModel() + { + Id = LocationId, + LocationAreaId = SelectedLocationAreaItem.Id, + LocationArea = SelectedLocationAreaItem.LocationAreaName, + LocationCode = LocationCode, + RcsStoreCode = RcsStoreCode, + ModifyUser = LocalStatic.CurrentUser, + AllowShelfTypes = selectShelfTypes, + IsEnable = IsEnable, + }; + } + + private List locationAreaItems; + public List LocationAreaItems + { + get { return locationAreaItems; } + set + { + SetProperty(ref locationAreaItems, value); + } + } + + private LocationAreaInfoModel selectedLocationAreaItem; + public LocationAreaInfoModel SelectedLocationAreaItem + { + get { return selectedLocationAreaItem; } + set + { + SetProperty(ref selectedLocationAreaItem, value); + } + } + + private int locationId; + public int LocationId + { + get { return locationId; } + set + { + SetProperty(ref locationId, value); + } + } + + private string locationCode; + public string LocationCode + { + get { return locationCode; } + set + { + SetProperty(ref locationCode, value); + } + } + + /// + /// 允许放置的货架类型 + /// + private List allowShelfTypes; + public List AllowShelfTypes + { + get { return allowShelfTypes; } + set + { + SetProperty(ref allowShelfTypes, value); + } + } + + private string rcsStoreCode; + public string RcsStoreCode + { + get { return rcsStoreCode; } + set + { + SetProperty(ref rcsStoreCode, value); + } + } + + private bool isEnable; + public bool IsEnable + { + get { return isEnable; } + set + { + SetProperty(ref isEnable, value); + } + } + #endregion + } +} diff --git a/货架标准上位机/ViewModels/MatBaseInfoViewModel.cs b/货架标准上位机/ViewModels/MatBaseInfoViewModel.cs index 7cf6181..b1fac1c 100644 --- a/货架标准上位机/ViewModels/MatBaseInfoViewModel.cs +++ b/货架标准上位机/ViewModels/MatBaseInfoViewModel.cs @@ -338,11 +338,11 @@ namespace 智慧物流软件系统.ViewModel if (isConfirmed) { //查询勾选的第一个数据 - var matBaseInfoIds = DataGridItemSource?.Where(t => t.IsSelected == true) + var needDeleteIds = DataGridItemSource?.Where(t => t.IsSelected == true) .Select(t => t.Id) .ToList(); - if (matBaseInfoIds == null) + if (needDeleteIds == null) { Growl.Warning("请选择需要修改的数据!"); } @@ -352,7 +352,7 @@ namespace 智慧物流软件系统.ViewModel { UserName = LocalStatic.CurrentUser, DeviceType = LocalFile.Config.DeviceType, - MatBaseInfoIds = matBaseInfoIds, + needDeleteIds = needDeleteIds, }; var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "matBaseInfo/deleteMatBaseInfo", body, "POST"); if (Result != null && Result.Code == 200) diff --git a/货架标准上位机/ViewModels/MatInfoViewModel.cs b/货架标准上位机/ViewModels/MatInfoViewModel.cs index 27e2223..b90d7d6 100644 --- a/货架标准上位机/ViewModels/MatInfoViewModel.cs +++ b/货架标准上位机/ViewModels/MatInfoViewModel.cs @@ -212,11 +212,11 @@ namespace 智慧物流软件系统.ViewModel if (isConfirmed) { //查询勾选的第一个数据 - var matBaseInfoIds = DataGridItemSource?.Where(t => t.IsSelected == true) + var needDeleteIds = DataGridItemSource?.Where(t => t.IsSelected == true) .Select(t => t.Id) .ToList(); - if (matBaseInfoIds == null) + if (needDeleteIds == null) { Growl.Warning("请选择需要修改的数据!"); } @@ -226,7 +226,7 @@ namespace 智慧物流软件系统.ViewModel { UserName = LocalStatic.CurrentUser, DeviceType = LocalFile.Config.DeviceType, - MatBaseInfoIds = matBaseInfoIds, + needDeleteIds = needDeleteIds, }; var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "matBaseInfos/deleteMatBaseInfo", body, "POST"); if (Result != null && Result.Code == 200) diff --git a/货架标准上位机/ViewModels/ShelfInfoViewModel.cs b/货架标准上位机/ViewModels/ShelfInfoViewModel.cs index 47eb15c..91cdae0 100644 --- a/货架标准上位机/ViewModels/ShelfInfoViewModel.cs +++ b/货架标准上位机/ViewModels/ShelfInfoViewModel.cs @@ -223,11 +223,11 @@ namespace 智慧物流软件系统.ViewModel if (isConfirmed) { //查询勾选的第一个数据 - var matBaseInfoIds = DataGridItemSource?.Where(t => t.IsSelected == true) + var needDeleteIds = DataGridItemSource?.Where(t => t.IsSelected == true) .Select(t => t.Id) .ToList(); - if (matBaseInfoIds == null) + if (needDeleteIds == null) { Growl.Warning("请选择需要修改的数据!"); } @@ -237,7 +237,7 @@ namespace 智慧物流软件系统.ViewModel { UserName = LocalStatic.CurrentUser, DeviceType = LocalFile.Config.DeviceType, - MatBaseInfoIds = matBaseInfoIds, + needDeleteIds = needDeleteIds, }; var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "storeInfo/deleteShelfInfo", body, "POST"); if (Result != null && Result.Code == 200) diff --git a/货架标准上位机/Views/LocationInfoAddOrUpdateView.xaml b/货架标准上位机/Views/LocationInfoAddOrUpdateView.xaml new file mode 100644 index 0000000..e0250f0 --- /dev/null +++ b/货架标准上位机/Views/LocationInfoAddOrUpdateView.xaml @@ -0,0 +1,91 @@ + + + + + + + + + +