54 lines
2.1 KiB
PHP
54 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace app\action;
|
|
|
|
use Exception;
|
|
use libs\db\Db;
|
|
|
|
class GetTrayProcessRoute
|
|
{
|
|
public function execute($post)
|
|
{
|
|
// 验证数据
|
|
$param = check_valid($post['action'], [
|
|
['device_code', 'string', '设备编码'],
|
|
['tray', 'string', '托盘号']
|
|
], $post['param']);
|
|
|
|
try {
|
|
$sql = sprintf(
|
|
"SELECT a.tray,a.lot,a.batch,a.process_code,a.next_process_code,
|
|
d.code as last_workingsubclass,e.code as next_workingsubclass,
|
|
f.code as last_workstation,g.code as next_workstation
|
|
FROM hf_mes_production_tray_map AS a
|
|
INNER JOIN hf_mes_technology_process b ON b.code = a.process_code
|
|
INNER JOIN hf_mes_technology_process c ON c.code = a.next_process_code
|
|
INNER JOIN hf_mes_process_workingsubclass d ON d.id = b.workingsubclass_id
|
|
INNER JOIN hf_mes_process_workingsubclass e ON e.id = c.workingsubclass_id
|
|
INNER JOIN hf_mes_device_category f ON f.id = d.device_category_id
|
|
INNER JOIN hf_mes_device_category g ON g.id = e.device_category_id
|
|
WHERE a.tray='%s' AND a.active=1 LIMIT 1;",
|
|
$param['tray']
|
|
);
|
|
$ret = Db::fetch($sql);
|
|
if (empty($ret)) {
|
|
throw new Exception("托盘[{$param['tray']}]不是激活状态");
|
|
}
|
|
} catch (Exception $e) {
|
|
throw new Exception($e->getMessage());
|
|
}
|
|
|
|
return array(
|
|
'tray' => $ret['tray'],
|
|
'lot' => $ret['lot'],
|
|
'batch' => $ret['batch'],
|
|
'last_process_code' => $ret['process_code'],
|
|
'next_process_code' => $ret['next_process_code'],
|
|
'last_workingsubclass' => $ret['last_workingsubclass'],
|
|
'next_workingsubclass' => $ret['next_workingsubclass'],
|
|
'last_workstation' => $ret['last_workstation'],
|
|
'next_workstation' => $ret['next_workstation']
|
|
);
|
|
}
|
|
}
|