<add>[important]添加库前输送机状态查询(仅适用卡特)

This commit is contained in:
葛林强 2024-06-25 09:12:20 +08:00
parent 799043a848
commit b2f1573805
6 changed files with 160 additions and 13 deletions

View File

@ -0,0 +1,80 @@
using System.Text.Json.Serialization;
namespace WcsMain.ApiServe.Controllers.Dto.WcsDto.StackerConvey;
public class StackerConveyStatusResponse
{
/// <summary>
/// WCS 点位
/// </summary>
[JsonPropertyName("wcsLocation")]
public string? WcsLocation { get; set; }
/// <summary>
/// WMS 点位
/// </summary>
[JsonPropertyName("wmsLocation")]
public string? WmsLocation { get; set; }
/// <summary>
/// 点位名称
/// </summary>
[JsonPropertyName("locationName")]
public string? LocationName { get; set; }
/// <summary>
/// plc 的位置
/// </summary>
[JsonPropertyName("plcLocation")]
public string? PlcLocation { get; set; }
/// <summary>
/// 区域
/// </summary>
[JsonPropertyName("area")]
public string? Area { get; set; }
/// <summary>
/// 点位类型
/// </summary>
[JsonPropertyName("locationType")]
public int? LocationType { get; set; }
/// <summary>
/// 点位状态
/// </summary>
[JsonPropertyName("locationStatus")]
public int? LocationStatus { get; set; }
/// <summary>
/// 写入方式
/// </summary>
[JsonPropertyName("writeType")]
public int? WriteType { get; set; }
/// <summary>
/// 备注信息
/// </summary>
[JsonPropertyName("remark")]
public string? Remark { get; set; }
/// <summary>
/// 查询结果
/// </summary>
[JsonPropertyName("msg")]
public string? Message { get; set; } = "-";
/// <summary>
/// 条码
/// </summary>
[JsonPropertyName("code")]
public string? Code { get; set; }
/// <summary>
/// 动作允许
/// </summary>
[JsonPropertyName("allowAction")]
public bool? AllowAction { get; set; }
}

View File

@ -5,6 +5,7 @@ using WcsMain.ApiServe.ControllerFilter;
using WcsMain.ApiServe.Service.WcsService; using WcsMain.ApiServe.Service.WcsService;
using WcsMain.ApiServe.Controllers.Dto; using WcsMain.ApiServe.Controllers.Dto;
using WcsMain.DataBase.TableEntity; using WcsMain.DataBase.TableEntity;
using WcsMain.ApiServe.Controllers.Dto.WcsDto.StackerConvey;
namespace WcsMain.ApiServe.Controllers.WcsController; namespace WcsMain.ApiServe.Controllers.WcsController;
@ -24,7 +25,11 @@ public class StackerConveyController(StackerConveyService stackerConveyService)
[HttpGet("queryStackerConveyInfo")] [HttpGet("queryStackerConveyInfo")]
public WcsApiResponse<List<AppStackerConvey>>? QueryStackerConveyInfo() => stackerConveyService.QueryStackerConveyInfo(); public WcsApiResponse<List<AppStackerConvey>>? QueryStackerConveyInfo() => stackerConveyService.QueryStackerConveyInfo();
/// <summary>
/// 查询所有库前输送线状态信息
/// </summary>
/// <returns></returns>
[HttpGet("queryStackerConveyStatus")]
public WcsApiResponse<List<StackerConveyStatusResponse>>? QueryStackerConveyStatus() => stackerConveyService.QueryStackerConveyStatus();
} }

View File

