Commit 524b9d31 authored by van.chen's avatar van.chen

中转池页面改接口

parent a6970763
......@@ -47,7 +47,6 @@ export class AlarmPage implements OnInit {
this.api.alarm.getAlarmByTerm([req, (data) => {
this.data = [];
if (data && data.constructor === Array) {
console.log(data.length);
if (data.length > 0) {
this.itemExit = true;
} else {
......@@ -78,7 +77,6 @@ export class AlarmPage implements OnInit {
this.api.alarm.getAlarmByTerm([req, (data) => {
this.data = [];
if (data && data.constructor === Array) {
console.log(data.length);
if (data.length > 0) {
this.itemExit = true;
} else {
......@@ -101,10 +99,8 @@ export class AlarmPage implements OnInit {
choose(e) {
if (e.detail.value === 'day') {
this.getAlarmOneDay();
console.log(e.detail.value);
} else {
this.getAlarmOneWeek();
console.log(e.detail.value);
}
}
......
......@@ -79,4 +79,6 @@
padding-top: 1px;
width: 70px;
margin-left: 52px;
height: 21px;
float: right;
}
......@@ -3,98 +3,50 @@
(onLeftClick)="onLeftClick()"
style="background-color: #28c9bd"
>
东中转池控制
{{fieldRegionName}}控制
</Navbar>
<div class="topPart">
<!--<div class="online" *ngFor="let one of items">-->
<!--<div class="label">{{one.label}}</div>-->
<!--<div class="btn">-->
<!--<ion-toggle mode="md" color="primary" (ionChange)="toggle(one.type, $event)"></ion-toggle>-->
<!--</div>-->
<!--</div>-->
<ListItem multipleLine>
<ListItem multipleLine *ngIf="this.yewei">
当前液位:
<div class="process">
<div class="inlineProcess" [ngStyle]="{width: proc + '%'}"
[ngClass]="{'orange': yewei < 3 && yewei > 2.5, 'red': yewei > 3}">
<div [class]="'inlineProcess ' + color" [ngStyle]="{width: proc + '%'}">
</div>
</div>
{{yewei.toFixed(2)}}m
</ListItem>
<ListItem multipleLine>
<ListItem multipleLine *ngIf="this.temp">
当前温度:
<div style="display: inline-block;margin-left: calc(100% - 145px);vertical-align: middle">
{{temp}}℃
{{temp.toFixed(2)}}℃
</div>
</ListItem>
<ListItem multipleLine [extra]="s1">
南水
<div *ngFor="let a of nb;let i = index">
<ListItem multipleLine [extra]="a.fieldDeviceName === '南水' ? s1 : s2">
{{a.fieldDeviceName}}
</ListItem>
<ListItem multipleLine *ngIf="nanClicked">
<ListItem multipleLine *ngIf="a.fieldDeviceName === '南水' ? nanClicked : beiClicked">
选择开启时间
<Stepper class="stepClass" [(ngModel)]="duration" [min]="1" [showNumber]="true"></Stepper>分钟
<div style="text-align: right;padding-top: 10px">
<div Button style="margin-right: 10px" class="btn" (click)="cancel()" [inline]="true" [size]="'small'" [type]="'default'">取消</div>
<div Button (click)="confirm(0)" class="btn" [inline]="true" [size]="'small'" [type]="'primary'">确认</div>
<div Button (click)="confirm(a)" class="btn" [inline]="true" [size]="'small'" [type]="'primary'">确认</div>
</div>
</ListItem>
<ListItem multipleLine [extra]="s2">
北水
</ListItem>
<ListItem multipleLine *ngIf="beiClicked">
选择开启时间
<Stepper class="stepClass" [(ngModel)]="duration" [min]="1" [showNumber]="true"></Stepper>分钟
<div style="text-align: right;padding-top: 10px">
<div Button style="margin-right: 20px" class="btn" (click)="cancel()" [inline]="true" [size]="'small'" [type]="'default'">取消</div>
<div Button (click)="confirm(1)" class="btn" [inline]="true" [size]="'small'" [type]="'primary'">确认</div>
</div>
</ListItem>
</div>
<div class="bottomPart">
<ListItem multipleLine [extra]="s3">
一号搅拌器
</ListItem>
<ListItem multipleLine [extra]="s4">
二号搅拌器
<ListItem multipleLine *ngFor="let a of devices;let i = index">
{{a.fieldDeviceName}}
<v-switch [value]="a.value" (click)="toggle(a)" [loading]="a.loading"></v-switch>
</ListItem>
<!--<ListItem multipleLine [extra]="s5">-->
<!--三号搅拌器-->
<!--</ListItem>-->
<!--<ListItem multipleLine [extra]="s6">-->
<!--四号搅拌器-->
<!--</ListItem>-->
<!--<ListItem multipleLine [extra]="s7">-->
<!--一号泵-->
<!--</ListItem>-->
<!--<ListItem multipleLine [extra]="s8">-->
<!--二号泵-->
<!--</ListItem>-->
</div>
</div>
<ng-template #icon>
<span class="vo v-back"></span>
</ng-template>
<ng-template #s1>
<v-switch [value]="value[0]" [disabled]="beiLoading || value[0] || value[1]" (click)="toggle(0)" [loading]="nanLoading"></v-switch>
<v-switch [value]="value[0]" [disabled]="beiLoading || value[0] || value[1]" (click)="toggleNb(0)" [loading]="nanLoading"></v-switch>
</ng-template>
<ng-template #s2>
<v-switch [value]="value[1]" [disabled]="nanLoading || value[0] || value[1]" (click)="toggle(1)" [loading]="beiLoading"></v-switch>
</ng-template>
<ng-template #s3>
<v-switch [value]="value[2]" (click)="toggle(2)" [loading]="loading2"></v-switch>
</ng-template>
<ng-template #s4>
<v-switch [value]="value[3]" (click)="toggle(3)" [loading]="loading3"></v-switch>
</ng-template>
<ng-template #s5>
<v-switch [value]="value[4]" [disabled]="true"></v-switch>
</ng-template>
<ng-template #s6>
<v-switch [value]="value[5]" [disabled]="true"></v-switch>
</ng-template>
<ng-template #s7>
<v-switch [value]="value[6]" [disabled]="true"></v-switch>
</ng-template>
<ng-template #s8>
<v-switch [value]="value[7]" [disabled]="true"></v-switch>
<v-switch [value]="value[1]" [disabled]="nanLoading || value[0] || value[1]" (click)="toggleNb(1)" [loading]="beiLoading"></v-switch>
</ng-template>
......@@ -16,10 +16,6 @@
height: 20px;
}
.orange {
background-color: #ffa847;
}
.red {
background-color: #f04844;
}
......
......@@ -2,6 +2,7 @@ import {Component, OnInit} from '@angular/core';
import {Transfer} from '../service/transfer';
import {Api} from '../service/api';
import {Load} from '../service/load';
import {ActivatedRoute} from '@angular/router';
@Component({
selector: 'v-east',
......@@ -11,21 +12,28 @@ import {Load} from '../service/load';
export class EastPage implements OnInit {
value = [false, false, false, false, false, false, false];
yewei = 0;
temp = '-';
temp = 0;
proc = 0;
duration = 23;
nanClicked = false;
beiClicked = false;
nanLoading = false;
beiLoading = false;
loading2 = false;
loading3 = false;
_inv;
color;
nb = [];
devices = [];
fieldRegionNo = '';
fieldRegionName = '';
constructor(private tf: Transfer, private api: Api, private load: Load) {
constructor(private tf: Transfer, private api: Api, private load: Load, private ac: ActivatedRoute) {
}
ngOnInit() {
this.ac.queryParams.subscribe((data) => {
this.fieldRegionNo = data.fieldRegionNo || 'FRN108122347982438400';
this.fieldRegionName = data.fieldRegionName || '东中转池';
});
}
// ionic的生命周期函数
......@@ -38,11 +46,10 @@ export class EastPage implements OnInit {
}
ionViewWillLeave() {
// 清掉计数器
clearTimeout(this._inv);
}
toggle(index) {
toggleNb(index) {
if (!(this.beiLoading || this.nanLoading || this.value[0] || this.value[1])) {
if (index === 0) {
this.nanClicked = true;
......@@ -50,51 +57,29 @@ export class EastPage implements OnInit {
} else if (index === 1) {
this.beiClicked = true;
this.beiLoading = true;
} else if (index === 2) {
this.loading2 = true;
const req = [{
data: {
d0: 1,
startTime: +new Date(),
ts: +new Date()
},
sn: '19041005',
type: 'WTDR66C'
}];
this.api.data.updateControl([req, (data) => {
if (data && data.code === 1) {
this.getData(1);
this.api.presentMsgToast(data.message);
} else {
this.api.presentMsgToast(data.message);
}
this.loading2 = false;
this.load.offLoad();
}]);
} else if (index === 3) {
this.loading3 = true;
const req = [{
data: {
d2: 1,
startTime: +new Date(),
ts: +new Date()
},
sn: '19041005',
type: 'WTDR66C'
}];
this.api.data.updateControl([req, (data) => {
}
}
toggle(a) {
a.loading = true;
const req = {
fieldDeviceNo: a.fieldDeviceNo,
op: a.value ? 0 : 1,
ts: new Date().getTime()
};
this.load.toLoad('指令已发送, 等待处理结果', true);
this.api.control.controlSwitch([req, (data) => {
if (data && data.code === 1) {
this.getData(1);
this.api.presentMsgToast(data.message);
} else {
a.loading = false;
this.api.presentMsgToast(data.message);
}
this.loading3 = false;
this.load.offLoad();
}]);
}
}
}
cancel() {
this.nanClicked = false;
......@@ -103,44 +88,26 @@ export class EastPage implements OnInit {
this.beiLoading = false;
}
confirm(index) {
this.load.toLoad('发送指令中,等待指令返回...', true);
let req;
if (index) {
req = [{
data: {
d2: 1,
confirm(a) {
const req = {
fieldDeviceNo: a.fieldDeviceNo,
op: a.value ? 0 : 1,
duration: this.duration,
startTime: +new Date(),
ts: +new Date()
},
sn: '19041004',
type: 'WTDR66C'
}];
} else {
req = [{
data: {
d0: 1,
startTime: +new Date(),
ts: +new Date()
},
sn: '19041004',
type: 'WTDR66C'
}];
}
this.nanClicked = false;
this.beiClicked = false;
this.api.data.updateControl([req, (data) => {
startTime: new Date().getTime(),
ts: new Date().getTime()
};
this.load.toLoad('指令已发送, 等待处理结果', true);
this.api.control.controlSwitch([req, (data) => {
if (data && data.code === 1) {
this.getData(1);
this.api.presentMsgToast(data.message);
} else {
this.api.presentMsgToast(data.message);
}
this.nanClicked = false;
this.beiClicked = false;
this.nanLoading = false;
this.beiLoading = false;
this.loading2 = false;
this.loading3 = false;
this.api.presentMsgToast(data.message);
}
this.load.offLoad();
}]);
}
......@@ -151,65 +118,36 @@ export class EastPage implements OnInit {
getData(time) {
if (time) {this.load.toLoad('加载中...', false); }
// 东中转池 19041001 0号通道为温度
this.api.data.getRealData([{sn: '19041001', type: 'WTDR14P'}, (data) => {
if (data && data.constructor === Array) {
if (data.length > 0) {
this.temp = Number(data[0].value).toFixed(2);
}
} else {
this.api.presentMsgToast('获取数据失败');
}
}]);
// 东中转池 19041003 0号通道为液位
this.api.data.getRealData([{sn: '19041003', type: 'WTDR18X'}, (data) => {
if (data && data.constructor === Array) {
if (data.length > 0) {
if (data[0].value) {
data[0].value = Number(data[0].value) > 0 ? data[0].value : '0';
data[0].value = Number(data[0].value) <= 6.5 ? data[0].value : '6.5';
this.yewei = 6.5 - Number(data[0].value);
this.proc = 100 - (Number(data[0].value) * 100 / 6.5);
}
}
this.api.app.getDeviceData([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data.constructor === Array) {
this.devices = data;
} else {
this.api.presentMsgToast('获取数据失败');
}
}]);
// 东中转池 19041004 0,1号通道为南水 2,3号通道为北水
this.api.data.getRealData([{sn: '19041004', type: 'WTDR66C'}, (data) => {
if (data && data.constructor === Array) {
if (data.length > 0) {
if (data[0]) {
this.value[0] = !!(data[0].value === '1.0');
this.api.presentMsgToast(data.message || '获取数据失败');
}
if (data[2]) {
this.value[1] = !!(data[2].value === '1.0');
}
}
this.value = [...this.value];
} else {
this.api.presentMsgToast('获取数据失败');
}
if (time) {this.load.offLoad(); }
this.load.offLoad();
this._inv = setTimeout(() => {
this.getData(0);
}, 10000);
}, 30000);
}]);
// 东中转池 19041005 0,1号通道为1号搅拌池 2,3号通道为2号搅拌池
this.api.data.getRealData([{sn: '19041005', type: 'WTDR66C'}, (data) => {
if (data && data.constructor === Array) {
if (data.length > 0) {
if (data[0]) {
this.value[2] = !!(data[0].value === '1.0');
}
if (data[2]) {
this.value[3] = !!(data[2].value === '1.0');
this.api.app.getLiquidLevelData([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data.liquidLevel) {
this.yewei = Number(data.liquidLevel);
this.proc = (Number(data.liquidLevel) / (Number(data.liquidLevelMax) * 1.5)) * 100;
this.color = Number(data.liquidLevel) > Number(data.liquidLevelMax) ||
Number(data.liquidLevel) < Number(data.liquidLevelMin) ? 'red' : '';
}
if (data.temp) {
this.temp = Number(data.temp);
}
this.value = [...this.value];
}]);
this.api.app.getNorthSouthWaterData([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data.constructor === Array) {
this.nb = data;
this.value = this.nb.map(a => a.value);
} else {
this.api.presentMsgToast('获取数据失败');
this.api.presentMsgToast(data.message || '获取数据失败');
}
}]);
}
......
......@@ -83,7 +83,6 @@ export class HomePage implements OnInit, OnDestroy {
this.load.toLoad('加载中...', false);
}
this.api.app.getAll(['', (data) => {
console.log(data);
if (data.constructor === Array) {
this.data = data;
} else {
......@@ -107,9 +106,9 @@ export class HomePage implements OnInit, OnDestroy {
pullToRefresh(event) {
if (event === 'endReachedRefresh') {
console.log(11111111111111);
// console.log(11111111111111);
} else {
console.log(22222222222222);
// console.log(22222222222222);
}
}
}
......@@ -48,6 +48,11 @@ export class Api {
getLatestAlarm: (data) => this.trans('get', '/alarm/getLatestAlarm', data)
};
public control = {
controlBatchSwitch: (data) => this.trans('post', '/control/controlBatchSwitch', data),
controlSwitch: (data) => this.trans('post', '/control/controlSwitch', data),
};
private trans(type, addr, data) {
this.sendHttpReq(type, addr, data[0], data[1], data[2], data[3]);
}
......
......@@ -39,7 +39,6 @@ export class Mqtt {
this.msg = 'mqtt连接成功';
this.client.subscribe(this.topic);
this.client.on('message', (a, b) => {
console.log(b.toString());
this.localNotifications.schedule([{
title: '牧场报警',
text: JSON.parse(b.toString())[0].description,
......
......@@ -4,10 +4,10 @@
export const environment = {
production: false,
url: 'http://pasture.witium.com/api', // 对外访问测试网地址
// url: 'http://pasture.witium.com/api', // 对外访问测试网地址
// url: 'http://cloud-test.witium.com:8096', // 测试
// url: 'http://172.16.1.53:8097', // cy
// url: 'http://172.16.1.52:8096', // zz
url: 'http://172.16.1.52:8096', // zz
// url: 'http://172.16.1.13:8094', // 测试
};
......
<!DOCTYPE html>
<html lang="en">
<html lang="zh">
<head>
<meta charset="utf-8" />
......
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