救援代码修正

This commit is contained in:
xiao-fajia 2024-09-04 14:25:30 +08:00
parent 3a43bc9511
commit b2db2d3b71
5 changed files with 44 additions and 39 deletions

View File

@ -50,78 +50,78 @@ public class RescueDriverController extends BaseController {
//获取司机状态 //获取司机状态
@GetMapping("/getStatus") @GetMapping("/getStatus")
public CommonResult getStatus(Long driverId) public CommonResult getStatus(Long driverId) {
{ return success(rescueDriverInfoService.getStatus(driverId));
return success( rescueDriverInfoService.getStatus(driverId));
} }
//司机数据统计 //司机数据统计
@GetMapping("/driverInfoStatistics") @GetMapping("/driverInfoStatistics")
public CommonResult driverInfoStatistics(Long driverId) public CommonResult driverInfoStatistics(Long driverId) {
{ return success(rescueDriverInfoService.driverInfoStatistics(driverId));
return success( rescueDriverInfoService.driverInfoStatistics(driverId));
} }
//司机待救援列表 //司机待救援列表
@GetMapping("/driverRescueList") @GetMapping("/driverRescueList")
public CommonResult driverRescueList() public CommonResult driverRescueList() {
{
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
DriverInfo driverInfo = driverInfoService.getOne(new LambdaQueryWrapper<DriverInfo>().eq(DriverInfo::getUserId, loginUser.getId())); DriverInfo driverInfo = driverInfoService.getOne(new LambdaQueryWrapper<DriverInfo>().eq(DriverInfo::getUserId, loginUser.getId()));
return success(rescueDriverInfoService.driverRescueList(driverInfo.getId())); return success(rescueDriverInfoService.driverRescueList(driverInfo.getId()));
} }
//司机进行中的 已完成的救援信息 //司机进行中的 已完成的救援信息
@GetMapping("/driverRescuePage") @GetMapping("/driverRescuePage")
public CommonResult driverRescuePage(RescueInfo rescueInfo, public CommonResult driverRescuePage(RescueInfo rescueInfo,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @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(); LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
DriverInfo driverInfo = driverInfoService.getOne(new LambdaQueryWrapper<DriverInfo>().eq(DriverInfo::getUserId, loginUser.getId())); DriverInfo driverInfo = driverInfoService.getOne(new LambdaQueryWrapper<DriverInfo>().eq(DriverInfo::getUserId, loginUser.getId()));
rescueInfo.setDriverId(driverInfo.getId()); rescueInfo.setDriverId(driverInfo.getId());
Page<RescueInfo> page = new Page<>(pageNum, pageSize); Page<RescueInfo> page = new Page<>(pageNum, pageSize);
if (rescueInfo.getRescueStatus().equals("2")){ if (rescueInfo.getRescueStatus().equals("2")) {
IPage<RescueInfo> rescueInfos = rescueDriverInfoService.driverRescueList2(driverInfo.getId(), page); IPage<RescueInfo> rescueInfos = rescueDriverInfoService.driverRescueList2(driverInfo.getId(), page);
return success(rescueInfos); return success(rescueInfos);
}else { } else {
IPage<RescueInfo> rescueInfos = rescueDriverInfoService.driverRescuePage2(rescueInfo, page); IPage<RescueInfo> rescueInfos = rescueDriverInfoService.driverRescuePage2(rescueInfo, page);
return success(rescueInfos); return success(rescueInfos);
} }
} }
//司机待救援列表 //司机待救援列表
@PostMapping("/updateWork") @PostMapping("/updateWork")
public CommonResult updateWork(Long driverId) throws Exception { public CommonResult updateWork(Long driverId) throws Exception {
DriverInfo driverInfo = driverInfoService.getById(driverId); DriverInfo driverInfo = driverInfoService.getById(driverId);
if (driverInfo.getDriverStatus().equals("2")){ if (driverInfo.getDriverStatus().equals("2")) {
driverInfo.setDriverStatus("1"); driverInfo.setDriverStatus("1");
}else { } else {
LambdaQueryWrapper<RescueInfo> queryWrapper =new LambdaQueryWrapper<>(); LambdaQueryWrapper<RescueInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueInfo::getDriverId,driverId).eq(RescueInfo::getRescueStatus,"3").last("limit 1"); queryWrapper.eq(RescueInfo::getDriverId, driverId).eq(RescueInfo::getRescueStatus, "3").last("limit 1");
RescueInfo one = rescueInfoService.getOne(queryWrapper); RescueInfo one = rescueInfoService.getOne(queryWrapper);
if (!ObjectUtil.isEmpty(one)){ if (!ObjectUtil.isEmpty(one)) {
throw new Exception("有订单进行中,不可暂停"); throw new Exception("有订单进行中,不可暂停");
} }
driverInfo.setDriverStatus("2"); driverInfo.setDriverStatus("2");
} }
AdminUserRespDTO sysUser = userService.getUser(driverInfo.getUserId()); AdminUserRespDTO sysUser = userService.getUser(driverInfo.getUserId());
//所在顶级机构 //所在顶级机构
String redisKey = Redis_Driver_Key+sysUser.getDeptId()+":"+driverId; String redisKey = Redis_Driver_Key + sysUser.getDeptId() + ":" + driverId;
if (!redisCache2.hasKey(redisKey)){ if (!redisCache2.hasKey(redisKey)) {
redisCache2.setCacheMapValue(redisKey,"status",driverInfo.getDriverStatus()); redisCache2.setCacheMapValue(redisKey, "status", driverInfo.getDriverStatus());
} }
driverInfoService.updateById(driverInfo); driverInfoService.updateById(driverInfo);
return success(); return success();
} }
//司机接受或拒绝 choose 0拒绝1接受 //司机接受或拒绝 choose 0拒绝1接受
@PostMapping("/driverAccept") @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); rescueDriverInfoService.driverAccept(rescueDriverId, choose, rejectReason);
return success("查询成功"); return success("查询成功");
} }
//救援信息详情 //救援信息详情
@GetMapping("/rescueDetail") @GetMapping("/rescueDetail")
public CommonResult rescueDetail(Long rescueId) public CommonResult rescueDetail(Long rescueId) {
{
return success(rescueDriverInfoService.rescueDetail(rescueId)); return success(rescueDriverInfoService.rescueDetail(rescueId));
} }
@ -132,18 +132,21 @@ public class RescueDriverController extends BaseController {
rescueDriverInfoService.uploadDetailByDriver(rescueInfoDetail); rescueDriverInfoService.uploadDetailByDriver(rescueInfoDetail);
return success("成功"); return success("成功");
} }
//设置应收金额 //设置应收金额
@PostMapping("/setOrderMoney") @PostMapping("/setOrderMoney")
public CommonResult setOrderMoney(@RequestParam("rescueId") String rescueId,@RequestParam("setMoney") Double setMoney) throws Exception { public CommonResult setOrderMoney(@RequestParam("rescueId") String rescueId, @RequestParam("setMoney") Double setMoney) throws Exception {
rescueDriverInfoService.setOrderMoney(Long.parseLong(rescueId),setMoney); rescueDriverInfoService.setOrderMoney(Long.parseLong(rescueId), setMoney);
return success("成功"); return success("成功");
} }
//完成救援 //完成救援
@PostMapping("/endRescue") @PostMapping("/endRescue")
public CommonResult endRescue(@RequestParam("rescueId") String rescueId) throws Exception { public CommonResult endRescue(@RequestParam("rescueId") String rescueId) throws Exception {
rescueDriverInfoService.endRescue(Long.parseLong(rescueId)); rescueDriverInfoService.endRescue(Long.parseLong(rescueId));
return success("成功"); return success("成功");
} }
//上传加油记录 //上传加油记录
@PostMapping("/addRefuelRecord") @PostMapping("/addRefuelRecord")
public CommonResult addRefuelRecord(@RequestBody RescueRefuelRecord rescueRefuelRecord) throws Exception { public CommonResult addRefuelRecord(@RequestBody RescueRefuelRecord rescueRefuelRecord) throws Exception {
@ -161,8 +164,7 @@ public class RescueDriverController extends BaseController {
return success(rescueRefuelRecords); return success(rescueRefuelRecords);
} }
protected TableDataInfo getDataTable(List<?> list) protected TableDataInfo getDataTable(List<?> list) {
{
TableDataInfo rspData = new TableDataInfo(); TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS); rspData.setCode(HttpStatus.SUCCESS);
rspData.setMsg("查询成功"); rspData.setMsg("查询成功");

View File

@ -92,7 +92,8 @@ public class RescueDriverInfoServiceImpl extends ServiceImpl<RescueDriverInfoMap
*/ */
@Override @Override
public int insertRescueDriverInfo(RescueDriverInfo rescueDriverInfo) { public int insertRescueDriverInfo(RescueDriverInfo rescueDriverInfo) {
return baseMapper.insertRescueDriverInfo(rescueDriverInfo); return baseMapper.insert(rescueDriverInfo);
// return baseMapper.insertRescueDriverInfo(rescueDriverInfo);
} }
@Override @Override

View File

@ -401,18 +401,28 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
if (CollectionUtil.isEmpty(list)) { if (CollectionUtil.isEmpty(list)) {
throw exception0(500, "该路段没有司机,请先配置"); throw exception0(500, "该路段没有司机,请先配置");
} }
// 司机的userId
Set<Long> driverIds = list.stream() Set<Long> driverIds = list.stream()
.map(RescueDictStaff::getDriverIds) .map(RescueDictStaff::getDriverIds)
.flatMap(item -> Arrays.stream(item.split(","))) .flatMap(item -> Arrays.stream(item.split(",")))
.map(Long::parseLong) .map(Long::parseLong)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
driverIds.forEach(item -> { // 司机的driver_id
List<DriverInfo> driverInfos = driverInfoService.list(new LambdaQueryWrapper<DriverInfo>().in(DriverInfo::getUserId, driverIds));
driverInfos.forEach(item -> {
// 发消息
SysAnnouncement sysAnnouncement = new SysAnnouncement(); SysAnnouncement sysAnnouncement = new SysAnnouncement();
sysAnnouncement.setType("救援信息"); sysAnnouncement.setType("救援信息");
sysAnnouncement.setToUserIds(Collections.singletonList(item)); sysAnnouncement.setToUserIds(Collections.singletonList(item.getUserId()));
sysAnnouncement.setTitle("有新的救援订单请立即处理"); sysAnnouncement.setTitle("有新的救援订单请立即处理");
sysAnnouncement.setContent("有新的救援订单请立即处理"); sysAnnouncement.setContent("有新的救援订单请立即处理");
announcementService.insertSysAnnouncements(sysAnnouncement); 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(); TaskDto taskDto = new TaskDto();

View File

@ -43,10 +43,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="driverId != null">driver_id,</if> <if test="driverId != null">driver_id,</if>
<if test="driverAccept != null">driver_accept,</if> <if test="driverAccept != null">driver_accept,</if>
<if test="driverRejectReason != null">driver_reject_reason,</if> <if test="driverRejectReason != null">driver_reject_reason,</if>
<if test="createTime != null">create_time,</if>
<if test="creator != null">creator,</if>
<if test="updateTime != null">update_time,</if>
<if test="updater != null">updater,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if> <if test="id != null">#{id},</if>
@ -54,10 +50,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="driverId != null">#{driverId},</if> <if test="driverId != null">#{driverId},</if>
<if test="driverAccept != null">#{driverAccept},</if> <if test="driverAccept != null">#{driverAccept},</if>
<if test="driverRejectReason != null">#{driverRejectReason},</if> <if test="driverRejectReason != null">#{driverRejectReason},</if>
<if test="createTime != null">#{createTime},</if>
<if test="creator != null">#{creator},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updater != null">#{updater},</if>
</trim> </trim>
</insert> </insert>

View File

@ -12,7 +12,7 @@
rescue_info ri rescue_info ri
left join rescue_order_info roi on roi.rescue_info_id = ri.id left join rescue_order_info roi on roi.rescue_info_id = ri.id
<where> <where>
1=1 1=1 and ri.deleted = '0'
<if test="map.rescueStatus != null "> <if test="map.rescueStatus != null ">
<choose> <choose>
<when test="map.rescueStatus == '1'.toString()"> <when test="map.rescueStatus == '1'.toString()">