wangzhibo
2026-07-28 920cec41cedfde27f89d7c19b78e03147b926ab5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Inject } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { PushVehicleGpsEntity } from '../../entity/vehiclegps';
import { PushVehicleGpsService } from '../../service/vehiclegps';
import { BaseSysDepartmentEntity } from '../../../base/entity/sys/department'
import { WithDeptFilterWhere } from '../../../base/middleware/with-dept-filter-where'
 
/**
 * 车载监控GPS位置数据
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: PushVehicleGpsEntity,
  service: PushVehicleGpsService,
  pageQueryOp: {
    keyWordLikeFields: ['a.sn', 'a.vehicleNo'],
    fieldEq: ['a.status'],
    select: ['a.*', 'b.name AS departmentName'],
    join: [
      {
        entity: BaseSysDepartmentEntity,
        alias: 'b',
        condition: 'a.departmentId = b.id',
        type: 'leftJoin',
      },
    ],
    where: async (ctx) => {
      const { createDate, gpsTime } = ctx.request.body;
      const conditions: any[][] = [];
      if (createDate && createDate.length === 2) {
        conditions.push(['a.createDate BETWEEN :createStartDate AND :createEndDate', { createStartDate: createDate[0], createEndDate: createDate[1] }]);
      }
      if (gpsTime && gpsTime.length === 2) {
        conditions.push(['a.gpsTime BETWEEN :gpsStartDate AND :gpsEndDate', { gpsStartDate: gpsTime[0], gpsEndDate: gpsTime[1] }]);
      }
 
      conditions.push(...(await WithDeptFilterWhere(ctx, { alias: 'a', field: 'departmentId' })));
 
      return conditions;
    }
  }
})
export class AdminPushVehicleGpsController extends BaseController {
  @Inject()
  pushVehicleGpsService: PushVehicleGpsService;
}