Passed
Push — master ( 3cf56c...4a4ccf )
by Guangyu
04:43 queued 10s
created

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

Complexity

Total Complexity 23
Complexity/F 0

Size

Lines of Code 807
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 807
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
320
      // enable submit button
321
      setSubmitButtonDisabled(false);
322
      // hide spinner
323
      setSpinnerHidden(true);
324
      // show export buttion
325
      setExportButtonHidden(false)
326
    
327
      return response.json();
328
    }).then(json => {
329
      if (isResponseOK) {
330
        console.log(json)
331
              
332
        setCombinedEquipmentLineChartLabels({
333
          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'],
334
          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'],
335
          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'],
336
          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'],
337
        });
338
339
        setCombinedEquipmentLineChartData({
340
          a0: [4, 1, 6, 2, 7, 12, 4, 6, 5, 4, 5, 10],
341
          a1: [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8],
342
          a2: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2],
343
          a3: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2]
344
        });
345
346
        setCombinedEquipmentLineChartOptions([
347
          { value: 'a', label: '综合能效比EER' },
348
        ]);
349
        
350
        setParameterLineChartLabels({
351
          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'],
352
          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'],
353
          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'],
354
          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'],
355
        });
356
357
        setParameterLineChartData({
358
          a0: [40, 31, 36, 32, 27, 32, 34, 26, 25, 24, 25, 30],
359
          a1: [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8],
360
          a2: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2],
361
          a3: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2],
362
          a4: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2]
363
        });
364
365
        setParameterLineChartOptions([
366
          { value: 'a0', label: '室外温度' },
367
          { value: 'a1', label: '相对湿度' },
368
          { value: 'a2', label: '电费率' },
369
          { value: 'a3', label: '自来水费率' },
370
          { value: 'a4', label: '天然气费率' }
371
        ]);
372
373
        setDetailedDataTableData([
374
          {
375
            id: 1,
376
            startdatetime: '2020-07-01',
377
            a: '9872',
378
            b: '55975',
379
            c: '5.67',
380
          },
381
          {
382
            id: 2,
383
            startdatetime: '2020-07-02',
384
            a: '9872',
385
            b: '55975',
386
            c: '5.67',
387
          },
388
          {
389
            id: 3,
390
            startdatetime: '2020-07-03',
391
            a: '9872',
392
            b: '55975',
393
            c: '5.67',
394
          },
395
          {
396
            id: 4,
397
            startdatetime: '2020-07-04',
398
            a: '9872',
399
            b: '55975',
400
            c: '5.67',
401
          },
402
          {
403
            id: 5,
404
            startdatetime: '2020-07-05',
405
            a: '9872',
406
            b: '55975',
407
            c: '5.67',
408
          },
409
          {
410
            id: 6,
411
            startdatetime: '2020-07-06',
412
            a: '9872',
413
            b: '55975',
414
            c: '5.67',
415
          },
416
          {
417
            id: 7,
418
            startdatetime: '2020-07-07',
419
            a: '9872',
420
            b: '55975',
421
            c: '5.67',
422
          },
423
          {
424
            id: 8,
425
            startdatetime: '2020-07-08',
426
            a: '9872',
427
            b: '55975',
428
            c: '5.67',
429
          },
430
          {
431
            id: 9,
432
            startdatetime: '2020-07-09',
433
            a: '9872',
434
            b: '55975',
435
            c: '5.67',
436
          },
437
          {
438
            id: 10,
439
            startdatetime: '2020-07-10',
440
            a: '9872',
441
            b: '55975',
442
            c: '5.67',
443
          },
444
          {
445
            id: 11,
446
            startdatetime: '2020-07-11',
447
            a: '9872',
448
            b: '55975',
449
            c: '5.67',
450
          },
451
          {
452
            id: 12,
453
            startdatetime: '2020-07-12',
454
            a: '9872',
455
            b: '55975',
456
            c: '5.67',
457
          },
458
          {
459
            id: 13,
460
            startdatetime: t('Total'),
461
            a: '118464',
462
            b: '671700',
463
            c: '5.67',
464
          }
465
        ]);
