xiuwenDataTest.php 1.5 KB

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