You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
3.0 KiB
PHTML
108 lines
3.0 KiB
PHTML
2 years ago
|
<?php
|
||
|
|
||
|
include('config.henan.inc.php');
|
||
|
|
||
|
function CvtWind($wind)
|
||
|
{
|
||
|
//
|
||
|
|
||
|
}
|
||
|
|
||
|
$elinewatch = array('database' => 'elinewatch_132', 'dbuser' => 'exp', 'password' => 'exp@123', 'host' => '192.168.111.12');
|
||
|
// $elinewatch = $config;
|
||
|
// $elinewatch['database'] = 'elinewatch';
|
||
|
|
||
|
$terms = array();
|
||
|
$db = new PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['database'], $config['dbuser'], $config['password'], [
|
||
|
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
|
||
|
\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8mb4'"
|
||
|
]);
|
||
|
|
||
|
$db2 = new PDO('mysql:host=' . $elinewatch['host'] . ';dbname=' . $elinewatch['database'], $elinewatch['dbuser'], $elinewatch['password'], [
|
||
|
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
|
||
|
\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8mb4'"
|
||
|
]);
|
||
|
|
||
|
$sql = "select `id`, cmdid from terminals";
|
||
|
foreach ($db->query($sql) as $row)
|
||
|
{
|
||
|
$terms[$row['cmdid']] = $row['id'];
|
||
|
}
|
||
|
$cnt = 0;
|
||
|
$sql = 'SELECT COUNT(*) as cnt FROM t_news_conduct_line_pull';
|
||
|
foreach ($db2->query($sql) as $row)
|
||
|
{
|
||
|
$cnt = $row['cnt'];
|
||
|
}
|
||
|
|
||
|
$minid = 0;
|
||
|
$content = @file_get_contents('./data/leadpull.txt');
|
||
|
if (!empty($content))
|
||
|
{
|
||
|
$minid = intval($content);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
$sql = "SELECT `id`,UNIX_TIMESTAMP(ext13) as update_time,ext12 as cmdid,tag2 as maxpull_pull,tag3 as maxpull_wind,tag1 as maxpull_tilt,tag4 as minpull_pull,tag5 as minpull_wind,tag6 as minpull_tilt," .
|
||
|
"ext15 as maxwind_wind,ext16 as maxwind_pull,ext17 as maxwind_tilt,ext18 as minwind_wind,ext19 as minwind_pull,ext20 as minwind_tilt FROM `t_news_conduct_line_pull` WHERE `id`>:minid ORDER BY `id` LIMIT 10000";
|
||
|
|
||
|
$sql2 = "INSERT INTO lead_pulls(term_id,update_time,maxpull_pull,maxpull_wind,maxpull_tilt,minpull_pull,minpull_wind,minpull_tilt,maxwind_wind,maxwind_pull,maxwind_tilt,minwind_wind,minwind_pull,minwind_tilt) " .
|
||
|
" VALUES(:term_id,:update_time,:maxpull_pull,:maxpull_wind,:maxpull_tilt,:minpull_pull,:minpull_wind,:minpull_tilt,:maxwind_wind,:maxwind_pull,:maxwind_tilt,:minwind_wind,:minwind_pull,:minwind_tilt)";
|
||
|
|
||
|
$stmt = $db2->prepare($sql);
|
||
|
$stmt2 = $db->prepare($sql2);
|
||
|
|
||
|
$idx = 0;
|
||
|
while (1)
|
||
|
{
|
||
|
$res = $stmt->execute(array(':minid' => $minid));
|
||
|
if (!$res)
|
||
|
{
|
||
|
echo $sql;
|
||
|
exit();
|
||
|
}
|
||
|
|
||
|
$rows = $stmt->fetchAll();
|
||
|
if (count($rows) == 0)
|
||
|
{
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
$db->beginTransaction();
|
||
|
foreach ($rows as $row)
|
||
|
{
|
||
|
$values = array();
|
||
|
|
||
|
$minid = $row['id'];
|
||
|
$values[':term_id'] = $terms[$row['cmdid']];
|
||
|
|
||
|
unset($row['cmdid']);
|
||
|
unset($row['id']);
|
||
|
|
||
|
foreach ($row as $key => $val)
|
||
|
{
|
||
|
$values[':' . $key] = $val;
|
||
|
}
|
||
|
|
||
|
if ($stmt2->execute($values))
|
||
|
{
|
||
|
echo $idx . '/' . $cnt . " id:" . $minid . "\r\n";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
print_r($stmt2->errorInfo());
|
||
|
print_r($values);
|
||
|
exit;
|
||
|
}
|
||
|
|
||
|
$idx++;
|
||
|
}
|
||
|
$db->commit();
|
||
|
|
||
|
$stmt->closeCursor();
|
||
|
|
||
|
}
|
||
|
|
||
|
file_put_contents('./data/leadpull.txt', $minid);
|