export default {
    toObjData(excelData) {
        return excelData.map(item => {
            const monitorTime = new Date();
            monitorTime.setFullYear(item[0]);
            monitorTime.setMonth(item[7] - 1);
            monitorTime.setDate(item[8]);
            monitorTime.setHours(item[9]);
            monitorTime.setMinutes(item[10]);
            let quarter = 1;
            const month = item[7]
            if (month < 4) {
                quarter = 1
            } else if (month < 7) {
                quarter = 2
            } else if (month < 10) {
                quarter = 3
            } else {
                quarter = 4
            }
            const row = {
                regionCode: "450100",
                monitorYear: item[0],
                gridLength: item[1],
                gridWidth: item[2],
                place: item[3],
                gridNo: item[4],
                area: item[5],
                source: item[6],
                monitorMonth: item[7],
                monitorDay: item[8],
                monitorHour: item[9],
                monitorMinute: item[10],
                indexLeq: item[11],
                indexSd: item[12],
                indexL10: item[13],
                indexL50: item[14],
                indexL90: item[15],
                indexLmax: item[16],
                indexLmin: item[17],
                station: item[18],
                monitorInstrumentModel: item[19],
                monitorInstrumentCode: item[20],
                beforeMonitorValue: item[21],
                afterMonitorValue: item[22],
                soundPressureValue: item[23],
                soundInstrumentModel: item[24],
                soundInstrumentCode: item[25],
                city: '南宁',
                regionLevel: "市级",
                monitorTime: monitorTime.getTime(),
                quarter
            }

            if (row.monitorHour >= 6 && row.monitorHour < 22) {
                row.timeSlot = "昼"
            }else{
                row.timeSlot = "夜"
            }
            if (row.indexL10 < row.indexL50 || row.indexL50 < row.indexL90) {
                throw new Error(row.place + "数值有误")
            }
            // console.log(monitorTime)
            return row;
        })

    },
    toPlaceData(excelData) {
        return excelData.map(item => {
            return {
                place: item[0],
                placeLng: item[1],
                placeLat: item[2],
                motorway: item[3],
                motorwayType: item[4],
                motorwayLevel: item[5],
                refObj: item[6],
                people: item[7],
                station: item[8],
                monitorInstrumentModel: item[9],
                monitorInstrumentCode: item[10],
                beforeMonitorValue: item[11],
                afterMonitorValue: item[12],
                soundPressureValue: item[13],
                soundInstrumentModel: item[14],
                soundInstrumentCode: item[15],

            }
        })

    },
    // 解析县级数据
    toAreaObjData(excelData) {
        return excelData.map(item => {
            const monitorTime = new Date();
            monitorTime.setFullYear(item[1]);
            monitorTime.setMonth(item[10] - 1);
            monitorTime.setDate(item[11]);
            monitorTime.setHours(item[12]);
            monitorTime.setMinutes(item[13]);
            let quarter = 1;
            const month = item[10]
            if (month < 4) {
                quarter = 1
            } else if (month < 7) {
                quarter = 2
            } else if (month < 10) {
                quarter = 3
            } else {
                quarter = 4
            }
            const row = {
                regionCode: item[0],
                monitorYear: item[1],
                placeCode: item[2],
                place: item[3],
                placeLng: item[4],
                placeLat: item[5],
                reqObj: item[6],
                gridLength: item[7],
                people: item[8],
                functionCode: item[9],
                monitorMonth: item[10],
                monitorDay: item[11],
                monitorHour: item[12],
                monitorMinute: item[13],
                sourceCode: item[14],
                indexLeq: item[15],
                indexL10: item[16],
                indexL50: item[17],
                indexL90: item[18],
                indexLmax: item[19],
                indexLmin: item[20],
                indexSd: item[21],
                station: item[22],
                monitorInstrumentModel: item[23],
                monitorInstrumentCode: item[24],
                beforeMonitorValue: item[25],
                afterMonitorValue: item[26],
                soundPressureValue: item[27],
                soundInstrumentModel: item[28],
                soundInstrumentCode: item[29],
                city: '南宁',
                regionLevel: "县级",
                monitorTime: monitorTime.getTime(),
                quarter
            }

            if (row.monitorHour >= 6 && row.monitorHour < 22) {
                row.timeSlot = "昼"
            }else{
                row.timeSlot = "夜"
            }
            if (row.indexL10 < row.indexL50 || row.indexL50 < row.indexL90) {
                throw new Error(row.place + "数值有误")
            }
            return row;
        })
    }
}