Commit 80b92e88 authored by yating.lin's avatar yating.lin

牛舍历史数据

parent a8ade56b
...@@ -109,14 +109,7 @@ export class EnvDetailPage implements OnInit { ...@@ -109,14 +109,7 @@ export class EnvDetailPage implements OnInit {
} }
toHistory(item) { toHistory(item) {
this.tf.transfer({url: '/env-history'}); const query = 'env-history?no=' + item.fieldRegionNo;
const query = '?no=' + item.fieldRegionNo;
this.tf.transfer({
url: '/env-history',
query: query,
hash: ''
});
this.nav.navigateForward(query); this.nav.navigateForward(query);
} }
} }
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<ion-card-content> <ion-card-content>
<!--<ion-toggle slot="middle" [checked]="device.state"></ion-toggle>--> <!--<ion-toggle slot="middle" [checked]="device.state"></ion-toggle>-->
<v-switch class="btn-switch" (click)="deviceCheck(device)" [value]="device.op" [disabled]="device.disabled" [loading]="device.load"></v-switch> <v-switch class="btn-switch" (click)="deviceCheck(device)" [value]="device.state" [disabled]="device.disabled" [loading]="device.load"></v-switch>
</ion-card-content> </ion-card-content>
</ion-card> </ion-card>
</div> </div>
......
...@@ -8,5 +8,5 @@ ...@@ -8,5 +8,5 @@
.btn-switch { .btn-switch {
float: none; float: none;
display: inline-block; display: inline-block;
margin-top: 5px margin-top: 5px;
} }
...@@ -20,7 +20,7 @@ export class EnvFanPage implements OnInit { ...@@ -20,7 +20,7 @@ export class EnvFanPage implements OnInit {
// 各设备信息 // 各设备信息
devices = []; devices = [];
// 一鍵控制按钮(默认开启:1) // 一鍵控制按钮
batchSwitch = {op: undefined, type: undefined, load: undefined, disabled: undefined}; batchSwitch = {op: undefined, type: undefined, load: undefined, disabled: undefined};
controlModelOptions = [ controlModelOptions = [
...@@ -87,7 +87,6 @@ export class EnvFanPage implements OnInit { ...@@ -87,7 +87,6 @@ export class EnvFanPage implements OnInit {
} }
// 一键控制 // 一键控制
allCheck(btn) { allCheck(btn) {
debugger;
btn.load = true; btn.load = true;
const req = { const req = {
fieldRegionNo: this.fieldRegionNo, fieldRegionNo: this.fieldRegionNo,
...@@ -117,9 +116,10 @@ export class EnvFanPage implements OnInit { ...@@ -117,9 +116,10 @@ export class EnvFanPage implements OnInit {
// 单个设备控制 // 单个设备控制
deviceCheck(btn) { deviceCheck(btn) {
btn.loading = true;
const req = { const req = {
fieldDeviceNo: btn.fieldDeviceNo, fieldDeviceNo: btn.fieldDeviceNo,
op: btn.op ? 0 : 1, op: btn.state ? 0 : 1,
ts: parseInt((new Date().getTime() / 1000).toString(), 10) ts: parseInt((new Date().getTime() / 1000).toString(), 10)
}; };
this.comm.remain = 20; this.comm.remain = 20;
......
...@@ -6,6 +6,8 @@ import { Routes, RouterModule } from '@angular/router'; ...@@ -6,6 +6,8 @@ import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular'; import { IonicModule } from '@ionic/angular';
import { EnvHistoryPage } from './env-history.page'; import { EnvHistoryPage } from './env-history.page';
import {NgxDatatableModule} from '@swimlane/ngx-datatable';
import {NgxEchartsCoreModule} from 'ngx-echarts/core';
const routes: Routes = [ const routes: Routes = [
{ {
...@@ -19,7 +21,9 @@ const routes: Routes = [ ...@@ -19,7 +21,9 @@ const routes: Routes = [
CommonModule, CommonModule,
FormsModule, FormsModule,
IonicModule, IonicModule,
RouterModule.forChild(routes) RouterModule.forChild(routes),
NgxDatatableModule,
NgxEchartsCoreModule
], ],
declarations: [EnvHistoryPage] declarations: [EnvHistoryPage]
}) })
......
...@@ -4,7 +4,47 @@ ...@@ -4,7 +4,47 @@
</ion-toolbar> </ion-toolbar>
</ion-header> </ion-header>
<ion-content> <ion-content color='light' style="height: 100%">
<h1 style="
font-size: 16px;
padding-left: 5px;
border-left: 5px solid #28c9bd;
line-height: 25px;
margin-bottom: 5px;">牛舍热应激状态</h1> <span [ngClass]="{'perfect': analResult === '优','good': analResult === '良','bad': analResult === '差'}">{{analResult}}</span>
<h1 style="
font-size: 16px;
padding-left: 5px;
border-left: 5px solid #28c9bd;
line-height: 25px;
margin-bottom: 5px;">近8个小时环境参数曲线</h1>
<div echarts [options]="chartOption" class="demo-chart"></div>
<h1 style="
font-size: 16px;
padding-left: 5px;
border-left: 5px solid #28c9bd;
line-height: 25px;
margin-bottom: 5px;">近8个小时环境参数表</h1>
<div>
<ngx-datatable class='material' [rows]="rows" [columnMode]="'force'" [scrollbarH]="true"[scrollbarV]="true" style="white-space: nowrap; ">
<ngx-datatable-column name="时间" prop="time" width="100">
</ngx-datatable-column>
<ngx-datatable-column name="热应激" prop="thi" width="60">
</ngx-datatable-column>
<ngx-datatable-column name="温度" prop="temp" width="80">
</ngx-datatable-column>
<ngx-datatable-column name="湿度" prop="humi" width="80">
</ngx-datatable-column>
<ngx-datatable-column name="光照" prop="AA" width="80">
</ngx-datatable-column>
<ngx-datatable-column name="风机" prop="BB" width="80">
</ngx-datatable-column>
<ngx-datatable-column name="喷淋" prop="CC" width="80">
</ngx-datatable-column>
<ngx-datatable-column name="照明" prop="DD" width="80">
</ngx-datatable-column>
</ngx-datatable>
</div>
</ion-content> </ion-content>
@import '~@swimlane/ngx-datatable/release/index.css';
@import '~@swimlane/ngx-datatable/release/themes/material.css';
@import '~@swimlane/ngx-datatable/release/assets/icons.css';
.perfect{
width: 30px;
height: 30px;
background-color:green;
border-radius: 17%;
-moz-border-radius: 17%;
-webkit-border-radius: 17%;
font-size: 25px;
color:white;
}
.good {
width: 30px;
height: 30px;
background-color:yellow;
border-radius: 17%;
-moz-border-radius: 17%;
-webkit-border-radius: 17%;
font-size: 25px;
color:white;
}
.bad {
width: 30px;
height: 30px;
background-color:red;
border-radius: 17%;
-moz-border-radius: 17%;
-webkit-border-radius: 17%;
font-size: 25px;
color:white;
}
.demo-chart{
width: 100%;
height: 230px;
}
.title{
text-align: center;
padding-left: 0px
}
...@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core'; ...@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {Api} from '../../service/api'; import {Api} from '../../service/api';
import {Load} from '../../service/load'; import {Load} from '../../service/load';
import { NgxDatatableModule } from '@swimlane/ngx-datatable';
@Component({ @Component({
selector: 'v-env-history', selector: 'v-env-history',
...@@ -13,11 +14,78 @@ export class EnvHistoryPage implements OnInit { ...@@ -13,11 +14,78 @@ export class EnvHistoryPage implements OnInit {
constructor(private api: Api, private ac: ActivatedRoute, private load: Load) { } constructor(private api: Api, private ac: ActivatedRoute, private load: Load) { }
item = {fieldRegionNo: ''}; item = {fieldRegionNo: ''};
// TODO 以下为假数据 待删除
analResult = '优';
chartOption = {
backgroundColor: '#F0F8FF',
visualMap: [{
show: false,
type: 'continuous',
seriesIndex: 0,
min: 0,
max: 400},
{
show: false,
type: 'continuous',
seriesIndex: 1,
dimension: 0,
min: 0,
max: 400
}],
xAxis: {
name: '时间',
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: [{
name: '温度(℃)',
type: 'value',
splitLine: {show: false}
},
{
name: '湿度(%)',
type: 'value',
max: 100,
splitLine: {show: false}
}],
series: [{
data: [28, 32, 35, 34, 30, 29, 27],
type: 'line'
},{
data: [15, 13, 12, 11, 12, 11, 87],
yAxisIndex: 1,
type: 'line'
},{
data: [76, 45, 43, 23, 34, 54, 23],
yAxisIndex: 1,
type: 'line'
}]
};
// 时间 热应激 温度 湿度 光照 风机 喷淋 照明
rows = [
{ time: '17:00', thi: '轻', temp: '23.8', humi: '56', AA: '70', BB: '55%', CC: 'O', DD: 'X'},
{ time: '17:30', thi: '中', temp: '27.2', humi: '43', AA: '80', BB: '55%', CC: 'X', DD: 'O' },
{ time: '18:00', thi: '轻', temp: '23.2', humi: '61', AA: '99', BB: '55%', CC: 'O', DD: 'X' },
{ time: '18:30', thi: '轻', temp: '23.1', humi: '47', AA: '100', BB: '55%', CC: 'X', DD: 'O'},
{ time: '19:00', thi: '轻', temp: '20.2', humi: '43', AA: '60', BB: '55%', CC: 'O', DD: 'X' },
{ time: '19:30', thi: '轻', temp: '21.6', humi: '34', AA: '50', BB: '55%', CC: 'O', DD: 'X' },
{ time: '20:00', thi: '轻', temp: '22.5', humi: '43', AA: '40', BB: '55%', CC: 'X', DD: 'O' },
];
ngOnInit() { ngOnInit() {
this.ac.queryParams.subscribe((data) => { this.ac.queryParams.subscribe((data) => {
this.item.fieldRegionNo = data.no; this.item.fieldRegionNo = data.no;
}); });
this.getData(0); this.getData(0);
// TODO 待删除
for (let i = 0; i < 8; i ++) {
this.chartOption.xAxis.data = ['8', '7', '6', '5', '4', '3', '2', '1'];
}
} }
getData(time) { getData(time) {
......
...@@ -6,6 +6,7 @@ import { Routes, RouterModule } from '@angular/router'; ...@@ -6,6 +6,7 @@ import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular'; import { IonicModule } from '@ionic/angular';
import { EnvLightPage } from './env-light.page'; import { EnvLightPage } from './env-light.page';
import { WtModule } from '../../components/wt/wt.module';
const routes: Routes = [ const routes: Routes = [
{ {
...@@ -19,7 +20,8 @@ const routes: Routes = [ ...@@ -19,7 +20,8 @@ const routes: Routes = [
CommonModule, CommonModule,
FormsModule, FormsModule,
IonicModule, IonicModule,
RouterModule.forChild(routes) RouterModule.forChild(routes),
WtModule
], ],
declarations: [EnvLightPage] declarations: [EnvLightPage]
}) })
......
...@@ -32,9 +32,10 @@ ...@@ -32,9 +32,10 @@
border-left: 5px solid #28c9bd; border-left: 5px solid #28c9bd;
line-height: 25px; line-height: 25px;
margin-bottom: 5px;">控制/状态</h1> margin-bottom: 5px;">控制/状态</h1>
<ion-item *ngIf="batchSwitch" lines="full" insert="false"> <ion-item *ngIf="devices" lines="full" insert="false">
<ion-label>一键控制</ion-label> <ion-label>一键控制</ion-label>
<ion-toggle slot="end" [checked]="batchSwitch.op"></ion-toggle> <!-- <ion-toggle slot="end" [checked]="batchSwitch.op"></ion-toggle>-->
<v-switch (click)="allCheck(batchSwitch)" [value]="batchSwitch.op" [disabled]="batchSwitch.disabled" [loading]="batchSwitch.load"></v-switch>
</ion-item> </ion-item>
<div> <div>
<ion-card *ngFor="let device of devices" class="card" color="white"> <ion-card *ngFor="let device of devices" class="card" color="white">
...@@ -43,25 +44,10 @@ ...@@ -43,25 +44,10 @@
</ion-card-header> </ion-card-header>
<ion-card-content> <ion-card-content>
<ion-toggle slot="middle" [checked]="device.state"></ion-toggle> <!-- <ion-toggle slot="middle" [checked]="device.state"></ion-toggle>-->
<v-switch class="btn-switch" (click)="deviceCheck(device)" [value]="device.state" [disabled]="device.disabled" [loading]="device.load"></v-switch>
</ion-card-content> </ion-card-content>
</ion-card> </ion-card>
</div> </div>
<!--<ion-item *ngIf="batchSwitch" lines="full" insert="false">-->
<!--<ion-label>一键控制</ion-label>-->
<!--<ion-toggle slot="end" [checked]="batchSwitch.op"></ion-toggle>-->
<!--</ion-item>-->
<!--<div>-->
<!--<ion-card *ngFor="let a of workarea.param" class="card" color="white">-->
<!--<ion-card-header>-->
<!--<ion-card-subtitle>{{a.name}}</ion-card-subtitle>-->
<!--</ion-card-header>-->
<!--<ion-card-content>-->
<!--<v-switch [value]="a.runningState" (click)="toggle(a)" style="float: none;display: inline-block;margin-top: 5px"></v-switch>-->
<!--</ion-card-content>-->
<!--</ion-card>-->
<!--</div>-->
</ion-content> </ion-content>
...@@ -12,4 +12,10 @@ i.vo { ...@@ -12,4 +12,10 @@ i.vo {
margin: 10px 10px 5px 5px; margin: 10px 10px 5px 5px;
} }
.btn-switch {
float: none;
display: inline-block;
margin-top: 5px;
}
...@@ -9,8 +9,6 @@ import {Load} from '../../service/load'; ...@@ -9,8 +9,6 @@ import {Load} from '../../service/load';
styleUrls: ['./env-light.page.scss'], styleUrls: ['./env-light.page.scss'],
}) })
export class EnvLightPage implements OnInit { export class EnvLightPage implements OnInit {
// @Input() fieldRegionNo: string;
/* 照明 */ /* 照明 */
// 牧场区域编号 // 牧场区域编号
fieldRegionNo = ''; fieldRegionNo = '';
...@@ -32,65 +30,35 @@ export class EnvLightPage implements OnInit { ...@@ -32,65 +30,35 @@ export class EnvLightPage implements OnInit {
// 各设备信息 // 各设备信息
devices = []; devices = [];
// 一鍵控制信息 // 一鍵控制信息
batchSwitch = {op: 0, type: '照明'}; batchSwitch = {op: undefined, type: undefined, load: undefined, disabled: undefined};
controlModelOptions = [ controlModelOptions = [
{modelId: 0, modelValue: '手控模式'}, {modelId: 0, modelValue: '手控模式'},
{modelId: 1, modelValue: '自控模式'}, {modelId: 1, modelValue: '自控模式'},
{modelId: 2, modelValue: '智慧控制'}]; {modelId: 2, modelValue: '智慧控制'}];
// workModeSetting = { 'workMode' : '1',
// 'DeviceNo' : '',
// 'workModeOld' : '1'};
// 发送指令延时判断 // 发送指令延时判断
comm = { comm = {
remain : 20, remain: 20,
isLoading : true isLoading: true
}; };
// allBtns = [{v: 1}]; constructor(private api: Api, private ac: ActivatedRoute, private load: Load, private route: ActivatedRoute) {
// fieldRegionNo = ''; }
// fieldRegionName = '';
lightMode = {
name: 'July',
openTime: '19:00',
closeTime: '05:00'};
// workarea = {
// param: [
// {
// name: '1号组',
// runningState: true,
// },
// {
// name: '2号组',
// runningState:false,
// }
// ]
// };
constructor(private api: Api, private ac: ActivatedRoute, private load: Load, private route: ActivatedRoute) { }
ngOnInit() { ngOnInit() {
// this.ac.queryParams.subscribe((data) => { this.route.paramMap.subscribe(params => {
// this.fieldRegionNo = data.no; this.fieldRegionNo = params.get('fieldRegionNo');
// }); });
this.route.paramMap.subscribe(params => {this.fieldRegionNo = params.get('fieldRegionNo'); });
this.getData(0); this.getData(0);
} }
toggle(a) {
console.log('123');
}
getData(time) { getData(time) {
this.curDate = +new Date().getMonth(); this.curDate = +new Date().getMonth();
if (time) { if (time) {
this.load.toLoad('加载中...', false); this.load.toLoad('加载中...', false);
} }
this.api.cowshedApp.getZhaoMingData([{'fieldRegionNo' : this.fieldRegionNo}, (data) => { this.api.cowshedApp.getZhaoMingData([{'fieldRegionNo': this.fieldRegionNo}, (data) => {
if (data) { if (data) {
this.fieldRegionNo = data.fieldRegionNo; this.fieldRegionNo = data.fieldRegionNo;
this.fieldDeviceType = data.fieldDeviceType; this.fieldDeviceType = data.fieldDeviceType;
...@@ -109,41 +77,81 @@ export class EnvLightPage implements OnInit { ...@@ -109,41 +77,81 @@ export class EnvLightPage implements OnInit {
// this.controlModel = 2; // this.controlModel = 2;
this.on = '19:00'; this.on = '19:00';
this.off = '05:00'; this.off = '05:00';
// this.devices = [{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'A号照明组', state: 1}, this.devices = [{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'A号照明组', state: 1},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'B号照明组', state: 0}, {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'B号照明组', state: 0},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'C号照明组', state: 1}, {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'C号照明组', state: 1},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'D号照明组', state: 0}, {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'D号照明组', state: 0},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'E号照明组', state: 1}, {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'E号照明组', state: 1},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'F号照明组', state: 1}]; {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'F号照明组', state: 1}];
// 获取一键控制信息 // [智控(2)]的状态下:非活性(true) 以外:活性(false)
this.allCheck(this.batchSwitch); const allDisabled = this.controlModel === 2 ? true : false;
this.batchSwitch.disabled = allDisabled;
this.devices.forEach((device, i) => {
device.disabled = allDisabled;
});
// 设置[一键控制]按钮(默认: 开启)
// 当任意子按钮[关闭]的状态下: 关闭 以外:开启
this.batchSwitch.op = 1;
this.devices.map((device) => {
if (device.state === 0) {
this.batchSwitch.op = 0;
}
});
} }
}]); }]);
} }
allCheck(batchSwitch) { // 一键控制
batchSwitch.type = this.fieldDeviceType; allCheck(btn) {
btn.load = true;
const req = { const req = {
fieldRegionNo: this.fieldRegionNo, fieldRegionNo: this.fieldRegionNo,
op: batchSwitch.op, // op: batchSwitch.op ? 0 : 1, op: btn.op ? 0 : 1,
fieldDeviceType: batchSwitch.type, type: this.fieldDeviceType,
ts: parseInt((new Date().getTime() / 1000).toString(), 10) ts: parseInt((new Date().getTime() / 1000).toString(), 10)
}; };
this.comm.remain = 120; this.comm.remain = 120;
// 一键开启设备
this.api.control.controlBatchSwitch([req, (data) => { this.api.control.controlBatchSwitch([req, (data) => {
if (data.code === 1) { if (data.code === 1) {
this.batchSwitch.op = data.op; this.getData(1);
this.api.presentMsgToast(data.message); this.api.presentMsgToast(data.message);
} else { } else {
this.api.presentMsgToast(data.message); this.api.presentMsgToast(data.message);
} }
this.comm.remain = 0; this.comm.remain = 0;
// batchSwitch.state = false; btn.load = false;
}]);
// 子按钮状态
this.devices.forEach((device, i) => {
device.state = btn.op ? 0 : 1;
});
}
// 单个设备控制
deviceCheck(btn) {
btn.loading = true;
const req = {
fieldDeviceNo: btn.fieldDeviceNo,
op: btn.state ? 0 : 1,
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
this.comm.remain = 20;
this.api.control.controlSwitch([req, (data) => {
if (data && data.code === 1) {
this.getData(1);
this.comm.remain = 0;
this.api.presentMsgToast(data.message);
} else {
this.comm.remain = 0;
this.api.presentMsgToast(data.message);
}
btn.loading = false;
}]); }]);
// TODO 测试用准备数据
// this.batchSwitch.op = 0;
} }
} }
...@@ -6,6 +6,7 @@ import { Routes, RouterModule } from '@angular/router'; ...@@ -6,6 +6,7 @@ import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular'; import { IonicModule } from '@ionic/angular';
import { EnvShowerPage } from './env-shower.page'; import { EnvShowerPage } from './env-shower.page';
import { WtModule } from '../../components/wt/wt.module';
const routes: Routes = [ const routes: Routes = [
{ {
...@@ -19,7 +20,8 @@ const routes: Routes = [ ...@@ -19,7 +20,8 @@ const routes: Routes = [
CommonModule, CommonModule,
FormsModule, FormsModule,
IonicModule, IonicModule,
RouterModule.forChild(routes) RouterModule.forChild(routes),
WtModule
], ],
declarations: [EnvShowerPage] declarations: [EnvShowerPage]
}) })
......
...@@ -57,7 +57,8 @@ ...@@ -57,7 +57,8 @@
<ion-card-content style="margin: 0px; padding-top:0px;"> <ion-card-content style="margin: 0px; padding-top:0px;">
<span class="content">压力 {{a.press}} MPa</span><br> <span class="content">压力 {{a.press}} MPa</span><br>
<ion-toggle [checked]="a.state"></ion-toggle> <!-- <ion-toggle [checked]="a.state"></ion-toggle>-->
<v-switch class="btn-switch" (click)="deviceCheck(a)" [value]="a.state" [loading]="a.load"></v-switch>
</ion-card-content> </ion-card-content>
</ion-card> </ion-card>
</div> </div>
......
...@@ -13,3 +13,9 @@ ...@@ -13,3 +13,9 @@
.content { .content {
font-size: 13px; font-size: 13px;
} }
.btn-switch {
float: none;
display: inline-block;
margin-top: 5px;
}
...@@ -67,4 +67,25 @@ export class EnvShowerPage implements OnInit { ...@@ -67,4 +67,25 @@ export class EnvShowerPage implements OnInit {
}]); }]);
} }
// 单个设备控制
deviceCheck(btn) {
const req = {
fieldDeviceNo: btn.fieldDeviceNo,
op: btn.state ? 0 : 1,
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
this.comm.remain = 20;
this.api.control.controlSwitch([req, (data) => {
if (data && data.code === 1) {
this.getData(1);
this.comm.remain = 0;
this.api.presentMsgToast(data.message);
} else {
this.comm.remain = 0;
this.api.presentMsgToast(data.message);
}
btn.loading = false;
}]);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment