src/components/MyEMS/CombinedEquipment/CombinedEquipmentEfficiency.js   A
last analyzed

Complexity

Total Complexity 23
Complexity/F 0

Size

Lines of Code 806
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 23
eloc 721
mnd 23
bc 23
fnc 0
dl 0
loc 806
rs 9.879
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import React, { Fragment, useEffect, useState } from 'react';
2
import {
3
  Breadcrumb,
4
  BreadcrumbItem,
5
  Row,
6
  Col,
7
  Card,
8
  CardBody,
9
  Button,
10
  ButtonGroup,
11
  Form,
12
  FormGroup,
13
  Input,
14
  Label,
15
  CustomInput,
16
  Spinner,
17
} from 'reactstrap';
18
import CountUp from 'react-countup';
19
import Datetime from 'react-datetime';
20
import moment from 'moment';
21
import loadable from '@loadable/component';
22
import Cascader from 'rc-cascader';
23
import CardSummary from '../common/CardSummary';
24
import LineChart from '../common/LineChart';
25
import { getCookieValue, createCookie } from '../../../helpers/utils';
26
import withRedirect from '../../../hoc/withRedirect';
27
import { withTranslation } from 'react-i18next';
28
import { periodTypeOptions } from '../common/PeriodTypeOptions';
29
import { comparisonTypeOptions } from '../common/ComparisonTypeOptions';
30
import { toast } from 'react-toastify';
31
import ButtonIcon from '../../common/ButtonIcon';
32
import { APIBaseURL } from '../../../config';
33
34
35
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
36
37
const CombinedEquipmentEfficiency = ({ setRedirect, setRedirectUrl, t }) => {
38
  let current_moment = moment();
39
  useEffect(() => {
40
    let is_logged_in = getCookieValue('is_logged_in');
41
    let user_name = getCookieValue('user_name');
42
    let user_display_name = getCookieValue('user_display_name');
43
    let user_uuid = getCookieValue('user_uuid');
44
    let token = getCookieValue('token');
45
    if (is_logged_in === null || !is_logged_in) {
46
      setRedirectUrl(`/authentication/basic/login`);
47
      setRedirect(true);
48
    } else {
49
      //update expires time of cookies
50
      createCookie('is_logged_in', true, 1000 * 60 * 60 * 8);
51
      createCookie('user_name', user_name, 1000 * 60 * 60 * 8);
52
      createCookie('user_display_name', user_display_name, 1000 * 60 * 60 * 8);
53
      createCookie('user_uuid', user_uuid, 1000 * 60 * 60 * 8);
54
      createCookie('token', token, 1000 * 60 * 60 * 8);
55
    }
56
  });
57
  // State
58
  // Query Parameters
59
  const [selectedSpaceName, setSelectedSpaceName] = useState(undefined);
60
  const [selectedSpaceID, setSelectedSpaceID] = useState(undefined);
61
  const [combinedEquipmentList, setCombinedEquipmentList] = useState([]);
62
  const [selectedCombinedEquipment, setSelectedCombinedEquipment] = useState(undefined);
63
  const [comparisonType, setComparisonType] = useState('month-on-month');
64
  const [periodType, setPeriodType] = useState('daily');
65
  const [basePeriodBeginsDatetime, setBasePeriodBeginsDatetime] = useState(current_moment.clone().subtract(1, 'months').startOf('month'));
66
  const [basePeriodEndsDatetime, setBasePeriodEndsDatetime] = useState(current_moment.clone().subtract(1, 'months'));
67
  const [basePeriodBeginsDatetimeDisabled, setBasePeriodBeginsDatetimeDisabled] = useState(true);
68
  const [basePeriodEndsDatetimeDisabled, setBasePeriodEndsDatetimeDisabled] = useState(true);
69
  const [reportingPeriodBeginsDatetime, setReportingPeriodBeginsDatetime] = useState(current_moment.clone().startOf('month'));
70
  const [reportingPeriodEndsDatetime, setReportingPeriodEndsDatetime] = useState(current_moment);
71
  const [fractionParameter, setFractionParameter] = useState(1);
72
  const [cascaderOptions, setCascaderOptions] = useState(undefined);
73
74
  // buttons
75
  const [submitButtonDisabled, setSubmitButtonDisabled] = useState(true);
76
  const [spinnerHidden, setSpinnerHidden] = useState(true);
77
  const [exportButtonHidden, setExportButtonHidden] = useState(true);
78
  
79
  //Results
80
  const [combinedEquipmentLineChartLabels, setCombinedEquipmentLineChartLabels] = useState([]);
81
  const [combinedEquipmentLineChartData, setCombinedEquipmentLineChartData] = useState({});
82
  const [combinedEquipmentLineChartOptions, setCombinedEquipmentLineChartOptions] = useState([]);
83
84
  const [parameterLineChartLabels, setParameterLineChartLabels] = useState([]);
85
  const [parameterLineChartData, setParameterLineChartData] = useState({});
86
  const [parameterLineChartOptions, setParameterLineChartOptions] = useState([]);
87
88
  const [detailedDataTableData, setDetailedDataTableData] = useState([]);
89
  const [detailedDataTableColumns, setDetailedDataTableColumns] = useState([{dataField: 'startdatetime', text: t('Datetime'), sort: true}]);
90
  const [excelBytesBase64, setExcelBytesBase64] = useState(undefined);
91
92
  useEffect(() => {
93
    let isResponseOK = false;
94
    fetch(APIBaseURL + '/spaces/tree', {
95
      method: 'GET',
96
      headers: {
97
        "Content-type": "application/json",
98
        "User-UUID": getCookieValue('user_uuid'),
99
        "Token": getCookieValue('token')
100
      },
101
      body: null,
102
103
    }).then(response => {
104
      console.log(response)
105
      if (response.ok) {
106
        isResponseOK = true;
107
      }
108
      return response.json();
109
    }).then(json => {
110
      console.log(json)
111
      if (isResponseOK) {
112
        // rename keys 
113
        json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":'));
114
        setCascaderOptions(json);
115
        setSelectedSpaceName([json[0]].map(o => o.label));
116
        setSelectedSpaceID([json[0]].map(o => o.value));
117
        // get Combined Equipments by root Space ID
118
        let isResponseOK = false;
119
        fetch(APIBaseURL + '/spaces/' + [json[0]].map(o => o.value) + '/combinedequipments', {
120
          method: 'GET',
121
          headers: {
122
            "Content-type": "application/json",
123
            "User-UUID": getCookieValue('user_uuid'),
124
            "Token": getCookieValue('token')
125
          },
126
          body: null,
127
128
        }).then(response => {
129
          if (response.ok) {
130
            isResponseOK = true;
131
          }
132
          return response.json();
133
        }).then(json => {
134
          if (isResponseOK) {
135
            json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":'));
136
            console.log(json);
137
            setCombinedEquipmentList(json[0]);
138
            if (json[0].length > 0) {
139
              setSelectedCombinedEquipment(json[0][0].value);
140
              // enable submit button
141
              setSubmitButtonDisabled(false);
142
            } else {
143
              setSelectedCombinedEquipment(undefined);
144
              // disable submit button
145
              setSubmitButtonDisabled(true);
146
            }
147
          } else {
148
            toast.error(json.description)
149
          }
150
        }).catch(err => {
151
          console.log(err);
152
        });
153
        // end of get Combined Equipments by root Space ID
154
      } else {
155
        toast.error(json.description)
156
      }
157
    }).catch(err => {
158
      console.log(err);
159
    });
160
161
  }, []);
162
163
  const fractionParameterOptions = [
164
    { value: 1, label: '综合能效比EER' },];
165
166
  const labelClasses = 'ls text-uppercase text-600 font-weight-semi-bold mb-0';
167
168
  let onSpaceCascaderChange = (value, selectedOptions) => {
169
    setSelectedSpaceName(selectedOptions.map(o => o.label).join('/'));
170
    setSelectedSpaceID(value[value.length - 1]);
171
172
    let isResponseOK = false;
173
    fetch(APIBaseURL + '/spaces/' + value[value.length - 1] + '/combinedequipments', {
174
      method: 'GET',
175
      headers: {
176
        "Content-type": "application/json",
177
        "User-UUID": getCookieValue('user_uuid'),
178
        "Token": getCookieValue('token')
179
      },
180
      body: null,
181
182
    }).then(response => {
183
      if (response.ok) {
184
        isResponseOK = true;
185
      }
186
      return response.json();
187
    }).then(json => {
188
      if (isResponseOK) {
189
        json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":'));
190
        console.log(json)
191
        setCombinedEquipmentList(json[0]);
192
        if (json[0].length > 0) {
193
          setSelectedCombinedEquipment(json[0][0].value);
194
          // enable submit button
195
          setSubmitButtonDisabled(false);
196
        } else {
197
          setSelectedCombinedEquipment(undefined);
198
          // disable submit button
199
          setSubmitButtonDisabled(true);
200
        }
201
      } else {
202
        toast.error(json.description)
203
      }
204
    }).catch(err => {
205
      console.log(err);
206
    });
207
  }
208
209
210
  let onComparisonTypeChange = ({ target }) => {
211
    console.log(target.value);
212
    setComparisonType(target.value);
213
    if (target.value === 'year-over-year') {
214
      setBasePeriodBeginsDatetimeDisabled(true);
215
      setBasePeriodEndsDatetimeDisabled(true);
216
      setBasePeriodBeginsDatetime(moment(reportingPeriodBeginsDatetime).subtract(1, 'years'));
217
      setBasePeriodEndsDatetime(moment(reportingPeriodEndsDatetime).subtract(1, 'years'));
218
    } else if (target.value === 'month-on-month') {
219
      setBasePeriodBeginsDatetimeDisabled(true);
220
      setBasePeriodEndsDatetimeDisabled(true);
221
      setBasePeriodBeginsDatetime(moment(reportingPeriodBeginsDatetime).subtract(1, 'months'));
222
      setBasePeriodEndsDatetime(moment(reportingPeriodEndsDatetime).subtract(1, 'months'));
223
    } else if (target.value === 'free-comparison') {
224
      setBasePeriodBeginsDatetimeDisabled(false);
225
      setBasePeriodEndsDatetimeDisabled(false);
226
    } else if (target.value === 'none-comparison') {
227
      setBasePeriodBeginsDatetime(undefined);
228
      setBasePeriodEndsDatetime(undefined);
229
      setBasePeriodBeginsDatetimeDisabled(true);
230
      setBasePeriodEndsDatetimeDisabled(true);
231
    }
232
  }
233
234
  let onBasePeriodBeginsDatetimeChange = (newDateTime) => {
235
    setBasePeriodBeginsDatetime(newDateTime);
236
  }
237
238
  let onBasePeriodEndsDatetimeChange = (newDateTime) => {
239
    setBasePeriodEndsDatetime(newDateTime);
240
  }
241
242
  let onReportingPeriodBeginsDatetimeChange = (newDateTime) => {
243
    setReportingPeriodBeginsDatetime(newDateTime);
244
    if (comparisonType === 'year-over-year') {
245
      setBasePeriodBeginsDatetime(newDateTime.clone().subtract(1, 'years'));
246
    } else if (comparisonType === 'month-on-month') {
247
      setBasePeriodBeginsDatetime(newDateTime.clone().subtract(1, 'months'));
248
    }
249
  }
250
251
  let onReportingPeriodEndsDatetimeChange = (newDateTime) => {
252
    setReportingPeriodEndsDatetime(newDateTime);
253
    if (comparisonType === 'year-over-year') {
254
      setBasePeriodEndsDatetime(newDateTime.clone().subtract(1, 'years'));
255
    } else if (comparisonType === 'month-on-month') {
256
      setBasePeriodEndsDatetime(newDateTime.clone().subtract(1, 'months'));
257
    }
258
  }
259
260
  var getValidBasePeriodBeginsDatetimes = function (currentDate) {
261
    return currentDate.isBefore(moment(basePeriodEndsDatetime, 'MM/DD/YYYY, hh:mm:ss a'));
262
  }
263
264
  var getValidBasePeriodEndsDatetimes = function (currentDate) {
265
    return currentDate.isAfter(moment(basePeriodBeginsDatetime, 'MM/DD/YYYY, hh:mm:ss a'));
266
  }
267
268
  var getValidReportingPeriodBeginsDatetimes = function (currentDate) {
269
    return currentDate.isBefore(moment(reportingPeriodEndsDatetime, 'MM/DD/YYYY, hh:mm:ss a'));
270
  }
271
272
  var getValidReportingPeriodEndsDatetimes = function (currentDate) {
273
    return currentDate.isAfter(moment(reportingPeriodBeginsDatetime, 'MM/DD/YYYY, hh:mm:ss a'));
274
  }
275
276
  // Handler
277
  const handleSubmit = e => {
278
    e.preventDefault();
279
    console.log('handleSubmit');
280
    console.log(selectedSpaceID);
281
    console.log(selectedCombinedEquipment);
282
    console.log(periodType);
283
    console.log(basePeriodBeginsDatetime != null ? basePeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') : undefined);
284
    console.log(basePeriodEndsDatetime != null ? basePeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss') : undefined);
285
    console.log(reportingPeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss'));
286
    console.log(reportingPeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss'));
287
288
    // disable submit button
289
    setSubmitButtonDisabled(true);
290
    // show spinner
291
    setSpinnerHidden(false);
292
    // hide export buttion
293
    setExportButtonHidden(true)
294
295
    // Reinitialize tables
296
    setDetailedDataTableData([]);
297
    
298
    let isResponseOK = false;
299
    fetch(APIBaseURL + '/reports/combinedequipmentefficiency?' +
300
      'combinedequipmentid=' + selectedCombinedEquipment +
301
      '&fractionparameterid=' + fractionParameter +
302
      '&periodtype=' + periodType +
303
      '&baseperiodstartdatetime=' + (basePeriodBeginsDatetime != null ? basePeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') : '') +
304
      '&baseperiodenddatetime=' + (basePeriodEndsDatetime != null ? basePeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss') : '') +
305
      '&reportingperiodstartdatetime=' + reportingPeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') +
306
      '&reportingperiodenddatetime=' + reportingPeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss'), {
307
      method: 'GET',
308
      headers: {
309
        "Content-type": "application/json",
310
        "User-UUID": getCookieValue('user_uuid'),
311
        "Token": getCookieValue('token')
312
      },
313
      body: null,
314
315
    }).then(response => {
316
      if (response.ok) {
317
        isResponseOK = true;
318
      };
319
      return response.json();
320
    }).then(json => {
321
      if (isResponseOK) {
322
        console.log(json)
323
              
324
        setCombinedEquipmentLineChartLabels({
325
          a0: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
326
          a1: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
327
          a2: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
328
          a3: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
329
        });
330
331
        setCombinedEquipmentLineChartData({
332
          a0: [4, 1, 6, 2, 7, 12, 4, 6, 5, 4, 5, 10],
333
          a1: [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8],
334
          a2: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2],
335
          a3: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2]
336
        });
337
338
        setCombinedEquipmentLineChartOptions([
339
          { value: 'a', label: '综合能效比EER' },
340
        ]);
341
        
342
        setParameterLineChartLabels({
343
          a0: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
344
          a1: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
345
          a2: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
346
          a3: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
347
        });
348
349
        setParameterLineChartData({
350
          a0: [40, 31, 36, 32, 27, 32, 34, 26, 25, 24, 25, 30],
351
          a1: [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8],
352
          a2: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2],
353
          a3: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2],
354
          a4: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2]
355
        });
356
357
        setParameterLineChartOptions([
358
          { value: 'a0', label: '室外温度' },
359
          { value: 'a1', label: '相对湿度' },
360
          { value: 'a2', label: '电费率' },
361
          { value: 'a3', label: '自来水费率' },
362
          { value: 'a4', label: '天然气费率' }
363
        ]);
364
365
        setDetailedDataTableData([
366
          {
367
            id: 1,
368
            startdatetime: '2020-07-01',
369
            a: '9872',
370
            b: '55975',
371
            c: '5.67',
372
          },
373
          {
374
            id: 2,
375
            startdatetime: '2020-07-02',
376
            a: '9872',
377
            b: '55975',
378
            c: '5.67',
379
          },
380
          {
381
            id: 3,
382
            startdatetime: '2020-07-03',
383
            a: '9872',
384
            b: '55975',
385
            c: '5.67',
386
          },
387
          {
388
            id: 4,
389
            startdatetime: '2020-07-04',
390
            a: '9872',
391
            b: '55975',
392
            c: '5.67',
393
          },
394
          {
395
            id: 5,
396
            startdatetime: '2020-07-05',
397
            a: '9872',
398
            b: '55975',
399
            c: '5.67',
400
          },
401
          {
402
            id: 6,
403
            startdatetime: '2020-07-06',
404
            a: '9872',
405
            b: '55975',
406
            c: '5.67',
407
          },
408
          {
409
            id: 7,
410
            startdatetime: '2020-07-07',
411
            a: '9872',
412
            b: '55975',
413
            c: '5.67',
414
          },
415
          {
416
            id: 8,
417
            startdatetime: '2020-07-08',
418
            a: '9872',
419
            b: '55975',
420
            c: '5.67',
421
          },
422
          {
423
            id: 9,
424
            startdatetime: '2020-07-09',
425
            a: '9872',
426
            b: '55975',
427
            c: '5.67',
428
          },
429
          {
430
            id: 10,
431
            startdatetime: '2020-07-10',
432
            a: '9872',
433
            b: '55975',
434
            c: '5.67',
435
          },
436
          {
437
            id: 11,
438
            startdatetime: '2020-07-11',
439
            a: '9872',
440
            b: '55975',
441
            c: '5.67',
442
          },
443
          {
444
            id: 12,
445
            startdatetime: '2020-07-12',
446
            a: '9872',
447
            b: '55975',
448
            c: '5.67',
449
          },
450
          {
451
            id: 13,
452
            startdatetime: t('Total'),
453
            a: '118464',
454
            b: '671700',
455
            c: '5.67',
456
          }
457
        ]);
458
459
        setDetailedDataTableColumns([
460
          {
461
            dataField: 'startdatetime',
462
            text: t('Datetime'),
463
            sort: true
464
          }, {
465
            dataField: 'a',
466
            text: '电 (kWh)',
467
            sort: true
468
          }, {
469
            dataField: 'b',
470
            text: '冷 (kWh)',
471
            sort: true
472
          }, {
473
            dataField: 'c',
474
            text: '综合能效比EER (kWh/kWh)',
475
            sort: true
476
          }
477
        ]);
478
        
479
        setExcelBytesBase64(json['excel_bytes_base64']);
480
481
        // enable submit button
482
        setSubmitButtonDisabled(false);
483
        // hide spinner
484
        setSpinnerHidden(true);
485
        // show export buttion
486
        setExportButtonHidden(false);
487
          
488
      } else {
489
        toast.error(json.description)
490
      }
491
    }).catch(err => {
492
      console.log(err);
493
    });
494
    
495
  };
496
497
  const handleExport = e => {
498
    e.preventDefault();
499
    const mimeType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
500
    const fileName = 'combinedequipmentefficiency.xlsx'
501
    var fileUrl = "data:" + mimeType + ";base64," + excelBytesBase64;
502
    fetch(fileUrl)
503
        .then(response => response.blob())
504
        .then(blob => {
505
            var link = window.document.createElement("a");
506
            link.href = window.URL.createObjectURL(blob, { type: mimeType });
507
            link.download = fileName;
508
            document.body.appendChild(link);
509
            link.click();
510
            document.body.removeChild(link);
511
        });
512
  };
513
  
514
  return (
515
    <Fragment>
516
      <div>
517
        <Breadcrumb>
518
          <BreadcrumbItem>{t('Combined Equipment Data')}</BreadcrumbItem><BreadcrumbItem active>{t('Efficiency')}</BreadcrumbItem>
519
        </Breadcrumb>
520
      </div>
521
      <Card className="bg-light mb-3">
522
        <CardBody className="p-3">
523
          <Form onSubmit={handleSubmit}>
524
            <Row form>
525
              <Col xs="auto">
526
                <FormGroup className="form-group">
527
                  <Label className={labelClasses} for="space">
528
                    {t('Space')}
529
                  </Label>
530
                  <br />
531
                  <Cascader options={cascaderOptions}
532
                    onChange={onSpaceCascaderChange}
533
                    changeOnSelect
534
                    expandTrigger="hover">
535
                    <Input value={selectedSpaceName || ''} readOnly />
536
                  </Cascader>
537
                </FormGroup>
538
              </Col>
539
              <Col xs="auto">
540
                <FormGroup>
541
                  <Label className={labelClasses} for="combinedEquipmentSelect">
542
                    {t('Combined Equipment')}
543
                  </Label>
544
                  <CustomInput type="select" id="combinedEquipmentSelect" name="combinedEquipmentSelect" onChange={({ target }) => setSelectedCombinedEquipment(target.value)}
545
                  >
546
                    {combinedEquipmentList.map((combinedEquipment, index) => (
547
                      <option value={combinedEquipment.value} key={combinedEquipment.value}>
548
                        {combinedEquipment.label}
549
                      </option>
550
                    ))}
551
                  </CustomInput>
552
                </FormGroup>
553
              </Col>
554
              <Col xs="auto">
555
                <FormGroup>
556
                  <Label className={labelClasses} for="fractionParameter">
557
                    {t('Fraction Parameter')}
558
                  </Label>
559
                  <CustomInput type="select" id="fractionParameter" name="fractionParameter" value={fractionParameter} onChange={({ target }) => setFractionParameter(target.value)}
560
                  >
561
                    {fractionParameterOptions.map((fractionParameter, index) => (
562
                      <option value={fractionParameter.value} key={fractionParameter.value}>
563
                        {fractionParameter.label}
564
                      </option>
565
                    ))}
566
                  </CustomInput>
567
                </FormGroup>
568
              </Col>
569
              <Col xs="auto">
570
                <FormGroup>
571
                  <Label className={labelClasses} for="comparisonType">
572
                    {t('Comparison Types')}
573
                  </Label>
574
                  <CustomInput type="select" id="comparisonType" name="comparisonType"
575
                    defaultValue="month-on-month"
576
                    onChange={onComparisonTypeChange}
577
                  >
578
                    {comparisonTypeOptions.map((comparisonType, index) => (
579
                      <option value={comparisonType.value} key={comparisonType.value} >
580
                        {t(comparisonType.label)}
581
                      </option>
582
                    ))}
583
                  </CustomInput>
584
                </FormGroup>
585
              </Col>
586
              <Col xs="auto">
587
                <FormGroup>
588
                  <Label className={labelClasses} for="periodType">
589
                    {t('Period Types')}
590
                  </Label>
591
                  <CustomInput type="select" id="periodType" name="periodType" defaultValue="daily" onChange={({ target }) => setPeriodType(target.value)}
592
                  >
593
                    {periodTypeOptions.map((periodType, index) => (
594
                      <option value={periodType.value} key={periodType.value} >
595
                        {t(periodType.label)}
596
                      </option>
597
                    ))}
598
                  </CustomInput>
599
                </FormGroup>
600
              </Col>
601
              <Col xs="auto">
602
                <FormGroup className="form-group">
603
                  <Label className={labelClasses} for="basePeriodBeginsDatetime">
604
                    {t('Base Period Begins')}{t('(Optional)')}
605
                  </Label>
606
                  <Datetime id='basePeriodBeginsDatetime'
607
                    value={basePeriodBeginsDatetime}
608
                    inputProps={{ disabled: basePeriodBeginsDatetimeDisabled }}
609
                    onChange={onBasePeriodBeginsDatetimeChange}
610
                    isValidDate={getValidBasePeriodBeginsDatetimes}
611
                    closeOnSelect={true} />
612
                </FormGroup>
613
              </Col>
614
              <Col xs="auto">
615
                <FormGroup className="form-group">
616
                  <Label className={labelClasses} for="basePeriodEndsDatetime">
617
                    {t('Base Period Ends')}{t('(Optional)')}
618
                  </Label>
619
                  <Datetime id='basePeriodEndsDatetime'
620
                    value={basePeriodEndsDatetime}
621
                    inputProps={{ disabled: basePeriodEndsDatetimeDisabled }}
622
                    onChange={onBasePeriodEndsDatetimeChange}
623
                    isValidDate={getValidBasePeriodEndsDatetimes}
624
                    closeOnSelect={true} />
625
                </FormGroup>
626
              </Col>
627
              <Col xs="auto">
628
                <FormGroup className="form-group">
629
                  <Label className={labelClasses} for="reportingPeriodBeginsDatetime">
630
                    {t('Reporting Period Begins')}
631
                  </Label>
632
                  <Datetime id='reportingPeriodBeginsDatetime'
633
                    value={reportingPeriodBeginsDatetime}
634
                    onChange={onReportingPeriodBeginsDatetimeChange}
635
                    isValidDate={getValidReportingPeriodBeginsDatetimes}
636
                    closeOnSelect={true} />
637
                </FormGroup>
638
              </Col>
639
              <Col xs="auto">
640
                <FormGroup className="form-group">
641
                  <Label className={labelClasses} for="reportingPeriodEndsDatetime">
642
                    {t('Reporting Period Ends')}
643
                  </Label>
644
                  <Datetime id='reportingPeriodEndsDatetime'
645
                    value={reportingPeriodEndsDatetime}
646
                    onChange={onReportingPeriodEndsDatetimeChange}
647
                    isValidDate={getValidReportingPeriodEndsDatetimes}
648
                    closeOnSelect={true} />
649
                </FormGroup>
650
              </Col>
651
              <Col xs="auto">
652
                <FormGroup>
653
                  <br></br>
654
                  <ButtonGroup id="submit">
655
                    <Button color="success" disabled={submitButtonDisabled} >{t('Submit')}</Button>
656
                  </ButtonGroup>
657
                </FormGroup>
658
              </Col>
659
              <Col xs="auto">
660
                <FormGroup>
661
                  <br></br>
662
                  <Spinner color="primary" hidden={spinnerHidden}  />
663
                </FormGroup>
664
              </Col>
665
              <Col xs="auto">
666
                  <br></br>
667
                  <ButtonIcon icon="external-link-alt" transform="shrink-3 down-2" color="falcon-default" 
668
                  hidden={exportButtonHidden}
669
                  onClick={handleExport} >
670
                    {t('Export')}
671
                  </ButtonIcon>
672
              </Col>
673
            </Row>
674
          </Form>
675
        </CardBody>
676
      </Card>
677
      <div className="card-deck">
678
        <CardSummary rate="0.0%" title={t('COMBINED_EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
679
          color="info" >
680
          <CountUp end={32988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
681
        </CardSummary>
682
        <CardSummary rate="0.0%" title={t('COMBINED_EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
683
          color="info" >
684
          <CountUp end={5880.36} duration={2} prefix="" separator="," decimals={2} decimal="." />
685
        </CardSummary>
686
        <CardSummary rate="+2.0%" title={t('COMBINED_EQUIPMENT Reporting Period Cumulative Comprehensive Efficiency UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'UNIT': '(kWh/kWh)' })}
687
          color="warning" >
688
          <CountUp end={32988.833 / 5880.36} duration={2} prefix="" separator="," decimals={2} decimal="." />
689
        </CardSummary>
690
        <CardSummary rate="0.0%" title={t('COMBINED_EQUIPMENT Instantaneous Comprehensive Efficiency UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'UNIT': '(kWh/kWh)' })}
691
          color="warning" >
692
          <CountUp end={32988.833 / 5880.36 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
693
        </CardSummary>
694
      </div>
695
      <div className="card-deck">
696
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷机#1', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
697
          color="info" >
698
          <CountUp end={12988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
699
        </CardSummary>
700
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷机#1', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
701
          color="info" >
702
          <CountUp end={2000} duration={2} prefix="" separator="," decimals={2} decimal="." />
703
        </CardSummary>
704
        <CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷机#1', 'UNIT': '(kWh/kWh)' })}
705
          color="warning" >
706
          <CountUp end={12988.833 / 2000} duration={2} prefix="" separator="," decimals={2} decimal="." />
707
        </CardSummary>
708
        <CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷机#1', 'UNIT': '(kWh/kWh)' })}
709
          color="warning" >
710
          <CountUp end={12988.833 / 2000 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
711
        </CardSummary>
712
      </div>
713
      <div className="card-deck">
714
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷机#2', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
715
          color="info" >
716
          <CountUp end={22988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
717
        </CardSummary>
718
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷机#2', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
719
          color="info" >
720
          <CountUp end={3000} duration={2} prefix="" separator="," decimals={2} decimal="." />
721
        </CardSummary>
722
        <CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷机#2', 'UNIT': '(kWh/kWh)' })}
723
          color="warning" >
724
          <CountUp end={22988.833 / 3000} duration={2} prefix="" separator="," decimals={2} decimal="." />
725
        </CardSummary>
726
        <CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷机#2', 'UNIT': '(kWh/kWh)' })}
727
          color="warning" >
728
          <CountUp end={22988.833 / 3000 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
729
        </CardSummary>
730
      </div>
731
      <div className="card-deck">
732
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷冻泵', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
733
          color="info" >
734
          <CountUp end={32988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
735
        </CardSummary>
736
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷冻泵', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
737
          color="info" >
738
          <CountUp end={200} duration={2} prefix="" separator="," decimals={2} decimal="." />
739
        </CardSummary>
740
        <CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷冻泵', 'UNIT': '(kWh/kWh)' })}
741
          color="warning" >
742
          <CountUp end={32988.833 / 200} duration={2} prefix="" separator="," decimals={2} decimal="." />
743
        </CardSummary>
744
        <CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷冻泵', 'UNIT': '(kWh/kWh)' })}
745
          color="warning" >
746
          <CountUp end={32988.833 / 200 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
747
        </CardSummary>
748
      </div>
749
      <div className="card-deck">
750
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷却泵', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
751
          color="info" >
752
          <CountUp end={32988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
753
        </CardSummary>
754
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷却泵', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
755
          color="info" >
756
          <CountUp end={300} duration={2} prefix="" separator="," decimals={2} decimal="." />
757
        </CardSummary>
758
        <CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷却泵', 'UNIT': '(kWh/kWh)' })}
759
          color="warning" >
760
          <CountUp end={32988.833 / 300} duration={2} prefix="" separator="," decimals={2} decimal="." />
761
        </CardSummary>
762
        <CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷却泵', 'UNIT': '(kWh/kWh)' })}
763
          color="warning" >
764
          <CountUp end={32988.833 / 300 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
765
        </CardSummary>
766
      </div>
767
      <div className="card-deck">
768
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷却塔', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
769
          color="info" >
770
          <CountUp end={32988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
771
        </CardSummary>
772
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷却塔', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
773
          color="info" >
774
          <CountUp end={380.36} duration={2} prefix="" separator="," decimals={2} decimal="." />
775
        </CardSummary>
776
        <CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷却塔', 'UNIT': '(kWh/kWh)' })}
777
          color="warning" >
778
          <CountUp end={32988.833 / 380.36} duration={2} prefix="" separator="," decimals={2} decimal="." />
779
        </CardSummary>
780
        <CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷却塔', 'UNIT': '(kWh/kWh)' })}
781
          color="warning" >
782
          <CountUp end={32988.833 / 380.36 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
783
        </CardSummary>
784
      </div>
785
      <LineChart reportingTitle={t('COMBINED_EQUIPMENT Reporting Period Cumulative Comprehensive Efficiency VALUE UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'VALUE': 5.609, 'UNIT': '(kWh/kWh)' })}
786
        baseTitle={t('COMBINED_EQUIPMENT Base Period Cumulative Comprehensive Efficiency VALUE UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'VALUE': 4.321, 'UNIT': '(kWh/kWh)' })}
787
        labels={combinedEquipmentLineChartLabels}
788
        data={combinedEquipmentLineChartData}
789
        options={combinedEquipmentLineChartOptions}>
790
      </LineChart>
791
      <LineChart reportingTitle={t('Related Parameters')}
792
        baseTitle=''
793
        labels={parameterLineChartLabels}
794
        data={parameterLineChartData}
795
        options={parameterLineChartOptions}>
796
      </LineChart>
797
      <br />
798
      <DetailedDataTable data={detailedDataTableData} title={t('Detailed Data')} columns={detailedDataTableColumns} pagesize={50} >
799
      </DetailedDataTable>
800
801
    </Fragment>
802
  );
803
};
804
805
export default withTranslation()(withRedirect(CombinedEquipmentEfficiency));
806