From b0923c5e054f33283e0cea737e871e55caa6f7ef Mon Sep 17 00:00:00 2001 From: zhibing.pu <393733352@qq.com> Date: 星期六, 10 八月 2024 13:59:42 +0800 Subject: [PATCH] 修改2.0 bug --- DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java | 124 ++++++++++++++++++++++++++++++++++++++--- 1 files changed, 115 insertions(+), 9 deletions(-) diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java index 2582519..e2a1ec1 100644 --- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java +++ b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java @@ -2,6 +2,7 @@ import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.mchange.util.FailSuppressedMessageLogger; import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; @@ -12,11 +13,8 @@ import com.stylefeng.guns.modular.system.dao.DriverActivityHistoryMapper; import com.stylefeng.guns.modular.system.model.*; import com.stylefeng.guns.modular.system.service.*; -import com.stylefeng.guns.modular.system.util.ALiSendSms; -import com.stylefeng.guns.modular.system.util.DateUtil; -import com.stylefeng.guns.modular.system.util.EmailUtil; +import com.stylefeng.guns.modular.system.util.*; import com.stylefeng.guns.modular.system.util.GoogleMap.FleetEngineUtil; -import com.stylefeng.guns.modular.system.util.ResultUtil; import com.stylefeng.guns.modular.system.warpper.*; import com.stylefeng.guns.modular.system.warpper.BalanceUsageRecord; import com.stylefeng.guns.modular.taxi.model.OrderTaxi; @@ -25,13 +23,20 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.text.SimpleDateFormat; import java.util.*; @@ -43,6 +48,8 @@ @RestController @RequestMapping("") public class DriverController { + + private Logger log = LoggerFactory.getLogger(DriverController.class); @Autowired private IDriverService driverService; @@ -810,7 +817,7 @@ return ResultUtil.tokenErr(); } Map<String, Object> map = driverService.queryInfo(language, uid); - map.put("qrCodeIsOpen",driverService.getAppOpenInfo(1)==1); + map.put("qrCodeIsOpen", driverService.getAppOpenInfo(1)==1); DriverInfoWarpper driverInfoWarpper = DriverInfoWarpper.getDriverInfoWarpper(map); // Double money = driverService.getThisWeekMoney(uid); // driverInfoWarpper.setLaveBusinessMoney(driverInfoWarpper.getLaveBusinessMoney()-(money==null?0d:money)); @@ -1210,6 +1217,9 @@ switch (Integer.valueOf(String.valueOf(null != map.get("orderType") ? map.get("orderType") : 0))){ case 1: OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(map.get("incomeId").toString()); + if(null == orderPrivateCar){ + continue; + } baseWarpper.setName(language == 1 ? (orderPrivateCar.getCancelMidway() == 0 ? "" : "【途中取消】") + "打车" : language == 2 ? (orderPrivateCar.getCancelMidway() == 0 ? "" : "【Cancelled during the trip】") + "Ride" : (orderPrivateCar.getCancelMidway() == 0 ? "" : "【Annulé en cours de voyage】") + "Course"); break; case 2: @@ -1220,6 +1230,9 @@ break; case 4: OrderLogistics orderLogistics = orderLogisticsService.selectById(map.get("incomeId").toString()); + if(null == orderLogistics){ + continue; + } baseWarpper.setName(language == 1 ? (orderLogistics.getCancelMidway() == 0 ? "" : "【途中取消】") + "包裹" : language == 2 ? (orderLogistics.getCancelMidway() == 0 ? "" : "【Cancelled during the trip】") + "Delivery" : (orderLogistics.getCancelMidway() == 0 ? "" : "【Annulé en cours de voyage】") + "Livraison"); break; case 5: @@ -1242,6 +1255,9 @@ break; case 2: OrderTaxi orderTaxi = orderTaxiService.selectById(map.get("incomeId").toString()); + if(null == orderTaxi){ + continue; + } List<Income> incomes1 = incomeService.queryData(1, null, 2, orderTaxi.getId(), 2); map1.put("travelMoney", orderTaxi != null ? orderTaxi.getTravelMoney() : 0);//行程费 map1.put("parkMoney", orderTaxi != null ? orderTaxi.getParkMoney() : 0);//停车费 @@ -1251,6 +1267,9 @@ break; case 3: OrderCrossCity orderCrossCity = orderCrossCityService.selectById(map.get("incomeId").toString()); + if(null == orderCrossCity){ + continue; + } List<Income> incomes2 = incomeService.queryData(1, null, 2, orderCrossCity.getId(), 3); map1.put("travelMoney", orderCrossCity != null ? orderCrossCity.getOrderMoney() : 0);//行程费 map1.put("parkMoney", 0);//停车费 @@ -1260,6 +1279,9 @@ break; case 4: OrderLogistics orderLogistics = orderLogisticsService.selectById(map.get("incomeId").toString()); + if(null == orderLogistics){ + continue; + } List<Income> incomes3 = incomeService.queryData(1, null, 2, orderLogistics.getId(), 4); map1.put("parkMoney", orderLogistics != null ? orderLogistics.getParkMoney() : 0);//停车费 map1.put("tipMoney", 0);//小费 @@ -1268,6 +1290,9 @@ break; case 5: OrderLogistics orderLogistics1 = orderLogisticsService.selectById(map.get("incomeId").toString()); + if(null == orderLogistics1){ + continue; + } List<Income> incomes4 = incomeService.queryData(1, null, 2, orderLogistics1.getId(), 5); map1.put("travelMoney", orderLogistics1 != null ? orderLogistics1.getOrderMoney() : 0);//行程费 map1.put("parkMoney", 0);//停车费 @@ -1298,7 +1323,10 @@ break; } baseWarpper.setName(language == 1 ? "取消订单费用" : language == 2 ? "Cancellation fee" : "Frais d'annulation"); - baseWarpper.setData(new Object()); + List<Income> incomes = incomeService.queryData(1, 1, 3, Integer.valueOf(map.get("incomeId").toString()), Integer.valueOf(map.get("orderType").toString())); + Map<String, Object> map1 = new HashMap<>(); + map1.put("rakeMoney", incomes.size() > 0 ? incomes.get(0).getMoney() : 0);//抽成 + baseWarpper.setData(map1); } if("5".equals(type)){ switch (Integer.valueOf(String.valueOf(null != map.get("orderType") ? map.get("orderType") : 0))){ @@ -1732,20 +1760,98 @@ @PostMapping("/api/driver/getFleetEngineAuth") @ApiOperation(value = "获取google地图授权token", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ + @ApiImplicitParam(value = "车辆id", name = "vehicleId", required = true, dataType = "string"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) - public ResultUtil<String> getFleetEngineAuth(HttpServletRequest request){ + public ResultUtil<Map<String, Object>> getFleetEngineAuth(String vehicleId, HttpServletRequest request){ try { Integer uid = driverService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } - String s = fleetEngineUtil.fleetEngineAuth(2, uid); + if(!StringUtils.hasLength(vehicleId)){ + return ResultUtil.paranErr(); + } + Map<String, Object> s = fleetEngineUtil.fleetEngineAuth(2, vehicleId); return ResultUtil.success(s); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } - + + + + @ResponseBody + @PostMapping("/api/driver/textToSpeech") + @ApiOperation(value = "获取语音播报文件地址", tags = {"司机端-个人中心"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "语言", name = "languageCode", required = true, dataType = "string"), + @ApiImplicitParam(value = "内容", name = "text", required = true, dataType = "string"), + @ApiImplicitParam(value = "文件名称", name = "fileName", required = true, dataType = "string"), + @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResultUtil textToSpeech(String languageCode, String text, String fileName){ + try { + String s = TextToSpeechUtil.create(languageCode, text, fileName + ".mp3"); + //定时任务删除语音文件 + new Timer().schedule(new TimerTask() { + @Override + public void run() { + Process process = null; + try { + process = Runtime.getRuntime().exec("rm -rf /usr/local/nginx/html/files/audio/" + fileName + ".mp3"); + } catch (IOException e) { + throw new RuntimeException(e); + } + if (process != null) { + process.destroy(); + } + } + }, 30000); + return ResultUtil.success(s); + } catch (Exception e) { + e.printStackTrace(); + return ResultUtil.runErr(); + } + } + + + /** + * 手动添加当日活动 + */ + @ResponseBody + @GetMapping("/base/driver/addTodayActivity") + public void addTodayActivity(){ + try { + driverService.addTodayActivity(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + + /** + * 短信回调通知 + * @param request + */ + @ResponseBody + @PostMapping("/base/sendCellulantMessageCallback") + public void sendCellulantMessageCallback(HttpServletRequest request){ + try { + StringBuilder sb = new StringBuilder(); + InputStream inputStream = request.getInputStream(); + String s; + BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); + while ((s = in.readLine()) != null) { + sb.append(s); + } + in.close(); + inputStream.close(); + log.info("短信通知回调:" + sb.toString()); + }catch (Exception e){ + e.printStackTrace(); + } + } } -- Gitblit v1.7.1