whereOr([$map1, $map2])->order('charge_pile_id desc')->count('charge_pile_id'); if ($hasfault) { $case1 = [ ['charge_pile.status', '=',255], ['is_pushed','=',1], ]; $case2 = [ ['charge_pile.status', '=',0], ['is_pushed','=',1], ]; $faultInfo = Db::table('charge_pile,charge_station') ->whereOr([$case1, $case2]) ->where('charge_pile.charge_station_id = charge_station.charge_station_id') ->order('charge_pile_id desc') ->field('charge_station.charge_station_id,charge_station_name,charge_pile.charge_pile_number,charge_station.area,charge_station.street,charge_pile.status,charge_pile.no') ->find(); $faultInfo['code'] = 1; foreach ($worker->connections as $connection) { if (empty($connection->lastMessageTime)) { $connection->lastMessageTime = $time_now; } if ($time_now - $connection->lastMessageTime > self::$heartbeat_time) { $connection->close(); } $connection->send(json_encode($faultInfo)); } Db::table('charge_pile')->where('charge_pile_number',$faultInfo['charge_pile_number'])->save(['is_pushed'=>2]); } else { foreach ($worker->connections as $connection) { if (empty($connection->lastMessageTime)) { $connection->lastMessageTime = $time_now; continue; } if ($time_now - $connection->lastMessageTime > self::$heartbeat_time) { //连接超时 $connection->close(); } $connection->send(json_encode(['code'=>0,'msg'=>'暂时没有信息'])); } } }); } }