123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- // 修文县项目验收,添加测试数据
- require_once './DB.php';
- date_default_timezone_set('Asia/Shanghai');
- $config = json_decode(file_get_contents('./db_config.php'),true);
- $begin = date('H:i',time()-60);
- while (1) {
- $end = date('H:i',time());
- if ($end == $begin) {
- sleep(1);
- $end = date('H:i',time());
- continue;
- }
- $begin = $end;
- $db = new Db($config);
- $sql = 'select * from lampinfo where projectid = 30319';
- $lampinfoList = $db->query($sql);
- $count = 1;
- foreach ($lampinfoList as $lampinfo) {
- if ($lampinfo['status'] == 1 && $lampinfo['lighteness'] > 0) $count ++;
- }
- $allCount = count($lampinfoList);
- $db->table('network')->where('projectid=30319')->update(array('status'=>1));
- $now = explode(':', $end);
- $now = intval($now[0]) * 60 + intval($now[1]);
- if (1) {
- if ($now >= 18 * 60 || $now < 8 * 60) {
- $lighteness = 100;
- $db->table('lampinfo')->where('projectid=30319')->update(array('status'=>1,'lighteness'=>$lighteness));
- }
- if ($end == '08:00') {
- $lighteness = 0;
- $db->table('lampinfo')->where('projectid=30319')->update(array('status'=>0,'lighteness'=>$lighteness));
- }
- $db->table('network')->where('projectid=30319')->update(array('status'=>1));
-
- }else{
- foreach ($lampinfoList as $lampinfo) {
- if (empty($lampinfo['logtime']) || time() - strtotime($lampinfo['logtime']) > 10*3600) {
- $db->table('network')->where('id='.$lampinfo['networkid'])->update(array('status'=>0));
- }
- }
- }
- $db->close();
- }
|