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>
......
......@@ -5,6 +5,8 @@ import {Load} from '../../service/load';
import {shrink, stretch, zoomIn, zoomOut, fadeIn, fadeOut, up, down} from '../../animations/animations';
import {Transfer} from '../../service/transfer';
import {ActivatedRoute} from '@angular/router';
import {DatePipe} from '@angular/common';
import {Constants} from '../../service/constants';
@Component({
selector: 'v-env-cfg',
......@@ -23,16 +25,17 @@ export class EnvCfgPage implements OnInit {
};
controlModelOptions = [
{modelId: 0, modelValue: '手控模式'},
{modelId: 1, modelValue: '自控模式'}];
{modelId: 1, modelValue: '手控模式'},
{modelId: 2, modelValue: '自控模式'}];
alarmWays = [
{alarmId: '无', alarmValue: '无'},
{alarmId: '平台', alarmValue: '平台'},
{alarmId: '平台/短信', alarmValue: '平/短'}];
constructor(public alerCtrl: AlertController, private pickerController: PickerController, private alertController: AlertController,
private api: Api, private load: Load, public nav: NavController, private tf: Transfer, private ac: ActivatedRoute) {
constructor(public alertCtrl: AlertController, private pickerController: PickerController, private alertController: AlertController,
private api: Api, private load: Load, public nav: NavController, private tf: Transfer, private ac: ActivatedRoute,
private datePipe: DatePipe) {
}
isError = false;
......@@ -188,140 +191,11 @@ export class EnvCfgPage implements OnInit {
}
this.load.offLoad();
}]);
// START----------------------------------------------------
// TODO 测试用准备数据
// this.cowshedList = [
// {
// // 0-无热应激 离线 无报警
// fieldRegionNo: 'FRN136641006052720640',
// fieldRegionName: '1号牛舍',
// temp: '23.5',
// humi: '82',
// heatStressLevel: '0',
// online: 0, // 0-离线,1-在线
// alarm: 0,
// ts: '2019-08-05 23:44',
// },
// {
// // 1-轻度热应激 在线 现控 无报警
// fieldRegionNo: 'FN108050436279648256',
// fieldRegionName: '2号牛舍',
// temp: '23.5',
// humi: '82',
// heatStressLevel: '1',
// online: 1, // 0-离线,1-在线
// operationModel: 0, // 0-现控,1-平控
// alarm: 0,
// ts: '2019-08-05 23:44',
// },
// {
// // 2-中度热应激 在线 平控 非智控(手控) 有报警
// fieldRegionNo: 'FN108050436279648256',
// fieldRegionName: '3号牛舍',
// temp: '23.5',
// humi: '82',
// heatStressLevel: '2',
// online: 1, // 0-离线,1-在线
// operationModel: 1, // 0-现控,1-平控
// isWisdomModel: 0, // 0-非智控(手控),1-智控
// alarm: 1,
// ts: '2019-08-05 23:44',
// },
// {
// // 3-重度热应激 在线 平控 非智控(自控) 有报警
// fieldRegionNo: 'FN108050436279648256',
// fieldRegionName: '4号牛舍',
// temp: '23.5',
// humi: '82',
// heatStressLevel: '3',
// online: 1, // 0-离线,1-在线
// operationModel: 1, // 0-现控,1-平控
// isWisdomModel: 0, // 0-非智控(自控),1-智控
// alarm: 1,
// ts: '2019-08-05 23:44',
// },
// {
// // 4-II重度热应激 在线 平控 智控 有报警
// fieldRegionNo: 'FN108050436279648256',
// fieldRegionName: '测试用5号牛舍',
// temp: '23.5',
// humi: '82',
// heatStressLevel: '4',
// online: 1, // 0-离线,1-在线
// operationModel: 1, // 0-现控,1-平控
// isWisdomModel: 1, // 0-非智控(自控),1-智控
// alarm: 1,
// ts: '2019-08-05 23:44',
// },
// ];
// END----------------------------------------------------
}
// 获取当前牛舍配置信息
selectCowshed() {
this.api.config.getByFieldRegionNo([{fieldRegionNo: this.curFieldRegionNo}, (data) => {
// START----------------------------------------------------
// TODO 测试用准备数据
// data = {
// factoryNo: 'FN108050436279648256',
// factoryName: '一厂',
// fieldRegionNo: 'FRN136641006052720640',
// fieldRegionName: '1号牛舍',
// isWisdomModel: 1,
// propertyConfig: {toft: '1.5', hoft: '2'},
// config: [
// {fieldDeviceType: '风机',
// controlModel: '0',
// controlConfig: {TU: 28, TL: 20},
// },
// {fieldDeviceType: '喷淋',
// controlModel: '1',
// controlConfig: [{id: 1, name: '模式一', T: 21, A: 35, B: 45, interval: 55},
// {id: 2, name: '模式二', T: 21, A: 35, B: 45, interval: 55}]
// },
// {fieldDeviceType: '照明',
// controlModel: '1',
// controlConfig: [{id: 1, name: '模式A', startDate: '10-01', stopDate: '11-02', on: '19:00', off: '05:00'},
// {id: 2, name: '模式B', startDate: '10-01', stopDate: '11-02', on: '19:00', off: '05:00'}]
// },
// {fieldDeviceType: '水槽',
// controlModel: '0',
// controlConfig: {power: 100, startDate: '10-01', stopDate: '11-02'},
// }
// ],
// leave: [{type: '风机', flag: true}, {type: '喷淋', flag: false}, {type: '照明', flag: true}],
// back: [{type: '风机', flag: false}, {type: '喷淋', flag: true}, {type: '照明', flag: false}],
// environmentConfigJson: {HL: 0, HU: 100, TL: -10, TU: 50},
// heatStressList: [
// {
// heatStressLevel: '无应激',
// alarmLevel: '无',
// thi: 68
// },
// {
// heatStressLevel: '轻度应激',
// alarmLevel: '低',
// thi: 72
// },
// {
// heatStressLevel: '中度应激',
// alarmLevel: '中',
// thi: 80
// },
// {
// heatStressLevel: '重度应激',
// alarmLevel: '高',
// thi: 90
// },
// {
// heatStressLevel: 'II重度应激',
// alarmLevel: '高',
// thi: 100
// }
// ]
// };
// END----------------------------------------------------
if (data) {
data.environmentConfigJson = JSON.parse(data.environmentConfigJson.toString());
this.curCowshed = data;
......@@ -345,8 +219,10 @@ export class EnvCfgPage implements OnInit {
configInfo.map((value, index) => {
switch (value.fieldDeviceType) {
case '风机':
const fanConfig = JSON.parse(value.controlConfig);
this.fan = value;
this.isFanDisplay = this.fan.controlModel === 0 ? false : true;
this.fan.controlConfig = fanConfig;
this.isFanDisplay = this.fan.controlModel === Constants.CONTROLL_SELF;
break;
case '喷淋' :
......@@ -356,19 +232,38 @@ export class EnvCfgPage implements OnInit {
this.shower.dataConfig = value.dataConfig;
this.shower.controlConfig = showerConfig;
this.isShowerDisplay = this.shower.controlModel === 0 ? false : true;
this.isShowerDisplay = this.shower.controlModel === Constants.CONTROLL_SELF;
break;
case '照明' :
const lightConfig = JSON.parse(value.controlConfig);
// lightConfig.forEach( allCfg => {
// const lightStart = new Date( new Date().getFullYear(),
// parseInt(allCfg.config.startDate.slice(0, 2), 10),
// parseInt(allCfg.config.startDate.slice(3, 5), 10)).getTime();
// const lightStop = new Date( new Date().getFullYear(),
// parseInt(allCfg.config.stopDate.slice(0, 2), 10),
// parseInt(allCfg.config.stopDate.slice(3, 5), 10)).getTime();
// allCfg.config.startDate = lightStart;
// allCfg.config.stopDate = lightStop;
// });
this.light.fieldDeviceType = value.fieldDeviceType;
this.light.controlModel = value.controlModel;
this.light.dataConfig = value.dataConfig;
this.light.controlConfig = lightConfig;
this.isLightDisplay = this.light.controlModel === 0 ? false : true;
this.isLightDisplay = this.light.controlModel === Constants.CONTROLL_SELF;
break;
case '水槽' :
const waterChannelConfig = JSON.parse(value.controlConfig);
// const waterStart = new Date( new Date().getFullYear(),
// parseInt(waterChannelConfig.config.startDate.slice(0, 2), 10),
// parseInt(waterChannelConfig.config.startDate.slice(3, 5), 10)).getTime();
// const waterStop = new Date( new Date().getFullYear(),
// parseInt(waterChannelConfig.config.stopDate.slice(0, 2), 10),
// parseInt(waterChannelConfig.config.stopDate.slice(3, 5), 10)).getTime();
// waterChannelConfig.config.startDate = waterStart;
// waterChannelConfig.config.stopDate = waterStop;
this.waterChannel.fieldDeviceType = value.fieldDeviceType;
this.waterChannel.controlModel = value.controlModel;
this.waterChannel.dataConfig = value.dataConfig;
......@@ -384,13 +279,13 @@ export class EnvCfgPage implements OnInit {
workModeChange(device) {
switch (device) {
case 'fan':
this.isFanDisplay = this.fan.controlModel === 0 ? false : true;
this.isFanDisplay = this.fan.controlModel === Constants.CONTROLL_SELF;
break;
case 'shower' :
this.isShowerDisplay = this.shower.controlModel === 0 ? false : true;
this.isShowerDisplay = this.shower.controlModel === Constants.CONTROLL_SELF;
break;
case 'light' :
this.isLightDisplay = this.light.controlModel === 0 ? false : true;
this.isLightDisplay = this.light.controlModel === Constants.CONTROLL_SELF;
break;
default:
break;
......@@ -438,60 +333,216 @@ export class EnvCfgPage implements OnInit {
// 修改牛舍配置
updateCowshed() {
this.curCowshed.isWisdomModel = this.curCowshed.isWisdomModelChecked ? 1 : 0;
this.api.config.updateConfig([this.curCowshed, (data) => {
if (data) {
console.log('更新成功');
} else {
this.api.presentMsgToast('获取数据失败');
this.isError = true;
this.curCowshed.config = [];
this.curCowshed.config.push(this.fan);
this.curCowshed.config.push(this.shower);
this.curCowshed.config.push(this.light);
this.curCowshed.config.push(this.waterChannel);
this.updateDateFormat();
if (this.validate()) {
this.updateModels();
this.load.toLoad('加载中...', false);
this.curCowshed.isWisdomModel = this.curCowshed.isWisdomModelChecked ? 1 : 0;
this.api.config.updateConfig([this.curCowshed, (data) => {
if (data && data.code !== 0) {
this.api.presentMsgToast(data.message);
} else {
this.api.presentMsgToast('获取数据失败');
this.isError = true;
}
this.load.offLoad();
}]);
}
}
updateDateFormat() {
this.light.controlConfig.forEach( allCfg => {
allCfg.startDate = this.formatDate(allCfg.config.startDate);
allCfg.stopDate = this.formatDate(allCfg.config.stopDate);
});
this.waterChannel.controlConfig.config.startDate = this.formatDate(this.waterChannel.controlConfig.config.startDate);
this.waterChannel.controlConfig.config.stopDate = this.formatDate(this.waterChannel.controlConfig.config.stopDate);
}
updateModels() {
let fanConfig = '';
let showerConfig = '';
let lightConfig = '';
let waterChannelConfig = '';
// 风机
fanConfig = JSON.stringify(this.fan.controlConfig);
this.fan.controlConfig = fanConfig;
// 喷淋
showerConfig = JSON.stringify(this.shower.controlConfig);
this.shower.controlConfig = showerConfig;
// 照明
lightConfig = JSON.stringify(this.light.controlConfig);
this.light.controlConfig = lightConfig;
// 水槽
waterChannelConfig = JSON.stringify(this.waterChannel.controlConfig);
this.waterChannel.controlConfig = waterChannelConfig;
this.curCowshed.config = [];
this.curCowshed.config.push(this.fan);
this.curCowshed.config.push(this.shower);
this.curCowshed.config.push(this.light);
this.curCowshed.config.push(this.waterChannel);
}
validate() {
if (this.isEmpty(this.curCowshed.propertyConfig.toft)) {
this.api.presentMsgToast('请输入偏差温度');
return false;
}
if (this.isEmpty(this.curCowshed.propertyConfig.hoft)) {
this.api.presentMsgToast('请输入偏差湿度');
return false;
}
if (this.fan.controlModel === Constants.CONTROLL_SELF) {
if (this.isEmpty(this.fan.controlConfig.TU) || this.isEmpty(this.fan.controlConfig.TL)) {
this.api.presentMsgToast('请完成风机配置');
return false;
}
this.load.offLoad();
}]);
}
if (this.shower.controlModel === Constants.CONTROLL_SELF) {
let hasError = false;
this.shower.controlConfig.map(allCfg => {
if (!hasError) {
hasError = this.isEmpty(allCfg.config.name);
}
if (!hasError) {
hasError = this.isEmpty(allCfg.config.interval);
}
if (!hasError) {
hasError = this.isEmpty(allCfg.config.T);
}
if (!hasError) {
hasError = this.isEmpty(allCfg.config.A);
}
if (!hasError) {
hasError = this.isEmpty(allCfg.config.B);
}
});
if (hasError) {
this.api.presentMsgToast('请完成喷淋配置');
return false;
}
}
if (this.light.controlModel === Constants.CONTROLL_SELF) {
let hasError = false;
let hasBlank = false;
this.light.controlConfig.map(allCfg => {
if (!hasError) {
hasError = this.isEmpty(allCfg.config.name);
hasBlank = true;
}
if (!hasError) {
hasError = this.isEmpty(allCfg.config.startDate);
hasBlank = true;
}
if (!hasError) {
hasError = this.isEmpty(allCfg.config.stopDate);
hasBlank = true;
}
if (!hasError) {
hasError = this.isEmpty(allCfg.config.on);
hasBlank = true;
}
if (!hasError) {
hasError = this.isEmpty(allCfg.config.off);
hasBlank = true;
}
// if (!hasError) {
// hasError = this.validateDate(allCfg.config.startDate);
// }
// if (!hasError) {
// hasError = this.validateDate(allCfg.config.stopDate);
// }
if (!hasError) {
hasError = this.validateDateFromTo(allCfg.config.startDate, allCfg.config.stopDate);
}
});
if (hasError && hasBlank) {
this.api.presentMsgToast('请完成喷淋配置');
return false;
} else if (hasError && !hasBlank) {
this.api.presentMsgToast('喷淋配置: 请输入正确的日期范围');
return false;
}
}
if (this.isEmpty(this.waterChannel.controlConfig.config.startDate) ||
this.isEmpty(this.waterChannel.controlConfig.config.stopDate)) {
this.api.presentMsgToast('请完成水槽预警时间段配置');
return false;
} else {
let hasError = false;
// if (!hasError) {
// hasError = this.validateDate(this.waterChannel.controlConfig.config.startDate);
// }
// if (!hasError) {
// hasError = this.validateDate(this.waterChannel.controlConfig.config.stopDate);
// }
if (!hasError) {
hasError = this.validateDateFromTo(this.waterChannel.controlConfig.config.startDate,
this.waterChannel.controlConfig.config.stopDate);
}
if (hasError) {
this.api.presentMsgToast('水槽预警时间段配置: 请输入正确的日期范围');
return false;
}
}
if (this.isEmpty(this.curCowshed.environmentConfigJson.TU) ||
this.isEmpty(this.curCowshed.environmentConfigJson.TL) ||
this.isEmpty(this.curCowshed.environmentConfigJson.HU) ||
this.isEmpty(this.curCowshed.environmentConfigJson.HL) ||
this.isEmpty(this.curCowshed.environmentConfigJson.NH3U) ||
this.isEmpty(this.curCowshed.environmentConfigJson.NH3L)) {
this.api.presentMsgToast('请完成环境参数预警配置');
return false;
}
return true;
}
isEmpty(item) {
let hasError = false;
if (item === undefined || item === null || item === '') {
hasError = true;
}
return hasError;
}
validateDate(date) {
// let hasError = false;
// const month = parseInt(date.slice(0, 2), 10);
// const day = parseInt(date.slice(2, 4), 10);
// const newDate = new Date(new Date().getFullYear(), month, day);
// if (newDate.getMonth() === month && newDate.getMonth() === day) {
// hasError = true;
// }
// return hasError;
return false;
}
validateDateFromTo(dateFrom, dateTo) {
let hasError = false;
const fromMonth = parseInt(dateFrom.slice(0, 2), 10);
const fromDay = parseInt(dateFrom.slice(2, 4), 10);
const from = new Date(new Date().getFullYear(), fromMonth, fromDay).valueOf();
const toMonth = parseInt(dateTo.slice(0, 2), 10);
const toDay = parseInt(dateTo.slice(2, 4), 10);
const to = new Date(new Date().getFullYear(), toMonth, toDay).valueOf();
if (from > to) {
hasError = true;
}
return hasError;
}
onReferenceModel() {
let popFanModels = {};
this.api.devicePatternModel.getByFactoryNoAndType([{factoryNo: this.curCowshed.factoryNo, fieldDeviceType: '风机'}, (data) => {
// START---------------------------------------------------------
// TODO 测试用数据
// data = [{
// patternModelNo: '1234681324789546',
// patternModelName: '春季1',
// fieldDeviceType: '风机',
// configJson: {name: '模式名A', TU: 20, TL: -10},
// factoryNo: 'FN108050436279648256',
// factoryName: '一厂',
// remark: '测试'
// },
// {
// patternModelNo: '1234681324789546',
// patternModelName: '夏季2',
// fieldDeviceType: '风机',
// configJson: {name: '模式名A', TU: 20, TL: -10},
// factoryNo: 'FN108050436279648256',
// factoryName: '一厂',
// remark: '测试'
// },
// {
// patternModelNo: '1234681324789546',
// patternModelName: '秋季3',
// fieldDeviceType: '风机',
// configJson: {name: '模式名A', TU: 20, TL: -10},
// factoryNo: 'FN108050436279648256',
// factoryName: '一厂',
// remark: '测试'
// },
// {
// patternModelNo: '1234681324789546',
// patternModelName: '冬季4',
// fieldDeviceType: '风机',
// configJson: {name: '模式名', TU: 20, TL: -10},
// factoryNo: 'FN108050436279648256',
// factoryName: '一厂',
// remark: '测试'
// }];
// END---------------------------------------------------------
if (data) {
popFanModels = data;
this.selectModel('风机', 1, popFanModels);
......@@ -504,45 +555,6 @@ export class EnvCfgPage implements OnInit {
let popShowerModels = {};
this.api.devicePatternModel.getByFactoryNoAndType([{factoryNo: this.curCowshed.factoryNo, fieldDeviceType: '喷淋'}, (data) => {
// START---------------------------------------------------------
// TODO 测试用数据
// data = [{
// patternModelNo: '1234681324789546',
// patternModelName: '春季1',
// fieldDeviceType: '喷淋',
// configJson: {name: '模式名A', T: 25, offset: 3, A: 25, B: 25, interval: 30},
// factoryNo: 'FN108050436279648256',
// factoryName: '一厂',
// remark: '测试'
// },
// {
// patternModelNo: '1234681324789546',
// patternModelName: '夏季2',
// fieldDeviceType: '喷淋',
// configJson: {name: '模式名A', T: 25, offset: 3, A: 25, B: 25, interval: 30},
// factoryNo: 'FN108050436279648256',
// factoryName: '一厂',
// remark: '测试'
// },
// {
// patternModelNo: '1234681324789546',
// patternModelName: '秋季3',
// fieldDeviceType: '风机',
// configJson: {name: '模式名A', T: 25, offset: 3, A: 25, B: 25, interval: 30},
// factoryNo: 'FN108050436279648256',
// factoryName: '一厂',
// remark: '测试'
// },
// {
// patternModelNo: '1234681324789546',
// patternModelName: '冬季4',
// fieldDeviceType: '风机',
// configJson: {name: '模式名A', T: 25, offset: 3, A: 25, B: 25, interval: 30},
// factoryNo: 'FN108050436279648256',
// factoryName: '一厂',
// remark: '测试'
// }];
// END---------------------------------------------------------
if (data) {
popShowerModels = data;
this.selectModel('喷淋', 2, popShowerModels);
......@@ -555,49 +567,7 @@ export class EnvCfgPage implements OnInit {
let popLightModels = {};
this.api.devicePatternModel.getByFactoryNoAndType([{factoryNo: this.curCowshed.factoryNo, fieldDeviceType: '照明'}, (data) => {
// START---------------------------------------------------------
// TODO 测试用数据
// data = [{
// patternModelNo: '1234681324789546',
// patternModelName: '春季1',
// fieldDeviceType: '照明',
// configJson: [{name: '模式名A', startDate: '03-01', stopDate: '05-01', on: '19:00', off: '07:00'},
// {name: '模式名B', startDate: '03-01', stopDate: '05-01', on: '19:00', off: '07:00'}],
// factoryNo: 'FN108050436279648256',
// factoryName: '一厂',
// remark: '测试'
// },
// {
// patternModelNo: '1234681324789546',
// patternModelName: '夏季2',
// fieldDeviceType: '风机',
// configJson: [{name: '模式名A', startDate: '03-01', stopDate: '05-01', on: '19:00', off: '07:00'},
// {name: '模式名B', startDate: '03-01', stopDate: '05-01', on: '19:00', off: '07:00'}],
// factoryNo: 'FN108050436279648256',
// factoryName: '一厂',
// remark: '测试'
// },
// {
// patternModelNo: '1234681324789546',
// patternModelName: '秋季3',
// fieldDeviceType: '风机',
// configJson: [{name: '模式名A', startDate: '03-01', stopDate: '05-01', on: '19:00', off: '07:00'},
// {name: '模式名B', startDate: '03-01', stopDate: '05-01', on: '19:00', off: '07:00'}],
// factoryNo: 'FN108050436279648256',
// factoryName: '一厂',
// remark: '测试'
// },
// {
// patternModelNo: '1234681324789546',
// patternModelName: '冬季4',
// fieldDeviceType: '风机',
// configJson: [{name: '模式名A', startDate: '03-01', stopDate: '05-01', on: '19:00', off: '07:00'},
// {name: '模式名B', startDate: '03-01', stopDate: '05-01', on: '19:00', off: '07:00'}],
// factoryNo: 'FN108050436279648256',
// factoryName: '一厂',
// remark: '测试'
// }];
// END---------------------------------------------------------
if (data) {
popLightModels = data;
this.selectModel('照明', 3, popLightModels);
......@@ -651,7 +621,7 @@ export class EnvCfgPage implements OnInit {
value: 'other',
checked: false});
}
const alert = await this.alerCtrl.create({
const alert = await this.alertCtrl.create({
header: deviceName + '常用模式选择',
inputs: list,
buttons: [
......@@ -730,4 +700,11 @@ export class EnvCfgPage implements OnInit {
this.nav.navigateForward(query);
}
formatDate(date) {
let formatDate = date;
if (date.toString().length !== 5) {
formatDate = this.datePipe.transform(date, 'MM-dd');
}
return formatDate;
}
}
......@@ -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