37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?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());
|
||
}
|
||
}
|
||
}
|