import store from '../common/store.js'

class Dataprocessing {
	constructor() {

	}


	//
	putWindPowerStationName(windPowerStationName) {
		uni.setStorageSync('windpowerstationName', windPowerStationName);
	}

	putWindPowerStationId(windPowerStationId) {
		uni.setStorageSync('windPowerStationId', windPowerStationId);
	}

	getWindPowerStationName() {
		return uni.getStorageSync('windpowerstationName');
	}

	getWindPowerStationId() {
		return uni.getStorageSync('windPowerStationId');
	}

	getWindPowerStationNameById(name) {
		if (name == '宁夏新能源公司') {
			let wpId = '0';
			return wpId;
		} else if (name == '麻黄山风电场') {

			let wpId = 'MHS_FDC';
			return wpId;
		} else if (name == '牛首山风电场') {
			let wpId = 'NSS_FDC';
			return wpId;
		} else if (name == '石板泉风电场') {
			let wpId = 'SBQ_FDC';
			return wpId;
		} else if (name == '青山风电场') {
			let wpId = 'QS_FDC';
			return wpId;
		} else if (name == '香山风电场') {
			let wpId = 'XS_FDC';
			return wpId;
		} else if (name == '河北能源集团') {
			let wpId = '0';
			return wpId;
		} else if (name == '崇礼风电场') {
			let wpId = 'CL_FDC';
			return wpId;
		} else if (name == '康保风电场') {
			let wpId = 'KB_FDC';
			return wpId;
		} else if (name == '代县风电场') {
			let wpId = 'DX_FDC';
			return wpId;
		}
	}

	getWindPowerStationNameByWeatherId(name) {

		if (name == '宁夏新能源公司') {
			let wpId = 'MHS_FDC';
			return wpId;
		} else if (name == '麻黄山风电场') {

			let wpId = 'MHS_FDC';
			return wpId;
		} else if (name == '牛首山风电场') {
			let wpId = 'NSS_FDC';
			return wpId;
		} else if (name == '石板泉风电场') {
			let wpId = 'SBQ_FDC';
			return wpId;
		} else if (name == '青山风电场') {
			let wpId = 'QS_FDC';
			return wpId;
		} else if (name == '香山风电场') {
			let wpId = 'XS_FDC';
			return wpId;
		} else if (name == '河北能源集团') {
			let wpId = 'CL_FDC';
			return wpId;
		} else if (name == '崇礼风电场') {
			let wpId = 'CL_FDC';
			return wpId;
		} else if (name == '康保风电场') {
			let wpId = 'KB_FDC';
			return wpId;
		} else if (name == '代县风电场') {
			let wpId = 'DX_FDC';
			return wpId;
		}
	}

	getWindPowerStationNameByNames(name) {
		if (name == '宁夏新能源公司') {

			let windStations = ['麻黄山风电场', '牛首山风电场', '石板泉风电场', '青山风电场', '香山风电场'];
			return windStations;
		} else if (name == '麻黄山风电场') {
			let windStations = ['麻黄山风电场', '牛首山风电场', '石板泉风电场', '青山风电场', '香山风电场'];
			return windStations;
		} else if (name == '牛首山风电场') {
			let windStations = ['牛首山风电场', '麻黄山风电场', '石板泉风电场', '青山风电场', '香山风电场'];
			return windStations;
		} else if (name == '石板泉风电场') {
			let windStations = ['石板泉风电场', '麻黄山风电场', '牛首山风电场', '青山风电场', '香山风电场'];
			return windStations;
		} else if (name == '香山风电场') {
			let windStations = ['香山风电场', '麻黄山风电场', '牛首山风电场', '石板泉风电场', '青山风电场'];
			return windStations;
		} else if (name == '青山风电场') {
			let windStations = ['青山风电场', '麻黄山风电场', '牛首山风电场', '石板泉风电场', '香山风电场'];
			return windStations;
		} else if (name == '河北能源集团') {
			let windStations = ['崇礼风电场', '康保风电场', '代县风电场'];
			return windStations;
		} else if (name == '崇礼风电场') {
			let windStations = ['崇礼风电场', '康保风电场', '代县风电场'];
			return windStations;
		} else if (name == '康保风电场') {
			let windStations = ['康保风电场', '崇礼风电场', '代县风电场'];
			return windStations;
		} else if (name == '代县风电场') {
			let windStations = ['代县风电场', '康保风电场', '崇礼风电场'];
			return windStations;
		}
	}

