库位表重新生成,一些数据使用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,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,