From aacf4910511b3f5a1f1db1f255055859ad925fdc Mon Sep 17 00:00:00 2001 From: zgf Date: Mon, 4 Dec 2023 23:47:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=A3=E8=B4=A7=E5=AE=8C=E6=88=90=EF=BC=8C?= =?UTF-8?q?=E5=9B=9E=E4=BC=A0=E5=BA=93=E5=AD=98=E4=BF=A1=E6=81=AF=E5=88=B0?= =?UTF-8?q?mes=EF=BC=8C=E6=95=B0=E9=87=8F=E4=B8=BA0=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=9B=9E=E5=BA=93=E5=BA=93=E5=AD=98=E6=96=B0=E5=A2=9E=E4=BA=A4?= =?UTF-8?q?=E6=98=93=E8=A1=A8bug=20=E5=87=BA=E5=BA=93=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=92=8C=E5=8A=9F=E8=83=BD=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HHWMS.Web/Areas/Api/IWCSController.cs | 3 +- .../Controllers/InventoryController.cs | 2 +- .../Shipment/Controllers/ShipOutController.cs | 203 ++++++++++++------ .../Areas/Shipment/Views/ShipOut/Index.cshtml | 37 +++- 4 files changed, 167 insertions(+), 78 deletions(-) diff --git a/HHWMS.Web/Areas/Api/IWCSController.cs b/HHWMS.Web/Areas/Api/IWCSController.cs index 0513619..f9bd6a6 100644 --- a/HHWMS.Web/Areas/Api/IWCSController.cs +++ b/HHWMS.Web/Areas/Api/IWCSController.cs @@ -360,7 +360,8 @@ namespace HHWMS.Web if(task.TaskType == TaskTypeEnum.盘料盒入库 || task.TaskType == TaskTypeEnum.散料盒入库) { - var invList = _unitwork.Find(x => x.ContainerCode == task.ContainerCode) + var invList = _unitwork.Find(x => x.ContainerCode == task.ContainerCode + && x.TaskStatus == InventoryTaskStatus.任务中) .ToList(); var listInvtran = new List(); foreach (var inv in invList) diff --git a/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs b/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs index 576ac5c..95f02c5 100644 --- a/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs +++ b/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs @@ -229,7 +229,7 @@ namespace HHWMS.Web.Controllers public ActionResult ReturnToMes(string id) { var inv = _unitwork.FindById(int.Parse(id)); - if(inv.Status == "1") + if (inv.Status == "1") { return FFResult().Message($"物料{inv.UniqueCode}已回传MES").RefreshGrid(); } diff --git a/HHWMS.Web/Areas/Shipment/Controllers/ShipOutController.cs b/HHWMS.Web/Areas/Shipment/Controllers/ShipOutController.cs index 778f8e1..c451758 100644 --- a/HHWMS.Web/Areas/Shipment/Controllers/ShipOutController.cs +++ b/HHWMS.Web/Areas/Shipment/Controllers/ShipOutController.cs @@ -2,8 +2,11 @@ using System; using System.Collections.Generic; using System.Linq; using HHWMS.Web.Models; +using MESTOWMSService; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Newtonsoft.Json; +using ServiceReference1; using WalkingTec.Mvvm.Core; using WalkingTec.Mvvm.Mvc; @@ -34,16 +37,17 @@ public class ShipOutController : BaseController /// 扫描散料箱/盘料周转箱 返回待出库明细 /// /// + /// /// [HttpPost] - public ActionResult ScanBox(string code) + public ActionResult ScanBox(string code, string type) { Location box = new Location(); - if (code.Contains("C")) + if (type.Contains("slbox")) { box = _unitWork.FindSingle(x => x.Code.Equals(code) && x.Type == LocationTypeEnum.散料库站台); } - else if (code.Contains("L")) + else if (type.Contains("lt")) { box = _unitWork.FindSingle(x => x.Code.Equals(code) && x.Type == LocationTypeEnum.料塔); } @@ -87,79 +91,142 @@ public class ShipOutController : BaseController var shipment = _unitWork.Find(x => x.UniqueCode.Equals(uniqueCode)) .Include(x => x.ShipmentHeader) .FirstOrDefault(); - if (shipment == null) + using (var tran = Wtm.DC.Database.BeginTransaction()) { - return JsonMore(null, 500, "未找到该出库单!"); - } - shipment.Status = ShipStatusEnum.拣货完成; - shipment.UpdateTime = DateTime.Now; - shipment.UpdateBy = Wtm.LoginUserInfo.ITCode; - - - if (!shipment.ShipmentHeader.ShipmentDetails.Any(x => x.Status < ShipStatusEnum.拣货完成)) - { - shipment.ShipmentHeader.FirstStatus = ShipStatusEnum.拣货完成; - } - else - { - shipment.ShipmentHeader.FirstStatus = ShipStatusEnum.拣货中; - } - shipment.UpdateBy = Wtm.LoginUserInfo.ITCode; - shipment.UpdateTime = DateTime.Now; - _unitWork.Update(shipment); - - var inv = _unitWork.FindSingle(x => x.UniqueCode.Equals(uniqueCode) && x.LocationCode == station); - if (inv != null) - { - // 删除库存,扣账,记录库存交易 todo,根据站台查询是否还有未拣货的物料,如果没有就清空站台占用 - - var invTran = new InventoryTransaction + try { - BillType = "out", - ZoneCode = inv.ZoneCode, - Type = inv.UniqueCode, - MaterialCode = inv.MaterialCode, - MaterialName = inv.MaterialName, - MaterialSpec = inv.MaterialSpec, - MaterialUnit = inv.MaterialUnit, - MaterialType = inv.MaterialType, - Batch = inv.Batch, - Lot = inv.Lot, - CompanyCode = inv.CompanyCode, - LocationCode = inv.LocationCode, - SupplierCode = inv.SupplierCode, - Qty = inv.Qty, - CreateTime = DateTime.Now - }; - _unitWork.Add(invTran); - - _unitWork.Delete(inv); - var Sation = _unitWork.Find(x => x.Code == station).FirstOrDefault(); - if (Sation != null && Sation.Type == "T") - { - Sation.Height -= 1; - if (Sation.Height <= 0) + if (shipment == null) { - Sation.Height = 0; - Sation.ContainerCode = ""; + return JsonMore(null, 500, "未找到该出库单!"); } - _unitWork.Update(Sation); - } - List list = _unitWork.Find(x => x.LocationCode == station).ToList(); - if (list.Count() == 0) - { - //var Sation = _unitWork.Find(x => x.Code == station).FirstOrDefault(); - if (Sation != null && Sation.Type == "T") + shipment.Status = ShipStatusEnum.拣货完成; + shipment.UpdateTime = DateTime.Now; + shipment.UpdateBy = Wtm.LoginUserInfo.ITCode; + + + if (!shipment.ShipmentHeader.ShipmentDetails.Any(x => x.Status < ShipStatusEnum.拣货完成)) { - Sation.ContainerCode = ""; - Sation.Height = 0; - _unitWork.Update(Sation); + shipment.ShipmentHeader.FirstStatus = ShipStatusEnum.拣货完成; + } + else + { + shipment.ShipmentHeader.FirstStatus = ShipStatusEnum.拣货中; + } + shipment.UpdateBy = Wtm.LoginUserInfo.ITCode; + shipment.UpdateTime = DateTime.Now; + _unitWork.Update(shipment); + + var inv = _unitWork.FindSingle(x => x.UniqueCode.Equals(uniqueCode) && x.LocationCode == station); + if (inv != null) + { + //回传MES + var qr = _unitWork.FindSingle(x => x.UniqueCode.Equals(inv.UniqueCode))?.QRCode; + + var bizData = new InStore + { + INWMS = new INWMS + { + INITEMS = new INITEMS + { + INITEM = new List() + { + new INITEMItem() + { + ERPSN = qr, + WMSSN = inv?.UniqueCode, + QTY = "0", + TYPE = "2", + FLAG = "1" + } + } + } + } + }; + var str = JsonConvert.SerializeObject(bizData); + var request = new ServiceReference1.bizOperationV1Request + { + fromUnit = "8357S", + toUnit = "8357TEST", + fromSys = "WMSTEST", + toSys = "MES", + bizOperation = "InStore", + bizData = str + }; + var client = new ServiceReference1.portTypeClient(); + var result = client.bizOperationV1Async(request).Result; + //var result = new bizOperationV1Response(); + //result.Status = "Y"; + if (result.Status == "Y") + { + // 删除库存,扣账,记录库存交易 todo,根据站台查询是否还有未拣货的物料,如果没有就清空站台占用 + + var invTran = new InventoryTransaction + { + BillType = "out", + ZoneCode = inv.ZoneCode, + Type = inv.UniqueCode, + MaterialCode = inv.MaterialCode, + MaterialName = inv.MaterialName, + MaterialSpec = inv.MaterialSpec, + MaterialUnit = inv.MaterialUnit, + MaterialType = inv.MaterialType, + Batch = inv.Batch, + Lot = inv.Lot, + CompanyCode = inv.CompanyCode, + LocationCode = inv.LocationCode, + SupplierCode = inv.SupplierCode, + Qty = inv.Qty, + CreateTime = DateTime.Now + }; + _unitWork.Add(invTran); + _unitWork.Delete(inv); + + var Sation = _unitWork.Find(x => x.Code == station).FirstOrDefault(); + if (Sation != null && Sation.Type == "T") + { + Sation.Height -= 1; + if (Sation.Height <= 0) + { + Sation.Height = 0; + Sation.ContainerCode = ""; + } + _unitWork.Update(Sation); + } + List list = _unitWork.Find(x => x.LocationCode == station).ToList(); + if (list.Count() == 0) + { + //var Sation = _unitWork.Find(x => x.Code == station).FirstOrDefault(); + if (Sation != null && Sation.Type == "T") + { + Sation.ContainerCode = ""; + Sation.Height = 0; + _unitWork.Update(Sation); + } + } + + Wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: JsonConvert.SerializeObject(request), result: "success"); + tran.Commit(); + return JsonMore(null); + } + else + { + tran.Rollback(); + Wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: JsonConvert.SerializeObject(request), result: "error"); + return JsonMore(null, 500, $"回传MES失败,失败原因{result.Message}"); + } + } + else + { + tran.Rollback(); + return JsonMore(null, 500, $"站台{station}上的{uniqueCode}不存在!"); } } - - return JsonMore(inv); + catch (Exception ex) + { + tran.Rollback(); + return JsonMore(null, 500, $"拣货失败,失败原因{ex.Message}"); + } } - return JsonMore(null, 500, $"站台{station}上的{uniqueCode}不存在!"); } /// diff --git a/HHWMS.Web/Areas/Shipment/Views/ShipOut/Index.cshtml b/HHWMS.Web/Areas/Shipment/Views/ShipOut/Index.cshtml index 2db2fa8..940b4c2 100644 --- a/HHWMS.Web/Areas/Shipment/Views/ShipOut/Index.cshtml +++ b/HHWMS.Web/Areas/Shipment/Views/ShipOut/Index.cshtml @@ -4,7 +4,7 @@ -