466
467
        setDetailedDataTableColumns([
468
          {
469
            dataField: 'startdatetime',
470
            text: t('Datetime'),
471
            sort: true
472
          }, {
473
            dataField: 'a',
474
            text: '电 (kWh)',
475
            sort: true
476
          }, {
477
            dataField: 'b',
478
            text: '冷 (kWh)',
479
            sort: true
480
          }, {
481
            dataField: 'c',
482
            text: '综合能效比EER (kWh/kWh)',
483
            sort: true
484
          }
485
        ]);
486
        
487
        setExcelBytesBase64(json['excel_bytes_base64']);
488
489
      } else {
490
        toast.error(json.description)
491
      }
492
    }).catch(err => {
493
      console.log(err);
494
    });
495
    
496
  };
497
498
  const handleExport = e => {
499
    e.preventDefault();
500
    const mimeType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
501
    const fileName = 'combinedequipmentefficiency.xlsx'
502
    var fileUrl = "data:" + mimeType + ";base64," + excelBytesBase64;
503
    fetch(fileUrl)
504
        .then(response => response.blob())
505
        .then(blob => {
506
            var link = window.document.createElement("a");
507
            link.href = window.URL.createObjectURL(blob, { type: mimeType });
508
            link.download = fileName;
509
            document.body.appendChild(link);
510
            link.click();
511
            document.body.removeChild(link);
512
        });
513
  };
514
  
