using Admin.NET.Core.Service;
|
using Elastic.Clients.Elasticsearch;
|
using Furion.Logging;
|
using Qiniu.Storage;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace WCS.Application;
|
public static class AGVStorageUtil
|
{
|
private static readonly ISqlSugarClient _db = SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId);
|
private static readonly SysCacheService sysCacheService = App.GetRequiredService<SysCacheService>();
|
private static readonly SysConfigService _sysConfigService = App.GetRequiredService<SysConfigService>();
|
private static List<string[]> listStorage = new List<string[]>();
|
private static string[] listPallet = new[] { "cache_Z53", "cache_Z52", "cache_Z51" };
|
static AGVStorageUtil()
|
{
|
listStorage.Add(new[] { "cache_Z11", "cache_Z12", "cache_Z13" });
|
listStorage.Add(new[] { "cache_Z21", "cache_Z22", "cache_Z23" });
|
listStorage.Add(new[] { "cache_Z31", "cache_Z32", "cache_Z33" });
|
listStorage.Add(new[] { "cache_Z41", "cache_Z42", "cache_Z43" });
|
}
|
/// <summary>
|
/// 获取成品数量
|
/// </summary>
|
/// <returns></returns>
|
public static int ProductCount()
|
{
|
int i = 0;
|
foreach (var item in listStorage)
|
{
|
foreach (var mod in item.Reverse())
|
{
|
var value = _sysConfigService.GetConfigValue<bool>(mod).Result;
|
if (value)
|
i++;
|
}
|
}
|
return i;
|
}
|
/// <summary>
|
/// 获取成品要入的储位
|
/// </summary>
|
/// <returns></returns>
|
public static string GetProductInStorage(string TaskNo = "")
|
{
|
List<string> listResult = new List<string>();
|
foreach (var item in listStorage)
|
{
|
List<string> listItem = new List<string>();
|
foreach (var mod in item.Reverse())
|
{
|
var value = _sysConfigService.GetConfigValue<bool>(mod).Result;
|
if (!value)
|
listItem.Add(mod.Split('_')[1]);
|
else
|
break;
|
}
|
listResult.AddRange(listItem.AsEnumerable().Reverse());
|
}
|
//检查是否有正在入的任务
|
foreach (var result in listResult)
|
{
|
if (!_db.Queryable<WcsTask>().Where(s => s.Type == PLCTypeEnum.AGV && s.Status <= TaskStatusEnum.Doing && s.EndLocate == result && s.TaskNo != TaskNo).Any())
|
return result;
|
}
|
return "";
|
//Log.Error("无可入的储位");
|
//throw Oops.Bah("无可入的储位");
|
}
|
/// <summary>
|
/// 获取成品要出的储位
|
/// </summary>
|
/// <returns></returns>
|
public static string GetProductOutStorage()
|
{
|
foreach (var item in listStorage.AsEnumerable().Reverse())
|
{
|
foreach (var mod in item.Reverse())
|
{
|
var value = _sysConfigService.GetConfigValue<bool>(mod).Result;
|
if (value)
|
return mod.Split('_')[1];
|
}
|
}
|
return "";
|
//Log.Error("无可出的储位");
|
//throw Oops.Bah("无可出的储位");
|
}
|
/// <summary>
|
/// 获取托盘要入的储位
|
/// </summary>
|
/// <returns></returns>
|
public static string GetPalletInStorage(string TaskNo = "")
|
{
|
List<string> listResult = new List<string>();
|
foreach (var item in listPallet)
|
{
|
var value = _sysConfigService.GetConfigValue<bool>(item).Result;
|
if (!value)
|
listResult.Add(item.Split('_')[1]);
|
else
|
break;
|
}
|
//检查是否有正在入的任务
|
foreach (var result in listResult.AsEnumerable().Reverse())
|
{
|
if (!_db.Queryable<WcsTask>().Where(s => s.Type == PLCTypeEnum.AGV && s.Status <= TaskStatusEnum.Doing && s.EndLocate == result && s.TaskNo != TaskNo).Any())
|
return result;
|
}
|
return "";
|
//Log.Error("无可入的储位");
|
//throw Oops.Bah("无可入的储位");
|
}
|
/// <summary>
|
/// 获取托盘要出的储位
|
/// </summary>
|
/// <returns></returns>
|
public static string GetPalletOutStorage()
|
{
|
foreach (var item in listPallet)
|
{
|
var value = _sysConfigService.GetConfigValue<bool>(item).Result;
|
if (value)
|
return item.Split('_')[1];
|
}
|
return "";
|
//Log.Error("无可出的储位");
|
//throw Oops.Bah("无可出的储位");
|
}
|
|
#region 属性
|
|
public static bool Z11
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z11").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z11", value);
|
}
|
}
|
public static bool Z12
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z12").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z12", value);
|
}
|
}
|
public static bool Z13
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z13").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z13", value);
|
}
|
}
|
public static bool Z21
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z21").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z21", value);
|
}
|
}
|
public static bool Z22
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z22").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z22", value);
|
}
|
}
|
public static bool Z23
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z23").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z23", value);
|
}
|
}
|
public static bool Z31
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z31").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z31", value);
|
}
|
}
|
public static bool Z32
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z32").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z32", value);
|
}
|
}
|
public static bool Z33
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z33").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z33", value);
|
}
|
}
|
public static bool Z41
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z41").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z41", value);
|
}
|
}
|
public static bool Z42
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z42").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z42", value);
|
}
|
}
|
public static bool Z43
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z43").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z43", value);
|
}
|
}
|
public static bool Z51
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z51").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z51", value);
|
}
|
}
|
public static bool Z52
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z52").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z52", value);
|
}
|
}
|
public static bool Z53
|
{
|
get
|
{
|
return _sysConfigService.GetConfigValue<bool>("cache_Z53").Result;
|
}
|
set
|
{
|
_sysConfigService.UpdateConfigValue("cache_Z53", value);
|
}
|
}
|
#endregion
|
}
|