diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueDriverController.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueDriverController.java index f18228bb..5066ef2b 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueDriverController.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueDriverController.java @@ -50,78 +50,78 @@ public class RescueDriverController extends BaseController { //获取司机状态 @GetMapping("/getStatus") - public CommonResult getStatus(Long driverId) - { - return success( rescueDriverInfoService.getStatus(driverId)); + public CommonResult getStatus(Long driverId) { + return success(rescueDriverInfoService.getStatus(driverId)); } + //司机数据统计 @GetMapping("/driverInfoStatistics") - public CommonResult driverInfoStatistics(Long driverId) - { - return success( rescueDriverInfoService.driverInfoStatistics(driverId)); + public CommonResult driverInfoStatistics(Long driverId) { + return success(rescueDriverInfoService.driverInfoStatistics(driverId)); } + //司机待救援列表 @GetMapping("/driverRescueList") - public CommonResult driverRescueList() - { + public CommonResult driverRescueList() { LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); DriverInfo driverInfo = driverInfoService.getOne(new LambdaQueryWrapper().eq(DriverInfo::getUserId, loginUser.getId())); return success(rescueDriverInfoService.driverRescueList(driverInfo.getId())); } + //司机进行中的 已完成的救援信息 @GetMapping("/driverRescuePage") public CommonResult driverRescuePage(RescueInfo rescueInfo, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, - @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) - { + @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); DriverInfo driverInfo = driverInfoService.getOne(new LambdaQueryWrapper().eq(DriverInfo::getUserId, loginUser.getId())); rescueInfo.setDriverId(driverInfo.getId()); Page page = new Page<>(pageNum, pageSize); - if (rescueInfo.getRescueStatus().equals("2")){ + if (rescueInfo.getRescueStatus().equals("2")) { IPage rescueInfos = rescueDriverInfoService.driverRescueList2(driverInfo.getId(), page); return success(rescueInfos); - }else { + } else { IPage rescueInfos = rescueDriverInfoService.driverRescuePage2(rescueInfo, page); return success(rescueInfos); } } + //司机待救援列表 @PostMapping("/updateWork") public CommonResult updateWork(Long driverId) throws Exception { DriverInfo driverInfo = driverInfoService.getById(driverId); - if (driverInfo.getDriverStatus().equals("2")){ + if (driverInfo.getDriverStatus().equals("2")) { driverInfo.setDriverStatus("1"); - }else { - LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(RescueInfo::getDriverId,driverId).eq(RescueInfo::getRescueStatus,"3").last("limit 1"); + } else { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RescueInfo::getDriverId, driverId).eq(RescueInfo::getRescueStatus, "3").last("limit 1"); RescueInfo one = rescueInfoService.getOne(queryWrapper); - if (!ObjectUtil.isEmpty(one)){ + if (!ObjectUtil.isEmpty(one)) { throw new Exception("有订单进行中,不可暂停"); } driverInfo.setDriverStatus("2"); } AdminUserRespDTO sysUser = userService.getUser(driverInfo.getUserId()); //所在顶级机构 - String redisKey = Redis_Driver_Key+sysUser.getDeptId()+":"+driverId; - if (!redisCache2.hasKey(redisKey)){ - redisCache2.setCacheMapValue(redisKey,"status",driverInfo.getDriverStatus()); + String redisKey = Redis_Driver_Key + sysUser.getDeptId() + ":" + driverId; + if (!redisCache2.hasKey(redisKey)) { + redisCache2.setCacheMapValue(redisKey, "status", driverInfo.getDriverStatus()); } driverInfoService.updateById(driverInfo); return success(); } + //司机接受或拒绝 choose 0拒绝1接受 @PostMapping("/driverAccept") - public CommonResult driverAccept(Long rescueDriverId,String choose,String rejectReason) throws Exception { + public CommonResult driverAccept(Long rescueDriverId, String choose, String rejectReason) throws Exception { rescueDriverInfoService.driverAccept(rescueDriverId, choose, rejectReason); return success("查询成功"); } //救援信息详情 @GetMapping("/rescueDetail") - public CommonResult rescueDetail(Long rescueId) - { + public CommonResult rescueDetail(Long rescueId) { return success(rescueDriverInfoService.rescueDetail(rescueId)); } @@ -132,18 +132,21 @@ public class RescueDriverController extends BaseController { rescueDriverInfoService.uploadDetailByDriver(rescueInfoDetail); return success("成功"); } + //设置应收金额 @PostMapping("/setOrderMoney") - public CommonResult setOrderMoney(@RequestParam("rescueId") String rescueId,@RequestParam("setMoney") Double setMoney) throws Exception { - rescueDriverInfoService.setOrderMoney(Long.parseLong(rescueId),setMoney); + public CommonResult setOrderMoney(@RequestParam("rescueId") String rescueId, @RequestParam("setMoney") Double setMoney) throws Exception { + rescueDriverInfoService.setOrderMoney(Long.parseLong(rescueId), setMoney); return success("成功"); } + //完成救援 @PostMapping("/endRescue") public CommonResult endRescue(@RequestParam("rescueId") String rescueId) throws Exception { rescueDriverInfoService.endRescue(Long.parseLong(rescueId)); return success("成功"); } + //上传加油记录 @PostMapping("/addRefuelRecord") public CommonResult addRefuelRecord(@RequestBody RescueRefuelRecord rescueRefuelRecord) throws Exception { @@ -161,8 +164,7 @@ public class RescueDriverController extends BaseController { return success(rescueRefuelRecords); } - protected TableDataInfo getDataTable(List list) - { + protected TableDataInfo getDataTable(List list) { TableDataInfo rspData = new TableDataInfo(); rspData.setCode(HttpStatus.SUCCESS); rspData.setMsg("查询成功"); diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueDriverInfoServiceImpl.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueDriverInfoServiceImpl.java index 501b5a4d..6653d5a5 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueDriverInfoServiceImpl.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueDriverInfoServiceImpl.java @@ -92,7 +92,8 @@ public class RescueDriverInfoServiceImpl extends ServiceImpl driverIds = list.stream() .map(RescueDictStaff::getDriverIds) .flatMap(item -> Arrays.stream(item.split(","))) .map(Long::parseLong) .collect(Collectors.toSet()); - driverIds.forEach(item -> { + // 司机的driver_id + List driverInfos = driverInfoService.list(new LambdaQueryWrapper().in(DriverInfo::getUserId, driverIds)); + driverInfos.forEach(item -> { + // 发消息 SysAnnouncement sysAnnouncement = new SysAnnouncement(); sysAnnouncement.setType("救援信息"); - sysAnnouncement.setToUserIds(Collections.singletonList(item)); + sysAnnouncement.setToUserIds(Collections.singletonList(item.getUserId())); sysAnnouncement.setTitle("有新的救援订单请立即处理"); sysAnnouncement.setContent("有新的救援订单请立即处理"); announcementService.insertSysAnnouncements(sysAnnouncement); + // 发订单 + RescueDriverInfo rescueDriverInfo = new RescueDriverInfo(); + rescueDriverInfo.setDriverId(item.getId()); + rescueDriverInfo.setRescueId(rescueInfo.getId()); + rescueDriverInfo.setDriverAccept("2"); + rescueDriverInfoService.insertRescueDriverInfo(rescueDriverInfo); }); // 新增延迟消息,用于三分钟后没人接单通知 TaskDto taskDto = new TaskDto(); diff --git a/dl-module-rescue/src/main/resources/mapper/rescue/RescueDriverInfoMapper.xml b/dl-module-rescue/src/main/resources/mapper/rescue/RescueDriverInfoMapper.xml index 1830c2f2..35c032d0 100644 --- a/dl-module-rescue/src/main/resources/mapper/rescue/RescueDriverInfoMapper.xml +++ b/dl-module-rescue/src/main/resources/mapper/rescue/RescueDriverInfoMapper.xml @@ -43,10 +43,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" driver_id, driver_accept, driver_reject_reason, - create_time, - creator, - update_time, - updater, #{id}, @@ -54,10 +50,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{driverId}, #{driverAccept}, #{driverRejectReason}, - #{createTime}, - #{creator}, - #{updateTime}, - #{updater}, diff --git a/dl-module-rescue/src/main/resources/mapper/rescue/RescueInfoMapper.xml b/dl-module-rescue/src/main/resources/mapper/rescue/RescueInfoMapper.xml index fdeb0491..68a89b8a 100644 --- a/dl-module-rescue/src/main/resources/mapper/rescue/RescueInfoMapper.xml +++ b/dl-module-rescue/src/main/resources/mapper/rescue/RescueInfoMapper.xml @@ -12,7 +12,7 @@ rescue_info ri left join rescue_order_info roi on roi.rescue_info_id = ri.id - 1=1 + 1=1 and ri.deleted = '0'