123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- 'use strict';
- const Controller = require('egg').Controller;
- // 用户出行信息行为统计分析模块
- class UserDrivingController2 extends Controller {
- constructor(ctx) {
- super(ctx);
- // 特殊的入参校验可以重写在这,默认可以使用commonRule
- this.createRule = {
- startTime: { type: 'number', min: 0 }, // 开始时间的时间戳 包含
- endTime: { type: 'number', min: 0 }, // 结束时间的时间戳 不包含(客户端处理结束时间 下一日 ,下一月第一日 ,下一年第一日)
- };
- }
- // 驾驶行为 基础
- async index() {
- const { ctx, service } = this;
- // 校验参数 组装参数
- const payload = ctx.validate();
- // // 调用 Service 进行业务处理
- const data = await service.drivingBehaviorInfoService2.index(payload, this.ctx.params.id);
- // // 设置响应内容和响应状态码
- ctx.success({ data });
- }
- // 驾驶行为 月年
- async mixMY() {
- const { ctx, service } = this;
- // 校验参数 组装参数
- const payload = ctx.validate();
- // // 调用 Service 进行业务处理
- let key = this.ctx.params.id;
- switch (payload.type) {
- case '1':
- key += 'Month';
- break;
- case '2':
- key += 'Year';
- break;
- default:
- break;
- }
- const data = await service.drivingBehaviorInfoService2.mixMY(payload, key);
- // // 设置响应内容和响应状态码
- ctx.success({ data });
- }
- // 驾驶行为 出行时间+疲劳驾驶
- async mileageStartTimeAndDsm() {
- const { ctx, service } = this;
- // 校验参数 组装参数
- const payload = ctx.validate();
- // // 调用 Service 进行业务处理
- const data = await service.drivingBehaviorInfoService2.mileageStartTimeAndDsm(payload);
- // // 设置响应内容和响应状态码
- ctx.success({ data });
- }
- // 驾驶行为 分组 时间区分 工作日 周末
- async date() {
- const { ctx, service } = this;
- // 校验参数 组装参数
- const payload = ctx.validate();
- // // 调用 Service 进行业务处理
- const data = await service.drivingBehaviorInfoService2.date(payload, this.ctx.params.id);
- // // 设置响应内容和响应状态码
- ctx.success({ data });
- }
- // 驾驶行为 日累加
- async count2() {
- const { ctx, service } = this;
- // 校验参数 组装参数
- const payload = ctx.validate();
- // // 调用 Service 进行业务处理
- const data = await service.drivingBehaviorInfoService2.count2(payload, this.ctx.params.id);
- // // 设置响应内容和响应状态码
- ctx.success({ data });
- }
- // 驾驶行为 一段时间总和
- async sum() {
- const { ctx, service } = this;
- // 校验参数 组装参数
- const payload = ctx.validate(this.createRule);
- // 调用 Service 进行业务处理
- const data = await service.drivingBehaviorInfoService2.sum(payload, this.ctx.params.id);
- // // // 设置响应内容和响应状态码
- ctx.success({ data });
- }
- // 驾驶行为 额外
- async ext() {
- const { ctx, service } = this;
- // 调用 Service 进行业务处理
- const data = await service.drivingBehaviorInfoService2.ext();
- // // // 设置响应内容和响应状态码
- ctx.success({ data });
- }
- }
- module.exports = UserDrivingController2;
|