56 lines
1.5 KiB
PHP
56 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace app\action;
|
|
|
|
use Exception;
|
|
use libs\db\Db;
|
|
|
|
/**
|
|
* 托盘解绑接口
|
|
* Class SetTrayBinding
|
|
* @package app\action
|
|
*/
|
|
class SetTrayUnbinding
|
|
{
|
|
public function execute($post)
|
|
{
|
|
// 验证数据
|
|
$param = check_valid($post['action'], [
|
|
['tray', 'string', '托盘号']
|
|
], $post['param']);
|
|
|
|
try {
|
|
$tray = $param['tray'];
|
|
|
|
$sql = sprintf(
|
|
"SELECT batch,subbatch,lot,next_process_code
|
|
FROM hf_mes_production_tray_map
|
|
WHERE tray='%s' AND active=1 LIMIT 1;",
|
|
$tray
|
|
);
|
|
$ret = Db::fetch($sql);
|
|
if (empty($ret)) {
|
|
throw new Exception("该托盘[$tray]没有激活,无法进行托盘解绑!", 4001);
|
|
}
|
|
|
|
list($batch, $subbatch, $lot, $next_process_code) = [
|
|
$ret['batch'],
|
|
$ret['subbatch'],
|
|
$ret['lot'],
|
|
$ret['next_process_code']
|
|
];
|
|
|
|
$sql = "UPDATE hf_mes_production_tray_map SET active=0 WHERE batch='$batch' AND subbatch='$subbatch' AND tray='$tray' AND lot='$lot' AND active=1";
|
|
$ret = Db::query($sql);
|
|
if($ret===NULL){
|
|
throw new Exception("Record Update failed:[hf_mes_production_tray_map]");
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
throw new Exception($e->getMessage(), $e->getCode() ? $e->getCode() : 4001);
|
|
}
|
|
|
|
return '';
|
|
}
|
|
}
|