diff --git a/WCS.BLL/DbModels/STZL/MatDetailCurrentInfo.cs b/WCS.BLL/DbModels/STZL/MatDetailCurrentInfo.cs index 3995e10..541bc54 100644 --- a/WCS.BLL/DbModels/STZL/MatDetailCurrentInfo.cs +++ b/WCS.BLL/DbModels/STZL/MatDetailCurrentInfo.cs @@ -44,32 +44,31 @@ namespace WCS.BLL.DbModels /// [SugarColumn(ColumnName = "shelf_area", Length = 64, IsNullable = true, ColumnDescription = "货架区域")] public string ShelfArea { get; set; } - #endregion #region 物料属性 /// /// 物料编码 /// - [SugarColumn(ColumnName = "mat_code", Length = 100, IsNullable = true, ColumnDescription = "物料编号")] + [SugarColumn(ColumnName = "mat_code", Length = 128, IsNullable = true, ColumnDescription = "物料编号")] public string MatCode { get; set; } /// /// 物料名称 /// - [SugarColumn(ColumnName = "mat_name", Length = 150, IsNullable = true, ColumnDescription = "物料名称")] + [SugarColumn(ColumnName = "mat_name", Length = 128, IsNullable = true, ColumnDescription = "物料名称")] public string MatName { get; set; } /// /// 物料规格 /// - [SugarColumn(ColumnName = "mat_spec", Length = 150, IsNullable = true, ColumnDescription = "物料规格")] + [SugarColumn(ColumnName = "mat_spec", Length = 128, IsNullable = true, ColumnDescription = "物料规格")] public string MatSpec { get; set; } /// - /// 物料数量 - /// - [SugarColumn(ColumnName = "mat_qty", IsNullable = false, ColumnDescription = "物料数量")] - public int MatQty { get; set; } + /// 物料单位 + /// + [SugarColumn(ColumnName = "mat_unit", Length = 64, IsNullable = true, ColumnDescription = "物料单位")] + public string? MatUnit { get; set; } /// /// 物料供应商 @@ -82,6 +81,12 @@ namespace WCS.BLL.DbModels /// [SugarColumn(ColumnName = "mat_customer", Length = 128, IsNullable = true, ColumnDescription = "物料客户")] public string? MatCustomer { get; set; } + + /// + /// 物料数量 + /// + [SugarColumn(ColumnName = "mat_qty", IsNullable = false, ColumnDescription = "物料数量")] + public int MatQty { get; set; } #endregion /// diff --git a/WCS.BLL/DbModels/STZL/ShelfInfo.cs b/WCS.BLL/DbModels/STZL/ShelfInfo.cs index 73f14e9..d9ef57d 100644 --- a/WCS.BLL/DbModels/STZL/ShelfInfo.cs +++ b/WCS.BLL/DbModels/STZL/ShelfInfo.cs @@ -63,14 +63,32 @@ namespace WCS.DAL.DbModels /// /// 当前位置ID /// - [SugarColumn(ColumnName = "current_location_id", IsNullable = true, ColumnDescription = "当前位置ID")] + [SugarColumn(ColumnName = "current_location_id", IsNullable = false, ColumnDescription = "当前位置ID")] public int CurrentLocationId { get; set; } = 0; /// /// 当前位置编码 /// - [SugarColumn(ColumnName = "current_location_code", Length = 64, IsNullable = true, ColumnDescription = "当前位置编码")] + [SugarColumn(ColumnName = "current_location_code", Length = 64, IsNullable = false, ColumnDescription = "当前位置编码")] public string CurrentLocaiotnCode { get; set; } = string.Empty; + + /// + /// 目的地位置Id + /// + [SugarColumn(ColumnName = "destination_location_id", IsNullable = false, ColumnDescription = "当前位置ID")] + public int DestinationLocationId { get; set; } = 0; + + /// + /// 目的地位置物料编码 + /// + [SugarColumn(ColumnName = "destination_location_code", Length = 64, IsNullable = false, ColumnDescription = "当前位置编码")] + public string DestinationLocaiotnCode { get; set; } = string.Empty; + + /// + /// 货架运输状态 + /// + [SugarColumn(ColumnName = "trans_status", IsNullable = false, ColumnDescription = "货架运输状态")] + public TransStatusEnum TransStatus { get; set; } = TransStatusEnum.静止; #endregion /// @@ -116,9 +134,21 @@ namespace WCS.DAL.DbModels public bool IsSelected { get; set; } } + /// + /// 货架绑定物料的状态 + /// public enum ShelfStatusEnum { 空货架 = 0, 非空货架 = 1, } + + /// + /// 货架运输状态 + /// + public enum TransStatusEnum + { + 静止 = 0, + 运输中 = 1 + } } diff --git a/WCS.BLL/Manager/DbInit.cs b/WCS.BLL/Manager/DbInit.cs index 1f70a39..7b2f53c 100644 --- a/WCS.BLL/Manager/DbInit.cs +++ b/WCS.BLL/Manager/DbInit.cs @@ -62,7 +62,7 @@ namespace WCS.BLL.Manager } //手动修改后台配置后再进行CodeFirst 数据库的生成、表的生成 //如果不配置此参数 每次启动都会持续几十秒才能成功启动后端 - if (LocalFile.Config.IsResetDBOrTable) + //if (LocalFile.Config.IsResetDBOrTable)//开发阶段暂时屏蔽初始化限制 { #region 建库建表 只在表有变动时运行 DbHelp.db.DbMaintenance.CreateDatabase(); @@ -71,7 +71,7 @@ namespace WCS.BLL.Manager Logs.Write("【初始化数据库】创建数据库", LogsType.StartBoot); DbHelp.db.CodeFirst.InitTables(typeof(ShelfInfo), typeof(MatBaseInfo), typeof(ShelfTypeInfo) - ,typeof(LocationInfo), typeof(LocationAreaInfo) + ,typeof(LocationInfo), typeof(LocationAreaInfo),typeof(MatDetailCurrentInfo) , typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail) , typeof(MatInfo), typeof(StoreInfo) , typeof(StockTakingOrder), typeof(StockTakingOrderMatDetail), typeof(InOutRecord) diff --git a/WCS.BLL/Services/IService/IMatDetailCurrentInfoService.cs b/WCS.BLL/Services/IService/IMatDetailCurrentInfoService.cs new file mode 100644 index 0000000..da94c27 --- /dev/null +++ b/WCS.BLL/Services/IService/IMatDetailCurrentInfoService.cs @@ -0,0 +1,38 @@ +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 IMatDetailCurrentInfoService + { + /// + /// 查询货架存量列表 + /// + /// + /// + public Task> GetMatDetailCurrentInfos(GetMatDetailCurrentInfosRequest request); + + /// + /// 更新货架存量 + /// + /// + /// + public Task> updateMatDetailCurrentInfo(AddLocaionInfoRequest request); + + /// + /// 删除货架存量数据 + /// + /// + /// + public Task> deleteMatDetailCurrentInfo(DeleteInfosRequest request); + } +} diff --git a/WCS.BLL/Services/Service/LocationInfoService.cs b/WCS.BLL/Services/Service/LocationInfoService.cs index 895b242..46cab19 100644 --- a/WCS.BLL/Services/Service/LocationInfoService.cs +++ b/WCS.BLL/Services/Service/LocationInfoService.cs @@ -92,7 +92,7 @@ namespace WCS.BLL.Services.Service Data = null }; } - else if (existId != locationInfo.Id) + else if (existId != 0 && existId != locationInfo.Id) { return new ResponseCommon { diff --git a/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs b/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs new file mode 100644 index 0000000..84d6f50 --- /dev/null +++ b/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs @@ -0,0 +1,224 @@ +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 MatDetailCurrentInfoService : IMatDetailCurrentInfoService + { + + public async Task> GetMatDetailCurrentInfos(GetMatDetailCurrentInfosRequest request) + { + try + { + var recordsQueryable = DbHelp.db.Queryable() + .LeftJoin((mci, si) => mci.ShlefId == si.Id) + .LeftJoin((mci, si, li) => (si.TransStatus == TransStatusEnum.静止 && si.CurrentLocationId == li.Id) + || (si.TransStatus == TransStatusEnum.运输中 && si.DestinationLocationId == li.Id)) + .WhereIF(request.LocationAreaId != null && request.LocationAreaId != 0, (mci, si, li) => li.LocationAreaId == request.LocationAreaId) + .WhereIF(!string.IsNullOrEmpty(request.LocationCode), (mci, si, li) => li.LocationCode.Contains(request.LocationCode)) + .WhereIF(request.ShelfTypeId != null && request.ShelfTypeId != 0, (mci, si, li) => si.ShelfTypeId == request.ShelfTypeId) + .WhereIF(!string.IsNullOrEmpty(request.ShelfCode), (mci, si, li) => si.ShelfCode.Contains(request.ShelfCode)) + .WhereIF(!string.IsNullOrEmpty(request.MatCode), (mci, si, li) => mci.MatCode.Contains(request.MatCode)) + .WhereIF(!string.IsNullOrEmpty(request.MatName), (mci, si, li) => mci.MatCode.Contains(request.MatName)) + .Select((mci, si, li) => mci); + + //分页 + 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> updateMatDetailCurrentInfo(AddLocaionInfoRequest request) + { + return null; + //try + //{ + // var MatDetailCurrentInfo = await DbHelp.db.Queryable() //.Where(t => t.MatDetailCurrentCode == request.MatDetailCurrentInfo.MatDetailCurrentCode) + // .FirstAsync(); + // //修改位置信息 + // if (request.AddOrUpdate == AddOrUpdate.Update) + // { + // var existId = MatDetailCurrentInfo == null ? 0 : MatDetailCurrentInfo.Id; + + // MatDetailCurrentInfo = await DbHelp.db.Queryable() + // //.Where(t => t.Id == request.MatDetailCurrentInfo.Id) + // .FirstAsync(); + // if (MatDetailCurrentInfo == null) + // { + // return new ResponseCommon + // { + // Code = 201, + // Message = $"更新位置信息失败:该位置不存在!", + // Data = null + // }; + // } + // else if (existId != 0 && existId != MatDetailCurrentInfo.Id) + // { + // return new ResponseCommon + // { + // Code = 201, + // Message = $"更新位置信息失败:位置[{MatDetailCurrentInfo.MatDetailCurrentCode}]已存在!!", + // Data = null + // }; + // } + // else + // { + // request.MatDetailCurrentInfo.ModifyUser = request.UserName; + // request.MatDetailCurrentInfo.ModifyTime = DateTime.Now; + + // var rowNum = await DbHelp.db.Updateable(request.MatDetailCurrentInfo).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 (MatDetailCurrentInfo != null) + // { + // return new ResponseCommon + // { + // Code = 201, + // Message = $"新增位置信息失败:位置[{MatDetailCurrentInfo.MatDetailCurrentCode}]已存在!", + // Data = null + // }; + // } + // else + // { + // request.MatDetailCurrentInfo.ModifyUser = request.UserName; + // var rowNum = await DbHelp.db.Insertable(request.MatDetailCurrentInfo).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> deleteMatDetailCurrentInfo(DeleteInfosRequest request) + { + //先查询出具体的Id + var MatDetailCurrentInfos = await DbHelp.db.Queryable() + .Where(t => request.needDeleteIds.Contains(t.Id)) + .ToListAsync(); + //执行删除 + try + { + var deleteRows = await DbHelp.db.Deleteable(MatDetailCurrentInfos).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/StoreInfoService.cs b/WCS.BLL/Services/Service/StoreInfoService.cs index b4c168f..6c33c40 100644 --- a/WCS.BLL/Services/Service/StoreInfoService.cs +++ b/WCS.BLL/Services/Service/StoreInfoService.cs @@ -91,7 +91,7 @@ namespace WCS.BLL.Services.Service Data = null }; } - else if (existId != shelfnfo.Id) + else if (existId != 0 && existId != shelfnfo.Id) { return new ResponseCommon { diff --git a/WCS.Model/ApiModel/MatDetailCurrentInfo/GetLocationInfosRequest.cs b/WCS.Model/ApiModel/MatDetailCurrentInfo/GetLocationInfosRequest.cs new file mode 100644 index 0000000..073dca4 --- /dev/null +++ b/WCS.Model/ApiModel/MatDetailCurrentInfo/GetLocationInfosRequest.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.StoreInfo +{ + public class GetMatDetailCurrentInfosRequest : PageQueryRequestBase + { + public int? LocationAreaId { get; set; } + public string LocationCode { get; set; } + + public int? ShelfTypeId { get; set; } + public string ShelfCode { get; set; } + + public string MatCode { get; set; } + + public string MatName { get; set; } + } +} diff --git a/WCS.Model/ApiModel/PDAMatBind/BindMatDetailRequest.cs b/WCS.Model/ApiModel/PDAMatBind/BindMatDetailRequest.cs new file mode 100644 index 0000000..b69c24c --- /dev/null +++ b/WCS.Model/ApiModel/PDAMatBind/BindMatDetailRequest.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.PDAMatBind +{ + + public class BindMatDetailRequest : RequestBase + { + /// + /// 工位ID + /// + public int LocationId { get; set; } + /// + /// 位置编码 工位编码 + /// + public string LocationCode { get; set; } + + /// + /// 货架ID + /// + public int ShelfId { get; set; } + + /// + /// 货架编码 + /// + public string ShelfCode { get; set;} + + /// + /// 物料基础数据Id + /// + public int MatBaseInfoId { get; set; } + + /// + /// 物料编码 + /// + public string MatCode { get; set;} + + /// + /// 物料数量 + /// + public int Qty { get; set; } + } +} diff --git a/WCS.Model/ApiModel/PDAMatBind/GetShelfInfoByLocationCodeRequest.cs b/WCS.Model/ApiModel/PDAMatBind/GetShelfInfoByLocationCodeRequest.cs new file mode 100644 index 0000000..58b0095 --- /dev/null +++ b/WCS.Model/ApiModel/PDAMatBind/GetShelfInfoByLocationCodeRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.PDAMatBind +{ + public class GetShelfInfoByLocationCodeRequest:RequestBase + { + /// + /// 位置编码 工位编码 + /// + public string LocationCode { get; set; } + } +} diff --git a/WCS.Model/ApiModel/PDAMatBind/GetShelfInfoByLocationReturnData.cs b/WCS.Model/ApiModel/PDAMatBind/GetShelfInfoByLocationReturnData.cs new file mode 100644 index 0000000..9c2117b --- /dev/null +++ b/WCS.Model/ApiModel/PDAMatBind/GetShelfInfoByLocationReturnData.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.PDAMatBind +{ + public class GetShelfInfoByLocationReturnData + { + /// + /// 工位ID + /// + public int LocationId { get; set; } = 0; + + /// + /// 位置编码 工位编码 + /// + public string LocationCode { get; set; } = string.Empty; + + /// + /// 货架ID + /// + public int? ShelfId { get; set; } = 0; + + /// + /// 货架编码 + /// + public string ShelfCode { get; set;} = string.Empty; + } +} diff --git a/WCS.WebApi/Controllers/MatDetailCurrenInfoController.cs b/WCS.WebApi/Controllers/MatDetailCurrenInfoController.cs new file mode 100644 index 0000000..da9abf3 --- /dev/null +++ b/WCS.WebApi/Controllers/MatDetailCurrenInfoController.cs @@ -0,0 +1,50 @@ +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 MatDetailCurrenInfoController : ControllerBase + { + public IMatDetailCurrentInfoService _matDetailCurrentInfoService { get; set; } + public MatDetailCurrenInfoController(IMatDetailCurrentInfoService matDetailCurrentInfoService) + { + _matDetailCurrentInfoService = matDetailCurrentInfoService; + } + + #region 位置管理 + [Route("getMatDetailCurrentInfos")] + [HttpPost(Name = "getMatDetailCurrentInfos")] + public async Task GetMatDetailCurrentInfos(GetMatDetailCurrentInfosRequest request) + { + return await _matDetailCurrentInfoService.GetMatDetailCurrentInfos(request); + } + + [HttpPost("updateLocationInfo")] + public async Task> updateLocationInfo(AddLocaionInfoRequest request) + { + return await _matDetailCurrentInfoService.updateMatDetailCurrentInfo(request); + } + + [HttpPost("deleteLocationInfo")] + public async Task> deleteLocationInfo(DeleteInfosRequest request) + { + return await _matDetailCurrentInfoService.deleteMatDetailCurrentInfo(request); + } + #endregion + } +} diff --git a/WCS.WebApi/Controllers/PDAMatBindController.cs b/WCS.WebApi/Controllers/PDAMatBindController.cs new file mode 100644 index 0000000..c8210d1 --- /dev/null +++ b/WCS.WebApi/Controllers/PDAMatBindController.cs @@ -0,0 +1,228 @@ +using Microsoft.AspNetCore.Mvc; +using WCS.BLL.DbModels; +using WCS.BLL.Services.IService; +using WCS.DAL.Db; +using WCS.DAL.DbModels; +using WCS.Model; +using WCS.Model.ApiModel; +using WCS.Model.ApiModel.PDAMatBind; +using WCS.Model.ApiModel.User; +using WCS.Model.WebSocketModel; + +namespace WCS.WebApi.Controllers +{ + /// + /// PDA物料绑定相关接口 + /// + [ApiController] + [Route("[controller]")] + public class PDAMatBindController : ControllerBase + { + public IWarningService _warningService { get; set; } + + public PDAMatBindController(IWarningService warningService) + { + _warningService = warningService; + } + + [Route("getShelfInfoByLocationCode")] + [HttpPost(Name = "getShelfInfoByLocationCode")] + public async Task getShelfInfoByLocationCode(GetShelfInfoByLocationCodeRequest request) + { + //判断参数 + if (string.IsNullOrEmpty(request.LocationCode)) + { + return new ResponseCommon() + { + Code = 201, + Message = "工位编码为空!", + Data = null, + }; + } + + //获取是否存在当前工位 + var location = await DbHelp.db.Queryable() + .Where(t => t.LocationCode == request.LocationCode) + .Where(t => t.IsEnable == true) + .FirstAsync(); + if (location == null) + { + return new ResponseCommon() + { + Code = 201, + Message = $"工位[{request.LocationCode}]不存在或已被禁用!\r\n请联系系统管理人员维护工位信息!", + Data = null, + }; + } + + //获取当前工位的货架 + var shelf = await DbHelp.db.Queryable() + .Where(t => t.CurrentLocationId == location.Id && t.TransStatus == TransStatusEnum.静止 + || t.DestinationLocationId == location.Id && t.TransStatus == TransStatusEnum.运输中)//解决产线人员 呼叫后货架未到的时候绑定的问题 + .Where(t => t.IsEnable) + .FirstAsync(); + + return new ResponseBase() + { + Code = 200, + Message = $"success", + Data = new GetShelfInfoByLocationReturnData() + { + LocationId = location.Id, + LocationCode = request.LocationCode, + ShelfId = shelf?.Id, + ShelfCode = shelf?.ShelfCode, + }, + }; + + } + + [Route("bindMatDetail")] + [HttpPost(Name = "bindMatDetail")] + public async Task bindMatDetail(BindMatDetailRequest request) + { + try + { + #region 参数校验 + //判断参数 + if (request.LocationId == 0 || string.IsNullOrEmpty(request.LocationCode)) + { + return new ResponseCommon() + { + Code = 201, + Message = "工位或工位编码为空!", + Data = null, + }; + } + + if (request.ShelfId == 0 || string.IsNullOrEmpty(request.ShelfCode)) + { + + return new ResponseCommon() + { + Code = 201, + Message = "货架或货架编码为空!", + Data = null, + }; + } + + if (request.MatBaseInfoId == 0 || string.IsNullOrEmpty(request.MatCode)) + { + return new ResponseCommon() + { + Code = 201, + Message = "未选择物料!", + Data = null, + }; + } + + if (request.Qty <= 0) + { + return new ResponseCommon() + { + Code = 201, + Message = "数量应大于等于1!", + Data = null, + }; + } + #endregion + + #region 数据校验 + //判断参数 + if (string.IsNullOrEmpty(request.LocationCode)) + { + return new ResponseCommon() + { + Code = 201, + Message = "工位编码为空!", + Data = null, + }; + } + + //获取是否存在当前工位 + var location = await DbHelp.db.Queryable() + .Where(t => t.Id == request.LocationId) + .Where(t => t.IsEnable == true) + .FirstAsync(); + if (location == null) + { + return new ResponseCommon() + { + Code = 201, + Message = $"工位[{request.LocationCode}]不存在或已被禁用!\r\n请联系系统管理人员维护工位信息!", + Data = null, + }; + } + + //获取当前工位的货架 + var shelf = await DbHelp.db.Queryable() + .Where(t => t.Id == request.ShelfId) + .Where(t => t.CurrentLocationId == location.Id && t.TransStatus == TransStatusEnum.静止 + || t.DestinationLocationId == location.Id && t.TransStatus == TransStatusEnum.运输中)//解决产线人员 呼叫后货架未到的时候绑定的问题 + .Where(t => t.IsEnable == true) + .FirstAsync(); + if (shelf == null) + { + return new ResponseCommon() + { + Code = 205, + Message = $"货架[{request.ShelfCode}],已不在工位上!\r\n请进行【货架呼叫】!", + Data = null, + }; + } + + //获取物料基础信息 + var matBaseInfo = await DbHelp.db.Queryable() + .Where(t => t.Id == request.MatBaseInfoId) + .Where(t => t.IsEnable == true) + .FirstAsync(); + if (matBaseInfo == null) + { + return new ResponseCommon() + { + Code = 201, + Message = $"不存在物料[{request.MatCode}]或已被禁用!", + Data = null, + }; + } + #endregion + + //校验合格 进行保存 + var matDetailCurrentInfo = new MatDetailCurrentInfo() + { + ShlefId = shelf.Id, + ShelfCode = shelf.ShelfCode, + ShelfType = shelf.ShelfTypeName, + ShelfArea = shelf.ShelfArea, + + MatCode = matBaseInfo.MatCode, + MatName = matBaseInfo.MatName, + MatSupplier = matBaseInfo.MatSupplier, + MatCustomer = matBaseInfo.MatCustomer, + MatSpec = matBaseInfo.MatSpec, + MatUnit = matBaseInfo.MatUnit, + MatQty = request.Qty, + + ModifyUser = request.UserName, + }; + DbHelp.db.Insertable(matDetailCurrentInfo).ExecuteCommand(); + + return new ResponseCommon() + { + Code = 200, + Message = "success", + Data = null, + }; + } + catch (Exception ex) + { + return new ResponseCommon() + { + Code = 201, + Message = ex.Message, + Data = null, + }; + } + } + } +} diff --git a/WCS.WebApi/Program.cs b/WCS.WebApi/Program.cs index b88d43b..c656354 100644 --- a/WCS.WebApi/Program.cs +++ b/WCS.WebApi/Program.cs @@ -82,6 +82,7 @@ namespace WebApi builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddScoped(); //롢ɵõģʽ builder.Services.AddSingleton(); diff --git a/货架标准上位机/ViewModels/MatDetailCurrentInfoViewModel.cs b/货架标准上位机/ViewModels/MatDetailCurrentInfoViewModel.cs new file mode 100644 index 0000000..ff09a67 --- /dev/null +++ b/货架标准上位机/ViewModels/MatDetailCurrentInfoViewModel.cs @@ -0,0 +1,441 @@ +using HandyControl.Controls; +using MiniExcelLibs; +using Ping9719.WpfEx.Mvvm; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Input; +using 智慧物流软件系统.Views.Controls; +using 智慧物流软件系统.Api; +using WCS.Model; +using WCS.Model.ApiModel.Home; +using WCS.Model.ApiModel.StoreInfo; +using WCS.BLL.DbModels; +using WCS.Model.ApiModel.MatBaseInfo; +using WCS.Model.ApiModel.User; +using WCS.Model.ApiModel; +using Newtonsoft.Json.Bson; +using WCS.Model.ApiModel.LocationInfo; + +namespace 智慧物流软件系统.ViewModel +{ + public class MatDetailCurrentInfoViewModel : BindableBase + { + public MatDetailCurrentInfoViewModel() + { + + } + + #region Property + private List dataGridItemSource; + public List DataGridItemSource + { + get { return dataGridItemSource; } + set + { + SetProperty(ref dataGridItemSource, value); + } + } + + private LocationInfoModel selectedataGridItem; + public LocationInfoModel SelectedataGridItem + { + get { return selectedataGridItem; } + set + { + SetProperty(ref selectedataGridItem, value); + } + } + + + #region 位置 + private string locationCode; + public string LocationCode + { + get { return locationCode; } + set + { + SetProperty(ref locationCode, value); + } + } + + private List locationAreaItems; + public List LocationAreaItems + { + get { return locationAreaItems; } + set + { + SetProperty(ref locationAreaItems, value); + } + } + + private LocationAreaInfoModel? selectedLocationAreaItems; + public LocationAreaInfoModel? SelectedLocationAreaItems + { + get { return selectedLocationAreaItems; } + set + { + SetProperty(ref selectedLocationAreaItems, value); + } + } + + public void InitLocationAreaItems() + { + //调用接口更新! + Task.Run(() => + { + LocationAreaItems = new List(); + LocationAreaItems.Add(new LocationAreaInfoModel { Id = null, LocationAreaName = "全部" }); + + 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) + { + LocationAreaItems.AddRange(Result.Data.Lists); + } + + SelectedLocationAreaItems = LocationAreaItems.FirstOrDefault(); + }); + } + #endregion + + #region 货架 + /// + /// 货架编号 + /// + private string shelfCode; + public string ShelfCode + { + get { return shelfCode; } + set + { + SetProperty(ref shelfCode, value); + } + } + + private List shelfTypeItems; + public List ShelfTypeItems + { + get { return shelfTypeItems; } + set + { + SetProperty(ref shelfTypeItems, value); + } + } + + private ShelfTypeModel? selectedShelfTypeItem; + public ShelfTypeModel? SelectedShelfTypeItem + { + get { return selectedShelfTypeItem; } + set + { + SetProperty(ref selectedShelfTypeItem, value); + } + } + public void InitShelfTypeItems() + { + //调用接口更新! + Task.Run(() => + { + ShelfTypeItems = new List(); + ShelfTypeItems.Add(new ShelfTypeModel { Id = null, ShelfTypeName = "全部" }); + + var body = new RequestBase() + { + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + }; + + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "home/getShelfTypes", body, "POST"); + if (Result != null && Result.Data != null && Result.Data.Lists.Count() > 0) + { + ShelfTypeItems.AddRange(Result.Data.Lists); + } + + SelectedShelfTypeItem = ShelfTypeItems.FirstOrDefault(); + }); + } + #endregion + + #region + /// + /// 物料编码 + /// + 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 + + + #endregion + + #region Command + public ICommand BtnResetCommand { get => new DelegateCommand(BtnReset); } + public void BtnReset() + { + if (LocationAreaItems != null) + { + SelectedLocationAreaItems = LocationAreaItems.FirstOrDefault(); + } + LocationCode = string.Empty; + + if (ShelfTypeItems != null) + { + SelectedShelfTypeItem = ShelfTypeItems.FirstOrDefault(); + } + ShelfCode = string.Empty; + + MatCode = string.Empty; + MatName = 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 GetLocationInfosRequest() + { + LocationAreaId = SelectedLocationAreaItems == null ? null : SelectedLocationAreaItems.Id, + LocationCode = LocationCode, + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + PageNumber = CurrentPage, + PageSize = PageSize, + }; + 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; + MaxPage = Result.Data.MaxPage; + TotalCount = Result.Data.TotalCount; + } + } + catch (Exception ex) + { + Growl.Error("加载数据失败:" + ex.Message); + } + finally + { + dia.Close(); + } + #endregion + } + + /// + /// 物料新增操作 + /// + public ICommand BtnAddCommand { get => new DelegateCommand(BtnAdd); } + public async void BtnAdd() + { + var addView = new LocationInfoAddOrUpdateView("新增位置"); + addView.ShowDialog(); + if (addView.DialogResult == true) + { + //添加或修改成功后重新查询 + CurrentPage = 1; + } + } + + public ICommand BtnEditCommand { get => new DelegateCommand(BtnEdit); } + public async void BtnEdit() + { + //查询勾选的第一个数据 + var info = DataGridItemSource?.Where(t => t.IsSelected == true).FirstOrDefault(); + if (info == null) + { + Growl.Warning("请选择需要修改的数据!"); + } + else + { + var addView = new LocationInfoAddOrUpdateView("修改位置", info); + addView.ShowDialog(); + if (addView.DialogResult == true) + { + CurrentPage = 1; + } + } + } + + public ICommand BtnDeleteCommand { get => new DelegateCommand(BtnDelete); } + public void BtnDelete() + { + Growl.Ask($"是否删除所有勾选的数据?", isConfirmed => + { + if (isConfirmed) + { + //查询勾选的第一个数据 + var needDeleteIds = DataGridItemSource?.Where(t => t.IsSelected == true) + .Select(t => t.Id) + .ToList(); + + if (needDeleteIds == null) + { + Growl.Warning("请选择需要修改的数据!"); + } + else + { + var body = new DeleteInfosRequest() + { + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + needDeleteIds = needDeleteIds, + }; + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "locationInfo/deleteLocationInfo", body, "POST"); + if (Result != null && Result.Code == 200) + { + BtnSearch(); + Growl.Success("删除成功!" + Result?.Message); + } + else + { + Growl.Error($"{Result?.Message?.ToString()}"); + } + } + } + return true; + }); + + ////查询勾选的第一个数据 + //var info = DataGridItemSource?.Where(t => t.IsSelected == true).FirstOrDefault(); + //if (info == null) + //{ + // Growl.Warning("请选择需要删除的数据!"); + //} + //else + //{ + // var body = new AddShelfInfoRequest() + // { + // UserName = LocalStatic.CurrentUser, + // DeviceType = LocalFile.Config.DeviceType, + // ShelfInfo = info, + // AddOrUpdate = AddOrUpdate.Delete + // }; + // var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "storeInfo/addOrUpdateShelfInfo", body, "POST"); + // if (Result != null && Result.Code == 200) + // { + // Growl.Success("删除成功!"); + // CurrentPage = 1; + // } + // else + // { + // Growl.Error($"{Result?.Message?.ToString()}"); + // } + //} + } + #endregion + + #region PageOperation 分页操作 + private int currentPage; + public int CurrentPage + { + get { return currentPage; } + set + { + SetProperty(ref currentPage, value); + BtnSearch(false); + } + } + + private int maxPage; + public int MaxPage + { + get { return maxPage; } + set { SetProperty(ref maxPage, value); } + } + + //总数量 + private int totalCount; + public int TotalCount + { + get { return totalCount; } + set { SetProperty(ref totalCount, value); } + } + + private int pageSize = 10; + public int PageSize + { + get => pageSize; + set + { + SetProperty(ref pageSize, value); + BtnSearch(true); + } + } + + + public ICommand BtnFirstPageCommand { get => new DelegateCommand(BtnFirstPage); } + public void BtnFirstPage() + { + CurrentPage = 1; + } + + public ICommand BtnPrePageCommand { get => new DelegateCommand(BtnPrePage); } + public void BtnPrePage() + { + if (CurrentPage > 1) + { + CurrentPage--; + } + } + + public ICommand BtnNextPageCommand { get => new DelegateCommand(BtnNextPage); } + public void BtnNextPage() + { + if (CurrentPage < MaxPage) + { + CurrentPage++; + } + } + + public ICommand BtnLastPageCommand { get => new DelegateCommand(BtnLastPage); } + public void BtnLastPage() + { + if (CurrentPage != MaxPage) + { + CurrentPage = MaxPage; + } + } + #endregion + } +} diff --git a/货架标准上位机/Views/LocationInfoView.xaml b/货架标准上位机/Views/LocationInfoView.xaml index 6d5b78e..72d8349 100644 --- a/货架标准上位机/Views/LocationInfoView.xaml +++ b/货架标准上位机/Views/LocationInfoView.xaml @@ -30,23 +30,28 @@ - - - - - + + FontSize="18" + IsEditable="False" /> + + + + + - + diff --git a/货架标准上位机/Views/MainWindows/MainWindow1.xaml b/货架标准上位机/Views/MainWindows/MainWindow1.xaml index a639976..94aa1b6 100644 --- a/货架标准上位机/Views/MainWindows/MainWindow1.xaml +++ b/货架标准上位机/Views/MainWindows/MainWindow1.xaml @@ -140,7 +140,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10条/页 + 20条/页 + 50条/页 + 100条/页 + 500条/页 + + + + + + + + + + + + + + + + +