Commit 6bcbbc68 authored by yating.lin's avatar yating.lin

接口调试

parent e2d344a5
......@@ -59,7 +59,7 @@
<div style="padding:5px;">
<div class="detailContent">
<div class="timeline" *ngIf="detailInfo.trouble">
<div class="timeline" *ngIf="detailInfoLength > 0">
<div class="entry" *ngFor="let item of detailInfo.trouble">
<div class="title">
<div><img [src]="'../../assets/img/' + item.fieldDeviceType + '.png'" class="deviceIcon"></div>
......
......@@ -19,6 +19,7 @@ export class EnvAlarmDetailPage implements OnInit {
fieldRegionGroup = '';
detailInfo: any = {};
detailInfoLength = 0;
disposeState = '';
fieldDeviceType = '';
startTime = null;
......@@ -76,6 +77,7 @@ export class EnvAlarmDetailPage implements OnInit {
getTroubleList() {
if (this.displayArea === 'trouble') {
this.isTroubleDis = true;
this.detailInfo = {};
const req = {
fieldRegionNo: this.fieldRegionNo,
......@@ -91,65 +93,13 @@ export class EnvAlarmDetailPage implements OnInit {
req.fieldDeviceType = this.fieldDeviceType;
}
this.api.troubleLog.getByTerm([req, (data) => {
// START---------------------------------------------------------
// TODO 测试用数据
// data = {
// fieldRegionNo: 'FRN110268534764224512',
// fieldRegionName: '1号牛舍',
// startTime: 1565165000000,
// stopTime: 156516501230000,
// devErr: 11,
// devErrTotal: 33,
// trouble: [{
// troubleLogNo: '123415646196875456',
// fieldDeviceName: '一号风机组',
// fieldDeviceType: '风机',
// description: '一号风机组故障',
// troubleTime: 1565165000000,
// data: {liquidPump: 25, press: 50},
// disposeState: 0
// }, {
// troubleLogNo: '123415646196875456',
// fieldDeviceName: '一号风机组',
// fieldDeviceType: '风机',
// description: '一号风机组故障',
// troubleTime: 1565165000000,
// data: {liquidPump: 25, press: 50},
// disposeState: 0
// }, {
// troubleLogNo: '123415646196875456',
// fieldDeviceName: '一号风机组',
// fieldDeviceType: '风机',
// description: '一号风机组故障',
// troubleTime: 1565165000000,
// data: {liquidPump: 25, press: 50},
// disposeState: 0
// }, {
// troubleLogNo: '123415646196875456',
// fieldDeviceName: '一号风机组',
// fieldDeviceType: '风机',
// description: '一号风机组故障',
// troubleTime: 1565165000000,
// data: {liquidPump: 25, press: 50},
// disposeState: 0
// }, {
// troubleLogNo: '123415646196875456',
// fieldDeviceName: '一号风机组',
// fieldDeviceType: '风机',
// description: '一号风机组故障',
// troubleTime: 1565165000000,
// data: {liquidPump: 25, press: 50},
// disposeState: 0
// }]
// };
// END--------------------------------------------------------
this.detailInfo = data;
if (data.trouble && data.trouble.constructor === Array) {
data.trouble.forEach((value) => {
value.troubleTime = this.api.formatTime('yyyy-MM-dd hh:mm:ss', new Date(value.troubleTime));
});
this.detailInfo.trouble = data.trouble;
this.detailInfoLength = data.trouble.length();
}
}]);
}
......@@ -157,6 +107,7 @@ export class EnvAlarmDetailPage implements OnInit {
getAlarmList() {
if (this.displayArea === 'alarm') {
this.isAlarmDis = true;
this.detailInfo = {};
const req = {
fieldRegionNo: this.fieldRegionNo,
......@@ -172,65 +123,13 @@ export class EnvAlarmDetailPage implements OnInit {
req.fieldDeviceType = this.fieldDeviceType;
}
this.api.alarm.getCowshedAlarm([req, (data) => {
// START---------------------------------------------------------
// TODO 测试用数据
// data = {
// fieldRegionNo: 'FRN110268534764224512',
// fieldRegionName: '1号牛舍',
// startTime: 1565165000000,
// stopTime: 156516501230000,
// alarm: 22,
// alarmTotal: 44,
// trouble: [{
// alarmLogNo: '123415646196875456',
// fieldDeviceName: '一号风机组',
// fieldDeviceType: '风机',
// description: '温度偏高',
// data: {temp: 25, humid: 50, heatStressLevel: '轻度', liquidPump: 25, press: 50, NH3: 50},
// alarmTime: 1565165000000,
// disposeState: 0
// }, {
// alarmLogNo: '123415646196875456',
// fieldDeviceName: '一号风机组',
// fieldDeviceType: '风机',
// description: '温度偏高',
// data: {temp: 25, humid: 50, heatStressLevel: '轻度', liquidPump: 25, press: 50, NH3: 50},
// alarmTime: 1565165000000,
// disposeState: 0
// }, {
// alarmLogNo: '123415646196875456',
// fieldDeviceName: '一号风机组',
// fieldDeviceType: '风机',
// description: '温度偏高',
// data: {temp: 25, humid: 50, heatStressLevel: '轻度', liquidPump: 25, press: 50, NH3: 50},
// alarmTime: 1565165000000,
// disposeState: 0
// }, {
// alarmLogNo: '123415646196875456',
// fieldDeviceName: '一号风机组',
// fieldDeviceType: '风机',
// description: '温度偏高',
// data: {temp: 25, humid: 50, heatStressLevel: '轻度', liquidPump: 25, press: 50, NH3: 50},
// alarmTime: 1565165000000,
// disposeState: 0
// }, {
// alarmLogNo: '123415646196875456',
// fieldDeviceName: '一号风机组',
// fieldDeviceType: '风机',
// description: '温度偏高',
// data: {temp: 25, humid: 50, heatStressLevel: '轻度', liquidPump: 25, press: 50, NH3: 50},
// alarmTime: 1565165000000,
// disposeState: 0
// }]
// };
// END---------------------------------------------------------
this.detailInfo = data;
if (data.trouble && data.trouble.constructor === Array) {
data.trouble.forEach((value) => {
value.troubleTime = this.api.formatTime('yyyy-MM-dd hh:mm:ss', new Date(value.alarmTime));
});
this.detailInfo.trouble = data.trouble;
this.detailInfoLength = data.trouble.length();
}
}]);
}
......
......@@ -61,14 +61,14 @@
<ion-col>
<ion-item class="fanItem">
<ion-label position="fixed">开启温度</ion-label>
<ion-input class="inputText" (ionFocus)="tempHaveTouch($event)" [(ngModel)]="fan.controlConfig.TU"></ion-input>
<ion-input class="inputText" (ionFocus)="tempHaveTouch($event)" [(ngModel)]="fan.controlConfig.config.TU"></ion-input>
<ion-label position="fixed"></ion-label>
</ion-item>
</ion-col>
<ion-col>
<ion-item class="fanItem">
<ion-label position="fixed">关闭温度</ion-label>
<ion-input class="inputText" (ionFocus)="tempHaveTouch($event)" [(ngModel)]="fan.controlConfig.TL"></ion-input>
<ion-input class="inputText" (ionFocus)="tempHaveTouch($event)" [(ngModel)]="fan.controlConfig.config.TL"></ion-input>
<ion-label position="fixed"></ion-label>
</ion-item>
</ion-col>
......@@ -234,14 +234,15 @@
<ion-item class="timepickerItem" lines="none">
<ion-label style="width:80px">日期范围</ion-label>
<!--<ion-input placeholder={{cfg.startTime}} (ionFocus)="tempHaveTouch()" style="width:50px;"></ion-input>-->
<ion-datetime class="inputDateTime timepicker" [(ngModel)]="waterChannel.controlConfig.config.startDate" displayFormat="MM-DD" cancelText="取消" doneText="确认"></ion-datetime>
<ion-datetime class="inputDateTime timepicker" [(ngModel)]="waterChannel.controlConfig.config.startDate"
[displayFormat]="'MM-DD'" cancelText="取消" doneText="确认"></ion-datetime>
</ion-item>
</ion-col>
<ion-col size="auto" style="font-size: 13px;">
<ion-item class="timepickerItem" lines="none">
<ion-label style="width:60px">~</ion-label>
<!--<ion-input placeholder={{cfg.endTime}} (ionFocus)="tempHaveTouch()" style="width:50px;"></ion-input>-->
<ion-datetime class="inputDateTime timepicker" [(ngModel)]="waterChannel.controlConfig.config.stopDate" displayFormat="MM-DD" cancelText="取消" doneText="确认"></ion-datetime>
<ion-datetime class="inputDateTime timepicker" [(ngModel)]="waterChannel.controlConfig.config.stopDate" [displayFormat]="'MM-DD'" cancelText="取消" doneText="确认"></ion-datetime>
</ion-item>
</ion-col>
</ion-row>
......@@ -338,14 +339,14 @@
<ion-item lines="none" class="thiItem">等级临界值</ion-item>
</ion-row>
<ion-row>
<ion-col class="thiItem">应激等级</ion-col>
<ion-col class="thiItem">THI值(<)</ion-col>
<ion-col class="thiItem" style="text-align:left">预警方式</ion-col>
<ion-col class="thiItem" size="3">应激等级</ion-col>
<ion-col class="thiItem" size="2">THI值(<)</ion-col>
<ion-col class="thiItem" size="5" style="text-align:left; padding-left:15px;">预警方式</ion-col>
</ion-row>
<ion-row *ngFor="let heatStress of curCowshed.heatStressList">
<ion-col class="thiItem">{{heatStress.heatStressLevel}}</ion-col>
<ion-col class="thiItem">{{heatStress.thi}}</ion-col>
<ion-col class="thiItem">
<ion-col class="thiItem" size="3" >{{heatStress.heatStressLevel}}</ion-col>
<ion-col class="thiItem" size="2" >{{heatStress.thi}}</ion-col>
<ion-col class="thiItem" size="5" >
<ion-select class="heatSelect" multiple="false" cancelText="取消" okText="确认" [(ngModel)]="heatStress.alarmLevel">
<ion-select-option *ngFor="let alarmWay of alarmWays" [value]="alarmWay.alarmId">{{alarmWay.alarmValue}}</ion-select-option>
</ion-select>
......
This diff is collapsed.
......@@ -28,7 +28,7 @@
</div>
</ion-header>
<ion-content style="background-color: #F3F4F4;">
<ion-router-outlet></ion-router-outlet>
<!--<ion-router-outlet></ion-router-outlet>-->
<ion-tabs>
<ion-tab-bar slot="top">
<ion-tab-button tab="tab-fan" class="tabSelected" >
......@@ -51,13 +51,13 @@
<!--<ion-tab-button tab="tab-fan" class="tabSelected">-->
<!--<ion-label>风机</ion-label>-->
<!--</ion-tab-button>-->
<!--<ion-tab-button tab="tab-shower" class="tabSelected"> &lt;!&ndash;[href]="showerLink" target="_self"&ndash;&gt;-->
<!--<ion-tab-button tab="tab-shower" class="tabSelected"> &lt;!&ndash;[rootParams]="fieldRegionNo"&ndash;&gt;-->
<!--<ion-label>喷淋</ion-label>-->
<!--</ion-tab-button>-->
<!--<ion-tab-button tab="tab-light" class="tabSelected"> &lt;!&ndash; [href]="lightLink" target="_self" &ndash;&gt;-->
<!--<ion-tab-button tab="tab-light" class="tabSelected">-->
<!--<ion-label>照明</ion-label>-->
<!--</ion-tab-button>-->
<!--<ion-tab-button tab="tab-waterchannel" class="tabSelected"> &lt;!&ndash; [href]="waterchannelLink" target="_self" &ndash;&gt;-->
<!--<ion-tab-button tab="tab-waterchannel" class="tabSelected">-->
<!--<ion-label>水槽</ion-label>-->
<!--</ion-tab-button>-->
<!--</ion-tab-bar>-->
......
......@@ -26,7 +26,7 @@ export class EnvDetailPage implements OnInit {
temp: 0,
humi: 0,
heatStressLevel: 0,
heatStressColor: '#71fa1d',
heatStressColor: '#52fabb',
heatStressLevelName: '无',
online: 0,
operationModel: 1,
......@@ -128,8 +128,8 @@ export class EnvDetailPage implements OnInit {
this.waterchannelLink = '/env-detail/tab-waterchannel/' + this.fieldRegionNo;
if (this.item) {
this.item.heatStressColor = this.item.heatStressLevel === 0 ? '#71fa1d' :
this.item.heatStressLevel === 1 ? '#71fa1d' :
this.item.heatStressColor = this.item.heatStressLevel === 0 ? '#52fabb' :
this.item.heatStressLevel === 1 ? '#52fabb' :
this.item.heatStressLevel === 2 ? '#FAB139' :
this.item.heatStressLevel === 3 ? '#ff6a1f' : '#b22222';
}
......
......@@ -44,4 +44,6 @@
</ion-card-content>
</ion-card>
</div>
<v-loading-bump style="z-index: 9999; color: red" [remain]="comm.remain" *ngIf="comm.isLoading"></v-loading-bump>
</ion-content>
......@@ -3,6 +3,7 @@ import {Api} from '../../service/api';
import {ActivatedRoute} from '@angular/router';
import {Load} from '../../service/load';
import { AlertController } from '@ionic/angular';
import {Constants} from '../../service/constants';
@Component({
selector: 'v-env-fan',
......@@ -10,6 +11,7 @@ import { AlertController } from '@ionic/angular';
styleUrls: ['./env-fan.page.scss'],
})
export class EnvFanPage implements OnInit {
/* 风机 */
// 牧场区域编号
fieldRegionNo = '';
......@@ -24,9 +26,10 @@ export class EnvFanPage implements OnInit {
batchSwitch = {op: false, type: undefined, load: false, disabled: undefined};
controlModelOptions = [
{modelId: 0, modelValue: '手控模式'},
{modelId: 1, modelValue: '自控模式'},
{modelId: 2, modelValue: '智控模式'}];
{modelId: 0, modelValue: '-'},
{modelId: 1, modelValue: '手控模式'},
{modelId: 2, modelValue: '自控模式'},
{modelId: 3, modelValue: '智控模式'}];
// 发送指令延时判断
comm = {
......@@ -34,15 +37,35 @@ export class EnvFanPage implements OnInit {
isLoading : true
};
commTmr: any;
constructor(private api: Api, private ac: ActivatedRoute, private load: Load, private alertController: AlertController) { }
ngOnInit() {
this.ionViewWillEnter();
// this.ionViewWillEnter();
this.comm.remain = 0;
this.comm.isLoading = false;
this.commTmr = window.setInterval(() => {
if (this.comm.remain > 0) {
this.comm.remain = this.comm.remain - 1;
}
if ( this.comm.remain < 1 ) {
this.comm.isLoading = false;
} else {
this.comm.isLoading = true;
}
}, 1000) ;
this.init();
}
ionViewWillEnter() {
// ionViewWillEnter() {
//
// }
ionViewWillLeave() {
clearInterval(this.commTmr);
}
init() {
......@@ -62,34 +85,21 @@ export class EnvFanPage implements OnInit {
this.controlModel = data.controlModel;
this.devices = data.param;
this.devices.forEach(device => {
device.op = device.state === 1 ? true : false;
device.op = device.state === 1;
});
this.initButtons();
}
this.load.offLoad();
}]);
// START--------------------------------------------------------------------
// TODO 测试用准备数据
// this.fieldDeviceType = '风机';
// this.controlModel = 0;
// this.devices = [{fieldDeviceNo: '136641005998194688', fieldDeviceName: '1号组', state: 1, alarm: 1},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: '2号组', state: 0, alarm: 1},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: '3号组', state: 1, alarm: 0},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: '4号组', state: 0, alarm: 1},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: '5号组', state: 1, alarm: 0},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: '6号组', state: 1, alarm: 0}];
// this.initButtons();
// END--------------------------------------------------------------------
}
initButtons() {
// 各个按钮表示状态
// [手控(0)]的状态:活性(false) 以外:非活性(true)
const allDisabled = this.controlModel === 0 ? false : true;
// 一键控制 远控的场合,活性(Disabled = false)
const allDisabled = !(this.controlModel === Constants.CONTROLL_REMOTR);
this.batchSwitch.disabled = allDisabled;
this.devices.forEach((device, i) => {
this.devices.forEach((device) => {
device.disabled = allDisabled;
});
......@@ -104,16 +114,12 @@ export class EnvFanPage implements OnInit {
}
toggle(btn) {
// btn.op = btn.op ? 1 : 0;
// event.preventDefault();
// a.loading = true;
this.opChangeComfirm(btn);
}
async opChangeComfirm(btn) {
const msgHeader = this.fieldDeviceType;
const msgOp = btn.op ? '打开' : '关闭';
const msgOp = btn.op ? '关闭' : '打开';
const alert = await this.alertController.create({
header: '请注意',
// subHeader: '确定要' + msgOp + ' ' + msgHeader + ' 这个泵吗?',
......@@ -158,8 +164,15 @@ export class EnvFanPage implements OnInit {
// device.state = btn.op ? 0 : 1;
// });
// }
this.api.presentMsgToast(data.message);
this.getData(1);
// this.api.presentMsgToast(data.message);
// this.getData(1);
if (data.code === 1) {
this.getData(1);
this.api.presentMsgToast(data.message);
} else {
this.getData(0);
this.api.presentMsgToast(data.message);
}
this.comm.remain = 0;
btn.load = false;
}]);
......@@ -177,22 +190,19 @@ export class EnvFanPage implements OnInit {
const req = {
fieldDeviceNo: btn.fieldDeviceNo,
fieldDeviceType: this.fieldDeviceType,
op: btn.op ? 1 : 0,
op: btn.op ? 0 : 1,
ts: new Date().valueOf()
};
this.comm.remain = 20;
this.api.control.controlCowedSwitch([req, (data) => {
// if (data && data.code === 1) {
// this.getData(1);
// this.api.presentMsgToast(data.message);
// } else {
// this.getData(0);
// this.api.presentMsgToast(data.message);
// }
this.getData(1);
this.api.presentMsgToast(data.message);
if (data && data.code === 1) {
this.getData(1);
this.api.presentMsgToast(data.message);
} else {
this.getData(0);
this.api.presentMsgToast(data.message);
}
this.comm.remain = 0;
// btn.load = false;
}]);
}
}
......@@ -18,6 +18,18 @@
<div echarts [options]="chartOption" class="demo-chart"></div>
<h1 class="subTittle">近8个小时环境参数表</h1>
<div style="width: 98%">
<!--<ngx-datatable class="material" [rows]="tableRows" [columnMode]="'force'" [scrollbarH]="true" [scrollbarV]="true" style="text-align: center; font-size:14px">-->
<!--<ngx-datatable-column name="时间" prop="ts" [width]="80">-->
<!--</ngx-datatable-column>-->
<!--<ngx-datatable-column name="热应激" prop="thi" [width]="80">-->
<!--</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="NH3" [width]="90">-->
<!--</ngx-datatable-column>-->
<!--</ngx-datatable>-->
<ngx-datatable class="material" [rows]="tableRows" [columnMode]="'force'" [scrollbarH]="true" [scrollbarV]="true" style="text-align: center; font-size:14px">
<ngx-datatable-column name="时间" prop="ts" [width]="80">
</ngx-datatable-column>
......
......@@ -4,6 +4,7 @@ import {Api} from '../../service/api';
import {Load} from '../../service/load';
import {NgxDatatableModule} from '@swimlane/ngx-datatable';
import {DateFormatter} from '@angular/common/src/pipes/deprecated/intl';
import {DatePipe} from '@angular/common';
@Component({
selector: 'v-env-history',
......@@ -12,7 +13,7 @@ import {DateFormatter} from '@angular/common/src/pipes/deprecated/intl';
})
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, private datePipe: DatePipe) {
}
fieldRegionNo = '';
......@@ -23,38 +24,6 @@ export class EnvHistoryPage implements OnInit {
chartOption = {};
tableRows = [];
// START--------------------------------------------------------------------------------
// TODO 以下为假数据 待删除
// 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: ['1', '2', '3', '4', '5', '6', '7', '8'],
// },
// 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'}
// ]
// };
// // 时间 热应激 温度 湿度 光照 风机 喷淋 照明
// tableRows = [
// {ts: '17:00', thi: '轻', temp: '23.8', humi: '56', NH3: '70'},
// {ts: '17:30', thi: '中', temp: '27.2', humi: '43', NH3: '80'},
// {ts: '18:00', thi: '轻', temp: '23.2', humi: '61', NH3: '99'},
// {ts: '18:30', thi: '轻', temp: '23.1', humi: '47', NH3: '100'},
// {ts: '19:00', thi: '轻', temp: '20.2', humi: '43', NH3: '60'},
// {ts: '19:30', thi: '轻', temp: '21.6', humi: '34', NH3: '50'},
// {ts: '20:00', thi: '轻', temp: '22.5', humi: '43', NH3: '40'},
// ];
// END--------------------------------------------------------------------------------
ngOnInit() {
this.init();
......@@ -98,7 +67,6 @@ export class EnvHistoryPage implements OnInit {
const humi = [];
const thi = [];
const times = [];
debugger;
if (param.temp && param.temp.constructor === Array) {
param.temp.map(item => {
times.push(new Date(item.time).getHours());
......@@ -142,7 +110,7 @@ export class EnvHistoryPage implements OnInit {
param.map(item => {
this.tableRows.push({
ts: item.ts,
ts: this.datePipe.transform(item.ts, 'hh-mm'),
thi: item.heatStressLevel,
temp: item.temp,
humi: item.humi,
......
......@@ -45,10 +45,10 @@
<span style="text-align: center">{{item.fieldRegionName}}</span><span style="text-align: center; font-size:12px; padding-left:10px; color:red;" *ngIf="item.operationModel === 4">(部分设备处于现控状态)</span></div>
</div>
<div class="content">
<span *ngIf="item.temp !== null" class="detailInfo" style="width: 40%">温度: &nbsp;&nbsp;{{item.temp}} ℃</span>
<span *ngIf="item.humi !== null" class="detailInfo" style="width: 40%">湿度: &nbsp;&nbsp;{{item.humi}} % rH</span>
<span *ngIf="item.NH3 !== null" class="detailInfo" style="width: 40%">氨气: &nbsp;&nbsp;{{item.NH3}} ppm</span>
<span *ngIf="item.heatStressLevel !== null" class="detailInfo" style="width: 40%">热应激: &nbsp;&nbsp;<span class="warmColor{{item.heatStressLevel}}">{{item.heatStressLevelName}}</span></span>
<span *ngIf="item.temp !== undefined && item.temp !== null" class="detailInfo" style="width: 40%">温度: &nbsp;&nbsp;{{item.temp}} ℃</span>
<span *ngIf="item.humi !== undefined && item.humi !== null" class="detailInfo" style="width: 40%">湿度: &nbsp;&nbsp;{{item.humi}} % rH</span>
<span *ngIf="item.NH3 !== undefined && item.NH3 !== null" class="detailInfo" style="width: 40%">氨气: &nbsp;&nbsp;{{item.NH3}} ppm</span>
<span *ngIf="item.heatStressLevel !== undefined && item.heatStressLevel !== null" class="detailInfo" style="width: 40%">热应激: &nbsp;&nbsp;<span class="warmColor{{item.heatStressLevel}}">{{item.heatStressLevelName}}</span></span>
</div>
<div class="bottom">
<div style="width:100%">
......
......@@ -54,4 +54,5 @@
</ion-card>
</div>
<v-loading-bump style="z-index: 9999; color: red" [remain]="comm.remain" *ngIf="comm.isLoading"></v-loading-bump>
</ion-content>
......@@ -3,6 +3,7 @@ import {Api} from '../../service/api';
import {ActivatedRoute} from '@angular/router';
import {Load} from '../../service/load';
import {AlertController} from '@ionic/angular';
import {Constants} from '../../service/constants';
@Component({
selector: 'v-env-light',
......@@ -34,32 +35,50 @@ export class EnvLightPage implements OnInit {
batchSwitch = {op: undefined, type: undefined, load: undefined, disabled: undefined};
controlModelOptions = [
{modelId: 0, modelValue: '手控模式'},
{modelId: 1, modelValue: '自控模式'},
{modelId: 2, modelValue: '智控模式'}];
{modelId: 0, modelValue: '-'},
{modelId: 1, modelValue: '手控模式'},
{modelId: 2, modelValue: '自控模式'},
{modelId: 3, modelValue: '智控模式'}];
// 发送指令延时判断
comm = {
remain: 20,
isLoading: true
remain : 20,
isLoading : true
};
commTmr: any;
constructor(private api: Api, private ac: ActivatedRoute, private load: Load, private route: ActivatedRoute,
private alertControlle: AlertController) {
}
ngOnInit() {
// this.route.paramMap.subscribe(params => {
// this.fieldRegionNo = params.get('fieldRegionNo');
// });
// this.getData(0);
}
this.comm.remain = 0;
this.comm.isLoading = false;
this.commTmr = window.setInterval(() => {
if (this.comm.remain > 0) {
this.comm.remain = this.comm.remain - 1;
}
ionViewWillEnter() {
console.log('ionViewWillEnter_shower');
if ( this.comm.remain < 1 ) {
this.comm.isLoading = false;
} else {
this.comm.isLoading = true;
}
}, 1000);
this.init();
}
// ionViewWillEnter() {
// console.log('ionViewWillEnter_shower');
// this.init();
// }
ionViewWillLeave() {
clearInterval(this.commTmr);
}
init() {
this.route.paramMap.subscribe(params => {
this.fieldRegionNo = params.get('fieldRegionNo');
......@@ -86,23 +105,6 @@ export class EnvLightPage implements OnInit {
device.op = device.state === 1 ? true : false;
});
// START--------------------------------------------------------------------
// TODO 测试用准备数据
// this.fieldRegionNo = 'FRN136641006052720640';
// this.startDate = '05-01';
// this.stopDate = '08-31';
// // this.fieldDeviceType = '照明';
// // this.controlModel = 2;
// this.on = '19:00';
// this.off = '05:00';
// this.devices = [{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'A号照明组', state: 1},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'B号照明组', state: 0},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'C号照明组', state: 1},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'D号照明组', state: 0},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'E号照明组', state: 1},
// {fieldDeviceNo: '136641005998194688', fieldDeviceName: 'F号照明组', state: 1}];
// END--------------------------------------------------------------------
this.initButtons();
}
this.load.offLoad();
......@@ -110,26 +112,53 @@ export class EnvLightPage implements OnInit {
}
initButtons() {
// 智控:2
if (this.controlModel === 2) {
this.batchSwitch.disabled = true;
this.devices.forEach((device) => {
device.disabled = true;
});
} else if (this.controlModel === 1) {
// 自控:1
// 一键控制: 活性 其他按钮: 非活性
// // 智控:2
// if (this.controlModel === 2) {
// this.batchSwitch.disabled = true;
// this.devices.forEach((device) => {
// device.disabled = true;
// });
// } else if (this.controlModel === 1) {
// // 自控:1
// // 一键控制: 活性 其他按钮: 非活性
// this.batchSwitch.disabled = false;
// this.devices.forEach((device) => {
// device.disabled = true;
// });
// } else {
// // 手控:0
// // 一键控制: 活性 其他按钮: 活性
// this.batchSwitch.disabled = false;
// this.devices.forEach((device) => {
// device.disabled = false;
// });
// }
if (this.controlModel === Constants.CONTROLL_REMOTR || this.controlModel === Constants.CONTROLL_SELF) {
// 远控+自控 的场合
// 一键控制: 活性
this.batchSwitch.disabled = false;
this.devices.forEach((device) => {
device.disabled = true;
device.disabled = false;
});
} else {
// 手控:0
// 一键控制: 活性 其他按钮: 活性
// 其他
// 一键控制: 活性
this.batchSwitch.disabled = false;
}
if (this.controlModel === Constants.CONTROLL_REMOTR) {
// 远控 的场合
// 子按钮: 活性
this.devices.forEach((device) => {
device.disabled = false;
});
} else {
// 其他
// 子按钮: 非活性
this.devices.forEach((device) => {
device.disabled = true;
});
}
// 设置[一键控制]按钮(默认: 开启)
......@@ -143,15 +172,12 @@ export class EnvLightPage implements OnInit {
}
toggle(btn) {
// btn.op = btn.op ? 1 : 0;
// event.preventDefault();
// a.loading = true;
this.opChangeComfirm(btn);
}
async opChangeComfirm(btn) {
const msgHeader = '照明灯';
const msgOp = btn.op ? '打开' : '关闭';
const msgOp = btn.op ? '关闭' : '打开';
let msgContent = '';
if (this.controlModel === 0) {
msgContent = '所有' + msgHeader + '即将' + msgOp + ',要继续吗?';
......@@ -188,23 +214,25 @@ export class EnvLightPage implements OnInit {
btn.load = true;
const req = {
fieldRegionNo: this.fieldRegionNo,
op: btn.op ? 0 : 1,
type: this.fieldDeviceType,
op: btn.op ? 1 : 0,
fieldDeviceType: this.fieldDeviceType,
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
this.comm.remain = 120;
// 一键开启设备
this.api.control.controlCowedBatchSwitch([req, (data) => {
// if (data.code === 1) {
// this.getData(1);
// this.api.presentMsgToast(data.message);
// } else {
// this.api.presentMsgToast(data.message);
// }
this.getData(0);
this.api.presentMsgToast(data.message);
if (data.code === 1) {
this.getData(1);
this.api.presentMsgToast(data.message);
} else {
this.getData(0);
this.api.presentMsgToast(data.message);
}
this.comm.remain = 0;
// this.getData(0);
// this.api.presentMsgToast(data.message);
// this.comm.remain = 0;
btn.load = false;
}]);
......@@ -222,22 +250,24 @@ export class EnvLightPage implements OnInit {
btn.loading = true;
const req = {
fieldDeviceNo: btn.fieldDeviceNo,
op: btn.state ? 0 : 1,
fieldDeviceType: this.fieldDeviceType,
op: btn.op ? 0 : 1,
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
this.comm.remain = 20;
this.api.control.controlCowedSwitch([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);
// }
this.getData(1);
this.comm.remain = 0;
this.api.presentMsgToast(data.message);
if (data && data.code === 1) {
this.getData(1);
this.comm.remain = 0;
this.api.presentMsgToast(data.message);
} else {
this.getData(0);
this.comm.remain = 0;
this.api.presentMsgToast(data.message);
}
// this.getData(1);
// this.comm.remain = 0;
// this.api.presentMsgToast(data.message);
btn.loading = false;
}]);
}
......
......@@ -34,13 +34,13 @@
line-height: 25px;
margin-bottom: 5px;">时间参数</h1>
<ion-item lines="full" insert="false">
<span class="content">{{param[0].fieldDeviceName}}喷淋时间 {{controlConfig.A}}</span>
<span class="content">{{param[0].fieldDeviceName}}喷淋时间 &nbsp;&nbsp;&nbsp;&nbsp;{{controlConfig.A}} &nbsp;&nbsp;&nbsp;&nbsp;</span>
</ion-item>
<ion-item lines="full" insert="false">
<span class="content">{{param[1].fieldDeviceName}}喷淋时间 {{controlConfig.B}}</span>
<span class="content">{{param[1].fieldDeviceName}}喷淋时间 &nbsp;&nbsp;&nbsp;&nbsp;{{controlConfig.B}} &nbsp;&nbsp;&nbsp;&nbsp;</span>
</ion-item>
<ion-item lines="full" insert="false">
<span class="content">间隔时间 {{controlConfig.interval}}</span>
<span class="content">间隔时间 &nbsp;&nbsp;&nbsp;&nbsp; {{controlConfig.interval}} &nbsp;&nbsp;&nbsp;&nbsp;</span>
</ion-item>
<h1 style="
......@@ -73,4 +73,6 @@
</ion-card-content>
</ion-card>
</div>
<v-loading-bump style="z-index: 9999; color: red" [remain]="comm.remain" *ngIf="comm.isLoading"></v-loading-bump>
</ion-content>
......@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import {Api} from '../../service/api';
import {ActivatedRoute} from '@angular/router';
import {Load} from '../../service/load';
import {Constants} from '../../service/constants';
@Component({
selector: 'v-env-shower',
......@@ -14,11 +15,13 @@ export class EnvShowerPage implements OnInit {
'DeviceNo' : '',
'workModeOld' : '1'};
// 发送指令延时判断
comm = {
remain : 20,
isLoading : true
};
// 发送指令延时判断
comm = {
remain : 20,
isLoading : true
};
commTmr: any;
// 牧场区域编号
fieldRegionNo = '';
......@@ -41,20 +44,39 @@ export class EnvShowerPage implements OnInit {
param = [];
controlModelOptions = [
{modelId: 0, modelValue: '手控模式'},
{modelId: 1, modelValue: '自控模式'},
{modelId: 2, modelValue: '智控模式'}];
{modelId: 0, modelValue: '-'},
{modelId: 1, modelValue: '手控模式'},
{modelId: 2, modelValue: '自控模式'},
{modelId: 3, modelValue: '智控模式'}];
constructor(private api: Api, private ac: ActivatedRoute, private load: Load, private route: ActivatedRoute) { }
ngOnInit() {
this.comm.remain = 0;
this.comm.isLoading = false;
this.commTmr = window.setInterval(() => {
if (this.comm.remain > 0) {
this.comm.remain = this.comm.remain - 1;
}
if ( this.comm.remain < 1 ) {
this.comm.isLoading = false;
} else {
this.comm.isLoading = true;
}
}, 1000) ;
this.init();
}
ionViewWillEnter() {
console.log('ionViewWillEnter_shower');
this.init();
// ionViewWillEnter() {
// console.log('ionViewWillEnter_shower');
// this.init();
// }
ionViewWillLeave() {
clearInterval(this.commTmr);
}
init() {
this.route.paramMap.subscribe(params => {
this.fieldRegionNo = params.get('fieldRegionNo');
......@@ -85,8 +107,8 @@ export class EnvShowerPage implements OnInit {
initButtons() {
this.param.forEach((device) => {
// disabled:手控状态下 活性false 其他非活性true
device.disabled = this.controlModel === 0 ? false : true;
// 远控的场合 小按钮活性(disabled = false)
device.disabled = !(this.controlModel === Constants.CONTROLL_REMOTR);
});
}
......@@ -95,22 +117,22 @@ export class EnvShowerPage implements OnInit {
const req = {
fieldDeviceNo: btn.fieldDeviceNo,
fieldDeviceType: this.fieldDeviceType,
op: btn.op ? 1 : 0,
op: btn.op ? 0 : 1,
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
this.comm.remain = 20;
this.api.control.controlCowedSwitch([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);
// }
this.getData(0);
this.comm.remain = 0;
this.api.presentMsgToast(data.message);
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);
}
// this.getData(0);
// this.comm.remain = 0;
// this.api.presentMsgToast(data.message);
btn.loading = false;
}]);
}
......
......@@ -14,7 +14,7 @@
--padding-inline-start: 0px !important;
--padding-inline-end: 0px !important;
padding: 10px;
font-size: 20px;
font-size: 18px;
text-align:left;
}
.cardContent {
......
......@@ -30,10 +30,10 @@ export class EnvWaterchannelPage implements OnInit {
}
// ionic的生命周期函数
ionViewWillEnter() {
console.log('ionViewWillEnter_waterChannel');
this.init();
}
// ionViewWillEnter() {
// console.log('ionViewWillEnter_waterChannel');
// this.init();
// }
init() {
this.route.paramMap.subscribe(params => {
......@@ -53,5 +53,4 @@ export class EnvWaterchannelPage implements OnInit {
this.load.offLoad();
}]);
}
}
import {Injectable} from '@angular/core';
@Injectable()
export class Constants {
constructor() {}
// public enum CONTROLL_MODELS: number {
// // ON_SITE,
// // REMOTR,
// // HAND,
// // WISDOM
// // }
public static CONTROLL_ON_SITE = 0; // 现控
public static CONTROLL_REMOTR = 1; // 远控
public static CONTROLL_SELF = 2; // 自控
public static CONTROLL_WISDOM = 3; // 智慧控制
}
import {Injectable} from '@angular/core';
@Injectable()
export class UtilService {
constructor() {}
public getStartDate(start): any {
const tmpStart = new Date(start);
const year = tmpStart.getFullYear();
const month = tmpStart.getMonth();
const day = tmpStart.getDate();
return new Date(year, month, day, 0, 0, 0 ).valueOf();
}
public getEndDate(end) {
const tmpEnd = new Date(end);
const year = tmpEnd.getFullYear();
const month = tmpEnd.getMonth();
const day = tmpEnd.getDate();
return new Date(year, month, day, 23, 59, 59 ).valueOf();
}
}
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