diff --git a/HHWMS.Web/Areas/Api/IWCSController.cs b/HHWMS.Web/Areas/Api/IWCSController.cs index b41cc00..7eaffa6 100644 --- a/HHWMS.Web/Areas/Api/IWCSController.cs +++ b/HHWMS.Web/Areas/Api/IWCSController.cs @@ -1,6 +1,9 @@ +using System.Collections.Generic; +using System.Linq; using AutoMapper; using HHWMS.Web.Models; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using WalkingTec.Mvvm.Core; namespace HHWMS.Web @@ -135,6 +138,134 @@ namespace HHWMS.Web [HttpPost] public IActionResult Test(TaskResponse response) { + 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) + { + if (task.Status != TaskStatusEnum.完成 && response.Result == (int)TaskStatusEnum.完成) + { + var newTask = new TaskHeader + { + 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) + { + case TaskTypeEnum.料盒入库: + // 更新库位 + // 起始库位为空 + // 目标库位为有货 + // 更新库存 + task.Status = TaskStatusEnum.完成; + // 测试 创建料盒出库任务 + newTask.ZoneCode = "L"; + newTask.TaskNo = _unitwork.GetSerialNumber("out", 4); + newTask.TaskType = TaskTypeEnum.料盒出库; + newTask.ContainerCode = task.FromLocation; + newTask.FromLocation = task.ToLocation; + newTask.ToLocation = task.FromLocation; + newTask.Status = TaskStatusEnum.待下发; + //newTask.Station = task.Station; + _unitwork.Add(newTask); + 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 = "L01"; + newTask.FromLocation = locationList.First(x => x.Type.Equals("G2")).Code; + newTask.ToLocation = "L01"; + 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-01-19-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; + } + + _unitwork.Update(task); + } + } + return ApiResult(); } } diff --git a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptHeaderController.cs b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptHeaderController.cs index dd0ba4d..dea58c5 100644 --- a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptHeaderController.cs +++ b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptHeaderController.cs @@ -5,6 +5,7 @@ using WalkingTec.Mvvm.Core; using WalkingTec.Mvvm.Mvc; using WalkingTec.Mvvm.Core.Extensions; using HHWMS.Web; +using HHWMS.Web.Models; namespace HHWMS.Web.Controllers { diff --git a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs new file mode 100644 index 0000000..13a2b3b --- /dev/null +++ b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs @@ -0,0 +1,48 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using WalkingTec.Mvvm.Core; +using WalkingTec.Mvvm.Mvc; +using WalkingTec.Mvvm.Core.Extensions; +using HHWMS.Web; +using HHWMS.Web.Models; + +namespace HHWMS.Web.Controllers +{ + [Area("receipt")] + [ActionDescription("入库单操作")] + public partial class ReceiptInController : BaseController + { + private readonly IUnitWork _unitwork; + public ReceiptInController(IUnitWork unitwork) + { + _unitwork = unitwork; + } + #region Search + [ActionDescription("Sys.Search")] + public ActionResult Index() + { + var vm = Wtm.CreateVM(); + return PartialView(vm); + } + + [ActionDescription("Sys.Search")] + [HttpPost] + public string Search(ReceiptInSearcher searcher) + { + var vm = Wtm.CreateVM(passInit: true); + if (ModelState.IsValid) + { + vm.Searcher = searcher; + return vm.GetJson(false); + } + else + { + return vm.GetError(); + } + } + + #endregion + + } +} diff --git a/HHWMS.Web/Areas/Receipt/ViewModels/ReceiptInVMs/ReceiptHeaderVM.cs b/HHWMS.Web/Areas/Receipt/ViewModels/ReceiptInVMs/ReceiptHeaderVM.cs new file mode 100644 index 0000000..f67fac8 --- /dev/null +++ b/HHWMS.Web/Areas/Receipt/ViewModels/ReceiptInVMs/ReceiptHeaderVM.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using System.Linq; +using HHWMS.Web.Models; +using WalkingTec.Mvvm.Core; +using Z.EntityFramework.Plus; + +namespace HHWMS.Web +{ + public partial class ReceiptInVM : BaseCRUDVM + { + public ReceiptDetailListVM2 Details = new ReceiptDetailListVM2(); + public ReceiptInVM() + { + } + + protected override void InitVM() + { + Details.CopyContext(this); + Details.Searcher.ReceiptHeaderId = Entity.ID; + } + } +} diff --git a/HHWMS.Web/Areas/Receipt/ViewModels/ReceiptInVMs/ReceiptInListVM.cs b/HHWMS.Web/Areas/Receipt/ViewModels/ReceiptInVMs/ReceiptInListVM.cs new file mode 100644 index 0000000..551e593 --- /dev/null +++ b/HHWMS.Web/Areas/Receipt/ViewModels/ReceiptInVMs/ReceiptInListVM.cs @@ -0,0 +1,57 @@ +using System.Collections.Generic; +using System.Linq; +using HHWMS.Web.Models; +using WalkingTec.Mvvm.Core; +using WalkingTec.Mvvm.Core.Extensions; + +namespace HHWMS.Web +{ + public partial class ReceiptInListVM : BasePagedListVM + { + public ReceiptDetailListVM2 Details { get; set; } = new ReceiptDetailListVM2(); + public List Codes { get; set; } + protected override void InitVM() + { + Details.CopyContext(this); + Codes = DC.Set().Select(x => new ComboSelectListItem + { + Text = x.Code, + Value = x.Code + }).ToList(); + } + protected override List InitGridAction() + { + return new List(); + /*{ + this.MakeStandardAction("ReceiptHeader", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"receipt", dialogWidth: 800), + 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), + this.MakeStandardAction("ReceiptHeader", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "receipt", dialogWidth: 800), + 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"), + };*/ + } + + protected override IEnumerable> InitGridHeader() + { + return new List>{ + this.MakeGridHeader(x => x.Code) + }; + } + + public override IOrderedQueryable GetSearchQuery() + { + var query = DC.Set() + .CheckContain(Searcher.Code, x => x.Code) + .Select(x => new ReceiptHeader_View + { + ID = x.ID, + Code = x.Code + }) + .OrderBy(x => x.ID); + return query; + } + } +} diff --git a/HHWMS.Web/Areas/Receipt/ViewModels/ReceiptInVMs/ReceiptInSearcher.cs b/HHWMS.Web/Areas/Receipt/ViewModels/ReceiptInVMs/ReceiptInSearcher.cs new file mode 100644 index 0000000..009c878 --- /dev/null +++ b/HHWMS.Web/Areas/Receipt/ViewModels/ReceiptInVMs/ReceiptInSearcher.cs @@ -0,0 +1,29 @@ +using System; +using System.ComponentModel.DataAnnotations; +using HHWMS.Web.Models; +using WalkingTec.Mvvm.Core; + +namespace HHWMS.Web +{ + public partial class ReceiptInSearcher : BaseSearcher + { + [Display(Name = "Inventory.SourceCode")] + public String SourceCode { get; set; } + + [Display(Name = "Inventory.ReceiptCode")] + public String Code { get; set; } + + [Display(Name = "Inventory.BillType")] + public String BillType { get; set; } + + [Display(Name = "Receipt.FirstStatus")] + public ReceiptStatusEnum? FirstStatus { get; set; } + + [Display(Name = "Receipt.LastStatus")] + public ReceiptStatusEnum? LastStatus { get; set; } + + protected override void InitVM() + { + } + } +} diff --git a/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml b/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml new file mode 100644 index 0000000..87c82a6 --- /dev/null +++ b/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml @@ -0,0 +1,111 @@ +@model HHWMS.Web.ReceiptInListVM +@inject IStringLocalizer Localizer; + +
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+ diff --git a/HHWMS.Web/Areas/System/Controllers/jobs/SendWcsJob.cs b/HHWMS.Web/Areas/System/Controllers/jobs/SendWcsJob.cs index a6d9d52..708ddfc 100644 --- a/HHWMS.Web/Areas/System/Controllers/jobs/SendWcsJob.cs +++ b/HHWMS.Web/Areas/System/Controllers/jobs/SendWcsJob.cs @@ -1,15 +1,13 @@ using System; -using System.IO; +using System.Collections.Generic; using System.Linq; -using System.Security.Cryptography; using System.Threading.Tasks; using HHWMS.Web.Models; +using Microsoft.EntityFrameworkCore; +using Newtonsoft.Json; using Quartz; using WalkingTec.Mvvm.Core; -using WalkingTec.Mvvm.Core.Extensions; using WalkingTec.Mvvm.Core.Support.Quartz; -using ProtoBuf; -using Newtonsoft.Json; namespace HHWMS.Web { @@ -24,35 +22,31 @@ namespace HHWMS.Web { var _unitwork = new UnitWork(Wtm); - var taskList = _unitwork.Find(x => x.Status == TaskStatusEnum.新建).Take(10); - var begin = new Location(); - var end = new Location(); - var locationCodeList = taskList.Select(x => x.FromLocation).Union(taskList.Select(x => x.ToLocation)).ToList(); - var locationList = _unitwork.Find(x => locationCodeList.Contains(x.Code)).ToList(); ; - foreach (var task in taskList) + var task = _unitwork.Find(x => x.Status == TaskStatusEnum.待下发) + .Include(x => x.TaskDetails.Where(x => x.Status < TaskStatusEnum.已下发)).FirstDynamic(); + var taskList = CreateWCSTask(task, _unitwork); + foreach (var item in taskList) { - begin = locationList.FirstOrDefault(x => x.Code.Equals(task.FromLocation)); - end = locationList.FirstOrDefault(x => x.Code.Equals(task.ToLocation)); - var taskInfo = new TaskInfo + task.ErrorMsg += JsonConvert.SerializeObject(item); + // 调用wcs任务下发接口 + try { - TaskId = task.TaskNo, - TaskType = (int)task.TaskType, - ObjId = task.ContainerCode, - StartPos = new CoordPos + var res = Wtm.CallAPI>("WCS", "TaskAssign", HttpMethodEnum.POST, item).Result.Data; + if (res.Success) { - X = begin.Line, - Y = begin.Row, - Z = begin.Layer - }, - EndPos = new CoordPos - { - X = end.Line, - Y = end.Row, - Z = end.Layer + task.TaskDetails.Where(x => x.UniqueCode.Equals(item.ObjId)).First().Status = TaskStatusEnum.已下发; } - }; + Task.Delay(500); + } + catch(Exception ex) + { + task.ErrorMsg += ex.Message; + } + _unitwork.Update(task); } + #region 更新时间 + var job = _unitwork.FindSingle(x => x.JobName == context.JobDetail.Key.Name); if (job != null) { @@ -64,10 +58,154 @@ namespace HHWMS.Web } _unitwork.Update(job); } - #endregion + + #endregion 更新时间 } catch { } return Task.CompletedTask; } + + /// + /// 创建WCS任务 + /// + public List CreateWCSTask(TaskHeader task, UnitWork _unitwork) + { + var taskInfoList = new List(); + if (task != null) + { + var locationList = _unitwork.Find(x => task.FromLocation.Equals(x.Code) || task.ToLocation.Equals(x.Code)).ToList(); + var begin = locationList.First(x => x.Code.Equals(task.FromLocation)); + var end = locationList.First(x => x.Code.Equals(task.ToLocation)); + // 根据不同任务类型 创建任务 + switch (task.TaskType) + { + case TaskTypeEnum.料盒入库: + case TaskTypeEnum.料盒出库: + var taskInfo = new TaskInfo(); + taskInfo.TaskType = (int)task.TaskType; + taskInfo.TaskId = task.TaskNo; + taskInfo.ObjId = task.ContainerCode; + taskInfo.StartType = ConvertTypeLocation(begin.Length); + taskInfo.StartPos = new CoordPos + { + X = begin.Line, + Y = begin.Row, + Z = begin.Layer + }; + taskInfo.EndType = ConvertTypeLocation(end.Length); + taskInfo.EndPos = new CoordPos + { + X = end.Line, + Y = end.Row, + Z = end.Layer + }; + taskInfoList.Add(taskInfo); + break; + + case TaskTypeEnum.盘料入库: + foreach (var item in task.TaskDetails) + { + taskInfoList.Add(new TaskInfo + { + TaskId = $"{task.TaskNo}-{item.FromLocation}", + TaskType = (int)task.TaskType, + ObjId = item.UniqueCode, + StartType = ConvertTypeLT(task.ContainerCode), + StartPos = new CoordPos + { + X = begin.Line, + Y = 2, + Z = int.Parse(item.FromLocation) + }, + EndType = ConvertTypeLocation(end.Length), + EndPos = new CoordPos + { + X = end.Line, + Y = int.Parse(item.ToLocation), + Z = 2 + } + }); + } + break; + + case TaskTypeEnum.盘料出库: + foreach (var item in task.TaskDetails) + { + taskInfoList.Add(new TaskInfo + { + TaskId = $"{task.TaskNo}-{item.FromLocation}", + TaskType = (int)task.TaskType, + ObjId = item.UniqueCode, + StartType = ConvertTypeLocation(begin.Length), + StartPos = new CoordPos + { + X = begin.Line, + Y = int.Parse(item.FromLocation), + Z = 2 + }, + + EndType = ConvertTypeLT(task.ContainerCode), + EndPos = new CoordPos + { + X = end.Line, + Y = 2, + Z = int.Parse(item.ToLocation) + } + }); + } + break; + + default: + break; + } + } + return taskInfoList; + } + + public int ConvertTypeLocation(decimal? length) + { + var type = 0; + if (length.HasValue) + { + switch ((int)length) + { + case 23: + type = (int)ContainerTypeEnum.格料盒23; + break; + + case 13: + type = (int)ContainerTypeEnum.格料盒13; + break; + + case 16: + type = (int)ContainerTypeEnum.格料盒16; + break; + + case 19: + type = (int)ContainerTypeEnum.格料盒19; + break; + } + } + return type; + } + + public int ConvertTypeLT(string LiaoTa) + { + var type = 0; + if (!string.IsNullOrEmpty(LiaoTa)) + { + switch (LiaoTa) + { + case "L01": + type = (int)LiaoTaTypeEnum.L01; + break; + + case "L02": + type = (int)LiaoTaTypeEnum.L02; + break; + } + } + return type; + } } } diff --git a/HHWMS.Web/Controllers/HomeController.cs b/HHWMS.Web/Controllers/HomeController.cs index 13eb3e1..430e469 100644 --- a/HHWMS.Web/Controllers/HomeController.cs +++ b/HHWMS.Web/Controllers/HomeController.cs @@ -23,7 +23,7 @@ namespace HHWMS.Web.Controllers [AllRights] public IActionResult Index(string redirect) { - ViewData["title"] = "WTM"; + ViewData["title"] = "WMS"; return View(); } diff --git a/HHWMS.Web/Models/Enum/WMSEnum.cs b/HHWMS.Web/Models/Enum/WMSEnum.cs index f7acf70..e0e8205 100644 --- a/HHWMS.Web/Models/Enum/WMSEnum.cs +++ b/HHWMS.Web/Models/Enum/WMSEnum.cs @@ -47,7 +47,7 @@ namespace HHWMS.Web.Models /// 盘料出库 /// [Display(Name = "TaskType.POut")] - 盘料出库 = 3 + 盘料出库 = 4 } /// @@ -58,6 +58,9 @@ namespace HHWMS.Web.Models [Display(Name = "TaskStatusEnum.0")] 新建 = 0, + [Display(Name = "TaskStatusEnum.1")] + 待下发 = 1, + [Display(Name = "TaskStatusEnum.5")] 已下发 = 5, @@ -86,6 +89,21 @@ namespace HHWMS.Web.Models 盘点锁 = 2, } + /// + /// 容器类型 + /// + public enum ContainerTypeEnum : int + { + //// 11:23格料盒; 12:13格料盒; 13:16格料盒; 14:19格料盒 + 格料盒23 = 11, + + 格料盒13 = 12, + + 格料盒16 = 13, + + 格料盒19 = 14, + } + /// /// 容器状态 /// @@ -238,4 +256,14 @@ namespace HHWMS.Web.Models public const string 任务中 = "lock"; } + + /// + /// 料塔类型 + /// + public enum LiaoTaTypeEnum : int + { + // 1: 20层料塔类型1; 2:16层料塔类型1; 3:20层料塔类型2 4:16层料塔类型2 + L01 = 1, + L02 = 2 + } } diff --git a/HHWMS.Web/Models/Request/Request/Proto_8357.cs b/HHWMS.Web/Models/Request/Request/Proto_8357.cs index 9fb2b1f..99e12ba 100644 --- a/HHWMS.Web/Models/Request/Request/Proto_8357.cs +++ b/HHWMS.Web/Models/Request/Request/Proto_8357.cs @@ -67,7 +67,7 @@ namespace HHWMS.Web.Models /// /// 响应结果 100:任务完成, 99:任务失败 /// - public int Resut { get; set; } + public int Result { get; set; } } /* diff --git a/HHWMS.Web/Resources/Program.zh.resx b/HHWMS.Web/Resources/Program.zh.resx index b1f0bb0..ff4ea95 100644 --- a/HHWMS.Web/Resources/Program.zh.resx +++ b/HHWMS.Web/Resources/Program.zh.resx @@ -1031,6 +1031,9 @@ 新建 + + + 待下发 已下发 diff --git a/HHWMS.Web/Views/Home/Layout.cshtml b/HHWMS.Web/Views/Home/Layout.cshtml index 8fa62c2..302352c 100644 --- a/HHWMS.Web/Views/Home/Layout.cshtml +++ b/HHWMS.Web/Views/Home/Layout.cshtml @@ -27,11 +27,11 @@ -
  • + @*
  • -
  • + *@
  • @@ -40,11 +40,11 @@