|
|
|
|
@@ -51,11 +51,15 @@ namespace Tnb.ProductionMgr
|
|
|
|
|
private Timer? CheckGettimer;
|
|
|
|
|
private Timer? Scantimer;
|
|
|
|
|
private Timer? SSXcodetimer;
|
|
|
|
|
// 八工位缓存区补充空托盘
|
|
|
|
|
private Timer? BGWCarrySupplementtimer;
|
|
|
|
|
// 供料叠盘机空托盘自动入库
|
|
|
|
|
private Timer? YCLGLDPJInstocktimer;
|
|
|
|
|
// 外协叠盘机空托盘自动入库
|
|
|
|
|
private Timer? YCLWXDPJInstocktimer;
|
|
|
|
|
|
|
|
|
|
// 二楼上升降机
|
|
|
|
|
private Timer? Floor2UpMachinecodetimer;
|
|
|
|
|
// 二楼下升降机
|
|
|
|
|
private Timer? Floor2DownMachinecodetimer;
|
|
|
|
|
// 二楼料架配送
|
|
|
|
|
private Timer? Floor2RackDeliverytimer;
|
|
|
|
|
|
|
|
|
|
@@ -92,6 +96,10 @@ namespace Tnb.ProductionMgr
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var json = _redisData.GetHash(config.dev_name!, config.tag_name!).Result;
|
|
|
|
|
if (json == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
JObject? res = JsonConvert.DeserializeObject<JObject>(json);
|
|
|
|
|
if (config.data_type == (int)DataType.INT)
|
|
|
|
|
{
|
|
|
|
|
@@ -182,6 +190,10 @@ namespace Tnb.ProductionMgr
|
|
|
|
|
var strs = getdic.Where(p => p.Key == key).First().Value;
|
|
|
|
|
bool flag = _redisData.HashExist(strs[0], strs[1]).Result;
|
|
|
|
|
string data = _redisData.GetHash(strs[0], strs[1]).Result;
|
|
|
|
|
if (data == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
|
|
|
|
|
|
|
|
|
|
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
|
|
|
|
|
@@ -190,6 +202,10 @@ namespace Tnb.ProductionMgr
|
|
|
|
|
if (!string.IsNullOrEmpty(strs[2]))
|
|
|
|
|
{
|
|
|
|
|
string codedata = _redisData.GetHash(strs[0], strs[2]).Result;
|
|
|
|
|
if (codedata == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
JObject? coderes = JsonConvert.DeserializeObject<JObject>(codedata);
|
|
|
|
|
string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value<string>("Value")! : "";
|
|
|
|
|
coderesult = coderesult.Replace("\r", "");
|
|
|
|
|
@@ -362,8 +378,46 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
|
|
|
|
|
})).CreateLogger(this.GetType());
|
|
|
|
|
|
|
|
|
|
protected ILogger LoggerBGWCarrySupplement => LoggerFactory.Create(builder => builder.AddFile($"{AppContext.BaseDirectory}/logs/customBGWCarrySupplement{DateTime.Now:yyyyMMdd}.log", cfgOpts =>
|
|
|
|
|
{
|
|
|
|
|
//cfgOpts.DateFormat = "yyyy-MM-dd HH:mm:ss.fff";
|
|
|
|
|
cfgOpts.MessageFormat = (logMsg) =>
|
|
|
|
|
{
|
|
|
|
|
var logLevel = s_logLevelMap[logMsg.LogLevel];
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
_ = sb.Append($"[{logLevel}] ");
|
|
|
|
|
_ = sb.Append($"{logMsg.LogName} ");
|
|
|
|
|
_ = sb.Append($"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} ");
|
|
|
|
|
_ = sb.Append($"#{logMsg.EventId.Id} ");
|
|
|
|
|
_ = sb.Append(logMsg.Message + " ");
|
|
|
|
|
_ = sb.Append(logMsg.Exception?.ToString());
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
})).CreateLogger(this.GetType());
|
|
|
|
|
|
|
|
|
|
protected ILogger LoggerYCLGLDPJInstock => LoggerFactory.Create(builder => builder.AddFile($"{AppContext.BaseDirectory}/logs/customBGWCarrySupplement{DateTime.Now:yyyyMMdd}.log", cfgOpts =>
|
|
|
|
|
{
|
|
|
|
|
//cfgOpts.DateFormat = "yyyy-MM-dd HH:mm:ss.fff";
|
|
|
|
|
cfgOpts.MessageFormat = (logMsg) =>
|
|
|
|
|
{
|
|
|
|
|
var logLevel = s_logLevelMap[logMsg.LogLevel];
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
_ = sb.Append($"[{logLevel}] ");
|
|
|
|
|
_ = sb.Append($"{logMsg.LogName} ");
|
|
|
|
|
_ = sb.Append($"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} ");
|
|
|
|
|
_ = sb.Append($"#{logMsg.EventId.Id} ");
|
|
|
|
|
_ = sb.Append(logMsg.Message + " ");
|
|
|
|
|
_ = sb.Append(logMsg.Exception?.ToString());
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
})).CreateLogger(this.GetType());
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 八工位
|
|
|
|
|
|
|
|
|
|
//扫码入库
|
|
|
|
|
private void ScanInStock(object state)
|
|
|
|
|
{
|
|
|
|
|
@@ -377,6 +431,10 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
var strs = getdic.Where(p => p.Key == key).First().Value;
|
|
|
|
|
bool flag = _redisData.HashExist(strs[0], strs[1]).Result;
|
|
|
|
|
string data = _redisData.GetHash(strs[0], strs[1]).Result;
|
|
|
|
|
if (data == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -393,7 +451,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
["Value"] = strs[4],
|
|
|
|
|
};
|
|
|
|
|
Logger.LogInformation($"【ScanInStock】 八工位 {key} 发送PutDoneEmptyBox指令 {_eleCtlCfg.WriteTagUrl} {JsonConvert.SerializeObject(dicCommand)}");
|
|
|
|
|
HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand).Wait();
|
|
|
|
|
HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand).Wait();
|
|
|
|
|
string codedata = _redisData.GetHash(strs[0], strs[2]).Result;
|
|
|
|
|
Logger.LogInformation($"【ScanInStock】 八工位 {key} 获取到扫码信息: {codedata}");
|
|
|
|
|
JObject? coderes = JsonConvert.DeserializeObject<JObject>(codedata);
|
|
|
|
|
@@ -402,18 +460,18 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
Logger.LogInformation($"【ScanInStock】 八工位 {key} 查找{coderesult}绑定的托盘: {JsonConvert.SerializeObject(carry)}");
|
|
|
|
|
if (carry != null)
|
|
|
|
|
{
|
|
|
|
|
if (_repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_id == carry.id && p.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID ).Any())
|
|
|
|
|
if (_repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_id == carry.id && p.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).Any())
|
|
|
|
|
{
|
|
|
|
|
Logger.LogInformation($"【ScanInStock】 八工位 {key} 托盘 {carry.id} 对应的执行任务状态(status)不是26126860808229(已完成),此时不能执行入库");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var WmsCarryCode = _repository.AsSugarClient().Queryable<WmsCarryCode>().Where(it => it.carry_id == carry.id).OrderByDescending(it => it.id).First();
|
|
|
|
|
// 用适当的字段替换 YourTimestampField
|
|
|
|
|
|
|
|
|
|
// 用适当的字段替换 YourTimestampField
|
|
|
|
|
|
|
|
|
|
if (WmsCarryCode != null)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogInformation($"【ScanInStock】 八工位 {key} 查找到托盘{carry.id}在WmsCarryCode中存在");
|
|
|
|
|
Logger.LogInformation($"【ScanInStock】 八工位 {key} 查找到托盘{carry.carry_code}在WmsCarryCode中存在");
|
|
|
|
|
|
|
|
|
|
VisualDevModelDataCrInput input = new VisualDevModelDataCrInput();
|
|
|
|
|
input.data = new Dictionary<string, object>();
|
|
|
|
|
@@ -440,6 +498,272 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 八工位空托盘补充
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async void BGWCarrySupplement(object state)
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
|
|
|
|
|
getdic.Add("YCLCKBGW", new string[] { "CP8", "AllowPutEmptyBox1" });
|
|
|
|
|
|
|
|
|
|
foreach (var key in getdic.Keys)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var strs = getdic.Where(p => p.Key == key).First().Value;
|
|
|
|
|
string data = await _redisData.GetHash(strs[0], strs[1]);
|
|
|
|
|
if (data == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
|
|
|
|
|
|
|
|
|
|
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
LoggerBGWCarrySupplement.LogInformation($"【BGWCarrySupplementtimer】 八工位 {key} {strs[1]}采集到 {res["Value"]}");
|
|
|
|
|
|
|
|
|
|
BasLocation endLocation = _repository.AsSugarClient().Queryable<BasLocation>().Where(r => r.location_code == key).First();
|
|
|
|
|
if (endLocation == null)
|
|
|
|
|
{
|
|
|
|
|
LoggerBGWCarrySupplement.LogWarning($"【BGWCarrySupplementtimer】 {key}未维护库位信息");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (endLocation.is_lock == 1)
|
|
|
|
|
{
|
|
|
|
|
LoggerBGWCarrySupplement.LogInformation($"【BGWCarrySupplementtimer】 八工位 {key} 已锁定");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 找到没有库位未锁定的空托盘
|
|
|
|
|
var wmsPoint = _repository.AsSugarClient().Queryable<WmsPointH>()
|
|
|
|
|
.InnerJoin<BasLocation>((a, b) => a.location_id == b.id)
|
|
|
|
|
.InnerJoin<WmsCarryH>((a, b, c) => b.id == c.location_id)
|
|
|
|
|
.LeftJoin<WmsCarryCode>((a, b, c, d) => c.id == d.carry_id)
|
|
|
|
|
.Where((a, b, c, d) => string.IsNullOrEmpty(d.barcode) && b.wh_id == WmsWareHouseConst.WAREHOUSE_YCL_ID && b.location_code.Contains("YCL-")).OrderBy((a, b, c, d) => b.location_code).Select((a, b, c, d) => new
|
|
|
|
|
{
|
|
|
|
|
wmsPoint = a,
|
|
|
|
|
FirstWmsCarryH = c
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
LoggerBGWCarrySupplement.LogInformation($"【BGWCarrySupplementtimer】 sql {wmsPoint.ToSqlString()}");
|
|
|
|
|
|
|
|
|
|
if (wmsPoint.Count() == 0)
|
|
|
|
|
{
|
|
|
|
|
LoggerBGWCarrySupplement.LogWarning($"【BGWCarrySupplementtimer】 当前没有可以出库的空托盘");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
WmsPointH startPoint = wmsPoint.First().wmsPoint;
|
|
|
|
|
WmsPointH endPoint = _repository.AsSugarClient().Queryable<WmsPointH>().Where(r => r.location_code == key).First();
|
|
|
|
|
if (endPoint == null)
|
|
|
|
|
{
|
|
|
|
|
LoggerBGWCarrySupplement.LogWarning($"【BGWCarrySupplementtimer】 终点库位{key}没有维护对应的点位");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//锁定起点库位
|
|
|
|
|
await _repository.AsSugarClient().Updateable<BasLocation>().SetColumns(r => r.is_lock == 1).Where(r => r.id == startPoint.location_id).ExecuteCommandAsync();
|
|
|
|
|
//锁定终点库位 更新为空闲
|
|
|
|
|
await _repository.AsSugarClient().Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1, is_use = "0" }).Where(r => r.id == endPoint.location_id).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
List<WmsPointH> points = new List<WmsPointH>();
|
|
|
|
|
points.Add(startPoint);
|
|
|
|
|
points.Add(endPoint);
|
|
|
|
|
|
|
|
|
|
Tuple<bool, WmsPretaskH> result_createPretask = await createPretask(points, wmsPoint.First().FirstWmsCarryH.id, wmsPoint.First().FirstWmsCarryH.carry_code, LoggerBGWCarrySupplement);
|
|
|
|
|
if (!result_createPretask.Item1)
|
|
|
|
|
{
|
|
|
|
|
LoggerBGWCarrySupplement.LogWarning($"【BGWCarrySupplementtimer】 {startPoint.location_code} 到 {endPoint.location_code} 预任务生成失败 ");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
LoggerBGWCarrySupplement.LogWarning($"【BGWCarrySupplementtimer】 {startPoint.location_code} 到 {endPoint.location_code} 预任务生成成功");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ = _wareHouseService.GenTaskExecute();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LoggerBGWCarrySupplement.LogInformation($"【BGWCarrySupplementtimer】 八工位空托盘补充发生异常:{ex}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 供料叠盘机空托盘自动入库
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async void YCLGLDPJInstock(object state)
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
|
|
|
|
|
getdic.Add("SGW-YCL", new string[] { "CP3-3", "AllowGetFullBox" });
|
|
|
|
|
|
|
|
|
|
foreach (var key in getdic.Keys)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var strs = getdic.Where(p => p.Key == key).First().Value;
|
|
|
|
|
string data = await _redisData.GetHash(strs[0], strs[1]);
|
|
|
|
|
if (data == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
|
|
|
|
|
|
|
|
|
|
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 三工位叠盘机 {key} {strs[1]}采集到 {res["Value"]}");
|
|
|
|
|
|
|
|
|
|
BasLocation endLocation = _repository.AsSugarClient().Queryable<BasLocation>().Where(r => r.location_code == key).First();
|
|
|
|
|
if (endLocation == null)
|
|
|
|
|
{
|
|
|
|
|
LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 {key}未维护库位信息");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (endLocation.is_lock == 1)
|
|
|
|
|
{
|
|
|
|
|
LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 三工位叠盘机 {key} 已锁定");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 找到未锁定且未占用的库位
|
|
|
|
|
var wmsPoint = _repository.AsSugarClient().Queryable<WmsPointH>()
|
|
|
|
|
.InnerJoin<BasLocation>((a, b) => a.location_id == b.id)
|
|
|
|
|
.Where((a, b) => b.is_lock == 0 && b.is_use == "0" && b.wh_id == WmsWareHouseConst.WAREHOUSE_YCL_ID && b.location_code.Contains("YCL-"));
|
|
|
|
|
|
|
|
|
|
LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 sql {wmsPoint.ToSqlString()}");
|
|
|
|
|
|
|
|
|
|
if (wmsPoint.Count() == 0)
|
|
|
|
|
{
|
|
|
|
|
LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 当前没有空库位可以入库");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
WmsPointH startPoint = _repository.AsSugarClient().Queryable<WmsPointH>().Where(r => r.location_code == key).First();
|
|
|
|
|
WmsPointH endPoint = wmsPoint.First();
|
|
|
|
|
if (endPoint == null)
|
|
|
|
|
{
|
|
|
|
|
LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 起点库位{key}没有维护对应的点位");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//锁定起点库位 更新为空闲
|
|
|
|
|
await _repository.AsSugarClient().Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1, is_use = "0" }).Where(r => r.id == startPoint.location_id).ExecuteCommandAsync();
|
|
|
|
|
//锁定终点库位
|
|
|
|
|
await _repository.AsSugarClient().Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == endPoint.location_id).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
List<WmsPointH> points = new List<WmsPointH>();
|
|
|
|
|
points.Add(startPoint);
|
|
|
|
|
points.Add(endPoint);
|
|
|
|
|
|
|
|
|
|
Tuple<bool, WmsPretaskH> result_createPretask = await createPretask(points, "", "", LoggerYCLGLDPJInstock);
|
|
|
|
|
if (!result_createPretask.Item1)
|
|
|
|
|
{
|
|
|
|
|
LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 {startPoint.location_code} 到 {endPoint.location_code} 预任务生成失败");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 {startPoint.location_code} 到 {endPoint.location_code} 预任务生成成功");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ = _wareHouseService.GenTaskExecute();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 三工位叠盘机空托入库发生异常:{ex}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 外协叠盘机空托盘自动入库
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async void YCLWXDPJInstock(object state)
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
|
|
|
|
|
getdic.Add("未定", new string[] { "CP3-3", "AllowGetFullBox" });
|
|
|
|
|
|
|
|
|
|
foreach (var key in getdic.Keys)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var strs = getdic.Where(p => p.Key == key).First().Value;
|
|
|
|
|
string data = await _redisData.GetHash(strs[0], strs[1]);
|
|
|
|
|
if (data == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
|
|
|
|
|
|
|
|
|
|
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 外协叠盘机 {key} {strs[1]}采集到 {res["Value"]}");
|
|
|
|
|
|
|
|
|
|
BasLocation endLocation = _repository.AsSugarClient().Queryable<BasLocation>().Where(r => r.location_code == key).First();
|
|
|
|
|
if (endLocation == null)
|
|
|
|
|
{
|
|
|
|
|
LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 {key}未维护库位信息");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (endLocation.is_lock == 1)
|
|
|
|
|
{
|
|
|
|
|
LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 外协叠盘机 {key} 已锁定");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 找到未锁定且未占用的库位
|
|
|
|
|
var wmsPoint = _repository.AsSugarClient().Queryable<WmsPointH>()
|
|
|
|
|
.InnerJoin<BasLocation>((a, b) => a.location_id == b.id)
|
|
|
|
|
.Where((a, b) => b.is_lock == 0 && b.is_use == "0" && b.wh_id == WmsWareHouseConst.WAREHOUSE_YCL_ID && b.location_code.Contains("YCL-"));
|
|
|
|
|
|
|
|
|
|
LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 sql {wmsPoint.ToSqlString()}");
|
|
|
|
|
|
|
|
|
|
if (wmsPoint.Count() == 0)
|
|
|
|
|
{
|
|
|
|
|
LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 当前没有空库位可以入库");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
WmsPointH startPoint = _repository.AsSugarClient().Queryable<WmsPointH>().Where(r => r.location_code == key).First();
|
|
|
|
|
WmsPointH endPoint = wmsPoint.First();
|
|
|
|
|
if (endPoint == null)
|
|
|
|
|
{
|
|
|
|
|
LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 起点库位{key}没有维护对应的点位");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//锁定起点库位 更新为空闲
|
|
|
|
|
await _repository.AsSugarClient().Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1, is_use = "0" }).Where(r => r.id == startPoint.location_id).ExecuteCommandAsync();
|
|
|
|
|
//锁定终点库位
|
|
|
|
|
await _repository.AsSugarClient().Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == endPoint.location_id).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
List<WmsPointH> points = new List<WmsPointH>();
|
|
|
|
|
points.Add(startPoint);
|
|
|
|
|
points.Add(endPoint);
|
|
|
|
|
|
|
|
|
|
Tuple<bool, WmsPretaskH> result_createPretask = await createPretask(points, "", "", LoggerYCLGLDPJInstock);
|
|
|
|
|
if (!result_createPretask.Item1)
|
|
|
|
|
{
|
|
|
|
|
LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 {startPoint.location_code} 到 {endPoint.location_code} 预任务生成失败");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 {startPoint.location_code} 到 {endPoint.location_code} 预任务生成成功");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ = _wareHouseService.GenTaskExecute();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 外协叠盘机空托入库发生异常:{ex}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 中储仓
|
|
|
|
|
|
|
|
|
|
private void SSXcode(object state)
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, string[]> dic = new Dictionary<string, string[]>();
|
|
|
|
|
@@ -453,14 +777,22 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
{
|
|
|
|
|
var strs = dic.Where(p => p.Key == key).First().Value;
|
|
|
|
|
string dataflag = _redisData.GetHash(key, strs[0]).Result;
|
|
|
|
|
if (dataflag == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
JObject? resflag = JsonConvert.DeserializeObject<JObject>(dataflag);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Logger.LogInformation($"【定时任务SSXcode】 {key}->{strs[0]} 采集结果:{resflag}");
|
|
|
|
|
bool re = resflag != null && resflag["Value"] != null ? resflag.Value<bool>("Value") : false;
|
|
|
|
|
bool re = resflag != null && resflag["Value"] != null ? resflag.Value<bool>("Value") : false;
|
|
|
|
|
if (!re)
|
|
|
|
|
continue;
|
|
|
|
|
string data = _redisData.GetHash(key, strs[1]).Result;
|
|
|
|
|
if (data == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
|
|
|
|
|
//Logger.LogInformation($"【定时任务SSXcode】 {key}->{strs[1]} 采集结果:{res}");
|
|
|
|
|
string? result = res != null && res["Value"] != null ? res.Value<string>("Value") : "";
|
|
|
|
|
@@ -500,7 +832,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
["DevName"] = key,
|
|
|
|
|
["token"] = _eleCtlCfg.token,
|
|
|
|
|
["TagName"] = strs[3],
|
|
|
|
|
["Value"] = "13",
|
|
|
|
|
["Value"] = "13",
|
|
|
|
|
};
|
|
|
|
|
HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2).Wait();
|
|
|
|
|
Dictionary<string, string> dicCommand = new(StringComparer.OrdinalIgnoreCase)
|
|
|
|
|
@@ -522,6 +854,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
Readtimer?.Dispose();
|
|
|
|
|
@@ -529,9 +863,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
Scantimer?.Dispose();
|
|
|
|
|
SSXcodetimer?.Dispose();
|
|
|
|
|
Floor2UpMachinecodetimer?.Dispose();
|
|
|
|
|
Floor2DownMachinecodetimer?.Dispose();
|
|
|
|
|
Floor2RackDeliverytimer.Dispose();
|
|
|
|
|
}
|
|
|
|
|
Floor2RackDeliverytimer?.Dispose();
|
|
|
|
|
BGWCarrySupplementtimer?.Dispose();
|
|
|
|
|
YCLGLDPJInstocktimer?.Dispose();
|
|
|
|
|
YCLWXDPJInstocktimer?.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 二楼上升降机机械臂
|
|
|
|
|
// 上升降机
|
|
|
|
|
@@ -691,131 +1027,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//private async void Floor2DownMachinecode(object args)
|
|
|
|
|
//{
|
|
|
|
|
// using (var db = _repository.AsSugarClient().CopyNew())
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
// // 读取上升降机的左右料架区配置
|
|
|
|
|
// string[] configs = new string[2] { "二楼下升降机机械臂左", "二楼下升降机机械臂右" };
|
|
|
|
|
|
|
|
|
|
// // 左右料架区配置
|
|
|
|
|
// List<WmsMechanicalArmH> WmsMechanicalArmHs = db.Queryable<WmsMechanicalArmH>()
|
|
|
|
|
// .Where(r => configs.Contains(r.name) && r.mechanicalconfirm == 1 && r.stackingcount < r.maxnum).ToList();
|
|
|
|
|
|
|
|
|
|
// // 是否可以放货
|
|
|
|
|
// if (WmsMechanicalArmHs.Count == 0)
|
|
|
|
|
// {
|
|
|
|
|
// //LoggerFloor2UpDownMachine.LogWarning($@"【下升降机】目前没有可以取货的料架区");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// WmsMechanicalArmH target;
|
|
|
|
|
// target = WmsMechanicalArmHs.First();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // 待拆垛列表
|
|
|
|
|
// List<WmsCarryD> WmsCarryCodes = db.Queryable<WmsMechanicalArmH>()
|
|
|
|
|
// .InnerJoin<WmsCarryD>((a, b) => a.rackid == b.carry_id)
|
|
|
|
|
// .Where(a => configs.Contains(a.name) && a.mechanicalconfirm == 1 && a.id == target.id).Select((a, b) => b).OrderBy(a => a.id).ToList();
|
|
|
|
|
|
|
|
|
|
// // 料架拆垛完成
|
|
|
|
|
// if (WmsCarryCodes.Count() == 0)
|
|
|
|
|
// {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// string barcode = WmsCarryCodes[0].membercarry_code;
|
|
|
|
|
|
|
|
|
|
// // 如果条码已被绑定
|
|
|
|
|
// if (WmsMechanicalArmHs.Where(r => !string.IsNullOrEmpty(r.barcodes) && r.barcodes.Contains(barcode)).Count() > 0)
|
|
|
|
|
// {
|
|
|
|
|
// LoggerFloor2UpDownMachine.LogWarning($@"【下升降机】条码{barcode}已被绑定");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// LoggerFloor2UpDownMachine.LogInformation($@"【下升降机】扫描到有效条码 {barcode}");
|
|
|
|
|
|
|
|
|
|
// await db.Ado.BeginTranAsync();
|
|
|
|
|
// try
|
|
|
|
|
// {
|
|
|
|
|
// LoggerFloor2UpDownMachine.LogInformation($@"【下升降机】当前条码目标料架区为 {JsonConvert.SerializeObject(target)}");
|
|
|
|
|
|
|
|
|
|
// // 料架信息
|
|
|
|
|
// WmsCarryH rack = db.Queryable<WmsCarryH>().Where(r => r.id == target.rackid).ToList()[0];
|
|
|
|
|
|
|
|
|
|
// // 料箱信息
|
|
|
|
|
// WmsCarryH LX = db.Queryable<WmsCarryH>().Where(r => r.carry_code == barcode).ToList()[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// await db.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
|
|
|
|
|
// {
|
|
|
|
|
// barcodes = $"{target.barcodes},{barcode}".Trim(','),
|
|
|
|
|
// stackingcount = r.stackingcount + 1
|
|
|
|
|
// }).Where(r => r.id == target.id).ExecuteCommandAsync();
|
|
|
|
|
// LoggerFloor2UpDownMachine.LogInformation($@"【下升降机】回写料箱条码、拆垛计数");
|
|
|
|
|
|
|
|
|
|
// // 解除绑定料箱到料架
|
|
|
|
|
// CarryBindFloor2UpDownMachineInput carryBindFloor2UpDownMachineInput = new() { };
|
|
|
|
|
// carryBindFloor2UpDownMachineInput.carry_id = target.rackid;
|
|
|
|
|
// carryBindFloor2UpDownMachineInput.carry_code = target.rackcode;
|
|
|
|
|
// carryBindFloor2UpDownMachineInput.membercarry_id = LX.id;
|
|
|
|
|
// carryBindFloor2UpDownMachineInput.membercarry_code = LX.carry_code;
|
|
|
|
|
// carryBindFloor2UpDownMachineInput.carrystd_id = rack.carrystd_id;
|
|
|
|
|
|
|
|
|
|
// await _wmsCarryBindService.CarryUnbindFloor2UpDownMachine(carryBindFloor2UpDownMachineInput);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// await db.Ado.CommitTranAsync();
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// catch (Exception ex)
|
|
|
|
|
// {
|
|
|
|
|
// LoggerFloor2UpDownMachine.LogError(ex.ToString());
|
|
|
|
|
// LoggerFloor2UpDownMachine.LogError(ex.StackTrace);
|
|
|
|
|
// await db.Ado.RollbackTranAsync();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检查机械臂料架区信号(上升降机空托1送到)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
//public async Task<bool> 检查机械臂料架区信号_上升降机空托1送到()
|
|
|
|
|
//{
|
|
|
|
|
// using (var db = _repository.AsSugarClient().CopyNew())
|
|
|
|
|
// {
|
|
|
|
|
// string[] configs_upMachine = new string[2] { "二楼上升降机机械臂左", "二楼上升降机机械臂右" };
|
|
|
|
|
|
|
|
|
|
// // 找到AGV已到货的数据 发送机械臂送到指令
|
|
|
|
|
// ISugarQueryable<WmsMechanicalArmH> WmsMechanicalArmHsuagar = db.Queryable<WmsMechanicalArmH>()
|
|
|
|
|
// .Where(r => r.agvconfirm == 1 && r.mechanicalconfirm == 0 && configs_upMachine.Contains(r.name));
|
|
|
|
|
|
|
|
|
|
// foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHsuagar.ToList())
|
|
|
|
|
// {
|
|
|
|
|
// // 尝试写入空托送到信号
|
|
|
|
|
// bool result上升降机空托送到 = await Floor2UpDownMachinecode_SetTag($"上升降机空托{wmsMechanicalArmH.stackingposition}送到", "true");
|
|
|
|
|
// LoggerFloor2UpDownMachine.LogInformation($@"【送空托到上升降区】回写 上升降机空托{wmsMechanicalArmH.stackingposition}送到 结果为{result上升降机空托送到}");
|
|
|
|
|
// if (!result上升降机空托送到)
|
|
|
|
|
// {
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// // 绑定料架
|
|
|
|
|
// await db.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
|
|
|
|
|
// {
|
|
|
|
|
// mechanicalconfirm = 1
|
|
|
|
|
// }).Where(r => r.id == wmsMechanicalArmH.id).ExecuteCommandAsync();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// return true;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检查机械臂料架区信号(上升降机满托1送到)
|
|
|
|
|
/// 检查机械臂料架区信号(下升降机满托1送到)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> 检查机械臂料架区信号_下升降机满托1送到()
|
|
|
|
|
@@ -831,15 +1044,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
|
|
|
|
|
foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHsuagar.ToList())
|
|
|
|
|
{
|
|
|
|
|
// 尝试写入满托送到信号
|
|
|
|
|
bool result上升降机空托送到 = await Floor2UpDownMachinecode_SetTag($"下升降机满托{wmsMechanicalArmH.stackingposition}送到", "true");
|
|
|
|
|
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】回写 下升降机满托{wmsMechanicalArmH.stackingposition}送到 结果为{result上升降机空托送到}");
|
|
|
|
|
if (!result上升降机空托送到)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int LXCount = db.Queryable<WmsCarryD>() .Where(a => a.carry_id == wmsMechanicalArmH.rackid).Count();
|
|
|
|
|
int LXCount = db.Queryable<WmsCarryD>().Where(a => a.carry_id == wmsMechanicalArmH.rackid).Count();
|
|
|
|
|
|
|
|
|
|
bool result = await Floor2UpDownMachinecode_SetTag($"下升降机满托{wmsMechanicalArmH.stackingposition}数量", LXCount.ToString());
|
|
|
|
|
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】设定下升降机满托{wmsMechanicalArmH.stackingposition}满托数量为 {LXCount} 结果为 {result}");
|
|
|
|
|
@@ -847,6 +1052,15 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($@"【送满托到下升降区】设定升降机满托{wmsMechanicalArmH.stackingposition}满托数量为 {LXCount} 结果为 {result}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 尝试写入满托送到信号
|
|
|
|
|
bool result下升降机空托送到 = await Floor2UpDownMachinecode_SetTag($"下升降机满托{wmsMechanicalArmH.stackingposition}送到", "true");
|
|
|
|
|
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】回写 下升降机满托{wmsMechanicalArmH.stackingposition}送到 结果为{result下升降机空托送到}");
|
|
|
|
|
if (!result下升降机空托送到)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 绑定料架
|
|
|
|
|
await db.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
|
|
|
|
|
{
|
|
|
|
|
@@ -882,7 +1096,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
string[] configs_upMachine = new string[2] { "二楼上升降机机械臂左", "二楼上升降机机械臂右" };
|
|
|
|
|
|
|
|
|
|
// 找到没有绑定料架的且库位未锁定的料架区
|
|
|
|
|
ISugarQueryable<WmsMechanicalArmH> WmsMechanicalArmHsuagar = _repository.AsSugarClient().Queryable<WmsMechanicalArmH>().
|
|
|
|
|
ISugarQueryable<WmsMechanicalArmH> WmsMechanicalArmHsuagar = db.Queryable<WmsMechanicalArmH>().
|
|
|
|
|
InnerJoin<WmsPointH>((a, b) => a.point_id == b.id)
|
|
|
|
|
.InnerJoin<BasLocation>((a, b, c) => b.location_id == c.id)
|
|
|
|
|
.Where((a, b, c) => string.IsNullOrEmpty(a.rackcode) && c.is_lock == 0 && configs_upMachine.Contains(a.name));
|
|
|
|
|
@@ -898,13 +1112,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
// 料架区
|
|
|
|
|
foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHs)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
LoggerFloor2RackDelivery.LogInformation($"【送空托到上升降区】 即将补充料架区{wmsMechanicalArmH.name}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 找到占用且未锁定的库位上的空料架
|
|
|
|
|
ISugarQueryable<BasLocation> rackStartLocations =
|
|
|
|
|
_repository.AsSugarClient().Queryable<BasLocation>()
|
|
|
|
|
db.Queryable<BasLocation>()
|
|
|
|
|
.InnerJoin<WmsCarryH>((a, b) => a.id == b.location_id)
|
|
|
|
|
.LeftJoin<WmsCarryD>((a, b, c) => b.id == c.carry_id)
|
|
|
|
|
.Where((a, b, c) => a.wh_id == "33780009364245" && a.is_use == "1" && a.is_lock == 0 && string.IsNullOrEmpty(c.id)
|
|
|
|
|
@@ -915,10 +1125,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
LoggerFloor2RackDelivery.LogWarning($"【送空托到上升降区】 暂存仓中没有可用的空料架 {rackStartLocations.ToSqlString()}");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
LoggerFloor2RackDelivery.LogInformation($"【送空托到上升降区】 即将补充料架区{wmsMechanicalArmH.name}");
|
|
|
|
|
|
|
|
|
|
BasLocation startLocation = rackStartLocations.First();
|
|
|
|
|
|
|
|
|
|
List<WmsPointH> startPoints = _repository.AsSugarClient().Queryable<WmsPointH>().Where(r => r.location_id == startLocation.id).ToList();
|
|
|
|
|
List<WmsPointH> startPoints = db.Queryable<WmsPointH>().Where(r => r.location_id == startLocation.id).ToList();
|
|
|
|
|
|
|
|
|
|
if (startPoints.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
@@ -926,7 +1137,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<WmsPointH> endPoints = _repository.AsSugarClient().Queryable<WmsPointH>().Where(r => r.id == wmsMechanicalArmH.point_id).ToList();
|
|
|
|
|
List<WmsPointH> endPoints = db.Queryable<WmsPointH>().Where(r => r.id == wmsMechanicalArmH.point_id).ToList();
|
|
|
|
|
|
|
|
|
|
if (endPoints.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
@@ -934,7 +1145,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<WmsCarryH> wmsCarryHs = _repository.AsSugarClient().Queryable<WmsCarryH>().Where(r => r.location_id == startLocation.id).ToList();
|
|
|
|
|
List<WmsCarryH> wmsCarryHs = db.Queryable<WmsCarryH>().Where(r => r.location_id == startLocation.id).ToList();
|
|
|
|
|
if (wmsCarryHs.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
LoggerFloor2RackDelivery.LogError($"【送空托到上升降区】 起点{startLocation.id} {startLocation.location_code}上找不到料架");
|
|
|
|
|
@@ -953,11 +1164,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
WmsPointH startPoint = startPoints.First();
|
|
|
|
|
WmsPointH endPoint = endPoints.First();
|
|
|
|
|
|
|
|
|
|
await _repository.AsSugarClient().Updateable<BasLocation>().SetColumns(r => new BasLocation
|
|
|
|
|
await db.Updateable<BasLocation>().SetColumns(r => new BasLocation
|
|
|
|
|
{
|
|
|
|
|
is_lock = 1
|
|
|
|
|
}).Where(r => r.id == startLocation.id).ExecuteCommandAsync();
|
|
|
|
|
await _repository.AsSugarClient().Updateable<BasLocation>().SetColumns(r => new BasLocation
|
|
|
|
|
await db.Updateable<BasLocation>().SetColumns(r => new BasLocation
|
|
|
|
|
{
|
|
|
|
|
is_lock = 1
|
|
|
|
|
}).Where(r => r.id == endPoint.location_id).ExecuteCommandAsync();
|
|
|
|
|
@@ -972,7 +1183,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
points.Add(startPoint);
|
|
|
|
|
points.Add(endPoint);
|
|
|
|
|
|
|
|
|
|
Tuple<bool, WmsPretaskH> result = await Floor2UpDownMachinecode_createPretask(points, targetCarry.id, targetCarry.carry_code);
|
|
|
|
|
Tuple<bool, WmsPretaskH> result = await createPretask(points, targetCarry.id, targetCarry.carry_code, LoggerFloor2RackDelivery);
|
|
|
|
|
if (!result.Item1)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
@@ -993,8 +1204,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
{
|
|
|
|
|
string[] configs_upMachine = new string[2] { "二楼下升降机机械臂左", "二楼下升降机机械臂右" };
|
|
|
|
|
|
|
|
|
|
// 找到没有绑定料架的且点位未锁定的料架区
|
|
|
|
|
ISugarQueryable<WmsMechanicalArmH> WmsMechanicalArmHsuagar = _repository.AsSugarClient().Queryable<WmsMechanicalArmH>().
|
|
|
|
|
// 找到没有绑定料架的且库位未锁定的料架区
|
|
|
|
|
ISugarQueryable<WmsMechanicalArmH> WmsMechanicalArmHsuagar = db.Queryable<WmsMechanicalArmH>().
|
|
|
|
|
InnerJoin<WmsPointH>((a, b) => a.point_id == b.id)
|
|
|
|
|
.InnerJoin<BasLocation>((a, b, c) => b.location_id == c.id)
|
|
|
|
|
.Where((a, b, c) => string.IsNullOrEmpty(a.rackcode) && c.is_lock == 0 && configs_upMachine.Contains(a.name));
|
|
|
|
|
@@ -1021,7 +1232,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
|
|
|
|
|
// 找到占用且未锁定的库位上的满料架且料架中的料箱是空的
|
|
|
|
|
List<BasLocation> rackStartLocations =
|
|
|
|
|
_repository.AsSugarClient().Queryable<BasLocation>()
|
|
|
|
|
db.Queryable<BasLocation>()
|
|
|
|
|
.InnerJoin<WmsCarryH>((a, b) => a.id == b.location_id)
|
|
|
|
|
.LeftJoin<WmsCarryD>((a, b, c) => b.id == c.carry_id) // 有料箱
|
|
|
|
|
.LeftJoin<WmsCarryCode>((a, b, c, d) => c.membercarry_id == d.carry_id)
|
|
|
|
|
@@ -1058,7 +1269,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
|
|
|
|
|
BasLocation startLocation = rackStartLocations.First();
|
|
|
|
|
|
|
|
|
|
List<WmsPointH> startPoints = _repository.AsSugarClient().Queryable<WmsPointH>().Where(r => r.location_id == startLocation.id).ToList();
|
|
|
|
|
List<WmsPointH> startPoints = db.Queryable<WmsPointH>().Where(r => r.location_id == startLocation.id).ToList();
|
|
|
|
|
|
|
|
|
|
if (startPoints.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
@@ -1066,7 +1277,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<WmsPointH> endPoints = _repository.AsSugarClient().Queryable<WmsPointH>().Where(r => r.id == wmsMechanicalArmH.point_id).ToList();
|
|
|
|
|
List<WmsPointH> endPoints = db.Queryable<WmsPointH>().Where(r => r.id == wmsMechanicalArmH.point_id).ToList();
|
|
|
|
|
|
|
|
|
|
if (endPoints.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
@@ -1074,7 +1285,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<WmsCarryH> wmsCarryHs = _repository.AsSugarClient().Queryable<WmsCarryH>().Where(r => r.location_id == startLocation.id).ToList();
|
|
|
|
|
List<WmsCarryH> wmsCarryHs = db.Queryable<WmsCarryH>().Where(r => r.location_id == startLocation.id).ToList();
|
|
|
|
|
if (wmsCarryHs.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
LoggerFloor2RackDelivery.LogError($"【送满托到下升降区】 起点{startLocation.id} {startLocation.location_code}上找不到料架");
|
|
|
|
|
@@ -1093,12 +1304,12 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
WmsPointH startPoint = startPoints.First();
|
|
|
|
|
WmsPointH endPoint = endPoints.First();
|
|
|
|
|
|
|
|
|
|
await _repository.AsSugarClient().Updateable<BasLocation>().SetColumns(r => new BasLocation
|
|
|
|
|
await db.Updateable<BasLocation>().SetColumns(r => new BasLocation
|
|
|
|
|
{
|
|
|
|
|
is_lock = 1
|
|
|
|
|
}).Where(r => r.id == startLocation.id).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
await _repository.AsSugarClient().Updateable<BasLocation>().SetColumns(r => new BasLocation
|
|
|
|
|
await db.Updateable<BasLocation>().SetColumns(r => new BasLocation
|
|
|
|
|
{
|
|
|
|
|
is_lock = 1
|
|
|
|
|
}).Where(r => r.id == endPoint.location_id).ExecuteCommandAsync();
|
|
|
|
|
@@ -1113,7 +1324,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
points.Add(startPoint);
|
|
|
|
|
points.Add(endPoint);
|
|
|
|
|
|
|
|
|
|
Tuple<bool, WmsPretaskH> result = await Floor2UpDownMachinecode_createPretask(points, targetCarry.id, targetCarry.carry_code);
|
|
|
|
|
Tuple<bool, WmsPretaskH> result = await createPretask(points, targetCarry.id, targetCarry.carry_code, LoggerFloor2RackDelivery);
|
|
|
|
|
if (!result.Item1)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("【送满托到下升降区】 未成功生成预任务");
|
|
|
|
|
@@ -1135,7 +1346,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
string[] configs_upMachine = new string[2] { "二楼上升降机机械臂左", "二楼上升降机机械臂右" };
|
|
|
|
|
// 读取上升降机的左右料架区配置
|
|
|
|
|
|
|
|
|
|
List<WmsMechanicalArmH> WmsMechanicalArmHs = _repository.AsSugarClient().Queryable<WmsMechanicalArmH>().Where(r => r.stackingcount == r.maxnum && r.maxnum != 0 && !string.IsNullOrEmpty(r.rackcode) && r.iscreatepretask == 0 && configs_upMachine.Contains(r.name) && r.mechanicalconfirm == 1).ToList();
|
|
|
|
|
List<WmsMechanicalArmH> WmsMechanicalArmHs = db.Queryable<WmsMechanicalArmH>().Where(r => r.stackingcount == r.maxnum && r.maxnum != 0 && !string.IsNullOrEmpty(r.rackcode) && r.iscreatepretask == 0 && configs_upMachine.Contains(r.name) && r.mechanicalconfirm == 1).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHs)
|
|
|
|
|
{
|
|
|
|
|
@@ -1151,14 +1362,14 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _repository.AsSugarClient().Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
|
|
|
|
|
await db.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
|
|
|
|
|
{
|
|
|
|
|
iscreatepretask = 1
|
|
|
|
|
}).Where(r => r.id == wmsMechanicalArmH.id).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
List<WmsPointH> points = new List<WmsPointH>();
|
|
|
|
|
|
|
|
|
|
List<WmsPointH> startPoints = _repository.AsSugarClient().Queryable<WmsPointH>().Where(r => r.id == wmsMechanicalArmH.point_id).ToList();
|
|
|
|
|
List<WmsPointH> startPoints = db.Queryable<WmsPointH>().Where(r => r.id == wmsMechanicalArmH.point_id).ToList();
|
|
|
|
|
|
|
|
|
|
if (startPoints.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
@@ -1171,7 +1382,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
|
|
|
|
|
// 找到未占用且未锁定的库位
|
|
|
|
|
ISugarQueryable<BasLocation> rackEndLocations =
|
|
|
|
|
_repository.AsSugarClient().Queryable<BasLocation>()
|
|
|
|
|
db.Queryable<BasLocation>()
|
|
|
|
|
.Where(r => r.wh_id == "33780009364245" && r.is_use == "0" && r.is_lock == 0).OrderBy(a => a.id).Take(1);
|
|
|
|
|
|
|
|
|
|
if (rackEndLocations.Count() == 0)
|
|
|
|
|
@@ -1182,7 +1393,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
|
|
|
|
|
BasLocation endLocation = rackEndLocations.First();
|
|
|
|
|
|
|
|
|
|
List<WmsPointH> endPoints = _repository.AsSugarClient().Queryable<WmsPointH>().Where(r => r.location_id == endLocation.id).ToList();
|
|
|
|
|
List<WmsPointH> endPoints = db.Queryable<WmsPointH>().Where(r => r.location_id == endLocation.id).ToList();
|
|
|
|
|
|
|
|
|
|
if (endPoints.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
@@ -1205,7 +1416,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
|
|
|
|
|
LoggerFloor2RackDelivery.LogInformation($"【移走上升降区满托的料架】 开始执行预任务生成: 料架区为{wmsMechanicalArmH.name}{wmsMechanicalArmH.stackingposition} 料架为{wmsMechanicalArmH.rackcode}");
|
|
|
|
|
|
|
|
|
|
Tuple<bool, WmsPretaskH> result = await Floor2UpDownMachinecode_createPretask(points, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode);
|
|
|
|
|
Tuple<bool, WmsPretaskH> result = await createPretask(points, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode, LoggerFloor2RackDelivery);
|
|
|
|
|
if (!result.Item1)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("未成功生成预任务");
|
|
|
|
|
@@ -1240,7 +1451,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
string[] configs_upMachine = new string[2] { "二楼下升降机机械臂左", "二楼下升降机机械臂右" };
|
|
|
|
|
// 读取下升降机的左右料架区配置
|
|
|
|
|
|
|
|
|
|
List<WmsMechanicalArmH> WmsMechanicalArmHs = _repository.AsSugarClient().Queryable<WmsMechanicalArmH>().Where(r => !string.IsNullOrEmpty(r.rackcode) && r.iscreatepretask == 0 && configs_upMachine.Contains(r.name)).ToList();
|
|
|
|
|
List<WmsMechanicalArmH> WmsMechanicalArmHs = db.Queryable<WmsMechanicalArmH>().Where(r => !string.IsNullOrEmpty(r.rackcode) && r.iscreatepretask == 0 && configs_upMachine.Contains(r.name)).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHs)
|
|
|
|
|
{
|
|
|
|
|
@@ -1256,14 +1467,14 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 开始执行预任务生成 {wmsMechanicalArmH.point_code} {wmsMechanicalArmH.outbill} {wmsMechanicalArmH.barcodes}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _repository.AsSugarClient().Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
|
|
|
|
|
await db.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
|
|
|
|
|
{
|
|
|
|
|
iscreatepretask = 1
|
|
|
|
|
}).Where(r => r.id == wmsMechanicalArmH.id).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
List<WmsPointH> points = new List<WmsPointH>();
|
|
|
|
|
|
|
|
|
|
List<WmsPointH> startPoints = _repository.AsSugarClient().Queryable<WmsPointH>().Where(r => r.id == wmsMechanicalArmH.point_id).ToList();
|
|
|
|
|
List<WmsPointH> startPoints = db.Queryable<WmsPointH>().Where(r => r.id == wmsMechanicalArmH.point_id).ToList();
|
|
|
|
|
|
|
|
|
|
if (startPoints.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
@@ -1276,7 +1487,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
|
|
|
|
|
// 找到未占用且未锁定的库位
|
|
|
|
|
ISugarQueryable<BasLocation> rackEndLocations =
|
|
|
|
|
_repository.AsSugarClient().Queryable<BasLocation>()
|
|
|
|
|
db.Queryable<BasLocation>()
|
|
|
|
|
.Where(r => r.wh_id == "33780009364245" && r.is_use == "0" && r.is_lock == 0).OrderBy(a => a.id).Take(1);
|
|
|
|
|
|
|
|
|
|
if (rackEndLocations.Count() == 0)
|
|
|
|
|
@@ -1287,7 +1498,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
|
|
|
|
|
BasLocation endLocation = rackEndLocations.First();
|
|
|
|
|
|
|
|
|
|
List<WmsPointH> endPoints = _repository.AsSugarClient().Queryable<WmsPointH>().Where(r => r.location_id == endLocation.id).ToList();
|
|
|
|
|
List<WmsPointH> endPoints = db.Queryable<WmsPointH>().Where(r => r.location_id == endLocation.id).ToList();
|
|
|
|
|
|
|
|
|
|
if (endPoints.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
@@ -1318,7 +1529,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
|
|
|
|
|
LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 开始执行预任务生成: 料架区为{wmsMechanicalArmH.name}{wmsMechanicalArmH.stackingposition} 料架为{wmsMechanicalArmH.rackcode}");
|
|
|
|
|
|
|
|
|
|
Tuple<bool, WmsPretaskH> result = await Floor2UpDownMachinecode_createPretask(points, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode);
|
|
|
|
|
Tuple<bool, WmsPretaskH> result = await createPretask(points, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode, LoggerFloor2RackDelivery);
|
|
|
|
|
if (!result.Item1)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("未成功生成预任务");
|
|
|
|
|
@@ -1338,7 +1549,6 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
// 料架配送
|
|
|
|
|
private async void Floor2RackDelivery(object args)
|
|
|
|
|
{
|
|
|
|
|
var db = _repository.AsSugarClient().CopyNew();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 检查机械臂料架区信号(上升降机空托1送到)
|
|
|
|
|
@@ -1372,7 +1582,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 上下升降机生成预任务(补充料架、上升降机取货到料架、上升降机满托运走,下升降机拿货到输送线、下升降机空托运走)
|
|
|
|
|
private async Task<Tuple<bool, WmsPretaskH>> Floor2UpDownMachinecode_createPretask(List<WmsPointH> points, string carry_id, string carry_code)
|
|
|
|
|
private async Task<Tuple<bool, WmsPretaskH>> createPretask(List<WmsPointH> points, string carry_id, string carry_code, ILogger logger)
|
|
|
|
|
{
|
|
|
|
|
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
|
|
|
|
WmsPretaskH preTask = null;
|
|
|
|
|
@@ -1481,13 +1691,19 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
|
|
|
|
CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
|
|
|
|
|
Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
|
|
|
|
|
SSXcodetimer = new Timer(SSXcode, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
|
|
|
|
|
//// 八工位缓存区补充空托盘
|
|
|
|
|
//BGWCarrySupplementtimer = new Timer(BGWCarrySupplement, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
|
|
|
|
|
|
|
|
|
// 二楼上升降机
|
|
|
|
|
Floor2UpMachinecodetimer = new Timer(Floor2UpMachinecode, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
|
|
|
|
|
// 二楼下升降机
|
|
|
|
|
//Floor2DownMachinecodetimer = new Timer(Floor2DownMachinecode, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
|
|
|
|
|
// 二楼料架配送
|
|
|
|
|
Floor2RackDeliverytimer = new Timer(Floor2RackDelivery, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
|
|
|
|
//// 供料叠盘机空托盘自动入库
|
|
|
|
|
//YCLGLDPJInstocktimer = new Timer(YCLGLDPJInstock, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
|
|
|
|
|
|
|
|
|
////// 外协叠盘机空托盘自动入库
|
|
|
|
|
////YCLWXDPJInstocktimer = new Timer(YCLWXDPJInstock, null, TimeSpan.Zero, TimeSpan.FromSeconds(100000));
|
|
|
|
|
|
|
|
|
|
//// 二楼上升降机
|
|
|
|
|
//Floor2UpMachinecodetimer = new Timer(Floor2UpMachinecode, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
|
|
|
|
|
//// 二楼料架配送
|
|
|
|
|
//Floor2RackDeliverytimer = new Timer(Floor2RackDelivery, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
|