From e02a102f1782ce782393b9e006109e4c66853b0a Mon Sep 17 00:00:00 2001 From: fro1991 Date: Thu, 2 Oct 2025 14:23:42 +0700 Subject: [PATCH] update --- src/entity/gps_device_log.ts | 90 ++++++++++++++++++++++++++++++++++++ src/schema/gps.ts | 2 + src/types/gps.ts | 26 +++++++++++ 3 files changed, 118 insertions(+) create mode 100644 src/entity/gps_device_log.ts create mode 100644 src/types/gps.ts diff --git a/src/entity/gps_device_log.ts b/src/entity/gps_device_log.ts new file mode 100644 index 0000000..eb62389 --- /dev/null +++ b/src/entity/gps_device_log.ts @@ -0,0 +1,90 @@ +import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, JoinTable, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; +import { GpsDevice } from "./gps_devices"; +import { GpsActionType, GpsEngineStatus, GpsIgnitionStatus, GpsReverseGeoStatus } from "../types/gps"; + +@Entity("gps_device_logs", { schema: "gps" }) +export class GpsDeviceLog { + @PrimaryGeneratedColumn("uuid") + id: string; + + @ManyToOne(() => GpsDevice, { nullable: true }) + @JoinColumn({ name: "deviceId" }) + device: GpsDevice; + + @Column({ + nullable: false, + type: "text", + }) + socket: string; + + @Column({ + nullable: false, + type: "text", + }) + hex: string; + + @Column({ + nullable: false, + }) + action: GpsActionType; + + @Column({ + nullable: true, + type: "double precision", + }) + latitude: number; + + @Column({ + nullable: true, + type: "double precision", + }) + longitude: number; + + @Column({ + nullable: true, + type: "float", + }) + speed: string; + + @Column({ + nullable: true, + }) + ignition_status: GpsIgnitionStatus; + + @Column({ + nullable: true, + }) + engine_status: GpsEngineStatus; + + @Column({ + nullable: true, + }) + reverse_geo_status: GpsReverseGeoStatus; + + @Column({ + nullable: true, + type: "jsonb", + }) + reverse_geo: string; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ type: "varchar", length: 255 }) + created_by: string; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ type: "varchar", length: 255, nullable: true }) + updated_by: string; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + + @Column({ type: "varchar", length: 255, nullable: true }) + deleted_by: string; +} diff --git a/src/schema/gps.ts b/src/schema/gps.ts index 7fc7429..930b116 100644 --- a/src/schema/gps.ts +++ b/src/schema/gps.ts @@ -1 +1,3 @@ +export * from "../types/gps"; export * from "../entity/gps_devices"; +export * from "../entity/gps_device_log"; diff --git a/src/types/gps.ts b/src/types/gps.ts new file mode 100644 index 0000000..ceb6b95 --- /dev/null +++ b/src/types/gps.ts @@ -0,0 +1,26 @@ +export enum GpsActionType { + "login" = "login", + "hearthbeat" = "hearthbeat", + "location" = "location", + "other" = "other", +} + +export enum GpsIgnitionStatus { + "on" = "on", + "off" = "off", + "acc_low" = "acc_low", + "ac_high" = "ac_high", +} + +export enum GpsEngineStatus { + "idling" = "idling", + "moving" = "moving", + "stopping" = "stopping", +} + +export enum GpsReverseGeoStatus { + "pending" = "pending", + "process" = "process", + "success" = "success", + "fail" = "fail", +}