Bladeren bron

杀虫灯接口对接完成

yf_zd 5 jaren geleden
bovenliggende
commit
6dabc42081

+ 244 - 165
bigdata2/src/pages/cure/scd/scd.vue

@@ -8,123 +8,119 @@
 			@fun2="getIDName"
 			@fun2="getIDName"
 			@fun3="getIsOnline"
 			@fun3="getIsOnline"
 		></search-bar>
 		></search-bar>
-		<template v-if="displayType == 1">
-			<el-row :gutter="10">
-				<el-col
-					:xs="24"
-					:sm="24"
-					:md="12"
-					:lg="8"
-					:xl="6"
-					v-for="item in equipList"
-					:key="item.imei"
-				>
-					<el-card class="box-card">
-						<span
-							:class="['on-stauts', item.device_status == 1 ? 'on' : 'off']"
-						></span>
-						<div
-							class="superOperate"
-							v-show="userType == 1"
-							@click="equipOperation(item.d_id)"
-						>
-							<i class="el-icon-setting"></i>
-						</div>
-						<img src="@/assets/images/cure/scd/scdIconOn.png" />
-						<p class="equip">{{ item.device_id }}</p>
-						<div class="item_info">
-							<p>设备名称 : {{ item.device_name }}</p>
-							<p>最新上报时间 : {{ (item.status_time * 1000) | formatTime }}</p>
-							<p>地址 : {{ item.address || '无' }}</p>
-						</div>
-						<div class="btns">
-							<el-button
-								size="mini"
-								type="info"
-								@click="equipStateSet(item.device_id, item.device_status)"
-								>设备状态</el-button
-							>
-							<el-button
-								size="mini"
-								type="warning"
-								@click="EquipControl(item.d_id)"
-								>设备控制</el-button
-							>
-							<el-button size="mini" type="success" @click="simSet(item.d_id)"
-								>SIM卡状态</el-button
-							>
-							<el-button
-								size="mini"
-								type="danger"
-								@click="dataDetails(item.device_id, item.d_id)"
-								>数据详情</el-button
-							>
-						</div>
-					</el-card>
-				</el-col>
-			</el-row>
-		</template>
-		<template v-if="displayType == 2">
-			<el-card class="box-card">
-				<el-table :data="equipList" stripe style="width: 100%">
-					<el-table-column prop="device_id" label="设备ID" width="180">
-						<template slot-scope="scope">{{ scope.row.device_id }}</template>
-					</el-table-column>
-					<el-table-column prop="device_name" label="设备名称" width="180">
-						<template slot-scope="scope">{{
-							scope.row.device_name == '' ? '无' : scope.row.device_name
-						}}</template>
-					</el-table-column>
-					<el-table-column prop="device_status" label="在线状态">
-						<template slot-scope="scope">
-							<p style="color: #17bb89" v-if="scope.row.device_status == 1">
-								在线
-							</p>
-							<p style="color: #eb6765" v-if="scope.row.device_status == 0">
-								离线
-							</p>
-						</template>
-					</el-table-column>
-					<el-table-column prop="dver_num" label="设备版本"></el-table-column>
-					<el-table-column prop="status_time" label="最新上报时间">
-						<template slot-scope="scope">{{
-							(scope.row.status_time * 1000) | formatTime
-						}}</template>
-					</el-table-column>
-					<el-table-column label="操作" width="400">
-						<template slot-scope="scope">
-							<el-button
-								size="mini"
-								type="info"
-								@click="
-									equipStateSet(scope.row.device_id, scope.row.device_status)
-								"
-								>设备状态</el-button
-							>
-							<el-button
-								size="mini"
-								type="warning"
-								@click="EquipControl(scope.row.d_id)"
-								>设备控制</el-button
-							>
-							<el-button
-								size="mini"
-								type="success"
-								@click="simSet(scope.row.d_id)"
-								>SIM卡状态</el-button
-							>
-							<el-button
-								size="mini"
-								type="danger"
-								@click="dataDetails(scope.row.device_id, scope.row.d_id)"
-								>数据详情</el-button
-							>
-						</template>
-					</el-table-column>
-				</el-table>
-			</el-card>
-		</template>
+		<div v-loading='dataloading'>
+			<template v-if="displayType == 1">
+				<el-row :gutter="10">
+					<el-col
+						:xs="24"
+						:sm="24"
+						:md="12"
+						:lg="8"
+						:xl="6"
+						v-for="item in equipList"
+						:key="item.imei"
+					>
+						<el-card class="box-card">
+							<span
+								:class="['on-stauts', item.device_status == 1 ? 'on' : 'off']"
+							></span>
+							<img src="@/assets/images/cure/scd/scdIconOn.png" />
+							<p class="equip">{{ item.device_id }}</p>
+							<div class="item_info">
+								<p>设备名称 : {{ item.device_name || '无' }}</p>
+								<p>最新上报时间 : {{ item.status_time }}</p>
+								<p>地址 : {{ item.address || '无' }}</p>
+							</div>
+							<div class="btns">
+								<el-button
+									size="mini"
+									type="info"
+									@click="equipStateSet(item.device_id,item.device_status)"
+									>设备状态</el-button
+								>
+								<el-button
+									size="mini"
+									type="warning"
+									@click="EquipControl(item.device_id)"
+									>设备控制</el-button
+								>
+								<el-button
+									size="mini"
+									type="danger"
+									@click="dataDetails(item.device_id,item.device_name,item.address)"
+									>数据详情</el-button
+								>
+							</div>
+						</el-card>
+					</el-col>
+				</el-row>
+			</template>
+			<template v-if="displayType == 2">
+				<el-card class="box-card">
+					<el-table :data="equipList" stripe style="width: 100%">
+						<el-table-column prop="device_id" label="设备ID" width="180">
+							<template slot-scope="scope">{{ scope.row.device_id }}</template>
+						</el-table-column>
+						<el-table-column prop="device_name" label="设备名称" width="180">
+							<template slot-scope="scope">{{
+								scope.row.device_name == '' ? '无' : scope.row.device_name
+							}}</template>
+						</el-table-column>
+						<el-table-column prop="device_status" label="在线状态">
+							<template slot-scope="scope">
+								<p style="color: #17bb89" v-if="scope.row.device_status == 1">
+									在线
+								</p>
+								<p style="color: #eb6765" v-if="scope.row.device_status == 0">
+									离线
+								</p>
+							</template>
+						</el-table-column>
+						<el-table-column prop="address" label="地址">
+							<template slot-scope="scope">{{ scope.row.address }}</template>
+						</el-table-column>
+						<el-table-column prop="status_time" label="最新上报时间">
+							<template slot-scope="scope">{{ scope.row.status_time }}</template>
+						</el-table-column>
+						<el-table-column label="操作" width="400">
+							<template slot-scope="scope">
+								<el-button
+									size="mini"
+									type="info"
+									@click="
+										equipStateSet(scope.row.device_id,scope.row.device_status)
+									"
+									>设备状态</el-button
+								>
+								<el-button
+									size="mini"
+									type="warning"
+									@click="EquipControl(scope.row.device_id)"
+									>设备控制</el-button
+								>
+								<el-button
+									size="mini"
+									type="danger"
+									@click="dataDetails(scope.row.device_id,scope.row.device_name,scope.row.address)"
+									>数据详情</el-button
+								>
+							</template>
+						</el-table-column>
+					</el-table>
+				</el-card>
+			</template>
+			<!-- 暂无数据 -->
+			<div class="expertDiagnosis_referral_units_not" v-if="equipList.length<=0 && displayType==1">
+				<img
+					src="@/assets/images/zanwu.png"
+					alt
+					class="expertDiagnosis_referral_units_notImg"
+				/>
+			</div>
+		</div>
+		
 		<el-pagination
 		<el-pagination
+			v-if="equipList.length>0"
 			background
 			background
 			layout="prev, pager, next"
 			layout="prev, pager, next"
 			:total="totalNum"
 			:total="totalNum"
@@ -199,15 +195,15 @@
 					label-width="120px"
 					label-width="120px"
 				>
 				>
 					<el-form-item label="设备开关:" prop="ds">
 					<el-form-item label="设备开关:" prop="ds">
-						<el-select v-model="equipContrlForm.ds">
-							<el-option label="开机" value="1"></el-option>
-							<el-option label="关机" value="0"></el-option>
+						<el-select v-model="equipContrlForm.ds" @change="equipSwitch">
+							<el-option label="开机" :value="1"></el-option>
+							<el-option label="关机" :value="0"></el-option>
 						</el-select>
 						</el-select>
 					</el-form-item>
 					</el-form-item>
 					<el-form-item label="定时模式:" prop="ts">
 					<el-form-item label="定时模式:" prop="ts">
 						<el-select v-model="equipContrlForm.ts" placeholder="定时模式">
 						<el-select v-model="equipContrlForm.ts" placeholder="定时模式">
-							<el-option label="光控" value="0"></el-option>
-							<el-option label="时控" value="1"></el-option>
+							<el-option label="光控" :value="0"></el-option>
+							<el-option label="时控" :value="1"></el-option>
 						</el-select>
 						</el-select>
 					</el-form-item>
 					</el-form-item>
 					<el-form-item
 					<el-form-item
@@ -221,9 +217,9 @@
 									placeholder="起始时间"
 									placeholder="起始时间"
 									v-model="equipContrlForm.st"
 									v-model="equipContrlForm.st"
 									:picker-options="{
 									:picker-options="{
-										start: '00:00',
-										step: '01:00',
-										end: '24:00'
+										start: '0:00',
+										step: '1:00',
+										end: '23:00'
 									}"
 									}"
 								></el-time-select>
 								></el-time-select>
 							</el-col>
 							</el-col>
@@ -233,9 +229,10 @@
 									placeholder="结束时间"
 									placeholder="结束时间"
 									v-model="equipContrlForm.et"
 									v-model="equipContrlForm.et"
 									:picker-options="{
 									:picker-options="{
-										start: '00:00',
-										step: '01:00',
-										end: '24:00'
+										start: '0:00',
+										step: '1:00',
+										end: '23:00',
+										minTime: equipContrlForm.st
 									}"
 									}"
 								></el-time-select>
 								></el-time-select>
 							</el-col>
 							</el-col>
@@ -261,16 +258,16 @@
 						<div class="sliderParent">
 						<div class="sliderParent">
 							<div class="block">
 							<div class="block">
 								<el-slider
 								<el-slider
-									:min="10"
-									step="10"
-									:max="120"
+									:min='10'
+									:step='10'
+									:max='120'
 									v-model="equipContrlForm.dattim"
 									v-model="equipContrlForm.dattim"
 									show-input
 									show-input
 								></el-slider>
 								></el-slider>
 							</div>
 							</div>
 						</div>
 						</div>
 					</el-form-item>
 					</el-form-item>
