SCTMES_V5/mes_in_sct/app/action/GetDeviceThisTray.php
2025-06-14 18:55:09 +08:00

37 lines
1.2 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\action;
use Exception;
use libs\db\Db;
class GetDeviceThisTray
{
public function execute($post)
{
// 验证数据
$param = check_valid($post['action'], [
['device_code', 'string', '设备号'],
], $post['param']);
$device_code = $param['device_code'];
try {
$sql = "SELECT id,status from hf_mes_device WHERE code = '$device_code' LIMIT 1;";
$ret = Db::fetch($sql);
if (empty($ret)) {
throw new Exception("不存在设备号【{$device_code}请查看设备设置的设备编码是否与MES一致");
}
$sql = "SELECT code, tray
FROM hf_mes_device_this_tray
WHERE code='{$device_code}' AND finish=0 ORDER BY id DESC LIMIT 1;";
$ret = Db::fetch($sql);
if (empty($ret)) {
throw new Exception("设备号【{$device_code}】不存在入库信息请现在MES上绑定托盘号在放入托盘");
}
return $ret;
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
}
}