diff --git a/.gitignore b/.gitignore index 956f670..a5f270e 100644 --- a/.gitignore +++ b/.gitignore @@ -279,3 +279,4 @@ __pycache__/ /nuget.exe /demo/WalkingTec.Mvvm.VueDemo/ClientApp/yarn.lock *.lock +.DS_Store \ No newline at end of file diff --git a/HHWMS.Web/Areas/Api/IWCSController.cs b/HHWMS.Web/Areas/Api/IWCSController.cs index af66d30..bac0a4e 100644 --- a/HHWMS.Web/Areas/Api/IWCSController.cs +++ b/HHWMS.Web/Areas/Api/IWCSController.cs @@ -56,6 +56,7 @@ namespace HHWMS.Web // 1.更新库存 _unitWork.BatchUpdate(x => x.ContainerCode.Equals(task.ContainerCode), x => new Inventory { + LocationCode = task.ToLocation, UpdateTime = DateTime.Now, UpdateBy = "WMS", TaskStatus = InventoryTaskStatus.无任务 @@ -80,29 +81,29 @@ namespace HHWMS.Web }); // 4.插入库存交易 // 1.将任务容器的库存查出来 - if (inventoryList.Count > 0) - { - // 2.根据库存生成库存交易出库信息 - var inventoryTransactions = inventoryList.Select(inventory => new InventoryTransaction - { - BillType = InventoryTranType.入库, - MaterialCode = inventory.MaterialCode, - MaterialName = inventory.MaterialName, - MaterialUnit = inventory.MaterialUnit, - Batch = inventory.Batch, - Lot = inventory.Lot, - LocationCode = inventory.LocationCode, - ContainerCode = inventory.ContainerCode, - Qty = inventory.Qty, - CreateTime = DateTime.Now, - CreateBy = "WMS", - UpdateTime = DateTime.Now, - UpdateBy = "WMS" - }).ToList(); - - // 3.批量插入库存交易 - _unitWork.BatchAdd(inventoryTransactions); - } + // if (inventoryList.Count > 0) + // { + // // 2.根据库存生成库存交易出库信息 + // var inventoryTransactions = inventoryList.Select(inventory => new InventoryTransaction + // { + // BillType = InventoryTranType.入库, + // MaterialCode = inventory.MaterialCode, + // MaterialName = inventory.MaterialName, + // MaterialUnit = inventory.MaterialUnit, + // Batch = inventory.Batch, + // Lot = inventory.Lot, + // LocationCode = inventory.LocationCode, + // ContainerCode = inventory.ContainerCode, + // Qty = inventory.Qty, + // CreateTime = DateTime.Now, + // CreateBy = "WMS", + // UpdateTime = DateTime.Now, + // UpdateBy = "WMS" + // }).ToList(); + // + // // 3.批量插入库存交易 + // _unitWork.BatchAdd(inventoryTransactions); + // } break; case TaskTypeEnum.立库出库: @@ -121,6 +122,8 @@ namespace HHWMS.Web Status = LocationStatus.空仓位, ContainerCode = "" }); + + /* // 1.将任务容器的库存查出来 var inventoryList2 = _unitWork.Find(x => x.ContainerCode.Equals(task.ContainerCode)) .ToList(); @@ -149,10 +152,13 @@ namespace HHWMS.Web _unitWork.BatchDelete(inventoryList2); } + */ + // 如果是出库页面创建的任务,则创建入库任务并联动AGV - if (task.Station == "1") + /* + if (task.Station == "1") { - new ReceiptInController(_unitWork, Wtm).TaskIn(task.ContainerCode, false, false); + new ReceiptInController(_unitWork, Wtm).TaskIn(task.ContainerCode); // 下发AGV到出库口的任务 @@ -170,6 +176,7 @@ namespace HHWMS.Web // } } + */ break; default: diff --git a/HHWMS.Web/Areas/Configs/ViewModels/MaterialVMs/MaterialListVM.cs b/HHWMS.Web/Areas/Configs/ViewModels/MaterialVMs/MaterialListVM.cs index 7f8f03a..282aebc 100644 --- a/HHWMS.Web/Areas/Configs/ViewModels/MaterialVMs/MaterialListVM.cs +++ b/HHWMS.Web/Areas/Configs/ViewModels/MaterialVMs/MaterialListVM.cs @@ -25,6 +25,8 @@ namespace HHWMS.Web this.MakeStandardAction("Material", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "configs", dialogWidth: 800), this.MakeStandardAction("Material", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "configs", dialogWidth: 800), this.MakeStandardAction("Material", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "configs"), + this.MakeAction("Location","Print",Localizer["Sys.Print"],Localizer["Sys.Print"],GridActionParameterTypesEnum.MultiIds,"configs") + .SetShowDialog(false).SetOnClickScript("print"), }; } diff --git a/HHWMS.Web/Areas/Configs/ViewModels/MaterialVMs/MaterialSearcher.cs b/HHWMS.Web/Areas/Configs/ViewModels/MaterialVMs/MaterialSearcher.cs index 82e0049..0f07634 100644 --- a/HHWMS.Web/Areas/Configs/ViewModels/MaterialVMs/MaterialSearcher.cs +++ b/HHWMS.Web/Areas/Configs/ViewModels/MaterialVMs/MaterialSearcher.cs @@ -14,6 +14,9 @@ namespace HHWMS.Web { [Display(Name = "Inventory.MaterialCode")] public String MaterialCode { get; set; } + + [Display(Name = "Inventory.MaterialName")] + public String MaterialName { get; set; } protected override void InitVM() { diff --git a/HHWMS.Web/Areas/Configs/Views/Material/Index.cshtml b/HHWMS.Web/Areas/Configs/Views/Material/Index.cshtml index 5ec0875..d03e868 100644 --- a/HHWMS.Web/Areas/Configs/Views/Material/Index.cshtml +++ b/HHWMS.Web/Areas/Configs/Views/Material/Index.cshtml @@ -3,7 +3,25 @@ - + + + \ No newline at end of file diff --git a/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs b/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs index bba8875..b481fa6 100644 --- a/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs +++ b/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs @@ -244,14 +244,14 @@ namespace HHWMS.Web.Controllers location.Status = LocationStatus.任务锁; location.UpdateTime = DateTime.Now; location.UpdateBy = Wtm.LoginUserInfo?.ITCode ?? "WMS"; - _unitwork.Update(location); + // _unitwork.Update(location); // 查找container,并更新状态 var container = _unitwork.FindSingle(x => x.Code == location.ContainerCode); container.IsLock = ContainerLockEnum.任务锁; container.UpdateTime = DateTime.Now; container.UpdateBy = Wtm.LoginUserInfo?.ITCode ?? "WMS"; - _unitwork.Update(container); + // _unitwork.Update(container); //创建出库任务 var task = new TaskHeader @@ -266,7 +266,7 @@ namespace HHWMS.Web.Controllers CreateBy = Wtm.LoginUserInfo?.ITCode ?? "WMS", CreateTime = DateTime.Now }; - _unitwork.Add(task); + // _unitwork.Add(task); // 下发任务到wcs var postData = new @@ -281,15 +281,23 @@ namespace HHWMS.Web.Controllers if (res.Success) { task.Status = TaskStatusEnum.已下发; + task.UpdateTime = DateTime.Now; + task.UpdateBy = "WMS"; + _unitwork.Add(task); + + inv.TaskStatus = InventoryTaskStatus.任务中; + _unitwork.Update(inv); + + _unitwork.Update(container); + _unitwork.Update(location); } else { task.ErrorMsg = res.Msg; + return FFResult().RefreshGrid().Alert("出库任务创建失败!"); } - task.UpdateTime = DateTime.Now; - task.UpdateBy = "WMS"; - _unitwork.Update(task); + } return FFResult().RefreshGrid().Message("任务创建成功!"); diff --git a/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryListVM.cs b/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryListVM.cs index af4c22a..828e520 100644 --- a/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryListVM.cs +++ b/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryListVM.cs @@ -60,7 +60,7 @@ namespace HHWMS.Web this.MakeGridHeader(x => x.MaterialCode), // this.MakeGridHeader(x => x.MaterialType), this.MakeGridHeader(x => x.MaterialName), - // this.MakeGridHeader(x => x.MaterialSpec), + this.MakeGridHeader(x => x.MaterialSpec), // this.MakeGridHeader(x => x.MaterialUnit), // this.MakeGridHeader(x => x.Batch), // this.MakeGridHeader(x => x.Lot), diff --git a/HHWMS.Web/Areas/Inventory/Views/Inventory/Index.cshtml b/HHWMS.Web/Areas/Inventory/Views/Inventory/Index.cshtml index 91867e1..cd924f2 100644 --- a/HHWMS.Web/Areas/Inventory/Views/Inventory/Index.cshtml +++ b/HHWMS.Web/Areas/Inventory/Views/Inventory/Index.cshtml @@ -3,12 +3,9 @@ - - - - @* + @* diff --git a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs index 4cb8a29..ceb0506 100644 --- a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs +++ b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs @@ -30,124 +30,369 @@ namespace HHWMS.Web.Controllers #endregion Index - [HttpPost] - public ActionResult TaskIn(string containerCode, bool inv, bool agv) + [HttpGet] + public ActionResult SearchMaterials(string keyword) { - if (Wtm == null) + if (string.IsNullOrEmpty(keyword)) { - Wtm = _context; - } - // 判断containerCode是否为空 - if (string.IsNullOrEmpty(containerCode)) - { - return JsonMore(null, 500, "容器编码为空!请检查后重新提交!"); - } - // 查询container表code为containercode的值 - var container = _unitWork.FindSingle(u => u.Code == containerCode); - if (container == null) - { - return JsonMore(null, 500, $"库内没有编码为 {containerCode} 的容器!"); - } - // 如果 container的库位不为空,或者islock为true,则返回错误信息 - if (!string.IsNullOrEmpty(container.LocationCode) || container.IsLock == ContainerLockEnum.任务锁) - { - return JsonMore(null, 500, $"容器 {containerCode} 已被锁定或已在库内!"); + return JsonMore(new { Data = new object[] { } }); } - container.IsLock = ContainerLockEnum.任务锁; - container.UpdateTime = DateTime.Now; - container.UpdateBy = Wtm?.LoginUserInfo?.ITCode??"WMS"; - // _unitWork.Update(container); + var materials = _unitWork.Find(x => + x.MaterialCode.Contains(keyword) || + x.MaterialName.Contains(keyword)) + .Take(10) + .Select(x => new { + MaterialCode = x.MaterialCode, + MaterialName = x.MaterialName, + MaterialSpec = x.MaterialSpec, + MaterialUnit = x.MaterialUnit + }) + .ToList(); - //查找仓位 - var location = _unitWork.Find(u => u.Status == LocationStatus.空仓位 - && u.Type == container.Type - && !u.IsStop) - .OrderByDescending(x => x.Layer) - .ThenByDescending(x => x.Line) - .FirstOrDefault(); - - // 判断location是否为空 - if (location == null) + return JsonMore( materials ); + } + + [HttpPost] + public ActionResult AddInventory(string containerCode, string materialCode, decimal qty) + { + try { - return JsonMore(null, 500, "库内没有空闲仓位!"); - } - location.Status = LocationStatus.任务锁; - location.UpdateTime = DateTime.Now; - location.UpdateBy = Wtm?.LoginUserInfo?.ITCode??"WMS"; - _unitWork.Update(location); + if (string.IsNullOrEmpty(containerCode)) + { + return JsonMore(null, 500, "容器编码为空!"); + } + if (string.IsNullOrEmpty(materialCode)) + { + return JsonMore(null, 500, "物料编码为空!"); + } + if (qty <= 0) + { + return JsonMore(null, 500, "数量必须大于0!"); + } - if (inv) //有货 - { - _unitWork.Add(new Inventory() + // 查询容器 + var container = _unitWork.FindSingle(u => u.Code == containerCode); + if (container == null) + { + return JsonMore(null, 500, $"库内没有编码为 {containerCode} 的容器!"); + } + + // 查询物料信息 + var material = _unitWork.FindSingle(x => x.MaterialCode == materialCode); + if (material == null) + { + return JsonMore(null, 500, $"未找到物料编码为 {materialCode} 的物料信息!"); + } + + // 创建库存记录 + var inventory = new Inventory() { ZoneCode = ZoneCodeEnum.立库, ContainerCode = containerCode, - LocationCode = location.Code, - MaterialCode = "123456", - MaterialName = "矿泉水", - Qty = 1, + MaterialCode = material.MaterialCode, + MaterialName = material.MaterialName, + MaterialType = material.MaterialType, + MaterialSpec = material.MaterialSpec, + MaterialUnit = material.MaterialUnit, + Qty = qty, TaskStatus = InventoryTaskStatus.任务中, CreateTime = DateTime.Now - }); - } - _unitWork.Update(container); - //创建容器编码为containercode的任务 - var task = new TaskHeader - { - ZoneCode = ZoneCodeEnum.立库, - TaskNo = _unitWork.GetSerialNumber("In"), - TaskType = TaskTypeEnum.立库入库, - ContainerCode = containerCode, - FromLocation = "", - ToLocation = location.Code, - Status = TaskStatusEnum.待下发, - CreateBy = Wtm?.LoginUserInfo?.ITCode??"WMS", - CreateTime = DateTime.Now - }; - _unitWork.Add(task); + }; + _unitWork.Add(inventory); - // 下发任务到wcs - var postData = new - { - TaskNo = task.TaskNo, - PalletNo = task.ContainerCode, - FromLocation = task.FromLocation, - ToLocation = task.ToLocation - }; - try - { - var res = Wtm.CallAPI>("WCS", "TaskAssign", HttpMethodEnum.POST, postData) - .Result.Data; + // 创建入库交易记录 + var transaction = new InventoryTransaction + { + BillType = InventoryTranType.入库, + MaterialCode = material.MaterialCode, + MaterialName = material.MaterialName, + MaterialUnit = material.MaterialUnit, + ContainerCode = containerCode, + Qty = qty, + CreateTime = DateTime.Now, + CreateBy = "WMS", + UpdateTime = DateTime.Now, + UpdateBy = "WMS" + }; + _unitWork.Add(transaction); - if (res.Success) - { - task.Status = TaskStatusEnum.已下发; - } - else - { - task.ErrorMsg = res.Msg; - } + return JsonMore(new { Id = inventory.ID }); } catch (Exception ex) { - task.ErrorMsg = ex.Message; + return JsonMore(null, 500, ex.Message); } - task.UpdateTime = DateTime.Now; - task.UpdateBy = "WMS"; - _unitWork.Update(task); + } - if (agv) + [HttpPost] + public ActionResult TaskIn(string containerCode) + { + try { - // 调用AGV接口 - var task_id = Wtm.ConfigInfo.AppSettings - .FirstOrDefault(x => x.Key == "OutIn").Value; - var res2 = Wtm.CallAPI("ACS", "task_mould_do", HttpMethodEnum.POST, new + if (string.IsNullOrEmpty(containerCode)) { - task_id = task_id + return JsonMore(null, 500, "容器编码为空!"); + } + + // 查询容器 + var container = _unitWork.FindSingle(u => u.Code == containerCode); + if (container == null) + { + return JsonMore(null, 500, $"库内没有编码为 {containerCode} 的容器!"); + } + + // 查询容器的库存 + var inventories = _unitWork.Find(x => x.ContainerCode == containerCode).ToList(); + + // 根据库存情况设置容器状态 + if (inventories.Any()) + { + container.Status = ContainerStatus.有; + } + else + { + container.Status = ContainerStatus.空; + } + + // 查找仓位 + var location = _unitWork.Find(u => u.Status == LocationStatus.空仓位 + && u.Type == container.Type + && !u.IsStop) + .OrderBy(x => x.Layer) + .ThenBy(x => x.Line) + .FirstOrDefault(); + + // 判断location是否为空 + if (location == null) + { + return JsonMore(null, 500, "库内没有空闲仓位!"); + } + + // 更新容器状态 + container.IsLock = ContainerLockEnum.任务锁; + container.UpdateTime = DateTime.Now; + container.UpdateBy = Wtm?.LoginUserInfo?.ITCode ?? "WMS"; + // _unitWork.Update(container); + + // 更新仓位状态 + location.Status = LocationStatus.任务锁; + location.UpdateTime = DateTime.Now; + location.UpdateBy = Wtm?.LoginUserInfo?.ITCode ?? "WMS"; + // _unitWork.Update(location); + + // 更新库存记录 + // foreach (var inventory in inventories) + // { + // inventory.LocationCode = location.Code; + // _unitWork.Update(inventory); + // } + + // 创建入库任务 + var task = new TaskHeader + { + ZoneCode = ZoneCodeEnum.立库, + TaskNo = _unitWork.GetSerialNumber("In"), + TaskType = TaskTypeEnum.立库入库, + ContainerCode = containerCode, + FromLocation = "", + ToLocation = location.Code, + Status = TaskStatusEnum.待下发, + CreateTime = DateTime.Now, + CreateBy = Wtm?.LoginUserInfo?.ITCode??"WMS", + }; + + // _unitWork.Add(task); + + // 下发任务到wcs + var postData = new + { + TaskNo = task.TaskNo, + PalletNo = task.ContainerCode, + FromLocation = task.FromLocation, + ToLocation = task.ToLocation + }; + try + { + var res = Wtm.CallAPI>("WCS", "TaskAssign", HttpMethodEnum.POST, postData) + .Result?.Data; + + if (res.Success) + { + task.Status = TaskStatusEnum.已下发; + task.UpdateTime = DateTime.Now; + task.UpdateBy = "WMS"; + _unitWork.Add(task); + + _unitWork.Update(container); + _unitWork.Update(location); + } + else + { + task.ErrorMsg = res.Msg; + return JsonMore(null, 500, res.Msg); + } + } + catch (Exception ex) + { + task.ErrorMsg = ex.Message; + return JsonMore(null, 500, "任务下发失败!"); + } + + return JsonMore(null); + } + catch (Exception ex) + { + return JsonMore(null, 500, ex.Message); + } + } + + [HttpPost] + public ActionResult DeleteInventory(int id) + { + try + { + // 查询库存记录 + var inventory = _unitWork.Find(x => x.ID == id).FirstOrDefault(); + + if (inventory == null) + { + return JsonMore(null, 500, "未找到对应的库存记录!"); + } + + // 创建出库交易记录 + var transaction = new InventoryTransaction + { + BillType = InventoryTranType.出库, + MaterialCode = inventory.MaterialCode, + MaterialName = inventory.MaterialName, + MaterialUnit = inventory.MaterialUnit, + ContainerCode = inventory.ContainerCode, + Qty = inventory.Qty, + CreateTime = DateTime.Now, + CreateBy = "WMS", + UpdateTime = DateTime.Now, + UpdateBy = "WMS" + }; + _unitWork.Add(transaction); + + // 删除库存记录 + _unitWork.Delete(inventory); + + return JsonMore(null); + } + catch (Exception ex) + { + return JsonMore(null, 500, ex.Message); + } + } + + [HttpPost] + public ActionResult UpdateInventory(int id, decimal qty) + { + try + { + if (qty <= 0) + { + return JsonMore(null, 500, "数量必须大于0!"); + } + + // 查询库存记录 + var inventory = _unitWork.Find(x => x.ID == id).FirstOrDefault(); + + if (inventory == null) + { + return JsonMore(null, 500, "未找到对应的库存记录!"); + } + + // 创建出库交易记录(原数量) + var outTransaction = new InventoryTransaction + { + BillType = InventoryTranType.出库, + MaterialCode = inventory.MaterialCode, + MaterialName = inventory.MaterialName, + MaterialUnit = inventory.MaterialUnit, + ContainerCode = inventory.ContainerCode, + Qty = inventory.Qty, + CreateTime = DateTime.Now, + CreateBy = "WMS", + UpdateTime = DateTime.Now, + UpdateBy = "WMS" + }; + _unitWork.Add(outTransaction); + + // 创建入库交易记录(新数量) + var inTransaction = new InventoryTransaction + { + BillType = InventoryTranType.入库, + MaterialCode = inventory.MaterialCode, + MaterialName = inventory.MaterialName, + MaterialUnit = inventory.MaterialUnit, + ContainerCode = inventory.ContainerCode, + Qty = qty, + CreateTime = DateTime.Now, + CreateBy = "WMS", + UpdateTime = DateTime.Now, + UpdateBy = "WMS" + }; + _unitWork.Add(inTransaction); + + // 更新库存数量 + inventory.Qty = qty; + inventory.UpdateTime = DateTime.Now; + inventory.UpdateBy = Wtm?.LoginUserInfo?.ITCode ?? "WMS"; + _unitWork.Update(inventory); + + return JsonMore(null); + } + catch (Exception ex) + { + return JsonMore(null, 500, ex.Message); + } + } + + [HttpGet] + public JsonResult ValidateContainer(string containerCode) + { + try + { + if (string.IsNullOrEmpty(containerCode)) + { + return Json(new { Code = 400, Msg = "容器编码不能为空" }); + } + + var container = _unitWork.FindSingle(u => u.Code == containerCode); + if (container == null) + { + return Json(new { Code = 400, Msg = "容器不存在" }); + } + + if (!string.IsNullOrWhiteSpace(container.LocationCode)) + { + return Json(new { Code = 400, Msg = $"{containerCode} 容器状态不正确!已存在任务或者已在库内" }); + } + + // 获取容器内的物料信息 + var inventories = _unitWork.Find(x => x.ContainerCode == containerCode) + .Select(x => new { + Id = x.ID, + ContainerCode = x.ContainerCode, + MaterialCode = x.MaterialCode, + MaterialName = x.MaterialName, + Qty = x.Qty + }) + .ToList(); + + return Json(new { + Code = 200, + Msg = "验证成功", + Data = inventories }); } - return JsonMore(null); + catch (Exception ex) + { + return Json(new { Code = 500, Msg = ex.Message }); + } } } } diff --git a/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml b/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml index c41216a..c514ae5 100644 --- a/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml +++ b/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml @@ -1,36 +1,69 @@
- - - - - - - + + + + + + + + + + + + + + + + + + + + 绑定 + 入库 + + + - -