公司订单数较多,没办法用人工的方式审查每个订单的轨迹是否都偏移了,所以想出了这个查询方法。
// 查找每日一定会有问题的单
public function get_test() {
if (!empty($_GET['date'])) {
$today = strtotime($_GET['date']);
} else {
$today = strtotime(date('Y-m-d'));
}
$next_day = (strtotime("+1 day",$today)+3600*7);
$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();
$model = M('guiji');
$i = 1;
echo '<style>span{display: block;float: left;width: 190px;}</style><div style="width:18%;float:left">';
foreach ($list as $k => $v) {
$time = $v['arrive_time'] - $v['begion_time'];
$num = $time / 10 * 0.7; // 正常点( * 0.7);
if ($time > 600) {
$count = $model->where('order_id='.$v['id'])->count();
if ($count > 20 && $count < $num) {
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/>';
$i++;
}
}
}
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>';
echo '<script src="https://www.jq22.com/jquery/jquery-2.1.1.js"></script>';
echo '<script>$("#iframe").attr("width", $(window).width()*0.82);$("#iframe").attr("height", $(window).height());';
echo '$("a").click(function(){$("a").each(function(){$(this).css("color", "blue");});$("#iframe").attr("src", $(this).attr("href"));$(this).css("color", "red"); return false;})';
echo '</script>';
}
原理:
通过订单的总行车时长,计算出该订单正常会有几个轨迹点。
当行车时间超过10分钟的订单,才认为可能存在漂移,时间太短的单就不看了。
然后该单轨迹少于真实轨迹数的70%,就认为是可疑订单。
至于那个A标签,是用于打卡iframe的内联框,是用来读取轨迹行车记录的,这个自己写个百度的地图,调用订单轨迹分布上去查看就好。