1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 'use strict';
- const Service = require('egg').Service;
- class DictService extends Service {
- async place() {
- const { ctx } = this;
- const agg = [
- { $lookup: { from: 't_sync_city', localField: 'province_id', foreignField: 'province_id', as: 'cities' } },
- ];
- return await ctx.model.TSyncProvinceModel.aggregateFix(agg);
- }
- async msgType() {
- const { ctx } = this;
- return await ctx.model.MsgTypeModel.find({ parent_id: 0 });
- }
- // 车系
- async car() {
- const { ctx } = this;
- const agg = [
- { $sort: { _id: -1 } },
- { $limit: 1 },
- { $unwind: '$car' },
- { $match: { 'car._id.series_code': { $ne: null } } },
- { $group: {
- _id: '$car._id.series_code',
- name: { $first: '$car.series_name' }, code: { $first: '$car._id.series_code' },
- children: { $addToSet: { name: '$car.model_name', code: '$car._id.model_code' } },
- },
- },
- ];
- return await ctx.model.Local.TVehicleRecordModel.aggregateFix(agg);
- }
- // 远控失败类型
- async rcFailType() {
- const { ctx } = this;
- const agg = [
- { $unwind: '$remoteControlFailure' },
- { $match: { 'remoteControlFailure._id': { $ne: null } } },
- { $group: { _id: '$remoteControlFailure._id' } },
- { $project: { _id: 0, name: '$_id' } },
- ];
- return await ctx.model.Local.AppBehaviorRecordModel.aggregateFix(agg);
- }
- // 自动化测试流程id
- async autoTest() {
- const { ctx } = this;
- const agg = [
- { $unwind: '$autoTest' },
- { $match: { 'autoTest._id': { $ne: null } } },
- { $group: { _id: '$autoTest._id' } },
- { $project: { _id: 0, name: '$_id' } },
- ];
- return await ctx.model.Local.TBoxAutoTestingStatsModel.aggregateFix(agg);
- }
- }
- module.exports = DictService;
|