From 8de4bc26cda91fa614d71720e87e7aa298aeec11 Mon Sep 17 00:00:00 2001 From: zgf Date: Thu, 24 Aug 2023 09:07:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E5=BA=93=E6=93=8D=E4=BD=9C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ReceiptInController.cs | 56 ++++++- .../Controllers/ReceiptSLInController.cs | 140 +++++++++++++++++- .../Receipt/Views/ReceiptIn/Index.cshtml | 2 +- .../Receipt/Views/ReceiptSLIn/Index.cshtml | 109 ++++++++++++-- HHWMS.Web/Models/Enum/WMSEnum.cs | 37 +++++ HHWMS.Web/Models/Inventory/Inventory.cs | 7 + HHWMS.Web/Resposity/IUnitWork.cs | 1 + HHWMS.Web/Resposity/UnitWork.cs | 21 +++ 8 files changed, 348 insertions(+), 25 deletions(-) diff --git a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs index fee2cdc..96bc7f0 100644 --- a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs +++ b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs @@ -17,10 +17,10 @@ namespace HHWMS.Web.Controllers [ActionDescription("盘料操作")] public partial class ReceiptInController : BaseController { - private readonly IUnitWork _unitwork; + private readonly IUnitWork _unitWork; public ReceiptInController(IUnitWork unitwork) { - _unitwork = unitwork; + _unitWork = unitwork; } #region Search [ActionDescription("Sys.Search")] @@ -32,7 +32,7 @@ namespace HHWMS.Web.Controllers [HttpPost] public ActionResult SelectReceiptCode() { - var data = _unitwork.Find(x => x.FirstStatus < ReceiptStatusEnum.回传) + var data = _unitWork.Find(x => x.FirstStatus <= ReceiptStatusEnum.收完) .Select(x => new { label = x.Code, value = x.Code }); return JsonMore(data); } @@ -40,10 +40,12 @@ namespace HHWMS.Web.Controllers [HttpPost] public ActionResult SelectReceipt(string Code) { - var data = _unitwork.Find(x => x.Code == Code).Include(x => x.ReceiptDetails).FirstOrDefault(); + var data = _unitWork.Find(x => x.Code == Code) + .Include(x => x.ReceiptDetails.Where(a => a.Status < ReceiptStatusEnum.收完)) + .FirstOrDefault(); if(data != null) { - var result = data.ReceiptDetails.Select(x => new { name = x.MaterialCode }); + var result = data.ReceiptDetails.Select(x => new { name = x.UniqueCode }); return JsonMore(result); } else @@ -57,10 +59,46 @@ namespace HHWMS.Web.Controllers /// /// [HttpPost] - public dynamic BindingData(List data) + public ActionResult BindingData(List data) { - // 查找明细,修改对应状态,并且 绑定物料周转箱 - return new ApiJsonResult { Success = true }; + var receiptHeaderList = _unitWork.Find(x => + data.Select(x => x.ReceiptCode).ToList().Contains(x.Code)) + .Include(x => x.ReceiptDetails).ToList(); + // 查找明细,修改对应状态,并且 绑定物料周转箱 + foreach (Binding item in data) + { + // 更新入库单明细状态 + var header = receiptHeaderList.First(x => x.Code.Equals(item.ReceiptCode)); + var receipt = header.ReceiptDetails.First(x => x.UniqueCode.Equals(item.UniqueCode)); + //var receipt = _unitWork.FindSingle(x => x.UniqueCode == item.UniqueCode); + if (receipt != null) + { + if (receipt.Status == ReceiptStatusEnum.收完) continue; + receipt.CompletedQty += item.BindQty; + } + if (receipt.CompletedQty == receipt.Qty) + { + receipt.Status = ReceiptStatusEnum.收完; + if (!header.ReceiptDetails.Any(x => x.Status < ReceiptStatusEnum.收完)) + { + header.FirstStatus = ReceiptStatusEnum.收完; + _unitWork.Update(header); + } + } + // 新建库存 + var inventory = new Inventory + { + ZoneCode = ZoneCodeEnum.盘料库, + UniqueCode = item.UniqueCode, + Flag = item.Index, + Qty = receipt.Qty, + Lot = item.Size.ToString(), + ContainerCode = item.BoxCode, + TaskStatus = InventoryTaskStatus.任务中 + }; + _unitWork.Add(inventory); + } + return JsonMore(null); } #endregion @@ -69,9 +107,11 @@ namespace HHWMS.Web.Controllers public class Binding { + public string ReceiptCode { get; set; } public string UniqueCode { get; set; } public string BoxCode { get; set; } public int Index { get; set; } public int Size { get; set; } + public int BindQty { get; set; } } } diff --git a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptSLInController.cs b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptSLInController.cs index 83da42a..167cc24 100644 --- a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptSLInController.cs +++ b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptSLInController.cs @@ -1,7 +1,9 @@ using System; +using System.Collections.Generic; using System.Linq; using HHWMS.Web.Models; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using WalkingTec.Mvvm.Core; using WalkingTec.Mvvm.Mvc; @@ -69,6 +71,35 @@ public class ReceiptSLInController : BaseController return JsonMore(null); } + /// + /// 扫描散料箱 + /// + /// + /// + [HttpPost] + public ActionResult ScanBox(string boxCode) + { + // 判断任务重复 + if (_unitWork.IsExit(x => x.ZoneCode.Equals(ZoneCodeEnum.散料库) && x.ContainerCode.Equals(boxCode))) + { + return JsonMore(null, 500, $"库内已存在{boxCode}的任务,请勿重复操作!"); + }; + // 判断箱号是否合理 + var box = _unitWork.FindSingle(x => x.ContainerCode.Equals(boxCode)); + if (box != null) + { + if (box.Type != LocationTypeEnum.散料库站台) + { + return JsonMore(null, 500, $"{boxCode}不在站台,无法入库!"); + } + return JsonMore(null); + } + else + { + return JsonMore(null, 500, $"{boxCode}不正确!"); + } + } + /// /// 扫描唯一码,并验证,返回入库单明细 /// @@ -82,10 +113,117 @@ public class ReceiptSLInController : BaseController { if (receiptDetail.Status == ReceiptStatusEnum.收完) { - return JsonMore(null, 500, $"{uniqueCode}已绑定,无需重新绑定!"); + return JsonMore(null, 500, $"{uniqueCode}已全部收完,无需重新绑定!"); } return JsonMore(receiptDetail); } return JsonMore(null, 500, $"{uniqueCode}不存在!"); } + + /// + /// 绑定 + /// + /// + /// + [HttpPost] + public ActionResult BindingData(List data) + { + var receiptHeaderList = _unitWork.Find(x => + data.Select(x => x.ReceiptCode).ToList().Contains(x.ID.ToString())) + .Include(x => x.ReceiptDetails).ToList(); + // 查找明细,修改对应状态,并且 绑定物料周转箱 + foreach (Binding item in data.OrderBy(x => x.ReceiptCode)) + { + // 更新入库单明细状态 + var header = receiptHeaderList.Find(x => x.ID.ToString().Equals(item.ReceiptCode)); + var receipt = header.ReceiptDetails.First(x => x.UniqueCode.Equals(item.UniqueCode)); + if (receipt != null) + { + if (receipt.Status == ReceiptStatusEnum.收完) continue; + receipt.CompletedQty += item.BindQty; + } + if(receipt.CompletedQty == receipt.Qty) + { + receipt.Status = ReceiptStatusEnum.收完; + if (!header.ReceiptDetails.Any(x => x.Status < ReceiptStatusEnum.收完)) + { + header.FirstStatus = ReceiptStatusEnum.收完; + } + } + // 新建库存 + var inventory = new Inventory + { + ZoneCode = ZoneCodeEnum.散料库, + UniqueCode = item.UniqueCode, + Qty = item.BindQty, + Lot = item.Size.ToString(), + ContainerCode = item.BoxCode, + TaskStatus = InventoryTaskStatus.任务中 + }; + _unitWork.Add(inventory); + } + _unitWork.BatchUpdate(receiptHeaderList.ToArray()); + return JsonMore(null); + } + /// + /// 散料箱回库 + /// + /// + /// + /// + [HttpPost] + public ActionResult BoxBack(string boxCode, bool isFull) + { + // 判断任务重复 + if(!_unitWork.IsExit(x => x.ZoneCode.Equals(ZoneCodeEnum.散料库) && x.ContainerCode.Equals(boxCode))){ + return JsonMore(null, 500, $"库内已存在{boxCode}的任务,请勿重复操作!"); + }; + // 判断箱号是否合理 + var box = _unitWork.FindSingle(x => x.ContainerCode.Equals(boxCode)); + if (box != null) + { + if(box.Type != LocationTypeEnum.散料库站台) + { + return JsonMore(null, 500, $"{boxCode}不在站台,无法入库!"); + } + else + { + // 查找目标库位 + var toLocation = _unitWork.FindSingle(x => x.Status.Equals(LocationStatus.空仓位) + && x.Type.Equals(LocationTypeEnum.散料库位) + && x.Row.Equals(box.Row)); + + if (toLocation != null) + { + // 创建任务 + var task = new TaskHeader + { + ZoneCode = ZoneCodeEnum.散料库, + TaskNo = _unitWork.GetSerialNumber("CIn"), + TaskType = TaskTypeEnum.散料盒入库, + ContainerCode = boxCode, + FromLocation = box.Code, + ToLocation = toLocation.Code, + Status = TaskStatusEnum.新建, + CreateBy = Wtm.LoginUserInfo.ITCode, + CreateTime = DateTime.Now + }; + _unitWork.Add(task); + + toLocation.Status = LocationStatus.任务锁; + toLocation.Length = isFull ? 1 : 0; // 是否满盘 + _unitWork.Update(toLocation); + } + else + { + return JsonMore(null, 500, $"库内无可用仓位,无法入库!"); + } + } + return JsonMore(data: null); + } + else + { + return JsonMore(null, 500, $"{boxCode}不正确!"); + } + } } diff --git a/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml b/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml index 4fafd8d..7184abe 100644 --- a/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml +++ b/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml @@ -133,7 +133,7 @@ data: { data: _this.bindingData }, url: "/receipt/ReceiptIn/BindingData", success: function (json) { - if (json.Success) { + if (json.Code == 200) { _this.$message({ message: '绑定成功!' }); diff --git a/HHWMS.Web/Areas/Receipt/Views/ReceiptSLIn/Index.cshtml b/HHWMS.Web/Areas/Receipt/Views/ReceiptSLIn/Index.cshtml index c47490c..4fdfca8 100644 --- a/HHWMS.Web/Areas/Receipt/Views/ReceiptSLIn/Index.cshtml +++ b/HHWMS.Web/Areas/Receipt/Views/ReceiptSLIn/Index.cshtml @@ -5,7 +5,8 @@ + placeholder="请扫描散料盒编码" + @@change="scanBox"> @@ -28,12 +29,19 @@ - - - - + + + + + + + + + + +