From dd25815c03a5eb3fe640d5e3d6d29336cae0c09e Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Mon, 24 Feb 2025 15:36:58 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E7=89=A9=E6=96=99=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2.增加数据修改记录表和对应的操作数据的时候增加记录 --- WCS.BLL/DbModels/STZL/MatDetailHistoryInfo.cs | 59 +++--- WCS.BLL/Manager/DbInit.cs | 4 +- .../Service/BatchBindMatDetailService.cs | 184 ++++++++++++++---- .../Service/MatDetailCurrentInfoService.cs | 63 +++++- .../MatDetailHistoryInfoModel.cs | 87 +++++++++ .../BatchBindMatDetailController.cs | 70 ++++--- 货架标准上位机/Models/JsConfig.cs | 5 - .../ViewModels/BatchBindMatDetailViewModel.cs | 10 +- .../Views/BatchBindMatDetailView.xaml | 14 +- .../Views/BatchBindMatDetailView.xaml.cs | 3 +- .../Views/MatDetailCurrentInfoUpdateView.xaml.cs | 10 +- .../Views/Windows/UserLoginView.xaml.cs | 3 + 12 files changed, 395 insertions(+), 117 deletions(-) create mode 100644 WCS.Model/ApiModel/MatDetailHistoryInfo/MatDetailHistoryInfoModel.cs diff --git a/WCS.BLL/DbModels/STZL/MatDetailHistoryInfo.cs b/WCS.BLL/DbModels/STZL/MatDetailHistoryInfo.cs index 4850247..2f50bd5 100644 --- a/WCS.BLL/DbModels/STZL/MatDetailHistoryInfo.cs +++ b/WCS.BLL/DbModels/STZL/MatDetailHistoryInfo.cs @@ -5,11 +5,12 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using WCS.DAL.DbModels; +using WCS.Model.ApiModel.MatDetailHistoryInfo; namespace WCS.BLL.DbModels { /// - /// 当前库存盘点表 + /// 数据更新记录表 /// [SugarTable("wcs_mat_detail_history_info")] public class MatDetailHistoryInfo @@ -20,13 +21,13 @@ namespace WCS.BLL.DbModels [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)] public int Id { get; set; } - /// - /// 货架库存明细当前的ID - /// - [SugarColumn(ColumnName = "mat_detail_current_id", IsNullable = false, ColumnDescription = "库存明细当前的ID")] - public int MatDetailCurrentId { get; set; } - #region 货架属性 + /// + /// 货架类型 + /// + [SugarColumn(ColumnName = "shelf_type", Length = 64, IsNullable = true, ColumnDescription = "货架类型")] + public string ShelfType { get; set; } + /// /// 货架ID /// @@ -38,19 +39,6 @@ namespace WCS.BLL.DbModels /// [SugarColumn(ColumnName = "shelf_code", Length = 64, IsNullable = false, ColumnDescription = "货架编码")] public string ShelfCode { get; set; } - - /// - /// 货架类型 - /// - [SugarColumn(ColumnName = "shelf_type", Length = 64, IsNullable = true, ColumnDescription = "货架类型")] - public string ShelfType { get; set; } - - /// - /// 货架区域 - /// - [SugarColumn(ColumnName = "shelf_area", Length = 64, IsNullable = true, ColumnDescription = "货架区域")] - public string ShelfArea { get; set; } - #endregion #region 物料属性 @@ -59,7 +47,8 @@ namespace WCS.BLL.DbModels /// [SugarColumn(ColumnName = "mat_code", Length = 100, IsNullable = true, ColumnDescription = "物料编号")] public string MatCode { get; set; } - /// + + // /// 物料名称 /// [SugarColumn(ColumnName = "mat_name", Length = 150, IsNullable = true, ColumnDescription = "物料名称")] @@ -69,7 +58,7 @@ namespace WCS.BLL.DbModels /// 物料规格 /// [SugarColumn(ColumnName = "mat_spec", Length = 150, IsNullable = true, ColumnDescription = "物料规格")] - public string MatSpec { get; set; } + public string? MatSpec { get; set; } /// /// 物料数量(更新前物料数量) @@ -96,12 +85,6 @@ namespace WCS.BLL.DbModels public string? MatCustomer { get; set; } #endregion - /// - /// 更新人 - /// - [SugarColumn(ColumnName = "modify_user", IsNullable = true, Length = 50, ColumnDescription = "更新人")] - public string? ModifyUser { get; set; } - /// /// 更新时间 /// @@ -109,7 +92,25 @@ namespace WCS.BLL.DbModels public DateTime? ModifyTime { get; set; } = DateTime.Now; /// - /// 是否已删除 + /// 更新人 + /// + [SugarColumn(ColumnName = "modify_user", IsNullable = true, Length = 50, ColumnDescription = "更新人")] + public string? ModifyUser { get; set; } + + /// + /// 记录类型 + /// + [SugarColumn(ColumnName = "record_type", IsNullable = false, ColumnDescription = "记录类型")] + public RecordTypeEnum RecordType { get; set; } = RecordTypeEnum.修改; + + /// + /// 功能 + /// + [SugarColumn(ColumnName = "function_type", IsNullable = false, ColumnDescription = "功能")] + public FunctionTypeEnum FunctionType { get; set; } = FunctionTypeEnum.PDA物料绑定; + + /// + /// 是否已删除 假删除 /// [SugarColumn(ColumnName = "is_delete", IsNullable = false, ColumnDescription = "是否已删除")] public bool IsDelete { get; set; } = false; diff --git a/WCS.BLL/Manager/DbInit.cs b/WCS.BLL/Manager/DbInit.cs index 0d0ebc0..54d4236 100644 --- a/WCS.BLL/Manager/DbInit.cs +++ b/WCS.BLL/Manager/DbInit.cs @@ -64,7 +64,7 @@ namespace WCS.BLL.Manager //如果不配置此参数 每次启动都会持续几十秒才能成功启动后端 //if (LocalFile.Config.IsResetDBOrTable)//开发阶段暂时屏蔽初始化限制 { - #region 建库建表 只在表有变动时运行 + #region 建库建表 DbHelp.db.DbMaintenance.CreateDatabase(); //新部署时 日志需要建表 不然没得接口记录 DbHelp.dbLog.DbMaintenance.CreateDatabase(); @@ -72,7 +72,7 @@ namespace WCS.BLL.Manager DbHelp.db.CodeFirst.InitTables(typeof(ShelfInfo), typeof(MatBaseInfo), typeof(ShelfTypeInfo) , typeof(LocationInfo), typeof(LocationAreaInfo), typeof(MatDetailCurrentInfo), typeof(OrderTypeInfo) - , typeof(MatDetailStocktakingInfo), typeof(AgvTask) + , typeof(MatDetailStocktakingInfo), typeof(AgvTask),typeof(MatDetailHistoryInfo) , typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail) , typeof(MatInfo), typeof(StoreInfo) , typeof(StockTakingOrder), typeof(StockTakingOrderMatDetail), typeof(InOutRecord) diff --git a/WCS.BLL/Services/Service/BatchBindMatDetailService.cs b/WCS.BLL/Services/Service/BatchBindMatDetailService.cs index 6560565..2349cd5 100644 --- a/WCS.BLL/Services/Service/BatchBindMatDetailService.cs +++ b/WCS.BLL/Services/Service/BatchBindMatDetailService.cs @@ -20,6 +20,7 @@ using WCS.Model.ApiModel.BatchBindMatDetail; using WCS.Model.ApiModel.InOutRecord; using WCS.Model.ApiModel.MatBaseInfo; using WCS.Model.ApiModel.MatDetailCurrentInfo; +using WCS.Model.ApiModel.MatDetailHistoryInfo; using WCS.Model.ApiModel.StoreInfo; using WCS.Model.ApiModel.User; @@ -40,9 +41,11 @@ namespace WCS.BLL.Services.Service .LeftJoin((mci, si) => mci.ShelfId == si.Id) .LeftJoin((mci, si, li) => (si.TransStatus == TransStatusEnum.静止 && si.CurrentLocationId == li.Id) || (si.TransStatus == TransStatusEnum.运输中 && si.DestinationLocationId == li.Id)) + .Where((mci, si, li) => !string.IsNullOrEmpty(mci.StationCode)) .WhereIF(request.OrderTypeId != null && request.OrderTypeId != 0, (mci, si, li) => mci.OrderTypeId == request.OrderTypeId) .WhereIF(!string.IsNullOrEmpty(request.ShelfCode), (mci, si, li) => si.ShelfCode.Contains(request.ShelfCode)) - .WhereIF(!string.IsNullOrEmpty(request.StationCode), (mci, si, li) => mci.StationCode.Contains(request.StationCode)) + + .WhereIF(!string.IsNullOrEmpty(request.StationCode) && request.StationCode.ToLower() != "admin", (mci, si, li) => mci.StationCode.Contains(request.StationCode)) .Select((mci, si, li) => new MatDetailCurrentInfoModel() { Id = mci.Id, @@ -120,14 +123,37 @@ namespace WCS.BLL.Services.Service Data = null }; } + DbHelp.db.BeginTran(); + //新增数据修改记录表 + var historyInfo = new MatDetailHistoryInfo() + { + ShlefId = matDetailCurrentInfo.ShelfId, + ShelfType = matDetailCurrentInfo.ShelfType, + ShelfCode = matDetailCurrentInfo.ShelfCode, + MatCode = matDetailCurrentInfo.MatCode, + MatName = matDetailCurrentInfo.MatName, + MatSpec = matDetailCurrentInfo.MatSpec, + MatCustomer = matDetailCurrentInfo?.MatCustomer, + MatSupplier = matDetailCurrentInfo?.MatSupplier, + + BeforeQty = matDetailCurrentInfo.MatQty, + AfterQty = request.LocationInfo.MatQty, + + ModifyTime = DateTime.Now, + ModifyUser = request.UserName, + RecordType = RecordTypeEnum.修改, + FunctionType = FunctionTypeEnum.客户端物料绑定, + }; + await DbHelp.db.Insertable(historyInfo).ExecuteCommandAsync(); + //更新货架存量数据 matDetailCurrentInfo.MatQty = request.LocationInfo.MatQty; matDetailCurrentInfo.ModifyUser = request.UserName; matDetailCurrentInfo.ModifyTime = DateTime.Now; - var rowNum = await DbHelp.db.Updateable(matDetailCurrentInfo).ExecuteCommandAsync(); if (rowNum == 0) { + DbHelp.db.RollbackTran(); return new ResponseCommon { Code = 201, @@ -137,6 +163,7 @@ namespace WCS.BLL.Services.Service } else { + DbHelp.db.CommitTran(); return new ResponseCommon { Code = 200, @@ -144,16 +171,14 @@ namespace WCS.BLL.Services.Service Data = null }; } - - - } catch (Exception ex) { + DbHelp.db.RollbackTran(); var response = new ResponseCommon { Code = 300, - Message = $"操作失败:{ex.Message}", + Message = $"更新货架存量信息失败:{ex.Message}", Data = null }; return response; @@ -162,14 +187,42 @@ namespace WCS.BLL.Services.Service public async Task> deleteMatDetailCurrentInfo(DeleteInfosRequest request) { - //先查询出具体的Id - var MatDetailCurrentInfos = await DbHelp.db.Queryable() + //先查询出具体的数据 + var matDetailCurrentInfos = await DbHelp.db.Queryable() .Where(t => request.needDeleteIds.Contains(t.Id)) .ToListAsync(); //执行删除 try { - var deleteRows = await DbHelp.db.Deleteable(MatDetailCurrentInfos).ExecuteCommandAsync(); + DbHelp.db.BeginTran(); + //新增数据删除记录 + foreach (var matDetailCurrentInfo in matDetailCurrentInfos) + { + var historyInfo = new MatDetailHistoryInfo() + { + ShlefId = matDetailCurrentInfo.ShelfId, + ShelfType = matDetailCurrentInfo.ShelfType, + ShelfCode = matDetailCurrentInfo.ShelfCode, + + MatCode = matDetailCurrentInfo.MatCode, + MatName = matDetailCurrentInfo.MatName, + MatSpec = matDetailCurrentInfo.MatSpec, + MatCustomer = matDetailCurrentInfo?.MatCustomer, + MatSupplier = matDetailCurrentInfo?.MatSupplier, + + BeforeQty = matDetailCurrentInfo.MatQty, + AfterQty = 0,//删除数据 为0 + + ModifyTime = DateTime.Now, + ModifyUser = request.UserName, + RecordType = RecordTypeEnum.删除, + FunctionType = FunctionTypeEnum.客户端物料绑定, + }; + await DbHelp.db.Insertable(historyInfo).ExecuteCommandAsync(); + } + var deleteRows = await DbHelp.db.Deleteable(matDetailCurrentInfos).ExecuteCommandAsync(); + + DbHelp.db.CommitTran(); return new ResponseCommon { Code = 200, @@ -179,6 +232,7 @@ namespace WCS.BLL.Services.Service } catch (Exception ex) { + DbHelp.db.RollbackTran(); var response = new ResponseCommon { Code = 300, @@ -199,33 +253,64 @@ namespace WCS.BLL.Services.Service public async Task>> importMatDetailCurrentInfo(List lists, string userName, string deviceType, string stationCode) { #region 校验 - //工位校验 工位是否有货架校验 - var station = await DbHelp.db.Queryable() - .Where(t => t.LocationCode == stationCode && t.IsEnable == true) - .FirstAsync(); - if (station == null) + ////工位校验 工位是否有货架校验 + //var station = await DbHelp.db.Queryable() + // .Where(t => t.LocationCode == stationCode && t.IsEnable == true) + // .FirstAsync(); + //if (station == null) + //{ + // return new ResponseCommon>() + // { + // Code = 201, + // Message = $"导入失败:工位[{stationCode}]不存在或已被禁用!", + // Data = null, + // }; + //} + + //var shelfInfo = await DbHelp.db.Queryable() + // .Where(t => (t.TransStatus == TransStatusEnum.静止 && t.CurrentLocationId == station.Id) || + // t.TransStatus == TransStatusEnum.运输中 && t.DestinationLocationId == station.Id) + // .Where(t => t.IsEnable) + // .FirstAsync(); + //if (shelfInfo == null) + //{ + // return new ResponseCommon>() + // { + // Code = 201, + // Message = $"导入失败:当前工位不存在货架,请呼叫货架后再进行操作!", + // Data = null, + // }; + //} + //货架编码校验 + var shelfCodes = lists.Select(t => t.货架编码).Distinct().ToList(); + + var shelfInfosInDb = await DbHelp.db.Queryable() + .Where(t => shelfCodes.Contains(t.ShelfCode)) + .Where(t => t.IsEnable) + .ToListAsync(); + if (shelfInfosInDb == null) { return new ResponseCommon>() { Code = 201, - Message = $"导入失败:工位[{stationCode}]不存在或已被禁用!", + Message = $"导入失败:货架编码无效!请重试!", Data = null, }; } - - var shelfInfo = await DbHelp.db.Queryable() - .Where(t => (t.TransStatus == TransStatusEnum.静止 && t.CurrentLocationId == station.Id) || - t.TransStatus == TransStatusEnum.运输中 && t.DestinationLocationId == station.Id) - .Where(t => t.IsEnable) - .FirstAsync(); - if (shelfInfo == null) + //判断如果导入表中的货架编码数量与数据库中有效的货架数量不一致证明中间有无效的货架编码 + if (shelfInfosInDb != null && shelfInfosInDb.Count < shelfCodes.Count) { - return new ResponseCommon>() + var shelfCodesInDb = shelfInfosInDb.Select(t => t.ShelfCode).ToList(); + shelfCodes.RemoveAll(t => shelfCodesInDb.Contains(t)); + if (shelfCodes.Count > 0) { - Code = 201, - Message = $"导入失败:当前工位不存在货架,请呼叫货架后再进行操作!", - Data = null, - }; + return new ResponseCommon>() + { + Code = 201, + Message = $"导入失败:以下货架编码无效!\r\n{string.Join(",", shelfCodes)}", + Data = null, + }; + } } //单据类型校验 物料类型数量较小 不会对内存造成负担 @@ -264,15 +349,16 @@ namespace WCS.BLL.Services.Service }; } - if (!string.IsNullOrEmpty(matDetailCurrentInfo.货架编码) && matDetailCurrentInfo.货架编码 == shelfInfo.ShelfCode) - { - return new ResponseCommon>() - { - Code = 201, - Message = $"导入失败:货架[{matDetailCurrentInfo.货架编码}]不是当前工位的货架!", - Data = null, - }; - } + //不校验货架 + //if (!string.IsNullOrEmpty(matDetailCurrentInfo.货架编码) && matDetailCurrentInfo.货架编码 == shelfInfo.ShelfCode) + //{ + // return new ResponseCommon>() + // { + // Code = 201, + // Message = $"导入失败:货架[{matDetailCurrentInfo.货架编码}]不是当前工位的货架!", + // Data = null, + // }; + //} } #region 物料编码校验 @@ -320,9 +406,10 @@ namespace WCS.BLL.Services.Service foreach (var info in lists) { var matBaseInfo = matBaseInfoInDb?.Where(t => t.MatCode == info.物料编码).First(); + var shelfInfo = shelfInfosInDb?.Where(t => t.ShelfCode == info.货架编码).First(); var orderType = orderTypesInDb?.Where(t => t.OrderTypeName == info.单据类型).FirstOrDefault(); //应该是不能走进的分支 - if (matBaseInfo == null) + if (matBaseInfo == null || shelfInfo == null) { continue; } @@ -350,6 +437,29 @@ namespace WCS.BLL.Services.Service }; await DbHelp.db.Insertable(matDetailCurrentInfo).ExecuteCommandAsync(); + + var historyInfo = new MatDetailHistoryInfo() + { + ShlefId = matDetailCurrentInfo.ShelfId, + ShelfType = matDetailCurrentInfo.ShelfType, + ShelfCode = matDetailCurrentInfo.ShelfCode, + + MatCode = matDetailCurrentInfo.MatCode, + MatName = matDetailCurrentInfo.MatName, + MatSpec = matDetailCurrentInfo.MatSpec, + MatCustomer = matDetailCurrentInfo?.MatCustomer, + MatSupplier = matDetailCurrentInfo?.MatSupplier, + + BeforeQty = 0, + AfterQty = matDetailCurrentInfo.MatQty, + + ModifyTime = DateTime.Now, + ModifyUser = userName, + RecordType = RecordTypeEnum.新增, + FunctionType = FunctionTypeEnum.客户端物料绑定, + }; + await DbHelp.db.Insertable(historyInfo).ExecuteCommandAsync(); + } await DbHelp.db.CommitTranAsync(); return new ResponseCommon>() diff --git a/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs b/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs index 5792c34..7afe0fc 100644 --- a/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs +++ b/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs @@ -19,6 +19,7 @@ using WCS.Model.ApiModel; using WCS.Model.ApiModel.InOutRecord; using WCS.Model.ApiModel.MatBaseInfo; using WCS.Model.ApiModel.MatDetailCurrentInfo; +using WCS.Model.ApiModel.MatDetailHistoryInfo; using WCS.Model.ApiModel.StoreInfo; using WCS.Model.ApiModel.User; @@ -114,14 +115,37 @@ namespace WCS.BLL.Services.Service Data = null }; } + DbHelp.db.BeginTran(); + //新增数据修改记录表 + var historyInfo = new MatDetailHistoryInfo() + { + ShlefId = matDetailCurrentInfo.ShelfId, + ShelfType = matDetailCurrentInfo.ShelfType, + ShelfCode = matDetailCurrentInfo.ShelfCode, + MatCode = matDetailCurrentInfo.MatCode, + MatName = matDetailCurrentInfo.MatName, + MatSpec = matDetailCurrentInfo.MatSpec, + MatCustomer = matDetailCurrentInfo?.MatCustomer, + MatSupplier = matDetailCurrentInfo?.MatSupplier, + + BeforeQty = matDetailCurrentInfo.MatQty, + AfterQty = request.LocationInfo.MatQty, + + ModifyTime = DateTime.Now, + ModifyUser = request.UserName, + RecordType = RecordTypeEnum.修改, + FunctionType = FunctionTypeEnum.客户端货架存量, + }; + await DbHelp.db.Insertable(historyInfo).ExecuteCommandAsync(); + //更新货架存量数据 matDetailCurrentInfo.MatQty = request.LocationInfo.MatQty; matDetailCurrentInfo.ModifyUser = request.UserName; matDetailCurrentInfo.ModifyTime = DateTime.Now; - var rowNum = await DbHelp.db.Updateable(matDetailCurrentInfo).ExecuteCommandAsync(); if (rowNum == 0) { + DbHelp.db.RollbackTran(); return new ResponseCommon { Code = 201, @@ -131,6 +155,7 @@ namespace WCS.BLL.Services.Service } else { + DbHelp.db.CommitTran(); return new ResponseCommon { Code = 200, @@ -141,10 +166,11 @@ namespace WCS.BLL.Services.Service } catch (Exception ex) { + DbHelp.db.RollbackTran(); var response = new ResponseCommon { Code = 300, - Message = $"操作失败:{ex.Message}", + Message = $"更新货架存量信息失败:{ex.Message}", Data = null }; return response; @@ -156,13 +182,41 @@ namespace WCS.BLL.Services.Service public async Task> deleteMatDetailCurrentInfo(DeleteInfosRequest request) { //先查询出具体的Id - var MatDetailCurrentInfos = await DbHelp.db.Queryable() + var matDetailCurrentInfos = await DbHelp.db.Queryable() .Where(t => request.needDeleteIds.Contains(t.Id)) .ToListAsync(); //执行删除 try { - var deleteRows = await DbHelp.db.Deleteable(MatDetailCurrentInfos).ExecuteCommandAsync(); + DbHelp.db.BeginTran(); + //新增数据删除记录 + foreach (var matDetailCurrentInfo in matDetailCurrentInfos) + { + var historyInfo = new MatDetailHistoryInfo() + { + ShlefId = matDetailCurrentInfo.ShelfId, + ShelfType = matDetailCurrentInfo.ShelfType, + ShelfCode = matDetailCurrentInfo.ShelfCode, + + MatCode = matDetailCurrentInfo.MatCode, + MatName = matDetailCurrentInfo.MatName, + MatSpec = matDetailCurrentInfo.MatSpec, + MatCustomer = matDetailCurrentInfo?.MatCustomer, + MatSupplier = matDetailCurrentInfo?.MatSupplier, + + BeforeQty = matDetailCurrentInfo.MatQty, + AfterQty = 0,//删除数据 为0 + + ModifyTime = DateTime.Now, + ModifyUser = request.UserName, + RecordType = RecordTypeEnum.删除, + FunctionType = FunctionTypeEnum.客户端货架存量, + }; + await DbHelp.db.Insertable(historyInfo).ExecuteCommandAsync(); + } + var deleteRows = await DbHelp.db.Deleteable(matDetailCurrentInfos).ExecuteCommandAsync(); + + DbHelp.db.CommitTran(); return new ResponseCommon { Code = 200, @@ -172,6 +226,7 @@ namespace WCS.BLL.Services.Service } catch (Exception ex) { + DbHelp.db.RollbackTran(); var response = new ResponseCommon { Code = 300, diff --git a/WCS.Model/ApiModel/MatDetailHistoryInfo/MatDetailHistoryInfoModel.cs b/WCS.Model/ApiModel/MatDetailHistoryInfo/MatDetailHistoryInfoModel.cs new file mode 100644 index 0000000..2cef1fa --- /dev/null +++ b/WCS.Model/ApiModel/MatDetailHistoryInfo/MatDetailHistoryInfoModel.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace WCS.Model.ApiModel.MatDetailHistoryInfo +{ + public class MatDetailHistoryInfoModel : INotifyPropertyChanged + { + public int Id { get; set; } + + #region 货架属性 + public string ShelfType { get; set; } + + public int ShlefId { get; set; } + + public string ShelfCode { get; set; } + #endregion + + #region 物料属性 + public string MatCode { get; set; } + + public string MatName { get; set; } + + public string MatSpec { get; set; } + + public int BeforeQty { get; set; } + + public int AfterQty { get; set; } + + public string? MatSupplier { get; set; } + + public string? MatCustomer { get; set; } + #endregion + + public DateTime? ModifyTime { get; set; } = DateTime.Now; + + public string? ModifyUser { get; set; } + + public RecordTypeEnum RecordType { get; set; } = RecordTypeEnum.修改; + + public FunctionTypeEnum FunctionType { get; set; } = FunctionTypeEnum.PDA物料绑定; + + public bool IsDelete { get; set; } = false; + + 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)); + } + } + + /// + /// 数据更新类型 + /// + public enum RecordTypeEnum + { + 新增 = 0, + 修改 = 1, + 删除 = 2, + 清空 = 3, + } + + //具体是哪个功能 + public enum FunctionTypeEnum + { + PDA物料绑定, + PDA绑定查询, + PDA货架送回, + 库存盘点, + 客户端货架存量, + 客户端物料绑定, + } +} diff --git a/WCS.WebApi/Controllers/BatchBindMatDetailController.cs b/WCS.WebApi/Controllers/BatchBindMatDetailController.cs index 2693baa..d879172 100644 --- a/WCS.WebApi/Controllers/BatchBindMatDetailController.cs +++ b/WCS.WebApi/Controllers/BatchBindMatDetailController.cs @@ -11,6 +11,7 @@ using WCS.Model.ApiModel.BatchBindMatDetail; using WCS.Model.ApiModel.Home; using WCS.Model.ApiModel.MatBaseInfo; using WCS.Model.ApiModel.PDAMatBind; +using WCS.Model.ApiModel.StoreInfo; using WCS.Model.ApiModel.User; using WCS.Model.WebSocketModel; @@ -65,39 +66,58 @@ namespace WCS.WebApi.Controllers } } - [Route("getMatDetailCurrentInfosByStationCode")] [HttpPost(Name = "getMatDetailCurrentInfosByStationCode")] public async Task GetMatDetailCurrentInfosByStationCode(GetMatDetailCurrentInfosByStationCodeRequest request) { - //判断参数 - if (string.IsNullOrEmpty(request.StationCode)) - { - return new ResponseCommon() - { - Code = 201, - Message = "工位编码为空,请联系相关人员进行配置!", - Data = null, - }; - } - //判断工位是否存在 - var isExsistLocation = await DbHelp.db.Queryable() - .Where(t => t.LocationCode == request.StationCode) - .AnyAsync(); - //不存在工位 - if (!isExsistLocation) - { - return new ResponseCommon() - { - Code = 201, - Message = $"工位[{request.StationCode}]不存在,暂时无法使用此功能!", - Data = null, - }; - } + ////判断参数 + //if (string.IsNullOrEmpty(request.StationCode)) + //{ + // return new ResponseCommon() + // { + // Code = 201, + // Message = "工位编码为空,请联系相关人员进行配置!", + // Data = null, + // }; + //} + ////判断工位是否存在 + //var isExsistLocation = await DbHelp.db.Queryable() + // .Where(t => t.LocationCode == request.StationCode) + // .AnyAsync(); + ////不存在工位 + //if (!isExsistLocation) + //{ + // return new ResponseCommon() + // { + // Code = 201, + // Message = $"工位[{request.StationCode}]不存在,暂时无法使用此功能!", + // Data = null, + // }; + //} return await _batchBindMatDetailService.GetMatDetailCurrentInfosByStationCode(request); } + [HttpPost("updateMatDetailCurrentInfoForBind")] + public async Task> updateMatDetailCurrentInfoForBind(AddLocaionInfoRequest request) + { + return await _batchBindMatDetailService.updateMatDetailCurrentInfo(request); + } + + [HttpPost("deleteMatDetailCurrentInfoForBind")] + public async Task> deleteMatDetailCurrentInfoForBind(DeleteInfosRequest request) + { + //校验 + if (request.needDeleteIds == null || request.needDeleteIds.Count == 0) + { + return new ResponseCommon() + { + Code = 201, + Message = "操作失败:参数校验失败(ID)." + }; + } + return await _batchBindMatDetailService.deleteMatDetailCurrentInfo(request); + } [HttpPost("importMatDetailCurrentInfos")] public async Task importMatDetailCurrentInfos([FromForm] IFormFile excelFile, [FromForm] string userName diff --git a/货架标准上位机/Models/JsConfig.cs b/货架标准上位机/Models/JsConfig.cs index 9c46420..a662309 100644 --- a/货架标准上位机/Models/JsConfig.cs +++ b/货架标准上位机/Models/JsConfig.cs @@ -43,11 +43,6 @@ namespace 智慧物流软件系统 public string ModuleCodePattern { get; set; } - /// - /// 工位编码 WCS前端当前的工位编码 - /// - public string LocationCode { get; set; } - #region 导入相关配置 //点击导入选择文件时 是否自动加载下载导入模板得路径 diff --git a/货架标准上位机/ViewModels/BatchBindMatDetailViewModel.cs b/货架标准上位机/ViewModels/BatchBindMatDetailViewModel.cs index e317ade..2989d6a 100644 --- a/货架标准上位机/ViewModels/BatchBindMatDetailViewModel.cs +++ b/货架标准上位机/ViewModels/BatchBindMatDetailViewModel.cs @@ -35,7 +35,7 @@ namespace 智慧物流软件系统.ViewModel public BatchBindMatDetailViewModel() { //绑定工位编码 - StationCode = LocalFile.Config.LocationCode; + StationCode = LocalStatic.CurrentUser; } #region Property @@ -181,7 +181,7 @@ namespace 智慧物流软件系统.ViewModel OrderTypeId = SelectedOrderTypeItem?.Id, OrderNumber = OrderNumber, ShelfCode = ShelfCode, - StationCode = LocalFile.Config.LocationCode, + StationCode = StationCode, UserName = LocalStatic.CurrentUser, DeviceType = LocalFile.Config.DeviceType, @@ -223,7 +223,7 @@ namespace 智慧物流软件系统.ViewModel } else { - var updateView = new MatDetailCurrentInfoUpdateView("修改货架存量", info); + var updateView = new MatDetailCurrentInfoUpdateView("修改绑定数据", info); updateView.ShowDialog(); if (updateView.DialogResult == true) { @@ -256,7 +256,7 @@ namespace 智慧物流软件系统.ViewModel DeviceType = LocalFile.Config.DeviceType, needDeleteIds = needDeleteIds, }; - var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "matDetailCurrenInfo/deleteMatDetailCurrentInfo", body, "POST"); + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "batchBindMatDetail/deleteMatDetailCurrentInfoForBind", body, "POST"); if (Result != null && Result.Code == 200) { BtnSearch(); @@ -344,7 +344,7 @@ namespace 智慧物流软件系统.ViewModel string path = ofd.FileName; var result = await ApiHelp.StationPostImportFileAsync>>(path, System.Net.Http.HttpMethod.Post, - LocalFile.Config.ApiIpHost + "batchBindMatDetail/importMatDetailCurrentInfos", LocalStatic.CurrentUser, LocalFile.Config.DeviceType,LocalFile.Config.LocationCode); + LocalFile.Config.ApiIpHost + "batchBindMatDetail/importMatDetailCurrentInfos", LocalStatic.CurrentUser, LocalFile.Config.DeviceType,StationCode); if (result.Code == 200) { Growl.Success("成功导入!"); diff --git a/货架标准上位机/Views/BatchBindMatDetailView.xaml b/货架标准上位机/Views/BatchBindMatDetailView.xaml index f8619d0..f94de67 100644 --- a/货架标准上位机/Views/BatchBindMatDetailView.xaml +++ b/货架标准上位机/Views/BatchBindMatDetailView.xaml @@ -7,7 +7,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:hc="https://handyorg.github.io/handycontrol" mc:Ignorable="d" - d:DesignHeight="737" d:DesignWidth="1192" LoadedVisibleFirst="LoadedVisible"> + d:DesignHeight="737" d:DesignWidth="1192" Loaded="LoadedVisible"> @@ -87,14 +87,14 @@ - + Command="{Binding BtnAddCommand}">--> + Background="OrangeRed">--> - + diff --git a/货架标准上位机/Views/BatchBindMatDetailView.xaml.cs b/货架标准上位机/Views/BatchBindMatDetailView.xaml.cs index 4f74d96..8df3e3b 100644 --- a/货架标准上位机/Views/BatchBindMatDetailView.xaml.cs +++ b/货架标准上位机/Views/BatchBindMatDetailView.xaml.cs @@ -18,7 +18,7 @@ namespace 智慧物流软件系统 { public partial class BatchBindMatDetailView : UserControlBase { - public BatchBindMatDetailViewModel viewModel { get; set; } = new BatchBindMatDetailViewModel(); + public static BatchBindMatDetailViewModel viewModel { get; set; } = new BatchBindMatDetailViewModel(); public BatchBindMatDetailView() { InitializeComponent(); @@ -28,6 +28,7 @@ namespace 智慧物流软件系统 private void LoadedVisible(object sender, EventArgs e) { + viewModel.StationCode = LocalStatic.CurrentUser; viewModel.BtnReset(); viewModel.BtnSearchReset(); } diff --git a/货架标准上位机/Views/MatDetailCurrentInfoUpdateView.xaml.cs b/货架标准上位机/Views/MatDetailCurrentInfoUpdateView.xaml.cs index f20c274..03f12fa 100644 --- a/货架标准上位机/Views/MatDetailCurrentInfoUpdateView.xaml.cs +++ b/货架标准上位机/Views/MatDetailCurrentInfoUpdateView.xaml.cs @@ -24,7 +24,7 @@ namespace 智慧物流软件系统 ViewModel.textBox = txtMatQty; ViewModel.SetValues(_matDetailCurrentInfoModel); //绑定标题 - Title.Text = "修改货架存量"; + Title.Text = _titleText; } @@ -57,6 +57,12 @@ namespace 智慧物流软件系统 } #endregion + var url = LocalFile.Config.ApiIpHost + "matDetailCurrenInfo/updateMatDetailCurrentInfo"; + if (this.Title.Text == "修改绑定数据") + { + url = LocalFile.Config.ApiIpHost + "batchBindMatDetail/updateMatDetailCurrentInfoForBind"; + } + #region 保存/修改值 var body = new AddLocaionInfoRequest() { @@ -65,7 +71,7 @@ namespace 智慧物流软件系统 LocationInfo = ViewModel.GetValues(), AddOrUpdate = AddOrUpdate.Update }; - var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "matDetailCurrenInfo/updateMatDetailCurrentInfo", body, "POST"); + var Result = ApiHelp.GetDataFromHttp>(url, body, "POST"); if (Result != null && Result.Code == 200) { diff --git a/货架标准上位机/Views/Windows/UserLoginView.xaml.cs b/货架标准上位机/Views/Windows/UserLoginView.xaml.cs index bff6983..ff00a1e 100644 --- a/货架标准上位机/Views/Windows/UserLoginView.xaml.cs +++ b/货架标准上位机/Views/Windows/UserLoginView.xaml.cs @@ -108,6 +108,9 @@ namespace 智慧物流软件系统 viewModel.Roles = viewModel.User?.GetRoles; viewModel.IsLogin = true; LocalStatic.CurrentUser = loginName; + BatchBindMatDetailView.viewModel.StationCode = loginName; + BatchBindMatDetailView.viewModel.BtnSearchReset(); + this.DialogResult = true; this.Close(); }