救援代码修正

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")
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<DriverInfo>().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<DriverInfo>().eq(DriverInfo::getUserId, loginUser.getId()));
rescueInfo.setDriverId(driverInfo.getId());
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);
return success(rescueInfos);
}else {
} else {
IPage<RescueInfo> 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<RescueInfo> queryWrapper =new LambdaQueryWrapper<>();
queryWrapper.eq(RescueInfo::getDriverId,driverId).eq(RescueInfo::getRescueStatus,"3").last("limit 1");
} else {
LambdaQueryWrapper<RescueInfo> 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("查询成功");

View File

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

View File

@ -401,18 +401,28 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
if (CollectionUtil.isEmpty(list)) {
throw exception0(500, "该路段没有司机,请先配置");
}
// 司机的userId
Set<Long> driverIds = list.stream()
.map(RescueDictStaff::getDriverIds)
.flatMap(item -> Arrays.stream(item.split(",")))
.map(Long::parseLong)
.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.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();

View File

@ -43,10 +43,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="driverId != null">driver_id,</if>
<if test="driverAccept != null">driver_accept,</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 prefix="values (" suffix=")" suffixOverrides=",">
<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="driverAccept != null">#{driverAccept},</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>
</insert>

View File

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