| | |
| | | package com.stylefeng.guns.modular.system.controller.taxi; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStreamReader; |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | @Controller |
| | | @RequestMapping("/tOrderTaxi") |
| | | public class TOrderTaxiController extends BaseController { |
| | | |
| | | |
| | | private String PREFIX = "/system/tOrderTaxi/"; |
| | | |
| | | |
| | | @Autowired |
| | | private ITOrderTaxiService tOrderTaxiService; |
| | | |
| | | |
| | | @Autowired |
| | | private ITOrderPrivateCarService tOrderPrivateCarService; |
| | | |
| | | |
| | | @Autowired |
| | | private ITOrderPositionService tOrderPositionService; |
| | | |
| | | |
| | | @Autowired |
| | | private ITDriverService tDriverService; |
| | | |
| | | |
| | | @Autowired |
| | | private ITUserService userService; |
| | | |
| | | @Value("${filePath}") |
| | | private String filePath; |
| | | |
| | | |
| | | @Resource |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | |
| | | /** |
| | | * 跳转到出租车订单首页 |
| | | */ |
| | |
| | | public String index() { |
| | | return PREFIX + "tOrderTaxi.html"; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 跳转到添加出租车订单 |
| | | */ |
| | |
| | | public String tOrderTaxiAdd() { |
| | | return PREFIX + "tOrderTaxi_add.html"; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 跳转到修改出租车订单 |
| | | */ |
| | |
| | | public ResultUtil getOrderTrack(String orderDetailId) { |
| | | if (ToolUtil.isNotEmpty(orderDetailId)) { |
| | | try { |
| | | // List<TOrderPosition> list = tOrderPositionService.selectList(new EntityWrapper<TOrderPosition>().eq("orderType", 2).eq("orderId", orderDetailId).orderBy("insertTime")); |
| | | /*if(list.size() == 0){ |
| | | return ResultUtil.error("该订单没有运行轨迹"); |
| | | }*/ |
| | | //将数据存储到文件中 |
| | | File file = new File(filePath + orderDetailId + "_2.txt"); |
| | | if (!file.exists()) { |
| | | return ResultUtil.success(new ArrayList<>()); |
| | | } |
| | | //读取文件(字符流) |
| | | BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); |
| | | //循环取出数据 |
| | | String str = null; |
| | | StringBuffer sb = new StringBuffer(); |
| | | while ((str = in.readLine()) != null) { |
| | | sb.append(str); |
| | | } |
| | | List<TOrderPosition> list = JSONArray.parseArray(sb.toString(), TOrderPosition.class); |
| | | resultUtil = ResultUtil.success(list); |
| | | Query query = new Query() |
| | | .addCriteria(Criteria.where("orderId").is(orderDetailId).and("orderType").is(2)) |
| | | .with(new Sort(Sort.Direction.ASC, "insertTime")); |
| | | List<TOrderPosition> positions = mongoTemplate.find(query, TOrderPosition.class); |
| | | resultUtil = ResultUtil.success(positions); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | resultUtil = ResultUtil.runErr(); |