| | |
| | | package com.stylefeng.guns.modular.system.controller.specialTrain; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.beetl.ShiroExtUtil; |
| | | import com.stylefeng.guns.core.common.constant.factory.PageFactory; |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.util.DateUtil; |
| | | import com.stylefeng.guns.core.util.SinataUtil; |
| | | |
| | | |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.dao.OrderCancelMapper; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.HttpRequestUtil; |
| | | import com.stylefeng.guns.modular.system.util.PushMinistryOfTransportUtil; |
| | | import com.stylefeng.guns.modular.system.util.PushURL; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | 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 javax.annotation.Resource; |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStreamReader; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private ITDriverService tDriverService; |
| | | |
| | | |
| | | @Autowired |
| | | private PushMinistryOfTransportUtil pushMinistryOfTransportUtil; |
| | | @Autowired |
| | | private ITUserService userService; |
| | | @Resource |
| | | private OrderCancelMapper orderCancelMapper; |
| | | |
| | | |
| | | @Value("${pushMinistryOfTransport}") |
| | | private boolean pushMinistryOfTransport; |
| | | |
| | | @Value("${filePath}") |
| | | private String filePath; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | @Autowired |
| | | private ShiroExtUtil shiroExtUtil; |
| | | |
| | | |
| | | /** |
| | | * 跳转到快车订单首页 |
| | | */ |
| | |
| | | public String index(Model model) { |
| | | //服务快车车型 |
| | | List<TServerCarmodel> carmodelList = tServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 1).eq("state", 1)); |
| | | model.addAttribute("carmodelList",carmodelList); |
| | | model.addAttribute("carmodelList", carmodelList); |
| | | return PREFIX + "tOrderPrivateCar.html"; |
| | | } |
| | | |
| | |
| | | Integer serverCarModelId, |
| | | String driver, |
| | | Integer state, |
| | | Integer rideType) { |
| | | Integer rideType, |
| | | Integer abnormal, |
| | | Integer promotion, |
| | | String promotionUser |
| | | ) { |
| | | String beginTime = null; |
| | | String endTime = null; |
| | | if (SinataUtil.isNotEmpty(insertTime)){ |
| | | if (SinataUtil.isNotEmpty(insertTime)) { |
| | | String[] timeArray = insertTime.split(" - "); |
| | | beginTime = timeArray[0]; |
| | | endTime = timeArray[1]; |
| | | } |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); |
| | | page.setRecords(tOrderPrivateCarService.getPrivateCarOrderList(page,beginTime,endTime,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(), |
| | | orderNum,orderSource,userName,userPhone,passengers,passengersPhone,serverCarModelId,driver,state,rideType)); |
| | | page.setRecords(tOrderPrivateCarService.getPrivateCarOrderList(page, beginTime, endTime, shiroExtUtil.getUser().getRoleType(), shiroExtUtil.getUser().getObjectId(), |
| | | orderNum, orderSource, userName, userPhone, passengers, passengersPhone, serverCarModelId, driver, state, rideType, abnormal, promotion, promotionUser,null)); |
| | | return super.packForBT(page); |
| | | } |
| | | |
| | | private ResultUtil resultUtil; |
| | | |
| | | @GetMapping("/export") |
| | | @ResponseBody |
| | | public void export(String insertTime, |
| | | String orderNum, |
| | | Integer orderSource, |
| | | String userName, |
| | | String userPhone, |
| | | String passengers, |
| | | String passengersPhone, |
| | | Integer serverCarModelId, |
| | | String driver, |
| | | Integer state, |
| | | Integer rideType, |
| | | Integer abnormal, |
| | | Integer promotion, |
| | | String promotionUser, HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | String beginTime = null; |
| | | String endTime = null; |
| | | if (SinataUtil.isNotEmpty(insertTime)) { |
| | | String[] timeArray = insertTime.split(" - "); |
| | | beginTime = timeArray[0]; |
| | | endTime = timeArray[1]; |
| | | } |
| | | List<Map<String, Object>> list = tOrderPrivateCarService.getPrivateCarOrderListExport(null, beginTime, endTime, shiroExtUtil.getUser().getRoleType(), shiroExtUtil.getUser().getObjectId(), |
| | | orderNum, orderSource, userName, userPhone, passengers, passengersPhone, serverCarModelId, driver, state, rideType, abnormal, promotion, promotionUser,null); |
| | | |
| | | // 表格数据【封装】 |
| | | List<List<String>> dataList = new ArrayList<>(); |
| | | |
| | | //第一行显示【封装】 |
| | | List<String> twoList = new ArrayList<String>(); |
| | | twoList.add("总计:"); |
| | | twoList.add(String.valueOf(list.size())+"条"); |
| | | dataList.add(twoList); |
| | | |
| | | // 列【封装】 |
| | | List<String> shellList = new ArrayList<String>(); |
| | | shellList.add("下单时间"); |
| | | shellList.add("订单编号"); |
| | | shellList.add("订单来源"); |
| | | shellList.add("订单类型"); |
| | | shellList.add("乘车时间"); |
| | | shellList.add("下单用户昵称"); |
| | | shellList.add("下单用户手机"); |
| | | shellList.add("乘车用户姓名"); |
| | | shellList.add("乘车用户手机"); |
| | | shellList.add("起点"); |
| | | shellList.add("终点"); |
| | | shellList.add("选择车型"); |
| | | shellList.add("接单司机"); |
| | | shellList.add("接单车辆"); |
| | | shellList.add("订单金额"); |
| | | shellList.add("状态"); |
| | | shellList.add("是否异常订单"); |
| | | shellList.add("是否推广订单"); |
| | | shellList.add("推广员姓名"); |
| | | shellList.add("推广员电话"); |
| | | dataList.add(shellList); |
| | | |
| | | for (Map<String,Object> object : list){ |
| | | // 详细数据列【封装】 |
| | | shellList = new ArrayList<String>(); |
| | | if(SinataUtil.isNotEmpty(object.get("insertTime"))){ |
| | | shellList.add(DateUtil.formatDate(DateUtil.parse(object.get("insertTime").toString(),"YYYY-MM-dd HH:mm:ss.S"), "YYYY-MM-dd HH:mm:ss")); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | if(SinataUtil.isNotEmpty(object.get("orderNum"))){ |
| | | shellList.add(object.get("orderNum").toString()); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | // 1:APP下单,2:扫码下单,3:小程序下单,4:司机下单,5:调度下单 |
| | | if(SinataUtil.isNotEmpty(object.get("orderSource"))){ |
| | | switch (object.get("orderSource").toString()){ |
| | | case "1": |
| | | shellList.add("APP下单"); |
| | | break; |
| | | case "2": |
| | | shellList.add("扫码下单"); |
| | | break; |
| | | case "3": |
| | | shellList.add("小程序下单"); |
| | | break; |
| | | case "4": |
| | | shellList.add("司机下单"); |
| | | break; |
| | | case "5": |
| | | shellList.add("调度下单"); |
| | | break; |
| | | case "6": |
| | | shellList.add("道行龙城下单"); |
| | | break; |
| | | default: |
| | | shellList.add("-"); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | if(SinataUtil.isNotEmpty(object.get("rideType"))){ |
| | | switch (object.get("rideType").toString()){ |
| | | case "1": |
| | | shellList.add("独享订单"); |
| | | break; |
| | | case "2": |
| | | shellList.add("一口价订单"); |
| | | break; |
| | | case "3": |
| | | shellList.add("拼车订单"); |
| | | break; |
| | | default: |
| | | shellList.add("-"); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("travelTime"))){ |
| | | shellList.add(DateUtil.formatDate(DateUtil.parse(object.get("travelTime").toString(),"YYYY-MM-dd HH:mm:ss.S"), "YYYY-MM-dd HH:mm:ss")); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("userName"))){ |
| | | shellList.add(object.get("userName").toString()); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("userPhone"))){ |
| | | shellList.add(object.get("userPhone").toString()); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("passengers"))){ |
| | | shellList.add(object.get("passengers").toString()); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("passengersPhone"))){ |
| | | shellList.add(object.get("passengersPhone").toString()); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("contactPersonPhone"))){ |
| | | shellList.add(object.get("contactPersonPhone").toString()); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("startAddress"))){ |
| | | shellList.add(object.get("startAddress").toString()); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("endAddress"))){ |
| | | shellList.add(object.get("endAddress").toString()); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("serverCarModelName"))){ |
| | | shellList.add(object.get("serverCarModelName").toString()); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("driver"))){ |
| | | shellList.add(object.get("driver").toString()); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("car"))){ |
| | | shellList.add(object.get("car").toString()); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("orderMoney"))){ |
| | | shellList.add(object.get("orderMoney").toString()); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | // 1=待接单,2=待出发,3=待到达预约地点,4=待乘客上车,5=服务中,6=完成服务,7=待支付,8=待评价,9=已完成,10=已取消,11=改派中,12=取消待支付 |
| | | if(SinataUtil.isNotEmpty(object.get("state"))){ |
| | | switch (object.get("state").toString()){ |
| | | case "1": |
| | | shellList.add("待接单"); |
| | | break; |
| | | case "2": |
| | | shellList.add("待出发"); |
| | | break; |
| | | case "3": |
| | | shellList.add("待到达预约地点"); |
| | | break; |
| | | case "4": |
| | | shellList.add("待乘客上车"); |
| | | break; |
| | | case "5": |
| | | shellList.add("服务中"); |
| | | break; |
| | | case "6": |
| | | shellList.add("完成服务"); |
| | | break; |
| | | case "7": |
| | | shellList.add("待支付"); |
| | | break; |
| | | case "8": |
| | | shellList.add("待评价"); |
| | | break; |
| | | case "9": |
| | | shellList.add("已完成"); |
| | | break; |
| | | case "10": |
| | | shellList.add("已取消"); |
| | | break; |
| | | case "11": |
| | | shellList.add("改派中"); |
| | | break; |
| | | case "12": |
| | | shellList.add("取消待支付"); |
| | | break; |
| | | default: |
| | | shellList.add("-"); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("abnormal"))){ |
| | | shellList.add(object.get("abnormal").toString().equals("1")?"否":"是"); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("promotion"))){ |
| | | shellList.add(object.get("promotion").toString().equals("1")?"否":"是"); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | |
| | | if(SinataUtil.isNotEmpty(object.get("promotionUser"))){ |
| | | shellList.add(object.get("promotionUser").toString()); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | if(SinataUtil.isNotEmpty(object.get("promotionPhone"))){ |
| | | shellList.add(object.get("promotionPhone").toString()); |
| | | }else{ |
| | | shellList.add("-"); |
| | | } |
| | | |
| | | |
| | | dataList.add(shellList); |
| | | } |
| | | try { |
| | | // 调用工具类进行导出 |
| | | ExcelExportUtil.easySheet("订单导出记录"+DateUtil.formatDate(new Date(), "YYYYMMddHHmmss"), "订单导出记录", dataList,request, response); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | private ResultUtil resultUtil; |
| | | |
| | | /** |
| | | * 获取订单轨迹 |
| | | * |
| | | * @param orderDetailId |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping(value = "/getOrderTrack", method = RequestMethod.POST) |
| | | public ResultUtil getOrderTrack(String orderDetailId){ |
| | | if(ToolUtil.isNotEmpty(orderDetailId)){ |
| | | public ResultUtil getOrderTrack(Integer orderDetailId) { |
| | | if (ToolUtil.isNotEmpty(orderDetailId)) { |
| | | try { |
| | | // List<TOrderPosition> list = tOrderPositionService.selectList(new EntityWrapper<TOrderPosition>().eq("orderType", 1).eq("orderId", orderDetailId).orderBy("insertTime")); |
| | | /*if(list.size() == 0){ |
| | | return ResultUtil.error("该订单没有运行轨迹"); |
| | | }*/ |
| | | //将数据存储到文件中 |
| | | File file = new File(filePath + orderDetailId + "_1.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); |
| | | }catch (Exception e){ |
| | | Query query = new Query() |
| | | .addCriteria(Criteria.where("orderId").is(orderDetailId).and("orderType").is(1)) |
| | | .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(); |
| | | } |
| | | }else { |
| | | } else { |
| | | resultUtil = ResultUtil.paranErr(); |
| | | } |
| | | return resultUtil; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 取消快车订单 |
| | | */ |