新增接口,前端调用后,提示车辆是否已被出车
This commit is contained in:
@@ -14,6 +14,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -94,6 +95,16 @@ public class HotVehicleThreeInspectController extends BaseController {
|
||||
return R.ok(hotVehicleThreeInspectService.queryReceivedVehicles(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验当前驾驶员是否可选择指定车辆
|
||||
*/
|
||||
@GetMapping("/checkSelectableVehicle")
|
||||
@Operation(summary = "校验当前驾驶员是否可选择指定车辆")
|
||||
public R<Boolean> checkSelectableVehicle(@RequestParam @NotBlank(message = "驾驶员ID不能为空") String driverId,
|
||||
@RequestParam @NotBlank(message = "车辆ID不能为空") String vehicleId) {
|
||||
return R.ok(hotVehicleThreeInspectService.checkSelectableVehicle(driverId, vehicleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出车辆三检列表
|
||||
*/
|
||||
|
||||
@@ -114,6 +114,16 @@ public interface IHotVehicleThreeInspectService {
|
||||
*/
|
||||
void validateNoUnfinishedSwitchVehicleProcess(String vehicleId, String actionMessage);
|
||||
|
||||
/**
|
||||
* 校验当前驾驶员是否可选择指定车辆。
|
||||
* 若车辆未出车则直接返回true;若车辆已出车,且当次三检流程未完成,且记录驾驶员不是当前驾驶员,则抛出异常。
|
||||
*
|
||||
* @param driverId 当前驾驶员ID
|
||||
* @param vehicleId 车辆ID
|
||||
* @return 是否可选择
|
||||
*/
|
||||
boolean checkSelectableVehicle(String driverId, String vehicleId);
|
||||
|
||||
/**
|
||||
* 修改车辆三检
|
||||
*
|
||||
|
||||
@@ -25,6 +25,8 @@ import com.hotwj.platform.resourceManagement.vehicleManagement.domain.HotVehicle
|
||||
import com.hotwj.platform.resourceManagement.vehicleManagement.domain.vo.HotVehicleVo;
|
||||
import com.hotwj.platform.resourceManagement.vehicleManagement.mapper.HotVehicleMapper;
|
||||
import com.hotwj.platform.securityManagement.hiddenDanger.mapper.HotHiddenDangerMapper;
|
||||
import com.hotwj.platform.securityManagement.vehicleInoutCheck.domain.HotVehicleInoutCheck;
|
||||
import com.hotwj.platform.securityManagement.vehicleInoutCheck.mapper.HotVehicleInoutCheckMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
@@ -58,6 +60,7 @@ public class HotVehicleThreeInspectServiceImpl implements IHotVehicleThreeInspec
|
||||
private final HotVehicleThreeInspectMapper baseMapper;
|
||||
private final HotVehicleMapper hotVehicleMapper;
|
||||
private final HotHiddenDangerMapper hotHiddenDangerMapper;
|
||||
private final HotVehicleInoutCheckMapper hotVehicleInoutCheckMapper;
|
||||
private final ISysFlowService flowService;
|
||||
private final IHotSystemNotificationService notificationService;
|
||||
private final SignatureVerifyService signatureVerifyService;
|
||||
@@ -122,6 +125,27 @@ public class HotVehicleThreeInspectServiceImpl implements IHotVehicleThreeInspec
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkSelectableVehicle(String driverId, String vehicleId) {
|
||||
String trimmedDriverId = StringUtils.trimToNull(driverId);
|
||||
String trimmedVehicleId = StringUtils.trimToNull(vehicleId);
|
||||
if (StringUtils.isBlank(trimmedDriverId)) {
|
||||
throw new ServiceException("驾驶员ID不能为空");
|
||||
}
|
||||
Long parsedVehicleId = parseVehicleId(trimmedVehicleId);
|
||||
if (parsedVehicleId == null || !isVehicleOutbound(parsedVehicleId)) {
|
||||
return true;
|
||||
}
|
||||
HotVehicleThreeInspect latestInspect = selectLatestInspect(parsedVehicleId);
|
||||
if (latestInspect == null || Objects.equals(latestInspect.getInspectPhase(), 3L)) {
|
||||
return true;
|
||||
}
|
||||
if (StringUtils.equals(trimmedDriverId, StringUtils.trimToEmpty(latestInspect.getDriverId()))) {
|
||||
return true;
|
||||
}
|
||||
throw new ServiceException(buildVehicleOccupiedMessage(parsedVehicleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询车辆三检
|
||||
*
|
||||
@@ -361,6 +385,19 @@ public class HotVehicleThreeInspectServiceImpl implements IHotVehicleThreeInspec
|
||||
return "'" + plateNumber + "'车辆已出任务,请重新选择其他车辆";
|
||||
}
|
||||
|
||||
private boolean isVehicleOutbound(Long vehicleId) {
|
||||
if (vehicleId == null) {
|
||||
return false;
|
||||
}
|
||||
return hotVehicleInoutCheckMapper.selectCount(
|
||||
Wrappers.<HotVehicleInoutCheck>lambdaQuery()
|
||||
.eq(HotVehicleInoutCheck::getVehicleId, vehicleId)
|
||||
.eq(HotVehicleInoutCheck::getIsDeleted, 0L)
|
||||
.isNotNull(HotVehicleInoutCheck::getDepartureTime)
|
||||
.isNull(HotVehicleInoutCheck::getReturnTime)
|
||||
) > 0;
|
||||
}
|
||||
|
||||
private void validateInspectorSignatureByPhase(HotVehicleThreeInspectBo bo) {
|
||||
Long inspectPhase = bo.getInspectPhase();
|
||||
if (inspectPhase == null) {
|
||||
|
||||
Reference in New Issue
Block a user