@ -1,7 +1,12 @@
using WcsMain.ApiServe.Controllers.Dto; using Microsoft.CodeAnalysis.CSharp.Syntax;
using WcsMain.ApiServe.Controllers.Dto;
using WcsMain.ApiServe.Controllers.Dto.WcsDto.StackerConvey;
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.EquipOperation.Convey;
using WcsMain.EquipOperation.StackerConvey;
using WcsMain.Plugins;
using WcsMain.WcsAttribute.AutoFacAttribute; using WcsMain.WcsAttribute.AutoFacAttribute;
namespace WcsMain.ApiServe.Service.WcsService; namespace WcsMain.ApiServe.Service.WcsService;
@ -10,7 +15,7 @@ namespace WcsMain.ApiServe.Service.WcsService;
/// 库前输送线的 Service /// 库前输送线的 Service
/// </summary> /// </summary>
[Service] [Service]
public class StackerConveyService(AppStackerConveyDao stackerConveyDao) public class StackerConveyService(AppStackerConveyDao stackerConveyDao, ConveyOperation conveyOperation)
{ {
/// <summary> /// <summary>
@ -22,4 +27,44 @@ public class StackerConveyService(AppStackerConveyDao stackerConveyDao)
List<AppStackerConvey>? stackerConveys = stackerConveyDao.Query(); List<AppStackerConvey>? stackerConveys = stackerConveyDao.Query();
return stackerConveys == default ? WcsApiResponseFactory.DataBaseErr<List<AppStackerConvey>>() : WcsApiResponseFactory.Success(stackerConveys); return stackerConveys == default ? WcsApiResponseFactory.DataBaseErr<List<AppStackerConvey>>() : WcsApiResponseFactory.Success(stackerConveys);
} }
/// <summary>
/// 查询所有的库前输送线状态信息
/// </summary>
/// <returns></returns>
public WcsApiResponse<List<StackerConveyStatusResponse>>? QueryStackerConveyStatus()
{
List<AppStackerConvey>? stackerConveys = stackerConveyDao.Query();
if(stackerConveys == default) return WcsApiResponseFactory.DataBaseErr<List<StackerConveyStatusResponse>>();
if(stackerConveys.Count == 0) return WcsApiResponseFactory.Fail<List<StackerConveyStatusResponse>>(default, "未找到库前输送机数据,请检查基础资料");
List<StackerConveyStatusResponse> responseData = [];
foreach (var stackerConvey in stackerConveys)
{
StackerConveyStatusResponse stackerConveyStatusResponse = ObjectCopy.CopyProperties<AppStackerConvey, StackerConveyStatusResponse>(stackerConvey);
stackerConveyStatusResponse.Message = "查询成功";
// 读取条码
(string? errText, string? code) = conveyOperation.ReadConveyCode(stackerConvey.WcsLocation);
if(!string.IsNullOrEmpty(errText))
{
stackerConveyStatusResponse.Message = errText;
responseData.Add(stackerConveyStatusResponse);
continue;
}
stackerConveyStatusResponse.Code = code;
// 读取允许取放货状态
// ---- 取货站台
if(stackerConvey.LocationType == 1)
{
stackerConveyStatusResponse.AllowAction = conveyOperation.AllowGetVehicle(stackerConvey.WcsLocation![..1]);
}
if(stackerConvey.LocationType == 2)
{
stackerConveyStatusResponse.AllowAction = conveyOperation.AllowSetVehicle(stackerConvey.WcsLocation![..1]);
}
responseData.Add(stackerConveyStatusResponse);
}
return WcsApiResponseFactory.Success(responseData);
}
} }

View File

