库位表重新生成,一些数据使用enum type status

加上数据权限zoneCode
This commit is contained in:
zhougf committed 2025-04-30 19:59:47 +08:00
1 parent b0a6dcc035
commit b005422b01
25 files changed
+361 -541

No files matched your search

@@ -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();
}
}
/// <summary>
/// <summary>
/// Class to define batch edit fields
/// </summary>
public class Location_BatchEdit : BaseVM
{
protected override void InitVM()
{
}
}
}
@@ -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<Location>(x => x.LocationZoneId);
[Display(Name = "Location.Code")]
public ExcelPropety Code_Excel = ExcelPropety.CreateProperty<Location>(x => x.Code);
[Display(Name = "Location.Type")]
public ExcelPropety Type_Excel = ExcelPropety.CreateProperty<Location>(x => x.Type);
[Display(Name = "Location.Status")]
public ExcelPropety Status_Excel = ExcelPropety.CreateProperty<Location>(x => x.Status);
[Display(Name = "Location.Row")]
public ExcelPropety Row_Excel = ExcelPropety.CreateProperty<Location>(x => x.Row);
[Display(Name = "Location.Line")]
public ExcelPropety Line_Excel = ExcelPropety.CreateProperty<Location>(x => x.Line);
[Display(Name = "Location.Layer")]
public ExcelPropety Layer_Excel = ExcelPropety.CreateProperty<Location>(x => x.Layer);
[Display(Name = "Location.RoadWay")]
public ExcelPropety RoadWay_Excel = ExcelPropety.CreateProperty<Location>(x => x.RoadWay);
[Display(Name = "Location.Row")]
public ExcelPropety Row_Excel = ExcelPropety.CreateProperty<Location>(x => x.Row);
[Display(Name = "Location.Line")]
public ExcelPropety Line_Excel = ExcelPropety.CreateProperty<Location>(x => x.Line);
[Display(Name = "Location.Layer")]
public ExcelPropety Layer_Excel = ExcelPropety.CreateProperty<Location>(x => x.Layer);
[Display(Name = "Location.RowFlag")]
public ExcelPropety RowFlag_Excel = ExcelPropety.CreateProperty<Location>(x => x.RowFlag);
[Display(Name = "Location.ContainerCode")]
public ExcelPropety ContainerCode_Excel = ExcelPropety.CreateProperty<Location>(x => x.ContainerCode);
[Display(Name = "Location.ZoneCode")]
public ExcelPropety ZoneCode_Excel = ExcelPropety.CreateProperty<Location>(x => x.ZoneCode);
[Display(Name = "Location.IsStop")]
public ExcelPropety IsStop_Excel = ExcelPropety.CreateProperty<Location>(x => x.IsStop);
[Display(Name = "System.Length")]
public ExcelPropety Length_Excel = ExcelPropety.CreateProperty<Location>(x => x.Length);
[Display(Name = "System.Width")]
public ExcelPropety Width_Excel = ExcelPropety.CreateProperty<Location>(x => x.Width);
[Display(Name = "System.Height")]
public ExcelPropety Height_Excel = ExcelPropety.CreateProperty<Location>(x => x.Height);
[Display(Name = "Location.ContiguousCode")]
public ExcelPropety ContiguousCode_Excel = ExcelPropety.CreateProperty<Location>(x => x.ContiguousCode);
protected override void InitVM()
protected override void InitVM()
{
LocationZone_Excel.DataType = ColumnDataType.ComboBox;
LocationZone_Excel.ListItems = DC.Set<LocationZone>().GetSelectListItems(Wtm, y => y.Name);
}
}
public class LocationImportVM : BaseImportVM<LocationTemplateVM, Location>
{
}
}
@@ -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<Location_View, LocationSearcher>
{
public List<ComboSelectListItem> ZoneCodes { get; set; }
public List<ComboSelectListItem> Types { get; set; }
public List<ComboSelectListItem> LocationStatus { get; set; }
protected override void InitVM()
{
var vm = Wtm.CreateVM<LocationVM>();
ZoneCodes = vm.ZoneCodes;
Types = vm.Types;
LocationStatus = vm.LocationStatus;
}
protected override List<GridAction> InitGridAction()
{
return new List<GridAction>
@@ -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<IGridColumn<Location_View>> InitGridHeader()
{
InitVM();
return new List<GridColumn<Location_View>>{
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<Location_View> GetSearchQuery()
{
var query = DC.Set<Location>()
.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; }
}
}
@@ -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<ComboSelectListItem> 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<LocationZone>().GetSelectListItems(Wtm, y => y.Name);
}
}
}
@@ -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<Location>
{
public LocationVM()
{
}
public InventoryListVM Inventorys { get; set; } = new InventoryListVM();
public List<ComboSelectListItem> 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<ComboSelectListItem> RoadwayTypes { get; set; }
public List<ComboSelectListItem> ZoneCodes { get; set; }
public List<ComboSelectListItem> Types { get; set; }
public List<ComboSelectListItem> LocationStatus { get; set; }
public LocationVM()
{
SetInclude(x => x.LocationZone);
}
protected override void InitVM()
{
Inventorys.CopyContext(this);
Inventorys.Searcher.LocationCode = Entity.Code;
AllLocationZones = DC.Set<LocationZone>().GetSelectListItems(Wtm, y => y.Name);
var currentCulture = Wtm.CurrentCulture;
var dictData = DC.Set<SysDictData>().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<TaskHeader>().Where(x => x.ID > 1).Include(x => x.TaskDetails);
//_unitWork = new UnitWork(Wtm);
//var task = _unitWork.Find<TaskHeader>(x => x.ID > 1)
// .Include(x => x.TaskDetails)
// .FirstOrDefault();
//var details = task.TaskDetails;
var CurrentCulture = Wtm.CurrentCulture;
var dictDatas = DC.Set<SysDictData>().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<Location>()
.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,