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

中转池页面改接口

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