提交
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
package com.baiyue.lastleg.fleet.trip;
|
||||
|
||||
import com.baiyue.lastleg.masterdata.vehicle.application.port.out.VehicleRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
/** 运输执行仍由车队应用边界核对车辆主档,不向排车暴露车辆持久化。 */
|
||||
@Service
|
||||
public class FleetTransportVehicleGuard {
|
||||
private final VehicleRepository vehicles;
|
||||
/** 复用车辆应用端口及其行锁。 */
|
||||
public FleetTransportVehicleGuard(VehicleRepository vehicles){this.vehicles=vehicles;}
|
||||
/** 发车核对实时车辆资格,并冻结当次有效容量供业务量复核。 */
|
||||
public void validate(FleetTripEntity trip){
|
||||
var vehicle=vehicles.lockById(trip.getVehicleId()).orElseThrow(()->new ResponseStatusException(HttpStatus.CONFLICT,"车辆不存在"));
|
||||
if(!"OVERSEAS".equals(vehicle.region()) || !"IN_SERVICE".equals(vehicle.status()))throw new ResponseStatusException(HttpStatus.CONFLICT,"当前车辆不可出车");
|
||||
trip.setMaxPalletSpaces(vehicle.maxPalletSpaces());trip.setMaxLoadKg(vehicle.maxLoadKg());trip.setMaxVolumeCbm(vehicle.maxVolumeCbm());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.baiyue.lastleg.fleet.trip;
|
||||
|
||||
|
||||
/** 同步事务内的运输事实;任一投影失败时原执行一起回滚。 */
|
||||
public record TransportTripChanged(FleetTripEntity trip,String action,String reason,String operator) { }
|
||||
Reference in New Issue
Block a user