	viewUserid() {
		let userid = uni.getStorageSync('userid');
		let ip = store.state.wholeSituationBackStageIp;
		let port = store.state.wholeSituationBackStagePort;
		uni.request({
			url: 'http://' + ip + ':' + port + '/GyeeorganController/GyeeOrganList?userid=' + userid,
			data: {},
			method: 'GET',
			success: function(res) {

				let plusDrawerList = [];
				let plusDrawerList_weather = [];
				for (let j = 0; j < res.data.data.length; j++) {

					var obj = {};
					obj.name = res.data.data[j].describes;
					obj.windId = res.data.data[j].name;

					plusDrawerList.push(obj);
				}

				for (let j = 0; j < res.data.data.length; j++) {

					var obj = {};
					obj.name = res.data.data[j].describes;

					if (res.data.data[j].describes == '宁夏新能源公司') {
						obj.windId = 'MHS_FDC';
					} else if (res.data.data[j].describes == '河北能源集团') {
						obj.windId = 'CL_FDC';
					} else {
						obj.windId = res.data.data[j].name;
					}
					plusDrawerList_weather.push(obj);
				}

				uni.setStorageSync('plusList', plusDrawerList);
				uni.setStorageSync('plusList_we', plusDrawerList_weather);
			}
		})
	}


	monitoringAuthority() {
		let userid = uni.getStorageSync('userid');
		let ip = store.state.wholeSituationBackStageIp;
		let port = store.state.wholeSituationBackStagePort;
		uni.request({
				url: 'http://' + ip + ':' + port + '/GyeepermissionController/GyeePermissionList?userid=' + userid,
				data: {},
				method: 'GET',
				success: function(res) {

					let leftlist1 = [];
					let leftlist2 = [];
					let leftlist3 = [];
					let leftlist4 = [];
					let leftlist5 = [];

					for (let j = 0; j < res.data.data.length; j++) {

						let gyeePermissionList = res.data.data[j].gyeePermissionList;

						if (j == 0) {
							for (let k = 0; k < gyeePermissionList.length; k++) {
								var obj = {};
								obj.name = gyeePermissionList[k].permisssionname;
								obj.remark1 = gyeePermissionList[k].remark1;
								leftlist1.push(obj);
							}
						} else if (j == 1) {

							for (let k = 0; k < gyeePermissionList.length; k++) {
								var obj = {};
								obj.name = gyeePermissionList[k].permisssionname;
								obj.remark1 = gyeePermissionList[k].remark1;
								leftlist2.push(obj);
							}
						} else if (j == 2) {

							for (let k = 0; k < gyeePermissionList.length; k++) {
								var obj = {};
								obj.name = gyeePermissionList[k].permisssionname;
								obj.remark1 = gyeePermissionList[k].remark1;
								leftlist3.push(obj);
							}
						} else if (j == 3) {

							for (let k = 0; k < gyeePermissionList.length; k++) {
								var obj = {};
								obj.name = gyeePermissionList[k].permisssionname;
								obj.remark1 = gyeePermissionList[k].remark1;
								leftlist4.push(obj);
							}
						} else if (j == 4) {

							for (let k = 0; k < gyeePermissionList.length; k++) {
								var obj = {};
								obj.name = gyeePermissionList[k].permisssionname;
								obj.remark1 = gyeePermissionList[k].remark1;
								leftlist5.push(obj);
							}
						}

					}
					uni.setStorageSync('leftlist1', leftlist1);
					uni.setStorageSync('leftlist2', leftlist2);
					uni.setStorageSync('leftlist3', leftlist3);
					uni.setStorageSync('leftlist4', leftlist4);
					uni.setStorageSync('leftlist5', leftlist5);
				}

		})
	}
}

let dataprocessing = new Dataprocessing();
export default dataprocessing;
