79 lines
3.1 KiB
C#
79 lines
3.1 KiB
C#
using System.Collections.Generic;
|
|
using WcsMain.ApiServe.Controllers.Dto;
|
|
using WcsMain.ApiServe.Controllers.Dto.WcsDto.Stacker;
|
|
using WcsMain.ApiServe.Factory;
|
|
using WcsMain.DataBase.Dao;
|
|
using WcsMain.DataBase.TableEntity;
|
|
using WcsMain.PlcOperation.Stacker;
|
|
using WcsMain.WcsAttribute.AutoFacAttribute;
|
|
|
|
namespace WcsMain.ApiServe.Service.WcsService;
|
|
|
|
[Service]
|
|
public class StackerService(AppStackerDao stackerDao, StackerOperation stackerOperation)
|
|
{
|
|
|
|
private readonly AppStackerDao _stackerDao = stackerDao;
|
|
private readonly StackerOperation _stackerOperation = stackerOperation;
|
|
|
|
/// <summary>
|
|
/// 查询所有的 堆垛机信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public WcsApiResponse<List<AppStacker>> GetStacker()
|
|
{
|
|
List<AppStacker>? stackers = _stackerDao.Select(new AppStacker());
|
|
if(stackers == default)
|
|
{
|
|
return WcsApiResponseFactory.DataBaseErr<List<AppStacker>>();
|
|
}
|
|
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, "查询成功");
|
|
}
|
|
|
|
}
|