'use strict'; const dateRange = require('../util/dateRange'); const utils = require('../util/utils'); module.exports = { kv: { mileageCnt: { 0: '0-30', 30: '30-60', 60: '60-90', 90: '90-120', 120: '120以上(次)', }, mileageCntMonth: { 0: '0-30', 30: '30-60', 60: '60-90', 90: '90-120', 120: '120以上(次)', }, mileageCntYear: { 0: '0-300', 300: '300-600', 600: '600-900', 900: '900-1200', 1200: '1200以上(次)', }, mileage: { 0: '0-50', 50: '50-100', 100: '100-300', 300: '300-500', 500: '500-1000', 1000: '1000-1500', 1500: '1500-20000', 20000: '20000以上', }, mileageMonth: { 0: '0-500', 500: '500-1000', 1000: '1000-1500', 1500: '1500-2000', 2000: '2000-3000', 3000: '3000-4000', 4000: '4000-5000', 5000: '5000以上', }, mileageYear: { 0: '0-0.5万', 5000: '0.5-1万', 10000: '1万-1.5万', 15000: '1.5-2万', 20000: '2万-3万', 30000: '3万-4万', 40000: '4万-5万', 50000: '5万以上', }, supplementaryCnt: { 0: '无补传', 1: '1-20次', 20: '20-30次', 30: '30-40次', 40: '40-50次', 50: '50次以上', }, batterySoc: { 0: '60%以下', 60: '60%-70%', 70: '70%-80%', 80: '80%-90%', 90: '90%-100%', }, engineSpeed: { 0: '2000rpm以下', 2000: '2000-3000rpm', 3000: '3000-4000rpm', 4000: '4000-5000rpm', 5000: '5000rpm以上', }, insideTemperature: { '-1000': '30°C以下', 30: '30-35°C', 35: '35-40°C', 40: '40-45°C', 45: '45-50°C', }, outsideTemperature: { '-1000': '0°C以下', 0: '0-10°C', 10: '10-20°C', 20: '20-30°C', 30: '30°C以上', }, powerBatterySoc: { 0: '60%以下', 60: '60%-70%', 70: '70%-80%', 80: '80%-90%', 90: '90%-100%', }, chargeDuration: { 0: '1h以下', 1: '1h-2h', 2: '2h-3h', 3: '3h-4h', 4: '4h以上', }, chargeStartSoc: { 0: '0-10', 10: '10-20', 20: '20-30', 30: '30-40', 40: '40-50', 50: '50-60', 60: '60-70', 70: '70-80', 80: '80-90', 90: '90-100', }, chargeEndSoc: { 0: '0-10', 10: '10-20', 20: '20-30', 30: '30-40', 40: '40-50', 50: '50-60', 60: '60-70', 70: '70-80', 80: '80-90', 90: '90-100', }, chargePreStartMileage: { 0: '0-50', 50: '50-100', 100: '100-150', 150: '150-200', 200: '200-250', 250: '250-300', 300: '300-350', 350: '350-400', }, chargeStartTime: { 0: '0:00-1:00', 1: '1:00-2:00', 2: '2:00-3:00', 3: '3:00-4:00', 4: '4:00-5:00', 5: '5:00-6:00', 6: '6:00-7:00', 7: '7:00-8:00', 8: '8:00-9:00', 9: '9:00-10:00', 10: '10:00-11:00', 11: '11:00-12:00', 12: '12:00-13:00', 13: '13:00-14:00', 14: '14:00-15:00', 15: '15:00-16:00', 16: '16:00-17:00', 17: '17:00-18:00', 18: '18:00-19:00', 19: '19:00-20:00', 20: '20:00-21:00', 21: '21:00-22:00', 22: '22:00-23:00', 23: '23:00-0:00', }, chargeMileage: { 0: '0-50km', 50: '50-100km', 100: '100-150km', 150: '150-200km', 200: '200-250km', 250: '250-300km', 300: '300km以上', }, avgSpeedPower: { 0: '0-10', 10: '10-20', 20: '20-30', 30: '30-40', 40: '40-50', 50: '50-60', 60: '60-70', 70: '70-80', 80: '80-90', 90: '90-100', 100: '100-110', 110: '110-120', 120: '120以上', }, actualMileage: { 0: '100以下', 100: '100-120', 120: '120-140', 140: '140-160', 160: '160-180', 180: '180-200', 200: '200-220', 220: '220-240', 240: '240-260', 260: '260-280', 280: '280-300', 300: '300以上', }, chargeCnt: { 0: '50次以下', 50: '50-100次', 100: '100-150次', 150: '150-200次', 200: '200次以上', }, chargeCntMonth: { 0: '0-5次', 5: '5-10次', 10: '10-15次', 15: '15-20次', 20: '20次以上', }, chargeCntYear: { 0: '50次以下', 50: '50-100次', 100: '100-150次', 150: '150-200次', 200: '200次以上', }, skyDuration: { 0: '0-30min', 30: '30-60min', 60: '60-120min', 120: '120-180min', 180: '180min以上', }, skyDurationMonth:{ 0: '0-0.5h', 0.5: '0.5-1h', 1: '1-2h', 2: '2-3h', 3: '3h以上', }, skyDurationYear:{ 0: '0-5h', 5: '5-10h', 10: '10-20h', 20: '20-30h', 30: '30h以上', }, headlightCnt: { 0: '0-30次', 30: '30-60次', 60: '60-90次', 90: '90-120次', 120: '120-150次', 150: '150-180次', 180: '180-210次', 210: '210-240次', 240: '240-270次', 270: '270-300次', 300: '300次以上', }, headlightCntMonth: { 0: '0-30次', 30: '30-60次', 60: '60-90次', 90: '90-120次', 120: '120-150次', 150: '150-180次', 180: '180-210次', 210: '210-240次', 240: '240-270次', 270: '270-300次', 300: '300次以上', }, headlightCntYear: { 0: '0-300次', 300: '300-600次', 600: '600-900次', 900: '900-1200次', 1200: '1200-1500次', 1500: '1500-1800次', 1800: '1800-2100次', 2100: '2100-2400次', 2400: '2400-2700次', 2700: '2700-3000次', 3000: '3000次以上', }, headlightDuration: { 0: '0-0.5min', 0.5: '0.5-1min', 1: '1-3min', 3: '3-5min', 5: '5-8min', 8: '8-10min', 10: '10-15min', 15: '15-20min', 20: '20-25min', 25: '25-30min', 30: '30-40min', 40: '40-50min', 50: '50min以上', }, headlightDurationMonth:{ 0: '0-0.5h', 0.5: '0.5-1h', 1: '1-1.5h', 1.5: '1.5-2h', 2: '2-2.5h', 2.5: '2.5-3h', 3: '3-3.5h', 3.5: '3.5-4h', 4: '4-4.5h', 4.5: '4.5-5h', 5: '5-5.5h', 5.5: '5.5-6h', 6: '6h以上', }, headlightDurationYear:{ 0: '0-5h', 5: '5-10h', 10: '10-15h', 15: '15-20h', 20: '20-25h', 25: '25-30h', 30: '30-35h', 35: '35-40h', 40: '40-45h', 45: '45-50h', 50: '50-55h', 55: '55-60h', 60: '60h以上', }, highBeamCnt: { 0: '0-30次', 30: '30-60次', 60: '60-90次', 90: '90-120次', 120: '120-150次', 150: '150-180次', 180: '180-210次', 210: '210-240次', 240: '240-270次', 270: '270-300次', 300: '300次以上', }, highBeamCntMonth:{ 0: '0-10次', 10: '10-20次', 20: '20-30次', 30: '30-40次', 40: '40-50次', 50: '50-60次', 60: '60-70次', 70: '70-80次', 80: '80-90次', 90: '90-100次', 100: '100次以上', }, highBeamCntYear:{ 0: '0-100次', 100: '100-200次', 200: '200-300次', 300: '300-400次', 400: '400-500次', 500: '500-600次', 600: '600-700次', 700: '700-800次', 800: '800-900次', 900: '900-1000次', 1000: '1000次以上', }, highBeamDuration: { 0: '0-0.5min', 0.5: '0.5-1min', 1: '1-3min', 3: '3-5min', 5: '5-8min', 8: '8-10min', 10: '10-15min', 15: '15-20min', 20: '20-25min', 25: '25-30min', 30: '30-40min', 40: '40-50min', 50: '50min以上', }, highBeamDurationMonth:{ 0: '0-0.5h', 0.5: '0.5-1h', 1: '1-1.5h', 1.5: '1.5-2h', 2: '2-2.5h', 2.5: '2.5-3h', 3: '3-3.5h', 3.5: '3.5-4h', 4: '4-4.5h', 4.5: '4.5-5h', 5: '5-5.5h', 5.5: '5.5-6h', 6: '6h以上', }, highBeamDurationYear:{ 0: '0-5h', 5: '5-10h', 10: '10-15h', 15: '15-20h', 20: '20-25h', 25: '25-30h', 30: '30-35h', 35: '35-40h', 40: '40-45h', 45: '45-50h', 50: '50-55h', 55: '55-60h', 60: '60h以上', }, mileageSingle: { 0: '0-10', 10: '10-20', 20: '20-30', 30: '30-40', 40: '40-50', }, statsAcceCnt: { 1: '0-10%', 2: '10-20%', 3: '20-30%', 4: '30-40%', 5: '40-50%', 6: '50-60%', 7: '60-70%', 8: '70-80%', 9: '80-90%', 10: '90-100%', }, statsSpRange: { 1: '0-10km/h', 2: '10-20km/h', 3: '20-30km/h', 4: '30-40km/h', 5: '40-50km/h', 6: '50-60km/h', 7: '60-70km/h', 8: '70-80km/h', 9: '80-90km/h', 10: '90-100km/h', 11: '100-110km/h', 12: '110-120km/h', 13: '120km/h以上', }, spPowerConsumption: { 1: '0-10km/h', 2: '10-20km/h', 3: '20-30km/h', 4: '30-40km/h', 5: '40-50km/h', 6: '50-60km/h', 7: '60-70km/h', 8: '70-80km/h', 9: '80-90km/h', 10: '90-100km/h', 11: '100-110km/h', 12: '110-120km/h', 13: '120km/h以上', }, statsDece: { 1: '0-0.04g', 2: '0.04-0.08g', 3: '0.08-0.12g', 4: '0.12-0.16g', 5: '0.16-0.2g', 6: '0.2-0.24g', 7: '0.24-0.28g', 8: '0.28-0.32g', 9: '0.32-0.36g', 10: '0.36-0.4g', }, statsRotate: { 1: '3-10deg', 2: '10-50deg', 3: '50-100deg', 4: '100-200deg', 5: '200-300deg', 6: '300-400deg', 7: '400-500deg', 8: '500-550deg', }, dece: { 0: '0-0.04', 1: '0.04-0.08', 2: '0.08-0.12', 3: '0.12-0.16', 4: '0.16-0.20', 5: '0.2-0.24', 6: '0.24-0.28', 7: '0.28-0.32', 8: '0.32-0.36', 9: '0.36-0.4', }, statsSpRotate: { 1: '3-10deg', 2: '10-50deg', 3: '50-100deg', 4: '100-200deg', 5: '200-300deg', 6: '300-400deg', 7: '400-500deg', 8: '500-550deg', }, maxAcce: { 0: '0-0.05g', 0.05: '0.05-0.1g', 0.1: '0.1-0.15g', 0.15: '0.15-0.2g', 0.2: '0.2-0.25g', 0.25: '0.25-0.3g', 0.3: '0.3-0.35g', 0.35: '0.35-0.4g', 0.4: '0.4-0.45g', 0.45: '0.45-0.5g', }, yawPortraitAcces: { 1: '0-0.05g', 2: '0.05-0.1g', 3: '0.1-0.15g', 4: '0.15-0.2g', 5: '0.2-0.25g', 6: '0.25-0.3g', 7: '0.3-0.35g', 8: '0.35-0.4g', 9: '0.4-0.45g', 10: '0.45-0.5g', }, sidePortraitAcces: { 1: '0-0.05g', 2: '0.05-0.1g', 3: '0.1-0.15g', 4: '0.15-0.2g', 5: '0.2-0.25g', 6: '0.25-0.3g', 7: '0.3-0.35g', 8: '0.35-0.4g', 9: '0.4-0.45g', 10: '0.45-0.5g', }, maxDece: { 0: '0-0.05g', 0.05: '0.05-0.1g', 0.1: '0.1-0.15g', 0.15: '0.15-0.2g', 0.2: '0.2-0.25g', 0.25: '0.25-0.3g', 0.3: '0.3-0.35g', 0.35: '0.35-0.4g', 0.4: '0.4-0.45g', 0.45: '0.45-0.5g', 0.5: '0.5-0.55g', 0.55: '0.55-0.6g', 0.6: '0.6-0.65g', 0.65: '0.65-0.7g', 0.7: '0.7-0.75g', 0.75: '0.75-0.8g', }, statsDeceOther: { 1: '0-0.05g', 2: '0.05-0.1g', 3: '0.1-0.15g', 4: '0.15-0.2g', 5: '0.2-0.25g', 6: '0.25-0.3g', 7: '0.3-0.35g', 8: '0.35-0.4g', 9: '0.4-0.45g', 10: '0.45-0.5g', 11: '0.5-0.55g', 12: '0.55-0.6g', 13: '0.6-0.65g', 14: '0.65-0.7g', 15: '0.7-0.75g', 16: '0.75-0.8g', }, sideAcce: { 0: '0-0.05g', 0.05: '0.05-0.1g', 0.1: '0.1-0.15g', 0.15: '0.15-0.2g', 0.2: '0.2-0.25g', 0.25: '0.25-0.3g', 0.3: '0.3-0.35g', 0.35: '0.35-0.4g', 0.4: '0.4-0.45g', 0.45: '0.45-0.5g', }, statsHighSp: { 1: '80-100km/h', 2: '100-120km/h', 3: '120km/h以上', }, statsStartSp: { 1: '0-5km/h', 2: '5-10km/h', 3: '10-15km/h', 4: '15-20km/h', 5: '20-25km/h', 6: '25-30km/h', 7: '30-35km/h', 8: '35-40km/h', 9: '40-45km/h', 10: '45-50km/h', 11: '50-55km/h', 12: '55-60km/h', 13: '60-65km/h', 14: '65-70km/h', }, }, kv2: { mileageCnt2: { 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7以上', }, avgSpeed: { 0: '0-20', 20: '20-30min', 30: '30-40min', 40: '40-50min', 50: '50以上', }, mileage: { 0: '0-50', 50: '50-100', 100: '100-300', 300: '300-500', 500: '500-1000', 1000: '1000-1500', 1500: '1500-20000', 20000: '20000以上', }, mileage2: { 0: '0-5', 5: '5-10', 10: '10-20', 20: '20-30', 30: '30-50', 50: '50-100', 100: '100-200', 200: '200以上', }, driveDuration: { 0: '0-1', 1: '1-2', 2: '2-3', 3: '3-4', 4: '4以上', }, }, getOnlineCount() { return { count: utils.randomNumC(), offlineCount: utils.randomNumC(), saledCount: utils.randomNumC(), }; }, get3D(x, y) { const arry = []; for (let i = 0; i < x; i++) { for (let j = 0; j < y; j++) { arry.push([ i, j, utils.randomNumC() ]); } } return arry; }, getBehavior(str) { return [ { _id: 5001, behavior_name: '系统行为' }, { _id: 6001, behavior_name: '登录注册' }, { _id: 6002, behavior_name: '扫一扫' }, { _id: 6004, behavior_name: '行车记录仪' }, { _id: 6007, behavior_name: '电子围栏' }, { _id: 6008, behavior_name: '出行' }, { _id: 6010, behavior_name: '车况查询' }, { _id: 6011, behavior_name: '快递到车' }, { _id: 6012, behavior_name: '驾驶行为分析' }, { _id: 6013, behavior_name: '车辆服务' }, { _id: 6014, behavior_name: '消息中心' }, { _id: 6015, behavior_name: '应用信息' }, { _id: 6017, behavior_name: '个人信息' }, { _id: 6018, behavior_name: '设置' }, { _id: 6019, behavior_name: '我的爱车' }, { _id: 6020, behavior_name: '出车泊车' }, { _id: 6022, behavior_name: '后台运行' }, ].map(item => { const obj = { _id: item._id }; obj[str] = utils.randomNumC(); return obj; }); }, getAppExt() { return { countMonth: utils.randomNumC(), countPreMonth: utils.randomNumC(), durationMonth: utils.randomNumC(), durationPreMonth: utils.randomNumC(), }; }, getAuto() { const array = []; for (let i = 0; i < 18; i++) { const num = utils.randomNumC(); const num2 = num + utils.randomNumC(); array.push({ _id: i, count: num2, name: '远程配置' + i, failCount: num, }); } return array; }, getBehaviorExt() { return { fwMaxMonth: { _id: { month: 12, year: 2019, }, count: utils.randomNumC(), }, fwMaxYear: { _id: { month: 12, year: 2019, }, count: utils.randomNumC(), }, fwMinMonth: { _id: { month: 12, year: 2019, }, count: utils.randomNumC(), }, fwMinYear: { _id: { month: 12, year: 2019, }, count: utils.randomNumC(), }, musicMaxMonth: { _id: { month: 12, year: 2019, }, count: utils.randomNumC(), }, musicMaxYear: { _id: { month: 12, year: 2019, }, count: utils.randomNumC(), }, musicMinMonth: { _id: { month: 12, year: 2019, }, count: utils.randomNumC(), }, musicMinYear: { _id: { month: 12, year: 2019, }, count: utils.randomNumC(), }, videoMaxMonth: { _id: { month: 12, year: 2019, }, count: utils.randomNumC(), }, videoMaxYear: { _id: { month: 12, year: 2019, }, count: utils.randomNumC(), }, videoMinMonth: { _id: { month: 12, year: 2019, }, count: utils.randomNumC(), }, videoMinYear: { _id: { month: 12, year: 2019, }, count: utils.randomNumC(), }, }; }, getUserInfo() { const array = []; for (let i = 0; i < 10; i++) { array.push({ user_id: '396931284284211200', gender: 'M', id_card: '220104198602181856', user_mobileno: '13478799455', user_name: '测试人员', user_real_name: 'wyy', }); } return { list: array, total: 20, }; }, getMapP(count = 100) { const points = []; for (let i = 0; i < count; i++) { const latitude = utils.randomNum(21, 53); const longitude = utils.randomNum(73, 135); points[i] = { _id: 'VIN' + latitude, latitude, longitude, ag: 0, sp: 10, tm: i == 0 ? 1598341206 : 30, }; } return points; }, getSaledCity() { const array = []; const areas = utils.getAreas(); for (let i = 0; i < 3; i++) { const a = areas[utils.randomNumC() % 5]; let p = a.provinces[utils.randomNumC() % 5]; if (!p) { p = a.provinces[0]; } let c = p.cities[utils.randomNumC() % 5]; if (!c) { c = p.cities[0]; } array.push( { city_name: c.city_name, count: utils.randomNumC(), provice_name: p.provice_name, } ); } return array; }, getSaled() { const areas = utils.getAreas(); areas.forEach(item => { item.count = utils.randomNumC(); item.provinces.forEach(p => { p.count = utils.randomNumC(); p.cities.forEach(c => { c.count = utils.randomNumC(); }); }); }); return { areas, count: utils.randomNumC() }; }, getActiveExt() { return { maxMonth: { _id: { month: 12, year: 2019, }, activeCount: utils.randomNumC(), }, maxYear: { _id: { year: 2019, }, activeCount: utils.randomNumC(), }, }; }, getAir() { return { airDuration: utils.randomNumT(), blowerRatingFourDuration: utils.randomNumT(6), blowerRatingOneDuration: utils.randomNumT(6), blowerRatingOtherDuration: utils.randomNumT(6), blowerRatingThreeDuration: utils.randomNumT(6), blowerRatingTwoDuration: utils.randomNumT(6), offAutoDuration: utils.randomNumT(2), offCompressorDuration: utils.randomNumT(2), onAutoDuration: utils.randomNumT(2), onCompressorDuration: utils.randomNumT(2), }; }, getLevel(payload) { let data; switch (payload.level) { case 'province': data = utils.getPC().province.map(item => { return { name: item.name, count: utils.randomNumC() }; }).sort((a, b) => b.count - a.count).slice(0, 10); break; case 'city': data = utils.getPC().city.map(item => { return { name: item.name, count: utils.randomNumC() }; }).sort((a, b) => b.count - a.count).slice(0, 10); break; default: break; } return data; }, getData(payload, config) { return dateRange.rangeTest(payload.startTime, payload.endTime, payload.type, config); }, getDataAdd(payload, config) { return dateRange.rangeTestAdd(payload.startTime, payload.endTime, payload.type, config); }, getSum(kv) { return Object.keys(kv).map(item => { return { _id: item, count: utils.randomNumC() }; }); }, getSaledExt() { return { maxDay: { _id: { day: 12, month: 6, year: 2019, }, count: utils.randomNumC(), }, maxMonth: { _id: { month: 7, year: 2019, }, count: utils.randomNumC(), }, saledAppTotal: utils.randomNumC(), saledIviTotal: utils.randomNumC(), saledTotal: utils.randomNumC(), appTotal: utils.randomNumC(), iviTotal: utils.randomNumC(), }; }, getOnlineExt() { return { appYear: utils.randomNumC(), maxApp: { _id: { day: 18, month: 12, year: 2019, }, count: utils.randomNumC(), }, maxMonthTBox: { _id: { month: 12, year: 2019, }, count: utils.randomNumC(), }, maxTBox: { _id: { day: 19, month: 12, year: 2019, }, count: utils.randomNumC(), }, minApp: { _id: { day: 30, month: 3, year: 2019, }, count: utils.randomNumC(), }, minTBox: { _id: { day: 30, month: 3, year: 2019, }, count: utils.randomNumC(), }, tBoxYear: utils.randomNumC(), }; }, getSex2Age() { const list = Object.keys({ 18: '18-25岁', 25: '25-30岁', 30: '30-35岁', 35: '35-40岁', 40: '40岁以上(年龄)', }).map(item => { return { _id: item, mCount: utils.randomNumC(), fCount: utils.randomNumC(), count: utils.randomNumC() }; }); return {list,time:'2020-09-01'} }, getArea() { const areas = utils.getAreas(); areas.forEach(item => { item.count = utils.randomNumC(); item.provinces.forEach(p => { p.count = utils.randomNumC(); p.cities.forEach(c => { c.count = utils.randomNumC(); }); }); }); return {list:areas,time:'2020-09-01'}; }, getMix(payload, key) { return dateRange.rangeTest2(payload.startTime, payload.endTime, payload.type, this.kv[key]); }, getMix2(payload) { return dateRange.rangeTest3(payload.startTime, payload.endTime, payload.type, { 0: '0:00', 1: '1:00', 2: '2:00', 3: '3:00', 4: '4:00', 5: '5:00', 6: '6:00', 7: '7:00', 8: '8:00', 9: '9:00', 10: '10:00', 11: '11:00', 12: '12:00', 13: '13:00', 14: '14:00', 15: '15:00', 16: '16:00', 17: '17:00', 18: '18:00', 19: '19:00', 20: '20:00', 21: '21:00', 22: '22:00', 23: '23:00', }); }, getMix3(payload, key) { return dateRange.rangeTest2(payload.startTime, payload.endTime, payload.type, this.kv2[key]); }, // 通用验证规则 createCommonRule() { return { // { type: 'string', required: true, allowEmpty: false } startTime: { type: 'number', min: 0 }, // 开始时间的时间戳 包含 endTime: { type: 'number', min: 0 }, // 结束时间的时间戳 不包含(客户端处理结束时间 下一日 ,下一月第一日 ,下一年第一日) type: [ '0', '1', '2' ], // 类型分为 0日 1月 2年 }; }, validate(rules = this.createCommonRule(), data) { data = data || this.query || this.request.body || {}; console.log('参数', data); const errors = this.app.validator.validate(rules, data); if (errors) { this.throw(422, '参数校验失败', { // code: 'invalid_param', errors, }); } if (data.startTime && data.endTime && data.startTime > data.endTime) { this.throw(400, '开始时间不能小于结束时间'); } this.logger.debug('参数', data); return data; }, success({ data = null, msg = '请求成功' }) { this.body = { code: 0, data, msg, }; this.status = 200; }, };