diff --git a/HHWMS.Web/Areas/Api/IWCSController.cs b/HHWMS.Web/Areas/Api/IWCSController.cs index 042ed3c..d25672b 100644 --- a/HHWMS.Web/Areas/Api/IWCSController.cs +++ b/HHWMS.Web/Areas/Api/IWCSController.cs @@ -54,79 +54,127 @@ namespace HHWMS.Web /// /// [HttpPost] - public IActionResult ReturnStatus(WcsRequest request) + public IActionResult ReturnStatus(TaskResponse response) { - /*// 参数判断 - if (request.State == null || request.PalletNo == null) + var taskno = response.TaskId.Split("-")[0]; + //wcs 任务反馈 + var task = _unitwork.Find(x => x.TaskNo.Equals(taskno) && x.Status != TaskStatusEnum.完成).Include(x => x.TaskDetails).FirstOrDefault(); + + if (task != null) { - return ApiResultError(msg: $"传入参数不正确!"); - } - var task = _unitwork.FindSingle(x => x.ContainerCode.Equals(request.PalletNo)); - if (task == null) - { - return ApiResultError(msg: $"未找到容器号{request.PalletNo}的任务!"); - } - switch (task.TaskType) - { - case TaskTypeEnum.In: - //1.更新库位状态(目的仓位有货) - _unitwork.BatchUpdate(x => x.Code.Equals(task.ToLocation), x => new Location + if (task.Status != TaskStatusEnum.完成 && response.Result == (int)TaskStatusEnum.完成) + { + var newTask = new TaskHeader { - Status = LocationStatus.有货 - }); - //2.更新容器(旭东不需要) - //3.根据任务明细,创建库存和库存交易 - var details = _unitwork.Find(x => x.TaskHeaderId.Equals(task.ID)); - foreach (var detail in details) + TaskDetails = new List() + }; + var tasktolocatioin = _unitwork.FindSingle(x => x.Code.Equals(task.ToLocation)); + var taskfromlocatioin = _unitwork.FindSingle(x => x.Code.Equals(task.FromLocation)); + switch (task.TaskType) { - //创建库存 - var inventory = new Inventory - { - MaterialCode = detail.MaterialCode, - MaterialName = detail.MaterialName, - MaterialSpec = detail.MaterialSpec, - MaterialUnit = detail.MaterialUnit, - Batch = detail.Batch, - Lot = detail.Lot, - ContainerCode = task.ContainerCode, - LocationCode = task.ToLocation, - Qty = detail.Qty, - TaskStatus = InventoryTaskStatus.无任务 - }; - _unitwork.Add(inventory); - //创建库存交易 - var invTran = new InventoryTransaction - { - Type = InventoryTranType.入库, - MaterialCode = detail.MaterialCode, - MaterialName = detail.MaterialName, - MaterialSpec = detail.MaterialSpec, - MaterialUnit = detail.MaterialUnit, - Batch = detail.Batch, - Lot = detail.Lot, - ContainerCode = task.ContainerCode, - LocationCode = task.ToLocation, - Qty = detail.Qty, - }; - _unitwork.Add(invTran); + case TaskTypeEnum.盘料盒入库: + // 更新库位 + // 起始库位为空 + // 目标库位为有货 + // 更新库存 + task.Status = TaskStatusEnum.完成; + + break; + case TaskTypeEnum.盘料盒出库: + // 更新库位 + // 起始库位为空 + // 目标库位为有货 + // 更新库存 + task.Status = TaskStatusEnum.完成; + // 料盒出库是为了入,还是为了出 1是出,2是入 + /*if (task.Station == "1") + { + + } + else if (task.Station == "2") + { + + }*/ + // 测试 创建盘料出库任务 + var locationList = _unitwork.Find(x => x.Row == tasktolocatioin.Row && "T,G2".Contains(x.Type)).ToList(); + newTask.ZoneCode = "L"; + newTask.TaskNo = _unitwork.GetSerialNumber("pout", 4); + newTask.TaskType = TaskTypeEnum.盘料出库; + newTask.ContainerCode = "L02"; + newTask.FromLocation = locationList.First(x => x.Type.Equals("G2")).Code; + newTask.ToLocation = "L02"; + newTask.Status = TaskStatusEnum.待下发; + for (int i = 1; i <= 10; i++) + { + newTask.TaskDetails.Add(new TaskDetail + { + UniqueCode = $"{newTask.TaskNo}-{i}", + FromLocation = i.ToString(), + ToLocation = i.ToString(), + Status = TaskStatusEnum.新建 + }); + } + _unitwork.Add(newTask); + break; + case TaskTypeEnum.盘料入库: + var ll = response.TaskId.Split("-")[1]; + task.TaskDetails.First(x => x.FromLocation == ll).Status = TaskStatusEnum.完成; + // 查询料塔 是否还有已下发,未完成的盘料入库任务 有不操作,没有 创建料盒入库任务 + if (!task.TaskDetails.Any(x => x.Status < TaskStatusEnum.完成)) + { + task.Status = TaskStatusEnum.完成; + // 测试 创建料盒入库任务 + var fromL = _unitwork.FindSingle(x => x.Row.Equals(tasktolocatioin.Row) && x.Type == "G1"); + newTask.ZoneCode = "L"; + newTask.TaskNo = _unitwork.GetSerialNumber("in", 4); + newTask.TaskType = TaskTypeEnum.盘料盒入库; + newTask.ContainerCode = fromL.Code; + newTask.FromLocation = fromL.Code; + newTask.ToLocation = "L01-02-01-01"; + newTask.Status = TaskStatusEnum.待下发; + //newTask.Station = task.Station; + _unitwork.Add(newTask); + + } + + break; + case TaskTypeEnum.盘料出库: + var lll = response.TaskId.Split("-")[1]; + task.TaskDetails.First(x => x.FromLocation == lll).Status = TaskStatusEnum.完成; + // 查询工位 是否还有已下发,未完成的盘料出库任务 有不操作,没有 创建料盒入库任务 + if (!task.TaskDetails.Any(x => x.Status < TaskStatusEnum.完成)) + { + task.Status = TaskStatusEnum.完成; + // 测试 创建盘料入库任务 + var locationList1 = _unitwork.Find(x => x.Row == tasktolocatioin.Row && "T,G2".Contains(x.Type)).ToList(); + newTask.ZoneCode = "L"; + newTask.TaskNo = _unitwork.GetSerialNumber("pin", 4); + newTask.TaskType = TaskTypeEnum.盘料入库; + newTask.ContainerCode = locationList1.First(x => x.Type.Equals("T")).Code; + newTask.FromLocation = tasktolocatioin.Code; + newTask.ToLocation = taskfromlocatioin.Code; + newTask.Status = TaskStatusEnum.待下发; + for (int i = 1; i <= 10; i++) + { + newTask.TaskDetails.Add(new TaskDetail + { + UniqueCode = $"{newTask.TaskNo}-{i}", + FromLocation = i.ToString(), + ToLocation = i.ToString(), + Status = TaskStatusEnum.新建 + }); + } + _unitwork.Add(newTask); + } + break; + default: + break; } - //4.调用MES接口,告诉MES物料入库 - break; - case TaskTypeEnum.Out: - //1.更新库位状态(起始仓位为空) - //2.更新容器(旭东不需要) - //3.删除对应的库存信息,创建库存交易 - //4.调用MES接口,告诉MES物料出库 - break; - - case TaskTypeEnum.Move: - //1.更新库位状态(起始仓位为空,目的仓位有货) - //2.更新容器(旭东不需要) - //3.更新库存信息的库位 - break; + _unitwork.Update(task); + } } - */ + return ApiResult(); } @@ -191,9 +239,9 @@ namespace HHWMS.Web newTask.ZoneCode = "L"; newTask.TaskNo = _unitwork.GetSerialNumber("pout", 4); newTask.TaskType = TaskTypeEnum.盘料出库; - newTask.ContainerCode = "L01"; + newTask.ContainerCode = "L02"; newTask.FromLocation = locationList.First(x => x.Type.Equals("G2")).Code; - newTask.ToLocation = "L01"; + newTask.ToLocation = "L02"; newTask.Status = TaskStatusEnum.待下发; for (int i = 1; i <= 10; i++) { @@ -221,7 +269,7 @@ namespace HHWMS.Web newTask.TaskType = TaskTypeEnum.盘料盒入库; newTask.ContainerCode = fromL.Code; newTask.FromLocation = fromL.Code; - newTask.ToLocation = "L01-01-19-01"; + newTask.ToLocation = "L01-02-01-01"; newTask.Status = TaskStatusEnum.待下发; //newTask.Station = task.Station; _unitwork.Add(newTask); diff --git a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptHeaderController.cs b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptHeaderController.cs index 963e0bd..90ec4ec 100644 --- a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptHeaderController.cs +++ b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptHeaderController.cs @@ -6,6 +6,8 @@ using WalkingTec.Mvvm.Mvc; using WalkingTec.Mvvm.Core.Extensions; using HHWMS.Web; using HHWMS.Web.Models; +using Microsoft.EntityFrameworkCore; +using System.Linq; namespace HHWMS.Web.Controllers { @@ -161,7 +163,7 @@ namespace HHWMS.Web.Controllers { if (!ModelState.IsValid || !vm.DoBatchEdit()) { - return PartialView("BatchEdit",vm); + return PartialView("BatchEdit", vm); } else { @@ -185,7 +187,7 @@ namespace HHWMS.Web.Controllers { if (!ModelState.IsValid || !vm.DoBatchDelete()) { - return PartialView("BatchDelete",vm); + return PartialView("BatchDelete", vm); } else { @@ -195,7 +197,7 @@ namespace HHWMS.Web.Controllers #endregion #region Import - [ActionDescription("Sys.Import")] + [ActionDescription("Sys.Import")] public ActionResult Import() { var vm = Wtm.CreateVM(); @@ -226,5 +228,47 @@ namespace HHWMS.Web.Controllers } #endregion + #region 点数 + [ActionDescription("ReceiptHeader.Count")] + public ActionResult Count(string id) + { + var vm = Wtm.CreateVM(id); + return PartialView(vm); + } + + /// + /// 查所有新建的明细,已开始收货明细不允许点数 + /// + /// + /// + public ActionResult SelectReceiptDetailsByCode(string code) + { + var data = _unitwork.Find(x => x.Code == code) + .Include(x => x.ReceiptDetails).ToList(); + return JsonMore(data.FirstOrDefault().ReceiptDetails.Where(x => x.Status == ReceiptStatusEnum.新建)); + } + + /// + /// 修改明细的数量 + /// + /// + /// + /// + /// + public ActionResult CountCommit(string code, string uniqueCode, int qty) + { + var receiptDetail = _unitwork.FindSingle(x => x.UniqueCode.Equals(uniqueCode)); + if (receiptDetail != null) + { + receiptDetail.Qty = qty; + receiptDetail.UpdateTime = DateTime.Now; + receiptDetail.UpdateBy = Wtm.LoginUserInfo.ITCode; + _unitwork.Update(receiptDetail); + return JsonMore(null); + } + return JsonMore(null, 500, $"未找到唯一码{uniqueCode}的单据!"); + } + #endregion + } } diff --git a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInOperationController.cs b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInOperationController.cs new file mode 100644 index 0000000..3a0f51d --- /dev/null +++ b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInOperationController.cs @@ -0,0 +1,204 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using HHWMS.Web.Models; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using WalkingTec.Mvvm.Core; +using WalkingTec.Mvvm.Mvc; + +namespace HHWMS.Web.Controllers; + +[Area("receipt")] +[ActionDescription("盘料站台入库操作")] +public class ReceiptInOperationController : BaseController +{ + private readonly IUnitWork _unitWork; + + public ReceiptInOperationController(IUnitWork unitWork) + { + _unitWork = unitWork; + } + + #region Index + + [ActionDescription("Sys.Search")] + public ActionResult Index() + { + return PartialView("Index"); + } + #endregion + + /// + /// 获取已绑定物料的周转箱信息 + /// + /// + [HttpPost] + public ActionResult BindBox() + { + var boxInfo = _unitWork.Find(x => x.Status.Equals(TaskStatusEnum.新建) + && x.TaskType.Equals(TaskTypeEnum.盘料入库)).ToList(); + if(boxInfo.Count > 0) + { + return JsonMore(boxInfo.Select(x => x.ContainerCode).ToList()); + } + 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}不正确!"); + } + } + + /// + /// 扫描唯一码,并验证,返回入库单明细 + /// + /// + /// + [HttpPost] + public ActionResult ScanUniqueCode(string uniqueCode) + { + var receiptDetail = _unitWork.FindSingle(x => x.UniqueCode.Equals(uniqueCode)); + if (receiptDetail != null) + { + if (receiptDetail.Status == ReceiptStatusEnum.收完) + { + 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/ViewModels/ReceiptHeaderVMs/ReceiptHeaderListVM.cs b/HHWMS.Web/Areas/Receipt/ViewModels/ReceiptHeaderVMs/ReceiptHeaderListVM.cs index 5baed7d..2398afa 100644 --- a/HHWMS.Web/Areas/Receipt/ViewModels/ReceiptHeaderVMs/ReceiptHeaderListVM.cs +++ b/HHWMS.Web/Areas/Receipt/ViewModels/ReceiptHeaderVMs/ReceiptHeaderListVM.cs @@ -19,6 +19,8 @@ namespace HHWMS.Web return new List { this.MakeStandardAction("ReceiptHeader", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"receipt", dialogWidth: 800), + this.MakeAction("ReceiptHeader","Count",Localizer["ReceiptHeader.Count"],Localizer["ReceiptHeader.Count"],GridActionParameterTypesEnum.SingleId,"receipt") + .SetShowInRow().SetHideOnToolBar().SetButtonClass("layui-btn-Warm").SetSize(1200,500), this.MakeStandardAction("ReceiptHeader", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "receipt", dialogWidth: 800), this.MakeStandardAction("ReceiptHeader", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "receipt", dialogWidth: 800), this.MakeStandardAction("ReceiptHeader", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "receipt", dialogWidth: 800), @@ -26,6 +28,7 @@ namespace HHWMS.Web this.MakeStandardAction("ReceiptHeader", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "receipt", dialogWidth: 800), this.MakeStandardAction("ReceiptHeader", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "receipt", dialogWidth: 800), this.MakeStandardAction("ReceiptHeader", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "receipt"), + }; } @@ -47,7 +50,7 @@ namespace HHWMS.Web //this.MakeGridHeader(x => x.LastStatus), this.MakeGridHeader(x => x.AppointmentTime), this.MakeGridHeader(x => x.Remark), - this.MakeGridHeaderAction(width: 200) + this.MakeGridHeaderAction(width: 300) }; } diff --git a/HHWMS.Web/Areas/Receipt/Views/ReceiptHeader/Count.cshtml b/HHWMS.Web/Areas/Receipt/Views/ReceiptHeader/Count.cshtml new file mode 100644 index 0000000..c5bd60c --- /dev/null +++ b/HHWMS.Web/Areas/Receipt/Views/ReceiptHeader/Count.cshtml @@ -0,0 +1,149 @@ +@model HHWMS.Web.ReceiptHeaderVM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 确定 + + + + + + diff --git a/HHWMS.Web/Areas/Receipt/Views/ReceiptInOperation/Index.cshtml b/HHWMS.Web/Areas/Receipt/Views/ReceiptInOperation/Index.cshtml new file mode 100644 index 0000000..fc5a0da --- /dev/null +++ b/HHWMS.Web/Areas/Receipt/Views/ReceiptInOperation/Index.cshtml @@ -0,0 +1,314 @@ + + + + > + + + + + + + + + +
+ 启动入库 +
+
+
+ + diff --git a/HHWMS.Web/Resources/Program.zh.resx b/HHWMS.Web/Resources/Program.zh.resx index eab540c..d650e36 100644 --- a/HHWMS.Web/Resources/Program.zh.resx +++ b/HHWMS.Web/Resources/Program.zh.resx @@ -1362,4 +1362,7 @@ 参数 + + 点数 + \ No newline at end of file