지금은 출발지목적지가 달라도 강제로 수정이 가능합니다.
This commit is contained in:
parent
81c3e1b4ba
commit
c1be1893f5
|
|
@ -4116,39 +4116,43 @@ export class ButtonActionExecutor {
|
|||
try {
|
||||
console.log("🛑 [handleTrackingStop] 위치 추적 종료:", { config, context });
|
||||
|
||||
// 추적 중인지 확인
|
||||
if (!this.trackingIntervalId) {
|
||||
toast.warning("진행 중인 위치 추적이 없습니다.");
|
||||
return false;
|
||||
// 추적 중인지 확인 (새로고침 후에도 DB 상태 기반 종료 가능하도록 수정)
|
||||
const isTrackingActive = !!this.trackingIntervalId;
|
||||
|
||||
if (!isTrackingActive) {
|
||||
// 추적 중이 아니어도 DB 상태 변경은 진행 (새로고침 후 종료 지원)
|
||||
console.log("⚠️ [handleTrackingStop] trackingIntervalId 없음 - DB 상태 기반 종료 진행");
|
||||
} else {
|
||||
// 타이머 정리 (추적 중인 경우에만)
|
||||
clearInterval(this.trackingIntervalId);
|
||||
this.trackingIntervalId = null;
|
||||
}
|
||||
|
||||
// 타이머 정리
|
||||
clearInterval(this.trackingIntervalId);
|
||||
this.trackingIntervalId = null;
|
||||
|
||||
const tripId = this.currentTripId;
|
||||
|
||||
// 마지막 위치 저장 (trip_status를 completed로)
|
||||
const departure =
|
||||
this.trackingContext?.formData?.[this.trackingConfig?.trackingDepartureField || "departure"] || null;
|
||||
const arrival = this.trackingContext?.formData?.[this.trackingConfig?.trackingArrivalField || "arrival"] || null;
|
||||
const departureName = this.trackingContext?.formData?.["departure_name"] || null;
|
||||
const destinationName = this.trackingContext?.formData?.["destination_name"] || null;
|
||||
const vehicleId =
|
||||
this.trackingContext?.formData?.[this.trackingConfig?.trackingVehicleIdField || "vehicle_id"] || null;
|
||||
// 마지막 위치 저장 (추적 중이었던 경우에만)
|
||||
if (isTrackingActive) {
|
||||
const departure =
|
||||
this.trackingContext?.formData?.[this.trackingConfig?.trackingDepartureField || "departure"] || null;
|
||||
const arrival = this.trackingContext?.formData?.[this.trackingConfig?.trackingArrivalField || "arrival"] || null;
|
||||
const departureName = this.trackingContext?.formData?.["departure_name"] || null;
|
||||
const destinationName = this.trackingContext?.formData?.["destination_name"] || null;
|
||||
const vehicleId =
|
||||
this.trackingContext?.formData?.[this.trackingConfig?.trackingVehicleIdField || "vehicle_id"] || null;
|
||||
|
||||
await this.saveLocationToHistory(
|
||||
tripId,
|
||||
departure,
|
||||
arrival,
|
||||
departureName,
|
||||
destinationName,
|
||||
vehicleId,
|
||||
"completed",
|
||||
);
|
||||
await this.saveLocationToHistory(
|
||||
tripId,
|
||||
departure,
|
||||
arrival,
|
||||
departureName,
|
||||
destinationName,
|
||||
vehicleId,
|
||||
"completed",
|
||||
);
|
||||
}
|
||||
|
||||
// 🆕 거리/시간 계산 및 저장
|
||||
if (tripId) {
|
||||
// 🆕 거리/시간 계산 및 저장 (추적 중이었던 경우에만)
|
||||
if (isTrackingActive && tripId) {
|
||||
try {
|
||||
const tripStats = await this.calculateTripStats(tripId);
|
||||
console.log("📊 운행 통계:", tripStats);
|
||||
|
|
@ -4260,9 +4264,9 @@ export class ButtonActionExecutor {
|
|||
}
|
||||
}
|
||||
|
||||
// 상태 변경 (vehicles 테이블 등)
|
||||
const effectiveConfig = config.trackingStatusOnStop ? config : this.trackingConfig;
|
||||
const effectiveContext = context.userId ? context : this.trackingContext;
|
||||
// 상태 변경 (vehicles 테이블 등) - 새로고침 후에도 동작하도록 config 우선 사용
|
||||
const effectiveConfig = config.trackingStatusOnStop ? config : this.trackingConfig || config;
|
||||
const effectiveContext = context.userId ? context : this.trackingContext || context;
|
||||
|
||||
if (effectiveConfig?.trackingStatusOnStop && effectiveConfig?.trackingStatusField && effectiveContext) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue