From aaf7c175627a140e39313d779c4e5fabf1b290fe Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Tue, 23 Apr 2024 08:31:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WCS.BLL/DbModels/MatBaseInfo.cs | 2 - WCS.BLL/DbModels/MatInfo.cs | 12 + WCS.BLL/HardWare/IShelfBase.cs | 5 + WCS.BLL/HardWare/IWarningLightBase.cs | 94 ++++- WCS.BLL/HardWare/SingleLightShelf.cs | 5 + WCS.BLL/HardWare/SmartShelf.cs | 153 ++++++- WCS.BLL/HardWare/SmartShelfModule.cs | 67 +++- .../Services/IService/IMatBaseInfoService.cs | 3 + .../IService/IMatInventoryDetailService.cs | 2 + .../Services/IService/ISelfCheckService.cs | 16 + WCS.BLL/Services/Service/InstoreService.cs | 16 +- .../Services/Service/MatBaseInfoService.cs | 47 ++- .../Service/MatInventoryDetailService.cs | 28 +- WCS.BLL/Services/Service/SelfCheckService.cs | 46 +++ .../ApiModel/InStore/QueryByMatSnResponse.cs | 4 + .../ApiModel/MatBaseInfo/GetMatInfoRequest.cs | 17 + .../ApiModel/MatBaseInfo/MatInfoModel.cs | 24 +- .../GetMatInventorySummaryRequest.cs | 21 + .../MatInventorySummaryModel.cs | 43 ++ .../StartSelfCheckByShelfCodeRequest.cs | 11 + WCS.WebApi/Controllers/InstoreController.cs | 3 +- .../Controllers/MatBaseInfoController.cs | 14 +- .../MatInventoryDetailController.cs | 6 + WCS.WebApi/Controllers/SelfCheckController.cs | 47 +++ WCS.WebApi/Program.cs | 1 + .../Converters/WorkItemBackgroundConverter.cs | 31 ++ 货架标准上位机/ViewModels/HomeViewModel.cs | 6 +- .../ViewModels/InInventoryViewModel.cs | 5 +- 货架标准上位机/ViewModels/MatInfoViewModel.cs | 278 +++++++++++++ .../ViewModels/OutInventoryAddDucumentViewModel.cs | 66 +++ .../ViewModels/OutInventoryAddMatViewModel.cs | 95 +++++ .../ViewModels/OutInventoryViewModel.cs | 379 ++++++++++++++++++ .../Views/MainWindows/MainWindow1.xaml | 2 +- .../Views/MatBaseInoGenarateMatInfoView.xaml.cs | 2 + 货架标准上位机/Views/MatInfoView.xaml | 17 +- 货架标准上位机/Views/MatInfoView.xaml.cs | 13 +- .../Views/MatInventoryDetailView.xaml.cs | 8 - .../Views/OutInventoryAddDucumentView.xaml | 90 +++++ .../Views/OutInventoryAddDucumentView.xaml.cs | 97 +++++ .../Views/OutInventoryAddMatView.xaml | 102 +++++ .../Views/OutInventoryAddMatView.xaml.cs | 81 ++++ 货架标准上位机/Views/OutInventoryView.xaml | 200 +++++++++ 货架标准上位机/Views/OutInventoryView.xaml.cs | 108 +++++ 43 files changed, 2196 insertions(+), 71 deletions(-) create mode 100644 WCS.BLL/Services/IService/ISelfCheckService.cs create mode 100644 WCS.BLL/Services/Service/SelfCheckService.cs create mode 100644 WCS.Model/ApiModel/MatBaseInfo/GetMatInfoRequest.cs create mode 100644 WCS.Model/ApiModel/MatInventoryDetail/GetMatInventorySummaryRequest.cs create mode 100644 WCS.Model/ApiModel/MatInventoryDetail/MatInventorySummaryModel.cs create mode 100644 WCS.Model/ApiModel/SelfCheck/StartSelfCheckByShelfCodeRequest.cs create mode 100644 WCS.WebApi/Controllers/SelfCheckController.cs create mode 100644 货架标准上位机/Converters/WorkItemBackgroundConverter.cs create mode 100644 货架标准上位机/ViewModels/MatInfoViewModel.cs create mode 100644 货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs create mode 100644 货架标准上位机/ViewModels/OutInventoryAddMatViewModel.cs create mode 100644 货架标准上位机/ViewModels/OutInventoryViewModel.cs create mode 100644 货架标准上位机/Views/OutInventoryAddDucumentView.xaml create mode 100644 货架标准上位机/Views/OutInventoryAddDucumentView.xaml.cs create mode 100644 货架标准上位机/Views/OutInventoryAddMatView.xaml create mode 100644 货架标准上位机/Views/OutInventoryAddMatView.xaml.cs create mode 100644 货架标准上位机/Views/OutInventoryView.xaml create mode 100644 货架标准上位机/Views/OutInventoryView.xaml.cs diff --git a/WCS.BLL/DbModels/MatBaseInfo.cs b/WCS.BLL/DbModels/MatBaseInfo.cs index a29ef42..6f234ae 100644 --- a/WCS.BLL/DbModels/MatBaseInfo.cs +++ b/WCS.BLL/DbModels/MatBaseInfo.cs @@ -125,7 +125,5 @@ namespace WCS.BLL.DbModels /// [SugarColumn(IsIgnore = true)] public int RowNumber { get; set; } - - } } diff --git a/WCS.BLL/DbModels/MatInfo.cs b/WCS.BLL/DbModels/MatInfo.cs index 506341e..2f8e6a9 100644 --- a/WCS.BLL/DbModels/MatInfo.cs +++ b/WCS.BLL/DbModels/MatInfo.cs @@ -90,5 +90,17 @@ namespace WCS.BLL.DbModels /// [SugarColumn(ColumnName = "modify_time", IsNullable = true, ColumnDescription = "更新时间")] public DateTime? ModifyTime { get; set; } = DateTime.Now; + + /// + /// 用于绑定DataGrid中是否选择 + /// + [SugarColumn(IsIgnore = true)] + public bool IsSelected { get; set; } + + /// + /// 用于绑定中显示序号 + /// + [SugarColumn(IsIgnore = true)] + public int RowNumber { get; set; } } } diff --git a/WCS.BLL/HardWare/IShelfBase.cs b/WCS.BLL/HardWare/IShelfBase.cs index 6b57d8c..42f4a64 100644 --- a/WCS.BLL/HardWare/IShelfBase.cs +++ b/WCS.BLL/HardWare/IShelfBase.cs @@ -96,6 +96,11 @@ namespace WCS.BLL.HardWare /// 货架复位 /// public void Reset(); + + /// + /// 货架自检 + /// + public void ShelfCheck(); } public enum Mode diff --git a/WCS.BLL/HardWare/IWarningLightBase.cs b/WCS.BLL/HardWare/IWarningLightBase.cs index d6cbfe1..ef6a7b7 100644 --- a/WCS.BLL/HardWare/IWarningLightBase.cs +++ b/WCS.BLL/HardWare/IWarningLightBase.cs @@ -1,4 +1,5 @@ -using System; +using SqlSugar; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,8 +7,95 @@ using System.Threading.Tasks; namespace WCS.BLL.HardWare { - public interface IWarningLightBase + public class WarningLight { - public void BlueLight(); + #region 关于协议的几个枚举 + public enum LightColorEnum + { + 红色 = 0x01, + 绿色 = 0x02, + 蓝色 = 0x03, + } + public enum LightModeEnum + { + 关闭 = 0x00, + 常亮 = 0x01, + 闪烁 = 0x02, + 短亮一次 = 0x03 + } + public enum LightBuzzerStatus + { + 关闭 = 0x00, + 循环鸣叫 = 0x01, + 鸣叫一次 = 0x02 + } + #endregion + public int LightId { get; set; } = 2047; + + public void LightOperation(LightColorEnum lightColor, LightModeEnum lightMode, LightBuzzerStatus lightBuzzerStatus, TCPClient tcpClient, byte time = 0x00) + { + try + { + var data = new byte[8] { 0x20, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00 }; + data[2] = (byte)lightColor; + data[3] = (byte)lightMode; + data[5] = (byte)lightBuzzerStatus; + + data[4] = time;//灯短亮一次的时间 + data[6] = time;//蜂鸣器持续鸣叫的时间 + + tcpClient.Send(tcpClient.GenerateMessage(LightId, data)); + return; + } + catch (Exception ex) + { + + } + } + + public void BlueLight(TCPClient tcpClient) + { + LightOperation(LightColorEnum.蓝色, LightModeEnum.常亮, LightBuzzerStatus.关闭, tcpClient); + } + + + + //public void CloseLight(string ip, int tagId) + //{ + // LightOperation(LightColorEnum.蓝色, LightModeEnum.关闭, LightBuzzerStatus.关闭, ip, "00", tagId); + //} + + ///// + ///// 红色报警灯 响三秒 + ///// + ///// + ///// + ///// + //public void WaringLight(string ip, int tagId) + //{ + // LightOperation(LightColorEnum.红色, LightModeEnum.短亮一次, LightBuzzerStatus.鸣叫一次, ip, "22", tagId); + // Thread.Sleep(3300); + // return BlueLight(ip, tagId); + //} + + //public void WaringLightAlwaysRed(string ip, int tagId) + //{ + // return LightOperation(LightColorEnum.红色, LightModeEnum.常亮, LightBuzzerStatus.鸣叫一次, ip, "22", tagId); + //} + + //public void SuccessLightBlueEnd(string ip, int tagId) + //{ + // LightOperation(LightColorEnum.绿色, LightModeEnum.短亮一次, LightBuzzerStatus.鸣叫一次, ip, "03", tagId); + // Thread.Sleep(300); + // return BlueLight(ip, tagId); + //} + + //public void SuccessLightGreenEnd(string ip, int tagId) + //{ + // LightOperation(LightColorEnum.绿色, LightModeEnum.短亮一次, LightBuzzerStatus.鸣叫一次, ip, "03", tagId); + // Thread.Sleep(300); + // return GreenLight(ip, tagId); + //} + } } diff --git a/WCS.BLL/HardWare/SingleLightShelf.cs b/WCS.BLL/HardWare/SingleLightShelf.cs index e63dcfb..4d13f46 100644 --- a/WCS.BLL/HardWare/SingleLightShelf.cs +++ b/WCS.BLL/HardWare/SingleLightShelf.cs @@ -60,6 +60,11 @@ namespace WCS.BLL.HardWare throw new NotImplementedException(); } + public void ShelfCheck() + { + throw new NotImplementedException(); + } + public void Warning() { throw new NotImplementedException(); diff --git a/WCS.BLL/HardWare/SmartShelf.cs b/WCS.BLL/HardWare/SmartShelf.cs index d737a46..3726b0c 100644 --- a/WCS.BLL/HardWare/SmartShelf.cs +++ b/WCS.BLL/HardWare/SmartShelf.cs @@ -5,6 +5,8 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; using TouchSocket.Core; +using TouchSocket.Sockets; +using WCS.BLL.DbModels; using WCS.DAL; using WCS.DAL.Db; using WCS.DAL.DbModels; @@ -35,6 +37,7 @@ namespace WCS.BLL.HardWare { ModuleId = module.Id, ModuleCode = module.ModuleCode, + BoardId = module.BoardId, IsEnable = module.IsEnable, CurrentMode = module.CurentMode }); @@ -71,6 +74,9 @@ namespace WCS.BLL.HardWare case 0x01: ; break; + case 0x03://正常入库信号 + InStoreReturnProcess(dataTemp); + break; default: ; break; @@ -91,7 +97,7 @@ namespace WCS.BLL.HardWare public List Modules { get; set; } = new List(); public TCPClient TcpCleint { get; set; } - public IWarningLightBase WarningLight { get; set; } + public WarningLight WarningLight { get; set; } public List ExceptionMessages { get; set; } = new List(); public string? InstoreIpAddress { get; set; } = string.Empty; @@ -100,6 +106,7 @@ namespace WCS.BLL.HardWare public string OrderNumber { get; set; } + #region 协议处理 public void GoInInstore(string? IPAddress) { //判断当前模式是否为待机模式 @@ -139,16 +146,10 @@ namespace WCS.BLL.HardWare } //警示灯亮起 //WarningLight.BlueLight(); - //绑定当前入库PDA的IP + //绑定当前进入入库PDA/WCS前端的IP InstoreIpAddress = IPAddress; //返回成功 return; - - } - - public void GoInInstoreReturn() - { - } public void GoOutInstore() @@ -181,7 +182,6 @@ namespace WCS.BLL.HardWare this.CurentMode = Mode.盘点模式; } - public void GoOutOutstore() { this.CurentMode = Mode.待机模式; @@ -206,5 +206,140 @@ namespace WCS.BLL.HardWare { throw new NotImplementedException(); } + + public void ShelfCheck() + { + foreach (var module in Modules.Where(t => t.IsEnable).ToList()) + { + module.ShelfCheck(TcpCleint); + } + } + #endregion + + #region 协议返回处理 + public void InStoreReturnProcess(byte[] data) + { + var boardId = (data[TcpCleint.PreFixLength + 0] << 8) + data[TcpCleint.PreFixLength + 1]; + var number = Convert.ToInt32(data[TcpCleint.PreFixLength + 3]); + var storeInfo = DbHelp.db.Queryable().Where(t => t.BoardId == boardId + && t.LightNumber == number).First(); + if (storeInfo == null) + { + //TO DO 报错 + return; + } + var module = this.Modules.Where(t => t.BoardId == boardId) + .FirstOrDefault(); + if (module == null) + { + //TO DO 报错 + return; + } + #region 判断是否扫码获取物料信息 + //物料未扫码 + if (this.InStoreData == null) + { + //重复给了多次信号 + if (!string.IsNullOrEmpty(storeInfo.CurrentMatSn)) + { + module.ComfirmInstore(TcpCleint); + //TO DO Logs.Write($"[{guid}]CAN给了多次正常入库信号,防止硬件异常,返回了确认入库"); + return; + } + else + { + module.ComfirmErrInstore(TcpCleint); + //WaringLight(shelfStatus.ClientIp, shelfStatus.LightId); + //TO DO Logs.Write($"[{guid}]当前物料信息不存在,请取出后重新扫码进行入库!"); + return; + } + } + //该位置已放置物料 + else if (!string.IsNullOrEmpty(storeInfo.CurrentMatSn)) + { + //ComfirmErrInstoreByIp(shelfStatus.ClientIp, boardId); + //WaringLight(shelfStatus.ClientIp, shelfStatus.LightId); + //Logs.Write($"[{guid}]该位置已放置物料!"); + return; + } + #endregion + + #region 已扫码且库位未被占用 保存数据 + { + try + { + DbHelp.db.BeginTran(); + //库存明细表 + var inventoryDetail = new InventoryDetail + { + StoreCode = storeInfo.StoreCode, + StoreId = storeInfo.Id, + + MatSN = this.InStoreData.materialBar, + MatCode = this.InStoreData.materialCode, + MatName = this.InStoreData.materialName, + MatSpec = this.InStoreData.materialSpec, + MatBatch = this.InStoreData.batchNo, + MatQty = (int)this.InStoreData.materialQty, + MatCustomer = this.InStoreData.customer, + MatSupplier = this.InStoreData.supplier, + + InstoreTime = DateTime.Now, + InstoreUser = "" + }; + + //出入库记录表 + var inOutRecord = new InOutRecord() + { + StoreCode = storeInfo.StoreCode, + StoreId = storeInfo.Id, + StoreInfo = storeInfo, + + MatSN = this.InStoreData.materialBar, + MatCode = this.InStoreData.materialCode, + MatName = this.InStoreData.materialName, + MatSpec = this.InStoreData.materialSpec, + MatBatch = this.InStoreData.batchNo, + MatQty = (int)this.InStoreData.materialQty, + MatCustomer = this.InStoreData.customer, + MatSupplier = this.InStoreData.supplier, + + OperateUser = this.InStoreData.InstoreUser, + Direction = DirectionEnum.入库, + }; + + //库位表 + storeInfo.CurrentMatSn = this.InStoreData.materialBar; + + //保存and更新数据 + DbHelp.db.Insertable(inventoryDetail).ExecuteCommand(); + DbHelp.db.Insertable(inOutRecord).ExecuteCommand(); + DbHelp.db.Updateable(storeInfo).ExecuteCommand(); + DbHelp.db.CommitTran(); + + //清空扫码信息 + this.InStoreData = null; + + //实际入库位置亮灯1S,报警灯同时进行亮绿灯并鸣叫一次提示。 + Thread.Sleep(20); + Task.Run(() => + { + //确认入库(硬件入库位置亮灯1秒) + //ComfirmInstoreByIp(client.IP, boardId); + //报警灯亮绿灯 鸣叫一次提示 + //SuccessLightBlueEnd(shelfStatus.ClientIp, shelfStatus.LightId); + }); + } + catch (Exception ex) + { + DbHelp.db.RollbackTran(); + Logs.Write($"入库保存数据异常,异常信息为{ex.Message}"); + //报警灯报警 + //WaringLight(shelfStatus.ClientIp, shelfStatus.LightId); + } + } + #endregion + } + #endregion } } diff --git a/WCS.BLL/HardWare/SmartShelfModule.cs b/WCS.BLL/HardWare/SmartShelfModule.cs index 9323f16..e1ccf34 100644 --- a/WCS.BLL/HardWare/SmartShelfModule.cs +++ b/WCS.BLL/HardWare/SmartShelfModule.cs @@ -10,18 +10,32 @@ namespace WCS.BLL.HardWare { public class SmartShelfModule : IModuleBase { - #region 协议明细 + #region 协议 /// /// 进入入库模式 /// public byte[] GoInInstoreData = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + + /// + /// 确认入库 + /// + public byte[] ComfirmInstoreData = { 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + + public byte[] ComfirmErrInstoreData = { 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + /// /// 退出入库模式 /// public byte[] GoOutInstoreData = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + + /// + /// 自检模式 + /// + public byte[] CheckModeData = { 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; #endregion public int ModuleId { get; set; } public string ModuleCode { get; set; } + public int BoardId { get; set; } public bool IsEnable { get; set; } public Mode CurrentMode { get; set; } @@ -30,16 +44,14 @@ namespace WCS.BLL.HardWare } - public void GoInInstoreMode(TCPClient tcpCleint) + public void GoInInstoreMode(TCPClient tcpClient) { - if (CurrentMode != Mode.待机模式) { - //退出对应的模式 然后再发送进入入库模式 + //TO DO 退出对应的模式 然后再发送进入入库模式 } - var storeInfos = DbHelp.db.Queryable() - .Where(t => t.BoardId == ModuleId) + .Where(t => t.BoardId == BoardId) .OrderBy(t => t.LightNumber) .ToList(); char[] data = "0000000000000000".ToCharArray(); @@ -57,14 +69,24 @@ namespace WCS.BLL.HardWare GoInInstoreData[1] = Convert.ToByte(data1, 2); GoInInstoreData[2] = Convert.ToByte(data2, 2); - tcpCleint.Send(tcpCleint.GenerateMessage(ModuleId, GoInInstoreData)); + tcpClient.Send(tcpClient.GenerateMessage(BoardId, GoInInstoreData)); } - public void GoOutInstoreMode(TCPClient tcpCleint) + public void ComfirmInstore(TCPClient tcpClient) + { + tcpClient.Send(tcpClient.GenerateMessage(BoardId, ComfirmInstoreData)); + } + + public void ComfirmErrInstore(TCPClient tcpClient) + { + tcpClient.Send(tcpClient.GenerateMessage(BoardId, ComfirmErrInstoreData)); + } + + public void GoOutInstoreMode(TCPClient tcpClient) { if (CurrentMode == Mode.入库模式) { - tcpCleint.Send(tcpCleint.GenerateMessage(ModuleId, GoOutInstoreData)); + tcpClient.Send(tcpClient.GenerateMessage(BoardId, GoOutInstoreData)); } else { @@ -73,7 +95,32 @@ namespace WCS.BLL.HardWare } } + public void ShelfCheck(TCPClient tcpClient) + { + if (CurrentMode != Mode.待机模式) + { + //TO DO 退出对应的模式 然后再发送进入入库模式 + } + var storeInfos = DbHelp.db.Queryable() + .Where(t => t.BoardId == BoardId) + .OrderBy(t => t.LightNumber) + .ToList(); + char[] data = "0000000000000000".ToCharArray(); + var boardStoreNumber = storeInfos.Count(); + foreach (var storeInfo in storeInfos) + { + if (!string.IsNullOrEmpty(storeInfo.CurrentMatSn) && storeInfo.LightNumber > 0 && storeInfo.LightNumber <= boardStoreNumber) + { + data[storeInfo.LightNumber - 1] = '1'; + } + } + var dataStr = string.Join("", data.Reverse()); + var data1 = dataStr.Substring(8, 8); + var data2 = dataStr.Substring(0, 8); + CheckModeData[1] = Convert.ToByte(data1, 2); + CheckModeData[2] = Convert.ToByte(data2, 2); - + tcpClient.Send(tcpClient.GenerateMessage(BoardId, CheckModeData)); + } } } diff --git a/WCS.BLL/Services/IService/IMatBaseInfoService.cs b/WCS.BLL/Services/IService/IMatBaseInfoService.cs index 902a22b..674cc61 100644 --- a/WCS.BLL/Services/IService/IMatBaseInfoService.cs +++ b/WCS.BLL/Services/IService/IMatBaseInfoService.cs @@ -22,5 +22,8 @@ namespace WCS.BLL.Services.IService public Task> deleteMatBaseInfo(DeleteMatBaseInfosRequest request); public Task>> getMatCodeList(GetMatCodeListRequest request); + + + public Task> getMatInfo(GetMatInfoRequest request); } } diff --git a/WCS.BLL/Services/IService/IMatInventoryDetailService.cs b/WCS.BLL/Services/IService/IMatInventoryDetailService.cs index d8363db..6d54543 100644 --- a/WCS.BLL/Services/IService/IMatInventoryDetailService.cs +++ b/WCS.BLL/Services/IService/IMatInventoryDetailService.cs @@ -14,5 +14,7 @@ namespace WCS.BLL.Services.IService public Task> getMatInventoryDetail(GetMatInventoryDetailRequest request); public Task> exportMatInventoryDetail(GetMatInventoryDetailRequest request); + + public Task>> getMatInventorySummary(GetMatInventorySummaryRequest request); } } diff --git a/WCS.BLL/Services/IService/ISelfCheckService.cs b/WCS.BLL/Services/IService/ISelfCheckService.cs new file mode 100644 index 0000000..141f61a --- /dev/null +++ b/WCS.BLL/Services/IService/ISelfCheckService.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WCS.Model.ApiModel.Stocktaking; +using WCS.Model; +using WCS.Model.ApiModel.SelfCheck; + +namespace WCS.BLL.Services.IService +{ + public interface ISelfCheckService + { + public Task StartSelfCheckByShelfCode(StartSelfCheckByShelfCodeRequest request); + } +} diff --git a/WCS.BLL/Services/Service/InstoreService.cs b/WCS.BLL/Services/Service/InstoreService.cs index 0d215fc..75baa7e 100644 --- a/WCS.BLL/Services/Service/InstoreService.cs +++ b/WCS.BLL/Services/Service/InstoreService.cs @@ -12,6 +12,7 @@ using WCS.BLL.Manager; using WCS.BLL.Services.IService; using WCS.DAL.Db; using WCS.Model; +using WCS.Model.ApiModel.MatBaseInfo; namespace WCS.BLL.Services.Service { @@ -86,7 +87,7 @@ namespace WCS.BLL.Services.Service var shelf = ShelfManager.Shelves.Where(t => t.ShelfCode == request.ShelfCode).FirstOrDefault(); if (shelf == null)//货架不存在 { - return new QueryByMatSnResponse() + return new ResponseCommon() { Code = 201, Message = $"操作失败:货架[{request.ShelfCode}]不存在!", @@ -95,7 +96,7 @@ namespace WCS.BLL.Services.Service //判断当前是否是入库模式 if (shelf.CurentMode != Mode.入库模式) { - return new QueryByMatSnResponse() + return new ResponseCommon() { Code = 201, Message = $"操作失败:货架[{request.ShelfCode}]不在入库模式!\r\n当前为{shelf.CurentMode}", @@ -105,7 +106,7 @@ namespace WCS.BLL.Services.Service var inventory = await DbHelp.db.Queryable().Where(t => t.MatSN == request.MatSn).FirstAsync(); if (inventory != null) { - return new QueryByMatSnResponse() + return new ResponseCommon() { Code = 201, Message = $"操作失败:物料{inventory.MatSN}已入库,库位为{inventory.StoreCode}", @@ -134,17 +135,19 @@ namespace WCS.BLL.Services.Service batchNo = matInfo.MatBatch, supplier = matInfo.MatSupplier, customer = matInfo.MatCustomer, + + InstoreUser = request.UserName }; - return new QueryByMatSnResponse() + return new ResponseCommon() { Code = 200, - Data = shelf.InStoreData, + Data = matInfo, Message = "success" }; } else - return new QueryByMatSnResponse() + return new ResponseCommon() { Code = 201, Data = null, @@ -176,6 +179,7 @@ namespace WCS.BLL.Services.Service Message = $"货架[{request.ShelfCode}]已退出入库模式!\r\n当前为{shelf.CurentMode}", }; } + //这个时间相当于需要入库扫码后需要等待的时间 var timeOut = 5000; var timeSpan = TimeSpan.FromMilliseconds(0); diff --git a/WCS.BLL/Services/Service/MatBaseInfoService.cs b/WCS.BLL/Services/Service/MatBaseInfoService.cs index e1e7557..b6acc77 100644 --- a/WCS.BLL/Services/Service/MatBaseInfoService.cs +++ b/WCS.BLL/Services/Service/MatBaseInfoService.cs @@ -378,8 +378,6 @@ namespace WCS.BLL.Services.Service { try { - - List matCodeList = null; if (request.IsFromBaseData) { @@ -412,5 +410,50 @@ namespace WCS.BLL.Services.Service }; } } + + + + public async Task> getMatInfo(GetMatInfoRequest request) + { + try + { + var recordsQueryable = DbHelp.db.Queryable() + .WhereIF(!string.IsNullOrEmpty(request.MatCode), t => t.MatCode.Contains(request.MatCode)) + .WhereIF(!string.IsNullOrEmpty(request.MatName), t => t.MatName.Contains(request.MatName)) + .WhereIF(!string.IsNullOrEmpty(request.MatSpec), t => t.MatSpec.Contains(request.MatSpec)) + .WhereIF(!string.IsNullOrEmpty(request.MatSN), t => t.MatSn.Contains(request.MatSN)); + 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) * 10 + 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}", + }; + } + } + } } diff --git a/WCS.BLL/Services/Service/MatInventoryDetailService.cs b/WCS.BLL/Services/Service/MatInventoryDetailService.cs index 7c3573a..c1e226a 100644 --- a/WCS.BLL/Services/Service/MatInventoryDetailService.cs +++ b/WCS.BLL/Services/Service/MatInventoryDetailService.cs @@ -122,6 +122,32 @@ namespace WCS.BLL.Services.Service }; } } - + + public async Task>> getMatInventorySummary(GetMatInventorySummaryRequest request) + { + var inventortyDetails = await DbHelp.db.Queryable() + .WhereIF(!string.IsNullOrEmpty(request.MatName), t => t.MatName.Contains(request.MatName)) + .WhereIF(!string.IsNullOrEmpty(request.MatCode), t => t.MatCode.Contains(request.MatCode)) + .GroupBy(t => t.MatCode) + .GroupBy(t => t.MatBatch) + .Select(t => new MatInventorySummaryModel + { + MatCode = t.MatCode, + MatName = t.MatName, + MatBatch = t.MatBatch, + MatSpec = t.MatSpec, + MatCustomer = t.MatCustomer, + MatSupplier = t.MatSupplier, + TotalQty = SqlFunc.AggregateSum(t.MatQty) + }) + .ToListAsync(); + + return new ResponseCommon>() + { + Code = 200, + Message = inventortyDetails.Count().ToString(), + Data = inventortyDetails + }; + } } } diff --git a/WCS.BLL/Services/Service/SelfCheckService.cs b/WCS.BLL/Services/Service/SelfCheckService.cs new file mode 100644 index 0000000..faf4866 --- /dev/null +++ b/WCS.BLL/Services/Service/SelfCheckService.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WCS.BLL.Manager; +using WCS.BLL.Services.IService; +using WCS.Model; +using WCS.Model.ApiModel.SelfCheck; + +namespace WCS.BLL.Services.Service +{ + public class SelfCheckService : ISelfCheckService + { + public async Task StartSelfCheckByShelfCode(StartSelfCheckByShelfCodeRequest request) + { + //获取货架 + var shelfs = ShelfManager.Shelves + .Where(t => request.ShelfCodes.Contains(t.ShelfCode)) + .ToList(); + + if (shelfs.Count < request.ShelfCodes.Count) + { + foreach (var shelf in shelfs) + { + request.ShelfCodes.RemoveAll(t => t == shelf.ShelfCode); + } + return new ResponseCommon() + { + Code = 201, + Message = $"货架{string.Join(",", request.ShelfCodes)}不存在!", + }; + } + + foreach (var shelf in shelfs) + { + shelf.ShelfCheck(); + } + return new ResponseCommon() + { + Code = 200, + Message = $"货架{string.Join(",", request.ShelfCodes)}已开始自检!", + }; + } + } +} diff --git a/WCS.Model/ApiModel/InStore/QueryByMatSnResponse.cs b/WCS.Model/ApiModel/InStore/QueryByMatSnResponse.cs index 478e753..0b31c3b 100644 --- a/WCS.Model/ApiModel/InStore/QueryByMatSnResponse.cs +++ b/WCS.Model/ApiModel/InStore/QueryByMatSnResponse.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using WCS.Model.ApiModel.MatBaseInfo; namespace WCS.Model { @@ -28,5 +29,8 @@ namespace WCS.Model public string supplier { get; set; } public string customer { get; set; } + + + public string InstoreUser { get; set; } } } diff --git a/WCS.Model/ApiModel/MatBaseInfo/GetMatInfoRequest.cs b/WCS.Model/ApiModel/MatBaseInfo/GetMatInfoRequest.cs new file mode 100644 index 0000000..026a9e1 --- /dev/null +++ b/WCS.Model/ApiModel/MatBaseInfo/GetMatInfoRequest.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.MatBaseInfo +{ + public class GetMatInfoRequest : PageQueryRequestBase + { + public string MatCode { get; set; } + + public string MatName { get; set; } + + public string MatSpec { get; set; } + + public string MatSN { get; set; } + } +} diff --git a/WCS.Model/ApiModel/MatBaseInfo/MatInfoModel.cs b/WCS.Model/ApiModel/MatBaseInfo/MatInfoModel.cs index 6a61f84..63e702c 100644 --- a/WCS.Model/ApiModel/MatBaseInfo/MatInfoModel.cs +++ b/WCS.Model/ApiModel/MatBaseInfo/MatInfoModel.cs @@ -1,15 +1,16 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Text; namespace WCS.Model.ApiModel.MatBaseInfo { - public class MatInfoModel + public class MatInfoModel : INotifyPropertyChanged { public int Id { get; set; } - public string MatSn { get; set; } + public string MatSN { get; set; } public string MatCode { get; set; } @@ -32,5 +33,24 @@ namespace WCS.Model.ApiModel.MatBaseInfo public string? ModifyUser { get; set; } public DateTime? ModifyTime { get; set; } = DateTime.Now; + + public bool IsSelected + { + get { return isSelected; } + set + { + isSelected = value; + OnPropertyChanged(nameof(IsSelected)); + } + } + public bool isSelected; + + public int RowNumber { get; set; } + + public event PropertyChangedEventHandler PropertyChanged; + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } } } diff --git a/WCS.Model/ApiModel/MatInventoryDetail/GetMatInventorySummaryRequest.cs b/WCS.Model/ApiModel/MatInventoryDetail/GetMatInventorySummaryRequest.cs new file mode 100644 index 0000000..ccbccdb --- /dev/null +++ b/WCS.Model/ApiModel/MatInventoryDetail/GetMatInventorySummaryRequest.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.MatInventoryDetail +{ + public class GetMatInventorySummaryRequest + { + public string MatCode { get; set; } + + public string MatName { get; set; } + + public string MatSpec { get; set; } + + public string MatBatch { get; set; } + + public string MatSupplier { get; set; } + + public string MatCustomer { get; set; } + } +} diff --git a/WCS.Model/ApiModel/MatInventoryDetail/MatInventorySummaryModel.cs b/WCS.Model/ApiModel/MatInventoryDetail/MatInventorySummaryModel.cs new file mode 100644 index 0000000..d71f5a9 --- /dev/null +++ b/WCS.Model/ApiModel/MatInventoryDetail/MatInventorySummaryModel.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace WCS.Model.ApiModel.MatInventoryDetail +{ + public class MatInventorySummaryModel: INotifyPropertyChanged + { + public string MatCode { get; set; } + + public string MatName { get; set; } + + public string MatSpec { get; set; } + + public string MatBatch { get; set; } + + public string MatSupplier { get; set; } + + public string MatCustomer { get; set; } + + public int TotalQty { get; set; } + + public int NeedQty { get; set; } = 0; + + 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/SelfCheck/StartSelfCheckByShelfCodeRequest.cs b/WCS.Model/ApiModel/SelfCheck/StartSelfCheckByShelfCodeRequest.cs new file mode 100644 index 0000000..3b5ac00 --- /dev/null +++ b/WCS.Model/ApiModel/SelfCheck/StartSelfCheckByShelfCodeRequest.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.SelfCheck +{ + public class StartSelfCheckByShelfCodeRequest : RequestBase + { + public List ShelfCodes { get; set; } + } +} diff --git a/WCS.WebApi/Controllers/InstoreController.cs b/WCS.WebApi/Controllers/InstoreController.cs index 736251e..f5aefe9 100644 --- a/WCS.WebApi/Controllers/InstoreController.cs +++ b/WCS.WebApi/Controllers/InstoreController.cs @@ -36,7 +36,8 @@ namespace WebApi.Controllers var IPAdress = HttpContext?.Connection?.RemoteIpAddress?.ToString(); if (string.IsNullOrEmpty(IPAdress)) { - //δȡ豸IPַ TO DO ¼־δȡIP + //δȡ豸IPַ + //TO DO ¼־δȡIP } else { diff --git a/WCS.WebApi/Controllers/MatBaseInfoController.cs b/WCS.WebApi/Controllers/MatBaseInfoController.cs index 85b2eca..5b5ee85 100644 --- a/WCS.WebApi/Controllers/MatBaseInfoController.cs +++ b/WCS.WebApi/Controllers/MatBaseInfoController.cs @@ -29,7 +29,7 @@ namespace WCS.WebApi.Controllers public MatBaseInfoController(IMatBaseInfoService matBaseInfoService, IGenerateService generateMatInfoService) { _matBaseInfoService = matBaseInfoService; - _generateMatInfoService = generateMatInfoService; + _generateMatInfoService = generateMatInfoService; } [Route("getMatBaseInfo")] @@ -110,5 +110,17 @@ namespace WCS.WebApi.Controllers { return await _generateMatInfoService.generateMatInfo(request); } + + /// + /// 获取物料明细 + /// + /// + /// + [Route("getMatInfo")] + [HttpPost(Name = "getMatInfo")] + public async Task getMatInfo(GetMatInfoRequest request) + { + return await _matBaseInfoService.getMatInfo(request); + } } } diff --git a/WCS.WebApi/Controllers/MatInventoryDetailController.cs b/WCS.WebApi/Controllers/MatInventoryDetailController.cs index 5bb8e06..b0e75e3 100644 --- a/WCS.WebApi/Controllers/MatInventoryDetailController.cs +++ b/WCS.WebApi/Controllers/MatInventoryDetailController.cs @@ -80,5 +80,11 @@ namespace WCS.WebApi.Controllers //} } + [Route("getMatInventorySummary")] + [HttpPost(Name = "getMatInventorySummary")] + public async Task getMatInventorySummary(GetMatInventorySummaryRequest request) + { + return await _matInventoryDetailService.getMatInventorySummary(request); + } } } diff --git a/WCS.WebApi/Controllers/SelfCheckController.cs b/WCS.WebApi/Controllers/SelfCheckController.cs new file mode 100644 index 0000000..738b2d5 --- /dev/null +++ b/WCS.WebApi/Controllers/SelfCheckController.cs @@ -0,0 +1,47 @@ +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using WCS.BLL.DbModels; +using WCS.BLL.Manager; +using WCS.BLL.Services.IService; +using WCS.BLL.Services.Service; +using WCS.DAL.Db; +using WCS.Model; +using WCS.Model.ApiModel.Home; +using WCS.Model.ApiModel.SelfCheck; + +namespace WCS.WebApi.Controllers +{ + /// + /// 自检 + /// + [ApiController] + [Route("[controller]")] + public class SelfCheckController : ControllerBase + { + public ISelfCheckService _selfCheckService { get; set; } + + public SelfCheckController(ISelfCheckService selfCheckService) + { + _selfCheckService = selfCheckService; + } + + [Route("startSelfCheckByShelfCode")] + [HttpPost(Name = "startSelfCheckByShelfCode")] + public async Task startSelfCheckByShelfCode(StartSelfCheckByShelfCodeRequest request) + { + try + { + return await _selfCheckService.StartSelfCheckByShelfCode(request); + } + catch (Exception ex) + { + return new ResponseBase() + { + Code = 300, + Message = "开始自检失败:" + ex.Message, + }; + } + } + + } +} diff --git a/WCS.WebApi/Program.cs b/WCS.WebApi/Program.cs index 756372a..471cc88 100644 --- a/WCS.WebApi/Program.cs +++ b/WCS.WebApi/Program.cs @@ -60,6 +60,7 @@ namespace WebApi builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddScoped(); //롢ɵõģʽ builder.Services.AddSingleton(); diff --git a/货架标准上位机/Converters/WorkItemBackgroundConverter.cs b/货架标准上位机/Converters/WorkItemBackgroundConverter.cs new file mode 100644 index 0000000..da34ea2 --- /dev/null +++ b/货架标准上位机/Converters/WorkItemBackgroundConverter.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; + +namespace 货架标准上位机 +{ + class WorkItemBackgroundConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value.ToString() == "True") + { + return Brushes.ForestGreen; + } + else + { + return Brushes.White; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/货架标准上位机/ViewModels/HomeViewModel.cs b/货架标准上位机/ViewModels/HomeViewModel.cs index 88216c7..12908d9 100644 --- a/货架标准上位机/ViewModels/HomeViewModel.cs +++ b/货架标准上位机/ViewModels/HomeViewModel.cs @@ -48,7 +48,7 @@ namespace 货架标准上位机.ViewModel public WrapPanel wrapPanel; public async void AddUserControl() { - var dia = Dialog.Show(new TextDialog()); + //var dia = Dialog.Show(new TextDialog()); try { var body = new GetShelfStatusRequest() @@ -75,9 +75,9 @@ namespace 货架标准上位机.ViewModel } finally { - dia.Close(); + //dia.Close(); } - } + } #endregion #region 页面加载时任务 diff --git a/货架标准上位机/ViewModels/InInventoryViewModel.cs b/货架标准上位机/ViewModels/InInventoryViewModel.cs index 6b81278..9f37f84 100644 --- a/货架标准上位机/ViewModels/InInventoryViewModel.cs +++ b/货架标准上位机/ViewModels/InInventoryViewModel.cs @@ -185,15 +185,16 @@ namespace 货架标准上位机.ViewModel { var body = new QueryByMatSnRequest() { + MatSn = scanner.TempCode, ShelfCode = scanner.ShelfCode, IpAddress = scanner.COM, DeviceType = LocalFile.Config.DeviceType, UserName = LocalStatic.CurrentUser, }; - var Result = ApiHelp.GetDataFromHttp(LocalFile.Config.ApiIpHost + "instore/queryByMatSn", body, "POST"); + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "instore/queryByMatSn", body, "POST"); if (Result != null && Result.Code == 200) { - scanner.MatSn = Result.Data.materialBar; + scanner.MatSn = Result.Data.MatSN; } } catch (Exception ex) diff --git a/货架标准上位机/ViewModels/MatInfoViewModel.cs b/货架标准上位机/ViewModels/MatInfoViewModel.cs new file mode 100644 index 0000000..08d4152 --- /dev/null +++ b/货架标准上位机/ViewModels/MatInfoViewModel.cs @@ -0,0 +1,278 @@ +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 WCS.BLL.DbModels; +using WCS.Model.ApiModel.MatBaseInfo; +using System.Collections.ObjectModel; +using HandyControl.Tools.Extension; +using 货架标准上位机.Tool; + +namespace 货架标准上位机.ViewModel +{ + public class MatInfoViewModel : BindableBase + { + #region Property + private ObservableCollection dataGridItemSource; + public ObservableCollection DataGridItemSource + { + get { return dataGridItemSource; } + set + { + SetProperty(ref dataGridItemSource, value); + } + } + + public MatInfoModel selectedataGridItem; + public MatInfoModel SelectedataGridItem + { + get { return selectedataGridItem; } + set + { + SetProperty(ref selectedataGridItem, value); + } + } + + /// + /// 物料编码 + /// + private string matCode; + public string MatCode + { + get { return matCode; } + set + { + SetProperty(ref matCode, value); + } + } + + /// + /// 物料名称 + /// + private string matName; + public string MatName + { + get { return matName; } + set + { + SetProperty(ref matName, value); + } + } + + /// + /// 物料规格 + /// + private string matSpec; + public string MatSpec + { + get { return matSpec; } + set + { + SetProperty(ref matSpec, value); + } + } + + 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; + MatSpec = string.Empty; + MatSN = 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 GetMatInfoRequest() + { + MatCode = MatCode, + MatName = MatName, + MatSpec = MatSpec, + MatSN = MatSN, + + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + PageNumber = CurrentPage, + PageSize = 10, + + }; + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "matBaseInfo/getMatInfo", body, "POST"); + if (Result != null && Result.Data != null && Result.Data.Lists != null) + { + DataGridItemSource = new ObservableCollection(Result.Data.Lists); + MaxPage = Result.Data.MaxPage; + TotalCount = Result.Data.TotalCount; + } + } + catch (Exception ex) + { + Growl.Error("加载数据失败:" + ex.Message); + } + finally + { + //dia.Close(); + } + #endregion + + + } + + /// + /// 物料删除操作 + /// + public ICommand BtnDeleteCommand { get => new DelegateCommand(BtnDelete); } + public async 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 DeleteMatBaseInfosRequest() + { + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + MatBaseInfoIds = matBaseInfoIds, + }; + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "matBaseInfo/deleteMatBaseInfo", body, "POST"); + if (Result != null && Result.Code == 200) + { + CurrentPage = 1; + Growl.Success("删除成功!" + Result?.Message); + } + else + { + Growl.Error($"{Result?.Message?.ToString()}"); + } + } + } + return true; + }); + } + + public ICommand BtnPrintCommand { get => new DelegateCommand(BtnPrint); } + public async void BtnPrint() + { + var matBaseInfo = DataGridItemSource?.Where(t => t.IsSelected == true).ToList(); + //TO DO后台批量打印 + } + #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 + } +} diff --git a/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs b/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs new file mode 100644 index 0000000..83d8ad2 --- /dev/null +++ b/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs @@ -0,0 +1,66 @@ +using HandyControl.Controls; +using Ping9719.WpfEx.Mvvm; +using System; +using System.Collections.ObjectModel; +using System.Windows; +using System.Windows.Input; +using WCS.BLL.DbModels; +using WCS.Model.ApiModel.MatInventoryDetail; + +namespace 货架标准上位机.ViewModels +{ + public class OutInventoryAddDucumentViewModel : BindableBase + { + #region Property + private ObservableCollection dataGridItemSource; + public ObservableCollection DataGridItemSource + { + get { return dataGridItemSource; } + set + { + SetProperty(ref dataGridItemSource, value); + } + } + #endregion + + #region Command + /// + /// 新增物料 + /// + public ICommand BtnAddCommand { get => new DelegateCommand(BtnAdd); } + public void BtnAdd() + { + var window = new OutInventoryAddMatView(); + window.Owner = Application.Current.MainWindow; + var result = window.ShowDialog(); + if (result == true) + { + if (DataGridItemSource == null) + DataGridItemSource = new ObservableCollection(); + DataGridItemSource.Add(window.inventorySummary); + } + else + { + return; + } + } + + public ICommand DelCommand { get => new DelegateCommand(Del); } + public void Del(MatInventorySummaryModel obj) + { + try + { + + DataGridItemSource.Remove(obj); + ; + } + catch (Exception ex) + { + + } + } + + + #endregion + } +} diff --git a/货架标准上位机/ViewModels/OutInventoryAddMatViewModel.cs b/货架标准上位机/ViewModels/OutInventoryAddMatViewModel.cs new file mode 100644 index 0000000..04f8520 --- /dev/null +++ b/货架标准上位机/ViewModels/OutInventoryAddMatViewModel.cs @@ -0,0 +1,95 @@ +using HandyControl.Controls; +using Ping9719.WpfEx.Mvvm; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; +using WCS.BLL.DbModels; +using WCS.Model; +using WCS.Model.ApiModel.MatBaseInfo; +using WCS.Model.ApiModel.MatInventoryDetail; +using 货架标准上位机.Api; + +namespace 货架标准上位机.ViewModels +{ + public class OutInventoryAddMatViewModel : BindableBase + { + #region Property + private ObservableCollection dataGridItemSource; + public ObservableCollection DataGridItemSource + { + get { return dataGridItemSource; } + set + { + SetProperty(ref dataGridItemSource, value); + } + } + + private MatInventorySummaryModel selectedataGridItem; + public MatInventorySummaryModel SelectedataGridItem + { + get { return selectedataGridItem; } + set + { + SetProperty(ref selectedataGridItem, value); + } + } + + + private string matCode; + public string MatCode + { + get { return matCode; } + set + { + SetProperty(ref matCode, value); + } + } + + private string matName; + public string MatName + { + get { return matName; } + set + { + SetProperty(ref matName, value); + } + } + #endregion + + #region Command + /// + /// 搜索 + /// + public ICommand BtnSearchCommand { get => new DelegateCommand(BtnSearch); } + public void BtnSearch() + { + #region 调用接口获取数据 + try + { + var body = new GetMatInventorySummaryRequest() + { + MatName = MatName, + MatCode = MatCode, + }; + var Result = ApiHelp.GetDataFromHttp>>(LocalFile.Config.ApiIpHost + "matInventoryDetail/getMatInventorySummary", body, "POST"); + if (Result != null && Result.Data != null) + { + DataGridItemSource = new ObservableCollection(Result.Data); + } + } + catch (Exception ex) + { + Growl.Error("加载数据失败:" + ex.Message); + } + finally + { + } + #endregion + } + #endregion + } +} diff --git a/货架标准上位机/ViewModels/OutInventoryViewModel.cs b/货架标准上位机/ViewModels/OutInventoryViewModel.cs new file mode 100644 index 0000000..9122f59 --- /dev/null +++ b/货架标准上位机/ViewModels/OutInventoryViewModel.cs @@ -0,0 +1,379 @@ +using HandyControl.Controls; +using HandyControl.Data; +using MiniExcelLibs; +using Ping9719.WpfEx.Mvvm; +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using TouchSocket.Core; +using 货架标准上位机.ViewModel; + +namespace 货架标准上位机.ViewModel +{ + public class OutInventoryViewModel : BindableBase + { + public OutInventoryViewModel() + { + //线程 更新当前选择的订单的状态 + //Task.Run(() => + //{ + // while (true) + // { + // try + // { + // Thread.Sleep(1000); + // //if (LocalStatic.IsRefreshOrderDetail) + // //{ + // // LocalStatic.IsRefreshOrderDetail = false; + // // SelectedPickBillNumberChanged(); + // //} + // } + // catch + // { + // //Logs.Write("更新订单状态异常!!"); + // } + // } + //}); + } + + public System.Windows.Controls.TextBox textBox { get; set; } + + #region Property + private string number; + public string Number + { + get { return number; } + set + { + SetProperty(ref number, value); + } + } + + private bool isOrderOut; + public bool IsOrderOut + { + get { return isOrderOut; } + set + { + SetProperty(ref isOrderOut, value); + //LocalStatic.IsOrderOut = value; + } + } + + private string matCode1; + public string MatCode1 + { + get { return matCode1; } + set + { + SetProperty(ref matCode1, value); + } + } + + private int matQty1; + public int MatQty1 + { + get { return matQty1; } + set + { + SetProperty(ref matQty1, value); + } + } + + private string order_prod_number; + public string Order_prod_number + { + get { return order_prod_number; } + set + { + SetProperty(ref order_prod_number, value); + } + } + + private string material_code; + public string Material_code + { + get { return material_code; } + set + { + SetProperty(ref material_code, value); + } + } + + private string material_name; + public string Material_name + { + get { return material_name; } + set + { + SetProperty(ref material_name, value); + } + } + + private string material_spec; + public string Material_spec + { + get { return material_spec; } + set + { + SetProperty(ref material_spec, value); + } + } + + private string matCode; + public string MatCode + { + get { return matCode; } + set + { + SetProperty(ref matCode, value); + } + } + + private string matName; + public string MatName + { + get { return matName; } + set + { + SetProperty(ref matName, value); + } + } + + private string matCode3; + public string MatCode3 + { + get { return matCode3; } + set + { + SetProperty(ref matCode3, value); + } + } + + private string matName3; + public string MatName3 + { + get { return matName3; } + set + { + SetProperty(ref matName3, value); + } + } + + private string matSpec3; + public string MatSpec3 + { + get { return matSpec3; } + set + { + SetProperty(ref matSpec3, value); + } + } + + private string matBatch3; + public string MatBatch3 + { + get { return matBatch3; } + set + { + SetProperty(ref matBatch3, value); + } + } + + private string selectedPickBillNumber; + public string SelectedPickBillNumber + { + get { return selectedPickBillNumber; } + set + { + SetProperty(ref selectedPickBillNumber, value); + } + } + + private string orderProdNumber; + public string OrderProdNumber + { + get { return orderProdNumber; } + set + { + SetProperty(ref orderProdNumber, value); + } + } + + private string orderStatus; + public string OrderStatus + { + get { return orderStatus; } + set + { + SetProperty(ref orderStatus, value); + } + } + + private List dataGridItemSource; + public List DataGridItemSource + { + get { return dataGridItemSource; } + set + { + SetProperty(ref dataGridItemSource, value); + RefreshCount(); + } + } + + //领料单号列表 + private List pickBillNumberList; + public List PickBillNumberList + { + get { return pickBillNumberList; } + set + { + SetProperty(ref pickBillNumberList, value); + } + } + + + + public void RefreshCount() + { + Task.Run(() => + { + TotalPan = dataGridItemSource.Count(); + //SendedPan = dataGridItemSource.Where(t => t.IsSend == true).Count(); + //UnSendedPan = dataGridItemSource.Where(t => t.IsSend == false).Count(); + }); + } + #endregion + + #region Command + //public ICommand BtnSearchCommand { get => new DelegateCommand(BtnSearch); } + //public void BtnSearch() + //{ + // if (string.IsNullOrEmpty(MatCode1)) + // { + // Growl.Warning("请输入料号进行筛选!"); + // return; + // } + // else if (MatQty1 == 0) + // { + // Growl.Warning("请输入需要的数量!"); + // return; + // } + + + // var inventoryDetails = DbHelp.db.Queryable(); + // if (!string.IsNullOrEmpty(MatCode1)) + // { + // inventoryDetails = inventoryDetails + // .Where(t => t.MatCode.Contains(MatCode1)) + // .Includes(t => t.StoreInfo) + // .OrderBy(t => t.MatQty); + // } + // else + // { + + // } + + // var inventorys = inventoryDetails.ToList(); + // int totalMatQty = 0; + // //List dataSourceTemp = new List(); + // foreach (var item in inventorys) + // { + // if (totalMatQty < MatQty1) + // { + // totalMatQty += item.MatQty; + // item.IsSelected = true; + // } + // else + // { + // break; + // } + // } + // DataGridItemSource = inventorys; + //} + + public ICommand BtnOutOrderCommand { get => new DelegateCommand(BtnOutOrder); } + public void BtnOutOrder() + { + var window = new OutInventoryAddDucumentView(); + window.Owner = Application.Current.MainWindow; + window.ShowDialog(); + } + + //public ICommand BtnTempOutCommand { get => new DelegateCommand(BtnTempOut); } + //public void BtnTempOut() + //{ + // var window = new OutInventoryDocumentDetailView(); + // window.ShowDialog(); + // if (window.DialogResult == true) + // { + // DataGridItemSource = window.DataGridItemSource; + + // } + //} + + public ICommand BtnReset3Command { get => new DelegateCommand(BtnReset3); } + public void BtnReset3() + { + MatCode3 = string.Empty; + MatName3 = string.Empty; + MatSpec3 = string.Empty; + MatBatch3 = string.Empty; + } + + + public ICommand BtnStartCommand { get => new DelegateCommand(BtnStart); } + public void BtnStart() + { + return; + } + + public ICommand BtnPauseCommand { get => new DelegateCommand(BtnPause); } + public void BtnPause() + { + + } + #endregion + + + #region PageOperation + private int totalPan; + public int TotalPan + { + get { return totalPan; } + set { SetProperty(ref totalPan, value); } + } + + private int sendedPan; + public int SendedPan + { + get { return sendedPan; } + set { SetProperty(ref sendedPan, value); } + } + + private int unSendedPan; + public int UnSendedPan + { + get { return unSendedPan; } + set { SetProperty(ref unSendedPan, value); } + } + #endregion + + #region private method + public bool GrowlCallBack(bool aaa) + { + return true; + } + #endregion + } +} diff --git a/货架标准上位机/Views/MainWindows/MainWindow1.xaml b/货架标准上位机/Views/MainWindows/MainWindow1.xaml index 75293fd..77c6bf4 100644 --- a/货架标准上位机/Views/MainWindows/MainWindow1.xaml +++ b/货架标准上位机/Views/MainWindows/MainWindow1.xaml @@ -110,7 +110,7 @@ - + diff --git a/货架标准上位机/Views/MatBaseInoGenarateMatInfoView.xaml.cs b/货架标准上位机/Views/MatBaseInoGenarateMatInfoView.xaml.cs index 0246a1f..acc45eb 100644 --- a/货架标准上位机/Views/MatBaseInoGenarateMatInfoView.xaml.cs +++ b/货架标准上位机/Views/MatBaseInoGenarateMatInfoView.xaml.cs @@ -42,6 +42,8 @@ namespace 货架标准上位机 MatBaseInfo = matBaseInfo, TotalCount = Convert.ToInt32(txtTotalCount.Text), MatQty = Convert.ToInt32(txtMatQty.Text), + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, }; var Result = ApiHelp.GetDataFromHttp>>(LocalFile.Config.ApiIpHost + "matBaseInfo/generateMatInfo", body, "POST"); if (Result != null && Result.Data != null && Result.Data.Count > 0) diff --git a/货架标准上位机/Views/MatInfoView.xaml b/货架标准上位机/Views/MatInfoView.xaml index 55b06b0..728a4b7 100644 --- a/货架标准上位机/Views/MatInfoView.xaml +++ b/货架标准上位机/Views/MatInfoView.xaml @@ -56,7 +56,7 @@ Text="物料条码:" FontSize="18" > + FontSize="18" MinWidth="90" Text="{Binding MatSN}"> + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <货架标准上位机:WorkItemBackgroundConverter x:Key="converter"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/货架标准上位机/Views/OutInventoryView.xaml.cs b/货架标准上位机/Views/OutInventoryView.xaml.cs new file mode 100644 index 0000000..c27c703 --- /dev/null +++ b/货架标准上位机/Views/OutInventoryView.xaml.cs @@ -0,0 +1,108 @@ +using Ping9719.WpfEx; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using System.Text.RegularExpressions; +using 货架标准上位机.ViewModel; + +namespace 货架标准上位机 +{ + public partial class OutVentoryView : UserControlBase + { + public OutVentoryView() + { + InitializeComponent(); + this.DataContext = new OutInventoryViewModel(); + } + + private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) + { + try + { + var viewModel = this.DataContext as InInventoryViewModel; + DataGrid datagrid = sender as DataGrid; + var index = datagrid.SelectedIndex; + if (index >= 0) + { + //if (viewModel.DataGridItemSource != null && viewModel.DataGridItemSource.Count() > index) + //{ + // var data = viewModel.DataGridItemSource.ElementAt(index); + // //data.IsSelected = !data.IsSelected; + // viewModel.DataGridItemSource = viewModel.DataGridItemSource.ToList(); + //} + } + datagrid.UnselectAllCells(); + } + catch + { + + } + } + + private void allChecked_Checked(object sender, RoutedEventArgs e) + { + //var viewMode = this.DataContext as OutInventoryViewModel; + //if (viewMode != null && viewMode.DataGridItemSource != null && viewMode.DataGridItemSource.Count() > 0) + //{ + // foreach (var item in viewMode.DataGridItemSource) + // { + // //item.IsSelected = true; + // } + // viewMode.DataGridItemSource = viewMode.DataGridItemSource.ToList(); + //} + } + + private void allChecked_Unchecked(object sender, RoutedEventArgs e) + { + //var viewMode = this.DataContext as OutInventoryViewModel; + //if (viewMode != null && viewMode.DataGridItemSource != null && viewMode.DataGridItemSource.Count() > 0) + //{ + // foreach (var item in viewMode.DataGridItemSource) + // { + // //item.IsSelected = false; + // } + // viewMode.DataGridItemSource = viewMode.DataGridItemSource.ToList(); + //} + } + + private void CheckBox_Checked(object sender, RoutedEventArgs e) + { + //var viewMode = this.DataContext as OutInventoryViewModel; + //viewMode.RefreshCount(); + } + + private void txtMatQty1_PreviewTextInput(object sender, TextCompositionEventArgs e) + { + if (!Regex.IsMatch(e.Text, "^[0-9]")) + { + e.Handled = true; + } + } + + private void ListView_PreviewMouseWheel(object sender, MouseWheelEventArgs e) + { + if (!e.Handled) + { + // ListView拦截鼠标滚轮事件 + e.Handled = true; + + // 激发一个鼠标滚轮事件,冒泡给外层ListView接收到 + var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta); + eventArg.RoutedEvent = UIElement.MouseWheelEvent; + eventArg.Source = sender; + var parent = ((Control)sender).Parent as UIElement; + parent.RaiseEvent(eventArg); + } + } + } +}