-					<el-form-item label="自清虫定时:" prop="clt">
+					<!-- <el-form-item label="自清虫定时:" prop="clt">
 						<div class="sliderParent">
 						<div class="sliderParent">
 							<div class="block">
 							<div class="block">
 								<el-slider
 								<el-slider
@@ -281,7 +278,7 @@
 								></el-slider>
 								></el-slider>
 							</div>
 							</div>
 						</div>
 						</div>
-					</el-form-item>
+					</el-form-item> -->
 					<el-form-item class="handAddFormBtn">
 					<el-form-item class="handAddFormBtn">
 						<el-button type="primary" size="mini" @click="equipControlSubm"
 						<el-button type="primary" size="mini" @click="equipControlSubm"
 							>确定</el-button
 							>确定</el-button
@@ -349,6 +346,7 @@ import SearchBar from '@/components/SearchBar'
 export default {
 export default {
 	data() {
 	data() {
 		return {
 		return {
+			dataloading:false,
 			//图表和表格切换
 			//图表和表格切换
 			displayType: '1',
 			displayType: '1',
 			//在线状态按钮切换
 			//在线状态按钮切换
@@ -406,7 +404,6 @@ export default {
 				ts: '',
 				ts: '',
 				tt: '',
 				tt: '',
 				dattim: 10,
 				dattim: 10,
-				clt: 10
 			},
 			},
 			//参数
 			//参数
 			queryInfo: {
 			queryInfo: {
@@ -461,22 +458,43 @@ export default {
 		},
 		},
 		//获取设备列表
 		//获取设备列表
 		getEquipList() {
 		getEquipList() {
+			this.dataloading = true;
 			this.$axios({
 			this.$axios({
 				method: 'POST',
 				method: 'POST',
-				url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
+				url: '/api/equipmanage_scd',
 				data: this.qs.stringify({
 				data: this.qs.stringify({
-					device_type_id: 2,
-					page_size: 8,
+					req: 'filter',
+					is_online:this.queryInfo.is_online,
+					ename: this.queryInfo.ename,
 					page: this.queryInfo.page,
 					page: this.queryInfo.page,
-					device_status: this.queryInfo.is_online,
-					device_name: this.queryInfo.ename,
-					device_id: this.queryInfo.f_id
+					f_id: this.queryInfo.f_id,
 				})
 				})
 			}).then((res) => {
 			}).then((res) => {
-				if (res.data.message == '') {
-					this.equipList = res.data.data.data
-					this.totalNum = res.data.data.counts
-				}
+				this.dataloading = false
+				if(res.data.nums){
+					var dat = res.data.dat;
+					var arr = [];
+					for(var i = 0;i<dat.length;i++){
+						arr.push({
+							address: dat[i].locat,
+							device_id: dat[i].equip_id,
+							device_name: dat[i].equip_name,
+							device_status: parseInt(dat[i].is_online),
+							status_time: dat[i].upl_time,
+						})
+						if(i == dat.length-1){
+							console.log(arr)
+							this.equipList = arr
+							this.totalNum = res.data.nums
+						}
+					}
+				}else{
+					this.equipList = []
+					this.totalNum = 0
+				}	
+			},error =>{
+				this.dataloading = false
+				this.$message.error('获取失败')
 			})
 			})
 		},
 		},
 		simSet(d_id) {
 		simSet(d_id) {
@@ -519,27 +537,40 @@ export default {
 			this.getEquipList()
 			this.getEquipList()
 		},
 		},
 		// 数据详情
 		// 数据详情
-		dataDetails(e_id, d_id) {
+		dataDetails(e_id,name,address) {
 			this.currImei = e_id
 			this.currImei = e_id
-			this.$router.push(`/index/scdDetail/${e_id}/${d_id}`)
+			this.$router.push({path:`/index/scdDetail`,query:{id:e_id,name:name,address:address}})
 		},
 		},
 		//sim卡状态
 		//sim卡状态
 		handleClick(tab, event) {
 		handleClick(tab, event) {
 			console.log(tab, event)
 			console.log(tab, event)
 		},
 		},
 		// 设备状态弹框
 		// 设备状态弹框
-		equipStateSet(id, device_status) {
+		equipStateSet(id,status) {
 			this.currImei = id
 			this.currImei = id
 			this.$axios({
 			this.$axios({
 				method: 'POST',
 				method: 'POST',
-				url: '/api/api_gateway?method=forecast.worm_lamp.device_history_data',
+				url: '/api/equipmanage_scd',
 				data: this.qs.stringify({
 				data: this.qs.stringify({
-					device_type_id: 2,
-					page_size: 1,
-					device_id: id,
-					page: 1
+					req: 'imei',
+					id: id,
 				})
 				})
 			}).then((res) => {
 			}).then((res) => {
+				var scd_status = eval('('+res.data.scd_status+')');
+				this.equipStateList[0].val = scd_status.ds == 0 ? '关机' : '开机';
+				if(scd_status.ws == 0){
+					this.equipStateList[1].val = '待机'
+				}else if(scd_status.ws == 1){
+					this.equipStateList[1].val = '工作'
+				}else if(scd_status.ws == 2){
+					this.equipStateList[1].val = '充电'
+				}
+				this.equipStateList[2].val = scd_status.tt == 0 ? '常亮' : scd_status.tt;
+				this.equipStateList[3].val = scd_status.clt/60;
+				this.equipStateList[4].val = scd_status.tbs == 0 ? '正常' : '保护'
+				this.equipStateList[5].val = status == 0 ? '离线' : '在线'
+				this.equipStateList[6].val = scd_status.rps == 0 ? '正常' : '保护'
+
 				if (res.data.message == '') {
 				if (res.data.message == '') {
 					let data = res.data.data.data[0].d_h_t
 					let data = res.data.data.data[0].d_h_t
 					this.equipStateList[5].val = device_status == 0 ? '离线' : '在线'
 					this.equipStateList[5].val = device_status == 0 ? '离线' : '在线'
@@ -573,39 +604,82 @@ export default {
 			this.equipStateDialogVisible = true
 			this.equipStateDialogVisible = true
 		},
 		},
 		//设备控制
 		//设备控制
-		EquipControl(d_id) {
-			this.d_id = d_id
+		EquipControl(id) {
+			this.currImei = id
 			this.$axios({
 			this.$axios({
 				method: 'POST',
 				method: 'POST',
-				url:
-					'/api/api_gateway?method=forecast.send_control.device_control_info',
-				data: this.qs.stringify({ d_id, get_type: 1 })
+				url: '/api/equipmanage_scd',
+				data: this.qs.stringify({
+					req: 'imei',
+					id: id,
+				})
 			}).then((res) => {
 			}).then((res) => {
-				if (Object.keys(res.data.data).length > 0) {
-					let data = res.data.data
-					this.equipContrlForm = data
+				var scd_status = eval('('+res.data.scd_status+')');
+				this.equipContrlForm = {
+					dattim: scd_status.dattim,
+					ds: scd_status.ds,
+					et: scd_status.et,
+					st: scd_status.st,
+					ts: scd_status.tcs,
+					tt: scd_status.tt,
 				}
 				}
 				this.equipControlDialogVisible = true
 				this.equipControlDialogVisible = true
 			})
 			})
 		},
 		},
 		equipControlSubm() {
 		equipControlSubm() {
+			let obj = this.equipContrlForm
+			obj.st = obj.st && obj.st.toString().slice(0, 2) != '0' ? obj.st.toString().slice(0, 2) : obj.st.toString().slice(1, 2)
+			obj.et = obj.et && obj.et.toString().slice(0, 2) != '0' ? obj.et.toString().slice(0, 2) : obj.et.toString().slice(1, 2)
 			this.$axios({
 			this.$axios({
 				method: 'POST',
 				method: 'POST',
-				url: '/api/api_gateway?method=forecast.send_control.device_control',
+				url: '/api/scd_mqtt',
 				data: this.qs.stringify({
 				data: this.qs.stringify({
-					device_type_id: 2,
-					d_id: this.d_id,
-					config: JSON.stringify(this.equipContrlForm)
+					sw: 'datt',
+					topicid: JSON.stringify([this.currImei]),
+					dattim: this.equipContrlForm.dattim
 				})
 				})
 			}).then((res) => {
 			}).then((res) => {
-				if (res.data.data) {
+				if (res.data != 0) {
+					this.$message.error('设备控制修改失败')
+				}
+			})
+			this.$axios({
+				method: 'POST',
+				url: '/api/scd_mqtt_all',
+				data: this.qs.stringify({
+					sw: 'timer',
+					ts: this.equipContrlForm.ts,
+					hours: this.equipContrlForm.tt,
+					begin: this.equipContrlForm.st,
+					end: this.equipContrlForm.et
+				})
+			}).then((res) => {
+				if (res.data == 0) {
 					this.$message.success('设备控制修改成功')
 					this.$message.success('设备控制修改成功')
 				} else {
 				} else {
-					his.$message.error('设备控制修改失败')
+					this.$message.error('设备控制修改失败')
 				}
 				}
 				this.equipControlDialogVisible = false
 				this.equipControlDialogVisible = false
 			})
 			})
 		},
 		},
+		//设备开关控制
+		equipSwitch(){
+			this.$axios({
+				method: 'POST',
+				url: '/api/scd_mqtt',
+				data: this.qs.stringify({
+					sw: 'timer',
+					topicid: JSON.stringify([this.currImei]),
+					ds: this.equipContrlForm.ds
+				})
+			}).then((res) => {
+				if (res.data == 0) {
+					this.$message.success('设备控制修改成功')
+				} else {
+					this.$message.error('设备控制修改失败')
+				}
+			})
+		},
 		equipControlDialogClosed() {
 		equipControlDialogClosed() {
 			this.$refs.equipContrlRef.resetFields()
 			this.$refs.equipContrlRef.resetFields()
 			// console.log(this.equipContrlForm)
 			// console.log(this.equipContrlForm)
@@ -817,4 +891,9 @@ export default {
 }
 }
 /deep/.el-date-editor--time-select{width:100%!important}
 /deep/.el-date-editor--time-select{width:100%!important}
 /deep/.line{text-align:center}
 /deep/.line{text-align:center}
+// 暂无数据
+.expertDiagnosis_referral_units_not {
+	width: 272px;
+	margin: 0 auto;
+}
 </style>
 </style>

+ 58 - 41
bigdata2/src/pages/cure/scd/scdDetail.vue

@@ -7,10 +7,9 @@
 		</el-breadcrumb>
 		</el-breadcrumb>
 		<div class="equipInfo">
 		<div class="equipInfo">
 			<div class="equipMsg">
 			<div class="equipMsg">
-				<i class="icon-zhuti_tiaosepan_o"></i>
 				<span>设备ID:{{id}}</span>
 				<span>设备ID:{{id}}</span>
-				<span>设备名称:{{equipStatus.equip_name || '无'}}</span>
-				<span>位置:{{equipStatus.lng}}</span>
+				<span>设备名称:{{name || '无'}}</span>
+				<span>位置:{{address}}</span>
 			</div>
 			</div>
 			<DateSearch @dateChange="dateChange"></DateSearch>
 			<DateSearch @dateChange="dateChange"></DateSearch>
 		</div>
 		</div>
@@ -24,21 +23,23 @@
 					<el-col :md="24" :lg="14">
 					<el-col :md="24" :lg="14">
 						<el-card class="box-card">
 						<el-card class="box-card">
 							<div class="charts">
 							<div class="charts">
-								<highcharts :options="options"></highcharts>
+								<highcharts :options="options" v-if="Object.keys(options).length>0"></highcharts>
+								<div v-else style="text-align:center;font-size:20px;line-height:360px">暂无数据</div>
 							</div>
 							</div>
 						</el-card>
 						</el-card>
 					</el-col>
 					</el-col>
 					<el-col :md="24" :lg="10">
 					<el-col :md="24" :lg="10">
 						<el-card class="box-card">
 						<el-card class="box-card">
 							<div class="pie">
 							<div class="pie">
-								<highcharts :options="options2"></highcharts>
+								<highcharts :options="options2" v-if="Object.keys(options2).length>0"></highcharts>
+								<div v-else style="text-align:center;font-size:20px;line-height:360px">暂无数据</div>
 							</div>
 							</div>
 						</el-card>
 						</el-card>
 					</el-col>
 					</el-col>
 				</el-row>
 				</el-row>
 				<div class="dataTableSearch">
 				<div class="dataTableSearch">
 					<div>
 					<div>
-						<el-button type="primary" size="mini">导出</el-button>
+						<!-- <el-button type="primary" size="mini">导出</el-button> -->
 					</div>
 					</div>
 				</div>
 				</div>
 			</div>
 			</div>
@@ -71,7 +72,9 @@ import DateSearch from '@/components/DateSearch'
 export default {
 export default {
 	data() {
 	data() {
 		return {
 		return {
-			id: this.$route.params.e_id,
+			id: this.$route.query.id,
+			name: this.$route.query.name,
+			address: this.$route.query.address,
 			lineTime: '',
 			lineTime: '',
 			dataTime: '',
 			dataTime: '',
 			options: {},
 			options: {},
@@ -104,8 +107,8 @@ export default {
 				['电击次数', 'ct'],
 				['电击次数', 'ct'],
 				['温度(°C)', 'at'],
 				['温度(°C)', 'at'],
 				['湿度(%)', 'ah'],
 				['湿度(%)', 'ah'],
-				['充电电压(mv)', 'cv'],
-				['电池电压(mv)', 'bv'],
+				['充电电压(V)', 'cv'],
+				['电池电压(V)', 'bv'],
 				['上报时间', 'addtime']
 				['上报时间', 'addtime']
 			],
 			],
 			// 表格数据
 			// 表格数据
@@ -114,8 +117,7 @@ export default {
 			queryInfo: {
 			queryInfo: {
 				begin: '',
 				begin: '',
 				end: '',
 				end: '',
-				e_id: this.$route.params.e_id,
-				d_id: this.$route.params.d_id,
+				e_id: this.$route.query.id,
 				page: 1
 				page: 1
 			},
 			},
 			viewSwitch: 1,
 			viewSwitch: 1,
@@ -140,15 +142,15 @@ export default {
 		getChartDataList() {
 		getChartDataList() {
 			this.$axios({
 			this.$axios({
 				method: 'POST',
 				method: 'POST',
-				url: '/api/api_gateway?method=forecast.worm_lamp.device_polyline_data',
+				url: '/api/scd_report_detail_chart',
 				data: this.qs.stringify({
 				data: this.qs.stringify({
-					device_type_id: 2,
-					device_id: this.queryInfo.e_id,
-					start_time: this.queryInfo.begin,
-					end_time: this.queryInfo.end
+					req: 'filter',
+					id: this.queryInfo.e_id,
+					begin: this.queryInfo.begin,
+					end: this.queryInfo.end
 				})
 				})
 			}).then((res) => {
 			}).then((res) => {
-				if (res.data.message == '') {
+				if (res.data.length > 0) {
 					var ChartData = [
 					var ChartData = [
 						{
 						{
 							name: '温度(°C)',
 							name: '温度(°C)',
@@ -163,22 +165,22 @@ export default {
 							dat: []
 							dat: []
 						}
 						}
 					]
 					]
-					var data = res.data.data
+					var data = res.data
 					this.options = {}
 					this.options = {}
 					this.options2 = {}
 					this.options2 = {}
 					if (data.length > 0) {
 					if (data.length > 0) {
 						for (let item of data) {
 						for (let item of data) {
 							ChartData[0].dat.unshift([
 							ChartData[0].dat.unshift([
-								item.addtime * 1000 + 8 * 3600000,
-								item.temperature
+								this.returnTime(item.tim),
+								parseFloat(item.at)
 							])
 							])
 							ChartData[1].dat.unshift([
 							ChartData[1].dat.unshift([
-								item.addtime * 1000 + 8 * 3600000,
-								item.humidity
+								this.returnTime(item.tim),
+								parseFloat(item.ah)
 							])
 							])
 							ChartData[2].dat.unshift([
 							ChartData[2].dat.unshift([
-								item.addtime * 1000 + 8 * 3600000,
-								item.others
+								this.returnTime(item.tim),
+								item.ct
 							])
 							])
 						}
 						}
 						this.options = {
 						this.options = {
@@ -259,6 +261,7 @@ export default {
 								]
 								]
 							}
 							}
 						}
 						}
+
 						this.options2 = {
 						this.options2 = {
 							title: {
 							title: {
 								text: '击虫次数',
 								text: '击虫次数',
@@ -334,35 +337,47 @@ export default {
 							}
 							}
 						}
 						}
 					}
 					}
+				}else{
+					this.options = {}
+					this.options2 = {}
 				}
 				}
 			})
 			})
 		},
 		},
+		// 返回时间戳
+		returnTime(time) {
+			var thisTime = time.replace(/-/g, '/');
+			var time = new Date(thisTime);
+			var timestamp = time.getTime() + 8 * 3600000;
+			return timestamp;
+		},
 		//获取表格数据
 		//获取表格数据
 		getHisDataList() {
 		getHisDataList() {
 			this.$axios({
 			this.$axios({
 				method: 'POST',
 				method: 'POST',
-				url: '/api/api_gateway?method=forecast.worm_lamp.device_history_data',
+				url: '/api/scd_report_detail',
 				data: this.qs.stringify({
 				data: this.qs.stringify({
-					device_type_id: 2,
-					device_id: this.queryInfo.e_id,
-					start_time: this.queryInfo.begin,
-					end_time: this.queryInfo.end,
+					req: 'filter',
+					id: this.queryInfo.e_id,
+					begin: this.queryInfo.begin,
+					end: this.queryInfo.end,
 					page: this.queryInfo.page
 					page: this.queryInfo.page
 				})
 				})
 			}).then((res) => {
 			}).then((res) => {
-				if (res.data.message == '') {
-					this.total = res.data.data.counts
-					var data = res.data.data.data
+				this.total = res.data.nums
+				if (res.data.nums >0) {
+					var data = res.data.dat
 					this.tableData = []
 					this.tableData = []
 					if (data.length > 0) {
 					if (data.length > 0) {
 						for (var i = 0; i < data.length; i++) {
 						for (var i = 0; i < data.length; i++) {
-							var dht = data[i].d_h_t
-							dht.addtime = this.formatTime(dht.addtime * 1000)
+							var dht = eval('('+data[i].scd_data+')');
+							dht.addtime = data[i].upl_time
 							dht.ds = dht.ds == 0 ? '关' : '开'
 							dht.ds = dht.ds == 0 ? '关' : '开'
 							dht.rps = dht.rps == 0 ? '正常' : '雨控'
 							dht.rps = dht.rps == 0 ? '正常' : '雨控'
 							dht.tps = dht.tps == 0 ? '正常' : '保护'
 							dht.tps = dht.tps == 0 ? '正常' : '保护'
 							dht.tbs = dht.tbs == 0 ? '正常' : '保护'
 							dht.tbs = dht.tbs == 0 ? '正常' : '保护'
 							dht.dps = dht.dps == 0 ? '正常' : '保护'
 							dht.dps = dht.dps == 0 ? '正常' : '保护'
+							dht.cv = dht.cv/1000
+							dht.bv = dht.bv/1000
 							switch (dht.ws) {
 							switch (dht.ws) {
 								case 0:
 								case 0:
 									dht.ws = '待机'
 									dht.ws = '待机'
@@ -377,13 +392,15 @@ export default {
 							this.tableData.push(dht)
 							this.tableData.push(dht)
 						}
 						}
 					}
 					}
+				}else{
+					this.tableData = []
 				}
 				}
 			})
 			})
 		},
 		},
 		dateChange(data) {
 		dateChange(data) {
 			this.queryInfo.page = 1
 			this.queryInfo.page = 1
-			this.queryInfo.begin = data.begin
-			this.queryInfo.end = data.end
+			this.queryInfo.begin = new Date(data.begin*1000).toLocaleDateString().replace(/\//g,'-'); 
+			this.queryInfo.end = new Date(data.end*1000).toLocaleDateString().replace(/\//g,'-'); 
 			this.getHisDataList()
 			this.getHisDataList()
 			this.getChartDataList()
 			this.getChartDataList()
 		},
 		},
@@ -400,14 +417,14 @@ export default {
 		refresh() {
 		refresh() {
 			this.$axios({
 			this.$axios({
 				method: 'POST',
 				method: 'POST',
-				url: '/api/api_gateway?method=forecast.send_control.get_device_config',
+				url: '/api/scd_mqtt',
 				data: this.qs.stringify({
 				data: this.qs.stringify({
-					device_type_id: 2,
-					d_id: this.queryInfo.d_id,
-					control_type: 'data'
+					sw: 'read',
+					topicid: JSON.stringify([this.queryInfo.e_id]),
+					kind: 'data'
 				})
 				})
 			}).then((res) => {
 			}).then((res) => {
-				if (res.data.data) {
+				if (res.data == 0) {
 					this.$message.success('刷新成功')
 					this.$message.success('刷新成功')
 				} else {
 				} else {
 					this.$message.err('刷新失败')
 					this.$message.err('刷新失败')

+ 98 - 90
bigdata2/src/pages/forecasting/cbd/Cbd.vue

@@ -4,96 +4,100 @@
 			<el-breadcrumb-item>虫情测报</el-breadcrumb-item>
 			<el-breadcrumb-item>虫情测报</el-breadcrumb-item>
 		</el-breadcrumb>
 		</el-breadcrumb>
 		<search-bar @fun="getDisplayType" @fun2="getIDName" @fun3="getIsOnline"></search-bar>
 		<search-bar @fun="getDisplayType" @fun2="getIDName" @fun3="getIsOnline"></search-bar>
-		<template v-if="displayType==1">
-			<el-row :gutter="10" v-loading="tableLoading">
-				<el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="6" v-for="item in equipList" :key="item.imei">
-					<el-card class="box-card">
-						<equip-item :is_online="item.device_status">
-							
-							<span slot="title">虫情测报</span>
-							<div slot="content" class="content">
-								<p>
-									<i class="iconfont icon-yonghu"></i>
-									设备ID:{{item.device_id}}
-								</p>
-								<p>
-									<i class="iconfont icon-biaoqian"></i>
-									设备名称:{{item.device_name==""?"无":item.device_name}}
-								</p>
-								<p>
-									<i class="iconfont icon-diannao"></i>在线状态:
-									<span
-										:class="{red:item.device_status==0,green:item.device_status==1}"
-									>{{item.device_status==0?"离线":"在线"}}</span>
-								</p>
-								<p>
-									<i class="iconfont icon-shijian"></i>
-									最新上报时间 : {{item.status_time}}
-								</p>
-								<p>
-									<i class="iconfont icon-dizhi"></i>
-									地址 : {{item.address || "无"}}
-								</p>
-								<p class="btns">
-									<i class="iconfont icon-yemiancaozuo"></i>
-									<el-button size="mini" type="info" @click="viewPhotoDialog(item.device_id,item.d_id)">查看图片</el-button>
-									<el-button size="mini" type="warning" @click="EquipControl(item.device_id)">设备控制</el-button>
-									<!-- <el-button size="mini" type="success" v-if="item.disc==1" @click="showTimeControlDialog(item.device_id)">害虫统计</el-button> -->
-									<el-button size="mini" type="success" @click="showTimeControlDialog(item.device_id,item.device_name,item.address)">害虫统计</el-button>
-									<el-button size="mini" type="danger" @click="dataDetails(item.device_id,item.device_name,item.address)">数据详情</el-button>
-								</p>
-							</div>
-						</equip-item>
-					</el-card>
-				</el-col>
-			</el-row>
-		</template>
-		<template v-if="displayType==2">
-			<el-card class="box-card" v-loading="tableLoading">
-				<el-table :data="equipList" stripe style="width: 100%">
-					<el-table-column prop="device_id" label="设备ID" width="180">
-						<template slot-scope="scope">{{scope.row.device_id}}</template>
-					</el-table-column>
-					<el-table-column prop="device_name" label="设备名称" width="180">
-						<template slot-scope="scope">{{scope.row.device_name==""?"无":scope.row.device_name}}</template>
-					</el-table-column>
-					<el-table-column prop="device_status" label="在线状态">
-						<template slot-scope="scope">
-							<p style="color:#17bb89" v-if="scope.row.device_status==1">在线</p>
-							<p style="color:#eb6765" v-if="scope.row.device_status==0">离线</p>
-						</template>
-					</el-table-column>
-					<el-table-column prop="address" label="地址"></el-table-column>
-					<el-table-column prop="status_time" label="最新上报时间">
-						<template slot-scope="scope">{{scope.row.status_time}}</template>
-					</el-table-column>
-					<el-table-column label="操作" width="400">
-						<template slot-scope="scope">
-							<el-button size="mini" type="info" @click="viewPhotoDialog(scope.row.device_id,scope.row.d_id)">查看图片</el-button>
-							<el-button size="mini" type="warning" @click="EquipControl(scope.row.d_id)">设备控制</el-button>
-							<el-button
-								size="mini"
-								type="success"
-								@click="showTimeControlDialog(scope.row.device_id,scope.row.device_name,scope.row.address)"
-							>害虫统计</el-button>
-							<el-button
-								size="mini"
-								type="danger"
-								@click="dataDetails(scope.row.device_id,scope.row.device_name,scope.row.address)"
-							>数据详情</el-button>
-						</template>
-					</el-table-column>
-				</el-table>
-			</el-card>
-		</template>
-		<!-- 暂无数据 -->
-		<div class="expertDiagnosis_referral_units_not" v-if="equipList.length<=0 && displayType==1">
-			<img
-				src="@/assets/images/zanwu.png"
-				alt
-				class="expertDiagnosis_referral_units_notImg"
-			/>
+		<div v-loading="tableLoading">
+			<template v-if="displayType==1">
+				<el-row :gutter="10">
+					<el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="6" v-for="item in equipList" :key="item.imei">
+						<el-card class="box-card">
+							<equip-item :is_online="item.device_status">
+								
+								<span slot="title">虫情测报</span>
+								<div slot="content" class="content">
+									<p>
+										<i class="iconfont icon-yonghu"></i>
+										设备ID:{{item.device_id}}
+									</p>
+									<p>
+										<i class="iconfont icon-biaoqian"></i>
+										设备名称:{{item.device_name==""?"无":item.device_name}}
+									</p>
+									<p>
+										<i class="iconfont icon-diannao"></i>在线状态:
+										<span
+											:class="{red:item.device_status==0,green:item.device_status==1}"
+										>{{item.device_status==0?"离线":"在线"}}</span>
+									</p>
+									<p>
+										<i class="iconfont icon-shijian"></i>
+										最新上报时间 : {{item.status_time}}
+									</p>
+									<p>
+										<i class="iconfont icon-dizhi"></i>
+										地址 : {{item.address || "无"}}
+									</p>
+									<p class="btns">
+										<i class="iconfont icon-yemiancaozuo"></i>
+										<el-button size="mini" type="info" @click="viewPhotoDialog(item.device_id,item.d_id)">查看图片</el-button>
+										<el-button size="mini" type="warning" @click="EquipControl(item.device_id)">设备控制</el-button>
+										<!-- <el-button size="mini" type="success" v-if="item.disc==1" @click="showTimeControlDialog(item.device_id)">害虫统计</el-button> -->
+										<el-button size="mini" type="success" @click="showTimeControlDialog(item.device_id,item.device_name,item.address)">害虫统计</el-button>
+										<el-button size="mini" type="danger" @click="dataDetails(item.device_id,item.device_name,item.address)">数据详情</el-button>
+									</p>
+								</div>
+							</equip-item>
+						</el-card>
+					</el-col>
+				</el-row>
+			</template>
+			<template v-if="displayType==2">
+				<el-card class="box-card" >
+					<el-table :data="equipList" stripe style="width: 100%">
+						<el-table-column prop="device_id" label="设备ID" width="180">
+							<template slot-scope="scope">{{scope.row.device_id}}</template>
+						</el-table-column>
+						<el-table-column prop="device_name" label="设备名称" width="180">
+							<template slot-scope="scope">{{scope.row.device_name==""?"无":scope.row.device_name}}</template>
+						</el-table-column>
+						<el-table-column prop="device_status" label="在线状态">
+							<template slot-scope="scope">
+								<p style="color:#17bb89" v-if="scope.row.device_status==1">在线</p>
+								<p style="color:#eb6765" v-if="scope.row.device_status==0">离线</p>
+							</template>
+						</el-table-column>
+						<el-table-column prop="address" label="地址"></el-table-column>
+						<el-table-column prop="status_time" label="最新上报时间">
+							<template slot-scope="scope">{{scope.row.status_time}}</template>
+						</el-table-column>
+						<el-table-column label="操作" width="400">
+							<template slot-scope="scope">
+								<el-button size="mini" type="info" @click="viewPhotoDialog(scope.row.device_id,scope.row.d_id)">查看图片</el-button>
+								<el-button size="mini" type="warning" @click="EquipControl(scope.row.d_id)">设备控制</el-button>
+								<el-button
+									size="mini"
+									type="success"
+									@click="showTimeControlDialog(scope.row.device_id,scope.row.device_name,scope.row.address)"
+								>害虫统计</el-button>
+								<el-button
+									size="mini"
+									type="danger"
+									@click="dataDetails(scope.row.device_id,scope.row.device_name,scope.row.address)"
+								>数据详情</el-button>
+							</template>
+						</el-table-column>
+					</el-table>
+				</el-card>
+			</template>
+			<!-- 暂无数据 -->
+			<div class="expertDiagnosis_referral_units_not" v-if="equipList.length<=0 && displayType==1">
+				<img
+					src="@/assets/images/zanwu.png"
+					alt
+					class="expertDiagnosis_referral_units_notImg"
+				/>
+			</div>
 		</div>
 		</div>
+		
+		
 		<el-pagination
 		<el-pagination
 			v-if="equipList.length>0"
 			v-if="equipList.length>0"
 			background
 			background
@@ -247,7 +251,7 @@ export default {
 			//设备列表
 			//设备列表
 			equipList: [],
 			equipList: [],
 			// 设备加载loading
 			// 设备加载loading
-			tableLoading : true,
+			tableLoading : false,
 			pageLoading:false,
 			pageLoading:false,
 			device_id: '',
 			device_id: '',
 			currid:'',//选中配置设备id
 			currid:'',//选中配置设备id
@@ -304,6 +308,7 @@ export default {
 		},
 		},
 		//获取设备列表
 		//获取设备列表
 		getEquipList() {
 		getEquipList() {
+			this.tableLoading = true;
 			this.$axios({
 			this.$axios({
 				method: 'POST',
 				method: 'POST',
 				url: '/api/equipmanage_cbd',
 				url: '/api/equipmanage_cbd',
@@ -332,6 +337,9 @@ export default {
 					this.equipList = dataArr
 					this.equipList = dataArr
 					this.totalNum = res.data.nums
 					this.totalNum = res.data.nums
 				}
 				}
+			},error =>{
+				this.dataloading = false
+				this.$message.error('获取失败')
 			})
 			})
 		},
 		},
 		//改变page
 		//改变page

+ 1 - 1
bigdata2/src/router/index.js

@@ -109,7 +109,7 @@ export default new Router({
         component: Scd
         component: Scd
       },
       },
       {
       {
-        path: 'scdDetail/:e_id/:d_id',
+        path: 'scdDetail',
         component: ScdDetail
         component: ScdDetail
       },
       },
     ]
     ]

BIN
bigdata2/static/images/cure/scd/stateIcon/1.png


BIN
bigdata2/static/images/cure/scd/stateIcon/10.png


BIN
bigdata2/static/images/cure/scd/stateIcon/11.png


BIN
bigdata2/static/images/cure/scd/stateIcon/12.png


BIN
bigdata2/static/images/cure/scd/stateIcon/2.png


BIN
bigdata2/static/images/cure/scd/stateIcon/3.png


BIN
bigdata2/static/images/cure/scd/stateIcon/4.png


BIN
bigdata2/static/images/cure/scd/stateIcon/5.png


BIN
bigdata2/static/images/cure/scd/stateIcon/6.png


BIN
bigdata2/static/images/cure/scd/stateIcon/7.png


BIN
bigdata2/static/images/cure/scd/stateIcon/8.png


BIN
bigdata2/static/images/cure/scd/stateIcon/9.png