diff --git a/HHWMS.Web/Areas/Api/IWCSController.cs b/HHWMS.Web/Areas/Api/IWCSController.cs index c6258ad..e9b30f5 100644 --- a/HHWMS.Web/Areas/Api/IWCSController.cs +++ b/HHWMS.Web/Areas/Api/IWCSController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using AutoMapper; @@ -31,6 +32,7 @@ namespace HHWMS.Web private readonly IMapper _mapper; private readonly IMemoryCache _cache; private const int DEBOUNCE_INTERVAL_MS = 1000; // 防抖间隔1秒 + private int ContainerWeight = 500; public IWCSController(IUnitWork unitWork, IMapper mapper, IMemoryCache cache) { @@ -133,7 +135,7 @@ namespace HHWMS.Web private async Task ProcessTaskStatusResult(WcsRequest request) { // 1. 根据托盘号查找对应的任务 - var task = _unitWork.FindSingle(x => x.ContainerCode == request.PalletNo + var task = _unitWork.FindSingle(x => x.TaskNo == request.TaskNo && x.Status != TaskStatusEnum.完成); if (task == null) @@ -166,7 +168,7 @@ namespace HHWMS.Web // 根据请求的高度,分配仓位 var locationVm = Wtm.CreateVM(); request.RoadWay = 2; - var container = _unitWork.FindSingle(x => x.Code == request.PalletNo); + var container = _unitWork.FindSingle(x => x.Code == task.ContainerCode); if (container != null) { request.LocationType = container.Type switch @@ -208,52 +210,72 @@ namespace HHWMS.Web { try { - // 1. 更新库存 - var inventories = _unitWork.Find(x => x.ContainerCode == request.PalletNo); + // 更新库存 + var inventories = _unitWork.Find(x => x.ContainerCode == task.ContainerCode).ToList(); + var invTrans = new List(); foreach (var inventory in inventories) { - // 更新库存的库位编码 + var material = _unitWork.FindSingle(x => x.MaterialCode == inventory.MaterialCode); + inventory.LocationCode = task.ToLocation; - // 更新库存任务状态为空闲 + if(task.TaskType == TaskTypeEnum.入库) + inventory.Qty = (request.Weight - ContainerWeight) / material.Qty; inventory.TaskStatus = InventoryTaskStatusEnum.Idle; - } - // 2. 更新容器状态 - var container = _unitWork.FindSingle(x => x.Code == request.PalletNo); + + // 创建库存交易记录 放到任务完成,计算数量信息 + var invTransaction = new InventoryTransaction + { + Type = task.TaskType == TaskTypeEnum.入库 ? InventoryTranType.入库 : InventoryTranType.出库, + ContainerCode = task.ContainerCode, + LocationCode = task.ToLocation, + MaterialCode = inventory.MaterialCode, + MaterialName = inventory.MaterialName, + MaterialSpec = inventory.MaterialSpec, + MaterialUnit = inventory.MaterialUnit, + Qty = inventory.Qty, + CreateTime = DateTime.Now + }; + invTrans.Add(invTransaction); + } + _unitWork.BatchAdd(invTrans); + _unitWork.BatchUpdate(inventories); + + + // 更新容器状态 + var container = _unitWork.FindSingle(x => x.Code == task.ContainerCode); if (container != null) { - // 更新容器的库位编码 container.LocationCode = task.ToLocation; - // 更新容器状态为有货 - container.Status = ContainerStatus.有; - // 解除容器的任务锁 container.IsLock = ContainerLockEnum.未锁; + container.UpdateTime = DateTime.Now; } + _unitWork.Update(container); - // 3. 更新库位状态 - var location = _unitWork.FindSingle(x => x.Code == task.ToLocation); + // 更新库位状态 + var location = task.TaskType == TaskTypeEnum.入库 + ? _unitWork.FindSingle(x => x.Code == task.ToLocation) + : _unitWork.FindSingle(x => x.Code == task.FromLocation); if (location != null) { - // 更新库位的容器编码 - location.ContainerCode = request.PalletNo; - // 更新库位状态为有货 - location.Status = LocationStatusEnum.Some; + location.ContainerCode = task.TaskType == TaskTypeEnum.入库 ? request.PalletNo : ""; + location.Status = LocationStatusEnum.未锁; + location.ContainerStatus = LocationStatus.空仓位; + location.UpdateTime = DateTime.Now; } + _unitWork.Update(location); - // 4. 更新任务状态为完成 + // 更新任务状态为完成 task.Status = TaskStatusEnum.完成; - // 5. 保存所有更改 - _unitWork.Save(); - - // 6. 将任务复制到历史任务表 + // 将任务复制到历史任务表 var taskHistory = _mapper.Map(task); _unitWork.Add(taskHistory); - // 7. 删除原任务 + // 删除原任务 _unitWork.Delete(task); - // 8. 提交事务 + // 提交事务 await transaction.CommitAsync(); } catch (System.Exception ex) @@ -281,7 +303,7 @@ namespace HHWMS.Web return Task.FromResult(ApiResultError("巷道不能为空")); } - return WithDebounce($"RequestLocation_{request.PalletNo}", () => + return WithDebounce($"RequestLocation_{request.TaskNo}", () => { var vm = Wtm.CreateVM(); var code = vm.GetLocation(request); @@ -321,11 +343,11 @@ namespace HHWMS.Web var container = _unitWork.Find(x => x.Code == palletNo).FirstOrDefault(); if (container != null) { - container.LocationCode = location.Code; + container.LocationCode = location?.Code; _unitWork.Update(container); } - return ApiResult(new { LocationCode = location.Code }); + return ApiResult(new { LocationCode = location?.Code }); } } } diff --git a/HHWMS.Web/Areas/Configs/Controllers/LocationController.cs b/HHWMS.Web/Areas/Configs/Controllers/LocationController.cs index f92d9df..6ac6d96 100644 --- a/HHWMS.Web/Areas/Configs/Controllers/LocationController.cs +++ b/HHWMS.Web/Areas/Configs/Controllers/LocationController.cs @@ -269,7 +269,8 @@ namespace HHWMS.Web.Controllers RowFlag = (vm.RoadwayType == 1 || vm.RoadwayType == 2 ? RowFlagEnum.Outer : (row == 1 || row == 4 ? RowFlagEnum.Inner : RowFlagEnum.Outer)), ContiguousCode = vm.RoadwayType == 4 ? $"{vm.Entity.Type}{vm.Entity.RoadWay.ToString().PadLeft(2, '0')}-{(row % 2 == 0?row-1:row+1) .ToString().PadLeft(2, '0')}-{line.ToString().PadLeft(2, '0')}-{layer.ToString().PadLeft(2, '0')}" : null, IsStop = false, - Status = LocationStatusEnum.Empty, + Status = LocationStatusEnum.未锁, + ContainerStatus = LocationStatus.空仓位, Length = vm.Entity.Length, Width = vm.Entity.Width, Height = vm.Entity.Height diff --git a/HHWMS.Web/Areas/Configs/Controllers/MaterialController.cs b/HHWMS.Web/Areas/Configs/Controllers/MaterialController.cs index 8e4f97e..a758414 100644 --- a/HHWMS.Web/Areas/Configs/Controllers/MaterialController.cs +++ b/HHWMS.Web/Areas/Configs/Controllers/MaterialController.cs @@ -224,5 +224,12 @@ namespace HHWMS.Web.Controllers } #endregion + + [HttpGet] + public IActionResult GetUniqueCode() + { + var sn = _unitWork.GetSerialNumber("M", 6); + return Json(sn); + } } } diff --git a/HHWMS.Web/Areas/Configs/Controllers/MaterialProcessController.cs b/HHWMS.Web/Areas/Configs/Controllers/MaterialProcessController.cs new file mode 100644 index 0000000..4116353 --- /dev/null +++ b/HHWMS.Web/Areas/Configs/Controllers/MaterialProcessController.cs @@ -0,0 +1,228 @@ +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; + +namespace HHWMS.Web.Controllers +{ + [Area("configs")] + [ActionDescription("物料工序")] + public partial class MaterialProcessController : BaseController + { + private readonly IUnitWork _unitWork; + + public MaterialProcessController(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(MaterialProcessSearcher searcher) + { + var vm = Wtm.CreateVM(passInit: true); + if (ModelState.IsValid) + { + vm.Searcher = searcher; + return vm.GetJson(false); + } + else + { + return vm.GetError(); + } + } + + #endregion + + #region Create + [ActionDescription("Sys.Create")] + public ActionResult Create() + { + var vm = Wtm.CreateVM(); + return PartialView(vm); + } + + [HttpPost] + [ActionDescription("Sys.Create")] + public ActionResult Create(MaterialProcessVM vm) + { + if (!ModelState.IsValid) + { + return PartialView(vm); + } + else + { + vm.DoAdd(); + if (!ModelState.IsValid) + { + vm.DoReInit(); + return PartialView(vm); + } + else + { + return FFResult().CloseDialog().RefreshGrid(); + } + } + } + #endregion + + #region Edit + [ActionDescription("Sys.Edit")] + public ActionResult Edit(string id) + { + var vm = Wtm.CreateVM(id); + return PartialView(vm); + } + + [ActionDescription("Sys.Edit")] + [HttpPost] + [ValidateFormItemOnly] + public ActionResult Edit(MaterialProcessVM vm) + { + if (!ModelState.IsValid) + { + return PartialView(vm); + } + else + { + vm.DoEdit(); + if (!ModelState.IsValid) + { + vm.DoReInit(); + return PartialView(vm); + } + else + { + return FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID); + } + } + } + #endregion + + #region Delete + [ActionDescription("Sys.Delete")] + public ActionResult Delete(string id) + { + var vm = Wtm.CreateVM(id); + return PartialView(vm); + } + + [ActionDescription("Sys.Delete")] + [HttpPost] + public ActionResult Delete(string id, IFormCollection nouse) + { + var vm = Wtm.CreateVM(id); + vm.DoDelete(); + if (!ModelState.IsValid) + { + return PartialView(vm); + } + else + { + return FFResult().CloseDialog().RefreshGrid(); + } + } + #endregion + + #region Details + [ActionDescription("Sys.Details")] + public ActionResult Details(string id) + { + var vm = Wtm.CreateVM(id); + return PartialView(vm); + } + #endregion + + #region BatchEdit + [HttpPost] + [ActionDescription("Sys.BatchEdit")] + public ActionResult BatchEdit(string[] IDs) + { + var vm = Wtm.CreateVM(Ids: IDs); + return PartialView(vm); + } + + [HttpPost] + [ActionDescription("Sys.BatchEdit")] + public ActionResult DoBatchEdit(MaterialProcessBatchVM vm, IFormCollection nouse) + { + if (!ModelState.IsValid || !vm.DoBatchEdit()) + { + return PartialView("BatchEdit",vm); + } + else + { + return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchEditSuccess", vm.Ids.Length]); + } + } + #endregion + + #region BatchDelete + [HttpPost] + [ActionDescription("Sys.BatchDelete")] + public ActionResult BatchDelete(string[] IDs) + { + var vm = Wtm.CreateVM(Ids: IDs); + return PartialView(vm); + } + + [HttpPost] + [ActionDescription("Sys.BatchDelete")] + public ActionResult DoBatchDelete(MaterialProcessBatchVM vm, IFormCollection nouse) + { + if (!ModelState.IsValid || !vm.DoBatchDelete()) + { + return PartialView("BatchDelete",vm); + } + else + { + return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchDeleteSuccess", vm.Ids.Length]); + } + } + #endregion + + #region Import + [ActionDescription("Sys.Import")] + public ActionResult Import() + { + var vm = Wtm.CreateVM(); + return PartialView(vm); + } + + [HttpPost] + [ActionDescription("Sys.Import")] + public ActionResult Import(MaterialProcessImportVM vm, IFormCollection nouse) + { + if (vm.ErrorListVM.EntityList.Count > 0 || !vm.BatchSaveData()) + { + return PartialView(vm); + } + else + { + return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.ImportSuccess", vm.EntityList.Count.ToString()]); + } + } + #endregion + + #region Export + [ActionDescription("Sys.Export")] + [HttpPost] + public IActionResult ExportExcel(MaterialProcessListVM vm) + { + return vm.GetExportData(); + } + #endregion + + } +} diff --git a/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationVM.cs b/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationVM.cs index 4fa1c0e..db81d36 100644 --- a/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationVM.cs +++ b/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationVM.cs @@ -14,7 +14,7 @@ namespace HHWMS.Web public partial class LocationVM : BaseCRUDVM { public List AllLocationZones { get; set; } - + [Display(Name = "Location.BeginLine", Description = "起始列")] public short BeginLine { get; set; } @@ -24,6 +24,7 @@ namespace HHWMS.Web [Display(Name = "Location.RoadwayType", Description = "巷道类型")] [Required(ErrorMessage = "Validate.{0}required")] public short RoadwayType { get; set; } + public List RoadwayTypes { get; set; } @@ -35,7 +36,7 @@ namespace HHWMS.Web protected override void InitVM() { AllLocationZones = DC.Set().GetSelectListItems(Wtm, y => y.Name); - + var currentCulture = Wtm.CurrentCulture; var dictData = DC.Set().ToList(); RoadwayTypes = dictData.Where(x => x.DictType == "RoadwayType").Select(x => new ComboSelectListItem @@ -43,13 +44,12 @@ namespace HHWMS.Web Text = currentCulture == "zh" ? x.DictLabel : x.DictLabelUs, Value = x.DictValue }).ToList(); - } #region base - + public override void DoAdd() - { + { base.DoAdd(); } @@ -62,18 +62,20 @@ namespace HHWMS.Web { base.DoDelete(); } + #endregion base - + /// /// 查找单伸位巷道的空仓位 /// private string GetEmptyLocationBySingle(int? roadway) { var locations = DC.Set() - .Where(l => l.RoadWay == roadway + .Where(l => l.RoadWay == roadway && !l.IsStop - && l.Status == LocationStatusEnum.Empty - && l.RowFlag == 0) // 单伸位只查找外仓位 + && l.Status == LocationStatusEnum.未锁 + && l.ContainerStatus == LocationStatus.空仓位 + && l.RowFlag == 0) // 单伸位只查找外仓位 .OrderBy(l => l.Layer) .ThenBy(l => l.Line) .AsNoTracking() @@ -85,7 +87,7 @@ namespace HHWMS.Web /// /// 查找双伸位巷道的空仓位 /// - private string GetEmptyLocationByDouble(int roadway,LocationTypeEnum locationType, decimal? height = 0) + private string GetEmptyLocationByDouble(int roadway, LocationTypeEnum locationType, decimal? height = 0) { // 一次性获取所需的所有数据,避免多次查询数据库 var locationPairs = DC.Set() @@ -93,11 +95,12 @@ namespace HHWMS.Web && l.Type == locationType && !l.IsStop && l.Height >= height) - .Select(l => new + .Select(l => new { l.Code, l.ContiguousCode, l.Status, + l.ContainerStatus, l.RowFlag, l.Height, l.Layer, @@ -108,10 +111,12 @@ namespace HHWMS.Web // 1. 优先查找里外仓位都为空的里仓位 var emptyInnerLocation = locationPairs.Values - .Where(l => l.RowFlag == RowFlagEnum.Inner - && l.Status == LocationStatusEnum.Empty - && locationPairs.TryGetValue(l.ContiguousCode, out var outer) - && outer.Status == LocationStatusEnum.Empty) + .Where(l => l.RowFlag == RowFlagEnum.Inner + && l.Status == LocationStatusEnum.未锁 + && l.ContainerStatus == LocationStatus.空仓位 + && locationPairs.TryGetValue(l.ContiguousCode, out var outer) + && outer.Status == LocationStatusEnum.未锁 + && outer.ContainerStatus == LocationStatus.空仓位) .OrderBy(l => l.Height) .ThenBy(l => l.Layer) .ThenBy(l => l.Line) @@ -124,10 +129,12 @@ namespace HHWMS.Web // 2. 查找里仓位有货,外仓位为空的外仓位 var availableOuterLocation = locationPairs.Values - .Where(l => l.RowFlag == 0 - && l.Status == LocationStatusEnum.Empty - && locationPairs.TryGetValue(l.ContiguousCode, out var inner) - && inner.Status == LocationStatusEnum.Some) + .Where(l => l.RowFlag == 0 + && l.Status == LocationStatusEnum.未锁 + && l.ContainerStatus == LocationStatus.空仓位 + && locationPairs.TryGetValue(l.ContiguousCode, out var inner) + && inner.Status == LocationStatusEnum.未锁 + && inner.ContainerStatus == LocationStatus.有货) .OrderBy(l => l.Height) .ThenBy(l => l.Layer) .ThenBy(l => l.Line) @@ -161,7 +168,8 @@ namespace HHWMS.Web locationCode = GetEmptyLocationBySingle(request.RoadWay.Value); break; case 4: // 双伸位 - locationCode = GetEmptyLocationByDouble(request.RoadWay.Value, request.LocationType, request.Height); + locationCode = + GetEmptyLocationByDouble(request.RoadWay.Value, request.LocationType, request.Height); break; default: return ResponseResult.Error("未知的巷道类型"); @@ -175,6 +183,40 @@ namespace HHWMS.Web return ResponseResult.Success(new { LocationCode = locationCode }); } + /// + /// 线边库查找空仓位 + /// + public string GetEmptyLocationFromXb(int beginLine, int endLine) + { + var location = DC.Set() + .Where(l => l.Type == LocationTypeEnum.X + && !l.IsStop + && l.Status == LocationStatusEnum.未锁 + && l.ContainerStatus == LocationStatus.空仓位 + && l.RowFlag == 0 + && (l.Line >= beginLine && l.Line <= endLine)) // 单伸位只查找外仓位 + .OrderBy(l => l.Layer) + .ThenBy(l => l.Line) + .AsNoTracking() + .FirstOrDefault(); + // 没查找合适的就找靠近的此区域的 + if (location == null) + { + location = DC.Set() + .Where(l => l.Type == LocationTypeEnum.X + && !l.IsStop + && l.Status == LocationStatusEnum.未锁 + && l.ContainerStatus == LocationStatus.空仓位 + && l.RowFlag == 0) // 单伸位只查找外仓位 + .OrderBy(l => Math.Abs(l.Line - (endLine - beginLine) / 2)) + .ThenBy(l => l.Layer) + .AsNoTracking() + .FirstOrDefault(); + } + + return location?.Code; + } + /// /// 根据巷道名称获取巷道类型 /// @@ -204,10 +246,10 @@ namespace HHWMS.Web // 获取所有巷道配置 var roadwayConfigs = DC.Set() .Where(x => x.DictType == "RoadwayConfig") - .Select(x => new - { - Roadway = x.DictLabel, - Type = x.DictValue + .Select(x => new + { + Roadway = x.DictLabel, + Type = x.DictValue }) .ToDictionary(x => x.Roadway, x => x.Type); @@ -223,6 +265,7 @@ namespace HHWMS.Web l.Code, l.ContiguousCode, l.Status, + l.ContainerStatus, l.RowFlag, l.Layer, l.Line, @@ -250,7 +293,9 @@ namespace HHWMS.Web { case "2": // 单伸位 var singleLocations = roadwayLocations - .Where(l => l.RowFlag == 0 && l.Status == LocationStatusEnum.Empty) + .Where(l => l.RowFlag == 0 + && l.Status == LocationStatusEnum.未锁 + && l.ContainerStatus == LocationStatus.空仓位) .OrderBy(l => l.Layer) .ThenBy(l => l.Line) .Select(l => new @@ -267,10 +312,12 @@ namespace HHWMS.Web case "4": // 双伸位 // 1. 查找里外都为空的里仓位 var emptyInnerLocations = roadwayLocations - .Where(l => l.RowFlag == RowFlagEnum.Inner - && l.Status == LocationStatusEnum.Empty - && allLocations.TryGetValue(l.ContiguousCode, out var outer) - && outer.Status == LocationStatusEnum.Empty) + .Where(l => l.RowFlag == RowFlagEnum.Inner + && l.Status == LocationStatusEnum.未锁 + && l.ContainerStatus == LocationStatus.空仓位 + && allLocations.TryGetValue(l.ContiguousCode, out var outer) + && outer.Status == LocationStatusEnum.未锁 + && outer.ContainerStatus == LocationStatus.空仓位) .OrderBy(l => l.Layer) .ThenBy(l => l.Line) .Select(l => new @@ -285,10 +332,12 @@ namespace HHWMS.Web // 2. 查找里仓位有货,外仓位为空的外仓位 var availableOuterLocations = roadwayLocations - .Where(l => l.RowFlag == 0 - && l.Status == LocationStatusEnum.Empty - && allLocations.TryGetValue(l.ContiguousCode, out var inner) - && inner.Status == LocationStatusEnum.Some) + .Where(l => l.RowFlag == 0 + && l.Status == LocationStatusEnum.未锁 + && l.ContainerStatus == LocationStatus.空仓位 + && allLocations.TryGetValue(l.ContiguousCode, out var inner) + && inner.Status == LocationStatusEnum.未锁 + && inner.ContainerStatus == LocationStatus.有货) .OrderBy(l => l.Layer) .ThenBy(l => l.Line) .Select(l => new @@ -309,8 +358,8 @@ namespace HHWMS.Web return ResponseResult.Error("未找到可用的空仓位"); } - return ResponseResult.Success(new - { + return ResponseResult.Success(new + { Locations = availableLocations, Total = availableLocations.Count }); diff --git a/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessBatchVM.cs b/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessBatchVM.cs new file mode 100644 index 0000000..4ff5d39 --- /dev/null +++ b/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessBatchVM.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Threading.Tasks; +using WalkingTec.Mvvm.Core; +using WalkingTec.Mvvm.Core.Extensions; +using HHWMS.Web.Models; + + +namespace HHWMS.Web +{ + public partial class MaterialProcessBatchVM : BaseBatchVM + { + public MaterialProcessBatchVM() + { + ListVM = new MaterialProcessListVM(); + LinkedVM = new MaterialProcess_BatchEdit(); + } + + } + + /// + /// Class to define batch edit fields + /// + public class MaterialProcess_BatchEdit : BaseVM + { + + protected override void InitVM() + { + } + + } + +} diff --git a/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessImportVM.cs b/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessImportVM.cs new file mode 100644 index 0000000..f858c56 --- /dev/null +++ b/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessImportVM.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Threading.Tasks; +using WalkingTec.Mvvm.Core; +using WalkingTec.Mvvm.Core.Extensions; +using HHWMS.Web.Models; + + +namespace HHWMS.Web +{ + public partial class MaterialProcessTemplateVM : BaseTemplateVM + { + [Display(Name = "MaterialProcess.MaterialCode")] + public ExcelPropety MaterialCode_Excel = ExcelPropety.CreateProperty(x => x.MaterialCode); + [Display(Name = "MaterialProcess.ProcessOrder")] + public ExcelPropety ProcessOrder_Excel = ExcelPropety.CreateProperty(x => x.ProcessOrder); + [Display(Name = "MaterialProcess.ProcessName")] + public ExcelPropety ProcessName_Excel = ExcelPropety.CreateProperty(x => x.ProcessName); + [Display(Name = "MaterialProcess.ProcessCode")] + public ExcelPropety ProcessCode_Excel = ExcelPropety.CreateProperty(x => x.ProcessCode); + [Display(Name = "MaterialProcess.Description")] + public ExcelPropety Description_Excel = ExcelPropety.CreateProperty(x => x.Description); + [Display(Name = "MaterialProcess.IsActive")] + public ExcelPropety IsActive_Excel = ExcelPropety.CreateProperty(x => x.IsActive); + + protected override void InitVM() + { + } + + } + + public class MaterialProcessImportVM : BaseImportVM + { + + } + +} diff --git a/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessListVM.cs b/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessListVM.cs new file mode 100644 index 0000000..a0de145 --- /dev/null +++ b/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessListVM.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WalkingTec.Mvvm.Core; +using WalkingTec.Mvvm.Core.Extensions; +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using HHWMS.Web.Models; + + +namespace HHWMS.Web +{ + public partial class MaterialProcessListVM : BasePagedListVM + { + protected override List InitGridAction() + { + return new List + { + this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"configs", dialogWidth: 800), + this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "configs", dialogWidth: 800), + this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "configs", dialogWidth: 800), + this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "configs", dialogWidth: 800), + this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "configs", dialogWidth: 800), + this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "configs", dialogWidth: 800), + this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "configs", dialogWidth: 800), + this.MakeStandardAction("MaterialProcess", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "configs"), + }; + } + + + protected override IEnumerable> InitGridHeader() + { + return new List>{ + this.MakeGridHeader(x => x.MaterialCode), + this.MakeGridHeader(x => x.ProcessOrder), + this.MakeGridHeader(x => x.ProcessName), + this.MakeGridHeader(x => x.ProcessCode), + this.MakeGridHeader(x => x.Description), + this.MakeGridHeader(x => x.IsActive), + this.MakeGridHeaderAction(width: 200) + }; + } + + public override IOrderedQueryable GetSearchQuery() + { + var query = DC.Set() + .CheckContain(Searcher.MaterialCode, x=>x.MaterialCode) + .CheckEqual(Searcher.ProcessOrder, x=>x.ProcessOrder) + .CheckContain(Searcher.ProcessName, x=>x.ProcessName) + .CheckContain(Searcher.ProcessCode, x=>x.ProcessCode) + .CheckContain(Searcher.Description, x=>x.Description) + .Select(x => new MaterialProcess_View + { + ID = x.ID, + MaterialCode = x.MaterialCode, + ProcessOrder = x.ProcessOrder, + ProcessName = x.ProcessName, + ProcessCode = x.ProcessCode, + Description = x.Description, + IsActive = x.IsActive, + }) + .OrderBy(x => x.ID); + return query; + } + + } + + public class MaterialProcess_View : MaterialProcess{ + + } +} diff --git a/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessSearcher.cs b/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessSearcher.cs new file mode 100644 index 0000000..dad62b8 --- /dev/null +++ b/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessSearcher.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Threading.Tasks; +using WalkingTec.Mvvm.Core; +using WalkingTec.Mvvm.Core.Extensions; +using HHWMS.Web.Models; + + +namespace HHWMS.Web +{ + public partial class MaterialProcessSearcher : BaseSearcher + { + [Display(Name = "MaterialProcess.MaterialCode")] + public String MaterialCode { get; set; } + [Display(Name = "MaterialProcess.ProcessOrder")] + public Int32? ProcessOrder { get; set; } + [Display(Name = "MaterialProcess.ProcessName")] + public String ProcessName { get; set; } + [Display(Name = "MaterialProcess.ProcessCode")] + public String ProcessCode { get; set; } + [Display(Name = "MaterialProcess.Description")] + public String Description { get; set; } + + protected override void InitVM() + { + } + + } +} diff --git a/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessVM.cs b/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessVM.cs new file mode 100644 index 0000000..c7eb214 --- /dev/null +++ b/HHWMS.Web/Areas/Configs/ViewModels/MaterialProcessVMs/MaterialProcessVM.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations; +using WalkingTec.Mvvm.Core; +using WalkingTec.Mvvm.Core.Extensions; +using HHWMS.Web.Models; + + +namespace HHWMS.Web +{ + public partial class MaterialProcessVM : BaseCRUDVM + { + + public MaterialProcessVM() + { + } + + protected override void InitVM() + { + } + + public override void DoAdd() + { + base.DoAdd(); + } + + public override void DoEdit(bool updateAllFields = false) + { + base.DoEdit(updateAllFields); + } + + public override void DoDelete() + { + base.DoDelete(); + } + } +} diff --git a/HHWMS.Web/Areas/Configs/ViewModels/MaterialVMs/MaterialListVM.cs b/HHWMS.Web/Areas/Configs/ViewModels/MaterialVMs/MaterialListVM.cs index d58a5d8..30ceb3d 100644 --- a/HHWMS.Web/Areas/Configs/ViewModels/MaterialVMs/MaterialListVM.cs +++ b/HHWMS.Web/Areas/Configs/ViewModels/MaterialVMs/MaterialListVM.cs @@ -25,6 +25,8 @@ namespace HHWMS.Web this.MakeStandardAction("Material", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "configs", dialogWidth: 800), this.MakeStandardAction("Material", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "configs", dialogWidth: 800), this.MakeStandardAction("Material", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "configs"), + this.MakeAction("Material","Print",Localizer["Sys.Print"],"",GridActionParameterTypesEnum.MultiIds,"configs") + .SetShowDialog(false).SetOnClickScript("print"), }; } diff --git a/HHWMS.Web/Areas/Configs/Views/Material/Index.cshtml b/HHWMS.Web/Areas/Configs/Views/Material/Index.cshtml index 13d1166..f69a4d5 100644 --- a/HHWMS.Web/Areas/Configs/Views/Material/Index.cshtml +++ b/HHWMS.Web/Areas/Configs/Views/Material/Index.cshtml @@ -12,3 +12,27 @@ + \ No newline at end of file diff --git a/HHWMS.Web/Areas/Configs/Views/MaterialProcess/BatchDelete.cshtml b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/BatchDelete.cshtml new file mode 100644 index 0000000..51c80fb --- /dev/null +++ b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/BatchDelete.cshtml @@ -0,0 +1,12 @@ +@model HHWMS.Web.MaterialProcessBatchVM +@inject IStringLocalizer Localizer; + + + @Localizer["Sys.BatchDeleteConfirm"] + + + + + + + diff --git a/HHWMS.Web/Areas/Configs/Views/MaterialProcess/BatchEdit.cshtml b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/BatchEdit.cshtml new file mode 100644 index 0000000..ce86b46 --- /dev/null +++ b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/BatchEdit.cshtml @@ -0,0 +1,14 @@ +@model HHWMS.Web.MaterialProcessBatchVM +@inject IStringLocalizer Localizer; + + +
@Localizer["Sys.BatchEditConfirm"]
+ + + + + + + + +
diff --git a/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Create.cshtml b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Create.cshtml new file mode 100644 index 0000000..7f1f8a5 --- /dev/null +++ b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Create.cshtml @@ -0,0 +1,17 @@ +@model HHWMS.Web.MaterialProcessVM +@inject IStringLocalizer Localizer; + + + + + + + + + + + + + + + diff --git a/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Delete.cshtml b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Delete.cshtml new file mode 100644 index 0000000..7e348c9 --- /dev/null +++ b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Delete.cshtml @@ -0,0 +1,19 @@ +@model HHWMS.Web.MaterialProcessVM +@inject IStringLocalizer Localizer; + + + @Localizer["Sys.DeleteConfirm"] + + + + + + + + + + + + + + diff --git a/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Details.cshtml b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Details.cshtml new file mode 100644 index 0000000..3128811 --- /dev/null +++ b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Details.cshtml @@ -0,0 +1,16 @@ +@model HHWMS.Web.MaterialProcessVM +@inject IStringLocalizer Localizer; + + + + + + + + + + + + + + diff --git a/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Edit.cshtml b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Edit.cshtml new file mode 100644 index 0000000..b539281 --- /dev/null +++ b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Edit.cshtml @@ -0,0 +1,18 @@ +@model HHWMS.Web.MaterialProcessVM +@inject IStringLocalizer Localizer; + + + + + + + + + + + + + + + + diff --git a/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Import.cshtml b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Import.cshtml new file mode 100644 index 0000000..17dfef9 --- /dev/null +++ b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Import.cshtml @@ -0,0 +1,14 @@ +@model HHWMS.Web.MaterialProcessImportVM +@inject IStringLocalizer Localizer; + + + + + + + + + + + + diff --git a/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Index.cshtml b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Index.cshtml new file mode 100644 index 0000000..1299463 --- /dev/null +++ b/HHWMS.Web/Areas/Configs/Views/MaterialProcess/Index.cshtml @@ -0,0 +1,13 @@ +@model HHWMS.Web.MaterialProcessListVM +@inject IStringLocalizer Localizer; + + + + + + + + + + + diff --git a/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs b/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs index 15aa9c2..a5edf52 100644 --- a/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.cs +++ b/HHWMS.Web/Areas/Inventory/Controllers/InventoryController.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 { @@ -224,5 +225,125 @@ namespace HHWMS.Web.Controllers } #endregion + #region InvOut 出库 + [ActionDescription("TaskType.Out")] + public ActionResult InvOut(string id) + { + var vm = Wtm.CreateVM(id); + if (vm.Entity.TaskStatus == InventoryTaskStatusEnum.Locked) + { + return FFResult().Alert("所选库存已被锁定!,请检查后重试!").RefreshGrid(); + } + return PartialView(vm); + } + + [HttpPost] + [ActionDescription("TaskType.Out")] + public ActionResult InvOut(InventoryVM vm) + { + var id = vm.Entity.ID; + // 校验参数 + if (string.IsNullOrWhiteSpace(vm.OutPort)) + { + return FFResult().Alert("出口必选,请选择后重试!"); + } + // 校验库存 + var inv = _unitWork.FindSingle(x => x.ID == id); + if (inv == null) + { + return FFResult().CloseDialog().Alert("所选库存不存在,请检查后重试!").RefreshGrid(); + } + if (inv.TaskStatus == InventoryTaskStatusEnum.Locked) + { + return FFResult().CloseDialog().Alert("所选库存已被锁定!,请检查后重试!").RefreshGrid(); + } + + // 校验容器 + var container = _unitWork.FindSingle(x => x.Code == inv.ContainerCode); + if (container == null) + { + return FFResult().CloseDialog().Alert("所选库存的容器不存在,请检查后重试!").RefreshGrid(); + } + + if (container.IsLock == ContainerLockEnum.任务锁) + { + return FFResult().CloseDialog().Alert("库存所在容器已被锁定!,请检查后重试!").RefreshGrid(); + } + + // 校验库位 + var location = _unitWork.FindSingle(x => x.Code == inv.LocationCode); + if (location == null) + { + return FFResult().CloseDialog().Alert("所选库存不在库内,请检查后重试!").RefreshGrid(); + } + + if (location.Status == LocationStatusEnum.锁定) + { + return FFResult().CloseDialog().Alert("库存所在仓位已被锁定!,请检查后重试!").RefreshGrid(); + } + + // 创建任务 + var task = new TaskHeader() + { + TaskNo = _unitWork.GetSerialNumber("Out", 6), + ZoneId = inv.ZoneId, + TaskType = TaskTypeEnum.出库, + FromLocation = inv.LocationCode, + ToLocation = vm.OutPort, + ContainerCode = inv.ContainerCode, + RoadWay = 1, + Status = TaskStatusEnum.新建, + CreateBy = Wtm.LoginUserInfo.ITCode, + CreateTime = DateTime.Now + }; + + // 6. 调用WCS接口下发任务 + var wcsTaskModel = new WCSTaskModel + { + TaskNo = task.TaskNo, + PalletNo = task.ContainerCode, + FromLocation = task.FromLocation, // 入库任务起始位置为空 + ToLocation = task.ToLocation, + }; + + //调用WCS任务下发接口 + var wcsResult = Wtm.CallAPI("WCSXB", "TaskAssign", HttpMethodEnum.POST, wcsTaskModel).Result.Data; + + if (wcsResult != null && wcsResult.Success) + { + // WCS任务下发成功 + task.Status = TaskStatusEnum.已下发; + _unitWork.Add(task); + + // 更新库存 + inv.TaskStatus = InventoryTaskStatusEnum.Locked; + inv.UpdateTime = DateTime.Now; + _unitWork.Update(inv); + + // 更新容器 + // _unitWork.BatchUpdate(x => x.Code == task.ContainerCode, x => new Container() + // { + // IsLock = ContainerLockEnum.任务锁, + // UpdateTime = DateTime.Now + // }); + container.IsLock = ContainerLockEnum.任务锁; + container.UpdateTime = DateTime.Now; + _unitWork.Update(container); + + // 更新库位 + location.Status = LocationStatusEnum.锁定; + location.UpdateTime = DateTime.Now; + _unitWork.Update(location); + + return FFResult().CloseDialog().Message("出库任务创建成功").RefreshGrid(); + } + else + { + // WCS任务下发失败 + return FFResult().CloseDialog().Message(wcsResult?.Msg ?? "WCS任务下发失败").RefreshGrid(); + } + + } + #endregion } } diff --git a/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryListVM.cs b/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryListVM.cs index f22fa02..6661b95 100644 --- a/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryListVM.cs +++ b/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryListVM.cs @@ -25,6 +25,8 @@ namespace HHWMS.Web this.MakeStandardAction("Inventory", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "inventory", dialogWidth: 800), this.MakeStandardAction("Inventory", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "inventory", dialogWidth: 800), this.MakeStandardAction("Inventory", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "inventory"), + this.MakeAction("Inventory","InvOut",Localizer["TaskType.Out"],"",GridActionParameterTypesEnum.SingleId,"inventory") + .SetSize(500,400), }; } diff --git a/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryVM.cs b/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryVM.cs index a996d6a..04ab70a 100644 --- a/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryVM.cs +++ b/HHWMS.Web/Areas/Inventory/ViewModels/InventoryVMs/InventoryVM.cs @@ -13,6 +13,10 @@ namespace HHWMS.Web public partial class InventoryVM : BaseCRUDVM { public List AllZones { get; set; } + public List AllOutPorts { get; set; } + + [Display(Name = "Location.OutPort", Description = "拣货口")] + public string OutPort { get; set; } public InventoryVM() { @@ -22,6 +26,16 @@ namespace HHWMS.Web protected override void InitVM() { AllZones = DC.Set().GetSelectListItems(Wtm, y => y.Name); + AllOutPorts = new List + { + new ComboSelectListItem { Text = "拣货口1", Value = "EnterExit_P2001" }, + new ComboSelectListItem { Text = "拣货口2", Value = "EnterExit_P2003" }, + new ComboSelectListItem { Text = "拣货口3", Value = "EnterExit_P2005" }, + new ComboSelectListItem { Text = "拣货口4", Value = "EnterExit_P2007" }, + new ComboSelectListItem { Text = "拣货口5", Value = "EnterExit_P2009" }, + new ComboSelectListItem { Text = "拣货口6", Value = "EnterExit_P2011" }, + new ComboSelectListItem { Text = "拣货口7", Value = "EnterExit_P2013" } + }; } public override void DoAdd() diff --git a/HHWMS.Web/Areas/Inventory/Views/Inventory/InvOut.cshtml b/HHWMS.Web/Areas/Inventory/Views/Inventory/InvOut.cshtml new file mode 100644 index 0000000..d826d7c --- /dev/null +++ b/HHWMS.Web/Areas/Inventory/Views/Inventory/InvOut.cshtml @@ -0,0 +1,13 @@ +@model HHWMS.Web.InventoryVM +@inject IStringLocalizer Localizer; + + + + + + + + + + + diff --git a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs index 12899c6..9319336 100644 --- a/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs +++ b/HHWMS.Web/Areas/Receipt/Controllers/ReceiptInController.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using HHWMS.Web.Models; using System.Threading.Tasks; using System.Linq; +using Aliyun.OSS; using Microsoft.EntityFrameworkCore; using WalkingTec.Mvvm.Core.Extensions; @@ -16,10 +17,17 @@ namespace HHWMS.Web.Controllers public partial class ReceiptInController : BaseController { private readonly IUnitWork _unitWork; + private readonly Dictionary _materialZones; public ReceiptInController(IUnitWork unitwork) { _unitWork = unitwork; + _materialZones = new Dictionary + { + { "zone1", new LineRange { BeginLine = 1, EndLine = 25 } }, + { "zone2", new LineRange { BeginLine = 26, EndLine = 57 } }, + { "zone3", new LineRange { BeginLine = 58, EndLine = 96 } }, + }; } #region Index @@ -37,32 +45,68 @@ namespace HHWMS.Web.Controllers [HttpPost] public IActionResult GetOperators() { - // TODO: 从数据库获取操作员列表 - var operators = new List - { - new { value = "1", label = "张三" }, - new { value = "2", label = "李四" } - }; - return Json(new { Code = 200, Data = operators }); + var users = _unitWork.Find(x => x.ITCode != "Admin") + .Select(x => new {x.ITCode,x.Name}) + .ToList(); + return Json(new { Code = 200, Data = users}); } [HttpPost] public IActionResult GetProcesses() { - // TODO: 从数据库获取工序列表 - var processes = new List + try { - new { value = "1", label = "工序1" }, - new { value = "2", label = "工序2" } - }; - return Json(new { Code = 200, Data = processes }); + var processes = _unitWork.Find(x => x.IsActive) + .OrderBy(x => x.ProcessOrder) + .Select(x => new { + value = x.ID.ToString(), + label = x.ProcessName, + processCode = x.ProcessCode, + processName = x.ProcessName + }) + .ToList(); + return Json(new { Code = 200, Data = processes }); + } + catch (Exception ex) + { + return Json(new { Code = 500, Msg = $"获取工序列表失败:{ex.Message}" }); + } + } + + [HttpPost] + public IActionResult GetProcessesByMaterial(string materialCode) + { + try + { + if (string.IsNullOrWhiteSpace(materialCode)) + { + return Json(new { Code = 200, Data = new object[] { } }); + } + + var processes = _unitWork.Find(x => x.MaterialCode == materialCode && x.IsActive) + .OrderBy(x => x.ProcessOrder) + .Select(x => new { + value = x.ID.ToString(), + label = x.ProcessName, + processCode = x.ProcessCode, + processName = x.ProcessName + }) + .ToList(); + return Json(new { Code = 200, Data = processes }); + } + catch (Exception ex) + { + return Json(new { Code = 500, Msg = $"获取物料工序失败:{ex.Message}" }); + } } [HttpPost] public IActionResult GetOperatorInfo() { - // TODO: 获取当前登录用户信息 - return Json(new { Code = 200, Data = "当前操作员:张三" }); + var users = _unitWork.Find(x => x.ITCode != "Admin") + .Select(x => new {x.ITCode,x.Name}) + .ToList(); + return Json(new { Code = 200, Data = users}); } [HttpPost] @@ -80,38 +124,13 @@ namespace HHWMS.Web.Controllers [HttpPost] public IActionResult SubmitReceipt([FromBody] ReceiptInModel model) { - // 1. 查找可用库位信息 - 使用LocationVM的GetLocation方法 - var locationVM = Wtm.CreateVM(); - - // 创建WcsRequest对象,设置巷道号为1 - var wcsRequest = new WcsRequest { RoadWay = 1 }; - - // 调用GetLocation方法获取可用库位 - var locationResult = locationVM.GetLocation(wcsRequest); - - if (!locationResult.Status) - { - return Json(new { Code = 500, Msg = locationResult.Message }); - } - - // 获取返回的库位编码 - string locationCode = locationResult.Data.LocationCode; - - // 根据库位编码获取完整的库位信息,使用AsNoTracking()避免实体跟踪冲突 - // var availableLocation = DC.Set().AsNoTracking().FirstOrDefault(l => l.Code == locationCode); - // - // if (availableLocation == null) - // { - // return Json(new { Code = 500, Msg = "没有可用库位" }); - // } - // 获取物料信息 var material = _unitWork.FindSingle(m => m.MaterialCode == model.MaterialCode); if (material == null) { return Json(new { Code = 500, Msg = "物料不存在" }); } - + // 获取容器信息 var container = _unitWork.FindSingle(c => c.Code == model.PalletCode); if (container == null) @@ -119,15 +138,35 @@ namespace HHWMS.Web.Controllers return Json(new { Code = 500, Msg = "容器不存在" }); } + // 从字典查询工序对应的区域 + var processName = _unitWork.FindSingle(x => x.DictType == "ProcessZone" + && x.DictLabel == model.ProcessName)?.DictValue; + + if (string.IsNullOrEmpty(processName)) + { + return Json(new { Code = 500, Msg = "未找到此工序配置" }); + } + + // 1. 查找可用库位信息 + var locationVm = Wtm.CreateVM(); + var locationCode = locationVm.GetEmptyLocationFromXb(_materialZones[processName].BeginLine, _materialZones[processName].EndLine); + + if (string.IsNullOrWhiteSpace(locationCode)) + { + return Json(new { Code = 500, Msg = "未找到可用的空仓位" }); + } + // 使用事务 using (var tran = DC.BeginTransaction()) { try { + var zone = _unitWork.FindSingle(x => x.Name == "线边库"); // 2. 生成入库任务 var taskNo = _unitWork.GetSerialNumber("In", 6); var taskHeader = new TaskHeader { + ZoneId = zone.ID, TaskNo = taskNo, TaskType = TaskTypeEnum.入库, FromLocation = "", @@ -144,13 +183,15 @@ namespace HHWMS.Web.Controllers // 3. 创建库存信息 var inventory = new Inventory { + ZoneId = zone.ID, ContainerCode = model.PalletCode, LocationCode = locationCode, MaterialCode = model.MaterialCode, MaterialName = material.MaterialName, MaterialSpec = material.MaterialSpec, MaterialUnit = material.MaterialUnit, - Qty = model.Quantity, + Batch = model.ProcessName, + Lot = model.ProcessId.ToString(), TaskStatus = InventoryTaskStatusEnum.Locked, CreateBy = model.OperatorId, CreateTime = DateTime.Now @@ -158,33 +199,32 @@ namespace HHWMS.Web.Controllers _unitWork.Add(inventory); - // 4. 创建库存交易记录 - var transaction = new InventoryTransaction - { - Type = InventoryTranType.入库, - ContainerCode = model.PalletCode, - LocationCode = locationCode, - MaterialCode = model.MaterialCode, - MaterialName = material.MaterialName, - MaterialSpec = material.MaterialSpec, - MaterialUnit = material.MaterialUnit, - Qty = model.Quantity, - CreateBy = model.OperatorId, - CreateTime = DateTime.Now - }; - - _unitWork.Add(transaction); - // 5. 锁定容器和库位 container.IsLock = ContainerLockEnum.任务锁; + container.Status = ContainerStatus.有; container.LocationCode = locationCode; _unitWork.Update(container); // 从数据库中重新获取库位实体,避免实体跟踪冲突 var locationToUpdate = _unitWork.FindSingle(l => l.Code == locationCode); - locationToUpdate.Status = LocationStatusEnum.Locked; - locationToUpdate.ContainerCode = model.PalletCode; - _unitWork.Update(locationToUpdate); + + var resultNum = _unitWork.BatchUpdate(x => x.Code == locationCode && x.Version == locationToUpdate.Version, + x => new Location() + { + Status = LocationStatusEnum.锁定, + ContainerStatus = LocationStatus.有货, + ContainerCode = model.PalletCode, + UpdateTime = DateTime.Now, + UpdateBy = "WMS", + Version = Guid.NewGuid() + }); + + if (resultNum == 0) + { + //失败 回滚 + tran.Rollback(); + return Json(new { Code = 500, Msg = "更新仓位失败!请重新提交!"}); + } // 6. 调用WCS接口下发任务 var wcsTaskModel = new WCSTaskModel @@ -196,7 +236,7 @@ namespace HHWMS.Web.Controllers }; // 调用WCS任务下发接口 - var wcsResult = Wtm.CallAPI("WCS", "TaskAssign", HttpMethodEnum.POST, wcsTaskModel).Result.Data; + var wcsResult = Wtm.CallAPI("WCSXB", "TaskAssign", HttpMethodEnum.POST, wcsTaskModel).Result.Data; if (wcsResult != null && wcsResult.Success) { @@ -220,6 +260,115 @@ namespace HHWMS.Web.Controllers } } + /// + /// 空托盘入库 + /// + /// + /// + [HttpPost] + public IActionResult SubmitEmptyPallet([FromBody] ReceiptInModel model) + { + // 获取容器信息 + var container = _unitWork.FindSingle(c => c.Code == model.PalletCode); + if (container == null) + { + return Json(new { Code = 500, Msg = "容器不存在" }); + } + + // 1. 查找可用库位信息 + var locationVm = Wtm.CreateVM(); + var locationCode = locationVm.GetEmptyLocationFromXb(_materialZones["zone1"].BeginLine, _materialZones["zone1"].EndLine); + + if (string.IsNullOrWhiteSpace(locationCode)) + { + return Json(new { Code = 500, Msg = "未找到可用的空仓位" }); + } + + // 使用事务 + using (var tran = DC.BeginTransaction()) + { + try + { + var zone = _unitWork.FindSingle(x => x.Name == "线边库"); + // 2. 生成入库任务 + var taskNo = _unitWork.GetSerialNumber("In", 6); + var taskHeader = new TaskHeader + { + ZoneId = zone.ID, + TaskNo = taskNo, + TaskType = TaskTypeEnum.入库, + FromLocation = "", + ToLocation = locationCode, + ContainerCode = model.PalletCode, + RoadWay = 1, + Status = TaskStatusEnum.新建, + CreateBy = model.OperatorId, + CreateTime = DateTime.Now + }; + + _unitWork.Add(taskHeader); + + + // 5. 锁定容器和库位 + container.IsLock = ContainerLockEnum.任务锁; + container.LocationCode = locationCode; + container.Status = ContainerStatus.空; + _unitWork.Update(container); + + // 从数据库中重新获取库位实体,避免实体跟踪冲突 + var locationToUpdate = _unitWork.FindSingle(l => l.Code == locationCode); + + var resultNum = _unitWork.BatchUpdate(x => x.Code == locationCode && x.Version == locationToUpdate.Version, + x => new Location() + { + Status = LocationStatusEnum.锁定, + ContainerStatus = LocationStatus.空仓位, + ContainerCode = model.PalletCode, + UpdateTime = DateTime.Now, + UpdateBy = "WMS", + Version = Guid.NewGuid() + }); + + if (resultNum == 0) + { + //失败 回滚 + tran.Rollback(); + return Json(new { Code = 500, Msg = "更新仓位失败!请重新提交!"}); + } + + // 6. 调用WCS接口下发任务 + var wcsTaskModel = new WCSTaskModel + { + TaskNo = taskNo, + PalletNo = model.PalletCode, + FromLocation = "", // 入库任务起始位置为空 + ToLocation = locationCode, + }; + + // 调用WCS任务下发接口 + var wcsResult = Wtm.CallAPI("WCSXB", "TaskAssign", HttpMethodEnum.POST, wcsTaskModel).Result.Data; + + if (wcsResult != null && wcsResult.Success) + { + // WCS任务下发成功,提交事务 + tran.Commit(); + return Json(new { Code = 200, Msg = "入库成功", Data = new { TaskNo = taskNo } }); + } + else + { + // WCS任务下发失败,回滚事务 + tran.Rollback(); + return Json(new { Code = 500, Msg = wcsResult?.Msg ?? "WCS任务下发失败" }); + } + } + catch (System.Exception ex) + { + // 发生异常,回滚事务 + tran.Rollback(); + return Json(new { Code = 500, Msg = ex.Message }); + } + }} + /// /// 搜索物料 /// @@ -260,9 +409,16 @@ namespace HHWMS.Web.Controllers public string MaterialCode { get; set; } public string OrderId { get; set; } public string OperatorId { get; set; } - public string ProcessId { get; set; } - public int Quantity { get; set; } + public int ProcessId { get; set; } + public string ProcessName { get; set; } + public bool IsQualified { get; set; } public string OperatorInfo { get; set; } } + + public class LineRange + { + public int BeginLine { get; set; } + public int EndLine { get; set; } + } } \ No newline at end of file diff --git a/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml b/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml index 867e6a9..ab9df04 100644 --- a/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml +++ b/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml @@ -4,34 +4,23 @@ - + - - - - {{ item.label }} - - - - - + @@ -40,31 +29,26 @@ - - + + - + - + - - - {{ item.label }} - - + - + 上架入库 + 空托盘入库 重置 @@ -81,14 +65,26 @@ const app = createApp({ setup() { const formRef = ref(null); + const loading = ref(false); + const palletCodeRef = ref(null); const materialCodeRef = ref(null); - const orderSelect = ref(null); - const processSelect = ref(null); - const operatorSelect = ref(null); - const quantityInput = ref(null); - const isQualifiedSwitch = ref(null); - const loading = ref(false); + const operatorIdRef = ref(null); + const operatorInfoRef = ref(null); + + const inputRefs = { + palletCodeRef, + materialCodeRef, + operatorIdRef, + operatorInfoRef + }; + const focusNext = (nextRefName) => { + nextTick(() => { + if (inputRefs[nextRefName] && inputRefs[nextRefName].value && inputRefs[nextRefName].value.focus) { + inputRefs[nextRefName].value.focus(); + } + }); + }; const form = reactive({ palletCode: '', @@ -96,15 +92,11 @@ orderId: '', operatorId: '', processId: '', - quantity: 1, + processName:'', isQualified: true, operatorInfo: '' }); - - const orderOptions = ref([]); - const operatorOptions = ref([]); const processOptions = ref([]); - const materialOptions = ref([]); let searchTimer = null; @@ -115,35 +107,24 @@ materialCode: [ { required: true, message: '请输入物料码', trigger: ['change', 'blur'] } ], - orderId: [ - { required: true, message: '请选择生产订单', trigger: ['change', 'blur'] } - ], - operatorId: [ - { required: true, message: '请选择操作员工', trigger: ['change', 'blur'] } - ], + processId: [ { required: true, message: '请选择工序', trigger: ['change', 'blur'] } ], - quantity: [ - { required: true, type: 'number', message: '请输入数量', trigger: ['change', 'blur'] } + operatorId: [ + { required: true, message: '请输入操作员工信息', trigger: ['change', 'blur'] } ], + operatorInfo: [ { required: true, message: '请输入检验员信息', trigger: ['change', 'blur'] } ] }; - - // 加载操作员列表 - const loadOperators = () => { - $.ajax({ - type: "post", - dataType: "json", - url: "/receipt/ReceiptIn/GetOperators", - success: (json) => { - operatorOptions.value = json.Data; - } - }); - }; - + + const processSelect = (value) => { + form.processName = processOptions.value.find(item => item.value === value).processName; + focusNext('operatorIdRef'); + } + // 加载工序列表 const loadProcesses = () => { $.ajax({ @@ -151,19 +132,41 @@ dataType: "json", url: "/receipt/ReceiptIn/GetProcesses", success: (json) => { - processOptions.value = json.Data; + if (json.Code == 200) { + processOptions.value = json.Data; + } else { + Message.error(json.Msg || '加载工序列表失败'); + } + }, + error: (xhr, status, error) => { + Message.error('加载工序列表失败:' + error); } }); }; - // 加载当前操作员信息 - const loadOperatorInfo = () => { + // 根据物料加载工序列表 + const loadProcessesByMaterial = (materialCode) => { + if (!materialCode) { + processOptions.value = []; + return; + } + $.ajax({ type: "post", dataType: "json", - url: "/receipt/ReceiptIn/GetOperatorInfo", + data: { materialCode: materialCode }, + url: "/receipt/ReceiptIn/GetProcessesByMaterial", success: (json) => { - form.operatorInfo = json.Data; + if (json.Code == 200) { + processOptions.value = json.Data; + } else { + Message.error(json.Msg || '加载物料工序失败'); + processOptions.value = []; + } + }, + error: (xhr, status, error) => { + Message.error('加载物料工序失败:' + error); + processOptions.value = []; } }); }; @@ -220,28 +223,15 @@ const selectedMaterial = materialOptions.value.find(item => item.value === value); if (selectedMaterial) { form.materialCode = selectedMaterial.MaterialCode; - // 选择物料后加载相关订单 - scanMaterial(); + // 选择物料后加载相关工序 + loadProcessesByMaterial(selectedMaterial.MaterialCode); } }; // 扫描物料码 const scanMaterial = () => { if (!form.materialCode) return; - $.ajax({ - type: "post", - dataType: "json", - data: { materialCode: form.materialCode }, - url: "/receipt/ReceiptIn/GetOrdersByMaterial", - success: (json) => { - orderOptions.value = json.Data; - } - }); - }; - - // 生产订单变更 - const handleOrderChange = () => { - loadProcesses(); + loadProcessesByMaterial(form.materialCode); }; // 提交表单 @@ -260,7 +250,10 @@ Message.success('入库成功!'); resetForm(); } else { - Message.error(json.Msg || '入库失败!'); + Message.error({ + content: json.Msg || '入库失败!', + duration: 5000 // 设置为 5 秒 + }); } }, error: (xhr, status, error) => { @@ -276,10 +269,48 @@ }); }; + // 空托盘入库 + const submitEmptyPallet = () => { + if (!form.palletCode) { + Message.error('请输入托盘码!'); + return; + } + + loading.value = true; + const emptyPalletData = { + palletCode: form.palletCode, + operatorId: form.operatorId || 'SYSTEM' + }; + + $.ajax({ + type: "post", + dataType: "json", + contentType: "application/json", + data: JSON.stringify(emptyPalletData), + url: "/receipt/ReceiptIn/SubmitEmptyPallet", + success: (json) => { + if (json.Code == 200) { + Message.success('空托盘入库成功!'); + resetForm(); + } else { + Message.error({ + content: json.Msg || '空托盘入库失败!', + duration: 5000 + }); + } + }, + error: (xhr, status, error) => { + Message.error('提交失败:' + error); + }, + complete: () => { + loading.value = false; + } + }); + }; + // 重置表单 const resetForm = () => { formRef.value.resetFields(); - orderOptions.value = []; processOptions.value = []; setTimeout(() => { if (palletCodeRef.value) { @@ -288,40 +319,9 @@ }, 100); }; - // 焦点跳转到下一个输入框 - const focusNext = (nextRef) => { - const refMap = { - materialCodeRef: materialCodeRef, - quantityInput: quantityInput - }; - - const nextElement = refMap[nextRef]; - if (nextElement?.value) { - // 先让当前元素失去焦点 - if (document.activeElement) { - document.activeElement.blur(); - } - - // 使用 nextTick 确保 DOM 更新完成 - nextTick(() => { - if (nextElement.value.$el) { - // 处理 Input 组件 - const input = nextElement.value.$el.querySelector('input'); - if (input) { - input.focus(); - } - } else { - // 处理基础组件 - nextElement.value.focus(); - } - }); - } - }; // 生命周期钩子 onMounted(() => { - loadOperators(); - loadOperatorInfo(); // 页面加载时自动聚焦第一个输入框 setTimeout(() => { if (palletCodeRef.value) { @@ -332,28 +332,26 @@ return { formRef, - palletCodeRef, - materialCodeRef, - orderSelect, - processSelect, - operatorSelect, - quantityInput, - isQualifiedSwitch, form, loading, - orderOptions, - operatorOptions, processOptions, rules, scanPallet, scanMaterial, - handleOrderChange, submitForm, + submitEmptyPallet, resetForm, - focusNext, materialOptions, handleMaterialSearch, - handleMaterialSelect + handleMaterialSelect, + palletCodeRef, + materialCodeRef, + operatorIdRef, + operatorInfoRef, + focusNext, + loadProcesses, + loadProcessesByMaterial, + processSelect }; } }); diff --git a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistoryImportVM.cs b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistoryImportVM.cs index 9ed065f..caae054 100644 --- a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistoryImportVM.cs +++ b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistoryImportVM.cs @@ -12,8 +12,6 @@ namespace HHWMS.Web { public partial class TaskHeaderHistoryTemplateVM : BaseTemplateVM { - [Display(Name = "Task.ZoneCode")] - public ExcelPropety ZoneCode_Excel = ExcelPropety.CreateProperty(x => x.ZoneCode); [Display(Name = "Task.TaskNo")] public ExcelPropety TaskNo_Excel = ExcelPropety.CreateProperty(x => x.TaskNo); [Display(Name = "Task.TaskType")] diff --git a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistoryListVM.cs b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistoryListVM.cs index 124e4f4..ebae5d1 100644 --- a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistoryListVM.cs +++ b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistoryListVM.cs @@ -32,7 +32,7 @@ namespace HHWMS.Web protected override IEnumerable> InitGridHeader() { return new List>{ - this.MakeGridHeader(x => x.ZoneCode), + this.MakeGridHeader(x => x.Name_view), this.MakeGridHeader(x => x.TaskNo), this.MakeGridHeader(x => x.TaskType), this.MakeGridHeader(x => x.FromLocation), @@ -50,7 +50,7 @@ namespace HHWMS.Web public override IOrderedQueryable GetSearchQuery() { var query = DC.Set() - .CheckContain(Searcher.ZoneCode, x=>x.ZoneCode) + .CheckEqual(Searcher.ZoneId, x=>x.ZoneId) .CheckContain(Searcher.TaskNo, x=>x.TaskNo) .CheckEqual(Searcher.TaskType, x=>x.TaskType) .CheckContain(Searcher.FromLocation, x=>x.FromLocation) @@ -58,10 +58,11 @@ namespace HHWMS.Web .CheckContain(Searcher.ContainerCode, x=>x.ContainerCode) .CheckEqual(Searcher.RoadWay, x=>x.RoadWay) .CheckEqual(Searcher.Status, x=>x.Status) + .DPWhere(Wtm,x => x.ZoneId) .Select(x => new TaskHeaderHistory_View { ID = x.ID, - ZoneCode = x.ZoneCode, + Name_view = x.Zone.Name, TaskNo = x.TaskNo, TaskType = x.TaskType, FromLocation = x.FromLocation, @@ -79,7 +80,9 @@ namespace HHWMS.Web } - public class TaskHeaderHistory_View : TaskHeaderHistory{ - + public class TaskHeaderHistory_View : TaskHeaderHistory + { + [Display(Name = "Location.ZoneName")] + public String Name_view { get; set; } } } diff --git a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistorySearcher.cs b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistorySearcher.cs index 199482c..1c4488b 100644 --- a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistorySearcher.cs +++ b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistorySearcher.cs @@ -12,8 +12,9 @@ namespace HHWMS.Web { public partial class TaskHeaderHistorySearcher : BaseSearcher { - [Display(Name = "Task.ZoneCode")] - public String ZoneCode { get; set; } + public List AllZones { get; set; } + [Display(Name = "Location.ZoneName")] + public int? ZoneId { get; set; } [Display(Name = "Task.TaskNo")] public String TaskNo { get; set; } [Display(Name = "Task.TaskType")] @@ -29,8 +30,10 @@ namespace HHWMS.Web [Display(Name = "Task.Status")] public TaskStatusEnum? Status { get; set; } + protected override void InitVM() { + AllZones = DC.Set().GetSelectListItems(Wtm, y => y.Name); } } diff --git a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistoryVM.cs b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistoryVM.cs index 90b05ae..9402786 100644 --- a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistoryVM.cs +++ b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderHistoryVMs/TaskHeaderHistoryVM.cs @@ -12,13 +12,15 @@ namespace HHWMS.Web { public partial class TaskHeaderHistoryVM : BaseCRUDVM { - + public List AllZones { get; set; } public TaskHeaderHistoryVM() { + SetInclude(x => x.Zone); } protected override void InitVM() { + AllZones = DC.Set().GetSelectListItems(Wtm, y => y.Name); } public override void DoAdd() diff --git a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderImportVM.cs b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderImportVM.cs index ddaac55..6b9293d 100644 --- a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderImportVM.cs +++ b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderImportVM.cs @@ -12,8 +12,6 @@ namespace HHWMS.Web { public partial class TaskHeaderTemplateVM : BaseTemplateVM { - [Display(Name = "Task.ZoneCode")] - public ExcelPropety ZoneCode_Excel = ExcelPropety.CreateProperty(x => x.ZoneCode); [Display(Name = "Task.TaskNo")] public ExcelPropety TaskNo_Excel = ExcelPropety.CreateProperty(x => x.TaskNo); [Display(Name = "Task.TaskType")] diff --git a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderListVM.cs b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderListVM.cs index 614ce16..9084b02 100644 --- a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderListVM.cs +++ b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderListVM.cs @@ -12,13 +12,11 @@ namespace HHWMS.Web { public partial class TaskHeaderListVM : BasePagedListVM { - public List ZoneCodes { get; set; } public TaskDetailListVM2 TaskDetails { get; set; } = new TaskDetailListVM2(); protected override void InitVM() { var vm = Wtm.CreateVM(); - ZoneCodes = vm.ZoneCodes; TaskDetails.CopyContext(this); } @@ -46,12 +44,7 @@ namespace HHWMS.Web { InitVM(); return new List>{ - this.MakeGridHeader(x => x.ZoneCode) - .SetFormat((a, b) => - { - var data = ZoneCodes.FirstOrDefault(x => x.Value.ToString() == a.ZoneCode); - return data?.Text ?? a.ZoneCode; - }).SetWidth(150), + this.MakeGridHeader(x => x.Name_view).SetWidth(150), this.MakeGridHeader(x => x.TaskNo) .SetFormat((a,b) => { @@ -75,7 +68,7 @@ namespace HHWMS.Web public override IOrderedQueryable GetSearchQuery() { var query = DC.Set() - .CheckContain(Searcher.ZoneCode, x=>x.ZoneCode) + .CheckEqual(Searcher.ZoneId, x=>x.ZoneId) .CheckContain(Searcher.TaskNo, x=>x.TaskNo) .CheckEqual(Searcher.TaskType, x=>x.TaskType) .CheckContain(Searcher.FromLocation, x=>x.FromLocation) @@ -83,10 +76,11 @@ namespace HHWMS.Web .CheckContain(Searcher.ContainerCode, x=>x.ContainerCode) .CheckEqual(Searcher.RoadWay, x=>x.RoadWay) .CheckEqual(Searcher.Status, x=>x.Status) + .DPWhere(Wtm,x => x.ZoneId) .Select(x => new TaskHeader_View { ID = x.ID, - ZoneCode = x.ZoneCode, + Name_view = x.Zone.Name, TaskNo = x.TaskNo, TaskType = x.TaskType, FromLocation = x.FromLocation, @@ -105,6 +99,7 @@ namespace HHWMS.Web } public class TaskHeader_View : TaskHeader{ - + [Display(Name = "Location.ZoneName")] + public String Name_view { get; set; } } } diff --git a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderSearcher.cs b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderSearcher.cs index 54d918f..2493021 100644 --- a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderSearcher.cs +++ b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderSearcher.cs @@ -12,8 +12,9 @@ namespace HHWMS.Web { public partial class TaskHeaderSearcher : BaseSearcher { - [Display(Name = "Task.ZoneCode")] - public String ZoneCode { get; set; } + public List AllZones { get; set; } + [Display(Name = "Location.ZoneName")] + public int? ZoneId { get; set; } [Display(Name = "Task.TaskNo")] public String TaskNo { get; set; } [Display(Name = "Task.TaskType")] @@ -31,6 +32,7 @@ namespace HHWMS.Web protected override void InitVM() { + AllZones = DC.Set().GetSelectListItems(Wtm, y => y.Name); } } diff --git a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderVM.cs b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderVM.cs index 8e161a2..ecb3fd5 100644 --- a/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderVM.cs +++ b/HHWMS.Web/Areas/TaskManage/ViewModels/TaskHeaderVMs/TaskHeaderVM.cs @@ -12,15 +12,17 @@ namespace HHWMS.Web { public partial class TaskHeaderVM : BaseCRUDVM { - public List ZoneCodes { get; set; } + public List AllZones { get; set; } private IUnitWork _unitWork { get; set; } public TaskHeaderVM() { + SetInclude(x => x.Zone); } protected override void InitVM() { + AllZones = DC.Set().GetSelectListItems(Wtm, y => y.Name); } public override void DoAdd() diff --git a/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Create.cshtml b/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Create.cshtml index b64047a..db708d4 100644 --- a/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Create.cshtml +++ b/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Create.cshtml @@ -3,7 +3,7 @@ - + diff --git a/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Delete.cshtml b/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Delete.cshtml index 6302b27..a061fe5 100644 --- a/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Delete.cshtml +++ b/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Delete.cshtml @@ -3,19 +3,19 @@ @Localizer["Sys.DeleteConfirm"] - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Details.cshtml b/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Details.cshtml index d21351c..25974d8 100644 --- a/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Details.cshtml +++ b/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Details.cshtml @@ -3,7 +3,7 @@ - + diff --git a/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Edit.cshtml b/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Edit.cshtml index 213f853..23ef21f 100644 --- a/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Edit.cshtml +++ b/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Edit.cshtml @@ -3,7 +3,7 @@ - + diff --git a/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Index.cshtml b/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Index.cshtml index 60e7aa0..104493e 100644 --- a/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Index.cshtml +++ b/HHWMS.Web/Areas/TaskManage/Views/TaskHeader/Index.cshtml @@ -3,7 +3,7 @@ - + @@ -13,8 +13,8 @@ - - + +@* *@