import { Body, Inject, Post } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { MapsLiveService } from '../../service/live';

/**
 * 地图实时位置与轨迹
 */
@CoolController()
export class AdminMapsLiveController extends BaseController {
  @Inject()
  mapsLiveService: MapsLiveService;

  @Post('/sites', { summary: '站点地图点位' })
  async sites() {
    return this.ok(await this.mapsLiveService.sites());
  }

  @Post('/siteWeight', { summary: '站点称重历史' })
  async siteWeight(
    @Body('businessId') businessId: string,
    @Body('startTime') startTime: string,
    @Body('endTime') endTime: string
  ) {
    return this.ok(await this.mapsLiveService.siteWeight(businessId, startTime, endTime));
  }

  @Post('/sorterOnline', { summary: '在线分拣员位置' })
  async sorterOnline() {
    return this.ok(await this.mapsLiveService.sorterOnline());
  }

  @Post('/sorterTrack', { summary: '分拣员历史轨迹' })
  async sorterTrack(
    @Body('idCard') idCard: string,
    @Body('startTime') startTime: string,
    @Body('endTime') endTime: string
  ) {
    return this.ok(await this.mapsLiveService.sorterTrack(idCard, startTime, endTime));
  }

  @Post('/sorterHealth', { summary: '分拣员健康与告警' })
  async sorterHealth(@Body('idCard') idCard: string) {
    return this.ok(await this.mapsLiveService.sorterHealth(idCard));
  }

  @Post('/vehicleOnline', { summary: '在线车辆位置' })
  async vehicleOnline() {
    return this.ok(await this.mapsLiveService.vehicleOnline());
  }

  @Post('/vehicleTrack', { summary: '车辆历史轨迹' })
  async vehicleTrack(
    @Body('vehicleNo') vehicleNo: string,
    @Body('startTime') startTime: string,
    @Body('endTime') endTime: string
  ) {
    return this.ok(await this.mapsLiveService.vehicleTrack(vehicleNo, startTime, endTime));
  }

  @Post('/vehicleEvents', { summary: '车辆司机行为消息' })
  async vehicleEvents(@Body('vehicleNo') vehicleNo: string) {
    return this.ok(await this.mapsLiveService.vehicleEvents(vehicleNo));
  }
}
