<update>[important]新增双货叉堆垛机写任务逻辑;新增堆垛机状态查询接口
This commit is contained in:
parent
4ab21e2940
commit
fcb5b72d4f
|
|
@ -27,20 +27,20 @@ public class WcsLog
|
||||||
lock (writeLog)
|
lock (writeLog)
|
||||||
{
|
{
|
||||||
string LogAddress = AppDomain.CurrentDomain.BaseDirectory + "Log\\" + LogName;
|
string LogAddress = AppDomain.CurrentDomain.BaseDirectory + "Log\\" + LogName;
|
||||||
|
DirectoryInfo di = new(LogAddress);
|
||||||
|
if (di.Exists == false) { di.Create(); }
|
||||||
StringBuilder logBuilder = new();
|
StringBuilder logBuilder = new();
|
||||||
if (addTime)
|
if (addTime)
|
||||||
{
|
{
|
||||||
logBuilder.AppendLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss:fff}]");
|
logBuilder.AppendLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss:fff}]");
|
||||||
}
|
}
|
||||||
logBuilder.AppendLine($"{strLog}");
|
logBuilder.AppendLine($"{strLog}");
|
||||||
DirectoryInfo di = new(LogAddress);
|
|
||||||
if (di.Exists == false) { di.Create(); }
|
|
||||||
string logFileName = LogAddress + "\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".log";
|
string logFileName = LogAddress + "\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".log";
|
||||||
using FileStream fs = new(logFileName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
|
using FileStream fs = new(logFileName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
|
||||||
using StreamWriter sw = new(fs);
|
using StreamWriter sw = new(fs);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sw.WriteLine(logBuilder);
|
sw.Write(logBuilder);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,16 @@ public class GetLocationWithPageRequest
|
||||||
public string? SearchStr { get; set; }
|
public string? SearchStr { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 任务类型
|
/// 点位状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonPropertyName("locationStatus")]
|
[JsonPropertyName("locationStatus")]
|
||||||
public List<string>? LocationStatus { get; set; }
|
public List<int>? LocationStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 点位类型
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("locationType")]
|
||||||
|
public List<int>? LocationType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分页信息
|
/// 分页信息
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace WcsMain.ApiServe.Controllers.Dto.WcsDto.Stacker;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询堆垛机状态的返回实体
|
||||||
|
/// </summary>
|
||||||
|
public class GetStackerStatusResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备编号
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("stackerId")]
|
||||||
|
public int? StackerId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 堆垛机名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("stackerName")]
|
||||||
|
public string? StackerName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 堆垛机状态
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// 0 - 禁用
|
||||||
|
/// 1 - 启用
|
||||||
|
/// </remarks>
|
||||||
|
[JsonPropertyName("stackerStatus")]
|
||||||
|
public int? StackerStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 货叉状态
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("forkStatus")]
|
||||||
|
public string? ForkStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询结果
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("msg")]
|
||||||
|
public string? Message { get; set; } = "-";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前运行任务号
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("plcId")]
|
||||||
|
public string? PlcId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 控制方式
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("controlModel")]
|
||||||
|
public string? ControlModel { get; set; } = "0";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备状态
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("stackerStatusEquip")]
|
||||||
|
public string? StackerStatusEquip { get; set; } = "0";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 排
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("queue")]
|
||||||
|
public int? Queue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 列
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("line")]
|
||||||
|
public int? Line { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 层
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("layer")]
|
||||||
|
public int? Layer { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 深
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("depth")]
|
||||||
|
public int? Depth { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 条码
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("code")]
|
||||||
|
public string? Code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 报警编号
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("errCode")]
|
||||||
|
public int? ErrCode { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using WcsMain.ApiServe.ControllerFilter.ExceptionFilter;
|
using WcsMain.ApiServe.ControllerFilter.ExceptionFilter;
|
||||||
using WcsMain.ApiServe.Controllers.Dto;
|
using WcsMain.ApiServe.Controllers.Dto;
|
||||||
|
using WcsMain.ApiServe.Controllers.Dto.WcsDto.Stacker;
|
||||||
using WcsMain.ApiServe.Service.WcsService;
|
using WcsMain.ApiServe.Service.WcsService;
|
||||||
using WcsMain.DataBase.TableEntity;
|
using WcsMain.DataBase.TableEntity;
|
||||||
|
|
||||||
|
|
@ -24,4 +25,14 @@ public class StackerController(StackerService stackerService) : ControllerBase
|
||||||
{
|
{
|
||||||
return _stackerService.GetStacker();
|
return _stackerService.GetStacker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询所有的 堆垛机状态信息 ---- 从设备返回
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("getStackerStatus")]
|
||||||
|
public WcsApiResponse<List<GetStackerStatusResponse>> GetStackerStatus()
|
||||||
|
{
|
||||||
|
return _stackerService.GetStackerStatus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,16 +1,20 @@
|
||||||
using WcsMain.ApiServe.Controllers.Dto;
|
using System.Collections.Generic;
|
||||||
|
using WcsMain.ApiServe.Controllers.Dto;
|
||||||
|
using WcsMain.ApiServe.Controllers.Dto.WcsDto.Stacker;
|
||||||
using WcsMain.ApiServe.Factory;
|
using WcsMain.ApiServe.Factory;
|
||||||
using WcsMain.DataBase.Dao;
|
using WcsMain.DataBase.Dao;
|
||||||
using WcsMain.DataBase.TableEntity;
|
using WcsMain.DataBase.TableEntity;
|
||||||
|
using WcsMain.PlcOperation.Stacker;
|
||||||
using WcsMain.WcsAttribute.AutoFacAttribute;
|
using WcsMain.WcsAttribute.AutoFacAttribute;
|
||||||
|
|
||||||
namespace WcsMain.ApiServe.Service.WcsService;
|
namespace WcsMain.ApiServe.Service.WcsService;
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
public class StackerService(AppStackerDao stackerDao)
|
public class StackerService(AppStackerDao stackerDao, StackerOperation stackerOperation)
|
||||||
{
|
{
|
||||||
|
|
||||||
private readonly AppStackerDao _stackerDao = stackerDao;
|
private readonly AppStackerDao _stackerDao = stackerDao;
|
||||||
|
private readonly StackerOperation _stackerOperation = stackerOperation;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询所有的 堆垛机信息
|
/// 查询所有的 堆垛机信息
|
||||||
|
|
@ -26,4 +30,49 @@ public class StackerService(AppStackerDao stackerDao)
|
||||||
return WcsApiResponseFactory.Success(stackers, "查询成功");
|
return WcsApiResponseFactory.Success(stackers, "查询成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询所有的 堆垛机状态信息 ---- 从设备返回
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WcsApiResponse<List<GetStackerStatusResponse>> GetStackerStatus()
|
||||||
|
{
|
||||||
|
List<AppStacker>? stackers = _stackerDao.Select(new AppStacker());
|
||||||
|
if (stackers == default)
|
||||||
|
{
|
||||||
|
return WcsApiResponseFactory.DataBaseErr<List<GetStackerStatusResponse>>();
|
||||||
|
}
|
||||||
|
List<GetStackerStatusResponse> getStackerStatusResponses = [];
|
||||||
|
foreach(AppStacker stacker in stackers)
|
||||||
|
{
|
||||||
|
GetStackerStatusResponse stackerStatusResponse = new()
|
||||||
|
{
|
||||||
|
StackerId = stacker.StackerId,
|
||||||
|
StackerName = stacker.StackerName,
|
||||||
|
StackerStatus = stacker.StackerStatus,
|
||||||
|
ForkStatus = stacker.ForkStatus,
|
||||||
|
};
|
||||||
|
/* 获取堆垛机状态 */
|
||||||
|
var (errMsg, stackerInfo) = _stackerOperation.GetStackerInfo((int)stacker.StackerId!);
|
||||||
|
if(string.IsNullOrEmpty(errMsg) && stackerInfo != default)
|
||||||
|
{
|
||||||
|
stackerStatusResponse.Message = "查询成功";
|
||||||
|
stackerStatusResponse.PlcId = stackerInfo.PlcId.ToString();
|
||||||
|
stackerStatusResponse.ControlModel = stackerInfo.ControlModel.ToString();
|
||||||
|
stackerStatusResponse.StackerStatusEquip = stackerInfo.StackerStatus.ToString();
|
||||||
|
stackerStatusResponse.Queue = stackerInfo.Row;
|
||||||
|
stackerStatusResponse.Line = stackerInfo.Line;
|
||||||
|
stackerStatusResponse.Layer = stackerInfo.Layer;
|
||||||
|
stackerStatusResponse.Depth = stackerInfo.Depth;
|
||||||
|
stackerStatusResponse.Code = stackerInfo.Code.ToString();
|
||||||
|
stackerStatusResponse.ErrCode = stackerInfo.ErrCode;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stackerStatusResponse.Message = errMsg;
|
||||||
|
}
|
||||||
|
getStackerStatusResponses.Add(stackerStatusResponse);
|
||||||
|
}
|
||||||
|
return WcsApiResponseFactory.Success(getStackerStatusResponses, "查询成功");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,4 +46,9 @@ public class ApplicationConfig
|
||||||
/// 是否仅以 api 形式运行,此状态下不会运行 Wcs 相关内容
|
/// 是否仅以 api 形式运行,此状态下不会运行 Wcs 相关内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool? ApiOnly { get; set; }
|
public bool? ApiOnly { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 程序的语言
|
||||||
|
/// </summary>
|
||||||
|
public string? Language { get; set; } = "zh-CN";
|
||||||
}
|
}
|
||||||
|
|
@ -4,13 +4,14 @@ using WcsMain.PlcOperation;
|
||||||
namespace WcsMain.Business.CirculationTask.CommonCirculation;
|
namespace WcsMain.Business.CirculationTask.CommonCirculation;
|
||||||
|
|
||||||
[Circulation]
|
[Circulation]
|
||||||
public class HeartBeat
|
public class HeartBeat(ConveyOperation conveyOperation)
|
||||||
{
|
{
|
||||||
|
private readonly ConveyOperation _conveyOperation = conveyOperation;
|
||||||
|
|
||||||
//[Circulation("输送机心跳", 1000)]
|
[Circulation("输送机心跳", 1000)]
|
||||||
public bool ConveyHeartBeat()
|
public bool ConveyHeartBeat()
|
||||||
{
|
{
|
||||||
ConveyOperation.Instance().WriteHeartBeat();
|
_conveyOperation.WriteHeartBeat();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
469
WcsMain/Business/CirculationTask/Stacker/ExeTaskDoubleFork.cs
Normal file
469
WcsMain/Business/CirculationTask/Stacker/ExeTaskDoubleFork.cs
Normal file
|
|
@ -0,0 +1,469 @@
|
||||||
|
using CirculateTool;
|
||||||
|
using WcsMain.Business.CommonAction;
|
||||||
|
using WcsMain.Common;
|
||||||
|
using WcsMain.DataBase.Dao;
|
||||||
|
using WcsMain.DataBase.MixDao;
|
||||||
|
using WcsMain.DataBase.TableEntity;
|
||||||
|
using WcsMain.DataService;
|
||||||
|
using WcsMain.Enum.Stacker;
|
||||||
|
using WcsMain.Enum.TaskEnum;
|
||||||
|
using WcsMain.ExtendMethod;
|
||||||
|
using WcsMain.PlcOperation;
|
||||||
|
using WcsMain.PlcOperation.Entity.Stacker;
|
||||||
|
using WcsMain.PlcOperation.Stacker;
|
||||||
|
using static Dm.net.buffer.ByteArrayBuffer;
|
||||||
|
|
||||||
|
namespace WcsMain.Business.CirculationTask.Stacker;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 双货叉单深位执行堆垛机任务 ---- 卡特模式
|
||||||
|
/// </summary>
|
||||||
|
[Circulation("双货叉单深位执行堆垛机任务")]
|
||||||
|
public class ExeTaskDoubleFork(
|
||||||
|
StackerOperation stackerOperation, AppWcsTaskDao wcsTaskDao, WCSTaskExecuteEvent wcsTaskEvent,
|
||||||
|
ConveyOperation conveyOperation, DataBaseData dataBaseData)
|
||||||
|
{
|
||||||
|
private readonly WCSTaskExecuteEvent _wcsTaskEvent = wcsTaskEvent;
|
||||||
|
private readonly AppWcsTaskDao _wcsTaskDao = wcsTaskDao;
|
||||||
|
private readonly StackerOperation _stackerOperation = stackerOperation;
|
||||||
|
private readonly ConveyOperation _conveyOperation = conveyOperation;
|
||||||
|
private readonly DataBaseData _dataBaseData = dataBaseData;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行堆垛机任务
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Circulation("执行堆垛机任务")]
|
||||||
|
public bool ExecuteStackerTask()
|
||||||
|
{
|
||||||
|
List<Task> tasks = [];
|
||||||
|
foreach (var stacker in CommonData.AppStackers.Open())
|
||||||
|
{
|
||||||
|
tasks.Add(Task.Factory.StartNew(() =>
|
||||||
|
{
|
||||||
|
var stackerUseStatus = _stackerOperation.StackerCanUse(stacker.StackerId, out int plcId, out int spare1);
|
||||||
|
if (stackerUseStatus == StackerUseStatusEnum.Free)
|
||||||
|
{
|
||||||
|
/* 空闲时正常执行任务 */
|
||||||
|
// 移库
|
||||||
|
bool exeMoveTask = ExecuteMoveTask(stacker.StackerId);
|
||||||
|
if (exeMoveTask) return;
|
||||||
|
// 出库
|
||||||
|
bool exeOutTask = ExecuteOutTask(stacker.StackerId);
|
||||||
|
if (exeOutTask) return;
|
||||||
|
// 入库
|
||||||
|
bool exeInTask = ExecuteInTask(stacker.StackerId);
|
||||||
|
if (exeInTask) return;
|
||||||
|
// 拣选
|
||||||
|
//bool exePickTask = ExecutePickTask(stacker.StackerId);
|
||||||
|
//if (exePickTask) return;
|
||||||
|
}
|
||||||
|
if (stackerUseStatus == StackerUseStatusEnum.waitTask)
|
||||||
|
{
|
||||||
|
/* 重复入库时执行任务 */
|
||||||
|
bool exeDoubleInTask = ExecuteDoubleInTask(stacker.StackerId, plcId, 1);
|
||||||
|
if (exeDoubleInTask) return;
|
||||||
|
exeDoubleInTask = ExecuteDoubleInTask(stacker.StackerId, spare1, 2);
|
||||||
|
if (exeDoubleInTask) return;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
Task.WaitAll([.. tasks]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行堆垛机入库任务,若执行了任务则返回 true
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stackerId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private bool ExecuteInTask(int? stackerId)
|
||||||
|
{
|
||||||
|
if (stackerId == default) return false;
|
||||||
|
/* 检查入库站台是否允许取货 */
|
||||||
|
bool allowGetGoods = _conveyOperation.AllGetVehicle(stackerId.ToString());
|
||||||
|
if(!allowGetGoods) return false; // 入库站台不允许取货
|
||||||
|
/* 读取入库站台的条码 */
|
||||||
|
var codes = _conveyOperation.ReadConveyCode(stackerId.ToString());
|
||||||
|
if(codes == default || codes.Count != 2) return false;
|
||||||
|
/* 构造任务数据 */
|
||||||
|
bool isWriteTask = false; // 指示是否写入任务
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
/* 校验货叉开启 */
|
||||||
|
string forkStatus = CommonData.AppStackers.First(f => f.StackerId == stackerId).ForkStatus ?? "";
|
||||||
|
if (forkStatus.Length <= i || forkStatus[i] != '1') continue; // 获取数据失败或者货叉未开启
|
||||||
|
var code = codes[i];
|
||||||
|
if (string.IsNullOrEmpty(code)) continue; // 检查条码是否为空
|
||||||
|
ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,入库位置:{i + 1} 返回:{code}");
|
||||||
|
if (code == "NoRead") // 检查条码是否为 NoRead
|
||||||
|
{
|
||||||
|
/* 检查卸货站台是否允许卸货 */
|
||||||
|
bool allowSetGoods = _conveyOperation.AllSetVehicle(stackerId.ToString());
|
||||||
|
if (!allowSetGoods) continue; // 出库站台不允许取货
|
||||||
|
/* 生成一个直接卸货出去的任务 */
|
||||||
|
int? plcId = _dataBaseData.GetNewPlcTaskId();
|
||||||
|
if(plcId == default || plcId == 0) continue;
|
||||||
|
StackerPlcTask errTask = StackerPlcTask.DefaultErrTask((int)plcId!, (int)stackerId!, i + 1);
|
||||||
|
string WriteTaskErrText = _stackerOperation.WriteTask(errTask, i + 1);
|
||||||
|
if(string.IsNullOrEmpty(WriteTaskErrText)) // 写入成功
|
||||||
|
{
|
||||||
|
ConsoleLog.Success($"{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code},写入任务成功,{errTask}");
|
||||||
|
isWriteTask = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code},写入任务失败,{errTask},异常信息:{WriteTaskErrText},");
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var wcsTasks = _wcsTaskDao.Select(new AppWcsTask { VehicleNo = code, TaskStatus = (int)WcsTaskStatusEnum.create });
|
||||||
|
if(wcsTasks == default) // 查询任务失败
|
||||||
|
{
|
||||||
|
ConsoleLog.Exception($"【警告】{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code} 查找任务失败,和数据库服务器连接中断");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(wcsTasks.Count < 1) // 没有任务
|
||||||
|
{
|
||||||
|
/* 检查卸货站台是否允许卸货 */
|
||||||
|
bool allowSetGoods = _conveyOperation.AllSetVehicle(stackerId.ToString());
|
||||||
|
if (!allowSetGoods) continue; // 出库站台不允许取货
|
||||||
|
/* 生成一个直接卸货出去的任务 */
|
||||||
|
ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code} 没有找到对应任务");
|
||||||
|
int? plcId = _dataBaseData.GetNewPlcTaskId();
|
||||||
|
if (plcId == default || plcId == 0) continue;
|
||||||
|
StackerPlcTask errTask = StackerPlcTask.DefaultErrTask((int)plcId!, (int)stackerId!, i + 1, code.ToPlcVehicleNo());
|
||||||
|
string WriteTaskErrText = _stackerOperation.WriteTask(errTask, i + 1);
|
||||||
|
if (string.IsNullOrEmpty(WriteTaskErrText)) // 写入成功
|
||||||
|
{
|
||||||
|
ConsoleLog.Success($"{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code},写入任务成功,{errTask}");
|
||||||
|
isWriteTask = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code},写入任务失败,{errTask},异常信息:{WriteTaskErrText},");
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var wcsTask = wcsTasks[0]; // 找出第一个任务
|
||||||
|
/* 校验终点是否正确 */
|
||||||
|
var destinationLocationInfo = CommonData.AppLocations.DetailWithWcsLocation(wcsTask.Destination);
|
||||||
|
if(destinationLocationInfo == default) // 任务终点错误,理论上此处不应该出现异常
|
||||||
|
{
|
||||||
|
/* 检查卸货站台是否允许卸货 */
|
||||||
|
bool allowSetGoods = _conveyOperation.AllSetVehicle(stackerId.ToString());
|
||||||
|
if (!allowSetGoods) continue; // 出库站台不允许取货
|
||||||
|
/* 生成一个直接卸货出去的任务 */
|
||||||
|
ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code} 无法识别的入库库位");
|
||||||
|
int? plcId = _dataBaseData.GetNewPlcTaskId();
|
||||||
|
if (plcId == default || plcId == 0) continue;
|
||||||
|
StackerPlcTask errTask = StackerPlcTask.DefaultErrTask((int)plcId!, (int)stackerId!, i + 1, code.ToPlcVehicleNo());
|
||||||
|
string WriteTaskErrText = _stackerOperation.WriteTask(errTask, i + 1);
|
||||||
|
if (string.IsNullOrEmpty(WriteTaskErrText)) // 写入成功
|
||||||
|
{
|
||||||
|
ConsoleLog.Success($"{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code},写入任务成功,{errTask}");
|
||||||
|
_wcsTaskEvent.ErrTaskEvent(wcsTask, "入库库位不正确");
|
||||||
|
isWriteTask = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code},写入任务失败,{errTask},异常信息:{WriteTaskErrText},");
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* 判断冲突货位是否有任务 */
|
||||||
|
var runningWcsTasks = _wcsTaskDao.QueryTaskWithWcsLocation(destinationLocationInfo.InterveneLocation);
|
||||||
|
if (runningWcsTasks == default) continue; // 查询失败
|
||||||
|
if(runningWcsTasks.Count > 0) continue; // 存在冲突点位,等待
|
||||||
|
/* 下发任务 */
|
||||||
|
StackerPlcTask stackerTask = wcsTask.ToStackerInTask((int)stackerId!, i + 1, destinationLocationInfo);
|
||||||
|
string WriteStackerTaskErrText = _stackerOperation.WriteTask(stackerTask, i + 1);
|
||||||
|
if (string.IsNullOrEmpty(WriteStackerTaskErrText)) // 写入成功
|
||||||
|
{
|
||||||
|
ConsoleLog.Success($"{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code},写入任务成功,{stackerTask}");
|
||||||
|
_wcsTaskEvent.StartTaskEvent(wcsTask); // 任务开始
|
||||||
|
isWriteTask = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code},写入任务失败,{stackerTask},异常信息:{WriteStackerTaskErrText},");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isWriteTask)
|
||||||
|
{
|
||||||
|
string confirmResult = _stackerOperation.WriteTaskConfirm(stackerId); // 写入任务确认
|
||||||
|
ConsoleLog.Info($"堆垛机入库任务写任务确认;信息:{(string.IsNullOrEmpty(confirmResult) ? "成功" : confirmResult)}");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
}
|
||||||
|
return isWriteTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行堆垛机出库任务,若执行了任务则返回 true
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stackerId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool ExecuteOutTask(int? stackerId)
|
||||||
|
{
|
||||||
|
if (stackerId == default) return false;
|
||||||
|
/* 检查出库站台是否可以卸货 */
|
||||||
|
bool allowSetGoods = _conveyOperation.AllSetVehicle(stackerId.ToString());
|
||||||
|
if (!allowSetGoods) return false; // 出库站台不允许取货
|
||||||
|
var wcsTasks = _wcsTaskDao.SelectOutTaskWithStacker((int)stackerId!);
|
||||||
|
if (wcsTasks == default)
|
||||||
|
{
|
||||||
|
ConsoleLog.Exception(string.Format("【异常】{0} 号堆垛机出库任务查询失败,与数据库连接异常", stackerId));
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (wcsTasks.Count == 0) return false;
|
||||||
|
bool isWriteTask = false; // 指示是否写入任务
|
||||||
|
int writeTaskCount = 0; // 表示执行了多少条任务
|
||||||
|
for (int i = 0; i < wcsTasks.Count; i++)
|
||||||
|
{
|
||||||
|
if (writeTaskCount >= 2) break; // 最多执行两条
|
||||||
|
/* 校验货叉开启 */
|
||||||
|
string forkStatus = CommonData.AppStackers.First(f => f.StackerId == stackerId).ForkStatus ?? "";
|
||||||
|
if (forkStatus.Length <= i || forkStatus[i] != '1')
|
||||||
|
{
|
||||||
|
writeTaskCount ++;
|
||||||
|
continue; // 获取数据失败或者货叉未开启
|
||||||
|
}
|
||||||
|
var wcsTask = wcsTasks[i];
|
||||||
|
/* 校验起点是否正确 */
|
||||||
|
var originLocationInfo = CommonData.AppLocations.DetailWithWcsLocation(wcsTask.Origin);
|
||||||
|
if (originLocationInfo == default) // 任务起点错误,理论上此处不应该出现异常
|
||||||
|
{
|
||||||
|
ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,出库库位:{wcsTask.Origin} 条码:{wcsTask.VehicleNo} 无法识别的出库库位");
|
||||||
|
_wcsTaskEvent.ErrTaskEvent(wcsTask, "出库的库位不正确");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* 判断冲突货位是否有任务 */
|
||||||
|
var runningWcsTasks = _wcsTaskDao.QueryTaskWithWcsLocation(originLocationInfo.InterveneLocation);
|
||||||
|
if (runningWcsTasks == default) continue; // 查询失败
|
||||||
|
if (runningWcsTasks.Count > 0) continue; // 存在冲突点位,等待
|
||||||
|
/* 下发任务 */
|
||||||
|
StackerPlcTask stackerTask = wcsTask.ToStackerOutTask((int)stackerId!, i + 1, originLocationInfo);
|
||||||
|
string WriteStackerTaskErrText = _stackerOperation.WriteTask(stackerTask, i + 1);
|
||||||
|
if (string.IsNullOrEmpty(WriteStackerTaskErrText)) // 写入成功
|
||||||
|
{
|
||||||
|
ConsoleLog.Success($"{stackerId} 号堆垛机,出库位置:{i + 1} 条码:{wcsTask.VehicleNo},写入任务成功,{stackerTask}");
|
||||||
|
_wcsTaskEvent.StartTaskEvent(wcsTask); // 任务开始
|
||||||
|
writeTaskCount++;
|
||||||
|
isWriteTask = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,出库位置:{i + 1} 条码:{wcsTask.VehicleNo},写入任务失败,{stackerTask},异常信息:{WriteStackerTaskErrText},");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isWriteTask)
|
||||||
|
{
|
||||||
|
string confirmResult = _stackerOperation.WriteTaskConfirm(stackerId); // 写入任务确认
|
||||||
|
ConsoleLog.Info($"堆垛机出库任务写任务确认;信息:{(string.IsNullOrEmpty(confirmResult) ? "成功" : confirmResult)}");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
}
|
||||||
|
return isWriteTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行堆垛机拣选任务,若执行了任务则返回 true
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stackerId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool ExecutePickTask(int? stackerId)
|
||||||
|
{
|
||||||
|
if (stackerId == default) return false;
|
||||||
|
var wcsTasks = _wcsTaskDao.SelectPickOutTaskWithStacker((int)stackerId!);
|
||||||
|
if (wcsTasks == default)
|
||||||
|
{
|
||||||
|
ConsoleLog.Error($"【异常】{stackerId} 号堆垛机拣选任务查询失败,与数据库连接异常");
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (wcsTasks.Count == 0) return false;
|
||||||
|
var wcsTask = wcsTasks[0]; // 取第一条任务
|
||||||
|
/* 校验出库站台是否可以卸货 */
|
||||||
|
// TODO
|
||||||
|
/* 检验并返回起点终点信息 */
|
||||||
|
var originLocationInfo = CommonData.AppLocations.DetailWithWcsLocation(wcsTask.Origin);
|
||||||
|
var destinationLocationInfo = CommonData.AppLocations.DetailWithWcsLocation(wcsTask.Destination);
|
||||||
|
if (destinationLocationInfo == default || originLocationInfo == default) // 起点终点错误,直接标记错误
|
||||||
|
{
|
||||||
|
// 已经在接口内做了检查,按道理此处不会出错。直接返回异常,任务直接取消
|
||||||
|
ConsoleLog.Warning($"【警告】任务号:{wcsTask.TaskId},Plc任务号:{wcsTask.PlcId} 无法执行,起点或者终点存在异常");
|
||||||
|
_wcsTaskEvent.ErrTaskEvent(wcsTask, $"起点或者终点存在异常");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
StackerPlcTask stackerTask = new()
|
||||||
|
{
|
||||||
|
StackerId = stackerId,
|
||||||
|
PlcId = wcsTask.PlcId,
|
||||||
|
TaskType = Convert.ToInt16(wcsTask.TaskType),
|
||||||
|
GetStand = 0,
|
||||||
|
InTunnelId = Convert.ToInt16(stackerId),
|
||||||
|
OutTunnelId = Convert.ToInt16(stackerId),
|
||||||
|
SetStand = 0,
|
||||||
|
GetQueue = Convert.ToInt16(originLocationInfo.Queue),
|
||||||
|
GetLine = Convert.ToInt16(originLocationInfo.Line),
|
||||||
|
GetLayer = Convert.ToInt16(originLocationInfo.Layer),
|
||||||
|
GetDeep = Convert.ToInt16(originLocationInfo.Depth),
|
||||||
|
SetQueue = Convert.ToInt16(destinationLocationInfo.Queue),
|
||||||
|
SetLine = Convert.ToInt16(destinationLocationInfo.Line),
|
||||||
|
SetLayer = Convert.ToInt16(destinationLocationInfo.Layer),
|
||||||
|
SetDeep = Convert.ToInt16(destinationLocationInfo.Depth),
|
||||||
|
Size = Convert.ToInt16(wcsTask.VehicleSize),
|
||||||
|
Weight = Convert.ToInt16(wcsTask.Weight),
|
||||||
|
Code = wcsTask.PlcVehicleNo ?? 0,
|
||||||
|
};
|
||||||
|
var writeStackerTaskErrText = _stackerOperation.WriteTask(stackerTask);
|
||||||
|
if (string.IsNullOrEmpty(writeStackerTaskErrText))
|
||||||
|
{
|
||||||
|
ConsoleLog.Success($"堆垛机:{stackerId} 写入拣选任务成功,箱号:{wcsTask.VehicleNo},PlcId:{wcsTask.PlcId};{wcsTask.Origin} => {wcsTask.Destination}");
|
||||||
|
_wcsTaskEvent.StartTaskEvent(wcsTask);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConsoleLog.Warning($"【警告】堆垛机:{stackerId} 写入拣选任务失败,箱号:{wcsTask.VehicleNo},PlcId:{wcsTask.PlcId};{wcsTask.Origin} => {wcsTask.Destination},异常信息:{writeStackerTaskErrText}");
|
||||||
|
_wcsTaskEvent.ErrTaskEvent(wcsTask, $"写入任务失败,异常信息:{writeStackerTaskErrText}");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行堆垛机移库任务,若执行了任务则返回 true
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stackerId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool ExecuteMoveTask(int? stackerId)
|
||||||
|
{
|
||||||
|
if (stackerId == default) return false;
|
||||||
|
var wcsTasks = _wcsTaskDao.SelectMoveTaskWithStacker((int)stackerId!);
|
||||||
|
if (wcsTasks == default)
|
||||||
|
{
|
||||||
|
ConsoleLog.Error($"【异常】{stackerId} 号堆垛机移库任务查询失败,与数据库连接异常");
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (wcsTasks.Count == 0) return false;
|
||||||
|
bool isWriteTask = false; // 指示是否写入任务
|
||||||
|
int writeTaskCount = 0; // 表示执行了多少条任务
|
||||||
|
for (int i = 0; i < wcsTasks.Count; i++)
|
||||||
|
{
|
||||||
|
if (writeTaskCount >= 2) break; // 最多执行两条
|
||||||
|
/* 校验货叉开启 */
|
||||||
|
string forkStatus = CommonData.AppStackers.First(f => f.StackerId == stackerId).ForkStatus ?? "";
|
||||||
|
if (forkStatus.Length <= i || forkStatus[i] != '1')
|
||||||
|
{
|
||||||
|
writeTaskCount++;
|
||||||
|
continue; // 获取数据失败或者货叉未开启
|
||||||
|
}
|
||||||
|
var wcsTask = wcsTasks[i];
|
||||||
|
/* 校验起点是否正确 */
|
||||||
|
var originLocationInfo = CommonData.AppLocations.DetailWithWcsLocation(wcsTask.Origin);
|
||||||
|
var destinationLocationInfo = CommonData.AppLocations.DetailWithWcsLocation(wcsTask.Origin);
|
||||||
|
if (originLocationInfo == default || destinationLocationInfo == default) // 任务起点终点错误,理论上此处不应该出现异常
|
||||||
|
{
|
||||||
|
ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,移库库位:{wcsTask.Origin} 条码:{wcsTask.VehicleNo} 无法识别的库位");
|
||||||
|
_wcsTaskEvent.ErrTaskEvent(wcsTask, "移库的库位不正确");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* 判断冲突货位是否有任务,起点终点都要判断 */
|
||||||
|
var runningWcsTasks = _wcsTaskDao.QueryTaskWithWcsLocation(destinationLocationInfo.InterveneLocation, originLocationInfo.InterveneLocation);
|
||||||
|
if (runningWcsTasks == default) continue; // 查询失败
|
||||||
|
if (runningWcsTasks.Count > 0) continue; // 存在冲突点位,等待
|
||||||
|
/* 下发任务 */
|
||||||
|
StackerPlcTask stackerTask = wcsTask.ToStackerMoveTask((int)stackerId!, originLocationInfo, destinationLocationInfo);
|
||||||
|
string WriteStackerTaskErrText = _stackerOperation.WriteTask(stackerTask, i + 1);
|
||||||
|
if (string.IsNullOrEmpty(WriteStackerTaskErrText)) // 写入成功
|
||||||
|
{
|
||||||
|
ConsoleLog.Success($"{stackerId} 号堆垛机,移库位置:{i + 1} 条码:{wcsTask.VehicleNo},写入任务成功,{stackerTask}");
|
||||||
|
_wcsTaskEvent.StartTaskEvent(wcsTask); // 任务开始
|
||||||
|
writeTaskCount++;
|
||||||
|
isWriteTask = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,移库位置:{i + 1} 条码:{wcsTask.VehicleNo},写入任务失败,{stackerTask},异常信息:{WriteStackerTaskErrText},");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isWriteTask)
|
||||||
|
{
|
||||||
|
string confirmResult = _stackerOperation.WriteTaskConfirm(stackerId); // 写入任务确认
|
||||||
|
ConsoleLog.Info($"堆垛机移库任务写任务确认;信息:{(string.IsNullOrEmpty(confirmResult) ? "成功" : confirmResult)}");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
}
|
||||||
|
return isWriteTask;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行重复入库新任务,若执行了返回true
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stackerId"></param>
|
||||||
|
/// <param name="plcId"></param>
|
||||||
|
/// <param name="forkId">货叉编号</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool ExecuteDoubleInTask(int? stackerId, int plcId, int forkId)
|
||||||
|
{
|
||||||
|
if (stackerId == default || plcId == 0) return false;
|
||||||
|
/* 查找这个PlcId对应的wms任务 */
|
||||||
|
List<AppWcsTask>? doubleInTasks = _wcsTaskDao.Select(new AppWcsTask { PlcId = plcId });
|
||||||
|
if (doubleInTasks == default)
|
||||||
|
{
|
||||||
|
ConsoleLog.Error($"【异常】{stackerId} 号堆垛机重复入库任务检验失败,与数据库连接异常");
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (doubleInTasks.Count == 0) return false; // 找不到对应的PlcId的任务
|
||||||
|
var doubleTask = doubleInTasks[0];
|
||||||
|
/* 判断这个任务是否出现卸货位置有货 */
|
||||||
|
if(doubleTask.TaskStatus != (int)WcsTaskStatusEnum.doubleIn) { return false; } // 没有重复入库不执行下面方法
|
||||||
|
/* 查找这个任务的新任务 */
|
||||||
|
List<AppWcsTask>? newTasks = _wcsTaskDao.Select(new AppWcsTask { TaskId = doubleTask.TaskId, TaskType = (int)WcsTaskTypeEnum.newTaskForDoubleIn, TaskStatus = (int)WmsTaskStatusEnum.create });
|
||||||
|
if (newTasks == default)
|
||||||
|
{
|
||||||
|
ConsoleLog.Error($"【异常】{stackerId} 号堆垛机重复入库任务新任务查询失败,与数据库连接异常");
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (newTasks.Count == 0) return false;
|
||||||
|
var newTask = newTasks[0];
|
||||||
|
var destinationLocationInfo = CommonData.AppLocations.DetailWithWcsLocation(newTask.Destination);
|
||||||
|
if (destinationLocationInfo == default) // 终点错误,直接标记错误
|
||||||
|
{
|
||||||
|
// 已经在接口内做了检查,按道理此处不会出错。直接返回异常,任务直接取消
|
||||||
|
ConsoleLog.Warning($"【警告】任务号:{newTask.TaskId},Plc任务号:{newTask.PlcId} 无法执行,新终点存在异常");
|
||||||
|
_wcsTaskEvent.ErrTaskEvent(newTask, $"新终点存在异常");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/* 判断冲突货位是否有任务 */
|
||||||
|
var runningWcsTasks = _wcsTaskDao.QueryTaskWithWcsLocation(destinationLocationInfo.InterveneLocation);
|
||||||
|
if (runningWcsTasks == default) return false; // 查询失败
|
||||||
|
if (runningWcsTasks.Count > 0) return false; // 存在冲突点位,等待
|
||||||
|
/* 下发任务 */
|
||||||
|
StackerPlcTask stackerTask = newTask.ToStackerInTask((int)stackerId!, forkId, destinationLocationInfo);
|
||||||
|
var writeStackerTaskErrText = _stackerOperation.WriteTask(stackerTask);
|
||||||
|
if (string.IsNullOrEmpty(writeStackerTaskErrText))
|
||||||
|
{
|
||||||
|
ConsoleLog.Success($"堆垛机:{stackerId} 写入重复入库新任务成功,箱号:{newTask.VehicleNo},PlcId:{newTask.PlcId};新目的地:{newTask.Destination}");
|
||||||
|
_wcsTaskEvent.StartTaskEvent(newTask);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConsoleLog.Warning($"【警告】堆垛机:{stackerId} 写入重复入库新任务失败,箱号:{newTask.VehicleNo},PlcId:{newTask.PlcId};新目的地:{newTask.Destination},异常信息:{writeStackerTaskErrText}");
|
||||||
|
_wcsTaskEvent.ErrTaskEvent(newTask, $"写入任务失败,异常信息:{writeStackerTaskErrText}");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -14,7 +14,7 @@ namespace WcsMain.Business.CirculationTask.Stacker;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 执行堆垛机任务类
|
/// 执行堆垛机任务类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Circulation(tags: ["stacker"])]
|
//[Circulation(tags: ["stacker"])]
|
||||||
public class ExecuteWcsTask(StackerOperation stackerOperation, AppWcsTaskDao wcsTaskDao, WCSTaskExecuteEvent wcsTaskEvent)
|
public class ExecuteWcsTask(StackerOperation stackerOperation, AppWcsTaskDao wcsTaskDao, WCSTaskExecuteEvent wcsTaskEvent)
|
||||||
{
|
{
|
||||||
private readonly WCSTaskExecuteEvent _wcsTaskEvent = wcsTaskEvent;
|
private readonly WCSTaskExecuteEvent _wcsTaskEvent = wcsTaskEvent;
|
||||||
|
|
@ -30,7 +30,7 @@ public class ExecuteWcsTask(StackerOperation stackerOperation, AppWcsTaskDao wcs
|
||||||
{
|
{
|
||||||
foreach (var stacker in CommonData.AppStackers.Open())
|
foreach (var stacker in CommonData.AppStackers.Open())
|
||||||
{
|
{
|
||||||
var stackerUseStatus = _stackerOperation.StackerCanUse(stacker.StackerId, out int plcId);
|
var stackerUseStatus = _stackerOperation.StackerCanUse(stacker.StackerId, out int plcId, out int _);
|
||||||
if (stackerUseStatus == StackerUseStatusEnum.Free)
|
if (stackerUseStatus == StackerUseStatusEnum.Free)
|
||||||
{
|
{
|
||||||
/* 空闲时正常执行任务 */
|
/* 空闲时正常执行任务 */
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,8 @@ public class AppLocationDao
|
||||||
.WhereIF(appLocation.Line != null, w => w.Line == appLocation.Line)
|
.WhereIF(appLocation.Line != null, w => w.Line == appLocation.Line)
|
||||||
.WhereIF(appLocation.Layer != null, w => w.Layer == appLocation.Layer)
|
.WhereIF(appLocation.Layer != null, w => w.Layer == appLocation.Layer)
|
||||||
.WhereIF(appLocation.Depth != null, w => w.Depth == appLocation.Depth)
|
.WhereIF(appLocation.Depth != null, w => w.Depth == appLocation.Depth)
|
||||||
|
.WhereIF(appLocation.InterveneLocation != default, w => w.InterveneLocation == appLocation.InterveneLocation)
|
||||||
|
.WhereIF(appLocation.VehicleType == default, w => w.VehicleType == appLocation.VehicleType)
|
||||||
.WhereIF(!string.IsNullOrEmpty(appLocation.VehicleNo), w => w.VehicleNo == appLocation.VehicleNo)
|
.WhereIF(!string.IsNullOrEmpty(appLocation.VehicleNo), w => w.VehicleNo == appLocation.VehicleNo)
|
||||||
.OrderBy(o => new { o.Queue, o.Line, o.Layer, o.Depth })
|
.OrderBy(o => new { o.Queue, o.Line, o.Layer, o.Depth })
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
@ -133,19 +135,18 @@ public class AppLocationDao
|
||||||
|| w.WmsLocation!.Contains(request.SearchStr!)
|
|| w.WmsLocation!.Contains(request.SearchStr!)
|
||||||
|| w.VehicleNo!.Contains(request.SearchStr!)
|
|| w.VehicleNo!.Contains(request.SearchStr!)
|
||||||
|| w.Remark!.Contains(request.SearchStr!));
|
|| w.Remark!.Contains(request.SearchStr!));
|
||||||
if (request.LocationStatus != default) // 查询任务类型
|
if (request.LocationStatus != default) // 查询点位状态
|
||||||
{
|
{
|
||||||
List<int?> locationStatus = [];
|
List<int?> locationStatus = [];
|
||||||
foreach (var ls in request.LocationStatus)
|
request.LocationStatus.ForEach(item => locationStatus.Add(item));
|
||||||
{
|
|
||||||
if (ls == "空闲") { locationStatus.Add((int)LocationStatusEnum.empty); }
|
|
||||||
if (ls == "锁定") { locationStatus.Add((int)LocationStatusEnum.locked); }
|
|
||||||
if (ls == "占用") { locationStatus.Add((int)LocationStatusEnum.used); }
|
|
||||||
if (ls == "禁用") { locationStatus.Add((int)LocationStatusEnum.forbidden); }
|
|
||||||
if (ls == "特殊点位") { locationStatus.Add((int)LocationStatusEnum.special); }
|
|
||||||
}
|
|
||||||
sqlFuc.Where(w => locationStatus.Contains(w.LocationStatus));
|
sqlFuc.Where(w => locationStatus.Contains(w.LocationStatus));
|
||||||
}
|
}
|
||||||
|
if (request.LocationType != default) // 查询点位类型
|
||||||
|
{
|
||||||
|
List<int?> locationTypes = [];
|
||||||
|
request.LocationType.ForEach(item => locationTypes.Add(item));
|
||||||
|
sqlFuc.Where(w => locationTypes.Contains(w.LocationType));
|
||||||
|
}
|
||||||
sqlFuc.OrderBy(o => new { o.EquipmentId, o.Queue, o.Line, o.Layer, o.Depth });
|
sqlFuc.OrderBy(o => new { o.EquipmentId, o.Queue, o.Line, o.Layer, o.Depth });
|
||||||
var queryResult = sqlFuc.ToPageList(request.Page!.PageIndex, request.Page!.PageSize, ref totalRows);
|
var queryResult = sqlFuc.ToPageList(request.Page!.PageIndex, request.Page!.PageSize, ref totalRows);
|
||||||
return (queryResult, totalRows);
|
return (queryResult, totalRows);
|
||||||
|
|
|
||||||
|
|
@ -378,7 +378,7 @@ public class AppWcsTaskDao
|
||||||
{
|
{
|
||||||
sql.AppendLine($"and vehicle_no = '{vehicleNo}' ");
|
sql.AppendLine($"and vehicle_no = '{vehicleNo}' ");
|
||||||
}
|
}
|
||||||
sql.AppendLine("order by priority desc, create_time asc ");
|
sql.AppendLine("order by priority desc, wms_time asc ");
|
||||||
var sqlFuc = CommonTool.DbServe.Ado.SqlQuery<AppWcsTask>(sql.ToString());
|
var sqlFuc = CommonTool.DbServe.Ado.SqlQuery<AppWcsTask>(sql.ToString());
|
||||||
return sqlFuc;
|
return sqlFuc;
|
||||||
}
|
}
|
||||||
|
|
@ -448,4 +448,35 @@ public class AppWcsTaskDao
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据起点或者终点查找当前正在运行的任务
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="destinations"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<AppWcsTask>? QueryTaskWithWcsLocation(params string?[] destinations)
|
||||||
|
{
|
||||||
|
List<AppWcsTask>? result = [];
|
||||||
|
if (destinations.Length < 1) return result;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var destination in destinations)
|
||||||
|
{
|
||||||
|
var sqlFuc = CommonTool.DbServe.Queryable<AppWcsTask>()
|
||||||
|
.Where(x => x.Destination == destination || x.Origin == destination)
|
||||||
|
.Where(x => DataService.EnumData.GetWcsTaskStatusEnumRunningStatus().Contains((int)WcsTaskStatusEnum.running));
|
||||||
|
result.AddRange(sqlFuc.ToList());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_ = ex;
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -46,6 +46,13 @@ public class AppLocation
|
||||||
[JsonPropertyName("locationStatus")]
|
[JsonPropertyName("locationStatus")]
|
||||||
public int? LocationStatus { get; set; }
|
public int? LocationStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 点位类型
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "location_type")]
|
||||||
|
[JsonPropertyName("locationType")]
|
||||||
|
public int? LocationType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 排
|
/// 排
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -75,11 +82,18 @@ public class AppLocation
|
||||||
public int? Depth { get; set; }
|
public int? Depth { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 点位类型
|
/// 干涉的点位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnName = "location_type")]
|
[SugarColumn(ColumnName = "intervene_location")]
|
||||||
[JsonPropertyName("locationType")]
|
[JsonPropertyName("interveneLocation")]
|
||||||
public int? LocationType { get; set; }
|
public string? InterveneLocation { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 兼容的载具类型
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "vehicle_type")]
|
||||||
|
[JsonPropertyName("vehicleType")]
|
||||||
|
public string? VehicleType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 载具编号
|
/// 载具编号
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,13 @@ public class AppStacker
|
||||||
[JsonPropertyName("stackerStatus")]
|
[JsonPropertyName("stackerStatus")]
|
||||||
public int? StackerStatus { get; set; }
|
public int? StackerStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 货叉状态
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "fork_status")]
|
||||||
|
[JsonPropertyName("forkStatus")]
|
||||||
|
public string? ForkStatus { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 控制该堆垛机的PLC
|
/// 控制该堆垛机的PLC
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
20
WcsMain/DataService/EnumData.cs
Normal file
20
WcsMain/DataService/EnumData.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
using WcsMain.Enum.TaskEnum;
|
||||||
|
|
||||||
|
namespace WcsMain.DataService;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 枚举的数据操作
|
||||||
|
/// </summary>
|
||||||
|
public static class EnumData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 返回可以视作正在运行的任务的Wcs任务状态的枚举
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int[] GetWcsTaskStatusEnumRunningStatus()
|
||||||
|
{
|
||||||
|
return [(int)WcsTaskStatusEnum.leaveOrigin, (int)WcsTaskStatusEnum.running];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -10,5 +10,7 @@ public enum WcsTaskStatusEnum
|
||||||
running = 2,
|
running = 2,
|
||||||
arriveDestination = 3,
|
arriveDestination = 3,
|
||||||
complete = 4,
|
complete = 4,
|
||||||
|
doubleIn = 7,
|
||||||
|
emptyOut = 8,
|
||||||
err = 9,
|
err = 9,
|
||||||
}
|
}
|
||||||
|
|
@ -7,4 +7,7 @@ public enum WcsTaskTypeEnum
|
||||||
pick = 4, // 拣选任务
|
pick = 4, // 拣选任务
|
||||||
check = 10, // 盘点任务
|
check = 10, // 盘点任务
|
||||||
moveTask = 9, // 移库任务
|
moveTask = 9, // 移库任务
|
||||||
|
|
||||||
|
|
||||||
|
newTaskForDoubleIn = 21, // 卸货位置有货的新任务
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
using WcsMain.DataBase.TableEntity;
|
using WcsMain.DataBase.TableEntity;
|
||||||
|
using WcsMain.Enum.TaskEnum;
|
||||||
|
using WcsMain.PlcOperation.Entity.Stacker;
|
||||||
|
|
||||||
namespace WcsMain.ExtendMethod;
|
namespace WcsMain.ExtendMethod;
|
||||||
|
|
||||||
|
|
@ -34,4 +36,110 @@ public static class AppWcsTaskExtendMethod
|
||||||
if (wcsTask == default) return false;
|
if (wcsTask == default) return false;
|
||||||
return wcsTask.NextPlcId == default;
|
return wcsTask.NextPlcId == default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生成一个入库任务
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="wcsTask"></param>
|
||||||
|
/// <param name="stackerId"></param>
|
||||||
|
/// <param name="forkId"></param>
|
||||||
|
/// <param name="destinationDetail"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static StackerPlcTask ToStackerInTask(this AppWcsTask wcsTask, int stackerId, int forkId, AppLocation destinationDetail)
|
||||||
|
{
|
||||||
|
StackerPlcTask stackerTask = new()
|
||||||
|
{
|
||||||
|
StackerId = stackerId,
|
||||||
|
PlcId = wcsTask.PlcId,
|
||||||
|
TaskType = (int)WcsTaskTypeEnum.inTask,
|
||||||
|
GetStand = 0,
|
||||||
|
InTunnelId = Convert.ToInt16(stackerId),
|
||||||
|
OutTunnelId = Convert.ToInt16(stackerId),
|
||||||
|
SetStand = 0,
|
||||||
|
GetQueue = 2,
|
||||||
|
GetLine = Convert.ToInt16(forkId),
|
||||||
|
GetLayer = 1,
|
||||||
|
GetDeep = 1,
|
||||||
|
SetQueue = Convert.ToInt16(destinationDetail.Queue),
|
||||||
|
SetLine = Convert.ToInt16(destinationDetail.Line),
|
||||||
|
SetLayer = Convert.ToInt16(destinationDetail.Layer),
|
||||||
|
SetDeep = Convert.ToInt16(destinationDetail.Depth),
|
||||||
|
Size = Convert.ToInt16(wcsTask.VehicleSize),
|
||||||
|
Weight = Convert.ToInt16(wcsTask.Weight),
|
||||||
|
Code = wcsTask.PlcVehicleNo ?? 0,
|
||||||
|
};
|
||||||
|
return stackerTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生成一个入库任务
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="wcsTask"></param>
|
||||||
|
/// <param name="stackerId"></param>
|
||||||
|
/// <param name="forkId"></param>
|
||||||
|
/// <param name="originDetail"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static StackerPlcTask ToStackerOutTask(this AppWcsTask wcsTask, int stackerId, int forkId, AppLocation originDetail)
|
||||||
|
{
|
||||||
|
StackerPlcTask stackerTask = new()
|
||||||
|
{
|
||||||
|
StackerId = stackerId,
|
||||||
|
PlcId = wcsTask.PlcId,
|
||||||
|
TaskType = (int)WcsTaskTypeEnum.outTask,
|
||||||
|
GetStand = 0,
|
||||||
|
InTunnelId = Convert.ToInt16(stackerId),
|
||||||
|
OutTunnelId = Convert.ToInt16(stackerId),
|
||||||
|
SetStand = 0,
|
||||||
|
GetQueue = Convert.ToInt16(originDetail.Queue),
|
||||||
|
GetLine = Convert.ToInt16(originDetail.Queue),
|
||||||
|
GetLayer = Convert.ToInt16(originDetail.Queue),
|
||||||
|
GetDeep = Convert.ToInt16(originDetail.Queue),
|
||||||
|
SetQueue = 2,
|
||||||
|
SetLine = Convert.ToInt16(forkId),
|
||||||
|
SetLayer = 2,
|
||||||
|
SetDeep = 1,
|
||||||
|
Size = Convert.ToInt16(wcsTask.VehicleSize),
|
||||||
|
Weight = Convert.ToInt16(wcsTask.Weight),
|
||||||
|
Code = wcsTask.PlcVehicleNo ?? 0,
|
||||||
|
};
|
||||||
|
return stackerTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生成一个移库任务
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="wcsTask"></param>
|
||||||
|
/// <param name="stackerId"></param>
|
||||||
|
/// <param name="originDetail"></param>
|
||||||
|
/// <param name="destinationDetail"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static StackerPlcTask ToStackerMoveTask(this AppWcsTask wcsTask, int stackerId, AppLocation originDetail, AppLocation destinationDetail)
|
||||||
|
{
|
||||||
|
StackerPlcTask stackerTask = new()
|
||||||
|
{
|
||||||
|
StackerId = stackerId,
|
||||||
|
PlcId = wcsTask.PlcId,
|
||||||
|
TaskType = (int)WcsTaskTypeEnum.moveTask,
|
||||||
|
GetStand = 0,
|
||||||
|
InTunnelId = Convert.ToInt16(stackerId),
|
||||||
|
OutTunnelId = Convert.ToInt16(stackerId),
|
||||||
|
SetStand = 0,
|
||||||
|
GetQueue = Convert.ToInt16(originDetail.Queue),
|
||||||
|
GetLine = Convert.ToInt16(originDetail.Queue),
|
||||||
|
GetLayer = Convert.ToInt16(originDetail.Queue),
|
||||||
|
GetDeep = Convert.ToInt16(originDetail.Queue),
|
||||||
|
SetQueue = Convert.ToInt16(destinationDetail.Queue),
|
||||||
|
SetLine = Convert.ToInt16(destinationDetail.Line),
|
||||||
|
SetLayer = Convert.ToInt16(destinationDetail.Layer),
|
||||||
|
SetDeep = Convert.ToInt16(destinationDetail.Depth),
|
||||||
|
Size = Convert.ToInt16(wcsTask.VehicleSize),
|
||||||
|
Weight = Convert.ToInt16(wcsTask.Weight),
|
||||||
|
Code = wcsTask.PlcVehicleNo ?? 0,
|
||||||
|
};
|
||||||
|
return stackerTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
WcsMain/Language/Readme.txt
Normal file
1
WcsMain/Language/Readme.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
多语言版本尚未添加
|
||||||
|
|
@ -2,21 +2,71 @@
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using WcsMain.Common;
|
using WcsMain.Common;
|
||||||
using WcsMain.PlcOperation.Entity;
|
using WcsMain.PlcOperation.Entity;
|
||||||
|
using WcsMain.WcsAttribute.AutoFacAttribute;
|
||||||
|
|
||||||
namespace WcsMain.PlcOperation;
|
namespace WcsMain.PlcOperation;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 输送机操作 ---- 箱式线,不包含于立库库前设备,库前请参考堆垛机操作
|
/// 输送机操作 ---- 箱式线,不包含于立库库前设备,库前请参考堆垛机操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Component]
|
||||||
public class ConveyOperation
|
public class ConveyOperation
|
||||||
{
|
{
|
||||||
private static ConveyOperation? _instance;
|
/// <summary>
|
||||||
|
/// 写入输送机心跳
|
||||||
public static ConveyOperation Instance()
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string WriteHeartBeat()
|
||||||
{
|
{
|
||||||
return _instance ??= new ConveyOperation();
|
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return "PLC尚未连接。";
|
||||||
|
var (writeResult, _) = CommonTool.Siemens.WritePlcWhithName($"箱式线写心跳", (short)0);
|
||||||
|
return writeResult.Success ? string.Empty : writeResult.Message ?? "写入失败,未知原因";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 箱式线允许取货
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="point">要取货的点位</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool AllGetVehicle(string? point)
|
||||||
|
{
|
||||||
|
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return false;
|
||||||
|
var readResult = CommonTool.Siemens.ReadInt16WithName($"箱式线允许取货{point}");
|
||||||
|
return readResult.Success && readResult.Value == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 箱式线允许卸货
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="point">要取货的点位</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool AllSetVehicle(string? point)
|
||||||
|
{
|
||||||
|
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return false;
|
||||||
|
var readResult = CommonTool.Siemens.ReadInt16WithName($"箱式线允许卸货{point}");
|
||||||
|
return readResult.Success && readResult.Value == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取箱式线入库站台反馈的载具号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="point"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<string>? ReadConveyCode(string? point)
|
||||||
|
{
|
||||||
|
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return default;
|
||||||
|
var readResult1 = CommonTool.Siemens.ReadStringWithName($"箱式线入库载具号{point}-1", 20, Encoding.ASCII);
|
||||||
|
var readResult2 = CommonTool.Siemens.ReadStringWithName($"箱式线入库载具号{point}-2", 20, Encoding.ASCII);
|
||||||
|
if (!readResult1.Success! || !readResult2.Success!) return default;
|
||||||
|
// 返回读取到的任务号
|
||||||
|
return [Regex.Replace(readResult1.Value ?? "", "\\W", ""), Regex.Replace(readResult2.Value ?? "", "\\W", "")];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 写入箱式线任务
|
/// 写入箱式线任务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -40,24 +90,8 @@ public class ConveyOperation
|
||||||
return writeResult.Message ?? "写入失败,未知原因";
|
return writeResult.Message ?? "写入失败,未知原因";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 写入输送机心跳
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public string WriteHeartBeat()
|
|
||||||
{
|
|
||||||
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default)
|
|
||||||
{
|
|
||||||
// 未连接PLC
|
|
||||||
return "PLC尚未连接。";
|
|
||||||
}
|
|
||||||
var (writeResult, _) = CommonTool.Siemens.WritePlcWhithName($"箱式线写心跳", (short)0);
|
|
||||||
if (writeResult.Success)
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
return writeResult.Message ?? "写入失败,未知原因";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取箱式线出库站台状态
|
/// 获取箱式线出库站台状态
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using WcsMain.Enum.TaskEnum;
|
using System.Collections;
|
||||||
|
using WcsMain.Enum.TaskEnum;
|
||||||
|
|
||||||
namespace WcsMain.PlcOperation.Entity.Stacker;
|
namespace WcsMain.PlcOperation.Entity.Stacker;
|
||||||
|
|
||||||
|
|
@ -100,36 +101,45 @@ public class StackerPlcTask
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Code { get; set; }
|
public int Code { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"PlcId:{PlcId},{GetQueue}排{GetLine}列{GetLayer}层{GetDeep}深 --> {SetQueue}排{SetLine}列{SetLayer}层{SetDeep}深";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 默认的直接从入口搬出去的任务
|
/// 默认的直接从入口搬出去的任务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="plcId"></param>
|
/// <param name="plcId"></param>
|
||||||
/// <param name="stackerId"></param>
|
/// <param name="stackerId"></param>
|
||||||
|
/// <param name="forkId"></param>
|
||||||
/// <param name="vehicleNo"></param>
|
/// <param name="vehicleNo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static StackerPlcTask DefaultOutTask(int plcId, int stackerId, int vehicleNo = 999999999)
|
public static StackerPlcTask DefaultErrTask(int plcId, int stackerId, int forkId, int vehicleNo = 999999999)
|
||||||
{
|
{
|
||||||
StackerPlcTask noTaskStackerTask = new()
|
StackerPlcTask stackerTask = new()
|
||||||
{
|
{
|
||||||
|
StackerId = stackerId,
|
||||||
PlcId = plcId,
|
PlcId = plcId,
|
||||||
TaskType = Convert.ToInt16(TaskTypeEnum.inTask),
|
TaskType = Convert.ToInt16(WcsTaskTypeEnum.moveTask),
|
||||||
GetStand = 0,
|
GetStand = 0,
|
||||||
InTunnelId = Convert.ToInt16(stackerId),
|
InTunnelId = Convert.ToInt16(stackerId),
|
||||||
OutTunnelId = Convert.ToInt16(stackerId),
|
OutTunnelId = Convert.ToInt16(stackerId),
|
||||||
SetStand = 0,
|
SetStand = 0,
|
||||||
GetQueue = 1,
|
GetQueue = 2,
|
||||||
GetLine = 46,
|
GetLine = Convert.ToInt16(forkId),
|
||||||
GetLayer = 1,
|
GetLayer = 1,
|
||||||
GetDeep = 1,
|
GetDeep = 1,
|
||||||
SetQueue = 2,
|
SetQueue = 2,
|
||||||
SetLine = 46,
|
SetLine = Convert.ToInt16(forkId),
|
||||||
SetLayer = 1,
|
SetLayer = 2,
|
||||||
SetDeep = 1,
|
SetDeep = 1,
|
||||||
Size = 0,
|
Size = 0,
|
||||||
Weight = 0,
|
Weight = 0,
|
||||||
Code = vehicleNo
|
Code = vehicleNo,
|
||||||
};
|
};
|
||||||
return noTaskStackerTask;
|
return stackerTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -21,11 +21,13 @@ public class StackerOperation
|
||||||
/// 判断堆垛机状态,若是等待(二次申请)状态则带出当前的PlcId
|
/// 判断堆垛机状态,若是等待(二次申请)状态则带出当前的PlcId
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stackerId"></param>
|
/// <param name="stackerId"></param>
|
||||||
/// <param name="plcId"></param>
|
/// <param name="plcId1"></param>
|
||||||
|
/// <param name="spare1"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public StackerUseStatusEnum StackerCanUse(int? stackerId, out int plcId)
|
public StackerUseStatusEnum StackerCanUse(int? stackerId, out int plcId1, out int spare1)
|
||||||
{
|
{
|
||||||
plcId = 0;
|
plcId1 = 0;
|
||||||
|
spare1 = 0;
|
||||||
if (stackerId == default) return StackerUseStatusEnum.BusyOrErr;
|
if (stackerId == default) return StackerUseStatusEnum.BusyOrErr;
|
||||||
/* 获取堆垛机状态 */
|
/* 获取堆垛机状态 */
|
||||||
var (errMsg, stackerInfo) = GetStackerInfo((int)stackerId!);
|
var (errMsg, stackerInfo) = GetStackerInfo((int)stackerId!);
|
||||||
|
|
@ -39,7 +41,8 @@ public class StackerOperation
|
||||||
&& stackerInfo.ErrCode == 0;
|
&& stackerInfo.ErrCode == 0;
|
||||||
if(waitTask)
|
if(waitTask)
|
||||||
{
|
{
|
||||||
plcId = stackerInfo.PlcId;
|
plcId1 = stackerInfo.PlcId;
|
||||||
|
spare1 = stackerInfo.Spare1;
|
||||||
return StackerUseStatusEnum.waitTask;
|
return StackerUseStatusEnum.waitTask;
|
||||||
}
|
}
|
||||||
return StackerUseStatusEnum.BusyOrErr;
|
return StackerUseStatusEnum.BusyOrErr;
|
||||||
|
|
@ -72,7 +75,7 @@ public class StackerOperation
|
||||||
{
|
{
|
||||||
return ("设备尚未连接", default); // 未连接PLC
|
return ("设备尚未连接", default); // 未连接PLC
|
||||||
}
|
}
|
||||||
var readResult = CommonTool.Siemens.ReadByteWithName($"堆垛机状态反馈{stackerId}", 24);
|
var readResult = CommonTool.Siemens.ReadByteWithName($"堆垛机状态反馈{stackerId}", 50);
|
||||||
if (!readResult.Success || readResult.Value == default)
|
if (!readResult.Success || readResult.Value == default)
|
||||||
{
|
{
|
||||||
return (readResult.Message, default); // 读取失败
|
return (readResult.Message, default); // 读取失败
|
||||||
|
|
@ -95,7 +98,7 @@ public class StackerOperation
|
||||||
// ForkCount = Convert.ToInt32(CommonTool.Siemens.Trans<int>(data, 32)), // 货叉动作次数
|
// ForkCount = Convert.ToInt32(CommonTool.Siemens.Trans<int>(data, 32)), // 货叉动作次数
|
||||||
// SubmitPlcId = Convert.ToInt32(CommonTool.Siemens.Trans<int>(data, 36)), // 提交的任务
|
// SubmitPlcId = Convert.ToInt32(CommonTool.Siemens.Trans<int>(data, 36)), // 提交的任务
|
||||||
// DeletePlcId = Convert.ToInt32(CommonTool.Siemens.Trans<int>(data, 40)), // 删除的任务
|
// DeletePlcId = Convert.ToInt32(CommonTool.Siemens.Trans<int>(data, 40)), // 删除的任务
|
||||||
// Spare1 = Convert.ToInt32(CommonTool.Siemens.Trans<int>(data, 44)), // 备用1
|
Spare1 = Convert.ToInt32(CommonTool.Siemens.Trans<int>(data, 44)), // 备用1
|
||||||
// Spare2 = Convert.ToInt16(CommonTool.Siemens.Trans<short>(data, 48)), // 备用2
|
// Spare2 = Convert.ToInt16(CommonTool.Siemens.Trans<short>(data, 48)), // 备用2
|
||||||
};
|
};
|
||||||
return (string.Empty, stackerInfo);
|
return (string.Empty, stackerInfo);
|
||||||
|
|
@ -182,31 +185,26 @@ public class StackerOperation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stackerId"></param>
|
/// <param name="stackerId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string WriteTaskConfirm(int stackerId)
|
public string WriteTaskConfirm(int? stackerId)
|
||||||
{
|
{
|
||||||
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default)
|
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return "PLC尚未连接。";
|
||||||
{
|
|
||||||
// 未连接PLC
|
|
||||||
return "PLC尚未连接。";
|
|
||||||
}
|
|
||||||
var (writeResult, _) = CommonTool.Siemens.WritePlcWhithName($"堆垛机写任务确认{stackerId}", (short)1);
|
var (writeResult, _) = CommonTool.Siemens.WritePlcWhithName($"堆垛机写任务确认{stackerId}", (short)1);
|
||||||
if (writeResult.Success)
|
return writeResult.Success ? string.Empty : writeResult.Message ?? "写入失败";
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
return writeResult.Message ?? "写入失败";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 写入堆垛机任务,返回错误信息
|
/// 写入堆垛机任务,返回错误信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="task"></param>
|
/// <param name="task">任务数据</param>
|
||||||
|
/// <param name="forkId">货叉编号</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string WriteTask(StackerPlcTask task)
|
public string WriteTask(StackerPlcTask task, int forkId = 0)
|
||||||
{
|
{
|
||||||
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return "PLC尚未连接。"; // 未连接PLC
|
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return "PLC尚未连接。"; // 未连接PLC
|
||||||
var (writeResult, _) = CommonTool.Siemens.WritePlcWhithName($"堆垛机写任务{task.StackerId}",
|
var dbAddressName = $"堆垛机写任务{task.StackerId}";
|
||||||
|
if(forkId != 0) { dbAddressName += $"-{forkId}"; }
|
||||||
|
var (writeResult, _) = CommonTool.Siemens.WritePlcWhithName(dbAddressName,
|
||||||
task.PlcId!,
|
task.PlcId!,
|
||||||
task.TaskType!,
|
task.TaskType!,
|
||||||
task.GetStand!,
|
task.GetStand!,
|
||||||
|
|
@ -225,7 +223,7 @@ public class StackerOperation
|
||||||
task.Weight!,
|
task.Weight!,
|
||||||
task.Code
|
task.Code
|
||||||
);
|
);
|
||||||
return writeResult.Success ? string.Empty : writeResult.Message ?? "写入失败";
|
return writeResult.Success ? string.Empty : writeResult.Message ?? "写入失败,未知原因";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ public class HostService(ServiceStart serverStart) : IHostedLifecycleService
|
||||||
{
|
{
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
_serverStart.LoadingData(); // 加载必要参数
|
||||||
string? loadingResult = LoadingRunningData.GetResult();
|
string? loadingResult = LoadingRunningData.GetResult();
|
||||||
if (!string.IsNullOrEmpty(loadingResult))
|
if (!string.IsNullOrEmpty(loadingResult))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,23 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs
|
||||||
private readonly ConnectPlcServe _connectPlcServe = connectPlcServe;
|
private readonly ConnectPlcServe _connectPlcServe = connectPlcServe;
|
||||||
|
|
||||||
private static string _errMsg = string.Empty;
|
private static string _errMsg = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载必要参数
|
||||||
|
/// </summary>
|
||||||
|
public void LoadingData()
|
||||||
|
{
|
||||||
|
LoadingConfig(); // 加载数据库中的配置项 (config 表)
|
||||||
|
LoadingStackerData(); // 加载数据库中的堆垛机信息
|
||||||
|
LoadingLocationData(); // 加载数据库中的库位信息
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(_errMsg))
|
||||||
|
{
|
||||||
|
ConsoleLog.Error($"【异常】启动加载运行文件出错,WCS功能受到限制,您可以检查网络连接后重新启动或者联系我们,参考信息:{_errMsg}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启动 ——-- 主方法
|
/// 启动 ——-- 主方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -35,15 +52,7 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs
|
||||||
{
|
{
|
||||||
/* 指定线程池规格 */
|
/* 指定线程池规格 */
|
||||||
ThreadPool.SetMinThreads(30, 10);
|
ThreadPool.SetMinThreads(30, 10);
|
||||||
LoadingConfig(); // 加载数据库中的配置项 (config 表)
|
|
||||||
LoadingStackerData(); // 加载数据库中的堆垛机信息
|
|
||||||
LoadingLocationData(); // 加载数据库中的库位信息
|
|
||||||
|
|
||||||
if(!string.IsNullOrEmpty(_errMsg))
|
|
||||||
{
|
|
||||||
ConsoleLog.Error($"【异常】启动加载运行文件出错,WCS功能受到限制,您可以检查网络连接后重新启动或者联系我们,参考信息:{_errMsg}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CreatePlcClient(); // 连接 PLC 客户端
|
CreatePlcClient(); // 连接 PLC 客户端
|
||||||
CreateSocketClient(); // Socket客户端
|
CreateSocketClient(); // Socket客户端
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,9 @@
|
||||||
<Folder Include="Business\Stacker\" />
|
<Folder Include="Business\Stacker\" />
|
||||||
<Folder Include="Business\StackerConvey\" />
|
<Folder Include="Business\StackerConvey\" />
|
||||||
<Folder Include="Business\Container\" />
|
<Folder Include="Business\Container\" />
|
||||||
<Folder Include="DataService\" />
|
<Folder Include="Language\Entity\" />
|
||||||
|
<Folder Include="Language\zh-CN\" />
|
||||||
|
<Folder Include="Language\en-US\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
6
WcsMain/WcsMain.csproj.user
Normal file
6
WcsMain/WcsMain.csproj.user
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<NameOfLastUsedPublishProfile>FolderProfile</NameOfLastUsedPublishProfile>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -8,13 +8,14 @@
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"Settings": {
|
"Settings": {
|
||||||
"DBMysql": "server=192.168.103.200;port=3306;user=developer;password=developer;database=wcs_main;",
|
"DBMysql": "server=192.168.103.200;port=3306;user=developer;password=developer;database=wcs_main;",
|
||||||
"DBMysqlLocal": "server=192.168.234.128;port=3306;user=developer;password=developer;database=wcs_main;",
|
"DBMysqlLocal": "server=192.168.234.128;port=3306;user=developer;password=developer;database=wcs_suzhoukt;",
|
||||||
|
|
||||||
"DBMssql": "Data Source=192.168.142.131;Initial Catalog=wcs;User Id=sa;Password=Sa123;",
|
"DBMssql": "Data Source=192.168.142.131;Initial Catalog=wcs;User Id=sa;Password=Sa123;",
|
||||||
"DBMssqlLocal": "Data Source=192.168.142.131;Initial Catalog=wcs_stacker;User Id=sa;Password=Sa123;",
|
"DBMssqlLocal": "Data Source=192.168.142.131;Initial Catalog=wcs_stacker;User Id=sa;Password=Sa123;",
|
||||||
|
|
||||||
"ApplicationConfig": {
|
"ApplicationConfig": {
|
||||||
"ApiOnly": true
|
"ApiOnly": true,
|
||||||
|
"Language": "zh-CN"
|
||||||
},
|
},
|
||||||
"UseUrls": [ "http://*:890" ]
|
"UseUrls": [ "http://*:890" ]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user