diff --git a/HHWMS.Web/Areas/Api/IWCSController.cs b/HHWMS.Web/Areas/Api/IWCSController.cs index 3bb3179..035b119 100644 --- a/HHWMS.Web/Areas/Api/IWCSController.cs +++ b/HHWMS.Web/Areas/Api/IWCSController.cs @@ -149,23 +149,30 @@ namespace HHWMS.Web _unitWork.BatchDelete(inventoryList2); } - - // 下发AGV到出库口的任务 - // 如果对接 执行下方任务,否则不执行 - var interfaceAgv = _unitWork.FindSingle(x => x.Prefix == "interfaceAGV")?.Value; - if (interfaceAgv == 1) + // 创建入库任务 + if (inventoryList2.Count == 0) { + new ReceiptInController(_unitWork, Wtm).TaskIn(task.ContainerCode, false, false); - var postAgv = new + // 下发AGV到出库口的任务 + // 如果对接 执行下方任务,否则不执行 + var interfaceAgv = _unitWork.FindSingle(x => x.Prefix == "interfaceAGV")?.Value; + if (interfaceAgv == 1) { - task_id = "6970907a6b82e7fb" - }; - var res = Wtm.CallAPI("ACS", "task_mould_do", HttpMethodEnum.POST, postAgv); - // if (res.Result.Data.ack == 0) - // { - // - // } + var agv_task_id = Wtm.ConfigInfo.AppSettings.FirstOrDefault(x => x.Key == "OutIn").Value; + var postAgv = new + { + task_id = agv_task_id, + }; + + var res = Wtm.CallAPI("ACS", "task_mould_do", + HttpMethodEnum.POST, postAgv); + // if (res.Result.Data.ack == 0) + // { + // + // } + } } break; diff --git a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs index 50fc598..8d8d577 100644 --- a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs +++ b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs @@ -12,10 +12,12 @@ namespace HHWMS.Web.Controllers public partial class ReceiptInController : BaseController { private readonly IUnitWork _unitWork; + private readonly WTMContext _context; - public ReceiptInController(IUnitWork unitWork) + public ReceiptInController(IUnitWork unitWork, WTMContext wtmContext) { _unitWork = unitWork; + _context = wtmContext; } #region Index @@ -29,8 +31,12 @@ namespace HHWMS.Web.Controllers #endregion Index [HttpPost] - public ActionResult TaskIn(string containerCode, bool inv) + public ActionResult TaskIn(string containerCode, bool inv, bool agv) { + if (Wtm == null) + { + Wtm = _context; + } // 判断containerCode是否为空 if (string.IsNullOrEmpty(containerCode)) { @@ -45,17 +51,17 @@ namespace HHWMS.Web.Controllers // 如果 container的库位不为空,或者islock为true,则返回错误信息 if (!string.IsNullOrEmpty(container.LocationCode) || container.IsLock == ContainerLockEnum.任务锁) { - return JsonMore(null, 500, $"容器 {containerCode} 已被占用!"); + return JsonMore(null, 500, $"容器 {containerCode} 已被锁定或已在库内!"); } - container.IsLock = ContainerLockEnum.任务锁; container.UpdateTime = DateTime.Now; - container.UpdateBy = Wtm.LoginUserInfo?.ITCode??"WMS"; + container.UpdateBy = Wtm?.LoginUserInfo?.ITCode??"WMS"; // _unitWork.Update(container); //查找仓位 - var location = _unitWork.Find(u => u.Status == LocationStatus.空仓位) + var location = _unitWork.Find(u => u.Status == LocationStatus.空仓位 + && u.Type == container.Type) .OrderBy(x => x.Layer) .ThenBy(x => x.Line) .FirstOrDefault(); @@ -67,7 +73,7 @@ namespace HHWMS.Web.Controllers } location.Status = LocationStatus.任务锁; location.UpdateTime = DateTime.Now; - location.UpdateBy = Wtm.LoginUserInfo?.ITCode??"WMS"; + location.UpdateBy = Wtm?.LoginUserInfo?.ITCode??"WMS"; _unitWork.Update(location); if (inv) //有货 @@ -95,7 +101,7 @@ namespace HHWMS.Web.Controllers FromLocation = "", ToLocation = location.Code, Status = TaskStatusEnum.待下发, - CreateBy = Wtm.LoginUserInfo?.ITCode??"WMS", + CreateBy = Wtm?.LoginUserInfo?.ITCode??"WMS", CreateTime = DateTime.Now }; _unitWork.Add(task); @@ -108,21 +114,37 @@ namespace HHWMS.Web.Controllers FromLocation = task.FromLocation, ToLocation = task.ToLocation }; - var res = Wtm.CallAPI>("WCS", "TaskAssign", HttpMethodEnum.POST, postData) - .Result.Data; + try + { + var res = Wtm.CallAPI>("WCS", "TaskAssign", HttpMethodEnum.POST, postData) + .Result.Data; - if (res.Success) - { - task.Status = TaskStatusEnum.已下发; + if (res.Success) + { + task.Status = TaskStatusEnum.已下发; + } + else + { + task.ErrorMsg = res.Msg; + } } - else + catch (Exception ex) { - task.ErrorMsg = res.Msg; } + task.UpdateTime = DateTime.Now; task.UpdateBy = "WMS"; _unitWork.Update(task); - + if (agv) + { + // 调用AGV接口 + var task_id = Wtm.ConfigInfo.AppSettings + .FirstOrDefault(x => x.Key == "OutIn").Value; + var res2 = Wtm.CallAPI("ACS", "task_mould_do", HttpMethodEnum.POST, new + { + task_id = task_id + }); + } return JsonMore(null); } } diff --git a/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml b/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml index 6d33177..c41216a 100644 --- a/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml +++ b/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml @@ -13,6 +13,15 @@ 空箱 + + + + + @@ -33,6 +42,7 @@ ContainerCode: '', loading1:false, inv:false, + agv:false, data: reactive([]) } }, @@ -50,6 +60,7 @@ let postData = new URLSearchParams(); postData.append('containerCode', _this.ContainerCode); postData.append('inv', _this.inv); + postData.append('agv', _this.agv); axios.post("/receipt/ReceiptIn/TaskIn", postData) .then(function (json) { diff --git a/HHWMS.Web/Areas/Shipment/Controllers/ShipOutController.cs b/HHWMS.Web/Areas/Shipment/Controllers/ShipOutController.cs index b1ad2c3..34553b5 100644 --- a/HHWMS.Web/Areas/Shipment/Controllers/ShipOutController.cs +++ b/HHWMS.Web/Areas/Shipment/Controllers/ShipOutController.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using HHWMS.Web.Models; using Microsoft.AspNetCore.Mvc; using WalkingTec.Mvvm.Core; @@ -94,11 +95,13 @@ public class ShipOutController : BaseController { try { + var ids = Wtm.ConfigInfo.AppSettings.ToList(); var task_id = type switch { - "In" => "ee66a5dc570cecd0", - "Out" => "6970907a6b82e7fb", - "Charge" => "a7a93155ff7f23a7", + "In" => ids.FirstOrDefault(x => x.Key == "In").Value, + "Out" => ids.FirstOrDefault(x => x.Key == "Out").Value, + "Charge" => ids.FirstOrDefault(x => x.Key == "Charge").Value, + "OutIn" => ids.FirstOrDefault(x => x.Key == "OutIn").Value, _ => throw new Exception("参数错误!") }; diff --git a/HHWMS.Web/Areas/Shipment/Views/ShipOut/Index.cshtml b/HHWMS.Web/Areas/Shipment/Views/ShipOut/Index.cshtml index ce5efa0..61bbf74 100644 --- a/HHWMS.Web/Areas/Shipment/Views/ShipOut/Index.cshtml +++ b/HHWMS.Web/Areas/Shipment/Views/ShipOut/Index.cshtml @@ -13,12 +13,12 @@ - - 到入库点 + 入库 - - 到出库点 - + @* *@ + @* 到出库点 *@ + @* *@ diff --git a/HHWMS.Web/Models/Enum/WMSEnum.cs b/HHWMS.Web/Models/Enum/WMSEnum.cs index 477021e..a498181 100644 --- a/HHWMS.Web/Models/Enum/WMSEnum.cs +++ b/HHWMS.Web/Models/Enum/WMSEnum.cs @@ -104,16 +104,10 @@ namespace HHWMS.Web.Models /// /// 容器类型 /// - public enum ContainerTypeEnum : int + public static class ContainerTypeEnum { - //// 11:23格料盒; 12:13格料盒; 13:16格料盒; 14:19格料盒 - 格料盒23 = 11, - - 格料盒13 = 12, - - 格料盒16 = 13, - - 格料盒19 = 14, + public const string 料箱 = "B"; + public const string 托盘 = "P"; } /// @@ -286,14 +280,19 @@ namespace HHWMS.Web.Models } /// - /// 区域 + /// 类型 /// public static class LocationTypeEnum { /// - /// 立库库位 = "L"; + /// 周转箱库位 = "B"; /// - public const string 立库库位 = "L"; + public const string 周转箱库位 = "B"; + + /// + /// 托盘库位 = "P"; + /// + public const string 托盘库位 = "P"; } diff --git a/HHWMS.Web/appsettings.json b/HHWMS.Web/appsettings.json index 9ff6413..f058e0c 100644 --- a/HHWMS.Web/appsettings.json +++ b/HHWMS.Web/appsettings.json @@ -119,6 +119,10 @@ }, "AppSettings": { "Key1": "abc", - "Key2": "123" + "Key2": "123", + "Out": "123", + "In": "123", + "Charge": "123", + "OutIn": "123", } }