From 4c99ee7028c3fe58a2cd4b8273b22c75c45574fc Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 16 五月 2025 10:27:41 +0800 Subject: [PATCH] 修改文档bug --- DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java | 158 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 145 insertions(+), 13 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..fb2cd10 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,8 @@ import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.mchange.util.FailSuppressedMessageLogger; +import com.stylefeng.guns.core.util.MD5Util; 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 +14,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 +24,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 +49,8 @@ @RestController @RequestMapping("") public class DriverController { + + private Logger log = LoggerFactory.getLogger(DriverController.class); @Autowired private IDriverService driverService; @@ -97,6 +105,12 @@ @Autowired private FleetEngineUtil fleetEngineUtil; + + @Autowired + private IOrderCancelService orderCancelService; + + @Autowired + private RedisUtil redisUtil; @@ -624,6 +638,13 @@ if(null == uid){ return ResultUtil.tokenErr(); } + String format = String.format("uid=%s&type=%s", uid, type); + String key = MD5Util.encrypt(format); + String value = redisUtil.getValue(key); + if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){ + return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); + } + redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); return driverService.work(uid, type, language); }catch (Exception e){ e.printStackTrace(); @@ -810,7 +831,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)); @@ -1206,10 +1227,14 @@ BaseWarpper baseWarpper = new BaseWarpper(); baseWarpper.setDay(String.valueOf(null != map.get("time") ? map.get("time") : "")); baseWarpper.setAmount(Double.valueOf(String.valueOf(null != map.get("money") ? map.get("money") : 0))); + baseWarpper.setType(Integer.valueOf(type)); if("2".equals(type)){ 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 +1245,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 +1270,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 +1282,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,7 +1294,11 @@ 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("travelMoney", orderLogistics != null ? orderLogistics.getOrderMoney() : 0);//行程费 map1.put("parkMoney", orderLogistics != null ? orderLogistics.getParkMoney() : 0);//停车费 map1.put("tipMoney", 0);//小费 map1.put("roadTollMoney", orderLogistics != null ? orderLogistics.getRoadTollMoney() : 0);//过路费 @@ -1268,11 +1306,14 @@ 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);//停车费 + map1.put("parkMoney", orderLogistics1 != null ? orderLogistics1.getParkMoney() : 0);//停车费 map1.put("tipMoney", 0);//小费 - map1.put("roadTollMoney", 0);//过路费 + map1.put("roadTollMoney", orderLogistics1 != null ? orderLogistics1.getRoadTollMoney() : 0);//过路费 map1.put("rakeMoney", incomes4.size() > 0 ? incomes4.get(0).getMoney() : 0);//抽成 break; } @@ -1297,8 +1338,14 @@ baseWarpper.setName(language == 1 ? "跨城小件物流" : language == 2 ? "Cross-city small parts logistics" : "Logistique des petites pièces à travers la ville"); 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<>(); + + OrderCancel orderCancel = orderCancelService.selectOne(new EntityWrapper<OrderCancel>().eq("orderType", map.get("orderType")) + .eq("orderId", map.get("incomeId")).eq("state", 2)); + map1.put("travelMoney", orderCancel.getMoney());//支付金额 + 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))){ @@ -1451,7 +1498,7 @@ return ResultUtil.tokenErr(); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - List<ActivityWarpper> activityWarppers = driverService.queryMyActivity(uid, sdf.parse(time), language); + List<ActivityWarpper> activityWarppers = driverService.queryHistoryList(uid, sdf.parse(time), language); return ResultUtil.success(activityWarppers); }catch (Exception e){ e.printStackTrace(); @@ -1732,20 +1779,105 @@ @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() { + try { + // 使用Runtime执行命令 + Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName + ".mp3"); + // 读取命令的输出 + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while ((line = reader.readLine()) != null) { + System.out.println(line); + } + // 等待命令执行完成 + process.waitFor(); + // 关闭流 + reader.close(); + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + } + } + }, 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