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

34 lines
1.1 KiB
PHP
Raw 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 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 '';
}
}