公司订单数较多,没办法用人工的方式审查每个订单的轨迹是否都偏移了,所以想出了这个查询方法。

  1. // 查找每日一定会有问题的单
  2. public function get_test() {
  3. if (!empty($_GET['date'])) {
  4. $today = strtotime($_GET['date']);
  5. } else {
  6. $today = strtotime(date('Y-m-d'));
  7. }
  8. $next_day = (strtotime("+1 day",$today)+3600*7);
  9. $list = M('order')->where('call_time>='.$today.' and call_time<'.$next_day.' and status=1 and kilometres > 8')->order('id DESC')->limit(0, 9000)->field('id,arrive_time,begion_time')->select();
  10. $model = M('guiji');
  11. $i = 1;
  12. echo '<style>span{display: block;float: left;width: 190px;}</style><div style="width:18%;float:left">';
  13. foreach ($list as $k => $v) {
  14. $time = $v['arrive_time'] - $v['begion_time'];
  15. $num = $time / 10 * 0.7; // 正常点( * 0.7);
  16. if ($time > 600) {
  17. $count = $model->where('order_id='.$v['id'])->count();
  18. if ($count > 20 && $count < $num) {
  19. echo '<a style="color:blue;text-decoration:none" href="/index.php/Order/guiji/order_id/'.$v['id'].'"><span>'.$i.',查看轨迹数('.$count.'),</span>ID:</a>'.$v['id'].'<br/>';
  20. $i++;
  21. }
  22. }
  23. }
  24. echo '</div><div style="width:82%;float:left"><iframe id="iframe" src="" frameborder="0" width="700" height="700" style="position: fixed;top: 0;"></iframe></div>';
  25. echo '<script src="https://www.jq22.com/jquery/jquery-2.1.1.js"></script>';
  26. echo '<script>$("#iframe").attr("width", $(window).width()*0.82);$("#iframe").attr("height", $(window).height());';
  27. echo '$("a").click(function(){$("a").each(function(){$(this).css("color", "blue");});$("#iframe").attr("src", $(this).attr("href"));$(this).css("color", "red"); return false;})';
  28. echo '</script>';
  29. }

原理:

通过订单的总行车时长,计算出该订单正常会有几个轨迹点。

当行车时间超过10分钟的订单,才认为可能存在漂移,时间太短的单就不看了。

然后该单轨迹少于真实轨迹数的70%,就认为是可疑订单。

至于那个A标签,是用于打卡iframe的内联框,是用来读取轨迹行车记录的,这个自己写个百度的地图,调用订单轨迹分布上去查看就好。