515
  return (
516
    <Fragment>
517
      <div>
518
        <Breadcrumb>
519
          <BreadcrumbItem>{t('Combined Equipment Data')}</BreadcrumbItem><BreadcrumbItem active>{t('Efficiency')}</BreadcrumbItem>
520
        </Breadcrumb>
521
      </div>
522
      <Card className="bg-light mb-3">
523
        <CardBody className="p-3">
524
          <Form onSubmit={handleSubmit}>
525
            <Row form>
526
              <Col xs="auto">
527
                <FormGroup className="form-group">
528
                  <Label className={labelClasses} for="space">
529
                    {t('Space')}
530
                  </Label>
531
                  <br />
532
                  <Cascader options={cascaderOptions}
533
                    onChange={onSpaceCascaderChange}
534
                    changeOnSelect
535
                    expandTrigger="hover">
536
                    <Input value={selectedSpaceName || ''} readOnly />
537
                  </Cascader>
538
                </FormGroup>
539
              </Col>
540
              <Col xs="auto">
541
                <FormGroup>
542
                  <Label className={labelClasses} for="combinedEquipmentSelect">
543
                    {t('Combined Equipment')}
544
                  </Label>
545
                  <CustomInput type="select" id="combinedEquipmentSelect" name="combinedEquipmentSelect" onChange={({ target }) => setSelectedCombinedEquipment(target.value)}
546
                  >
547
                    {combinedEquipmentList.map((combinedEquipment, index) => (
548
                      <option value={combinedEquipment.value} key={combinedEquipment.value}>
549
                        {combinedEquipment.label}
550
                      </option>
551
                    ))}
552
                  </CustomInput>
553
                </FormGroup>
554
              </Col>
555
              <Col xs="auto">
556
                <FormGroup>
557
                  <Label className={labelClasses} for="fractionParameter">
558
                    {t('Fraction Parameter')}
559
                  </Label>
560
                  <CustomInput type="select" id="fractionParameter" name="fractionParameter" value={fractionParameter} onChange={({ target }) => setFractionParameter(target.value)}
561
                  >
562
                    {fractionParameterOptions.map((fractionParameter, index) => (
563
                      <option value={fractionParameter.value} key={fractionParameter.value}>
564
                        {fractionParameter.label}
565
                      </option>
566
                    ))}
567
                  </CustomInput>
568
                </FormGroup>
569
              </Col>
570
              <Col xs="auto">
571
                <FormGroup>
572
                  <Label className={labelClasses} for="comparisonType">
573
                    {t('Comparison Types')}
574
                  </Label>
575
                  <CustomInput type="select" id="comparisonType" name="comparisonType"
576
                    defaultValue="month-on-month"
577
                    onChange={onComparisonTypeChange}
578
                  >
579
                    {comparisonTypeOptions.map((comparisonType, index) => (
580
                      <option value={comparisonType.value} key={comparisonType.value} >
581
                        {t(comparisonType.label)}
582
                      </option>
583
                    ))}
584
                  </CustomInput>
585
                </FormGroup>
586
              </Col>
587
              <Col xs="auto">
588
                <FormGroup>
589
                  <Label className={labelClasses} for="periodType">
590
                    {t('Period Types')}
591
                  </Label>
592
                  <CustomInput type="select" id="periodType" name="periodType" defaultValue="daily" onChange={({ target }) => setPeriodType(target.value)}
593
                  >
594
                    {periodTypeOptions.map((periodType, index) => (
595
                      <option value={periodType.value} key={periodType.value} >
596
                        {t(periodType.label)}
597
                      </option>
598
                    ))}
599
                  </CustomInput>
600
                </FormGroup>
601
              </Col>
602
              <Col xs="auto">
603
                <FormGroup className="form-group">
604
                  <Label className={labelClasses} for="basePeriodBeginsDatetime">
605
                    {t('Base Period Begins')}{t('(Optional)')}
606
                  </Label>
607
                  <Datetime id='basePeriodBeginsDatetime'
608
                    value={basePeriodBeginsDatetime}
609
                    inputProps={{ disabled: basePeriodBeginsDatetimeDisabled }}
610
                    onChange={onBasePeriodBeginsDatetimeChange}
611
                    isValidDate={getValidBasePeriodBeginsDatetimes}
612
                    closeOnSelect={true} />
613
                </FormGroup>
614
              </Col>
615
              <Col xs="auto">
616
                <FormGroup className="form-group">
617
                  <Label className={labelClasses} for="basePeriodEndsDatetime">
618
                    {t('Base Period Ends')}{t('(Optional)')}
619
                  </Label>
620
                  <Datetime id='basePeriodEndsDatetime'
621
                    value={basePeriodEndsDatetime}
622
                    inputProps={{ disabled: basePeriodEndsDatetimeDisabled }}
623
                    onChange={onBasePeriodEndsDatetimeChange}
624
                    isValidDate={getValidBasePeriodEndsDatetimes}
625
                    closeOnSelect={true} />
626
                </FormGroup>
627
              </Col>
628
              <Col xs="auto">
629
                <FormGroup className="form-group">
630
                  <Label className={labelClasses} for="reportingPeriodBeginsDatetime">
631
                    {t('Reporting Period Begins')}
632
                  </Label>
633
                  <Datetime id='reportingPeriodBeginsDatetime'
634
                    value={reportingPeriodBeginsDatetime}
635
                    onChange={onReportingPeriodBeginsDatetimeChange}
636
                    isValidDate={getValidReportingPeriodBeginsDatetimes}
637
                    closeOnSelect={true} />
638
                </FormGroup>
639
              </Col>
640
              <Col xs="auto">
641
                <FormGroup className="form-group">
642
                  <Label className={labelClasses} for="reportingPeriodEndsDatetime">
643
                    {t('Reporting Period Ends')}
644
                  </Label>
645
                  <Datetime id='reportingPeriodEndsDatetime'
646
                    value={reportingPeriodEndsDatetime}
647
                    onChange={onReportingPeriodEndsDatetimeChange}
648
                    isValidDate={getValidReportingPeriodEndsDatetimes}
649
                    closeOnSelect={true} />
650
                </FormGroup>
651
              </Col>
652
              <Col xs="auto">
653
                <FormGroup>
654
                  <br></br>
655
                  <ButtonGroup id="submit">
656
                    <Button color="success" disabled={submitButtonDisabled} >{t('Submit')}</Button>
657
                  </ButtonGroup>
658
                </FormGroup>
659
              </Col>
660
              <Col xs="auto">
661
                <FormGroup>
662
                  <br></br>
663
                  <Spinner color="primary" hidden={spinnerHidden}  />
664
                </FormGroup>
665
              </Col>
666
              <Col xs="auto">
667
                  <br></br>
668
                  <ButtonIcon icon="external-link-alt" transform="shrink-3 down-2" color="falcon-default" 
669
                  hidden={exportButtonHidden}
670
                  onClick={handleExport} >
671
                    {t('Export')}
672
                  </ButtonIcon>
673
              </Col>
674
            </Row>
675
          </Form>
676
        </CardBody>
677
      </Card>
678
      <div className="card-deck">
679
        <CardSummary rate="0.0%" title={t('COMBINED_EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
680
          color="info" >
681
          <CountUp end={32988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
682
        </CardSummary>
683
        <CardSummary rate="0.0%" title={t('COMBINED_EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
684
          color="info" >
685
          <CountUp end={5880.36} duration={2} prefix="" separator="," decimals={2} decimal="." />
686
        </CardSummary>
687
        <CardSummary rate="+2.0%" title={t('COMBINED_EQUIPMENT Reporting Period Cumulative Comprehensive Efficiency UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'UNIT': '(kWh/kWh)' })}
688
          color="warning" >
689
          <CountUp end={32988.833 / 5880.36} duration={2} prefix="" separator="," decimals={2} decimal="." />
690
        </CardSummary>
691
        <CardSummary rate="0.0%" title={t('COMBINED_EQUIPMENT Instantaneous Comprehensive Efficiency UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'UNIT': '(kWh/kWh)' })}
692
          color="warning" >
693
          <CountUp end={32988.833 / 5880.36 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
694
        </CardSummary>
695
      </div>
696
      <div className="card-deck">
697
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷机#1', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
698
          color="info" >
699
          <CountUp end={12988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
700
        </CardSummary>
701
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷机#1', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
702
          color="info" >
703
          <CountUp end={2000} duration={2} prefix="" separator="," decimals={2} decimal="." />
704
        </CardSummary>
705
        <CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷机#1', 'UNIT': '(kWh/kWh)' })}
706
          color="warning" >
707
          <CountUp end={12988.833 / 2000} duration={2} prefix="" separator="," decimals={2} decimal="." />
708
        </CardSummary>
709
        <CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷机#1', 'UNIT': '(kWh/kWh)' })}
710
          color="warning" >
711
          <CountUp end={12988.833 / 2000 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
712
        </CardSummary>
713
      </div>
714
      <div className="card-deck">
715
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷机#2', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
716
          color="info" >
717
          <CountUp end={22988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
718
        </CardSummary>
719
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷机#2', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
720
          color="info" >
721
          <CountUp end={3000} duration={2} prefix="" separator="," decimals={2} decimal="." />
722
        </CardSummary>
723
        <CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷机#2', 'UNIT': '(kWh/kWh)' })}
724
          color="warning" >
725
          <CountUp end={22988.833 / 3000} duration={2} prefix="" separator="," decimals={2} decimal="." />
726
        </CardSummary>
727
        <CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷机#2', 'UNIT': '(kWh/kWh)' })}
728
          color="warning" >
729
          <CountUp end={22988.833 / 3000 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
730
        </CardSummary>
731
      </div>
732
      <div className="card-deck">
733
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷冻泵', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
734
          color="info" >
735
          <CountUp end={32988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
736
        </CardSummary>
737
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷冻泵', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
738
          color="info" >
739
          <CountUp end={200} duration={2} prefix="" separator="," decimals={2} decimal="." />
740
        </CardSummary>
741
        <CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷冻泵', 'UNIT': '(kWh/kWh)' })}
742
          color="warning" >
743
          <CountUp end={32988.833 / 200} duration={2} prefix="" separator="," decimals={2} decimal="." />
744
        </CardSummary>
745
        <CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷冻泵', 'UNIT': '(kWh/kWh)' })}
746
          color="warning" >
747
          <CountUp end={32988.833 / 200 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
748
        </CardSummary>
749
      </div>
750
      <div className="card-deck">
751
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷却泵', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
752
          color="info" >
753
          <CountUp end={32988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
754
        </CardSummary>
755
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷却泵', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
756
          color="info" >
757
          <CountUp end={300} duration={2} prefix="" separator="," decimals={2} decimal="." />
758
        </CardSummary>
759
        <CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷却泵', 'UNIT': '(kWh/kWh)' })}
760
          color="warning" >
761
          <CountUp end={32988.833 / 300} duration={2} prefix="" separator="," decimals={2} decimal="." />
762
        </CardSummary>
763
        <CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷却泵', 'UNIT': '(kWh/kWh)' })}
764
          color="warning" >
765
          <CountUp end={32988.833 / 300 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
766
        </CardSummary>
767
      </div>
768
      <div className="card-deck">
769
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Output CATEGORY UNIT', { 'EQUIPMENT': '冷却塔', 'CATEGORY': '冷', 'UNIT': '(kWh)' })}
770
          color="info" >
771
          <CountUp end={32988.833} duration={2} prefix="" separator="," decimals={2} decimal="." />
772
        </CardSummary>
773
        <CardSummary rate="0.0%" title={t('EQUIPMENT Reporting Period Consumption CATEGORY UNIT', { 'EQUIPMENT': '冷却塔', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
774
          color="info" >
775
          <CountUp end={380.36} duration={2} prefix="" separator="," decimals={2} decimal="." />
776
        </CardSummary>
777
        <CardSummary rate="+2.0%" title={t('EQUIPMENT Reporting Period Cumulative Efficiency UNIT', { 'EQUIPMENT': '冷却塔', 'UNIT': '(kWh/kWh)' })}
778
          color="warning" >
779
          <CountUp end={32988.833 / 380.36} duration={2} prefix="" separator="," decimals={2} decimal="." />
780
        </CardSummary>
781
        <CardSummary rate="0.0%" title={t('EQUIPMENT Instantaneous Efficiency UNIT', { 'EQUIPMENT': '冷却塔', 'UNIT': '(kWh/kWh)' })}
782
          color="warning" >
783
          <CountUp end={32988.833 / 380.36 + 1} duration={2} prefix="" separator="," decimals={2} decimal="." />
784
        </CardSummary>
785
      </div>
786
      <LineChart reportingTitle={t('COMBINED_EQUIPMENT Reporting Period Cumulative Comprehensive Efficiency VALUE UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'VALUE': 5.609, 'UNIT': '(kWh/kWh)' })}
787
        baseTitle={t('COMBINED_EQUIPMENT Base Period Cumulative Comprehensive Efficiency VALUE UNIT', { 'COMBINED_EQUIPMENT': '冷站', 'VALUE': 4.321, 'UNIT': '(kWh/kWh)' })}
788
        labels={combinedEquipmentLineChartLabels}
789
        data={combinedEquipmentLineChartData}
790
        options={combinedEquipmentLineChartOptions}>
791
      </LineChart>
792
      <LineChart reportingTitle={t('Related Parameters')}
793
        baseTitle=''
794
        labels={parameterLineChartLabels}
795
        data={parameterLineChartData}
796
        options={parameterLineChartOptions}>
797
      </LineChart>
798
      <br />
799
      <DetailedDataTable data={detailedDataTableData} title={t('Detailed Data')} columns={detailedDataTableColumns} pagesize={50} >
800
      </DetailedDataTable>
801
802
    </Fragment>
803
  );
804
};
805
806
export default withTranslation()(withRedirect(CombinedEquipmentEfficiency));
807