修改
This commit is contained in:
@@ -142,7 +142,8 @@ public class BigScreenService : BaseService<Storagelocation>, IBigScreenService
|
||||
AlarmNum = layer.AlarmNum ?? 2, // 确认默认值
|
||||
PackageNum = layer.PackageNum ?? 0,
|
||||
IsLight = layer.IsLight == 1,
|
||||
IsFeedingMaterial = (layer.PackageNum ?? 0) <= (layer.AlarmNum ?? 2) && layer.IsLackAlarm == 1
|
||||
// IsFeedingMaterial = (layer.PackageNum ?? 0) < (layer.AlarmNum ?? 2) && layer.IsLackAlarm == 1
|
||||
IsFeedingMaterial = CalculateIsOneLayerNumFeedingMaterial(layer)
|
||||
}).ToArray();
|
||||
var rackDto = new BigScreenDto
|
||||
{
|
||||
@@ -150,7 +151,8 @@ public class BigScreenService : BaseService<Storagelocation>, IBigScreenService
|
||||
RackCode = group.Key,
|
||||
IsLight = layers.Any(l => l.IsLight == 1),
|
||||
IsInUse = layers.Any(l => l.IsLackAlarm == 1),
|
||||
IsFeedingMaterial = layers.Any(l => (l.PackageNum ?? 0) <= (l.AlarmNum ?? 2) && l.IsLackAlarm == 1),
|
||||
// IsFeedingMaterial = layers.Any(l => (l.PackageNum ?? 0) < (l.AlarmNum ?? 2) && l.IsLackAlarm == 1),
|
||||
IsFeedingMaterial = CalculateIsAllFeedingMaterial(layers),
|
||||
LayerObjectArray = layerObjects
|
||||
};
|
||||
result.Add(rackDto);
|
||||
@@ -158,4 +160,40 @@ public class BigScreenService : BaseService<Storagelocation>, IBigScreenService
|
||||
|
||||
return result;
|
||||
}
|
||||
// 将复杂逻辑封装到方法中
|
||||
private bool CalculateIsAllFeedingMaterial(List<Storagelocation> layers)
|
||||
{
|
||||
int OneTotalPackageNum = layers.Where(it => it.LayerNum == 1).Sum(it => it.PackageNum ?? 0);
|
||||
int SecondTotalPackageNum = layers.Where(it => it.LayerNum == 2).Sum(it => it.PackageNum ?? 0);
|
||||
int alarmNum = 2;
|
||||
if (layers.Any(ls => ls.Remark == "合并料架"))
|
||||
{
|
||||
alarmNum = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
alarmNum = layers[0].AlarmNum ?? 0;
|
||||
}
|
||||
return OneTotalPackageNum < alarmNum || SecondTotalPackageNum < alarmNum;
|
||||
|
||||
}
|
||||
|
||||
private bool CalculateIsOneLayerNumFeedingMaterial(Storagelocation layer)
|
||||
{
|
||||
if (layer.Remark == "合并料架")
|
||||
{
|
||||
int totalPackageNum = Context.Queryable<Storagelocation>()
|
||||
.Where(it => it.LayerNum == layer.LayerNum)
|
||||
.Where(it => it.RackCode == layer.RackCode)
|
||||
.Sum(it => it.PackageNum ?? 0);
|
||||
return totalPackageNum < 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (layer.PackageNum ?? 0) < (layer.AlarmNum ?? 2) && layer.IsLackAlarm == 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user