diff --git a/admin/app/controllers/settings/knowledgefile/knowledgefile.controller.js b/admin/app/controllers/settings/knowledgefile/knowledgefile.controller.js
index e591a6ef..997f315b 100644
--- a/admin/app/controllers/settings/knowledgefile/knowledgefile.controller.js
+++ b/admin/app/controllers/settings/knowledgefile/knowledgefile.controller.js
@@ -80,7 +80,7 @@ app.controller('KnowledgeFileController', function (
toaster.pop({
type: $translate.instant('TOASTER.SUCCESS'),
title: $translate.instant('TOASTER.SUCCESS_TITLE'),
- body: $translate.instant('KNOWLEDGEFILE.RESTORE_SUCCESS'),
+ body: $translate.instant('SETTING.RESTORE_SUCCESS'),
showCloseButton: true,
});
$scope.getAllKnowledgeFiles();
diff --git a/admin/app/controllers/settings/meter/offline-meter-file.controller.js b/admin/app/controllers/settings/meter/offline-meter-file.controller.js
index 99af4854..e72c9f7e 100644
--- a/admin/app/controllers/settings/meter/offline-meter-file.controller.js
+++ b/admin/app/controllers/settings/meter/offline-meter-file.controller.js
@@ -84,7 +84,26 @@ app.controller('OfflineMeterFileController', function(
}
};
-
+ $scope.restoreOfflineMeterFile = function (offlinemeterfile) {
+ OfflineMeterFileService.restoreOfflineMeterFile(offlinemeterfile, function (error, data) {
+ if (!error) {
+ toaster.pop({
+ type: $translate.instant('TOASTER.SUCCESS'),
+ title: $translate.instant('TOASTER.SUCCESS_TITLE'),
+ body: $translate.instant('SETTING.RESTORE_SUCCESS'),
+ showCloseButton: true,
+ });
+ $scope.getAllOfflineMeterFiles();
+ } else {
+ toaster.pop({
+ type: $translate.instant('TOASTER.ERROR'),
+ title: $translate.instant(error.title),
+ body: $translate.instant(error.description),
+ showCloseButton: true,
+ });
+ }
+ });
+ };
$scope.deleteOfflineMeterFile = function(offlinemeterfile) {
SweetAlert.swal({
diff --git a/admin/app/services/settings/meter/offline-meter-file.service.js b/admin/app/services/settings/meter/offline-meter-file.service.js
index 6b4045e7..94e4b2d7 100644
--- a/admin/app/services/settings/meter/offline-meter-file.service.js
+++ b/admin/app/services/settings/meter/offline-meter-file.service.js
@@ -37,6 +37,15 @@ app.factory('OfflineMeterFileService', function($http) {
callback(e,status);
});
},
+ restoreOfflineMeterFile: function (offlinemeterfile, callback) {
+ $http.get(getAPI() + 'offlinemeterfiles/' + offlinemeterfile.id + '/restore')
+ .success(function (response, status, headers, config) {
+ callback(null, response);
+ })
+ .error(function (e, status) {
+ callback(e, status);
+ });
+ },
deleteOfflineMeterFile: function(offlinemeterfile, callback) {
$http.delete(getAPI()+'offlinemeterfiles/'+offlinemeterfile.id)
.success(function (response, status, headers, config) {
diff --git a/admin/app/translations.js b/admin/app/translations.js
index e71d69fd..5d38a3ec 100644
--- a/admin/app/translations.js
+++ b/admin/app/translations.js
@@ -128,39 +128,6 @@ function config($translateProvider) {
},
MENU: {
- SPACE: 'Space',
- TENANT: 'Tenant',
- STORE: 'Store',
- MAINEQUIPMENT: 'Main Equipment',
- EQUIPMENTSTATUS: 'Equipment Status',
- EQUIPMENT_DETAILS: {
- EQUIPMENT_DETAILS: 'Equipment Details',
- CHILLER: 'Chiller',
- AIR_COMPRESSOR: 'Air Compressor',
- AIR_HANDLING_UNIT: 'Air Handling Unit',
- CHILLED_WATER_PUMP: 'Chilled Water Pump',
- COOLING_TOWER: 'Cooling Tower',
- COOLING_WATER_PUMP: 'Cooling Water Pump',
- HEAT_PUMP: 'Heat Pump',
- GROUND_SOURCE_HEAT_PUMP: 'Ground Source Heat Pump',
- STEAM_BOILER: 'Steam Boiler',
- },
-
- FDD: {
- FDD: 'FDD',
- RULE: 'Rule Settings',
- MESSAGEALARM: 'SMS Alarm',
- EMAILALARM: 'Email Alarm',
- WEBALARM: 'Web Alarm',
- WECHATALARM: 'WeChat Alarm',
- },
- VERIFICATION: {
- VERIFICATION: 'Data Verification',
- METER_VALIDATE: 'Meter Validation',
- METER_ENERGY: 'Meter Energy',
- METER_STATUS: 'Meter Status',
- GATEWAY: 'Gateway',
- },
SETTINGS: {
BASIC: 'Basic Settings',
SETTINGS: 'System Settings',
@@ -184,6 +151,14 @@ function config($translateProvider) {
CONTACT: 'Contacts',
KNOWLEDGEFILE: 'Knowledge Base Settings'
},
+ FDD: {
+ FDD: 'FDD',
+ RULE: 'Rule Settings',
+ MESSAGEALARM: 'SMS Alarm',
+ EMAILALARM: 'Email Alarm',
+ WEBALARM: 'Web Alarm',
+ WECHATALARM: 'WeChat Alarm',
+ },
USERSETTING: {
USERSETTING: 'Users & Privileges',
USER: 'User Settings',
@@ -384,8 +359,11 @@ function config($translateProvider) {
METER_DATA: 'Meter Data',
START_ENERGY: 'Start Energy Value',
END_ENERGY: 'End Energy Value',
- // ENERGY_VALUE: 'Energy Value',
DIFF_VALUE: 'Diff Value',
+
+ RESTORE: 'Restore',
+ RESTORE_SUCCESS: 'Restore Success',
+ RESTORE_FAILED: 'Restore Failed',
},
CONTACT: {
EMAIL: 'Email',
@@ -659,10 +637,7 @@ function config($translateProvider) {
KNOWLEDGE_FILE_LIST: 'Knowledge File List',
UPLOAD_USER: 'Upload User',
UPLOAD_TIME: 'Upload Time',
- RESTORE: 'Restore',
DELETE: 'Delete',
- RESTORE_SUCCESS: 'Restore Success',
- RESTORE_FAILED: 'Restore Failed'
},
TOASTER: {
FAILURE_TITLE: 'Error',
@@ -730,12 +705,6 @@ function config($translateProvider) {
ANALYSIS_DATE: 'Analysis Date',
BASELINE_DATE: 'Baseline Date',
- STEAM_OUTPUT: 'Steam Output',
- STEAM_OUTPUT_VALUE: 'Steam Output Value',
- TOTAL_STEAM_VALUE: 'Total electricity cost + Total tap water fee + Steam production value',
-
- ELECTRICITY_MONITORING: 'Electricity Monitoring',
-
EQUIPMENT: 'Equipment',
ENERGY_WITH_UNIT: 'Energy Consumption-kWh',
PUPEC_WITH_UNIT: 'Per Unit Product Energy Consumption-kWh',
@@ -1183,37 +1152,6 @@ function config($translateProvider) {
ACKNOWLEDGE_ALARM: '是否确认报警?',
},
MENU: {
- SPACE: '空间能耗',
- MAINEQUIPMENT: '重点设备能耗',
- PRODUCT: '单位产品能耗',
- EQUIPMENTSTATUS: '设备状态能耗',
- EQUIPMENT_DETAILS: {
- EQUIPMENT_DETAILS: '设备详情',
- CHILLER: '制冷机组',
- AIR_COMPRESSOR: '空压机',
- AIR_HANDLING_UNIT: '空气处理机组',
- CHILLED_WATER_PUMP: '冷冻水泵',
- COOLING_TOWER: '冷却塔',
- COOLING_WATER_PUMP: '冷却水泵',
- HEAT_PUMP: '热泵',
- GROUND_SOURCE_HEAT_PUMP: '地源热泵',
- STEAM_BOILER: '蒸汽锅炉',
- },
- FDD: {
- FDD: '故障检测与诊断',
- RULE: '规则管理',
- MESSAGEALARM: '短信报警',
- EMAILALARM: '邮件报警',
- WEBALARM: '网页报警',
- WECHATALARM: '微信报警',
- },
- VERIFICATION: {
- VERIFICATION: '数据校验',
- METER_VALIDATE: '表读数',
- METER_ENERGY: '表能耗',
- METER_STATUS: '表状态',
- GATEWAY: '网关',
- },
SETTINGS: {
BASIC: '基本设置',
SETTINGS: '系统管理',
@@ -1238,6 +1176,14 @@ function config($translateProvider) {
CONTACT: '联系人管理',
KNOWLEDGEFILE: '知识库管理'
},
+ FDD: {
+ FDD: '故障检测与诊断',
+ RULE: '规则管理',
+ MESSAGEALARM: '短信报警',
+ EMAILALARM: '邮件报警',
+ WEBALARM: '网页报警',
+ WECHATALARM: '微信报警',
+ },
USERSETTING: {
USERSETTING: '用户与权限',
USER: '用户设置',
@@ -1439,7 +1385,6 @@ function config($translateProvider) {
USER: '用户',
-
TEAM: '班组',
ADD_TEAM: '添加班组',
EDIT_TEAM: '编辑班组',
@@ -1447,8 +1392,11 @@ function config($translateProvider) {
METER_DATA: '计量表数据',
START_ENERGY: '起始能耗值',
END_ENERGY: '结束能耗值',
- // ENERGY_VALUE: '能耗值',
DIFF_VALUE: '差值',
+
+ RESTORE: '恢复',
+ RESTORE_SUCCESS: '恢复成功',
+ RESTORE_FAILED: '恢复失败',
},
CONTACT: {
EMAIL: '邮箱',
@@ -1729,10 +1677,7 @@ function config($translateProvider) {
KNOWLEDGE_FILE_LIST: '知识文件列表',
UPLOAD_USER: '上传者',
UPLOAD_TIME: '上传时间',
- RESTORE: '恢复',
DELETE: '删除',
- RESTORE_SUCCESS: '恢复成功',
- RESTORE_FAILED: '恢复失败'
},
TOASTER: {
FAILURE: '失败',
@@ -1802,16 +1747,6 @@ function config($translateProvider) {
ANALYSIS_DATE: '分析日期',
BASELINE_DATE: '基准日期',
- STEAM_OUTPUT: '蒸汽产出',
- STEAM_OUTPUT_VALUE: '蒸汽产值',
- TOTAL_STEAM_VALUE: '总电费+总自来水费+蒸汽产值',
-
- ELECTRICITY_MONITORING: '电力监控',
- ENERGY_UNIT_ONE: '新园区',
- ENERGY_UNIT_TWO: '化药组团动力中心',
- ENERGY_UNIT_THREE: '生物组团动力中心',
- ENERGY_UNIT_FOUR: '化药组团生产车间',
-
EQUIPMENT: '设备',
ENERGY_WITH_UNIT: '能耗-kWh',
PUPEC_WITH_UNIT: '单位产品能耗-kWh',
@@ -2235,37 +2170,6 @@ function config($translateProvider) {
ACKNOWLEDGE_ALARM: 'Bestätigen Sie den Alarm?',
},
MENU: {
- SPACE: 'Raumenergieverbrauch',
- MAINEQUIPMENT: 'Energieverbrauch der Schlüsselausrüstung',
- PRODUCT: 'Energieverbrauch pro Produkteinheit',
- EQUIPMENTSTATUS: 'Gerätestatus Energieverbrauch',
- EQUIPMENT_DETAILS: {
- EQUIPMENT_DETAILS: 'Gerätedetails',
- CHILLER: 'Kühleinheit',
- AIR_COMPRESSOR: 'Luftkompressor',
- AIR_HANDLING_UNIT: 'Lüftungsgerät',
- CHILLED_WATER_PUMP: 'Kühlwasserpumpen',
- COOLING_TOWER: 'Kühlturm',
- COOLING_WATER_PUMP: 'Kühlwasserpumpe',
- HEAT_PUMP: 'Wärmepumpe',
- GROUND_SOURCE_HEAT_PUMP: 'Erdwärmepumpe',
- STEAM_BOILER: 'Dampfer',
- },
- FDD: {
- FDD: 'Fehlererkennung und -diagnose',
- RULE: 'Regelverwaltung',
- MESSAGEALARM: 'SMS-Alarm',
- EMAILALARM: 'E-Mail-Alarm',
- WEBALARM: 'Webseitenalarm',
- WECHATALARM: 'WeChat Alarm',
- },
- VERIFICATION: {
- VERIFICATION: 'Datenvalidierung',
- METER_VALIDATE: 'Zählerstand',
- METER_ENERGY: 'Tabelle Energieverbrauch',
- METER_STATUS: 'Tabellenstatus',
- GATEWAY: 'Tor',
- },
SETTINGS: {
BASIC: 'Grundeinstellungen',
SETTINGS: 'Systemmanagement',
@@ -2290,6 +2194,14 @@ function config($translateProvider) {
CONTACT: 'Kontaktmanagement',
KNOWLEDGEFILE: 'Wissensdatenbankverwaltung'
},
+ FDD: {
+ FDD: 'Fehlererkennung und -diagnose',
+ RULE: 'Regelverwaltung',
+ MESSAGEALARM: 'SMS-Alarm',
+ EMAILALARM: 'E-Mail-Alarm',
+ WEBALARM: 'Webseitenalarm',
+ WECHATALARM: 'WeChat Alarm',
+ },
USERSETTING: {
USERSETTING: 'Benutzer und Berechtigungen',
USER: 'Benutzereinstellungen',
@@ -2499,8 +2411,11 @@ function config($translateProvider) {
METER_DATA: 'Zählerdaten',
START_ENERGY: 'Anfangsenergieverbrauchswert',
END_ENERGY: 'Ende des Energieverbrauchs',
- // ENERGY_VALUE: 'Energieverbrauchswert',
DIFF_VALUE: 'Unterschied',
+
+ RESTORE: 'wiederherstellen',
+ RESTORE_SUCCESS: 'Erfolgreiche Genesung',
+ RESTORE_FAILED: 'Wiederherstellung fehlgeschlagen',
},
CONTACT: {
EMAIL: 'Briefkasten',
@@ -2780,10 +2695,7 @@ function config($translateProvider) {
KNOWLEDGE_FILE_LIST: 'Liste der Wissensdateien',
UPLOAD_USER: 'hochgeladen von',
UPLOAD_TIME: 'Upload-Zeit',
- RESTORE: 'wiederherstellen',
DELETE: 'löschen',
- RESTORE_SUCCESS: 'Erfolgreiche Genesung',
- RESTORE_FAILED: 'Wiederherstellung fehlgeschlagen'
},
TOASTER: {
FAILURE: 'Fehler',
@@ -2853,16 +2765,6 @@ function config($translateProvider) {
ANALYSIS_DATE: 'Analysedatum',
BASELINE_DATE: 'Basisdatum',
- STEAM_OUTPUT: 'Dampferzeugung',
- STEAM_OUTPUT_VALUE: 'Dampfproduktionswert',
- TOTAL_STEAM_VALUE: 'Gesamtstromrechnung + Gesamtleitungswasserrechnung + Dampfproduktionswert',
-
- ELECTRICITY_MONITORING: 'Leistungsüberwachung',
- ENERGY_UNIT_ONE: 'Neuer Park',
- ENERGY_UNIT_TWO: 'Power Center der Chemical and Pharmaceutical Group',
- ENERGY_UNIT_THREE: 'Power Center der Biologischen Gruppe',
- ENERGY_UNIT_FOUR: 'Produktionswerkstatt für chemische Arzneimittelgruppen',
-
EQUIPMENT: 'Ausrüstung',
ENERGY_WITH_UNIT: 'Energieverbrauch-kWh',
PUPEC_WITH_UNIT: 'Energieverbrauch pro Produkteinheit-kWh',
diff --git a/admin/views/settings/knowledgefile/knowledgefile.html b/admin/views/settings/knowledgefile/knowledgefile.html
index 61321905..2e0240d2 100644
--- a/admin/views/settings/knowledgefile/knowledgefile.html
+++ b/admin/views/settings/knowledgefile/knowledgefile.html
@@ -25,7 +25,7 @@
{{ knowledgefile.upload_datetime | date:'yyyy-MM-dd HH:mm'}} |
{{'KNOWLEDGEFILE.RESTORE' | translate}}
+ class="btn btn-danger btn-rounded btn-xs">{{'SETTING.RESTORE' | translate}}
{{'KNOWLEDGEFILE.DELETE' | translate}}
|
diff --git a/admin/views/settings/meter/meter.html b/admin/views/settings/meter/meter.html
index 0f34f7a6..99c613ea 100644
--- a/admin/views/settings/meter/meter.html
+++ b/admin/views/settings/meter/meter.html
@@ -313,6 +313,8 @@
{{ offlinemeterfile.upload_datetime | date:'yyyy-MM-dd HH:mm'}}
+ {{'SETTING.RESTORE' | translate}}
{{'SETTING.DELETE' | translate}}
|
diff --git a/myems-api/MyEMS.postman_collection.json b/myems-api/MyEMS.postman_collection.json
index 924df9b3..106b66ce 100644
--- a/myems-api/MyEMS.postman_collection.json
+++ b/myems-api/MyEMS.postman_collection.json
@@ -2713,17 +2713,17 @@
"response": []
},
{
- "name": "GET Rstore a Knowledge File by ID",
+ "name": "GET Rstore an Offline Meter File by ID",
"request": {
"method": "GET",
"header": [],
"url": {
- "raw": "{{base_url}}/knowledgefiles/1/restore",
+ "raw": "{{base_url}}/offlinemeterfiles/1/restore",
"host": [
"{{base_url}}"
],
"path": [
- "knowledgefiles",
+ "offlinemeterfiles",
"1",
"restore"
]
@@ -3264,6 +3264,25 @@
},
"response": []
},
+ {
+ "name": "GET Rstore a Knowledge File by ID",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{base_url}}/knowledgefiles/1/restore",
+ "host": [
+ "{{base_url}}"
+ ],
+ "path": [
+ "knowledgefiles",
+ "1",
+ "restore"
+ ]
+ }
+ },
+ "response": []
+ },
{
"name": "POST Upload a Offline Meter File",
"request": {
diff --git a/myems-api/README.md b/myems-api/README.md
index 9dc7ef25..53de1156 100644
--- a/myems-api/README.md
+++ b/myems-api/README.md
@@ -1109,6 +1109,10 @@ $ curl -i -X DELETE {{base_url}}/offlinemeterfiles/{id}
```bash
$ curl -i -H "Content-Type: application/TBD" -X POST -d 'file: (binary)' {{base_url}}/offlinemeterfiles
```
+* GET Restore an Offline Meter File by ID from database to disk
+```bash
+$ curl -i -X GET {{base_url}}/offlinemeterfiles/{id}/restore
+```
### Point
diff --git a/myems-api/app.py b/myems-api/app.py
index 7cf363e9..083a0fed 100644
--- a/myems-api/app.py
+++ b/myems-api/app.py
@@ -266,6 +266,8 @@ api.add_route('/offlinemeterfiles',
offlinemeterfile.OfflineMeterFileCollection())
api.add_route('/offlinemeterfiles/{id_}',
offlinemeterfile.OfflineMeterFileItem())
+api.add_route('/offlinemeterfiles/{id_}/restore',
+ offlinemeterfile.OfflineMeterFileRestore())
api.add_route('/points',
point.PointCollection())
diff --git a/myems-api/core/offlinemeterfile.py b/myems-api/core/offlinemeterfile.py
index 37de469b..bbba93ed 100644
--- a/myems-api/core/offlinemeterfile.py
+++ b/myems-api/core/offlinemeterfile.py
@@ -219,3 +219,58 @@ class OfflineMeterFileItem:
cnx.disconnect()
resp.status = falcon.HTTP_204
+
+
+class OfflineMeterFileRestore:
+ @staticmethod
+ def __init__():
+ pass
+
+ @staticmethod
+ def on_options(req, resp, id_):
+ resp.status = falcon.HTTP_200
+
+ @staticmethod
+ def on_get(req, resp, id_):
+ if not id_.isdigit() or int(id_) <= 0:
+ raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
+ description='API.INVALID_OFFLINE_METER_FILE_ID')
+
+ cnx = mysql.connector.connect(**config.myems_historical_db)
+ cursor = cnx.cursor()
+
+ query = (" SELECT uuid, file_object "
+ " FROM tbl_offline_meter_files "
+ " WHERE id = %s ")
+ cursor.execute(query, (id_,))
+ row = cursor.fetchone()
+ cursor.close()
+ cnx.disconnect()
+
+ if row is None:
+ raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND',
+ description='API.OFFLINE_METER_FILE_NOT_FOUND')
+
+ result = {"uuid": row[0],
+ "file_object": row[1]}
+ try:
+ raw_blob = result["file_object"]
+ file_uuid = result["uuid"]
+
+ # Define file_path
+ file_path = os.path.join(config.upload_path, file_uuid)
+
+ # Write to a temporary file to prevent incomplete files from
+ # being used.
+ temp_file_path = file_path + '~'
+
+ open(temp_file_path, 'wb').write(raw_blob)
+
+ # Now that we know the file has been fully saved to disk
+ # move it into place.
+ os.replace(temp_file_path, file_path)
+ except Exception as ex:
+ raise falcon.HTTPError(falcon.HTTP_400, title='API.ERROR',
+ description='API.FAILED_TO_RESTORE_OFFLINE_METER_FILE')
+ resp.body = 'success'
+ resp.status = falcon.HTTP_200
diff --git a/web/src/components/MyEMS/Equipment/EquipmentBatch.js b/web/src/components/MyEMS/Equipment/EquipmentBatch.js
new file mode 100644
index 00000000..6ee0e0a2
--- /dev/null
+++ b/web/src/components/MyEMS/Equipment/EquipmentBatch.js
@@ -0,0 +1,330 @@
+import React, { Fragment, useEffect, useState } from 'react';
+import {
+ Breadcrumb,
+ BreadcrumbItem,
+ Row,
+ Col,
+ Card,
+ CardBody,
+ Button,
+ ButtonGroup,
+ Form,
+ FormGroup,
+ Input,
+ Label,
+ CustomInput,
+ Spinner,
+} from 'reactstrap';
+import Datetime from 'react-datetime';
+import moment from 'moment';
+import loadable from '@loadable/component';
+import Cascader from 'rc-cascader';
+import { getCookieValue, createCookie } from '../../../helpers/utils';
+import withRedirect from '../../../hoc/withRedirect';
+import { withTranslation } from 'react-i18next';
+import { toast } from 'react-toastify';
+import ButtonIcon from '../../common/ButtonIcon';
+import { APIBaseURL } from '../../../config';
+
+
+const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
+
+
+const EquipmentBatch = ({ setRedirect, setRedirectUrl, t }) => {
+ let current_moment = moment();
+ useEffect(() => {
+ let is_logged_in = getCookieValue('is_logged_in');
+ let user_name = getCookieValue('user_name');
+ let user_display_name = getCookieValue('user_display_name');
+ let user_uuid = getCookieValue('user_uuid');
+ let token = getCookieValue('token');
+ if (is_logged_in === null || !is_logged_in) {
+ setRedirectUrl(`/authentication/basic/login`);
+ setRedirect(true);
+ } else {
+ //update expires time of cookies
+ createCookie('is_logged_in', true, 1000 * 60 * 60 * 8);
+ createCookie('user_name', user_name, 1000 * 60 * 60 * 8);
+ createCookie('user_display_name', user_display_name, 1000 * 60 * 60 * 8);
+ createCookie('user_uuid', user_uuid, 1000 * 60 * 60 * 8);
+ createCookie('token', token, 1000 * 60 * 60 * 8);
+ }
+ });
+ // State
+ // Query Parameters
+ const [selectedSpaceName, setSelectedSpaceName] = useState(undefined);
+ const [selectedSpaceID, setSelectedSpaceID] = useState(undefined);
+ const [equipmentList, setEquipmentList] = useState([]);
+ const [reportingPeriodBeginsDatetime, setReportingPeriodBeginsDatetime] = useState(current_moment.clone().startOf('month'));
+ const [reportingPeriodEndsDatetime, setReportingPeriodEndsDatetime] = useState(current_moment);
+ const [cascaderOptions, setCascaderOptions] = useState(undefined);
+
+ // buttons
+ const [submitButtonDisabled, setSubmitButtonDisabled] = useState(false);
+ const [spinnerHidden, setSpinnerHidden] = useState(true);
+ const [exportButtonHidden, setExportButtonHidden] = useState(true);
+
+ //Results
+ const [detailedDataTableColumns, setDetailedDataTableColumns] = useState(
+ [{dataField: 'name', text: t('Name'), sort: true}, {dataField: 'space', text: t('Space'), sort: true}]);
+ const [excelBytesBase64, setExcelBytesBase64] = useState(undefined);
+
+ useEffect(() => {
+ let isResponseOK = false;
+ fetch(APIBaseURL + '/spaces/tree', {
+ method: 'GET',
+ headers: {
+ "Content-type": "application/json",
+ "User-UUID": getCookieValue('user_uuid'),
+ "Token": getCookieValue('token')
+ },
+ body: null,
+
+ }).then(response => {
+ console.log(response);
+ if (response.ok) {
+ isResponseOK = true;
+ }
+ return response.json();
+ }).then(json => {
+ console.log(json);
+ if (isResponseOK) {
+ // rename keys
+ json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":'));
+ setCascaderOptions(json);
+ // set the default selected space
+ setSelectedSpaceName([json[0]].map(o => o.label));
+ setSelectedSpaceID([json[0]].map(o => o.value));
+
+ setSubmitButtonDisabled(false);
+ setSpinnerHidden(true);
+ } else {
+ toast.error(json.description);
+ }
+ }).catch(err => {
+ console.log(err);
+ });
+
+ }, []);
+
+ const labelClasses = 'ls text-uppercase text-600 font-weight-semi-bold mb-0';
+
+ let onSpaceCascaderChange = (value, selectedOptions) => {
+ setSelectedSpaceName(selectedOptions.map(o => o.label).join('/'));
+ setSelectedSpaceID(value[value.length - 1]);
+ setEquipmentList([]);
+ setExportButtonHidden(true);
+ setSubmitButtonDisabled(false);
+ }
+ let onReportingPeriodBeginsDatetimeChange = (newDateTime) => {
+ setReportingPeriodBeginsDatetime(newDateTime);
+ }
+
+ let onReportingPeriodEndsDatetimeChange = (newDateTime) => {
+ setReportingPeriodEndsDatetime(newDateTime);
+ }
+
+ var getValidReportingPeriodBeginsDatetimes = function (currentDate) {
+ return currentDate.isBefore(moment(reportingPeriodEndsDatetime, 'MM/DD/YYYY, hh:mm:ss a'));
+ }
+
+ var getValidReportingPeriodEndsDatetimes = function (currentDate) {
+ return currentDate.isAfter(moment(reportingPeriodBeginsDatetime, 'MM/DD/YYYY, hh:mm:ss a'));
+ }
+
+ // Handler
+ const handleSubmit = e => {
+ e.preventDefault();
+ console.log('handleSubmit');
+ console.log(selectedSpaceID);
+ console.log(reportingPeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss'));
+ console.log(reportingPeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss'));
+
+ // disable submit button
+ setSubmitButtonDisabled(true);
+ // show spinner
+ setSpinnerHidden(false);
+ // hide export buttion
+ setExportButtonHidden(true)
+
+ // Reinitialize tables
+ setEquipmentList([]);
+
+ let isResponseOK = false;
+ fetch(APIBaseURL + '/reports/equipmentbatch?' +
+ 'spaceid=' + selectedSpaceID +
+ '&reportingperiodstartdatetime=' + reportingPeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') +
+ '&reportingperiodenddatetime=' + reportingPeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss'), {
+ method: 'GET',
+ headers: {
+ "Content-type": "application/json",
+ "User-UUID": getCookieValue('user_uuid'),
+ "Token": getCookieValue('token')
+ },
+ body: null,
+
+ }).then(response => {
+ if (response.ok) {
+ isResponseOK = true;
+ };
+ return response.json();
+ }).then(json => {
+ if (isResponseOK) {
+ console.log(json)
+ let equipments = [];
+ if (json['equipments'].length > 0) {
+ json['equipments'].forEach((currentEquipment, index) => {
+ let detailed_value = {};
+ detailed_value['id'] = currentEquipment['id'];
+ detailed_value['name'] = currentEquipment['equipment_name'];
+ detailed_value['space'] = currentEquipment['space_name'];
+ detailed_value['costcenter'] = currentEquipment['cost_center_name'];
+ currentEquipment['values'].forEach((currentValue, energyCategoryIndex) => {
+ detailed_value['a' + energyCategoryIndex] = currentValue.toFixed(2);
+ });
+ equipments.push(detailed_value);
+ });
+ };
+
+ setEquipmentList(equipments);
+
+ let detailed_column_list = [];
+ detailed_column_list.push({
+ dataField: 'name',
+ text: t('Name'),
+ sort: true
+ });
+ detailed_column_list.push({
+ dataField: 'space',
+ text: t('Space'),
+ sort: true
+ });
+ json['energycategories'].forEach((currentValue, index) => {
+ detailed_column_list.push({
+ dataField: 'a' + index,
+ text: currentValue['name'] + ' (' + currentValue['unit_of_measure'] + ')',
+ sort: true
+ })
+ });
+ setDetailedDataTableColumns(detailed_column_list);
+
+ setExcelBytesBase64(json['excel_bytes_base64']);
+
+ // enable submit button
+ setSubmitButtonDisabled(false);
+ // hide spinner
+ setSpinnerHidden(true);
+ // show export buttion
+ setExportButtonHidden(false);
+
+ } else {
+ toast.error(json.description)
+ }
+ }).catch(err => {
+ console.log(err);
+ });
+ };
+
+ const handleExport = e => {
+ e.preventDefault();
+ const mimeType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
+ const fileName = 'equipmentbatch.xlsx'
+ var fileUrl = "data:" + mimeType + ";base64," + excelBytesBase64;
+ fetch(fileUrl)
+ .then(response => response.blob())
+ .then(blob => {
+ var link = window.document.createElement("a");
+ link.href = window.URL.createObjectURL(blob, { type: mimeType });
+ link.download = fileName;
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ });
+ };
+
+
+
+ return (
+
+
+
+ {t('Equipment Data')}{t('Batch Analysis')}
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default withTranslation()(withRedirect(EquipmentBatch));
diff --git a/web/src/layouts/MyEMSRoutes.js b/web/src/layouts/MyEMSRoutes.js
index 5e32bf73..710f3130 100644
--- a/web/src/layouts/MyEMSRoutes.js
+++ b/web/src/layouts/MyEMSRoutes.js
@@ -113,15 +113,16 @@ import SpaceLoad from '../components/MyEMS/Space/SpaceLoad';
import SpaceStatistics from '../components/MyEMS/Space/SpaceStatistics';
import SpaceSaving from '../components/MyEMS/Space/SpaceSaving';
// Equipment
+import EquipmentBatch from '../components/MyEMS/Equipment/EquipmentBatch';
+import EquipmentCost from '../components/MyEMS/Equipment/EquipmentCost';
+import EquipmentEfficiency from '../components/MyEMS/Equipment/EquipmentEfficiency';
import EquipmentEnergyCategory from '../components/MyEMS/Equipment/EquipmentEnergyCategory';
import EquipmentEnergyItem from '../components/MyEMS/Equipment/EquipmentEnergyItem';
-import EquipmentCost from '../components/MyEMS/Equipment/EquipmentCost';
-import EquipmentOutput from '../components/MyEMS/Equipment/EquipmentOutput';
import EquipmentIncome from '../components/MyEMS/Equipment/EquipmentIncome';
-import EquipmentEfficiency from '../components/MyEMS/Equipment/EquipmentEfficiency';
import EquipmentLoad from '../components/MyEMS/Equipment/EquipmentLoad';
-import EquipmentStatistics from '../components/MyEMS/Equipment/EquipmentStatistics';
+import EquipmentOutput from '../components/MyEMS/Equipment/EquipmentOutput';
import EquipmentSaving from '../components/MyEMS/Equipment/EquipmentSaving';
+import EquipmentStatistics from '../components/MyEMS/Equipment/EquipmentStatistics';
import EquipmentTracking from '../components/MyEMS/Equipment/EquipmentTracking';
// Meter
import MeterEnergy from '../components/MyEMS/Meter/MeterEnergy';
@@ -160,16 +161,16 @@ import ShopfloorStatistics from '../components/MyEMS/Shopfloor/ShopfloorStatisti
import ShopfloorSaving from '../components/MyEMS/Shopfloor/ShopfloorSaving';
import ShopfloorBatch from '../components/MyEMS/Shopfloor/ShopfloorBatch';
// CombinedEquipment
+import CombinedEquipmentBatch from '../components/MyEMS/CombinedEquipment/CombinedEquipmentBatch'
+import CombinedEquipmentCost from '../components/MyEMS/CombinedEquipment/CombinedEquipmentCost';
+import CombinedEquipmentEfficiency from '../components/MyEMS/CombinedEquipment/CombinedEquipmentEfficiency';
import CombinedEquipmentEnergyCategory from '../components/MyEMS/CombinedEquipment/CombinedEquipmentEnergyCategory';
import CombinedEquipmentEnergyItem from '../components/MyEMS/CombinedEquipment/CombinedEquipmentEnergyItem';
-import CombinedEquipmentCost from '../components/MyEMS/CombinedEquipment/CombinedEquipmentCost';
-import CombinedEquipmentOutput from '../components/MyEMS/CombinedEquipment/CombinedEquipmentOutput';
-import CombinedEquipmentIncome from '../components/MyEMS/CombinedEquipment/CombinedEquipmentIncome';
-import CombinedEquipmentEfficiency from '../components/MyEMS/CombinedEquipment/CombinedEquipmentEfficiency';
import CombinedEquipmentLoad from '../components/MyEMS/CombinedEquipment/CombinedEquipmentLoad';
-import CombinedEquipmentStatistics from '../components/MyEMS/CombinedEquipment/CombinedEquipmentStatistics';
+import CombinedEquipmentIncome from '../components/MyEMS/CombinedEquipment/CombinedEquipmentIncome';
+import CombinedEquipmentOutput from '../components/MyEMS/CombinedEquipment/CombinedEquipmentOutput';
import CombinedEquipmentSaving from '../components/MyEMS/CombinedEquipment/CombinedEquipmentSaving';
-import CombinedEquipmentBatch from '../components/MyEMS/CombinedEquipment/CombinedEquipmentBatch'
+import CombinedEquipmentStatistics from '../components/MyEMS/CombinedEquipment/CombinedEquipmentStatistics';
// Auxiliary System
import EnergyFlowDiagram from '../components/MyEMS/AuxiliarySystem/EnergyFlowDiagram';
import DistributionSystem from '../components/MyEMS/AuxiliarySystem/DistributionSystem';
@@ -348,15 +349,16 @@ const MyEMSRoutes = () => (
{/*Equipment*/}
+
+
+
-
-
-
-
+
+
{/*Meter*/}
@@ -400,16 +402,16 @@ const MyEMSRoutes = () => (
{/*CombinedEquipment*/}
+
+
+
-
-
-
-
+
-
+
{/*Auxiliary System*/}
diff --git a/web/src/routes.js b/web/src/routes.js
index 11f39327..05fccaba 100644
--- a/web/src/routes.js
+++ b/web/src/routes.js
@@ -349,6 +349,7 @@ export const equipmentRoutes = {
{ to: '/equipment/load', name: 'Load' },
{ to: '/equipment/statistics', name: 'Statistics' },
{ to: '/equipment/saving', name: 'Saving' },
+ { to: '/equipment/batch', name: 'Batch Analysis'},
{ to: '/equipment/tracking', name: 'Equipment Tracking' },
]
};