一人多车,数据源
This commit is contained in:
@@ -6,6 +6,7 @@ import com.hotwj.platform.driverManagement.driver.domain.bo.DriverRegisterBo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.bo.HotDriverBatchBindVehicleBo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.bo.HotDriverBo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.bo.HotDriverPasswordBo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.bo.HotDriverSwitchVehicleBo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.vo.HotDriverImportVo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.vo.HotDriverLedgerExportVo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.vo.HotDriverVo;
|
||||
@@ -309,6 +310,17 @@ public class HotDriverController extends BaseController {
|
||||
return toAjax(hotDriverService.unbindVehicles(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前登录驾驶员切换默认车辆
|
||||
*/
|
||||
@Log(title = "驾驶员切换默认车辆", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/switchVehicle")
|
||||
@Operation(summary = "当前登录驾驶员切换默认车辆")
|
||||
public R<Void> switchVehicle(@Validated @RequestBody HotDriverSwitchVehicleBo bo) {
|
||||
return toAjax(hotDriverService.switchVehicle(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业负责人修改驾驶员登录密码
|
||||
*
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.hotwj.platform.driverManagement.driver.domain.bo;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 驾驶员切换默认车辆请求对象
|
||||
*
|
||||
* @author shihongwei
|
||||
* @date 2026-05-23
|
||||
*/
|
||||
@Data
|
||||
public class HotDriverSwitchVehicleBo {
|
||||
|
||||
/**
|
||||
* 目标车辆ID
|
||||
*/
|
||||
@NotBlank(message = "目标车辆ID不能为空")
|
||||
private String vehicleId;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.hotwj.platform.driverManagement.driver.service;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.bo.DriverRegisterBo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.bo.HotDriverBatchBindVehicleBo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.bo.HotDriverBo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.bo.HotDriverSwitchVehicleBo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.vo.HotDriverImportVo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.vo.HotDriverVo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@@ -84,6 +85,14 @@ public interface IHotDriverService {
|
||||
*/
|
||||
Boolean unbindVehicles(HotDriverBatchBindVehicleBo bo);
|
||||
|
||||
/**
|
||||
* 当前登录驾驶员切换默认车辆
|
||||
*
|
||||
* @param bo 切换信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
Boolean switchVehicle(HotDriverSwitchVehicleBo bo);
|
||||
|
||||
/**
|
||||
* 审核驾驶员账号
|
||||
*
|
||||
|
||||
@@ -7,11 +7,13 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.hotwj.platform.common.helper.DriverLoginContextHelper;
|
||||
import com.hotwj.platform.common.utils.PasswordUtils;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.HotDriver;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.bo.DriverRegisterBo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.bo.HotDriverBatchBindVehicleBo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.bo.HotDriverBo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.bo.HotDriverSwitchVehicleBo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.vo.HotDriverImportVo;
|
||||
import com.hotwj.platform.driverManagement.driver.domain.vo.HotDriverVo;
|
||||
import com.hotwj.platform.driverManagement.driver.mapper.HotDriverMapper;
|
||||
@@ -972,6 +974,57 @@ public class HotDriverServiceImpl implements IHotDriverService {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean switchVehicle(HotDriverSwitchVehicleBo bo) {
|
||||
HotDriver driver = DriverLoginContextHelper.getCurrentDriver();
|
||||
if (driver == null || Long.valueOf(1L).equals(driver.getIsDeleted())) {
|
||||
throw new ServiceException("驾驶员不存在");
|
||||
}
|
||||
if (driver.getCompanyId() == null) {
|
||||
throw new ServiceException("驾驶员所属公司不能为空");
|
||||
}
|
||||
|
||||
String targetVehicleId = StringUtils.trimToNull(bo.getVehicleId());
|
||||
if (StringUtils.isBlank(targetVehicleId)) {
|
||||
throw new ServiceException("目标车辆ID不能为空");
|
||||
}
|
||||
|
||||
List<String> boundVehicleIds = getBoundVehicleIds(driver);
|
||||
if (CollUtil.isEmpty(boundVehicleIds)) {
|
||||
throw new ServiceException("当前驾驶员未绑定车辆,不能切换");
|
||||
}
|
||||
if (!boundVehicleIds.contains(targetVehicleId)) {
|
||||
throw new ServiceException("驾驶员只能切换属于自己的车辆");
|
||||
}
|
||||
if (StringUtils.equals(driver.getVehicleId(), targetVehicleId)) {
|
||||
return true;
|
||||
}
|
||||
if (StringUtils.isBlank(driver.getVehicleId())) {
|
||||
throw new ServiceException("当前默认车辆不存在,不能切换");
|
||||
}
|
||||
|
||||
hotVehicleThreeInspectService.validateNoUnfinishedProcess(driver.getVehicleId(), "当前车辆三检流程未完成,不可切换车辆");
|
||||
|
||||
HotVehicle targetVehicle = vehicleMapper.selectOne(Wrappers.<HotVehicle>lambdaQuery()
|
||||
.eq(HotVehicle::getId, targetVehicleId)
|
||||
.eq(HotVehicle::getCompanyId, driver.getCompanyId())
|
||||
.eq(HotVehicle::getIsDeleted, 0L)
|
||||
.last("limit 1"));
|
||||
if (targetVehicle == null) {
|
||||
throw new ServiceException("目标车辆不存在");
|
||||
}
|
||||
if (!splitCsv(targetVehicle.getCurrentDriver()).contains(driver.getId())) {
|
||||
throw new ServiceException("驾驶员只能切换属于自己的车辆");
|
||||
}
|
||||
|
||||
return baseMapper.update(null, new LambdaUpdateWrapper<HotDriver>()
|
||||
.set(HotDriver::getVehicleId, targetVehicle.getId())
|
||||
.set(HotDriver::getPlateNumber, targetVehicle.getPlateNumber())
|
||||
.eq(HotDriver::getId, driver.getId())
|
||||
.eq(HotDriver::getCompanyId, driver.getCompanyId())) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除用户在特定企业的司机端登录权限
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,7 @@ spring:
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||
url: jdbc:mysql://172.21.143.42:33060/wucaixing?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
url: jdbc:mysql://172.21.143.42:33060/color?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: Hot20260401
|
||||
# # 从库数据源
|
||||
|
||||
Reference in New Issue
Block a user