From b3b7d3ae4789eb3d4d4bbadccd03d79adb28cb1a Mon Sep 17 00:00:00 2001 From: zhibing.pu <393733352@qq.com> Date: 星期四, 25 七月 2024 18:21:09 +0800 Subject: [PATCH] 修改2.0 bug --- UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/controller/OrderLogisticsController.java | 85 +++++++++++++++++++++++++++++++++++++++--- 1 files changed, 78 insertions(+), 7 deletions(-) diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/controller/OrderLogisticsController.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/controller/OrderLogisticsController.java index c1ed62c..c7d6e74 100644 --- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/controller/OrderLogisticsController.java +++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/controller/OrderLogisticsController.java @@ -1,16 +1,22 @@ package com.stylefeng.guns.modular.smallLogistics.controller; +import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics; import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService; import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; +import com.stylefeng.guns.modular.system.model.Driver; import com.stylefeng.guns.modular.system.model.Region; import com.stylefeng.guns.modular.system.model.UserRedPacketRecord; +import com.stylefeng.guns.modular.system.service.IDriverService; +import com.stylefeng.guns.modular.system.service.IDriverServiceService; import com.stylefeng.guns.modular.system.service.IUserInfoService; import com.stylefeng.guns.modular.system.util.GoogleMap.DistancematrixVo; import com.stylefeng.guns.modular.system.util.GoogleMap.GoogleMapUtil; import com.stylefeng.guns.modular.system.util.PushUtil; +import com.stylefeng.guns.modular.system.util.RedisUtil; import com.stylefeng.guns.modular.system.util.ResultUtil; +import com.stylefeng.guns.modular.system.util.TextToSpeechUtil; import com.stylefeng.guns.modular.system.warpper.BaseWarpper; import com.stylefeng.guns.modular.system.warpper.OrderTimeInfo; import io.swagger.annotations.Api; @@ -24,12 +30,10 @@ import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; +import java.io.IOException; import java.math.BigDecimal; import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 小件物流控制器 @@ -45,6 +49,18 @@ private IUserInfoService userInfoService; @Autowired private PushUtil pushUtil; + + @Autowired + private IDriverService driverService; + + @Autowired + private RedisUtil redisUtil; + + + + + + /** @@ -315,7 +331,8 @@ if(null != orderLogistics.getStartServiceTime()){ orderTimeInfo.setStartServiceTime(sdf.format(orderLogistics.getStartServiceTime())); } - long time = System.currentTimeMillis() - orderLogistics.getSnatchOrderTime().getTime() / 60000; + //分钟 + long time = (System.currentTimeMillis() - orderLogistics.getSnatchOrderTime().getTime()) / 60000; int h = Double.valueOf(time / 60).intValue(); long m = time % 60; @@ -333,6 +350,22 @@ Long distance = distancematrix.getDistance(); orderTimeInfo.setAllMileage(Double.valueOf(distance / 1000)); orderTimeInfo.setMileage(orderLogistics.getMileage() / 1000); + String value = redisUtil.getValue("DRIVER" + orderLogistics.getDriverId()); + if(ToolUtil.isNotEmpty(value)){ + String[] split = value.split(","); + distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(split[1]), Double.valueOf(split[0]), orderLogistics.getEndLat(), orderLogistics.getEndLon()); + //分钟 + Long duration = distancematrix.getDuration() / 60; + h = Double.valueOf(duration / 60).intValue(); + m = duration % 60; + String remainingTime = ""; + if(0 == h){ + remainingTime = language == 1 ? m + "分钟" : language == 2 ? m + "-minute" : m + "-minute"; + }else{ + remainingTime = language == 1 ? h + "小时" + m + "分钟" : language == 2 ? h + "-hour" + m + "-minute" : h + "-hour" + m + "-minute"; + } + orderTimeInfo.setRemainingTime(remainingTime); + } return ResultUtil.success(orderTimeInfo); }catch (Exception e){ e.printStackTrace(); @@ -353,11 +386,49 @@ }) public ResultUtil confirmDifferencePrice(Integer orderId, Double difference, Integer status){ OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId); - if(1 == status){ + if(2 == status){ orderLogistics.setPriceDifference(difference); orderLogisticsService.updateById(orderLogistics); } - pushUtil.pushPayDifference(2, orderLogistics.getDriverId(), orderId, 4, difference, status); + String audioUrl = ""; + if(3 == status){ + Driver driver = driverService.selectById(orderLogistics.getDriverId()); + Integer language = driver.getLanguage(); + String text = ""; + switch (language){ + case 1: + text = "您的包裹订单申请补差价 GSH " + difference + " 已被用户拒绝,请重新与用户协商"; + break; + case 2: + text = "Your delivery order,Request difference GSH " + difference + " was rejected, please renegotiate with the subscriber"; + break; + case 3: + text = "Votre commande de livraison,Demande de différence GSH " + difference + " a été rejeté, veuillez renégocier avec l’abonné"; + break; + + } + try { + audioUrl = TextToSpeechUtil.create(language == 1 ? "cmn-CN" : language == 2 ? "en-US" : "fr-FR", text, "difference" + driver.getId() + ".mp3"); + } catch (Exception e) { + throw new RuntimeException(e); + } + //定时任务删除语音文件 + 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/difference" + driver.getId() + ".mp3"); + } catch (IOException e) { + throw new RuntimeException(e); + } + if (process != null) { + process.destroy(); + } + } + }, 30000); + } + pushUtil.pushPayDifference(2, orderLogistics.getDriverId(), orderId, 4, difference, status, audioUrl); return ResultUtil.success(); } -- Gitblit v1.7.1