34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
||
|
||
namespace app\action;
|
||
|
||
use Exception;
|
||
use libs\db\Db;
|
||
|
||
class SetDeviceThisTrayFinish
|
||
{
|
||
public function execute($post)
|
||
{
|
||
// 验证数据
|
||
$param = check_valid($post['action'], [
|
||
['device_code', 'string', '设备号'],
|
||
], $post['param']);
|
||
list($device_code, $date) = [$param['device_code'], date('Y-m-d H:i:s')];
|
||
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 = "UPDATE hf_mes_device_this_tray SET finish=1,finish_time='" . $date . "' WHERE code='{$param['device_code']}' AND finish=0;";
|
||
$ret = Db::query($sql);
|
||
if ($ret === NULL) {
|
||
throw new Exception("出库失败:更新库位状态表失败!");
|
||
}
|
||
} catch (Exception $e) {
|
||
throw new Exception($e->getMessage());
|
||
}
|
||
return '';
|
||
}
|
||
}
|