diff --git a/HHWMS.Web/Areas/Api/IWCSController.cs b/HHWMS.Web/Areas/Api/IWCSController.cs index 553ef85..56d4ce2 100644 --- a/HHWMS.Web/Areas/Api/IWCSController.cs +++ b/HHWMS.Web/Areas/Api/IWCSController.cs @@ -30,14 +30,12 @@ namespace HHWMS.Web private readonly IMapper _mapper; private readonly IMemoryCache _cache; private const int DEBOUNCE_INTERVAL_MS = 1000; // 防抖间隔1秒 - private readonly PLCHelper _plcHelper; - public IWCSController(IUnitWork unitWork, IMapper mapper, IMemoryCache cache, PLCHelper plcHelper) + public IWCSController(IUnitWork unitWork, IMapper mapper, IMemoryCache cache) { _unitWork = unitWork; _mapper = mapper; _cache = cache; - _plcHelper = plcHelper; } /// @@ -108,14 +106,6 @@ namespace HHWMS.Web private async Task ProcessRequestIn(WcsRequest request) { // TODO: 实现具体的入库处理逻辑 - var t = 0; - var plc = new SiemensS7Net( SiemensPLCS.S1200, "10.211.55.4" ); - var read = await plc.ReadInt32Async( "V2634" ); - if (read.IsSuccess) - { - t = read.Content; - } - var write = await plc.WriteAsync( "V2634", t + 1 ); await Task.Delay(1000); // 模拟异步处理 } @@ -150,19 +140,36 @@ namespace HHWMS.Web var code = vm.GetLocation(request); if (code.Status) { - UpdateLocationAndContainer(code.Data.LocationCode, request.PalletNo); - return Task.FromResult(ApiResult(code.Data)); + var updateResult = UpdateLocationAndContainer(code.Data.LocationCode, request.PalletNo); + return Task.FromResult(updateResult); } return Task.FromResult(ApiResultError("没有符合条件的可用库位")); }); } - + + /// + /// 更新库位和容器 + /// + /// + /// + /// private IActionResult UpdateLocationAndContainer(string locationCode, string palletNo) { var location = _unitWork.Find(x => x.Code == locationCode).FirstOrDefault(); - location.ContainerCode = palletNo; - location.Status = LocationStatus.任务锁; - _unitWork.Update(location); + var resultNum = _unitWork.BatchUpdate(x => x.Code == locationCode && x.Version == location.Version, + x => new Location() + { + ContainerCode = palletNo, + // Status = LocationStatus.任务锁, + UpdateTime = DateTime.Now, + UpdateBy = "WMS", + Version = Guid.NewGuid() + }); + if (resultNum == 0) + { + //失败 + return ApiResult(ApiResultError("更新仓位失败!请重新请求!")); + } var container = _unitWork.Find(x => x.Code == palletNo).FirstOrDefault(); if (container != null) @@ -173,117 +180,5 @@ namespace HHWMS.Web return ApiResult(new { LocationCode = location.Code }); } - - /// - /// PLC通信测试接口 - /// - /// 通信参数 - [HttpPost] - public async Task CommunicateWithPLC(PlcCommunicationRequest request) - { - if (request == null) - { - return ApiResultError("请求参数不能为空"); - } - - try - { - // 连接PLC - if (!_plcHelper.Connect(PlcType.Siemens, request.IpAddress)) - { - return ApiResultError(msg:"PLC连接失败"); - } - - try - { - // 根据操作类型执行不同的读写操作 - switch (request.OperationType) - { - case "ReadInt32": - var value = _plcHelper.ReadInt32(request.Address); - return ApiResult(new { Value = value }); - - case "WriteInt16": - if (!short.TryParse(request.Value, out short shortValue)) - { - return ApiResultError(msg: "无效的数值"); - } - var writeResult = _plcHelper.WriteInt16(request.Address, shortValue); - return ApiResult(new { Success = writeResult }); - - case "ReadBool": - var boolValue = _plcHelper.ReadBool(request.Address); - return ApiResult(new { Value = boolValue }); - - case "WriteBool": - if (!bool.TryParse(request.Value, out bool boolWriteValue)) - { - return ApiResultError("无效的布尔值"); - } - var boolWriteResult = _plcHelper.WriteBool(request.Address, boolWriteValue); - return ApiResult(new { Success = boolWriteResult }); - - case "ReadString": - if (!ushort.TryParse(request.StringLength, out ushort length)) - { - return ApiResultError("无效的字符串长度"); - } - var stringValue = _plcHelper.ReadString(request.Address, length); - return ApiResult(new { Value = stringValue }); - - case "WriteString": - if (!ushort.TryParse(request.StringLength, out ushort writeLength)) - { - return ApiResultError("无效的字符串长度"); - } - var stringWriteResult = _plcHelper.WriteString(request.Address, request.Value, writeLength); - return ApiResult(new { Success = stringWriteResult }); - - default: - return ApiResultError("不支持的操作类型"); - } - } - finally - { - // 确保操作完成后断开连接 - _plcHelper.Disconnect(); - } - } - catch (Exception ex) - { - return ApiResultError($"PLC操作失败: {ex.Message}"); - } - } - - /// - /// PLC通信请求参数类 - /// - public class PlcCommunicationRequest - { - /// - /// PLC的IP地址 - /// - public string IpAddress { get; set; } - - /// - /// 操作类型(ReadInt16, WriteInt16, ReadBool, WriteBool, ReadString, WriteString) - /// - public string OperationType { get; set; } - - /// - /// PLC地址(例如"DB1.0") - /// - public string Address { get; set; } - - /// - /// 要写入的值(用于写操作) - /// - public string Value { get; set; } - - /// - /// 字符串长度(用于字符串操作) - /// - public string StringLength { get; set; } - } } } diff --git a/HHWMS.Web/Areas/Configs/Controllers/LocationController.cs b/HHWMS.Web/Areas/Configs/Controllers/LocationController.cs index 0c277f8..aad58a3 100644 --- a/HHWMS.Web/Areas/Configs/Controllers/LocationController.cs +++ b/HHWMS.Web/Areas/Configs/Controllers/LocationController.cs @@ -1,11 +1,11 @@ -using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using System; +using System.Collections.Generic; using WalkingTec.Mvvm.Core; using WalkingTec.Mvvm.Mvc; using WalkingTec.Mvvm.Core.Extensions; using HHWMS.Web; -using System.Collections.Generic; using HHWMS.Web.Models; namespace HHWMS.Web.Controllers @@ -14,11 +14,13 @@ namespace HHWMS.Web.Controllers [ActionDescription("库位管理")] public partial class LocationController : BaseController { - private readonly IUnitWork _unitwork; + private readonly IUnitWork _unitWork; + public LocationController(IUnitWork unitWork) { - _unitwork = unitWork; + _unitWork = unitWork; } + #region Search [ActionDescription("Sys.Search")] public ActionResult Index() @@ -140,7 +142,6 @@ namespace HHWMS.Web.Controllers public ActionResult Details(string id) { var vm = Wtm.CreateVM(id); - vm.Inventorys.SearcherMode = ListVMSearchModeEnum.MasterDetail; return PartialView(vm); } #endregion @@ -259,16 +260,16 @@ namespace HHWMS.Web.Controllers locationList.Add(new Location { Code = $"{vm.Entity.Type}{vm.Entity.RoadWay.ToString().PadLeft(2, '0')}-{row.ToString().PadLeft(2, '0')}-{line.ToString().PadLeft(2, '0')}-{layer.ToString().PadLeft(2, '0')}", - ZoneCode = vm.Entity.ZoneCode, + LocationZoneId = vm.Entity.LocationZoneId, Type = vm.Entity.Type, RoadWay = vm.Entity.RoadWay, Row = row, Line = line, Layer = layer, - RowFlag = (short?)(vm.RoadwayType == 1 || vm.RoadwayType == 2 ? 0 : (row == 1 || row == 4 ? 1 : 0)), + 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 = LocationStatus.空仓位, + Status = LocationStatusEnum.Empty, Length = vm.Entity.Length, Width = vm.Entity.Width, Height = vm.Entity.Height @@ -276,16 +277,11 @@ namespace HHWMS.Web.Controllers } } } - _unitwork.BatchAdd(locationList.ToArray()); + _unitWork.BatchAdd(locationList.ToArray()); return FFResult().CloseDialog().RefreshGrid(); } } #endregion 新增库位 - [ActionDescription("Sys.Print")] - public ActionResult Print() - { - return Ok(); - } - + } } diff --git a/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationBatchVM.cs b/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationBatchVM.cs index a851511..1c1497c 100644 --- a/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationBatchVM.cs +++ b/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationBatchVM.cs @@ -1,5 +1,12 @@ -using HHWMS.Web.Models; +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 { @@ -10,15 +17,19 @@ namespace HHWMS.Web ListVM = new LocationListVM(); LinkedVM = new Location_BatchEdit(); } + } - /// + /// /// Class to define batch edit fields /// public class Location_BatchEdit : BaseVM { + protected override void InitVM() { } + } + } diff --git a/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationImportVM.cs b/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationImportVM.cs index edfb194..c1f24ce 100644 --- a/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationImportVM.cs +++ b/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationImportVM.cs @@ -1,59 +1,58 @@ +using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using HHWMS.Web.Models; +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 LocationTemplateVM : BaseTemplateVM { + public ExcelPropety LocationZone_Excel = ExcelPropety.CreateProperty(x => x.LocationZoneId); [Display(Name = "Location.Code")] public ExcelPropety Code_Excel = ExcelPropety.CreateProperty(x => x.Code); - [Display(Name = "Location.Type")] public ExcelPropety Type_Excel = ExcelPropety.CreateProperty(x => x.Type); - [Display(Name = "Location.Status")] public ExcelPropety Status_Excel = ExcelPropety.CreateProperty(x => x.Status); - - [Display(Name = "Location.Row")] - public ExcelPropety Row_Excel = ExcelPropety.CreateProperty(x => x.Row); - - [Display(Name = "Location.Line")] - public ExcelPropety Line_Excel = ExcelPropety.CreateProperty(x => x.Line); - - [Display(Name = "Location.Layer")] - public ExcelPropety Layer_Excel = ExcelPropety.CreateProperty(x => x.Layer); - [Display(Name = "Location.RoadWay")] public ExcelPropety RoadWay_Excel = ExcelPropety.CreateProperty(x => x.RoadWay); - + [Display(Name = "Location.Row")] + public ExcelPropety Row_Excel = ExcelPropety.CreateProperty(x => x.Row); + [Display(Name = "Location.Line")] + public ExcelPropety Line_Excel = ExcelPropety.CreateProperty(x => x.Line); + [Display(Name = "Location.Layer")] + public ExcelPropety Layer_Excel = ExcelPropety.CreateProperty(x => x.Layer); + [Display(Name = "Location.RowFlag")] + public ExcelPropety RowFlag_Excel = ExcelPropety.CreateProperty(x => x.RowFlag); [Display(Name = "Location.ContainerCode")] public ExcelPropety ContainerCode_Excel = ExcelPropety.CreateProperty(x => x.ContainerCode); - - [Display(Name = "Location.ZoneCode")] - public ExcelPropety ZoneCode_Excel = ExcelPropety.CreateProperty(x => x.ZoneCode); - [Display(Name = "Location.IsStop")] public ExcelPropety IsStop_Excel = ExcelPropety.CreateProperty(x => x.IsStop); - [Display(Name = "System.Length")] public ExcelPropety Length_Excel = ExcelPropety.CreateProperty(x => x.Length); - [Display(Name = "System.Width")] public ExcelPropety Width_Excel = ExcelPropety.CreateProperty(x => x.Width); - [Display(Name = "System.Height")] public ExcelPropety Height_Excel = ExcelPropety.CreateProperty(x => x.Height); - [Display(Name = "Location.ContiguousCode")] public ExcelPropety ContiguousCode_Excel = ExcelPropety.CreateProperty(x => x.ContiguousCode); - protected override void InitVM() + protected override void InitVM() { + LocationZone_Excel.DataType = ColumnDataType.ComboBox; + LocationZone_Excel.ListItems = DC.Set().GetSelectListItems(Wtm, y => y.Name); } + } public class LocationImportVM : BaseImportVM { + } + } diff --git a/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationListVM.cs b/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationListVM.cs index b69dc67..fd8da83 100644 --- a/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationListVM.cs +++ b/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationListVM.cs @@ -1,25 +1,18 @@ +using System; using System.Collections.Generic; using System.Linq; -using HHWMS.Web.Models; +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 LocationListVM : BasePagedListVM { - public List ZoneCodes { get; set; } - public List Types { get; set; } - public List LocationStatus { get; set; } - - protected override void InitVM() - { - var vm = Wtm.CreateVM(); - ZoneCodes = vm.ZoneCodes; - Types = vm.Types; - LocationStatus = vm.LocationStatus; - } - protected override List InitGridAction() { return new List @@ -33,40 +26,25 @@ namespace HHWMS.Web this.MakeStandardAction("Location", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "configs", dialogWidth: 800), this.MakeStandardAction("Location", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "configs"), this.MakeAction("Location","AddLocation",Localizer["Location.AddLocation"],Localizer["Location.AddLocation"],GridActionParameterTypesEnum.NoId,"configs"), - this.MakeAction("Location","Print",Localizer["Sys.Print"],Localizer["Sys.Print"],GridActionParameterTypesEnum.MultiIds,"configs") - .SetShowDialog(false).SetOnClickScript("print"), - + this.MakeAction("Location","Print",Localizer["Sys.Print"],"",GridActionParameterTypesEnum.MultiIds,"configs") + .SetShowDialog(false).SetOnClickScript("print"), }; } + protected override IEnumerable> InitGridHeader() { - 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; - }), - this.MakeGridHeader(x => x.Code, 120), - this.MakeGridHeader(x => x.Type) - .SetFormat((a, b) => - { - var data = Types.FirstOrDefault(x => x.Value.ToString() == a.Type); - return data?.Text ?? a.Type; - }), - this.MakeGridHeader(x => x.Status) - .SetFormat((a, b) => - { - var data = LocationStatus.FirstOrDefault(x => x.Value.ToString() == a.Status); - return data?.Text ?? a.Status; - }), - this.MakeGridHeader(x => x.Row), - this.MakeGridHeader(x => x.Line), - this.MakeGridHeader(x => x.Layer), - this.MakeGridHeader(x => x.RoadWay).SetHide(), + this.MakeGridHeader(x => x.Name_view), + this.MakeGridHeader(x => x.Code), + this.MakeGridHeader(x => x.Type), + this.MakeGridHeader(x => x.Status), this.MakeGridHeader(x => x.ContainerCode), + this.MakeGridHeader(x => x.RoadWay), + this.MakeGridHeader(x => x.Row).SetHide(), + this.MakeGridHeader(x => x.Line).SetHide(), + this.MakeGridHeader(x => x.Layer).SetHide(), + this.MakeGridHeader(x => x.RowFlag).SetHide(), this.MakeGridHeader(x => x.IsStop), this.MakeGridHeader(x => x.Length).SetHide(), this.MakeGridHeader(x => x.Width).SetHide(), @@ -79,29 +57,27 @@ namespace HHWMS.Web public override IOrderedQueryable GetSearchQuery() { var query = DC.Set() - .CheckContain(Searcher.Code, x => x.Code) - .CheckContain(Searcher.Type, x => x.Type) - .CheckContain(Searcher.Status, x => x.Status) - .CheckEqual(Searcher.Row, x => x.Row) - .CheckEqual(Searcher.Line, x => x.Line) - .CheckEqual(Searcher.Layer, x => x.Layer) - .CheckEqual(Searcher.RoadWay, x => x.RoadWay) - .CheckContain(Searcher.ContainerCode, x => x.ContainerCode) - .CheckContain(Searcher.ZoneCode, x => x.ZoneCode) - .CheckEqual(Searcher.IsStop, x => x.IsStop) - .CheckContain(Searcher.ContiguousCode, x => x.ContiguousCode) + .CheckEqual(Searcher.LocationZoneId, x=>x.LocationZoneId) + .CheckContain(Searcher.Code, x=>x.Code) + .CheckEqual(Searcher.Type, x=>x.Type) + .CheckEqual(Searcher.Status, x=>x.Status) + .CheckEqual(Searcher.RoadWay, x=>x.RoadWay) + .CheckEqual(Searcher.RowFlag, x=>x.RowFlag) + .CheckContain(Searcher.ContainerCode, x=>x.ContainerCode) + .CheckEqual(Searcher.IsStop, x=>x.IsStop) .Select(x => new Location_View { - ID = x.ID, + ID = x.ID, + Name_view = x.LocationZone.Name, Code = x.Code, Type = x.Type, Status = x.Status, + RoadWay = x.RoadWay, Row = x.Row, Line = x.Line, Layer = x.Layer, - RoadWay = x.RoadWay, + RowFlag = x.RowFlag, ContainerCode = x.ContainerCode, - ZoneCode = x.ZoneCode, IsStop = x.IsStop, Length = x.Length, Width = x.Width, @@ -111,9 +87,12 @@ namespace HHWMS.Web .OrderBy(x => x.ID); return query; } + } - public class Location_View : Location - { + public class Location_View : Location{ + [Display(Name = "Location.ZoneCode")] + public String Name_view { get; set; } + } } diff --git a/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationSearcher.cs b/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationSearcher.cs index 6eb7d2e..5b15c4e 100644 --- a/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationSearcher.cs +++ b/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationSearcher.cs @@ -1,46 +1,39 @@ -using System; +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 LocationSearcher : BaseSearcher { + public List AllLocationZones { get; set; } + [Display(Name = "Location.ZoneCode")] + public int? LocationZoneId { get; set; } [Display(Name = "Location.Code")] public String Code { get; set; } - [Display(Name = "Location.Type")] - public String Type { get; set; } - + public LocationTypeEnum? Type { get; set; } [Display(Name = "Location.Status")] - public String Status { get; set; } - - [Display(Name = "Location.Row")] - public Int16? Row { get; set; } - - [Display(Name = "Location.Line")] - public Int16? Line { get; set; } - - [Display(Name = "Location.Layer")] - public Int16? Layer { get; set; } - + public LocationStatusEnum? Status { get; set; } [Display(Name = "Location.RoadWay")] public Int16? RoadWay { get; set; } - + [Display(Name = "Location.RowFlag")] + public RowFlagEnum? RowFlag { get; set; } [Display(Name = "Location.ContainerCode")] public String ContainerCode { get; set; } - - [Display(Name = "Location.ZoneCode")] - public String ZoneCode { get; set; } - [Display(Name = "Location.IsStop")] public Boolean? IsStop { get; set; } - [Display(Name = "Location.ContiguousCode")] - public String ContiguousCode { get; set; } - protected override void InitVM() { + AllLocationZones = DC.Set().GetSelectListItems(Wtm, y => y.Name); } + } } diff --git a/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationVM.cs b/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationVM.cs index f270752..1d3a009 100644 --- a/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationVM.cs +++ b/HHWMS.Web/Areas/Configs/ViewModels/LocationVMs/LocationVM.cs @@ -1,79 +1,52 @@ +using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; -using HHWMS.Web.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.SqlServer.Query.Internal; +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 LocationVM : BaseCRUDVM { - public LocationVM() - { - } - - public InventoryListVM Inventorys { get; set; } = new InventoryListVM(); - + public List AllLocationZones { get; set; } + [Display(Name = "Location.BeginLine", Description = "起始列")] - [Required(ErrorMessage = "Validate.{0}required")] public short BeginLine { get; set; } [Display(Name = "Location.BeginLayer", Description = "起始层")] - [Required(ErrorMessage = "Validate.{0}required")] public short BeginLayer { get; set; } [Display(Name = "Location.RoadwayType", Description = "巷道类型")] [Required(ErrorMessage = "Validate.{0}required")] public short RoadwayType { get; set; } - - private IUnitWork _unitWork { get; set; } - public List RoadwayTypes { get; set; } - public List ZoneCodes { get; set; } - public List Types { get; set; } - public List LocationStatus { get; set; } + + + public LocationVM() + { + SetInclude(x => x.LocationZone); + } protected override void InitVM() { - Inventorys.CopyContext(this); - Inventorys.Searcher.LocationCode = Entity.Code; + 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 + { + Text = currentCulture == "zh" ? x.DictLabel : x.DictLabelUs, + Value = x.DictValue + }).ToList(); - //var tt = DC.Set().Where(x => x.ID > 1).Include(x => x.TaskDetails); - //_unitWork = new UnitWork(Wtm); - //var task = _unitWork.Find(x => x.ID > 1) - // .Include(x => x.TaskDetails) - // .FirstOrDefault(); - //var details = task.TaskDetails; - - var CurrentCulture = Wtm.CurrentCulture; - var dictDatas = DC.Set().ToList(); - RoadwayTypes = dictDatas.Where(x => x.DictType == "RoadwayType").Select(x => new ComboSelectListItem - { - Text = CurrentCulture == "zh" ? x.DictLabel : x.DictLabelUs, - Value = x.DictValue - }).ToList(); - ZoneCodes = dictDatas.Where(x => x.DictType == "ZoneCode").Select(x => new ComboSelectListItem - { - Text = CurrentCulture == "zh" ? x.DictLabel : x.DictLabelUs, - Value = x.DictValue - }).ToList(); - Types = dictDatas.Where(x => x.DictType == "LocationType").Select(x => new ComboSelectListItem - { - Text = CurrentCulture == "zh" ? x.DictLabel : x.DictLabelUs, - Value = x.DictValue - }).ToList(); - LocationStatus = dictDatas.Where(x => x.DictType == "LocationStatus").Select(x => new ComboSelectListItem - { - Text = CurrentCulture == "zh" ? x.DictLabel : x.DictLabelUs, - Value = x.DictValue - }).ToList(); } public override void DoAdd() - { + { base.DoAdd(); } @@ -94,7 +67,7 @@ namespace HHWMS.Web { var locations = DC.Set() .Where(l => l.RoadWay == roadway - && l.Status == "empty" + && l.Status == LocationStatusEnum.Empty && l.RowFlag == 0) // 单伸位只查找外仓位 .OrderBy(l => l.Layer) .ThenBy(l => l.Line) @@ -124,10 +97,10 @@ namespace HHWMS.Web // 1. 优先查找里外仓位都为空的里仓位 var emptyInnerLocation = locationPairs.Values - .Where(l => l.RowFlag == 1 - && l.Status == "empty" + .Where(l => l.RowFlag == RowFlagEnum.Inner + && l.Status == LocationStatusEnum.Empty && locationPairs.TryGetValue(l.ContiguousCode, out var outer) - && outer.Status == "empty") + && outer.Status == LocationStatusEnum.Empty) .OrderBy(l => l.Layer) .ThenBy(l => l.Line) .FirstOrDefault(); @@ -140,9 +113,9 @@ namespace HHWMS.Web // 2. 查找里仓位有货,外仓位为空的外仓位 var availableOuterLocation = locationPairs.Values .Where(l => l.RowFlag == 0 - && l.Status == "empty" + && l.Status == LocationStatusEnum.Empty && locationPairs.TryGetValue(l.ContiguousCode, out var inner) - && inner.Status == "some") + && inner.Status == LocationStatusEnum.Some) .OrderBy(l => l.Layer) .ThenBy(l => l.Line) .FirstOrDefault(); @@ -240,8 +213,7 @@ namespace HHWMS.Web l.RowFlag, l.Layer, l.Line, - l.RoadWay, - l.ZoneCode + l.RoadWay }) .ToDictionary(l => l.Code); @@ -265,13 +237,12 @@ namespace HHWMS.Web { case "2": // 单伸位 var singleLocations = roadwayLocations - .Where(l => l.RowFlag == 0 && l.Status == "empty") + .Where(l => l.RowFlag == 0 && l.Status == LocationStatusEnum.Empty) .OrderBy(l => l.Layer) .ThenBy(l => l.Line) .Select(l => new { LocationCode = l.Code, - l.ZoneCode, l.RoadWay, l.Layer, l.Line, @@ -283,16 +254,15 @@ namespace HHWMS.Web case "4": // 双伸位 // 1. 查找里外都为空的里仓位 var emptyInnerLocations = roadwayLocations - .Where(l => l.RowFlag == 1 - && l.Status == "empty" + .Where(l => l.RowFlag == RowFlagEnum.Inner + && l.Status == LocationStatusEnum.Empty && allLocations.TryGetValue(l.ContiguousCode, out var outer) - && outer.Status == "empty") + && outer.Status == LocationStatusEnum.Empty) .OrderBy(l => l.Layer) .ThenBy(l => l.Line) .Select(l => new { LocationCode = l.Code, - l.ZoneCode, l.RoadWay, l.Layer, l.Line, @@ -303,15 +273,14 @@ namespace HHWMS.Web // 2. 查找里仓位有货,外仓位为空的外仓位 var availableOuterLocations = roadwayLocations .Where(l => l.RowFlag == 0 - && l.Status == "empty" + && l.Status == LocationStatusEnum.Empty && allLocations.TryGetValue(l.ContiguousCode, out var inner) - && inner.Status == "some") + && inner.Status == LocationStatusEnum.Some) .OrderBy(l => l.Layer) .ThenBy(l => l.Line) .Select(l => new { LocationCode = l.Code, - l.ZoneCode, l.RoadWay, l.Layer, l.Line, diff --git a/HHWMS.Web/Areas/Configs/Views/Location/AddLocation.cshtml b/HHWMS.Web/Areas/Configs/Views/Location/AddLocation.cshtml index 619a82e..fc7e71a 100644 --- a/HHWMS.Web/Areas/Configs/Views/Location/AddLocation.cshtml +++ b/HHWMS.Web/Areas/Configs/Views/Location/AddLocation.cshtml @@ -2,19 +2,20 @@ @inject IStringLocalizer Localizer; - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/HHWMS.Web/Areas/Configs/Views/Location/Create.cshtml b/HHWMS.Web/Areas/Configs/Views/Location/Create.cshtml index 6819c04..86b7ef7 100644 --- a/HHWMS.Web/Areas/Configs/Views/Location/Create.cshtml +++ b/HHWMS.Web/Areas/Configs/Views/Location/Create.cshtml @@ -3,15 +3,16 @@ + - - + + + - + - diff --git a/HHWMS.Web/Areas/Configs/Views/Location/Delete.cshtml b/HHWMS.Web/Areas/Configs/Views/Location/Delete.cshtml index 7399a8f..51086ca 100644 --- a/HHWMS.Web/Areas/Configs/Views/Location/Delete.cshtml +++ b/HHWMS.Web/Areas/Configs/Views/Location/Delete.cshtml @@ -4,15 +4,16 @@ @Localizer["Sys.DeleteConfirm"] + + - + - diff --git a/HHWMS.Web/Areas/Configs/Views/Location/Details.cshtml b/HHWMS.Web/Areas/Configs/Views/Location/Details.cshtml index 5c72f80..d699504 100644 --- a/HHWMS.Web/Areas/Configs/Views/Location/Details.cshtml +++ b/HHWMS.Web/Areas/Configs/Views/Location/Details.cshtml @@ -1,26 +1,24 @@ -@model HHWMS.Web.LocationVM +@model HHWMS.Web.LocationVM @inject IStringLocalizer Localizer; + -@* + + - + - - *@ + - - - diff --git a/HHWMS.Web/Areas/Configs/Views/Location/Edit.cshtml b/HHWMS.Web/Areas/Configs/Views/Location/Edit.cshtml index eb1d45a..c0fc8d1 100644 --- a/HHWMS.Web/Areas/Configs/Views/Location/Edit.cshtml +++ b/HHWMS.Web/Areas/Configs/Views/Location/Edit.cshtml @@ -1,17 +1,18 @@ -@model HHWMS.Web.LocationVM +@model HHWMS.Web.LocationVM @inject IStringLocalizer Localizer; + - - + + + - + - diff --git a/HHWMS.Web/Areas/Configs/Views/Location/Index.cshtml b/HHWMS.Web/Areas/Configs/Views/Location/Index.cshtml index 0b53a0c..e1a5adf 100644 --- a/HHWMS.Web/Areas/Configs/Views/Location/Index.cshtml +++ b/HHWMS.Web/Areas/Configs/Views/Location/Index.cshtml @@ -1,22 +1,20 @@ -@model HHWMS.Web.LocationListVM +@model HHWMS.Web.LocationListVM @inject IStringLocalizer Localizer; - + -@* - - - - - - *@ -@**@ + + + + + +