2024-05-14 16:30:56 +08:00
|
|
|
|
using WcsMain.DataService;
|
|
|
|
|
|
|
|
|
|
|
|
namespace WcsMain.Business.CirculationTask;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 读取 PLC 的扫码
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
//[Circulation]
|
2024-06-20 10:20:20 +08:00
|
|
|
|
public class ScanMethod()
|
2024-05-14 16:30:56 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//private static string[]? _scanId;
|
|
|
|
|
|
//private static ScanCodeAction? scanCodeAction;
|
|
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
|
/////
|
|
|
|
|
|
///// </summary>
|
|
|
|
|
|
///// <returns></returns>
|
|
|
|
|
|
////[Circulation("读取扫码信息", 100)]
|
|
|
|
|
|
//public bool ReadScanCode()
|
|
|
|
|
|
//{
|
|
|
|
|
|
// if (_scanId == default)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// GetScanNo();
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// foreach (string scanId in _scanId)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// Thread.Sleep(10);
|
|
|
|
|
|
// (string? errText, short scanOk, string code) = ConveyOperation.Instance().ReadScanInfo(scanId);
|
|
|
|
|
|
// if (!string.IsNullOrEmpty(errText))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// ConsoleLog.Error($"在扫码:{scanId} 处读取信息失败,信息:{errText}");
|
|
|
|
|
|
// Thread.Sleep(10000);
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (scanOk != 1) { continue; }
|
|
|
|
|
|
// ConveyOperation.Instance().ClearScanStatus(scanId);
|
|
|
|
|
|
// Task.Factory.StartNew(() =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// ConsoleLog.Info($"扫码器:{scanId} 收到数据:{code}");
|
|
|
|
|
|
// if (string.IsNullOrEmpty(code)) { return; }// 没有条码,不处理
|
|
|
|
|
|
// scanCodeAction ??= new ScanCodeAction();
|
|
|
|
|
|
// Type type = scanCodeAction.GetType();
|
|
|
|
|
|
// var methods = type.GetMethods();
|
|
|
|
|
|
// if (methods.Length < 1) { return; } // 类里面没有方法
|
|
|
|
|
|
// foreach (var method in methods)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// string? methodName = DataBaseData.Instance().GetConfig($"ScanMethod{scanId}");
|
|
|
|
|
|
// if (string.IsNullOrEmpty(methodName)) { return; }
|
|
|
|
|
|
// if (method.Name == methodName)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// method.Invoke(scanCodeAction, [new ScanCodeClass() { Code = code, StrScanID = scanId }]);
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// ConsoleLog.Error($"扫码器编号:{scanId} 未找到方法,请配置 config 参数。");
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//private void GetScanNo()
|
|
|
|
|
|
//{
|
|
|
|
|
|
// string? scans = DataBaseData.Instance().GetConfig("scanNo");
|
|
|
|
|
|
// if (string.IsNullOrEmpty(scans)) { return; }
|
|
|
|
|
|
// _scanId = scans.Split(',');
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|