$item) { $class = $item['class']; $classname = $item['classname']; $battery_id = $item['battery_id']; // 判断电池是否为空 if (empty($battery_id)) { throw new Exception("电池条码数组第[{$k}]位置的电池条码不能是:[0, '0', '', null, NAN]等,请上传电池条码"); } $sql = sprintf( "SELECT tray,lot,batch,subbatch FROM hf_mes_production_battery_map WHERE battery_id='%s' ORDER BY id DESC LIMIT 1;", $battery_id ); $ret = Db::fetch($sql); if (empty($ret)) { throw new Exception("电池[{$battery_id}]的数据不存在[battery_map]"); } list($tray, $lot, $batch, $subbatch) = [ $ret['tray'], $ret['lot'], $ret['batch'], $ret['subbatch'] ]; $sql = sprintf( "UPDATE \"%s\" SET class = '%s',classname = '%s',active = 0 WHERE battery_id='%s' AND lot='%s';", config('app.bkv_prefix') . $subbatch, $class, $classname, $battery_id, $lot ); $ret = Db::query($sql); if ($ret === NULL) { throw new Exception("更新bkv表数据失败"); } } } catch (Exception $e) { throw new Exception($e->getMessage()); } return ''; } }