wangzhibo
2026-07-18 708f980f0f351bfe47d7936151bf52ed4d4a7bc4
src/modules/push/controller/admin/vehiclegps.ts
@@ -2,6 +2,8 @@
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位置数据
@@ -13,16 +15,28 @@
  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 condition = [];
      const conditions: any[][] = [];
      if (createDate && createDate.length === 2) {
        condition.push(['a.createDate BETWEEN :createStartDate AND :createEndDate', { createStartDate: createDate[0], createEndDate: createDate[1] }]);
        conditions.push(['a.createDate BETWEEN :createStartDate AND :createEndDate', { createStartDate: createDate[0], createEndDate: createDate[1] }]);
      }
      if (gpsTime && gpsTime.length === 2) {
        condition.push(['a.gpsTime BETWEEN :gpsStartDate AND :gpsEndDate', { gpsStartDate: gpsTime[0], gpsEndDate: gpsTime[1] }]);
        conditions.push(['a.gpsTime BETWEEN :gpsStartDate AND :gpsEndDate', { gpsStartDate: gpsTime[0], gpsEndDate: gpsTime[1] }]);
      }
      return condition;
      conditions.push(...(await WithDeptFilterWhere(ctx, { alias: 'a', field: 'departmentId' })));
      return conditions;
    }
  }
})