export default {
    toObjData(excelData) {
        return excelData.map(item => {
            const monitorTime = new Date();
            monitorTime.setFullYear(item[0]);
            monitorTime.setMonth(item[4] - 1);
            monitorTime.setDate(item[5]);
            monitorTime.setHours(item[6]);
            monitorTime.setMinutes(item[7]);
            let quarter = 1;
            const month = item[4]
            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],
                place: item[1],
                placeCode: item[2],
                functionType: item[3],
                monitorMonth: item[4],
                monitorDay: item[5],
                monitorHour: item[6],
                monitorMinute: item[7],
                monitorTime: monitorTime.getTime(),
                indexLeq: item[8],
                indexSd: item[9],
                indexL10: item[10],
                indexL50: item[11],
                indexL90: item[12],
                indexLmax: item[13],
                indexLmin: item[14],
                regionLevel: "市级",
                city: '南宁',
                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 + "数值有误" + `${row.indexLeq},${row.indexL10},${row.indexL50},${row.indexL90}`)
            }
            return row;
        })

    },
    toPlaceData(excelData) {
        return excelData.map(item => {
            return {
                place: item[0],
                placeLng: item[1],
                placeLat: item[2],
                placeHeight: item[3],
                refObj: item[4],
                functionCode: item[5],
                monitorInstrumentModel: item[6],
                monitorInstrumentCode: item[7],
                beforeMonitorValue: item[8],
                afterMonitorValue: item[9],
                soundPressureValue: Number(item[10]) || null,
                soundInstrumentModel: item[11],
                soundInstrumentCode: item[12],

            }
        })

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

            }
            if(row.indexL10 < row.indexL50 || row.indexL50 < row.indexL90){
                throw new Error(row.place + "数值有误")
            }
            return row;
        })
    }
}