@ -74,10 +74,10 @@ public class ExeTaskDoubleFork(
{ {
if (stackerId == default) return false; if (stackerId == default) return false;
/* 检查入库站台是否允许取货 */ /* 检查入库站台是否允许取货 */
bool allowGetGoods = conveyOperation.AllGetVehicle(stackerId.ToString()); bool allowGetGoods = conveyOperation.AllowGetVehicle(stackerId.ToString());
if(!allowGetGoods) return false; // 入库站台不允许取货 if(!allowGetGoods) return false; // 入库站台不允许取货
/* 读取入库站台的条码 */ /* 读取入库站台的条码 */
var codes = conveyOperation.ReadConveyCode(stackerId.ToString()); var codes = conveyOperation.ReadAreaConveyCode(stackerId.ToString());
if(codes == default || codes.Count != 2) return false; if(codes == default || codes.Count != 2) return false;
/* 构造任务数据 */ /* 构造任务数据 */
bool isWriteTask = false; // 指示是否写入任务 bool isWriteTask = false; // 指示是否写入任务
@ -92,7 +92,7 @@ public class ExeTaskDoubleFork(
if (code == "NoRead") // 检查条码是否为 NoRead if (code == "NoRead") // 检查条码是否为 NoRead
{ {
/* 检查卸货站台是否允许卸货 */ /* 检查卸货站台是否允许卸货 */
bool allowSetGoods = conveyOperation.AllSetVehicle(stackerId.ToString()); bool allowSetGoods = conveyOperation.AllowSetVehicle(stackerId.ToString());
if (!allowSetGoods) continue; // 出库站台不允许取货 if (!allowSetGoods) continue; // 出库站台不允许取货
/* 生成一个直接卸货出去的任务 */ /* 生成一个直接卸货出去的任务 */
int? plcId = dataBaseData.GetNewPlcTaskId(); int? plcId = dataBaseData.GetNewPlcTaskId();
@ -119,7 +119,7 @@ public class ExeTaskDoubleFork(
if(wcsTasks.Count < 1) // 没有任务 if(wcsTasks.Count < 1) // 没有任务
{ {
/* 检查卸货站台是否允许卸货 */ /* 检查卸货站台是否允许卸货 */
bool allowSetGoods = conveyOperation.AllSetVehicle(stackerId.ToString()); bool allowSetGoods = conveyOperation.AllowSetVehicle(stackerId.ToString());
if (!allowSetGoods) continue; // 出库站台不允许取货 if (!allowSetGoods) continue; // 出库站台不允许取货
/* 生成一个直接卸货出去的任务 */ /* 生成一个直接卸货出去的任务 */
ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code} 没有找到对应任务"); ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code} 没有找到对应任务");
@ -144,7 +144,7 @@ public class ExeTaskDoubleFork(
if(destinationLocationInfo == default) // 任务终点错误,理论上此处不应该出现异常 if(destinationLocationInfo == default) // 任务终点错误,理论上此处不应该出现异常
{ {
/* 检查卸货站台是否允许卸货 */ /* 检查卸货站台是否允许卸货 */
bool allowSetGoods = conveyOperation.AllSetVehicle(stackerId.ToString()); bool allowSetGoods = conveyOperation.AllowSetVehicle(stackerId.ToString());
if (!allowSetGoods) continue; // 出库站台不允许取货 if (!allowSetGoods) continue; // 出库站台不允许取货
/* 生成一个直接卸货出去的任务 */ /* 生成一个直接卸货出去的任务 */
ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code} 无法识别的入库库位"); ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code} 无法识别的入库库位");
@ -200,7 +200,7 @@ public class ExeTaskDoubleFork(
{ {
if (stackerId == default) return false; if (stackerId == default) return false;
/* 检查出库站台是否可以卸货 */ /* 检查出库站台是否可以卸货 */
bool allowSetGoods = conveyOperation.AllSetVehicle(stackerId.ToString()); bool allowSetGoods = conveyOperation.AllowSetVehicle(stackerId.ToString());
if (!allowSetGoods) return false; // 出库站台不允许取货 if (!allowSetGoods) return false; // 出库站台不允许取货
var wcsTasks = wcsTaskDao.SelectOutTaskWithStacker((int)stackerId!); var wcsTasks = wcsTaskDao.SelectOutTaskWithStacker((int)stackerId!);
if (wcsTasks == default) if (wcsTasks == default)

View File

@ -28,7 +28,7 @@ public class ConveyOperation
/// </summary> /// </summary>
/// <param name="point">要取货的点位</param> /// <param name="point">要取货的点位</param>
/// <returns></returns> /// <returns></returns>
public bool AllGetVehicle(string? point) public bool AllowGetVehicle(string? point)
{ {
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return false; if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return false;
var readResult = CommonTool.Siemens.ReadInt16WithName($"箱式线允许取货{point}"); var readResult = CommonTool.Siemens.ReadInt16WithName($"箱式线允许取货{point}");
@ -40,7 +40,7 @@ public class ConveyOperation
/// </summary> /// </summary>
/// <param name="point">要取货的点位</param> /// <param name="point">要取货的点位</param>
/// <returns></returns> /// <returns></returns>
public bool AllSetVehicle(string? point) public bool AllowSetVehicle(string? point)
{ {
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return false; if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return false;
var readResult = CommonTool.Siemens.ReadInt16WithName($"箱式线允许卸货{point}"); var readResult = CommonTool.Siemens.ReadInt16WithName($"箱式线允许卸货{point}");
@ -52,7 +52,7 @@ public class ConveyOperation
/// </summary> /// </summary>
/// <param name="point"></param> /// <param name="point"></param>
/// <returns></returns> /// <returns></returns>
public List<string>? ReadConveyCode(string? point) public List<string>? ReadAreaConveyCode(string? point)
{ {
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return default; if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return default;
var readResult1 = CommonTool.Siemens.ReadStringWithName($"箱式线入库载具号{point}-1", 20, Encoding.ASCII); var readResult1 = CommonTool.Siemens.ReadStringWithName($"箱式线入库载具号{point}-1", 20, Encoding.ASCII);
@ -62,6 +62,20 @@ public class ConveyOperation
return [Regex.Replace(readResult1.Value ?? "", "\\W", ""), Regex.Replace(readResult2.Value ?? "", "\\W", "")]; return [Regex.Replace(readResult1.Value ?? "", "\\W", ""), Regex.Replace(readResult2.Value ?? "", "\\W", "")];
} }
/// <summary>
/// 读取箱号
/// </summary>
/// <param name="point"></param>
/// <returns></returns>
public (string? errText, string? code) ReadConveyCode(string? point)
{
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return ("设备离线", default);
var readResult1 = CommonTool.Siemens.ReadStringWithName($"箱式线入库载具号{point}", 20, Encoding.ASCII);
if (!readResult1.Success!) return (readResult1.Message, default);
// 返回读取到的任务号
return (default, Regex .Replace(readResult1.Value ?? "", "\\W", ""));
}
/// <summary> /// <summary>
/// 读取扫码点信息 /// 读取扫码点信息

View File

@ -4,6 +4,9 @@
/// <summary> /// <summary>
/// object 拷贝 /// object 拷贝
/// </summary> /// </summary>
/// <remarks>
/// 作者icewint(菻蔃)
/// </remarks>
public class ObjectCopy public class ObjectCopy
{ {