xiuwenDataTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. // 修文县项目验收,添加测试数据
  3. require_once './DB.php';
  4. date_default_timezone_set('Asia/Shanghai');
  5. $config = json_decode(file_get_contents('./db_config.php'),true);
  6. $begin = date('H:i',time()-60);
  7. while (1) {
  8. $end = date('H:i',time());
  9. if ($end == $begin) {
  10. sleep(1);
  11. $end = date('H:i',time());
  12. continue;
  13. }
  14. $begin = $end;
  15. $db = new Db($config);
  16. $sql = 'select * from lampinfo where projectid = 30319';
  17. $lampinfoList = $db->query($sql);
  18. $count = 1;
  19. foreach ($lampinfoList as $lampinfo) {
  20. if ($lampinfo['status'] == 1 && $lampinfo['lighteness'] > 0) $count ++;
  21. }
  22. $allCount = count($lampinfoList);
  23. $db->table('network')->where('projectid=30319')->update(array('status'=>1));
  24. $now = explode(':', $end);
  25. $now = intval($now[0]) * 60 + intval($now[1]);
  26. if (1) {
  27. if ($now >= 18 * 60 || $now < 8 * 60) {
  28. $lighteness = 100;
  29. $db->table('lampinfo')->where('projectid=30319')->update(array('status'=>1,'lighteness'=>$lighteness));
  30. }
  31. if ($end == '08:00') {
  32. $lighteness = 0;
  33. $db->table('lampinfo')->where('projectid=30319')->update(array('status'=>0,'lighteness'=>$lighteness));
  34. }
  35. $db->table('network')->where('projectid=30319')->update(array('status'=>1));
  36. }else{
  37. foreach ($lampinfoList as $lampinfo) {
  38. if (empty($lampinfo['logtime']) || time() - strtotime($lampinfo['logtime']) > 10*3600) {
  39. $db->table('network')->where('id='.$lampinfo['networkid'])->update(array('status'=>0));
  40. }
  41. }
  42. }
  43. $db->close();
  44. }