| | |
| | | @Override |
| | | public void saveData(OrderPosition orderPosition) throws Exception { |
| | | //计算实时里程 |
| | | // boolean b = orderService.calculateMileage(orderPosition); |
| | | // if(b){//如果计算了里程则将新的数据存储到数据库作为下个起点 |
| | | // //先计算里程,在存储最新位置 |
| | | // orderPosition.setInsertTime(new Date()); |
| | | // //将数据存储到文件中 |
| | | // List<OrderPosition> orderPositions = this.queryPosition(orderPosition.getOrderId(), orderPosition.getOrderType()); |
| | | // File file = new File(filePath + orderPosition.getOrderId() + "_" + orderPosition.getOrderType() + ".txt"); |
| | | // if(!file.exists()){ |
| | | // file.getParentFile().mkdirs(); |
| | | // file.createNewFile(); |
| | | // } |
| | | // //写入相应的文件 |
| | | // PrintWriter out = new PrintWriter(new FileWriter(file)); |
| | | // orderPositions.add(orderPosition); |
| | | // System.err.println("存储新数据:" + JSON.toJSONString(orderPositions)); |
| | | // out.write(JSON.toJSONString(orderPositions)); |
| | | // out.flush(); |
| | | // out.close(); |
| | | // } |
| | | boolean b = orderService.calculateMileage(orderPosition); |
| | | if(b){//如果计算了里程则将新的数据存储到数据库作为下个起点 |
| | | //先计算里程,在存储最新位置 |
| | | orderPosition.setInsertTime(new Date()); |
| | | //将数据存储到文件中 |
| | | List<OrderPosition> orderPositions = this.queryPosition(orderPosition.getOrderId(), orderPosition.getOrderType()); |
| | | File file = new File(filePath + orderPosition.getOrderId() + "_" + orderPosition.getOrderType() + ".txt"); |
| | | if(!file.exists()){ |
| | | file.getParentFile().mkdirs(); |
| | | file.createNewFile(); |
| | | } |
| | | //写入相应的文件 |
| | | PrintWriter out = new PrintWriter(new FileWriter(file)); |
| | | orderPositions.add(orderPosition); |
| | | System.err.println("存储新数据:" + JSON.toJSONString(orderPositions)); |
| | | out.write(JSON.toJSONString(orderPositions)); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |